annotate src/protocols/silc/wb.c @ 12498:a2de852981c1

[gaim-migrate @ 14810] SF Patch #1380806 from charkins "leave docklet loaded when notification area is not present" "From the summary, this sounds weird, but I think its better behavior. This really only effects some odd corner cases. The existing behavior is that the docklet plugin unloads itself after 10 seconds if the tray icon isn't created. The behavior with this patch is that there is a 3 second timeout (this is necessary to avoid race condition when restoring the gtkblist's visibility state on startup). After this timeout, the docklet plugin stays loaded waiting for a notification to appear, but is essentially non-functional. In the typical scenario, this patch doesn't effect the behavior. Here are some examples of where it does matter: 1) If gaim is closed with the buddy list hidden to the docklet, then gaim is started again without a notification area, the buddy list doesn't show up for 10 seconds (the time it takes for the docklet to timeout). This patch would reduce this to 3 seconds. 2) If the user removes the notification area from their panel, maybe to remove it from one panel and add it to a different panel, but doesn't add a new one back within 10 seconds, the current behavior would cause the docklet plugin to be unloaded. With this patch, the tray icon would automatically be added to the new notification area when it becomes available. 3) The gnome-panel dies and is not restarted within 10 seconds. Similar to #2. (There was a bug filed for this, but can't find it right now). My main concern was that it could be confusing to the user if they enable the docklet plugin, then 10 seconds later it gets disabled without any notification. This patch doesn't add any notification, but leaves the plugin running so it will automatically use a notification area when one becomes available. I also removed an unused parameter from docklet_remove() and changed the plugin description slightly to reflect the change in queuing/notification. Not sure how clear this is, so bug me on #gaim if you have any questions. --charkins" I made a few changes to this patch, but nothing terribly significant... committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Fri, 16 Dec 2005 09:16:14 +0000
parents 5851a9219bc7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12058
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1 /*
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
3 wb.c
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
4
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
5 Author: Pekka Riikonen <priikone@silcnet.org>
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
6
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
7 Copyright (C) 2005 Pekka Riikonen
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
8
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
9 This program is free software; you can redistribute it and/or modify
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
10 it under the terms of the GNU General Public License as published by
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
11 the Free Software Foundation; version 2 of the License.
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
12
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
13 This program is distributed in the hope that it will be useful,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
16 GNU General Public License for more details.
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
17
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
18 */
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
19
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
20 #include "silcincludes.h"
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
21 #include "silcclient.h"
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
22 #include "silcgaim.h"
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
23 #include "wb.h"
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
24
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
25 /*
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
26 SILC Whiteboard packet:
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
27
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
28 1 byte command
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
29 2 bytes width
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
30 2 bytes height
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
31 4 bytes brush color
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
32 2 bytes brush size
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
33 n bytes data
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
34
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
35 Data:
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
36
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
37 4 bytes x
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
38 4 bytes y
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
39
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
40 Commands:
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
41
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
42 0x01 draw
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
43 0x02 clear
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
44
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
45 MIME:
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
46
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
47 MIME-Version: 1.0
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
48 Content-Type: application/x-wb
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
49 Content-Transfer-Encoding: binary
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
50
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
51 */
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
52
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
53 #define SILCGAIM_WB_MIME "MIME-Version: 1.0\r\nContent-Type: application/x-wb\r\nContent-Transfer-Encoding: binary\r\n\r\n"
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
54 #define SILCGAIM_WB_HEADER strlen(SILCGAIM_WB_MIME) + 11
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
55
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
56 #define SILCGAIM_WB_WIDTH 500
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
57 #define SILCGAIM_WB_HEIGHT 400
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
58 #define SILCGAIM_WB_WIDTH_MAX 1024
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
59 #define SILCGAIM_WB_HEIGHT_MAX 1024
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
60
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
61 /* Commands */
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
62 typedef enum {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
63 SILCGAIM_WB_DRAW = 0x01,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
64 SILCGAIM_WB_CLEAR = 0x02,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
65 } SilcGaimWbCommand;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
66
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
67 /* Brush size */
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
68 typedef enum {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
69 SILCGAIM_WB_BRUSH_SMALL = 2,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
70 SILCGAIM_WB_BRUSH_MEDIUM = 5,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
71 SILCGAIM_WB_BRUSH_LARGE = 10,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
72 } SilcGaimWbBrushSize;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
73
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
74 /* Brush color (XXX Gaim should provide default colors) */
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
75 typedef enum {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
76 SILCGAIM_WB_COLOR_BLACK = 0,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
77 SILCGAIM_WB_COLOR_RED = 13369344,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
78 SILCGAIM_WB_COLOR_GREEN = 52224,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
79 SILCGAIM_WB_COLOR_BLUE = 204,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
80 SILCGAIM_WB_COLOR_YELLOW = 15658496,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
81 SILCGAIM_WB_COLOR_ORANGE = 16737792,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
82 SILCGAIM_WB_COLOR_CYAN = 52428,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
83 SILCGAIM_WB_COLOR_VIOLET = 5381277,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
84 SILCGAIM_WB_COLOR_PURPLE = 13369548,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
85 SILCGAIM_WB_COLOR_TAN = 12093547,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
86 SILCGAIM_WB_COLOR_BROWN = 5256485,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
87 SILCGAIM_WB_COLOR_GREY = 11184810,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
88 SILCGAIM_WB_COLOR_WHITE = 16777215,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
89 } SilcGaimWbColor;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
90
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
91 typedef struct {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
92 int type; /* 0 = buddy, 1 = channel */
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
93 union {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
94 SilcClientEntry client;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
95 SilcChannelEntry channel;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
96 } u;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
97 int width;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
98 int height;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
99 int brush_size;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
100 int brush_color;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
101 } *SilcGaimWb;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
102
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
103 /* Initialize whiteboard */
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
104
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
105 GaimWhiteboard *silcgaim_wb_init(SilcGaim sg, SilcClientEntry client_entry)
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
106 {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
107 SilcClientConnection conn;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
108 GaimWhiteboard *wb;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
109 SilcGaimWb wbs;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
110
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
111 conn = sg->conn;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
112 wb = gaim_whiteboard_get_session(sg->account, client_entry->nickname);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
113 if (!wb)
12167
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
114 wb = gaim_whiteboard_create(sg->account, client_entry->nickname, 0);
12058
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
115 if (!wb)
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
116 return NULL;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
117
12167
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
118 if (!wb->proto_data) {
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
119 wbs = silc_calloc(1, sizeof(*wbs));
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
120 if (!wbs)
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
121 return NULL;
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
122 wbs->type = 0;
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
123 wbs->u.client = client_entry;
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
124 wbs->width = SILCGAIM_WB_WIDTH;
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
125 wbs->height = SILCGAIM_WB_HEIGHT;
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
126 wbs->brush_size = SILCGAIM_WB_BRUSH_SMALL;
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
127 wbs->brush_color = SILCGAIM_WB_COLOR_BLACK;
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
128 wb->proto_data = wbs;
12058
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
129
12167
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
130 /* Start the whiteboard */
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
131 gaim_whiteboard_start(wb);
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
132 gaim_whiteboard_clear(wb);
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
133 }
12058
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
134
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
135 return wb;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
136 }
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
137
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
138 GaimWhiteboard *silcgaim_wb_init_ch(SilcGaim sg, SilcChannelEntry channel)
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
139 {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
140 GaimWhiteboard *wb;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
141 SilcGaimWb wbs;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
142
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
143 wb = gaim_whiteboard_get_session(sg->account, channel->channel_name);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
144 if (!wb)
12167
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
145 wb = gaim_whiteboard_create(sg->account, channel->channel_name, 0);
12058
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
146 if (!wb)
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
147 return NULL;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
148
12167
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
149 if (!wb->proto_data) {
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
150 wbs = silc_calloc(1, sizeof(*wbs));
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
151 if (!wbs)
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
152 return NULL;
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
153 wbs->type = 1;
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
154 wbs->u.channel = channel;
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
155 wbs->width = SILCGAIM_WB_WIDTH;
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
156 wbs->height = SILCGAIM_WB_HEIGHT;
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
157 wbs->brush_size = SILCGAIM_WB_BRUSH_SMALL;
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
158 wbs->brush_color = SILCGAIM_WB_COLOR_BLACK;
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
159 wb->proto_data = wbs;
12058
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
160
12167
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
161 /* Start the whiteboard */
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
162 gaim_whiteboard_start(wb);
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
163 gaim_whiteboard_clear(wb);
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
164 }
12058
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
165
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
166 return wb;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
167 }
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
168
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
169 static void
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
170 silcgaim_wb_parse(SilcGaimWb wbs, GaimWhiteboard *wb,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
171 unsigned char *message, SilcUInt32 message_len)
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
172 {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
173 SilcUInt8 command;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
174 SilcUInt16 width, height, brush_size;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
175 SilcUInt32 brush_color, x, y, dx, dy;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
176 SilcBufferStruct buf;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
177 int ret;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
178
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
179 /* Parse the packet */
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
180 silc_buffer_set(&buf, message, message_len);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
181 ret = silc_buffer_unformat(&buf,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
182 SILC_STR_UI_CHAR(&command),
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
183 SILC_STR_UI_SHORT(&width),
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
184 SILC_STR_UI_SHORT(&height),
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
185 SILC_STR_UI_INT(&brush_color),
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
186 SILC_STR_UI_SHORT(&brush_size),
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
187 SILC_STR_END);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
188 if (ret < 0)
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
189 return;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
190 silc_buffer_pull(&buf, ret);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
191
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
192 /* Update whiteboard if its dimensions changed */
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
193 if (width != wbs->width || height != wbs->height)
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
194 silcgaim_wb_set_dimensions(wb, height, width);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
195
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
196 if (command == SILCGAIM_WB_DRAW) {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
197 /* Parse data and draw it */
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
198 ret = silc_buffer_unformat(&buf,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
199 SILC_STR_UI_INT(&dx),
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
200 SILC_STR_UI_INT(&dy),
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
201 SILC_STR_END);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
202 if (ret < 0)
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
203 return;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
204 silc_buffer_pull(&buf, 8);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
205 x = dx;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
206 y = dy;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
207 while (buf.len > 0) {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
208 ret = silc_buffer_unformat(&buf,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
209 SILC_STR_UI_INT(&dx),
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
210 SILC_STR_UI_INT(&dy),
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
211 SILC_STR_END);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
212 if (ret < 0)
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
213 return;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
214 silc_buffer_pull(&buf, 8);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
215
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
216 gaim_whiteboard_draw_line(wb, x, y, x + dx, y + dy,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
217 brush_color, brush_size);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
218 x += dx;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
219 y += dy;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
220 }
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
221 }
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
222
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
223 if (command == SILCGAIM_WB_CLEAR)
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
224 gaim_whiteboard_clear(wb);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
225 }
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
226
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
227 typedef struct {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
228 unsigned char *message;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
229 SilcUInt32 message_len;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
230 SilcGaim sg;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
231 SilcClientEntry sender;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
232 SilcChannelEntry channel;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
233 } *SilcGaimWbRequest;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
234
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
235 static void
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
236 silcgaim_wb_request_cb(SilcGaimWbRequest req, gint id)
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
237 {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
238 GaimWhiteboard *wb;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
239
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
240 if (id != 1)
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
241 goto out;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
242
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
243 if (!req->channel)
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
244 wb = silcgaim_wb_init(req->sg, req->sender);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
245 else
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
246 wb = silcgaim_wb_init_ch(req->sg, req->channel);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
247
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
248 silcgaim_wb_parse(wb->proto_data, wb, req->message, req->message_len);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
249
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
250 out:
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
251 silc_free(req->message);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
252 silc_free(req);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
253 }
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
254
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
255 static void
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
256 silcgaim_wb_request(SilcClient client, const unsigned char *message,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
257 SilcUInt32 message_len, SilcClientEntry sender,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
258 SilcChannelEntry channel)
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
259 {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
260 char tmp[128];
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
261 SilcGaimWbRequest req;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
262 GaimConnection *gc;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
263 SilcGaim sg;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
264
12167
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
265 gc = client->application;
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
266 sg = gc->proto_data;
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
267
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
268 /* Open whiteboard automatically if requested */
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
269 if (gaim_account_get_bool(sg->account, "open-wb", FALSE)) {
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
270 GaimWhiteboard *wb;
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
271
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
272 if (!channel)
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
273 wb = silcgaim_wb_init(sg, sender);
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
274 else
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
275 wb = silcgaim_wb_init_ch(sg, channel);
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
276
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
277 silcgaim_wb_parse(wb->proto_data, wb, (unsigned char *)message,
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
278 message_len);
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
279 return;
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
280 }
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
281
12058
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
282 if (!channel) {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
283 g_snprintf(tmp, sizeof(tmp),
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
284 _("%s sent message to whiteboard. Would you like "
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
285 "to open the whiteboard?"), sender->nickname);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
286 } else {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
287 g_snprintf(tmp, sizeof(tmp),
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
288 _("%s sent message to whiteboard on %s channel. "
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
289 "Would you like to open the whiteboard?"),
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
290 sender->nickname, channel->channel_name);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
291 }
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
292
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
293 req = silc_calloc(1, sizeof(*req));
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
294 if (!req)
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
295 return;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
296 req->message = silc_memdup(message, message_len);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
297 req->message_len = message_len;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
298 req->sender = sender;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
299 req->channel = channel;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
300 req->sg = sg;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
301
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
302 gaim_request_action(gc, _("Whiteboard"), tmp, NULL, 1, req, 2,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
303 _("Yes"), G_CALLBACK(silcgaim_wb_request_cb),
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
304 _("No"), G_CALLBACK(silcgaim_wb_request_cb));
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
305 }
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
306
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
307 /* Process incoming whiteboard message */
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
308
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
309 void silcgaim_wb_receive(SilcClient client, SilcClientConnection conn,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
310 SilcClientEntry sender, SilcMessagePayload payload,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
311 SilcMessageFlags flags, const unsigned char *message,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
312 SilcUInt32 message_len)
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
313 {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
314 SilcGaim sg;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
315 GaimConnection *gc;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
316 GaimWhiteboard *wb;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
317 SilcGaimWb wbs;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
318
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
319 gc = client->application;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
320 sg = gc->proto_data;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
321
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
322 wb = gaim_whiteboard_get_session(sg->account, sender->nickname);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
323 if (!wb) {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
324 /* Ask user if they want to open the whiteboard */
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
325 silcgaim_wb_request(client, message, message_len,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
326 sender, NULL);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
327 return;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
328 }
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
329
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
330 wbs = wb->proto_data;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
331 silcgaim_wb_parse(wbs, wb, (unsigned char *)message, message_len);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
332 }
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
333
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
334 /* Process incoming whiteboard message on channel */
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
335
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
336 void silcgaim_wb_receive_ch(SilcClient client, SilcClientConnection conn,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
337 SilcClientEntry sender, SilcChannelEntry channel,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
338 SilcMessagePayload payload,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
339 SilcMessageFlags flags,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
340 const unsigned char *message,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
341 SilcUInt32 message_len)
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
342 {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
343 SilcGaim sg;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
344 GaimConnection *gc;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
345 GaimWhiteboard *wb;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
346 SilcGaimWb wbs;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
347
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
348 gc = client->application;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
349 sg = gc->proto_data;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
350
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
351 wb = gaim_whiteboard_get_session(sg->account, channel->channel_name);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
352 if (!wb) {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
353 /* Ask user if they want to open the whiteboard */
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
354 silcgaim_wb_request(client, message, message_len,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
355 sender, channel);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
356 return;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
357 }
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
358
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
359 wbs = wb->proto_data;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
360 silcgaim_wb_parse(wbs, wb, (unsigned char *)message, message_len);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
361 }
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
362
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
363 /* Send whiteboard message */
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
364
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
365 void silcgaim_wb_send(GaimWhiteboard *wb, GList *draw_list)
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
366 {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
367 SilcGaimWb wbs = wb->proto_data;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
368 SilcBuffer packet;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
369 GList *list;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
370 int len;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
371 GaimConnection *gc;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
372 SilcGaim sg;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
373
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
374 g_return_if_fail(draw_list);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
375 gc = gaim_account_get_connection(wb->account);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
376 g_return_if_fail(gc);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
377 sg = gc->proto_data;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
378 g_return_if_fail(sg);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
379
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
380 len = SILCGAIM_WB_HEADER;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
381 for (list = draw_list; list; list = list->next)
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
382 len += 4;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
383
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
384 packet = silc_buffer_alloc_size(len);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
385 if (!packet)
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
386 return;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
387
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
388 /* Assmeble packet */
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
389 silc_buffer_format(packet,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
390 SILC_STR_UI32_STRING(SILCGAIM_WB_MIME),
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
391 SILC_STR_UI_CHAR(SILCGAIM_WB_DRAW),
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
392 SILC_STR_UI_SHORT(wbs->width),
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
393 SILC_STR_UI_SHORT(wbs->height),
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
394 SILC_STR_UI_INT(wbs->brush_color),
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
395 SILC_STR_UI_SHORT(wbs->brush_size),
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
396 SILC_STR_END);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
397 silc_buffer_pull(packet, SILCGAIM_WB_HEADER);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
398 for (list = draw_list; list; list = list->next) {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
399 silc_buffer_format(packet,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
400 SILC_STR_UI_INT(GPOINTER_TO_INT(list->data)),
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
401 SILC_STR_END);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
402 silc_buffer_pull(packet, 4);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
403 }
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
404
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
405 /* Send the message */
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
406 if (wbs->type == 0) {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
407 /* Private message */
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
408 silc_client_send_private_message(sg->client, sg->conn,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
409 wbs->u.client,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
410 SILC_MESSAGE_FLAG_DATA,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
411 packet->head, len, TRUE);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
412 } else if (wbs->type == 1) {
12167
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
413 /* Channel message. Channel private keys are not supported. */
12058
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
414 silc_client_send_channel_message(sg->client, sg->conn,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
415 wbs->u.channel, NULL,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
416 SILC_MESSAGE_FLAG_DATA,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
417 packet->head, len, TRUE);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
418 }
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
419
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
420 silc_buffer_free(packet);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
421 }
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
422
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
423 /* Gaim Whiteboard operations */
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
424
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
425 void silcgaim_wb_start(GaimWhiteboard *wb)
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
426 {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
427 /* Nothing here. Everything is in initialization */
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
428 }
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
429
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
430 void silcgaim_wb_end(GaimWhiteboard *wb)
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
431 {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
432 silc_free(wb->proto_data);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
433 wb->proto_data = NULL;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
434 }
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
435
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
436 void silcgaim_wb_get_dimensions(GaimWhiteboard *wb, int *width, int *height)
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
437 {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
438 SilcGaimWb wbs = wb->proto_data;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
439 *width = wbs->width;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
440 *height = wbs->height;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
441 }
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
442
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
443 void silcgaim_wb_set_dimensions(GaimWhiteboard *wb, int width, int height)
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
444 {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
445 SilcGaimWb wbs = wb->proto_data;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
446 wbs->width = width > SILCGAIM_WB_WIDTH_MAX ? SILCGAIM_WB_WIDTH_MAX :
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
447 width;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
448 wbs->height = height > SILCGAIM_WB_HEIGHT_MAX ? SILCGAIM_WB_HEIGHT_MAX :
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
449 height;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
450
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
451 /* Update whiteboard */
12167
5851a9219bc7 [gaim-migrate @ 14468]
Ethan Blanton <elb@pidgin.im>
parents: 12058
diff changeset
452 gaim_whiteboard_set_dimensions(wb, wbs->width, wbs->height);
12058
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
453 }
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
454
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
455 void silcgaim_wb_get_brush(GaimWhiteboard *wb, int *size, int *color)
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
456 {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
457 SilcGaimWb wbs = wb->proto_data;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
458 *size = wbs->brush_size;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
459 *color = wbs->brush_color;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
460 }
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
461
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
462 void silcgaim_wb_set_brush(GaimWhiteboard *wb, int size, int color)
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
463 {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
464 SilcGaimWb wbs = wb->proto_data;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
465 wbs->brush_size = size;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
466 wbs->brush_color = color;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
467
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
468 /* Update whiteboard */
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
469 gaim_whiteboard_set_brush(wb, size, color);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
470 }
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
471
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
472 void silcgaim_wb_clear(GaimWhiteboard *wb)
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
473 {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
474 SilcGaimWb wbs = wb->proto_data;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
475 SilcBuffer packet;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
476 int len;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
477 GaimConnection *gc;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
478 SilcGaim sg;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
479
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
480 gc = gaim_account_get_connection(wb->account);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
481 g_return_if_fail(gc);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
482 sg = gc->proto_data;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
483 g_return_if_fail(sg);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
484
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
485 len = SILCGAIM_WB_HEADER;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
486 packet = silc_buffer_alloc_size(len);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
487 if (!packet)
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
488 return;
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
489
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
490 /* Assmeble packet */
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
491 silc_buffer_format(packet,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
492 SILC_STR_UI32_STRING(SILCGAIM_WB_MIME),
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
493 SILC_STR_UI_CHAR(SILCGAIM_WB_CLEAR),
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
494 SILC_STR_UI_SHORT(wbs->width),
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
495 SILC_STR_UI_SHORT(wbs->height),
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
496 SILC_STR_UI_INT(wbs->brush_color),
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
497 SILC_STR_UI_SHORT(wbs->brush_size),
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
498 SILC_STR_END);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
499
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
500 /* Send the message */
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
501 if (wbs->type == 0) {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
502 /* Private message */
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
503 silc_client_send_private_message(sg->client, sg->conn,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
504 wbs->u.client,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
505 SILC_MESSAGE_FLAG_DATA,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
506 packet->head, len, TRUE);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
507 } else if (wbs->type == 1) {
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
508 /* Channel message */
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
509 silc_client_send_channel_message(sg->client, sg->conn,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
510 wbs->u.channel, NULL,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
511 SILC_MESSAGE_FLAG_DATA,
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
512 packet->head, len, TRUE);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
513 }
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
514
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
515 silc_buffer_free(packet);
d5daff460913 [gaim-migrate @ 14353]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
516 }