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