annotate src/prpl.c @ 4917:c0c6efda8151

[gaim-migrate @ 5251] Note: Although sometimes it seems as if I'm just ignoring patches for no good reason, sometimes I'm ignoring them for good reasons. Either way, I tend not to appreciate people going over my head to get them committed. Thank you. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Mon, 31 Mar 2003 07:51:01 +0000
parents f7150929332b
children 54cd43869333
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
981
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /*
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 * gaim
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 *
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 *
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 * (at your option) any later version.
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 *
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 * GNU General Public License for more details.
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 *
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 *
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 */
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21
2417
5473c8c5378d [gaim-migrate @ 2430]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2403
diff changeset
22 #include "gaim.h"
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
23 #include "gtkutils.h"
981
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 #include "prpl.h"
2050
ddd696ccb46b [gaim-migrate @ 2060]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2007
diff changeset
25 #include <sys/types.h>
ddd696ccb46b [gaim-migrate @ 2060]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2007
diff changeset
26 #include <sys/stat.h>
ddd696ccb46b [gaim-migrate @ 2060]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2007
diff changeset
27 #include <unistd.h>
4235
cba92ec56248 [gaim-migrate @ 4481]
Mark Doliner <mark@kingant.net>
parents: 4162
diff changeset
28 #include <string.h>
4802
5b24e8e52e4a [gaim-migrate @ 5122]
Nathan Walp <nwalp@pidgin.im>
parents: 4799
diff changeset
29 #include <errno.h>
1000
91b7377e7b45 [gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 981
diff changeset
30
3738
10a60faad8d7 [gaim-migrate @ 3876]
Rob Flynn <gaim@robflynn.com>
parents: 3733
diff changeset
31 #ifdef _WIN32
10a60faad8d7 [gaim-migrate @ 3876]
Rob Flynn <gaim@robflynn.com>
parents: 3733
diff changeset
32 #include "win32dep.h"
10a60faad8d7 [gaim-migrate @ 3876]
Rob Flynn <gaim@robflynn.com>
parents: 3733
diff changeset
33 #endif
10a60faad8d7 [gaim-migrate @ 3876]
Rob Flynn <gaim@robflynn.com>
parents: 3733
diff changeset
34
1064
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
35 #include "pixmaps/ok.xpm"
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
36 #include "pixmaps/cancel.xpm"
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
37 #include "pixmaps/tb_forward.xpm"
1064
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
38
981
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 GSList *protocols = NULL;
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40
1499
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
41 GtkWidget *protomenu = NULL;
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
42 int prpl_accounts[PROTO_UNTAKEN];
1499
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
43
1500
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
44 struct _prompt {
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
45 GtkWidget *window;
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
46 GtkWidget *entry;
3466
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
47 void (*doit)(void *, const char *);
1500
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
48 void (*dont)(void *);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
49 void *data;
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
50 };
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
51
4557
53ce3af93edb [gaim-migrate @ 4837]
Christian Hammond <chipx86@chipx86.com>
parents: 4491
diff changeset
52 struct prpl *find_prpl(GaimProtocol type)
981
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 {
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 GSList *e = protocols;
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 struct prpl *r;
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 while (e) {
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 r = (struct prpl *)e->data;
4557
53ce3af93edb [gaim-migrate @ 4837]
Christian Hammond <chipx86@chipx86.com>
parents: 4491
diff changeset
59 if (r->protocol == type)
981
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60 return r;
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 e = e->next;
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62 }
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 return NULL;
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65 }
7e231bc0018a [gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
67 gint proto_compare(struct prpl *a, struct prpl *b)
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1210
diff changeset
68 {
1043
1528d05b3e6b [gaim-migrate @ 1053]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1040
diff changeset
69 /* neg if a before b, 0 if equal, pos if a after b */
1528d05b3e6b [gaim-migrate @ 1053]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1040
diff changeset
70 return a->protocol - b->protocol;
1528d05b3e6b [gaim-migrate @ 1053]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1040
diff changeset
71 }
1528d05b3e6b [gaim-migrate @ 1053]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1040
diff changeset
72
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
73 #ifdef GAIM_PLUGINS
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
74 gboolean load_prpl(struct prpl *p)
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
75 {
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
76 char *(*gaim_prpl_init)(struct prpl *);
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
77 debug_printf("Loading protocol %d\n", p->protocol);
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
78
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
79 if (!p->plug)
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
80 return TRUE;
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
81
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
82 p->plug->handle = g_module_open(p->plug->path, 0);
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
83 if (!p->plug->handle) {
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
84 debug_printf("%s is unloadable: %s\n", p->plug->path, g_module_error());
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
85 return TRUE;
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
86 }
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
87
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
88 if (!g_module_symbol(p->plug->handle, "gaim_prpl_init", (gpointer *)&gaim_prpl_init)) {
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
89 return TRUE;
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
90 }
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
91
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
92 gaim_prpl_init(p);
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
93 return FALSE;
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
94 }
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
95 #endif
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
96
3577
6fe1d751b494 [gaim-migrate @ 3679]
Sean Egan <seanegan@gmail.com>
parents: 3572
diff changeset
97 /* This is used only by static protocols */
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
98 void load_protocol(proto_init pi)
1000
91b7377e7b45 [gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 981
diff changeset
99 {
3577
6fe1d751b494 [gaim-migrate @ 3679]
Sean Egan <seanegan@gmail.com>
parents: 3572
diff changeset
100 struct prpl *p = g_new0(struct prpl, 1);
3390
a5d356cba156 [gaim-migrate @ 3409]
Christian Hammond <chipx86@chipx86.com>
parents: 3382
diff changeset
101
3382
e9a89676d120 [gaim-migrate @ 3401]
Sean Egan <seanegan@gmail.com>
parents: 3281
diff changeset
102 if (p->protocol == PROTO_ICQ)
3577
6fe1d751b494 [gaim-migrate @ 3679]
Sean Egan <seanegan@gmail.com>
parents: 3572
diff changeset
103 do_error_dialog(_("ICQ Protocol detected."),
3427
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3390
diff changeset
104 _("Gaim has loaded the ICQ plugin. This plugin has been deprecated. "
3382
e9a89676d120 [gaim-migrate @ 3401]
Sean Egan <seanegan@gmail.com>
parents: 3281
diff changeset
105 "As such, it was probably not compiled from the same version of the "
e9a89676d120 [gaim-migrate @ 3401]
Sean Egan <seanegan@gmail.com>
parents: 3281
diff changeset
106 "source as this application was, and cannot be guaranteed to work. "
4053
bf443ac50a07 [gaim-migrate @ 4263]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
107 "It is recommended that you use the AIM/ICQ protocol to connect to ICQ"),
3427
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3390
diff changeset
108 GAIM_WARNING);
3577
6fe1d751b494 [gaim-migrate @ 3679]
Sean Egan <seanegan@gmail.com>
parents: 3572
diff changeset
109 pi(p);
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1043
diff changeset
110 protocols = g_slist_insert_sorted(protocols, p, (GCompareFunc)proto_compare);
2204
5014b802eb41 [gaim-migrate @ 2214]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2191
diff changeset
111 regenerate_user_list();
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1043
diff changeset
112 }
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1043
diff changeset
113
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1210
diff changeset
114 void unload_protocol(struct prpl *p)
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1210
diff changeset
115 {
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
116 GList *c;
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
117 struct proto_user_opt *puo;
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
118 if (p->name)
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
119 g_free(p->name);
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
120 c = p->user_opts;
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1043
diff changeset
121 while (c) {
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
122 puo = c->data;
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
123 g_free(puo->label);
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
124 g_free(puo->def);
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
125 g_free(puo);
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
126 c = c->next;
1040
17cea517fd90 [gaim-migrate @ 1050]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1000
diff changeset
127 }
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
128 g_list_free(p->user_opts);
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
129 p->user_opts = NULL;
1000
91b7377e7b45 [gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 981
diff changeset
130 }
91b7377e7b45 [gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 981
diff changeset
131
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2050
diff changeset
132 STATIC_PROTO_INIT
1064
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
133
1252
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1210
diff changeset
134 static void des_win(GtkWidget *a, GtkWidget *b)
46c09828e929 [gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1210
diff changeset
135 {
1064
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
136 gtk_widget_destroy(b);
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
137 }
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
138
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
139 static GSList *do_ask_dialogs = NULL;
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
140
3730
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
141 struct doaskstruct {
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
142 GtkWidget *dialog;
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
143 GModule *handle;
3730
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
144 void (*yesfunc)(gpointer);
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
145 void (*nofunc)(gpointer);
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
146 gpointer data;
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
147 };
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
148
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
149 void do_ask_cancel_by_handle(GModule *handle)
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
150 {
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
151 GSList *d = do_ask_dialogs;
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
152
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
153 debug_printf("%d dialogs to search\n", g_slist_length(d));
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
154
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
155 while (d) {
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
156 struct doaskstruct *doask = d->data;
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
157
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
158 d = d->next;
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
159
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
160 if (doask->handle == handle) {
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
161 debug_printf("removing dialog, %d remain\n", g_slist_length(d));
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
162 gtk_dialog_response(GTK_DIALOG(doask->dialog), GTK_RESPONSE_NONE);
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
163 }
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
164 }
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
165 }
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
166
3730
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
167 static void do_ask_callback(GtkDialog *d, gint resp, struct doaskstruct *doask)
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
168 {
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
169 switch (resp)
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
170 {
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
171 case GTK_RESPONSE_YES:
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
172 if (doask->yesfunc)
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
173 doask->yesfunc(doask->data);
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
174 break;
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
175 default:
3730
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
176 if (doask->nofunc)
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
177 doask->nofunc(doask->data);
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
178 break;
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
179 }
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
180 do_ask_dialogs = g_slist_remove(do_ask_dialogs, doask);
3730
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
181 g_free(doask);
3738
10a60faad8d7 [gaim-migrate @ 3876]
Rob Flynn <gaim@robflynn.com>
parents: 3733
diff changeset
182 gtk_widget_destroy(GTK_WIDGET(d));
3730
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
183 }
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
184
3753
764ecb5f984b [gaim-migrate @ 3892]
Sean Egan <seanegan@gmail.com>
parents: 3738
diff changeset
185 #define STOCK_ITEMIZE(r, l) if (!strcmp(r,yestext)) \
764ecb5f984b [gaim-migrate @ 3892]
Sean Egan <seanegan@gmail.com>
parents: 3738
diff changeset
186 yestext = l; \
764ecb5f984b [gaim-migrate @ 3892]
Sean Egan <seanegan@gmail.com>
parents: 3738
diff changeset
187 if (!strcmp(r,notext)) \
764ecb5f984b [gaim-migrate @ 3892]
Sean Egan <seanegan@gmail.com>
parents: 3738
diff changeset
188 notext = l;
3730
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
189
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
190 void do_ask_dialog(const char *prim, const char *sec, void *data, char *yestext, void *doit, char *notext, void *dont, GModule *handle, gboolean modal)
1064
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
191 {
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
192 GtkWidget *window;
3730
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
193 GtkWidget *hbox;
1064
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
194 GtkWidget *label;
3730
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
195 char labeltext[1024 * 2];
3732
6767b4b1ce31 [gaim-migrate @ 3870]
Sean Egan <seanegan@gmail.com>
parents: 3730
diff changeset
196 char *filename = g_build_filename(DATADIR, "pixmaps", "gaim", "dialogs", "gaim_question.png", NULL);
3730
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
197 GtkWidget *img = gtk_image_new_from_file(filename);
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
198 struct doaskstruct *doask = g_new0(struct doaskstruct, 1);
1064
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
199
3730
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
200 g_free(filename);
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
201 gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
1064
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
202
3753
764ecb5f984b [gaim-migrate @ 3892]
Sean Egan <seanegan@gmail.com>
parents: 3738
diff changeset
203 /* This is ugly. GTK Stock items will take a button with a label "gtk-cancel" and turn it into a
764ecb5f984b [gaim-migrate @ 3892]
Sean Egan <seanegan@gmail.com>
parents: 3738
diff changeset
204 * Cancel button with a Cancel icon and whatnot. We want to avoid using anything gtk in the prpls
764ecb5f984b [gaim-migrate @ 3892]
Sean Egan <seanegan@gmail.com>
parents: 3738
diff changeset
205 * so we replace "Cancel" with "gtk-cancel" right here. */
764ecb5f984b [gaim-migrate @ 3892]
Sean Egan <seanegan@gmail.com>
parents: 3738
diff changeset
206 STOCK_ITEMIZE("Add", GTK_STOCK_ADD);
764ecb5f984b [gaim-migrate @ 3892]
Sean Egan <seanegan@gmail.com>
parents: 3738
diff changeset
207 STOCK_ITEMIZE("Apply", GTK_STOCK_APPLY);
764ecb5f984b [gaim-migrate @ 3892]
Sean Egan <seanegan@gmail.com>
parents: 3738
diff changeset
208 STOCK_ITEMIZE("Cancel", GTK_STOCK_CANCEL);
764ecb5f984b [gaim-migrate @ 3892]
Sean Egan <seanegan@gmail.com>
parents: 3738
diff changeset
209 STOCK_ITEMIZE("Close", GTK_STOCK_CLOSE);
764ecb5f984b [gaim-migrate @ 3892]
Sean Egan <seanegan@gmail.com>
parents: 3738
diff changeset
210 STOCK_ITEMIZE("Delete", GTK_STOCK_DELETE);
764ecb5f984b [gaim-migrate @ 3892]
Sean Egan <seanegan@gmail.com>
parents: 3738
diff changeset
211 STOCK_ITEMIZE("Remove", GTK_STOCK_REMOVE);
764ecb5f984b [gaim-migrate @ 3892]
Sean Egan <seanegan@gmail.com>
parents: 3738
diff changeset
212 STOCK_ITEMIZE("Yes", GTK_STOCK_YES);
764ecb5f984b [gaim-migrate @ 3892]
Sean Egan <seanegan@gmail.com>
parents: 3738
diff changeset
213 STOCK_ITEMIZE("No", GTK_STOCK_NO);
764ecb5f984b [gaim-migrate @ 3892]
Sean Egan <seanegan@gmail.com>
parents: 3738
diff changeset
214
4778
85c6c3a60503 [gaim-migrate @ 5098]
Mark Doliner <mark@kingant.net>
parents: 4777
diff changeset
215 window = gtk_dialog_new_with_buttons("", NULL, 0, notext, GTK_RESPONSE_NO, yestext, GTK_RESPONSE_YES, NULL);
4245
cd84b0fd63fc [gaim-migrate @ 4495]
Rob Flynn <gaim@robflynn.com>
parents: 4235
diff changeset
216
cd84b0fd63fc [gaim-migrate @ 4495]
Rob Flynn <gaim@robflynn.com>
parents: 4235
diff changeset
217 if (modal) {
cd84b0fd63fc [gaim-migrate @ 4495]
Rob Flynn <gaim@robflynn.com>
parents: 4235
diff changeset
218 gtk_window_set_modal(GTK_WINDOW(window), TRUE);
cd84b0fd63fc [gaim-migrate @ 4495]
Rob Flynn <gaim@robflynn.com>
parents: 4235
diff changeset
219 }
cd84b0fd63fc [gaim-migrate @ 4495]
Rob Flynn <gaim@robflynn.com>
parents: 4235
diff changeset
220
3730
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
221 gtk_dialog_set_default_response (GTK_DIALOG(window), GTK_RESPONSE_YES);
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
222 g_signal_connect(G_OBJECT(window), "response", G_CALLBACK(do_ask_callback), doask);
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
223
3730
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
224 gtk_container_set_border_width (GTK_CONTAINER(window), 6);
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
225 gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
226 gtk_dialog_set_has_separator(GTK_DIALOG(window), FALSE);
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
227 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(window)->vbox), 12);
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
228 gtk_container_set_border_width (GTK_CONTAINER(GTK_DIALOG(window)->vbox), 6);
1210
265abea9db72 [gaim-migrate @ 1220]
Rob Flynn <gaim@robflynn.com>
parents: 1064
diff changeset
229
3730
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
230 hbox = gtk_hbox_new(FALSE, 12);
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
231 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(window)->vbox), hbox);
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
232 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
233
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
234 g_snprintf(labeltext, sizeof(labeltext), "<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s", prim, sec ? sec : "");
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
235 label = gtk_label_new(NULL);
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
236 gtk_label_set_markup(GTK_LABEL(label), labeltext);
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
237 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
238 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
239 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
240
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
241 doask->dialog = window;
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
242 doask->handle = handle;
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
243 doask->yesfunc = doit;
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
244 doask->nofunc = dont;
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
245 doask->data = data;
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
246 do_ask_dialogs = g_slist_append(do_ask_dialogs, doask);
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
247
1210
265abea9db72 [gaim-migrate @ 1220]
Rob Flynn <gaim@robflynn.com>
parents: 1064
diff changeset
248 gtk_widget_show_all(window);
1064
b0b40b5faede [gaim-migrate @ 1074]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
249 }
1333
b332d8f46b84 [gaim-migrate @ 1343]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1252
diff changeset
250
1500
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
251 static void des_prompt(GtkWidget *w, struct _prompt *p)
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
252 {
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
253 if (p->dont)
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
254 (p->dont)(p->data);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
255 gtk_widget_destroy(p->window);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
256 g_free(p);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
257 }
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
258
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
259 static void act_prompt(GtkWidget *w, struct _prompt *p)
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
260 {
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
261 if (p->doit)
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
262 (p->doit)(p->data, gtk_entry_get_text(GTK_ENTRY(p->entry)));
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
263 gtk_widget_destroy(p->window);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
264 }
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
265
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
266 void do_prompt_dialog(const char *text, const char *def, void *data, void *doit, void *dont)
1500
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
267 {
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
268 GtkWidget *window;
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
269 GtkWidget *vbox;
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
270 GtkWidget *hbox;
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
271 GtkWidget *label;
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
272 GtkWidget *entry;
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
273 GtkWidget *button;
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
274 struct _prompt *p;
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
275
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
276 p = g_new0(struct _prompt, 1);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
277 p->data = data;
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
278 p->doit = doit;
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
279 p->dont = dont;
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
280
2725
f3c094e78609 [gaim-migrate @ 2738]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2718
diff changeset
281 GAIM_DIALOG(window);
1500
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
282 p->window = window;
4074
3ccbdf8e7f8d [gaim-migrate @ 4289]
Sean Egan <seanegan@gmail.com>
parents: 4053
diff changeset
283 gtk_window_set_role(GTK_WINDOW(window), "prompt");
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4557
diff changeset
284 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
1500
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
285 gtk_window_set_title(GTK_WINDOW(window), _("Gaim - Prompt"));
4162
d3c8d2b40494 [gaim-migrate @ 4391]
Christian Hammond <chipx86@chipx86.com>
parents: 4092
diff changeset
286 g_signal_connect(GTK_OBJECT(window), "destroy", G_CALLBACK(des_prompt), p);
1500
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
287 gtk_widget_realize(window);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
288
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
289 vbox = gtk_vbox_new(FALSE, 5);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
290 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
291 gtk_container_add(GTK_CONTAINER(window), vbox);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
292
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
293 hbox = gtk_hbox_new(FALSE, 5);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
294 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
295
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
296 label = gtk_label_new(text);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
297 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
298
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
299 entry = gtk_entry_new();
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
300 gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0);
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
301 if (def)
2543
830a83209475 [gaim-migrate @ 2556]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2541
diff changeset
302 gtk_entry_set_text(GTK_ENTRY(entry), def);
4162
d3c8d2b40494 [gaim-migrate @ 4391]
Christian Hammond <chipx86@chipx86.com>
parents: 4092
diff changeset
303 g_signal_connect(GTK_OBJECT(entry), "activate", G_CALLBACK(act_prompt), p);
1500
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
304 p->entry = entry;
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
305
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
306 hbox = gtk_hbox_new(FALSE, 5);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
307 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
308
4092
7edd02612086 [gaim-migrate @ 4307]
Luke Schierer <lschiere@pidgin.im>
parents: 4074
diff changeset
309 button = picture_button(window, _("Accept"), ok_xpm);
7edd02612086 [gaim-migrate @ 4307]
Luke Schierer <lschiere@pidgin.im>
parents: 4074
diff changeset
310 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
4162
d3c8d2b40494 [gaim-migrate @ 4391]
Christian Hammond <chipx86@chipx86.com>
parents: 4092
diff changeset
311 g_signal_connect(GTK_OBJECT(button), "clicked", G_CALLBACK(act_prompt), p);
4092
7edd02612086 [gaim-migrate @ 4307]
Luke Schierer <lschiere@pidgin.im>
parents: 4074
diff changeset
312
1500
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
313 button = picture_button(window, _("Cancel"), cancel_xpm);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
314 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
4162
d3c8d2b40494 [gaim-migrate @ 4391]
Christian Hammond <chipx86@chipx86.com>
parents: 4092
diff changeset
315 g_signal_connect(GTK_OBJECT(button), "clicked", G_CALLBACK(des_win), window);
1500
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
316
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
317 gtk_widget_show_all(window);
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
318 }
a054c28735fb [gaim-migrate @ 1510]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
319
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
320 static void proto_act(GtkObject *obj, struct proto_actions_menu *pam)
1499
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
321 {
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
322 if (pam->callback && pam->gc)
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
323 pam->callback(pam->gc);
1499
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
324 }
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
325
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
326 void do_proto_menu()
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
327 {
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
328 GtkWidget *menuitem;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
329 GtkWidget *submenu;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
330 GList *l;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
331 GSList *c = connections;
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
332 struct proto_actions_menu *pam;
1499
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
333 struct gaim_connection *gc = NULL;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
334 int count = 0;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
335 char buf[256];
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
336
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
337 if (!protomenu)
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
338 return;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
339
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4557
diff changeset
340 l = gtk_container_get_children(GTK_CONTAINER(protomenu));
1499
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
341 while (l) {
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
342 menuitem = l->data;
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4557
diff changeset
343 pam = g_object_get_data(G_OBJECT(menuitem), "proto_actions_menu");
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
344 if (pam)
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
345 g_free(pam);
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
346 gtk_container_remove(GTK_CONTAINER(protomenu), GTK_WIDGET(menuitem));
1499
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
347 l = l->next;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
348 }
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
349
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
350 while (c) {
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
351 gc = c->data;
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
352 if (gc->prpl->actions && gc->login_time)
1499
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
353 count++;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
354 c = g_slist_next(c);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
355 }
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
356 c = connections;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
357
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
358 if (!count) {
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
359 g_snprintf(buf, sizeof(buf), _("No actions available"));
1499
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
360 menuitem = gtk_menu_item_new_with_label(buf);
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4557
diff changeset
361 gtk_menu_shell_append(GTK_MENU_SHELL(protomenu), menuitem);
1499
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
362 gtk_widget_show(menuitem);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
363 return;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
364 }
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
365
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
366 if (count == 1) {
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
367 GList *act;
1499
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
368 while (c) {
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
369 gc = c->data;
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
370 if (gc->prpl->actions && gc->login_time)
1499
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
371 break;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
372 c = g_slist_next(c);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
373 }
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
374
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
375 act = gc->prpl->actions(gc);
1499
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
376
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
377 while (act) {
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
378 if (act->data) {
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
379 struct proto_actions_menu *pam = act->data;
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
380 menuitem = gtk_menu_item_new_with_label(pam->label);
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4557
diff changeset
381 gtk_menu_shell_append(GTK_MENU_SHELL(protomenu), menuitem);
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
382 g_signal_connect(GTK_OBJECT(menuitem), "activate",
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
383 G_CALLBACK(proto_act), pam);
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4557
diff changeset
384 g_object_set_data(G_OBJECT(menuitem), "proto_actions_menu", pam);
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
385 gtk_widget_show(menuitem);
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
386 } else {
1499
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
387 gaim_separator(protomenu);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
388 }
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
389 act = g_list_next(act);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
390 }
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
391 } else {
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
392 while (c) {
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
393 GList *act;
1499
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
394 gc = c->data;
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
395 if (!gc->prpl->actions || !gc->login_time) {
1499
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
396 c = g_slist_next(c);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
397 continue;
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
398 }
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
399
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
400 g_snprintf(buf, sizeof(buf), "%s (%s)", gc->username, gc->prpl->name);
1499
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
401 menuitem = gtk_menu_item_new_with_label(buf);
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4557
diff changeset
402 gtk_menu_shell_append(GTK_MENU_SHELL(protomenu), menuitem);
1499
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
403 gtk_widget_show(menuitem);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
404
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
405 submenu = gtk_menu_new();
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
406 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
407 gtk_widget_show(submenu);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
408
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
409 act = gc->prpl->actions(gc);
1499
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
410
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
411 while (act) {
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
412 if (act->data) {
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
413 struct proto_actions_menu *pam = act->data;
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
414 menuitem = gtk_menu_item_new_with_label(pam->label);
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4557
diff changeset
415 gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem);
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
416 g_signal_connect(GTK_OBJECT(menuitem), "activate",
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
417 G_CALLBACK(proto_act), pam);
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4557
diff changeset
418 g_object_set_data(G_OBJECT(menuitem), "proto_actions_menu",
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4557
diff changeset
419 pam);
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
420 gtk_widget_show(menuitem);
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
421 } else {
1536
3a9f11c9278b [gaim-migrate @ 1546]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1530
diff changeset
422 gaim_separator(submenu);
1499
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
423 }
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
424 act = g_list_next(act);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
425 }
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
426 c = g_slist_next(c);
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
427 }
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
428 }
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1470
diff changeset
429 }
2050
ddd696ccb46b [gaim-migrate @ 2060]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2007
diff changeset
430
2401
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
431 struct mail_notify {
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
432 struct gaim_connection *gc;
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
433 GtkWidget *email_win;
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
434 GtkWidget *email_label;
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
435 char *url;
2401
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
436 };
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
437 GSList *mailnots = NULL;
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
438
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
439 static struct mail_notify *find_mail_notify(struct gaim_connection *gc)
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2355
diff changeset
440 {
2401
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
441 GSList *m = mailnots;
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
442 while (m) {
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
443 if (((struct mail_notify *)m->data)->gc == gc)
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
444 return m->data;
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
445 m = m->next;
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
446 }
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
447 return NULL;
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
448 }
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
449
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
450 static void des_email_win(GtkWidget *w, struct mail_notify *mn)
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
451 {
2428
0394552f2aab [gaim-migrate @ 2441]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2417
diff changeset
452 if (w != mn->email_win) {
0394552f2aab [gaim-migrate @ 2441]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2417
diff changeset
453 gtk_widget_destroy(mn->email_win);
0394552f2aab [gaim-migrate @ 2441]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2417
diff changeset
454 return;
0394552f2aab [gaim-migrate @ 2441]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2417
diff changeset
455 }
0394552f2aab [gaim-migrate @ 2441]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2417
diff changeset
456 debug_printf("removing mail notification\n");
2401
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
457 mailnots = g_slist_remove(mailnots, mn);
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
458 if (mn->url)
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
459 g_free(mn->url);
2401
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
460 g_free(mn);
2153
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2151
diff changeset
461 }
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2151
diff changeset
462
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
463 void connection_has_mail(struct gaim_connection *gc, int count, const char *from, const char *subject, const char *url)
2153
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2151
diff changeset
464 {
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
465 GtkWidget *hbox;
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
466 GtkWidget *vbox;
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
467 GtkWidget *urlbut;
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
468 GtkWidget *close;
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
469
2401
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
470 struct mail_notify *mn;
2153
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2151
diff changeset
471 char buf[2048];
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2151
diff changeset
472
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4359
diff changeset
473 if (!(gc->account->options & OPT_ACCT_MAIL_CHECK))
2153
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2151
diff changeset
474 return;
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2151
diff changeset
475
2401
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
476 if (!(mn = find_mail_notify(gc))) {
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
477 mn = g_new0(struct mail_notify, 1);
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
478 mn->gc = gc;
2403
8555e48c02df [gaim-migrate @ 2416]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2401
diff changeset
479 mailnots = g_slist_append(mailnots, mn);
2401
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
480 }
86c9b44a35ae [gaim-migrate @ 2414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2372
diff changeset
481
3694
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents: 3577
diff changeset
482 if (count < 0) {
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents: 3577
diff changeset
483 if (from && subject)
4276
32fcf4cf5f80 [gaim-migrate @ 4527]
Luke Schierer <lschiere@pidgin.im>
parents: 4249
diff changeset
484 g_snprintf(buf, sizeof buf, _("%s has mail from %s: %s"), gc->username, from, *subject ? subject : _("No Subject"));
3694
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents: 3577
diff changeset
485 else
4276
32fcf4cf5f80 [gaim-migrate @ 4527]
Luke Schierer <lschiere@pidgin.im>
parents: 4249
diff changeset
486 g_snprintf(buf, sizeof buf, _("%s has new mail."), gc->username);
3694
e941bfbacf7c [gaim-migrate @ 3824]
Mark Doliner <mark@kingant.net>
parents: 3577
diff changeset
487 } else if (count > 0) {
4276
32fcf4cf5f80 [gaim-migrate @ 4527]
Luke Schierer <lschiere@pidgin.im>
parents: 4249
diff changeset
488 g_snprintf(buf, sizeof buf,
32fcf4cf5f80 [gaim-migrate @ 4527]
Luke Schierer <lschiere@pidgin.im>
parents: 4249
diff changeset
489 ngettext("%s has %d new message.","%s has %d new messages.",count), gc->username, count);
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
490 } else if (mn->email_win) {
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
491 gtk_widget_destroy(mn->email_win);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
492 return;
2606
f00549786a9c [gaim-migrate @ 2619]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2585
diff changeset
493 } else
f00549786a9c [gaim-migrate @ 2619]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2585
diff changeset
494 return;
2153
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2151
diff changeset
495
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
496 if (mn->email_win) {
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
497 gtk_label_set_text(GTK_LABEL(mn->email_label), buf);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
498 return;
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
499 }
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
500
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
501
2725
f3c094e78609 [gaim-migrate @ 2738]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2718
diff changeset
502 GAIM_DIALOG(mn->email_win);
4074
3ccbdf8e7f8d [gaim-migrate @ 4289]
Sean Egan <seanegan@gmail.com>
parents: 4053
diff changeset
503 gtk_window_set_role(GTK_WINDOW(mn->email_win), "mail");
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4557
diff changeset
504 gtk_window_set_resizable(GTK_WINDOW(mn->email_win), TRUE);
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
505 gtk_window_set_title(GTK_WINDOW(mn->email_win), _("Gaim - New Mail"));
4162
d3c8d2b40494 [gaim-migrate @ 4391]
Christian Hammond <chipx86@chipx86.com>
parents: 4092
diff changeset
506 g_signal_connect(GTK_OBJECT(mn->email_win), "destroy", G_CALLBACK(des_email_win), mn);
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
507 gtk_widget_realize(mn->email_win);
2153
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2151
diff changeset
508
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
509 vbox = gtk_vbox_new(FALSE, 5);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
510 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
511 gtk_container_add(GTK_CONTAINER(mn->email_win), vbox);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
512 gtk_widget_show(vbox);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
513
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
514 mn->email_label = gtk_label_new(buf);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
515 gtk_label_set_text(GTK_LABEL(mn->email_label), buf);
3493
4b204c262376 [gaim-migrate @ 3553]
Luke Schierer <lschiere@pidgin.im>
parents: 3474
diff changeset
516 gtk_label_set_line_wrap(GTK_LABEL(mn->email_label), TRUE);
4b204c262376 [gaim-migrate @ 3553]
Luke Schierer <lschiere@pidgin.im>
parents: 3474
diff changeset
517 gtk_box_pack_start(GTK_BOX(vbox), mn->email_label, FALSE, TRUE, 5);
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
518 gtk_widget_show(mn->email_label);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
519
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
520 hbox = gtk_hbox_new(FALSE, 5);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
521 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
522 gtk_widget_show(hbox);
2153
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2151
diff changeset
523
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
524 if (url) {
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
525 mn->url = g_strdup(url);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
526 urlbut = picture_button(mn->email_win, _("Open Mail"), tb_forward_xpm);
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
527 gtk_box_pack_end(GTK_BOX(hbox), urlbut, 0, 0, 5);
4162
d3c8d2b40494 [gaim-migrate @ 4391]
Christian Hammond <chipx86@chipx86.com>
parents: 4092
diff changeset
528 g_signal_connect(GTK_OBJECT(urlbut), "clicked", G_CALLBACK(open_url), mn->url);
d3c8d2b40494 [gaim-migrate @ 4391]
Christian Hammond <chipx86@chipx86.com>
parents: 4092
diff changeset
529 g_signal_connect(GTK_OBJECT(urlbut), "clicked", G_CALLBACK(des_email_win), mn);
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
530 }
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
531
4889
f7150929332b [gaim-migrate @ 5219]
Mark Doliner <mark@kingant.net>
parents: 4802
diff changeset
532 close = picture_button(mn->email_win, _("Close"), cancel_xpm);
f7150929332b [gaim-migrate @ 5219]
Mark Doliner <mark@kingant.net>
parents: 4802
diff changeset
533 gtk_window_set_focus(GTK_WINDOW(mn->email_win), close);
f7150929332b [gaim-migrate @ 5219]
Mark Doliner <mark@kingant.net>
parents: 4802
diff changeset
534 gtk_box_pack_end(GTK_BOX(hbox), close, 0, 0, 5);
f7150929332b [gaim-migrate @ 5219]
Mark Doliner <mark@kingant.net>
parents: 4802
diff changeset
535 g_signal_connect(GTK_OBJECT(close), "clicked", G_CALLBACK(des_email_win), mn);
f7150929332b [gaim-migrate @ 5219]
Mark Doliner <mark@kingant.net>
parents: 4802
diff changeset
536
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2428
diff changeset
537 gtk_widget_show(mn->email_win);
2153
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2151
diff changeset
538 }
2191
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
539
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
540 struct icon_data {
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
541 struct gaim_connection *gc;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
542 char *who;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
543 void *data;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
544 int len;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
545 };
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
546
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
547 static GList *icons = NULL;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
548
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
549 static gint find_icon_data(gconstpointer a, gconstpointer b)
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
550 {
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
551 const struct icon_data *x = a;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
552 const struct icon_data *y = b;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
553
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4778
diff changeset
554 return ((x->gc != y->gc) || gaim_utf8_strcasecmp(x->who, y->who));
2191
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
555 }
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
556
4777
e23a7e166680 [gaim-migrate @ 5097]
Nathan Walp <nwalp@pidgin.im>
parents: 4772
diff changeset
557 void set_icon_data(struct gaim_connection *gc, const char *who, void *data, int len)
2191
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
558 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
559 struct gaim_conversation *conv;
3281
941eb47c5bd4 [gaim-migrate @ 3299]
Sean Egan <seanegan@gmail.com>
parents: 3150
diff changeset
560 struct icon_data tmp;
941eb47c5bd4 [gaim-migrate @ 3299]
Sean Egan <seanegan@gmail.com>
parents: 3150
diff changeset
561 GList *l;
941eb47c5bd4 [gaim-migrate @ 3299]
Sean Egan <seanegan@gmail.com>
parents: 3150
diff changeset
562 struct icon_data *id;
4757
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
563 struct buddy *b;
4799
7fd8a82a7c36 [gaim-migrate @ 5119]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
564 /* i'm going to vent here a little bit about normalize(). normalize()
7fd8a82a7c36 [gaim-migrate @ 5119]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
565 * uses a static buffer, so when we call functions that use normalize() from
7fd8a82a7c36 [gaim-migrate @ 5119]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
566 * functions that use normalize(), whose parameters are the result of running
7fd8a82a7c36 [gaim-migrate @ 5119]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
567 * normalize(), bad things happen. To prevent some of this, we're going
7fd8a82a7c36 [gaim-migrate @ 5119]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
568 * to make a copy of what we get from normalize(), so we know nothing else
7fd8a82a7c36 [gaim-migrate @ 5119]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
569 * touches it, and buddy icons don't go to the wrong person. Some day I
7fd8a82a7c36 [gaim-migrate @ 5119]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
570 * will kill normalize(), and dance on its grave. That will be a very happy
7fd8a82a7c36 [gaim-migrate @ 5119]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
571 * day for everyone.
7fd8a82a7c36 [gaim-migrate @ 5119]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
572 * --ndw
7fd8a82a7c36 [gaim-migrate @ 5119]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
573 */
7fd8a82a7c36 [gaim-migrate @ 5119]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
574 char *realwho = g_strdup(normalize(who));
3281
941eb47c5bd4 [gaim-migrate @ 3299]
Sean Egan <seanegan@gmail.com>
parents: 3150
diff changeset
575 tmp.gc = gc;
4799
7fd8a82a7c36 [gaim-migrate @ 5119]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
576 tmp.who = realwho;
3281
941eb47c5bd4 [gaim-migrate @ 3299]
Sean Egan <seanegan@gmail.com>
parents: 3150
diff changeset
577 tmp.data=NULL;
4799
7fd8a82a7c36 [gaim-migrate @ 5119]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
578 tmp.len = 0;
3281
941eb47c5bd4 [gaim-migrate @ 3299]
Sean Egan <seanegan@gmail.com>
parents: 3150
diff changeset
579 l = g_list_find_custom(icons, &tmp, find_icon_data);
941eb47c5bd4 [gaim-migrate @ 3299]
Sean Egan <seanegan@gmail.com>
parents: 3150
diff changeset
580 id = l ? l->data : NULL;
2191
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
581
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
582 if (id) {
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
583 g_free(id->data);
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
584 if (!data) {
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
585 icons = g_list_remove(icons, id);
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
586 g_free(id->who);
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
587 g_free(id);
4799
7fd8a82a7c36 [gaim-migrate @ 5119]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
588 g_free(realwho);
2191
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
589 return;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
590 }
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
591 } else if (data) {
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
592 id = g_new0(struct icon_data, 1);
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
593 icons = g_list_append(icons, id);
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
594 id->gc = gc;
4799
7fd8a82a7c36 [gaim-migrate @ 5119]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
595 id->who = g_strdup(realwho);
2191
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
596 } else {
4799
7fd8a82a7c36 [gaim-migrate @ 5119]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
597 g_free(realwho);
2191
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
598 return;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
599 }
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
600
4799
7fd8a82a7c36 [gaim-migrate @ 5119]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
601 debug_printf("Got icon for %s (length %d)\n", realwho, len);
2284
83c7123e5a7e [gaim-migrate @ 2294]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2279
diff changeset
602
2191
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
603 id->data = g_memdup(data, len);
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
604 id->len = len;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
605
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
606 /* Update the buddy icon for this user. */
4799
7fd8a82a7c36 [gaim-migrate @ 5119]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
607 conv = gaim_find_conversation(realwho);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
608
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
609 /* XXX Buddy Icon should probalby be part of struct buddy instead of this weird global
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
610 * linked list stuff. */
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
611
4799
7fd8a82a7c36 [gaim-migrate @ 5119]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
612 if ((b = gaim_find_buddy(gc->account, realwho)) != NULL) {
4757
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
613 char *random = g_strdup_printf("%x", g_random_int());
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
614 char *filename = g_build_filename(gaim_user_dir(), "icons", random,
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
615 NULL);
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
616 char *dirname = g_build_filename(gaim_user_dir(), "icons", NULL);
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
617 char *old_icon = gaim_buddy_get_setting(b, "buddy_icon");
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
618 FILE *file = NULL;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
619
4757
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
620 g_free(random);
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
621
4802
5b24e8e52e4a [gaim-migrate @ 5122]
Nathan Walp <nwalp@pidgin.im>
parents: 4799
diff changeset
622 if(!g_file_test(dirname, G_FILE_TEST_IS_DIR)) {
5b24e8e52e4a [gaim-migrate @ 5122]
Nathan Walp <nwalp@pidgin.im>
parents: 4799
diff changeset
623 debug_printf("creating icon cache directory\n");
5b24e8e52e4a [gaim-migrate @ 5122]
Nathan Walp <nwalp@pidgin.im>
parents: 4799
diff changeset
624 if(mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0)
5b24e8e52e4a [gaim-migrate @ 5122]
Nathan Walp <nwalp@pidgin.im>
parents: 4799
diff changeset
625 debug_printf("error creating directory %s: %s\n",
5b24e8e52e4a [gaim-migrate @ 5122]
Nathan Walp <nwalp@pidgin.im>
parents: 4799
diff changeset
626 dirname, strerror(errno));
5b24e8e52e4a [gaim-migrate @ 5122]
Nathan Walp <nwalp@pidgin.im>
parents: 4799
diff changeset
627 }
4757
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
628
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
629 g_free(dirname);
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
630
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
631 file = fopen(filename, "wb");
4757
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
632 if (file) {
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
633 fwrite(data, 1, len, file);
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
634 fclose(file);
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
635 }
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
636
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
637 if(old_icon) {
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
638 unlink(old_icon);
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
639 g_free(old_icon);
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
640 }
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
641
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
642 gaim_buddy_set_setting(b, "buddy_icon", filename);
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
643 gaim_blist_save();
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
644
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
645 g_free(filename);
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
646
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
647 gaim_blist_update_buddy_icon(b);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
648 }
4757
c4ebe1a8484b [gaim-migrate @ 5074]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
649
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
650 if (conv != NULL && gaim_conversation_get_gc(conv) == gc)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
651 gaim_gtkconv_update_buddy_icon(conv);
4799
7fd8a82a7c36 [gaim-migrate @ 5119]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
652
7fd8a82a7c36 [gaim-migrate @ 5119]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
653 g_free(realwho);
2191
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
654 }
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
655
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
656 void remove_icon_data(struct gaim_connection *gc)
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
657 {
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
658 GList *list = icons;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
659 struct icon_data *id;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
660
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
661 while (list) {
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
662 id = list->data;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
663 if (id->gc == gc) {
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
664 g_free(id->data);
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
665 g_free(id->who);
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
666 list = icons = g_list_remove(icons, id);
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
667 g_free(id);
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
668 } else
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
669 list = list->next;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
670 }
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
671 }
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
672
4777
e23a7e166680 [gaim-migrate @ 5097]
Nathan Walp <nwalp@pidgin.im>
parents: 4772
diff changeset
673 void *get_icon_data(struct gaim_connection *gc, const char *who, int *len)
2191
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
674 {
2718
757688c301b5 [gaim-migrate @ 2731]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2662
diff changeset
675 struct icon_data tmp = { gc, normalize(who), NULL, 0 };
2191
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
676 GList *l = g_list_find_custom(icons, &tmp, find_icon_data);
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
677 struct icon_data *id = l ? l->data : NULL;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
678
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
679 if (id) {
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
680 *len = id->len;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
681 return id->data;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
682 }
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
683
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
684 *len = 0;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
685 return NULL;
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2189
diff changeset
686 }
2582
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
687
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
688 struct got_add {
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
689 struct gaim_connection *gc;
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
690 char *who;
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
691 char *alias;
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
692 };
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
693
3730
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
694 static void dont_add(struct got_add *ga)
2582
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
695 {
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
696 g_free(ga->who);
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
697 if (ga->alias)
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
698 g_free(ga->alias);
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
699 g_free(ga);
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
700 }
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
701
3730
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
702 static void do_add(struct got_add *ga)
2582
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
703 {
2585
4424c670021d [gaim-migrate @ 2598]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2582
diff changeset
704 if (g_slist_find(connections, ga->gc))
4424c670021d [gaim-migrate @ 2598]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2582
diff changeset
705 show_add_buddy(ga->gc, ga->who, NULL, ga->alias);
3730
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3694
diff changeset
706 dont_add(ga);
2582
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
707 }
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
708
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
709 void show_got_added(struct gaim_connection *gc, const char *id,
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
710 const char *who, const char *alias, const char *msg)
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
711 {
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
712 char buf[BUF_LONG];
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
713 struct got_add *ga = g_new0(struct got_add, 1);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
714 struct buddy *b = gaim_find_buddy(gc->account, who);
2582
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
715
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
716 ga->gc = gc;
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
717 ga->who = g_strdup(who);
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
718 ga->alias = alias ? g_strdup(alias) : NULL;
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
719
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4333
diff changeset
720
3150
0097f5462ac2 [gaim-migrate @ 3166]
Sean Egan <seanegan@gmail.com>
parents: 3037
diff changeset
721 g_snprintf(buf, sizeof(buf), _("%s%s%s%s has made %s his or her buddy%s%s%s"),
2582
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
722 who,
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
723 alias ? " (" : "",
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
724 alias ? alias : "",
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
725 alias ? ")" : "",
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
726 id ? id : gc->displayname[0] ? gc->displayname : gc->username,
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
727 msg ? ": " : ".",
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
728 msg ? msg : "",
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4333
diff changeset
729 b ? "" : _("\n\nDo you wish to add him or her to your buddy list?"));
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4333
diff changeset
730 if (b)
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
731 do_error_dialog(_("Gaim - Information"), buf, GAIM_INFO);
2582
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
732 else
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4309
diff changeset
733 do_ask_dialog(_("Gaim - Confirm"), buf, ga, _("Add"), do_add, _("Cancel"), dont_add, NULL, FALSE);
2582
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2558
diff changeset
734 }
2827
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
735
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
736 static GtkWidget *regdlg = NULL;
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
737 static GtkWidget *reg_list = NULL;
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
738 static GtkWidget *reg_area = NULL;
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
739 static GtkWidget *reg_reg = NULL;
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
740
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
741 static void delete_regdlg()
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
742 {
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
743 GtkWidget *tmp = regdlg;
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
744 regdlg = NULL;
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
745 if (tmp)
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
746 gtk_widget_destroy(tmp);
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
747 }
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
748
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
749 static void reset_reg_dlg()
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
750 {
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
751 GSList *P = protocols;
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
752
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
753 if (!regdlg)
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
754 return;
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
755
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
756 while (GTK_BOX(reg_list)->children)
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
757 gtk_container_remove(GTK_CONTAINER(reg_list),
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
758 ((GtkBoxChild *)GTK_BOX(reg_list)->children->data)->widget);
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
759
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
760 while (GTK_BOX(reg_area)->children)
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
761 gtk_container_remove(GTK_CONTAINER(reg_area),
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
762 ((GtkBoxChild *)GTK_BOX(reg_area)->children->data)->widget);
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
763
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
764 while (P) {
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
765 struct prpl *p = P->data;
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
766 if (p->register_user)
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
767 break;
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
768 P = P->next;
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
769 }
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
770
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
771 if (!P) {
2843
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2827
diff changeset
772 GtkWidget *no = gtk_label_new(_("You do not currently have any protocols available"
2827
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
773 " that are able to register new accounts."));
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
774 gtk_box_pack_start(GTK_BOX(reg_area), no, FALSE, FALSE, 5);
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
775 gtk_widget_show(no);
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
776
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
777 gtk_widget_set_sensitive(reg_reg, FALSE);
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
778
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
779 return;
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
780 }
2843
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2827
diff changeset
781
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2827
diff changeset
782 gtk_widget_set_sensitive(reg_reg, TRUE);
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2827
diff changeset
783
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2827
diff changeset
784 while (P) { /* we can safely ignore all the previous ones */
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2827
diff changeset
785 struct prpl *p = P->data;
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2827
diff changeset
786 P = P->next;
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2827
diff changeset
787
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2827
diff changeset
788 if (!p->register_user)
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2827
diff changeset
789 continue;
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2827
diff changeset
790
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2827
diff changeset
791 /* do stuff */
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2827
diff changeset
792 }
2827
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
793 }
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
794
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
795 void register_dialog()
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
796 {
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
797 /* this is just one big hack */
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
798 GtkWidget *vbox;
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
799 GtkWidget *frame;
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
800 GtkWidget *hbox;
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
801 GtkWidget *close;
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
802
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
803 if (regdlg) {
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
804 gdk_window_raise(regdlg->window);
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
805 return;
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
806 }
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
807
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
808 regdlg = gtk_window_new(GTK_WINDOW_TOPLEVEL);
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
809 gtk_window_set_title(GTK_WINDOW(regdlg), _("Gaim - Registration"));
4074
3ccbdf8e7f8d [gaim-migrate @ 4289]
Sean Egan <seanegan@gmail.com>
parents: 4053
diff changeset
810 gtk_window_set_role(GTK_WINDOW(regdlg), "register");
2827
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
811 gtk_widget_realize(regdlg);
4162
d3c8d2b40494 [gaim-migrate @ 4391]
Christian Hammond <chipx86@chipx86.com>
parents: 4092
diff changeset
812 g_signal_connect(GTK_OBJECT(regdlg), "destroy", G_CALLBACK(delete_regdlg), NULL);
2827
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
813
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
814 vbox = gtk_vbox_new(FALSE, 5);
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
815 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
816 gtk_container_add(GTK_CONTAINER(regdlg), vbox);
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
817 gtk_widget_show(vbox);
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
818
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
819 reg_list = gtk_hbox_new(FALSE, 5);
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
820 gtk_box_pack_start(GTK_BOX(vbox), reg_list, FALSE, FALSE, 5);
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
821 gtk_widget_show(reg_list);
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
822
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
823 frame = gtk_frame_new(_("Registration Information"));
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
824 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 5);
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
825 gtk_widget_show(frame);
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
826
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
827 reg_area = gtk_hbox_new(FALSE, 5);
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
828 gtk_container_add(GTK_CONTAINER(frame), reg_area);
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
829 gtk_widget_show(reg_area);
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
830
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
831 hbox = gtk_hbox_new(FALSE, 5);
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
832 gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
833 gtk_widget_show(hbox);
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
834
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
835 close = picture_button(regdlg, _("Close"), cancel_xpm);
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
836 gtk_box_pack_end(GTK_BOX(hbox), close, FALSE, FALSE, 5);
4162
d3c8d2b40494 [gaim-migrate @ 4391]
Christian Hammond <chipx86@chipx86.com>
parents: 4092
diff changeset
837 g_signal_connect(GTK_OBJECT(close), "clicked", G_CALLBACK(delete_regdlg), NULL);
2827
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
838 gtk_widget_show(close);
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
839
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
840 reg_reg = picture_button(regdlg, _("Register"), ok_xpm);
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
841 gtk_box_pack_end(GTK_BOX(hbox), reg_reg, FALSE, FALSE, 5);
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
842 gtk_widget_show(reg_reg);
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
843
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
844 /* fuck me */
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
845 reset_reg_dlg();
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
846
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
847 gtk_widget_show(regdlg);
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2725
diff changeset
848 }
3035
0f1766887ddd [gaim-migrate @ 3048]
Rob Flynn <gaim@robflynn.com>
parents: 2843
diff changeset
849
4040
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
850 static gboolean delayed_unload(void *handle) {
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
851 g_module_close(handle);
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
852 return FALSE;
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
853 }
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
854
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
855 gboolean ref_protocol(struct prpl *p) {
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
856 #ifdef GAIM_PLUGINS
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
857 if(p->plug) { /* This protocol is a plugin */
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
858 prpl_accounts[p->protocol]++;
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
859 debug_printf("Protocol %s now in use by %d connections.\n", p->name, prpl_accounts[p->protocol]);
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
860 if(!p->plug->handle) { /*But the protocol isn't yet loaded */
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
861 unload_protocol(p);
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
862 if (load_prpl(p))
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
863 return FALSE;
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
864 }
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
865 }
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
866 #endif /* GAIM_PLUGINS */
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
867 return TRUE;
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
868 }
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
869
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
870 void unref_protocol(struct prpl *p) {
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
871 #ifdef GAIM_PLUGINS
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
872 if(p->plug) { /* This protocol is a plugin */
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
873 prpl_accounts[p->protocol]--;
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
874 debug_printf("Protocol %s now in use by %d connections.\n", p->name, prpl_accounts[p->protocol]);
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
875 if(prpl_accounts[p->protocol] == 0) { /* No longer needed */
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
876 debug_printf("Throwing out %s protocol plugin\n", p->name);
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
877 do_ask_cancel_by_handle(p->plug->handle);
4040
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
878 g_timeout_add(0, delayed_unload, p->plug->handle);
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
879 p->plug->handle = NULL;
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
880 }
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
881 }
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
882 #endif /* GAIM_PLUGINS */
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
883 }
89b56ab2b692 [gaim-migrate @ 4248]
Luke Schierer <lschiere@pidgin.im>
parents: 4001
diff changeset
884