annotate console/gntconv.c @ 13977:96947ec79828

[gaim-migrate @ 16536] Eliminated some nested function declarations. committer: Tailor Script <tailor@pidgin.im>
author Mark Huetsch <markhuetsch>
date Sat, 22 Jul 2006 11:44:46 +0000
parents df8183b7fa2c
children a7b1d2ab9cb0
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>
13966
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
2
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
3 #include <cmds.h>
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
4 #include <util.h>
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
5
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
6 #include "gntgaim.h"
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
7 #include "gntblist.h"
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
8 #include "gntconv.h"
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
9
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
10 #include "gnt.h"
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
11 #include "gntbox.h"
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
12 #include "gntentry.h"
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
13 #include "gnttextview.h"
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
14
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
15 GHashTable *ggconvs;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
16
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
17 typedef struct _GGConv GGConv;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
18 typedef struct _GGConvChat GGConvChat;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
19 typedef struct _GGConvIm GGConvIm;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
20
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
21 struct _GGConv
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
22 {
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
23 GaimConversation *conv;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
24
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
25 GntWidget *window; /* the container */
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
26 GntWidget *entry; /* entry */
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
27 GntWidget *tv; /* text-view */
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
28
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
29 union
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
30 {
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
31 GGConvChat *chat;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
32 GGConvIm *im;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
33 } u;
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
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
36 struct _GGConvChat
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 GntWidget *userlist; /* the userlist */
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
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
41 struct _GGConvIm
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 void *nothing_for_now;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
44 };
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 static gboolean
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
47 entry_key_pressed(GntWidget *w, const char *key, GGConv *ggconv)
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
48 {
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
49 if (key[0] == '\r' && key[1] == 0)
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 const char *text = gnt_entry_get_text(GNT_ENTRY(ggconv->entry));
13938
82684a39f1ec [gaim-migrate @ 16469]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
52 if (*text == '/')
82684a39f1ec [gaim-migrate @ 16469]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
53 {
13966
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
54 GaimConversation *conv = ggconv->conv;
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
55 GaimCmdStatus status;
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
56 const char *cmdline = text + 1;
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
57 char *error = NULL, *escape;
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
58
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
59 escape = g_markup_escape_text(cmdline, -1);
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
60 status = gaim_cmd_do_command(conv, cmdline, escape, &error);
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
61 g_free(escape);
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
62
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
63 switch (status)
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
64 {
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
65 case GAIM_CMD_STATUS_OK:
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
66 break;
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
67 case GAIM_CMD_STATUS_NOT_FOUND:
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
68 gaim_conversation_write(conv, "", _("No such command."),
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
69 GAIM_MESSAGE_NO_LOG, time(NULL));
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
70 break;
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
71 case GAIM_CMD_STATUS_WRONG_ARGS:
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
72 gaim_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments "
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
73 "to that command."),
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
74 GAIM_MESSAGE_NO_LOG, time(NULL));
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
75 break;
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
76 case GAIM_CMD_STATUS_FAILED:
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
77 gaim_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."),
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
78 GAIM_MESSAGE_NO_LOG, time(NULL));
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
79 break;
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
80 case GAIM_CMD_STATUS_WRONG_TYPE:
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
81 if(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM)
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
82 gaim_conversation_write(conv, "", _("That command only works in chats, not IMs."),
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
83 GAIM_MESSAGE_NO_LOG, time(NULL));
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
84 else
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
85 gaim_conversation_write(conv, "", _("That command only works in IMs, not chats."),
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
86 GAIM_MESSAGE_NO_LOG, time(NULL));
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
87 break;
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
88 case GAIM_CMD_STATUS_WRONG_PRPL:
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
89 gaim_conversation_write(conv, "", _("That command doesn't work on this protocol."),
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
90 GAIM_MESSAGE_NO_LOG, time(NULL));
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
91 break;
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
92 }
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
93 g_free(error);
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
94 #if 0
13938
82684a39f1ec [gaim-migrate @ 16469]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
95 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv),
82684a39f1ec [gaim-migrate @ 16469]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
96 _("Commands are not supported yet. Message was NOT sent."),
82684a39f1ec [gaim-migrate @ 16469]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
97 GNT_TEXT_FLAG_DIM | GNT_TEXT_FLAG_UNDERLINE);
82684a39f1ec [gaim-migrate @ 16469]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
98 gnt_text_view_next_line(GNT_TEXT_VIEW(ggconv->tv));
82684a39f1ec [gaim-migrate @ 16469]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
99 gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), 0);
13966
80cbf6c2d562 [gaim-migrate @ 16522]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
100 #endif
13938
82684a39f1ec [gaim-migrate @ 16469]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
101 }
82684a39f1ec [gaim-migrate @ 16469]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
102 else
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
103 {
13938
82684a39f1ec [gaim-migrate @ 16469]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
104 switch (gaim_conversation_get_type(ggconv->conv))
82684a39f1ec [gaim-migrate @ 16469]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
105 {
82684a39f1ec [gaim-migrate @ 16469]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
106 case GAIM_CONV_TYPE_IM:
82684a39f1ec [gaim-migrate @ 16469]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
107 gaim_conv_im_send_with_flags(GAIM_CONV_IM(ggconv->conv), text, GAIM_MESSAGE_SEND);
82684a39f1ec [gaim-migrate @ 16469]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
108 break;
82684a39f1ec [gaim-migrate @ 16469]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
109 case GAIM_CONV_TYPE_CHAT:
82684a39f1ec [gaim-migrate @ 16469]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
110 gaim_conv_chat_send(GAIM_CONV_CHAT(ggconv->conv), text);
82684a39f1ec [gaim-migrate @ 16469]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
111 break;
82684a39f1ec [gaim-migrate @ 16469]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
112 default:
82684a39f1ec [gaim-migrate @ 16469]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
113 g_return_val_if_reached(FALSE);
82684a39f1ec [gaim-migrate @ 16469]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
114 }
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
115 }
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
116 gnt_entry_clear(GNT_ENTRY(ggconv->entry));
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
117 return TRUE;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
118 }
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13887
diff changeset
119 else if (key[0] == 27)
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13887
diff changeset
120 {
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13887
diff changeset
121 if (strcmp(key+1, GNT_KEY_DOWN) == 0)
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13887
diff changeset
122 gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), 1);
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13887
diff changeset
123 else if (strcmp(key+1, GNT_KEY_UP) == 0)
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13887
diff changeset
124 gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), -1);
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13887
diff changeset
125 else if (strcmp(key+1, GNT_KEY_PGDOWN) == 0)
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13887
diff changeset
126 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
127 else if (strcmp(key+1, GNT_KEY_PGUP) == 0)
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13887
diff changeset
128 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
129 else
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13887
diff changeset
130 return FALSE;
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13887
diff changeset
131 return TRUE;
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13887
diff changeset
132 }
13885
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 return FALSE;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
135 }
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
136
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
137 static void
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
138 closing_window(GntWidget *window, GGConv *ggconv)
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
139 {
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
140 ggconv->window = NULL;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
141 gaim_conversation_destroy(ggconv->conv);
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
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
144 static void
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
145 gg_create_conversation(GaimConversation *conv)
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
146 {
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
147 GGConv *ggc = g_hash_table_lookup(ggconvs, conv);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
148 char *title;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
149 GaimConversationType type;
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
150 int x, width;
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
151
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
152 if (ggc)
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
153 return;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
154
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
155 gg_blist_get_position(&x, NULL);
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
156 gg_blist_get_size(&width, NULL);
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
157
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
158 ggc = g_new0(GGConv, 1);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
159 g_hash_table_insert(ggconvs, conv, ggc);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
160
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
161 ggc->conv = conv;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
162
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
163 type = gaim_conversation_get_type(conv);
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
164 title = g_strdup_printf(_("%s"), gaim_conversation_get_name(conv));
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13938
diff changeset
165 ggc->window = gnt_box_new(FALSE, TRUE);
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
166 gnt_box_set_title(GNT_BOX(ggc->window), title);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
167 gnt_box_set_toplevel(GNT_BOX(ggc->window), TRUE);
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
168 gnt_box_set_pad(GNT_BOX(ggc->window), 0);
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13887
diff changeset
169 gnt_widget_set_name(ggc->window, title);
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
170
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
171 ggc->tv = gnt_text_view_new();
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
172 gnt_box_add_widget(GNT_BOX(ggc->window), ggc->tv);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
173 gnt_widget_set_name(ggc->tv, "conversation-window-textview");
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13916
diff changeset
174 gnt_widget_set_size(ggc->tv, getmaxx(stdscr) - 3 - x - width, getmaxy(stdscr) - 5);
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
175
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
176 ggc->entry = gnt_entry_new(NULL);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
177 gnt_box_add_widget(GNT_BOX(ggc->window), ggc->entry);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
178 gnt_widget_set_name(ggc->entry, "conversation-window-entry");
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
179
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
180 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
181 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
182
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
183 /* XXX: I am assuming the buddylist is on the leftmost corner.
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
184 * That may not always be correct, since the windows can be moved.
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
185 * It might be an option to remember the position of conv. windows. */
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
186 gnt_widget_set_position(ggc->window, x + width, 0);
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
187 gnt_widget_show(ggc->window);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
188
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
189 g_free(title);
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
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
192 static void
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
193 gg_destroy_conversation(GaimConversation *conv)
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
194 {
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
195 g_hash_table_remove(ggconvs, conv);
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
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
198 static void
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
199 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
200 GaimMessageFlags flags, time_t mtime)
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
201 {
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
202 GGConv *ggconv = g_hash_table_lookup(ggconvs, conv);
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
203 char *strip;
13931
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
204 GntTextFormatFlags fl = 0;
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
205
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
206 g_return_if_fail(ggconv != NULL);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
207
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
208 if (who && *who && (flags & (GAIM_MESSAGE_SEND | GAIM_MESSAGE_RECV)))
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
209 {
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
210 char * name = g_strdup_printf("%s: ", who);
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
211 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
212 name, GNT_TEXT_FLAG_BOLD);
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
213 g_free(name);
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
214 }
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
215 else
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
216 fl = GNT_TEXT_FLAG_DIM;
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
217
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
218 if (flags & GAIM_MESSAGE_ERROR)
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
219 fl |= GNT_TEXT_FLAG_BOLD;
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
220 if (flags & GAIM_MESSAGE_NICK)
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
221 fl |= GNT_TEXT_FLAG_UNDERLINE;
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
222
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
223 strip = gaim_markup_strip_html(message);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
224 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
225 strip, fl);
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
226 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
227 gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), 0);
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
228
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
229 g_free(strip);
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
230
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
231 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
232 gnt_widget_set_urgent(ggconv->tv);
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
233 }
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
234
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
235 static void
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
236 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
237 GaimMessageFlags flags, time_t mtime)
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
238 {
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
239 gg_write_common(conv, who, message, flags, mtime);
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
240 }
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
241
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
242 static void
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
243 gg_write_im(GaimConversation *conv, const char *who, const char *message,
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
244 GaimMessageFlags flags, time_t mtime)
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 if (flags & GAIM_MESSAGE_SEND)
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
247 {
13971
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
248 GaimAccount *account = gaim_conversation_get_account(conv);
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
249 who = gaim_connection_get_display_name(gaim_account_get_connection(account));
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
250 if (!who)
13971
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
251 who = gaim_account_get_alias(account);
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
252 if (!who)
13971
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
253 who = gaim_account_get_username(account);
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
254 }
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
255 else if (flags & GAIM_MESSAGE_RECV)
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
256 who = gaim_conversation_get_name(conv);
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
257
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
258 gg_write_common(conv, who, message, flags, mtime);
13885
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
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
261 static void
13886
90eb736b4c26 [gaim-migrate @ 16366]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
262 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
263 const char *message, GaimMessageFlags flags, time_t mtime)
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
264 {
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
265 const char *name;
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
266 if (alias && *alias)
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
267 name = alias;
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
268 else if (who && *who)
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
269 name = who;
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
270 else
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
271 name = NULL;
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
272
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
273 gg_write_common(conv, name, message, flags, mtime);
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
274 }
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
275
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
276 static void
13971
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
277 gg_chat_add_users(GaimConversation *conv, GList *users, gboolean new_arrivals)
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
278 {
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
279 if (!new_arrivals)
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
280 {
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
281 /* Print the list of users in the room */
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
282 GString *string = g_string_new(_("List of users:\n"));
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
283 GList *iter;
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
284
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
285 for (iter = users; iter; iter = iter->next)
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
286 {
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
287 GaimConvChatBuddy *cbuddy = iter->data;
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
288 char *str;
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
289
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
290 if ((str = cbuddy->alias) == NULL)
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
291 str = cbuddy->name;
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
292 g_string_append_printf(string, "[ %s ]", str);
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
293 }
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
294
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
295 gaim_conversation_write(conv, NULL, string->str,
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
296 GAIM_MESSAGE_SYSTEM, time(NULL));
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
297 g_string_free(string, TRUE);
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
298 }
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
299 /* XXX: Add the names for string completion */
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
300 }
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
301
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
302 static void
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
303 gg_chat_rename_user(GaimConversation *conv, const char *old, const char *new_n, const char *new_a)
13971
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
304 {
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
305 /* XXX: Update the name for string completion */
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
306 }
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
307
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
308 static void
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
309 gg_chat_remove_user(GaimConversation *conv, GList *list)
13971
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
310 {
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
311 /* XXX: Remove the name from string completion */
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
312 }
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
313
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
314 static void
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
315 gg_chat_update_user(GaimConversation *conv, const char *user)
13971
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
316 {
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
317 /* XXX: This probably will not require updating the string completion */
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
318 }
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
319
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
320 static GaimConversationUiOps conv_ui_ops =
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
321 {
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
322 .create_conversation = gg_create_conversation,
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
323 .destroy_conversation = gg_destroy_conversation,
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
324 .write_chat = gg_write_chat,
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
325 .write_im = gg_write_im,
13886
90eb736b4c26 [gaim-migrate @ 16366]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
326 .write_conv = gg_write_conv,
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
327 .chat_add_users = gg_chat_add_users,
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
328 .chat_rename_user = gg_chat_rename_user,
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
329 .chat_remove_users = gg_chat_remove_user,
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
330 .chat_update_user = gg_chat_update_user,
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
331 .present = NULL,
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
332 .has_focus = NULL,
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
333 .custom_smiley_add = NULL,
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
334 .custom_smiley_write = NULL,
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
335 .custom_smiley_close = NULL
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
336 };
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
337
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
338 static void
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
339 destroy_ggconv(gpointer data)
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
340 {
13971
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
341 GGConv *ggconv = data;
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
342 gnt_widget_destroy(ggconv->window);
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
343 g_free(ggconv);
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
344 }
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
345
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
346 GaimConversationUiOps *gg_conv_get_ui_ops()
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
347 {
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
348 return &conv_ui_ops;
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
349 }
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
350
13971
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
351 /* Xerox */
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
352 static GaimCmdRet
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
353 say_command_cb(GaimConversation *conv,
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
354 const char *cmd, char **args, char **error, void *data)
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
355 {
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
356 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM)
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
357 gaim_conv_im_send(GAIM_CONV_IM(conv), args[0]);
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
358 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT)
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
359 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), args[0]);
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
360
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
361 return GAIM_CMD_RET_OK;
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
362 }
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
363
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
364 /* Xerox */
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
365 static GaimCmdRet
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
366 me_command_cb(GaimConversation *conv,
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
367 const char *cmd, char **args, char **error, void *data)
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
368 {
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
369 char *tmp;
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
370
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
371 tmp = g_strdup_printf("/me %s", args[0]);
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
372
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
373 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM)
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
374 gaim_conv_im_send(GAIM_CONV_IM(conv), tmp);
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
375 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT)
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
376 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), tmp);
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
377
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
378 g_free(tmp);
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
379 return GAIM_CMD_RET_OK;
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
380 }
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
381
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
382 /* Xerox */
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
383 static GaimCmdRet
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
384 debug_command_cb(GaimConversation *conv,
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
385 const char *cmd, char **args, char **error, void *data)
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
386 {
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
387 char *tmp, *markup;
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
388 GaimCmdStatus status;
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
389
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
390 if (!g_ascii_strcasecmp(args[0], "version")) {
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
391 tmp = g_strdup_printf("me is using %s.", VERSION);
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
392 markup = g_markup_escape_text(tmp, -1);
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
393
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
394 status = gaim_cmd_do_command(conv, tmp, markup, error);
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
395
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
396 g_free(tmp);
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
397 g_free(markup);
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
398 return status;
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
399 } else {
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
400 gaim_conversation_write(conv, NULL, _("Supported debug options are: version"),
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
401 GAIM_MESSAGE_NO_LOG|GAIM_MESSAGE_ERROR, time(NULL));
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
402 return GAIM_CMD_STATUS_OK;
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
403 }
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
404 }
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
405
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
406 /* Xerox */
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
407 static GaimCmdRet
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
408 clear_command_cb(GaimConversation *conv,
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
409 const char *cmd, char **args, char **error, void *data)
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
410 {
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
411 GGConv *ggconv = conv->ui_data;
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
412 gnt_text_view_clear(GNT_TEXT_VIEW(ggconv->tv));
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
413 return GAIM_CMD_STATUS_OK;
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
414 }
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
415
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
416 /* Xerox */
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
417 static GaimCmdRet
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
418 help_command_cb(GaimConversation *conv,
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
419 const char *cmd, char **args, char **error, void *data)
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
420 {
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
421 GList *l, *text;
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
422 GString *s;
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
423
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
424 if (args[0] != NULL) {
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
425 s = g_string_new("");
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
426 text = gaim_cmd_help(conv, args[0]);
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
427
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
428 if (text) {
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
429 for (l = text; l; l = l->next)
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
430 if (l->next)
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
431 g_string_append_printf(s, "%s\n", (char *)l->data);
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
432 else
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
433 g_string_append_printf(s, "%s", (char *)l->data);
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
434 } else {
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
435 g_string_append(s, _("No such command (in this context)."));
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
436 }
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
437 } else {
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
438 s = g_string_new(_("Use \"/help &lt;command&gt;\" for help on a specific command.\n"
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
439 "The following commands are available in this context:\n"));
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
440
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
441 text = gaim_cmd_list(conv);
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
442 for (l = text; l; l = l->next)
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
443 if (l->next)
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
444 g_string_append_printf(s, "%s, ", (char *)l->data);
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
445 else
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
446 g_string_append_printf(s, "%s.", (char *)l->data);
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
447 g_list_free(text);
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
448 }
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
449
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
450 gaim_conversation_write(conv, NULL, s->str, GAIM_MESSAGE_NO_LOG, time(NULL));
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
451 g_string_free(s, TRUE);
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
452
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
453 return GAIM_CMD_STATUS_OK;
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
454 }
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
455
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
456
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
457 void gg_conversation_init()
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
458 {
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
459 ggconvs = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, destroy_ggconv);
13971
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
460
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
461 /* Xerox */
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
462 gaim_cmd_register("say", "S", GAIM_CMD_P_DEFAULT,
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
463 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL,
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
464 say_command_cb, _("say &lt;message&gt;: Send a message normally as if you weren't using a command."), NULL);
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
465 gaim_cmd_register("me", "S", GAIM_CMD_P_DEFAULT,
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
466 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL,
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
467 me_command_cb, _("me &lt;action&gt;: Send an IRC style action to a buddy or chat."), NULL);
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
468 gaim_cmd_register("debug", "w", GAIM_CMD_P_DEFAULT,
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
469 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL,
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
470 debug_command_cb, _("debug &lt;option&gt;: Send various debug information to the current conversation."), NULL);
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
471 gaim_cmd_register("clear", "", GAIM_CMD_P_DEFAULT,
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
472 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL,
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
473 clear_command_cb, _("clear: Clears the conversation scrollback."), NULL);
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
474 gaim_cmd_register("help", "w", GAIM_CMD_P_DEFAULT,
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
475 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, NULL,
df8183b7fa2c [gaim-migrate @ 16529]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13966
diff changeset
476 help_command_cb, _("help &lt;command&gt;: Help on a specific command."), NULL);
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
477 }
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
478
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
479 void gg_conversation_uninit()
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
480 {
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
481 g_hash_table_destroy(ggconvs);
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
482 ggconvs = NULL;
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
483 }
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
484