Mercurial > pidgin
comparison src/conversation.c @ 960:fa681641643d
[gaim-migrate @ 970]
*** MULTIPLE-CONNECTIONS ***
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Tue, 10 Oct 2000 00:02:02 +0000 |
parents | 311b3f72e7b9 |
children | 2cd7b73e2c9a |
comparison
equal
deleted
inserted
replaced
959:034d5d1d53eb | 960:fa681641643d |
---|---|
45 #include "pixmaps/speaker.xpm" | 45 #include "pixmaps/speaker.xpm" |
46 #include "pixmaps/smile_icon.xpm" | 46 #include "pixmaps/smile_icon.xpm" |
47 #include "pixmaps/wood.xpm" | 47 #include "pixmaps/wood.xpm" |
48 #include "pixmaps/link.xpm" | 48 #include "pixmaps/link.xpm" |
49 #include "pixmaps/strike.xpm" | 49 #include "pixmaps/strike.xpm" |
50 #include "pixmaps/fgcolor.xpm" | |
51 #include "pixmaps/bgcolor.xpm" | |
50 | 52 |
51 #include "pixmaps/angel.xpm" | 53 #include "pixmaps/angel.xpm" |
52 #include "pixmaps/bigsmile.xpm" | 54 #include "pixmaps/bigsmile.xpm" |
53 #include "pixmaps/burp.xpm" | 55 #include "pixmaps/burp.xpm" |
54 #include "pixmaps/crossedlips.xpm" | 56 #include "pixmaps/crossedlips.xpm" |
132 | 134 |
133 fclose(fd); | 135 fclose(fd); |
134 } | 136 } |
135 | 137 |
136 show_conv(c); | 138 show_conv(c); |
139 if (connections) | |
140 c->gc = (struct gaim_connection *)connections->data; | |
137 conversations = g_list_append(conversations, c); | 141 conversations = g_list_append(conversations, c); |
138 plugin_event(event_new_conversation, name, 0, 0); | 142 plugin_event(event_new_conversation, name, 0, 0); |
139 return c; | 143 return c; |
140 } | 144 } |
141 | 145 |
346 if (c->is_chat && (widget == c->close)) { | 350 if (c->is_chat && (widget == c->close)) { |
347 GtkWidget *tmp = c->window; | 351 GtkWidget *tmp = c->window; |
348 debug_print("chat clicked close button\n"); | 352 debug_print("chat clicked close button\n"); |
349 c->window = NULL; | 353 c->window = NULL; |
350 gtk_widget_destroy(tmp); | 354 gtk_widget_destroy(tmp); |
351 return; | 355 return FALSE; |
352 } | 356 } |
353 | 357 |
354 debug_print("conversation close callback\n"); | 358 debug_print("conversation close callback\n"); |
355 | 359 |
356 if (c->window) | 360 if (c->window) |
378 | 382 |
379 if (c->is_chat) { | 383 if (c->is_chat) { |
380 serv_chat_leave(c->id); | 384 serv_chat_leave(c->id); |
381 } else { | 385 } else { |
382 if (c->is_direct) { | 386 if (c->is_direct) { |
383 if (!USE_OSCAR) { | 387 if (c->gc->protocol == PROTO_OSCAR) { |
384 /* Direct IM TOC FIXME */ | |
385 } else { | |
386 gdk_input_remove(c->watcher); | 388 gdk_input_remove(c->watcher); |
387 sprintf(debug_buff, "Closing DirectIM conversation (%p)\n", c->conn); | 389 sprintf(debug_buff, "Closing DirectIM conversation (%p)\n", c->conn); |
388 debug_print(debug_buff); | 390 debug_print(debug_buff); |
389 aim_conn_kill(gaim_sess, &c->conn); | 391 aim_conn_kill(c->gc->oscar_sess, &c->conn); |
392 } else { | |
393 /* Direct IM TOC FIXME */ | |
390 } | 394 } |
391 } | 395 } |
392 delete_conversation(c); | 396 delete_conversation(c); |
393 } | 397 } |
394 | 398 |
598 void send_callback(GtkWidget *widget, struct conversation *c) | 602 void send_callback(GtkWidget *widget, struct conversation *c) |
599 { | 603 { |
600 char *buf, *buf2, *buf3; | 604 char *buf, *buf2, *buf3; |
601 int hdrlen, limit; | 605 int hdrlen, limit; |
602 | 606 |
607 if (!c->gc) return; | |
603 if (c->is_direct) limit = 0x8000; /* 32 k */ | 608 if (c->is_direct) limit = 0x8000; /* 32 k */ |
604 else if (c->is_chat && USE_OSCAR) limit = MAXCHATMSGLEN; | 609 else if (c->is_chat && c->gc->protocol == PROTO_OSCAR) limit = MAXCHATMSGLEN; |
605 else if (USE_OSCAR) limit = MAXMSGLEN; | 610 else if (c->gc->protocol == PROTO_OSCAR) limit = MAXMSGLEN; |
606 else limit = MSG_LEN; | 611 else limit = MSG_LEN; |
607 limit <<= 2; | 612 limit <<= 2; |
608 | 613 |
609 buf = g_malloc(limit); | 614 buf = g_malloc(limit); |
610 | 615 |
624 | 629 |
625 /* Let us determine how long the message CAN be. | 630 /* Let us determine how long the message CAN be. |
626 * toc_send_im is 11 chars long + 2 quotes. | 631 * toc_send_im is 11 chars long + 2 quotes. |
627 * + 2 spaces + 6 for the header + 2 for good | 632 * + 2 spaces + 6 for the header + 2 for good |
628 * measure = 23 bytes + the length of normalize c->name */ | 633 * measure = 23 bytes + the length of normalize c->name */ |
629 if (!USE_OSCAR) | 634 if (c->gc->protocol == PROTO_TOC) |
630 hdrlen = 23 + strlen(normalize(c->name)); | 635 hdrlen = 23 + strlen(normalize(c->name)); |
631 else | 636 else |
632 hdrlen = 0; | 637 hdrlen = 0; |
633 | 638 |
634 if (font_options & OPT_FONT_BOLD) { | 639 if (font_options & OPT_FONT_BOLD) { |
681 | 686 |
682 if (!c->is_chat) { | 687 if (!c->is_chat) { |
683 buf3 = g_strdup(buf); | 688 buf3 = g_strdup(buf); |
684 write_to_conv(c, buf3, WFLAG_SEND, NULL); | 689 write_to_conv(c, buf3, WFLAG_SEND, NULL); |
685 g_free(buf3); | 690 g_free(buf3); |
686 escape_text(buf); | |
687 if (escape_message(buf) > limit/4 - hdrlen) | |
688 do_error_dialog(_("Message too long, some data truncated."), _("Error")); | |
689 | 691 |
690 serv_send_im(c->name, buf, 0); | 692 serv_send_im(c->name, buf, 0); |
691 | 693 |
692 if (c->makesound && (sound_options & OPT_SOUND_SEND)) | 694 if (c->makesound && (sound_options & OPT_SOUND_SEND)) |
693 play_sound(SEND); | 695 play_sound(SEND); |
694 } else { | 696 } else { |
695 serv_chat_send(c->id, buf); /* this does escape_text for us */ | 697 serv_chat_send(c->id, buf); |
696 | 698 |
697 /* no sound because we do that when we receive our message */ | 699 /* no sound because we do that when we receive our message */ |
698 } | 700 } |
699 | 701 |
700 quiet_set(c->bold, FALSE); | 702 quiet_set(c->bold, FALSE); |
1202 char *smiley = g_malloc(7); | 1204 char *smiley = g_malloc(7); |
1203 struct buddy *b; | 1205 struct buddy *b; |
1204 | 1206 |
1205 if (!who) { | 1207 if (!who) { |
1206 if (flags & WFLAG_SEND) { | 1208 if (flags & WFLAG_SEND) { |
1207 b = find_buddy(current_user->username); | 1209 b = find_buddy(c->gc->username); |
1208 if (b) | 1210 if (b) |
1209 who = b->show; | 1211 who = b->show; |
1210 else | 1212 else |
1211 who = current_user->username; | 1213 who = c->gc->username; |
1212 } else { | 1214 } else { |
1213 b = find_buddy(c->name); | 1215 b = find_buddy(c->name); |
1214 if (b) | 1216 if (b) |
1215 who = b->show; | 1217 who = b->show; |
1216 else | 1218 else |
1613 gtk_widget_set_sensitive(c->strike, ((font_options & OPT_FONT_STRIKE)) ? FALSE : TRUE); | 1615 gtk_widget_set_sensitive(c->strike, ((font_options & OPT_FONT_STRIKE)) ? FALSE : TRUE); |
1614 | 1616 |
1615 return toolbar; | 1617 return toolbar; |
1616 } | 1618 } |
1617 | 1619 |
1620 static void convo_sel_send(GtkObject *m, struct gaim_connection *c) | |
1621 { | |
1622 struct conversation *cnv = gtk_object_get_user_data(m); | |
1623 cnv->gc = c; | |
1624 } | |
1625 | |
1626 static void create_convo_menu(struct conversation *cnv) | |
1627 { | |
1628 GtkWidget *menu, *opt; | |
1629 GSList *g = connections; | |
1630 struct gaim_connection *c; | |
1631 | |
1632 if (g_slist_length(g) < 2) | |
1633 gtk_widget_hide(cnv->menu->parent); | |
1634 else { | |
1635 menu = gtk_menu_new(); | |
1636 | |
1637 while (g) { | |
1638 c = (struct gaim_connection *)g->data; | |
1639 opt = gtk_menu_item_new_with_label(c->username); | |
1640 gtk_object_set_user_data(GTK_OBJECT(opt), cnv); | |
1641 gtk_signal_connect(GTK_OBJECT(opt), "activate", | |
1642 GTK_SIGNAL_FUNC(convo_sel_send), c); | |
1643 gtk_widget_show(opt); | |
1644 gtk_menu_append(GTK_MENU(menu), opt); | |
1645 g = g->next; | |
1646 } | |
1647 | |
1648 gtk_option_menu_remove_menu(GTK_OPTION_MENU(cnv->menu)); | |
1649 gtk_option_menu_set_menu(GTK_OPTION_MENU(cnv->menu), menu); | |
1650 gtk_option_menu_set_history(GTK_OPTION_MENU(cnv->menu), 0); | |
1651 | |
1652 gtk_widget_show(cnv->menu); | |
1653 gtk_widget_show(cnv->menu->parent); | |
1654 } | |
1655 } | |
1656 | |
1657 void redo_convo_menus() | |
1658 { | |
1659 GList *c = conversations; | |
1660 struct conversation *C; | |
1661 | |
1662 while (c) { | |
1663 C = (struct conversation *)c->data; | |
1664 create_convo_menu(C); | |
1665 c = c->next; | |
1666 } | |
1667 } | |
1618 | 1668 |
1619 void show_conv(struct conversation *c) | 1669 void show_conv(struct conversation *c) |
1620 { | 1670 { |
1621 GtkWidget *win; | 1671 GtkWidget *win; |
1622 char buf[256]; | 1672 char buf[256]; |
1632 GtkWidget *vbox; | 1682 GtkWidget *vbox; |
1633 GtkWidget *vbox2; | 1683 GtkWidget *vbox2; |
1634 GtkWidget *paned; | 1684 GtkWidget *paned; |
1635 GtkWidget *add; | 1685 GtkWidget *add; |
1636 GtkWidget *toolbar; | 1686 GtkWidget *toolbar; |
1637 GtkWidget *sep; | 1687 GtkWidget *hbox; |
1688 GtkWidget *label; | |
1638 int dispstyle; | 1689 int dispstyle; |
1639 | 1690 |
1640 win = gtk_window_new(GTK_WINDOW_TOPLEVEL); | 1691 win = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
1641 gtk_window_set_wmclass(GTK_WINDOW(win), "conversation", "Gaim"); | 1692 gtk_window_set_wmclass(GTK_WINDOW(win), "conversation", "Gaim"); |
1642 gtk_window_set_policy(GTK_WINDOW(win), TRUE, TRUE, TRUE); | 1693 gtk_window_set_policy(GTK_WINDOW(win), TRUE, TRUE, TRUE); |
1676 | 1727 |
1677 gtk_paned_pack1(GTK_PANED(paned), vbox, FALSE, TRUE); | 1728 gtk_paned_pack1(GTK_PANED(paned), vbox, FALSE, TRUE); |
1678 gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, FALSE); | 1729 gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, FALSE); |
1679 gtk_widget_show(vbox2); | 1730 gtk_widget_show(vbox2); |
1680 gtk_widget_show(paned); | 1731 gtk_widget_show(paned); |
1732 | |
1733 hbox = gtk_hbox_new(FALSE, 0); | |
1734 gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0); | |
1735 gtk_widget_show(hbox); | |
1736 | |
1737 label = gtk_label_new(_("Send message as: ")); | |
1738 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); | |
1739 gtk_widget_show(label); | |
1740 | |
1741 c->menu = gtk_option_menu_new(); | |
1742 gtk_box_pack_start(GTK_BOX(hbox), c->menu, FALSE, FALSE, 5); | |
1743 gtk_widget_show(c->menu); | |
1744 | |
1745 create_convo_menu(c); | |
1681 | 1746 |
1682 entry = gtk_text_new(NULL, NULL); | 1747 entry = gtk_text_new(NULL, NULL); |
1683 gtk_text_set_editable(GTK_TEXT(entry), TRUE); | 1748 gtk_text_set_editable(GTK_TEXT(entry), TRUE); |
1684 gtk_text_set_word_wrap(GTK_TEXT(entry), TRUE); | 1749 gtk_text_set_word_wrap(GTK_TEXT(entry), TRUE); |
1685 gtk_object_set_user_data(GTK_OBJECT(entry), c); | 1750 gtk_object_set_user_data(GTK_OBJECT(entry), c); |