annotate console/gntconv.c @ 13915:e78d113f82db

[gaim-migrate @ 16416] Stu pointed out two of my classic blunders! (Nineteen penguin points to the first person to figure out what movie I'm alluding to.) The MSN http connect method works now. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 03 Jul 2006 21:19:56 +0000
parents cc60d0861337
children fdf2dbed6faa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13887
diff changeset
1 #include <string.h>
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
2 #include <util.h>
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
3
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
4 #include "gntgaim.h"
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
5 #include "gntconv.h"
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
6
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
7 #include "gnt.h"
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
8 #include "gntbox.h"
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
9 #include "gntentry.h"
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
10 #include "gnttextview.h"
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
11
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
12 GHashTable *ggconvs;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
13
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
14 typedef struct _GGConv GGConv;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
15 typedef struct _GGConvChat GGConvChat;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
16 typedef struct _GGConvIm GGConvIm;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
17
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
18 struct _GGConv
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
19 {
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
20 GaimConversation *conv;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
21
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
22 GntWidget *window; /* the container */
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
23 GntWidget *entry; /* entry */
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
24 GntWidget *tv; /* text-view */
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
25
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
26 union
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
27 {
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
28 GGConvChat *chat;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
29 GGConvIm *im;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
30 } u;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
31 };
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
32
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
33 struct _GGConvChat
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
34 {
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
35 GntWidget *userlist; /* the userlist */
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
36 };
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
37
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
38 struct _GGConvIm
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
39 {
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
40 void *nothing_for_now;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
41 };
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
42
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
43 static gboolean
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
44 entry_key_pressed(GntWidget *w, const char *key, GGConv *ggconv)
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
45 {
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
46 if (key[0] == '\r' && key[1] == 0)
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
47 {
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
48 const char *text = gnt_entry_get_text(GNT_ENTRY(ggconv->entry));
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
49 switch (gaim_conversation_get_type(ggconv->conv))
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
50 {
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
51 case GAIM_CONV_TYPE_IM:
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
52 gaim_conv_im_send_with_flags(GAIM_CONV_IM(ggconv->conv), text, GAIM_MESSAGE_SEND);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
53 break;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
54 case GAIM_CONV_TYPE_CHAT:
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
55 gaim_conv_chat_send(GAIM_CONV_CHAT(ggconv->conv), text);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
56 break;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
57 default:
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
58 g_return_val_if_reached(FALSE);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
59 }
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
60 gnt_entry_clear(GNT_ENTRY(ggconv->entry));
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
61 return TRUE;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
62 }
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13887
diff changeset
63 else if (key[0] == 27)
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13887
diff changeset
64 {
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13887
diff changeset
65 if (strcmp(key+1, GNT_KEY_DOWN) == 0)
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13887
diff changeset
66 gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), 1);
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13887
diff changeset
67 else if (strcmp(key+1, GNT_KEY_UP) == 0)
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13887
diff changeset
68 gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), -1);
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13887
diff changeset
69 else if (strcmp(key+1, GNT_KEY_PGDOWN) == 0)
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13887
diff changeset
70 gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), ggconv->tv->priv.height - 2);
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13887
diff changeset
71 else if (strcmp(key+1, GNT_KEY_PGUP) == 0)
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13887
diff changeset
72 gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), -(ggconv->tv->priv.height - 2));
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13887
diff changeset
73 else
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13887
diff changeset
74 return FALSE;
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13887
diff changeset
75 return TRUE;
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13887
diff changeset
76 }
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
77
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
78 return FALSE;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
79 }
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
80
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
81 static void
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
82 closing_window(GntWidget *window, GGConv *ggconv)
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
83 {
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
84 ggconv->window = NULL;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
85 gaim_conversation_destroy(ggconv->conv);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
86 }
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
87
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
88 static void
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
89 gg_create_conversation(GaimConversation *conv)
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
90 {
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
91 GGConv *ggc = g_hash_table_lookup(ggconvs, conv);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
92 char *title;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
93 GaimConversationType type;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
94
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
95 if (ggc)
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
96 return;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
97
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
98 ggc = g_new0(GGConv, 1);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
99 g_hash_table_insert(ggconvs, conv, ggc);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
100
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
101 ggc->conv = conv;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
102
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
103 type = gaim_conversation_get_type(conv);
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
104 title = g_strdup_printf(_("%s"), gaim_conversation_get_name(conv));
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
105 ggc->window = gnt_box_new(FALSE, TRUE);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
106 gnt_box_set_title(GNT_BOX(ggc->window), title);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
107 gnt_box_set_toplevel(GNT_BOX(ggc->window), TRUE);
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13887
diff changeset
108 gnt_widget_set_name(ggc->window, title);
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
109
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
110 ggc->tv = gnt_text_view_new();
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
111 gnt_box_add_widget(GNT_BOX(ggc->window), ggc->tv);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
112 gnt_widget_set_name(ggc->tv, "conversation-window-textview");
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
113 gnt_widget_set_size(ggc->tv, getmaxx(stdscr) - 40, getmaxy(stdscr) - 15);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
114
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
115 ggc->entry = gnt_entry_new(NULL);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
116 gnt_box_add_widget(GNT_BOX(ggc->window), ggc->entry);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
117 gnt_widget_set_name(ggc->entry, "conversation-window-entry");
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
118 gnt_widget_set_size(ggc->entry, getmaxx(stdscr) - 40, 1);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
119
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
120 g_signal_connect(G_OBJECT(ggc->entry), "key_pressed", G_CALLBACK(entry_key_pressed), ggc);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
121 g_signal_connect(G_OBJECT(ggc->window), "destroy", G_CALLBACK(closing_window), ggc);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
122
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
123 gnt_widget_set_position(ggc->window, 32, 0);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
124 gnt_widget_show(ggc->window);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
125
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
126 g_free(title);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
127 }
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
128
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
129 static void
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
130 gg_destroy_conversation(GaimConversation *conv)
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
131 {
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
132 g_hash_table_remove(ggconvs, conv);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
133 }
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
134
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
135 static void
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
136 gg_write_common(GaimConversation *conv, const char *who, const char *message,
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
137 GaimMessageFlags flags, time_t mtime)
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
138 {
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
139 GGConv *ggconv = g_hash_table_lookup(ggconvs, conv);
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
140 char *strip;
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
141 GntTextViewFlags fl = 0;
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
142
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
143 g_return_if_fail(ggconv != NULL);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
144
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
145 if (who && *who && (flags & (GAIM_MESSAGE_SEND | GAIM_MESSAGE_RECV)))
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
146 {
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
147 char * name = g_strdup_printf("%s: ", who);
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
148 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv),
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
149 name, GNT_TEXT_FLAG_BOLD);
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
150 g_free(name);
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
151 }
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
152 else
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
153 fl = GNT_TEXT_FLAG_DIM;
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
154
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
155 if (flags & GAIM_MESSAGE_ERROR)
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
156 fl |= GNT_TEXT_FLAG_BOLD;
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
157 if (flags & GAIM_MESSAGE_NICK)
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
158 fl |= GNT_TEXT_FLAG_UNDERLINE;
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
159
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
160 strip = gaim_markup_strip_html(message);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
161 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv),
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
162 strip, fl);
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
163 gnt_text_view_next_line(GNT_TEXT_VIEW(ggconv->tv));
13886
90eb736b4c26 [gaim-migrate @ 16366]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
164 gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), 0);
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
165
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
166 g_free(strip);
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
167
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
168 if (flags & (GAIM_MESSAGE_RECV | GAIM_MESSAGE_NICK | GAIM_MESSAGE_ERROR))
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
169 gnt_widget_set_urgent(ggconv->tv);
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
170 }
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
171
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
172 static void
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
173 gg_write_chat(GaimConversation *conv, const char *who, const char *message,
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
174 GaimMessageFlags flags, time_t mtime)
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
175 {
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
176 gg_write_common(conv, who, message, flags, mtime);
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
177 }
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
178
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
179 static void
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
180 gg_write_im(GaimConversation *conv, const char *who, const char *message,
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
181 GaimMessageFlags flags, time_t mtime)
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
182 {
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
183 if (flags & GAIM_MESSAGE_SEND)
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
184 {
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
185 who = gaim_connection_get_display_name(conv->account->gc);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
186 if (!who)
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
187 who = gaim_account_get_alias(conv->account);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
188 if (!who)
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
189 who = gaim_account_get_username(conv->account);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
190 }
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
191 else if (flags & GAIM_MESSAGE_RECV)
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
192 who = gaim_conversation_get_name(conv);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
193
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
194 gg_write_common(conv, who, message, flags, mtime);
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
195 }
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
196
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
197 static void
13886
90eb736b4c26 [gaim-migrate @ 16366]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
198 gg_write_conv(GaimConversation *conv, const char *who, const char *alias,
90eb736b4c26 [gaim-migrate @ 16366]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
199 const char *message, GaimMessageFlags flags, time_t mtime)
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
200 {
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
201 const char *name;
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
202 if (alias && *alias)
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
203 name = alias;
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
204 else if (who && *who)
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
205 name = who;
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
206 else
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
207 name = NULL;
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
208
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
209 gg_write_common(conv, name, message, flags, mtime);
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
210 }
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
211
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
212 static void
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
213 gg_chat_add_users(GaimConversation *conv, GList *users, GList *flags, GList *aliases, gboolean new_arrivals)
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
214 {}
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
215
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
216 static void
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
217 gg_chat_rename_user(GaimConversation *conv, const char *old, const char *new_n, const char *new_a)
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
218 {}
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
219
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
220 static void
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
221 gg_chat_remove_user(GaimConversation *conv, GList *list)
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
222 {}
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
223
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
224 static void
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
225 gg_chat_update_user(GaimConversation *conv, const char *user)
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
226 {}
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
227
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
228 static GaimConversationUiOps conv_ui_ops =
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
229 {
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
230 .create_conversation = gg_create_conversation,
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
231 .destroy_conversation = gg_destroy_conversation,
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
232 .write_chat = gg_write_chat,
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
233 .write_im = gg_write_im,
13886
90eb736b4c26 [gaim-migrate @ 16366]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
234 .write_conv = gg_write_conv,
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
235 .chat_add_users = gg_chat_add_users,
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
236 .chat_rename_user = gg_chat_rename_user,
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
237 .chat_remove_users = gg_chat_remove_user,
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
238 .chat_update_user = gg_chat_update_user,
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
239 .present = NULL,
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
240 .has_focus = NULL,
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
241 .custom_smiley_add = NULL,
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
242 .custom_smiley_write = NULL,
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
243 .custom_smiley_close = NULL
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
244 };
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
245
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
246 static void
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
247 destroy_ggconv(gpointer data)
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
248 {
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
249 GGConv *conv = data;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
250 gnt_widget_destroy(conv->window);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
251 g_free(conv);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
252 }
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
253
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
254 GaimConversationUiOps *gg_conv_get_ui_ops()
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
255 {
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
256 return &conv_ui_ops;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
257 }
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
258
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
259
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
260 void gg_conversation_init()
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
261 {
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
262 ggconvs = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, destroy_ggconv);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
263 }
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
264
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
265 void gg_conversation_uninit()
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
266 {
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
267 g_hash_table_destroy(ggconvs);
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
268 ggconvs = NULL;
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
269 }
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
270