9709
|
1 /*
|
|
2 * gaim
|
|
3 *
|
|
4 * Gaim is the legal property of its developers, whose names are too numerous
|
|
5 * to list here. Please refer to the COPYRIGHT file distributed with this
|
|
6 * source distribution.
|
|
7 *
|
|
8 * This program is free software; you can redistribute it and/or modify
|
|
9 * it under the terms of the GNU General Public License as published by
|
|
10 * the Free Software Foundation; either version 2 of the License, or
|
|
11 * (at your option) any later version.
|
|
12 *
|
|
13 * This program is distributed in the hope that it will be useful,
|
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 * GNU General Public License for more details.
|
|
17 *
|
|
18 * You should have received a copy of the GNU General Public License
|
|
19 * along with this program; if not, write to the Free Software
|
|
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
21 */
|
|
22 #include "gtkinternal.h"
|
|
23
|
|
24 #include "debug.h"
|
|
25 #include "notify.h"
|
|
26 #include "prefs.h"
|
|
27 #include "prpl.h"
|
|
28 #include "request.h"
|
|
29 #include "status.h"
|
|
30 #include "util.h"
|
|
31
|
9730
|
32 #include "away.h"
|
9709
|
33 #include "gtkdialogs.h"
|
|
34 #include "gtkimhtml.h"
|
|
35 #include "gtkimhtmltoolbar.h"
|
|
36 #include "gtklog.h"
|
|
37 #include "gtkutils.h"
|
|
38 #include "stock.h"
|
|
39
|
|
40 /* XXX */
|
|
41 #include "gaim.h"
|
|
42
|
|
43 static GList *dialogwindows = NULL;
|
|
44
|
|
45 struct warning {
|
|
46 GtkWidget *window;
|
|
47 GtkWidget *anon;
|
|
48 char *who;
|
|
49 GaimConnection *gc;
|
|
50 };
|
|
51
|
|
52 /*------------------------------------------------------------------------*/
|
|
53 /* Destroys */
|
|
54 /*------------------------------------------------------------------------*/
|
|
55
|
9730
|
56 static void
|
|
57 destroy_dialog(GtkWidget *w, GtkWidget *w2)
|
9709
|
58 {
|
|
59 GtkWidget *dest;
|
|
60
|
|
61 if (!GTK_IS_WIDGET(w2))
|
|
62 dest = w;
|
|
63 else
|
|
64 dest = w2;
|
|
65
|
|
66 dialogwindows = g_list_remove(dialogwindows, dest);
|
|
67 gtk_widget_destroy(dest);
|
|
68 }
|
|
69
|
9730
|
70 void
|
|
71 gaim_gtkdialogs_destroy_all()
|
9709
|
72 {
|
|
73 while (dialogwindows)
|
|
74 destroy_dialog(NULL, dialogwindows->data);
|
|
75
|
9730
|
76 /* STATUS */
|
9709
|
77 if (awaymessage)
|
|
78 do_im_back(NULL, NULL);
|
|
79 }
|
|
80
|
9730
|
81 static void
|
|
82 gaim_gtkdialogs_im_cb(gpointer data, GaimRequestFields *fields)
|
9709
|
83 {
|
9730
|
84 GaimAccount *account;
|
|
85 const char *username;
|
9709
|
86
|
9730
|
87 account = gaim_request_fields_get_account(fields, "account");
|
|
88 username = gaim_request_fields_get_string(fields, "screenname");
|
9709
|
89
|
9730
|
90 gaim_gtkdialogs_im_with_user(account, username);
|
9709
|
91 }
|
|
92
|
9730
|
93 void
|
|
94 gaim_gtkdialogs_im(void)
|
9709
|
95 {
|
9730
|
96 GaimRequestFields *fields;
|
|
97 GaimRequestFieldGroup *group;
|
|
98 GaimRequestField *field;
|
9709
|
99
|
9730
|
100 fields = gaim_request_fields_new();
|
9709
|
101
|
9730
|
102 group = gaim_request_field_group_new(NULL);
|
|
103 gaim_request_fields_add_group(fields, group);
|
9709
|
104
|
9730
|
105 field = gaim_request_field_string_new("screenname", _("_Screen name"),
|
|
106 NULL, FALSE);
|
|
107 gaim_request_field_set_required(field, TRUE);
|
|
108 gaim_request_field_set_type_hint(field, "screenname");
|
|
109 gaim_request_field_group_add_field(group, field);
|
9709
|
110
|
9730
|
111 field = gaim_request_field_account_new("account", _("_Account"), NULL);
|
|
112 gaim_request_field_set_visible(field,
|
|
113 (gaim_connections_get_all() != NULL &&
|
|
114 gaim_connections_get_all()->next != NULL));
|
|
115 gaim_request_field_set_required(field, TRUE);
|
|
116 gaim_request_field_group_add_field(group, field);
|
|
117
|
|
118 gaim_request_fields(gaim_get_blist(), _("New Instant Message"),
|
|
119 NULL,
|
|
120 _("Please enter the screen name of the person you "
|
|
121 "would like to IM."),
|
|
122 fields,
|
|
123 _("OK"), G_CALLBACK(gaim_gtkdialogs_im_cb),
|
|
124 _("Cancel"), NULL,
|
|
125 NULL);
|
9709
|
126 }
|
|
127
|
9730
|
128 void
|
|
129 gaim_gtkdialogs_im_with_user(GaimAccount *account, const char *username)
|
9709
|
130 {
|
9730
|
131 GaimConversation *conv;
|
|
132 GaimConvWindow *win;
|
|
133 GaimGtkWindow *gtkwin;
|
9709
|
134
|
9730
|
135 conv = gaim_find_conversation_with_account(username, account);
|
9709
|
136
|
9730
|
137 if (conv == NULL)
|
|
138 conv = gaim_conversation_new(GAIM_CONV_IM, account, username);
|
9709
|
139
|
9730
|
140 win = gaim_conversation_get_window(conv);
|
|
141 gtkwin = GAIM_GTK_WINDOW(win);
|
9709
|
142
|
9730
|
143 gtk_window_present(GTK_WINDOW(gtkwin->window));
|
|
144 gaim_conv_window_switch_conversation(win, gaim_conversation_get_index(conv));
|
9709
|
145 }
|
|
146
|
9730
|
147 static gboolean
|
|
148 gaim_gtkdialogs_ee(const char *ee)
|
9709
|
149 {
|
|
150 GtkWidget *window;
|
|
151 GtkWidget *hbox;
|
|
152 GtkWidget *label;
|
|
153 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_COOL, GTK_ICON_SIZE_DIALOG);
|
|
154 gchar *norm = gaim_strreplace(ee, "rocksmyworld", "");
|
|
155
|
|
156 label = gtk_label_new(NULL);
|
|
157 if (!strcmp(norm, "zilding"))
|
|
158 gtk_label_set_markup(GTK_LABEL(label),
|
|
159 "<span weight=\"bold\" size=\"large\" foreground=\"purple\">Amazing! Simply Amazing!</span>");
|
|
160 else if (!strcmp(norm, "robflynn"))
|
|
161 gtk_label_set_markup(GTK_LABEL(label),
|
|
162 "<span weight=\"bold\" size=\"large\" foreground=\"#1f6bad\">Pimpin\' Penguin Style! *Waddle Waddle*</span>");
|
|
163 else if (!strcmp(norm, "flynorange"))
|
|
164 gtk_label_set_markup(GTK_LABEL(label),
|
|
165 "<span weight=\"bold\" size=\"large\" foreground=\"blue\">You should be me. I'm so cute!</span>");
|
|
166 else if (!strcmp(norm, "ewarmenhoven"))
|
|
167 gtk_label_set_markup(GTK_LABEL(label),
|
|
168 "<span weight=\"bold\" size=\"large\" foreground=\"orange\">Now that's what I like!</span>");
|
|
169 else if (!strcmp(norm, "markster97"))
|
|
170 gtk_label_set_markup(GTK_LABEL(label),
|
|
171 "<span weight=\"bold\" size=\"large\" foreground=\"brown\">Ahh, and excellent choice!</span>");
|
|
172 else if (!strcmp(norm, "seanegn"))
|
|
173 gtk_label_set_markup(GTK_LABEL(label),
|
|
174 "<span weight=\"bold\" size=\"large\" foreground=\"#009900\">Everytime you click my name, an angel gets its wings.</span>");
|
|
175 else if (!strcmp(norm, "chipx86"))
|
|
176 gtk_label_set_markup(GTK_LABEL(label),
|
|
177 "<span weight=\"bold\" size=\"large\" foreground=\"red\">This sunflower seed taste like pizza.</span>");
|
|
178 else if (!strcmp(norm, "markdoliner"))
|
|
179 gtk_label_set_markup(GTK_LABEL(label),
|
|
180 "<span weight=\"bold\" size=\"large\" foreground=\"#6364B1\">Hey! I was in that tumbleweed!</span>");
|
|
181 else if (!strcmp(norm, "lschiere"))
|
|
182 gtk_label_set_markup(GTK_LABEL(label),
|
|
183 "<span weight=\"bold\" size=\"large\" foreground=\"gray\">I'm not anything.</span>");
|
|
184 g_free(norm);
|
|
185
|
|
186 if (strlen(gtk_label_get_label(GTK_LABEL(label))) <= 0)
|
|
187 return FALSE;
|
|
188
|
|
189 window = gtk_dialog_new_with_buttons(GAIM_ALERT_TITLE, NULL, 0, GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL);
|
|
190 gtk_dialog_set_default_response (GTK_DIALOG(window), GTK_RESPONSE_OK);
|
|
191 g_signal_connect(G_OBJECT(window), "response", G_CALLBACK(gtk_widget_destroy), NULL);
|
|
192
|
|
193 gtk_container_set_border_width (GTK_CONTAINER(window), 6);
|
|
194 gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
|
|
195 gtk_dialog_set_has_separator(GTK_DIALOG(window), FALSE);
|
|
196 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(window)->vbox), 12);
|
|
197 gtk_container_set_border_width (GTK_CONTAINER(GTK_DIALOG(window)->vbox), 6);
|
|
198
|
|
199 hbox = gtk_hbox_new(FALSE, 12);
|
|
200 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(window)->vbox), hbox);
|
|
201 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
|
|
202
|
|
203 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
|
|
204 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
|
|
205 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
|
|
206
|
|
207 gtk_widget_show_all(window);
|
|
208 return TRUE;
|
|
209 }
|
|
210
|
|
211 static void
|
9730
|
212 gaim_gtkdialogs_info_cb(gpointer data, GaimRequestFields *fields)
|
9709
|
213 {
|
|
214 char *username;
|
|
215 gboolean found = FALSE;
|
|
216 GaimAccount *account;
|
|
217
|
|
218 account = gaim_request_fields_get_account(fields, "account");
|
|
219
|
|
220 username = g_strdup(gaim_normalize(account,
|
|
221 gaim_request_fields_get_string(fields, "screenname")));
|
|
222
|
|
223 if (username != NULL && gaim_str_has_suffix(username, "rocksmyworld"))
|
9730
|
224 found = gaim_gtkdialogs_ee(username);
|
9709
|
225
|
|
226 if (!found && username != NULL && *username != '\0' && account != NULL)
|
|
227 serv_get_info(gaim_account_get_connection(account), username);
|
|
228
|
|
229 g_free(username);
|
|
230 }
|
|
231
|
|
232 void
|
9714
|
233 gaim_gtkdialogs_info(void)
|
9709
|
234 {
|
|
235 GaimRequestFields *fields;
|
|
236 GaimRequestFieldGroup *group;
|
|
237 GaimRequestField *field;
|
|
238
|
|
239 fields = gaim_request_fields_new();
|
|
240
|
|
241 group = gaim_request_field_group_new(NULL);
|
|
242 gaim_request_fields_add_group(fields, group);
|
|
243
|
|
244 field = gaim_request_field_string_new("screenname", _("_Screen name"),
|
|
245 NULL, FALSE);
|
|
246 gaim_request_field_set_type_hint(field, "screenname");
|
|
247 gaim_request_field_set_required(field, TRUE);
|
|
248 gaim_request_field_group_add_field(group, field);
|
|
249
|
|
250 field = gaim_request_field_account_new("account", _("_Account"), NULL);
|
|
251 gaim_request_field_set_visible(field,
|
|
252 (gaim_connections_get_all() != NULL &&
|
|
253 gaim_connections_get_all()->next != NULL));
|
|
254 gaim_request_field_set_required(field, TRUE);
|
|
255 gaim_request_field_group_add_field(group, field);
|
|
256
|
|
257 gaim_request_fields(gaim_get_blist(), _("Get User Info"),
|
|
258 NULL,
|
|
259 _("Please enter the screen name of the person whose "
|
|
260 "info you would like to view."),
|
|
261 fields,
|
9730
|
262 _("OK"), G_CALLBACK(gaim_gtkdialogs_info_cb),
|
9709
|
263 _("Cancel"), NULL,
|
|
264 NULL);
|
|
265 }
|
|
266
|
|
267 static void
|
9730
|
268 gaim_gtkdialogs_log_cb(gpointer data, GaimRequestFields *fields)
|
9709
|
269 {
|
|
270 char *username;
|
|
271 GaimAccount *account;
|
|
272
|
|
273 account = gaim_request_fields_get_account(fields, "account");
|
|
274
|
|
275 username = g_strdup(gaim_normalize(account,
|
|
276 gaim_request_fields_get_string(fields, "screenname")));
|
|
277
|
|
278 if( username != NULL && *username != '\0' && account != NULL )
|
|
279 gaim_gtk_log_show( username, account );
|
|
280
|
|
281 g_free(username);
|
|
282 }
|
|
283
|
|
284 void
|
9714
|
285 gaim_gtkdialogs_log(void)
|
9709
|
286 {
|
|
287 GaimRequestFields *fields;
|
|
288 GaimRequestFieldGroup *group;
|
|
289 GaimRequestField *field;
|
|
290
|
|
291 fields = gaim_request_fields_new();
|
|
292
|
|
293 group = gaim_request_field_group_new(NULL);
|
|
294 gaim_request_fields_add_group(fields, group);
|
|
295
|
|
296 field = gaim_request_field_string_new("screenname", _("_Screen name"),
|
|
297 NULL, FALSE);
|
|
298 gaim_request_field_set_type_hint(field, "screenname");
|
|
299 gaim_request_field_set_required(field, TRUE);
|
|
300 gaim_request_field_group_add_field(group, field);
|
|
301
|
|
302 field = gaim_request_field_account_new("account", _("_Account"), NULL);
|
|
303 gaim_request_field_account_set_show_all(field, TRUE);
|
|
304 gaim_request_field_set_visible(field,
|
|
305 (gaim_accounts_get_all() != NULL &&
|
|
306 gaim_accounts_get_all()->next != NULL));
|
|
307 gaim_request_field_set_required(field, TRUE);
|
|
308 gaim_request_field_group_add_field(group, field);
|
|
309
|
|
310 gaim_request_fields(gaim_get_blist(), _("Get User Log"),
|
|
311 NULL,
|
|
312 _("Please enter the screen name of the person whose "
|
|
313 "log you would like to view."),
|
|
314 fields,
|
9730
|
315 _("OK"), G_CALLBACK(gaim_gtkdialogs_log_cb),
|
9709
|
316 _("Cancel"), NULL,
|
|
317 NULL);
|
|
318 }
|
|
319
|
9730
|
320 static void
|
|
321 gaim_gtkdialogs_warn_cb(GtkWidget *widget, gint resp, struct warning *w)
|
9709
|
322 {
|
9730
|
323 if (resp == GTK_RESPONSE_OK)
|
|
324 serv_warn(w->gc, w->who, (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w->anon))) ? 1 : 0);
|
9709
|
325
|
9730
|
326 destroy_dialog(NULL, w->window);
|
|
327 g_free(w->who);
|
|
328 g_free(w);
|
9709
|
329 }
|
|
330
|
9730
|
331 void
|
|
332 gaim_gtkdialogs_warn(GaimConnection *gc, const char *who)
|
9709
|
333 {
|
9730
|
334 char *labeltext;
|
|
335 GtkWidget *hbox, *vbox;
|
9709
|
336 GtkWidget *label;
|
9730
|
337 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
|
|
338 GaimConversation *c = gaim_find_conversation_with_account(who, gc->account);
|
|
339
|
|
340 struct warning *w = g_new0(struct warning, 1);
|
|
341 w->who = g_strdup(who);
|
|
342 w->gc = gc;
|
|
343
|
|
344 gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
|
9709
|
345
|
9730
|
346 w->window = gtk_dialog_new_with_buttons(_("Warn User"),
|
|
347 GTK_WINDOW(GAIM_GTK_WINDOW(c->window)->window), 0,
|
|
348 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
349 GAIM_STOCK_WARN, GTK_RESPONSE_OK, NULL);
|
|
350 gtk_dialog_set_default_response (GTK_DIALOG(w->window), GTK_RESPONSE_OK);
|
|
351 g_signal_connect(G_OBJECT(w->window), "response", G_CALLBACK(gaim_gtkdialogs_warn_cb), w);
|
|
352
|
|
353 gtk_container_set_border_width (GTK_CONTAINER(w->window), 6);
|
|
354 gtk_window_set_resizable(GTK_WINDOW(w->window), FALSE);
|
|
355 gtk_dialog_set_has_separator(GTK_DIALOG(w->window), FALSE);
|
|
356 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(w->window)->vbox), 12);
|
|
357 gtk_container_set_border_width (GTK_CONTAINER(GTK_DIALOG(w->window)->vbox), 6);
|
9709
|
358
|
|
359 hbox = gtk_hbox_new(FALSE, 12);
|
9730
|
360 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(w->window)->vbox), hbox);
|
|
361 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
|
9709
|
362
|
9730
|
363 vbox = gtk_vbox_new(FALSE, 0);
|
|
364 gtk_container_add(GTK_CONTAINER(hbox), vbox);
|
|
365 labeltext = g_strdup_printf(_("<span weight=\"bold\" size=\"larger\">Warn %s?</span>\n\n"
|
|
366 "This will increase %s's warning level and he or she will be subject to harsher rate limiting.\n"), who, who);
|
|
367 label = gtk_label_new(NULL);
|
|
368 gtk_label_set_markup(GTK_LABEL(label), labeltext);
|
|
369 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
|
|
370 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
|
|
371 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
|
|
372 g_free(labeltext);
|
9709
|
373
|
9730
|
374 w->anon = gtk_check_button_new_with_mnemonic(_("Warn _anonymously?"));
|
|
375 gtk_box_pack_start(GTK_BOX(vbox), w->anon, FALSE, FALSE, 0);
|
|
376
|
|
377 hbox = gtk_hbox_new(FALSE, 6);
|
|
378 gtk_container_add(GTK_CONTAINER(vbox), hbox);
|
|
379 img = gtk_image_new_from_stock(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_MENU);
|
|
380 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
|
|
381 labeltext = _("<b>Anonymous warnings are less severe.</b>");
|
|
382 label = gtk_label_new(NULL);
|
|
383 gtk_label_set_markup(GTK_LABEL(label), labeltext);
|
|
384 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
|
9709
|
385 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
|
|
386
|
9730
|
387 dialogwindows = g_list_prepend(dialogwindows, w->window);
|
|
388 gtk_widget_show_all(w->window);
|
9709
|
389 }
|
|
390
|
|
391 static void
|
9730
|
392 gaim_gtkdialogs_alias_contact_cb(GaimContact *contact, const char *new_alias)
|
|
393 {
|
|
394 gaim_contact_set_alias(contact, new_alias);
|
|
395 }
|
|
396
|
|
397 void
|
|
398 gaim_gtkdialogs_alias_contact(GaimContact *contact)
|
|
399 {
|
|
400 gaim_request_input(NULL, _("Alias Contact"), NULL,
|
|
401 _("Enter an alias for this contact."),
|
|
402 contact->alias, FALSE, FALSE, NULL,
|
|
403 _("Alias"), G_CALLBACK(gaim_gtkdialogs_alias_contact_cb),
|
|
404 _("Cancel"), NULL, contact);
|
|
405 }
|
|
406
|
|
407 static void
|
|
408 gaim_gtkdialogs_alias_buddy_cb(GaimBuddy *buddy, const char *new_alias)
|
|
409 {
|
|
410 gaim_blist_alias_buddy(buddy, new_alias);
|
|
411 serv_alias_buddy(buddy);
|
|
412 }
|
|
413
|
|
414 void
|
|
415 gaim_gtkdialogs_alias_buddy(GaimBuddy *b)
|
|
416 {
|
|
417 char *secondary = g_strdup_printf(_("Enter an alias for %s."), b->name);
|
|
418
|
|
419 gaim_request_input(NULL, _("Alias Buddy"), NULL,
|
|
420 secondary, b->alias, FALSE, FALSE, NULL,
|
|
421 _("Alias"), G_CALLBACK(gaim_gtkdialogs_alias_buddy_cb),
|
|
422 _("Cancel"), NULL, b);
|
|
423
|
|
424 g_free(secondary);
|
|
425 }
|
|
426
|
|
427 static void
|
|
428 gaim_gtkdialogs_alias_chat_cb(GaimChat *chat, const char *new_alias)
|
9709
|
429 {
|
|
430 gaim_blist_alias_chat(chat, new_alias);
|
|
431 }
|
|
432
|
|
433 void
|
9730
|
434 gaim_gtkdialogs_alias_chat(GaimChat *chat)
|
9709
|
435 {
|
|
436 gaim_request_input(NULL, _("Alias Chat"), NULL,
|
|
437 _("Enter an alias for this chat."),
|
|
438 chat->alias, FALSE, FALSE, NULL,
|
9730
|
439 _("Alias"), G_CALLBACK(gaim_gtkdialogs_alias_chat_cb),
|
9709
|
440 _("Cancel"), NULL, chat);
|
|
441 }
|
|
442
|
|
443 static void
|
9730
|
444 do_remove_contact(GaimContact *contact)
|
9709
|
445 {
|
9730
|
446 GaimBlistNode *bnode, *cnode;
|
|
447 GaimGroup *group;
|
|
448
|
|
449 if (!contact)
|
|
450 return;
|
|
451
|
|
452 cnode = (GaimBlistNode *)contact;
|
|
453 group = (GaimGroup*)cnode->parent;
|
|
454 for (bnode = cnode->child; bnode; bnode = bnode->next) {
|
|
455 GaimBuddy *buddy = (GaimBuddy*)bnode;
|
|
456 if (gaim_account_is_connected(buddy->account))
|
|
457 serv_remove_buddy(buddy->account->gc, buddy, group);
|
|
458 }
|
|
459 gaim_blist_remove_contact(contact);
|
|
460 }
|
|
461
|
|
462 void
|
|
463 gaim_gtkdialogs_remove_contact(GaimContact *contact)
|
|
464 {
|
|
465 GaimBuddy *buddy = gaim_contact_get_priority_buddy(contact);
|
|
466
|
|
467 if (!buddy)
|
|
468 return;
|
|
469
|
|
470 if (((GaimBlistNode*)contact)->child == (GaimBlistNode*)buddy &&
|
|
471 !((GaimBlistNode*)buddy)->next) {
|
|
472 gaim_gtkdialogs_remove_buddy(buddy);
|
|
473 } else {
|
|
474 char *text = g_strdup_printf(_("You are about to remove the contact containing %s and %d other buddies from your buddy list. Do you want to continue?"),
|
|
475 buddy->name, contact->totalsize - 1);
|
|
476
|
|
477 gaim_request_action(NULL, NULL, _("Remove Contact"), text, -1, contact, 2,
|
|
478 _("Remove Contact"), G_CALLBACK(do_remove_contact),
|
|
479 _("Cancel"), NULL);
|
|
480
|
|
481 g_free(text);
|
|
482 }
|
9709
|
483 }
|
|
484
|
|
485 void
|
9730
|
486 do_remove_group(GaimGroup *group)
|
9709
|
487 {
|
9730
|
488 GaimBlistNode *cnode, *bnode;
|
|
489
|
|
490 cnode = ((GaimBlistNode*)group)->child;
|
|
491
|
|
492 while (cnode) {
|
|
493 if (GAIM_BLIST_NODE_IS_CONTACT(cnode)) {
|
|
494 bnode = cnode->child;
|
|
495 cnode = cnode->next;
|
|
496 while (bnode) {
|
|
497 GaimBuddy *buddy;
|
|
498 if (GAIM_BLIST_NODE_IS_BUDDY(bnode)) {
|
|
499 GaimConversation *conv;
|
|
500 buddy = (GaimBuddy*)bnode;
|
|
501 bnode = bnode->next;
|
|
502 conv = gaim_find_conversation_with_account(buddy->name, buddy->account);
|
|
503 if (gaim_account_is_connected(buddy->account)) {
|
|
504 serv_remove_buddy(buddy->account->gc, buddy, group);
|
|
505 gaim_blist_remove_buddy(buddy);
|
|
506 if (conv)
|
|
507 gaim_conversation_update(conv,
|
|
508 GAIM_CONV_UPDATE_REMOVE);
|
|
509 }
|
|
510 } else {
|
|
511 bnode = bnode->next;
|
|
512 }
|
|
513 }
|
|
514 } else if (GAIM_BLIST_NODE_IS_CHAT(cnode)) {
|
|
515 GaimChat *chat = (GaimChat *)cnode;
|
|
516 cnode = cnode->next;
|
|
517 if (gaim_account_is_connected(chat->account))
|
|
518 gaim_blist_remove_chat(chat);
|
|
519 } else {
|
|
520 cnode = cnode->next;
|
|
521 }
|
|
522 }
|
|
523
|
|
524 gaim_blist_remove_group(group);
|
|
525 }
|
|
526
|
|
527 void
|
|
528 gaim_gtkdialogs_remove_group(GaimGroup *group)
|
|
529 {
|
|
530 char *text = g_strdup_printf(_("You are about to remove the group %s and all its members from your buddy list. Do you want to continue?"),
|
|
531 group->name);
|
|
532
|
|
533 gaim_request_action(NULL, NULL, _("Remove Group"), text, -1, group, 2,
|
|
534 _("Remove Group"), G_CALLBACK(do_remove_group),
|
|
535 _("Cancel"), NULL);
|
|
536
|
|
537 g_free(text);
|
9709
|
538 }
|
|
539
|
|
540 static void
|
9730
|
541 do_remove_buddy(GaimBuddy *buddy)
|
9709
|
542 {
|
9730
|
543 GaimGroup *group;
|
|
544 GaimConversation *conv;
|
|
545 gchar *name;
|
|
546 GaimAccount *account;
|
|
547
|
|
548 if (!buddy)
|
|
549 return;
|
|
550
|
|
551 group = gaim_find_buddys_group(buddy);
|
|
552 name = g_strdup(buddy->name); /* b->name is a crasher after remove_buddy */
|
|
553 account = buddy->account;
|
|
554
|
|
555 gaim_debug(GAIM_DEBUG_INFO, "blist",
|
|
556 "Removing '%s' from buddy list.\n", buddy->name);
|
|
557 /* XXX - Should remove from blist first... then call serv_remove_buddy()? */
|
|
558 serv_remove_buddy(buddy->account->gc, buddy, group);
|
|
559 gaim_blist_remove_buddy(buddy);
|
|
560
|
|
561 conv = gaim_find_conversation_with_account(name, account);
|
|
562
|
|
563 if (conv != NULL)
|
|
564 gaim_conversation_update(conv, GAIM_CONV_UPDATE_REMOVE);
|
|
565
|
|
566 g_free(name);
|
9709
|
567 }
|
|
568
|
|
569 void
|
9730
|
570 gaim_gtkdialogs_remove_buddy(GaimBuddy *buddy)
|
9709
|
571 {
|
9730
|
572 char *text;
|
|
573
|
|
574 if (!buddy)
|
|
575 return;
|
|
576
|
|
577 text = g_strdup_printf(_("You are about to remove %s from your buddy list. Do you want to continue?"), buddy->name);
|
|
578
|
|
579 gaim_request_action(NULL, NULL, _("Remove Buddy"), text, -1, buddy, 2,
|
|
580 _("Remove Buddy"), G_CALLBACK(do_remove_buddy),
|
|
581 _("Cancel"), NULL);
|
|
582
|
|
583 g_free(text);
|
|
584 }
|
9709
|
585
|
9730
|
586 static void
|
|
587 do_remove_chat(GaimChat *chat)
|
|
588 {
|
|
589 gaim_blist_remove_chat(chat);
|
|
590 }
|
9709
|
591
|
9730
|
592 void
|
|
593 gaim_gtkdialogs_remove_chat(GaimChat *chat)
|
|
594 {
|
|
595 char *name = gaim_chat_get_display_name(chat);
|
|
596 char *text = g_strdup_printf(_("You are about to remove the chat %s from your buddy list. Do you want to continue?"), name);
|
|
597
|
|
598 gaim_request_action(NULL, NULL, _("Remove Chat"), text, -1, chat, 2,
|
|
599 _("Remove Chat"), G_CALLBACK(do_remove_chat),
|
|
600 _("Cancel"), NULL);
|
|
601
|
|
602 g_free(name);
|
|
603 g_free(text);
|
9709
|
604 }
|