libpurple/protocols/silc10/wb.c

Tue, 18 Sep 2007 16:39:48 +0000

author
Will Thompson <resiak@pidgin.im>
date
Tue, 18 Sep 2007 16:39:48 +0000
branch
cpw.resiak.disconnectreason
changeset 20437
6596f4984a50
parent 17674
aafdd7bed36d
child 20289
5c844288fbec
child 20685
039aef89faf6
permissions
-rw-r--r--

Modify gadu-gadu to use purple_connection_error_reason. I'm not sure about
some of these.

17674
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
1 /*
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
2
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
3 wb.c
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
4
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
5 Author: Pekka Riikonen <priikone@silcnet.org>
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
6
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
7 Copyright (C) 2005 Pekka Riikonen
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
8
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
9 This program is free software; you can redistribute it and/or modify
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
10 it under the terms of the GNU General Public License as published by
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
11 the Free Software Foundation; version 2 of the License.
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
12
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
13 This program is distributed in the hope that it will be useful,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
16 GNU General Public License for more details.
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
17
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
18 */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
19
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
20 #include "silcincludes.h"
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
21 #include "silcclient.h"
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
22 #include "silcpurple.h"
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
23 #include "wb.h"
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
24
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
25 /*
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
26 SILC Whiteboard packet:
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
27
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
28 1 byte command
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
29 2 bytes width
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
30 2 bytes height
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
31 4 bytes brush color
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
32 2 bytes brush size
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
33 n bytes data
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
34
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
35 Data:
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
36
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
37 4 bytes x
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
38 4 bytes y
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
39
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
40 Commands:
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
41
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
42 0x01 draw
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
43 0x02 clear
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
44
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
45 MIME:
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
46
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
47 MIME-Version: 1.0
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
48 Content-Type: application/x-wb
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
49 Content-Transfer-Encoding: binary
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
50
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
51 */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
52
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
53 #define SILCPURPLE_WB_MIME "MIME-Version: 1.0\r\nContent-Type: application/x-wb\r\nContent-Transfer-Encoding: binary\r\n\r\n"
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
54 #define SILCPURPLE_WB_HEADER strlen(SILCPURPLE_WB_MIME) + 11
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
55
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
56 #define SILCPURPLE_WB_WIDTH 500
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
57 #define SILCPURPLE_WB_HEIGHT 400
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
58 #define SILCPURPLE_WB_WIDTH_MAX 1024
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
59 #define SILCPURPLE_WB_HEIGHT_MAX 1024
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
60
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
61 /* Commands */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
62 typedef enum {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
63 SILCPURPLE_WB_DRAW = 0x01,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
64 SILCPURPLE_WB_CLEAR = 0x02,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
65 } SilcPurpleWbCommand;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
66
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
67 /* Brush size */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
68 typedef enum {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
69 SILCPURPLE_WB_BRUSH_SMALL = 2,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
70 SILCPURPLE_WB_BRUSH_MEDIUM = 5,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
71 SILCPURPLE_WB_BRUSH_LARGE = 10,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
72 } SilcPurpleWbBrushSize;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
73
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
74 /* Brush color (XXX Purple should provide default colors) */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
75 typedef enum {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
76 SILCPURPLE_WB_COLOR_BLACK = 0,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
77 SILCPURPLE_WB_COLOR_RED = 13369344,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
78 SILCPURPLE_WB_COLOR_GREEN = 52224,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
79 SILCPURPLE_WB_COLOR_BLUE = 204,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
80 SILCPURPLE_WB_COLOR_YELLOW = 15658496,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
81 SILCPURPLE_WB_COLOR_ORANGE = 16737792,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
82 SILCPURPLE_WB_COLOR_CYAN = 52428,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
83 SILCPURPLE_WB_COLOR_VIOLET = 5381277,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
84 SILCPURPLE_WB_COLOR_PURPLE = 13369548,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
85 SILCPURPLE_WB_COLOR_TAN = 12093547,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
86 SILCPURPLE_WB_COLOR_BROWN = 5256485,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
87 SILCPURPLE_WB_COLOR_GREY = 11184810,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
88 SILCPURPLE_WB_COLOR_WHITE = 16777215,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
89 } SilcPurpleWbColor;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
90
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
91 typedef struct {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
92 int type; /* 0 = buddy, 1 = channel */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
93 union {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
94 SilcClientEntry client;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
95 SilcChannelEntry channel;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
96 } u;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
97 int width;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
98 int height;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
99 int brush_size;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
100 int brush_color;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
101 } *SilcPurpleWb;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
102
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
103 /* Initialize whiteboard */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
104
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
105 PurpleWhiteboard *silcpurple_wb_init(SilcPurple sg, SilcClientEntry client_entry)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
106 {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
107 SilcClientConnection conn;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
108 PurpleWhiteboard *wb;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
109 SilcPurpleWb wbs;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
110
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
111 conn = sg->conn;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
112 wb = purple_whiteboard_get_session(sg->account, client_entry->nickname);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
113 if (!wb)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
114 wb = purple_whiteboard_create(sg->account, client_entry->nickname, 0);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
115 if (!wb)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
116 return NULL;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
117
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
118 if (!wb->proto_data) {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
119 wbs = silc_calloc(1, sizeof(*wbs));
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
120 if (!wbs)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
121 return NULL;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
122 wbs->type = 0;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
123 wbs->u.client = client_entry;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
124 wbs->width = SILCPURPLE_WB_WIDTH;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
125 wbs->height = SILCPURPLE_WB_HEIGHT;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
126 wbs->brush_size = SILCPURPLE_WB_BRUSH_SMALL;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
127 wbs->brush_color = SILCPURPLE_WB_COLOR_BLACK;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
128 wb->proto_data = wbs;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
129
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
130 /* Start the whiteboard */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
131 purple_whiteboard_start(wb);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
132 purple_whiteboard_clear(wb);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
133 }
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
134
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
135 return wb;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
136 }
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
137
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
138 PurpleWhiteboard *silcpurple_wb_init_ch(SilcPurple sg, SilcChannelEntry channel)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
139 {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
140 PurpleWhiteboard *wb;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
141 SilcPurpleWb wbs;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
142
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
143 wb = purple_whiteboard_get_session(sg->account, channel->channel_name);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
144 if (!wb)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
145 wb = purple_whiteboard_create(sg->account, channel->channel_name, 0);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
146 if (!wb)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
147 return NULL;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
148
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
149 if (!wb->proto_data) {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
150 wbs = silc_calloc(1, sizeof(*wbs));
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
151 if (!wbs)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
152 return NULL;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
153 wbs->type = 1;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
154 wbs->u.channel = channel;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
155 wbs->width = SILCPURPLE_WB_WIDTH;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
156 wbs->height = SILCPURPLE_WB_HEIGHT;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
157 wbs->brush_size = SILCPURPLE_WB_BRUSH_SMALL;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
158 wbs->brush_color = SILCPURPLE_WB_COLOR_BLACK;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
159 wb->proto_data = wbs;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
160
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
161 /* Start the whiteboard */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
162 purple_whiteboard_start(wb);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
163 purple_whiteboard_clear(wb);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
164 }
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
165
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
166 return wb;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
167 }
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
168
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
169 static void
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
170 silcpurple_wb_parse(SilcPurpleWb wbs, PurpleWhiteboard *wb,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
171 unsigned char *message, SilcUInt32 message_len)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
172 {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
173 SilcUInt8 command;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
174 SilcUInt16 width, height, brush_size;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
175 SilcUInt32 brush_color, x, y, dx, dy;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
176 SilcBufferStruct buf;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
177 int ret;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
178
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
179 /* Parse the packet */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
180 silc_buffer_set(&buf, message, message_len);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
181 ret = silc_buffer_unformat(&buf,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
182 SILC_STR_UI_CHAR(&command),
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
183 SILC_STR_UI_SHORT(&width),
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
184 SILC_STR_UI_SHORT(&height),
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
185 SILC_STR_UI_INT(&brush_color),
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
186 SILC_STR_UI_SHORT(&brush_size),
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
187 SILC_STR_END);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
188 if (ret < 0)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
189 return;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
190 silc_buffer_pull(&buf, ret);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
191
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
192 /* Update whiteboard if its dimensions changed */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
193 if (width != wbs->width || height != wbs->height)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
194 silcpurple_wb_set_dimensions(wb, height, width);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
195
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
196 if (command == SILCPURPLE_WB_DRAW) {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
197 /* Parse data and draw it */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
198 ret = silc_buffer_unformat(&buf,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
199 SILC_STR_UI_INT(&dx),
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
200 SILC_STR_UI_INT(&dy),
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
201 SILC_STR_END);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
202 if (ret < 0)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
203 return;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
204 silc_buffer_pull(&buf, 8);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
205 x = dx;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
206 y = dy;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
207 while (buf.len > 0) {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
208 ret = silc_buffer_unformat(&buf,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
209 SILC_STR_UI_INT(&dx),
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
210 SILC_STR_UI_INT(&dy),
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
211 SILC_STR_END);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
212 if (ret < 0)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
213 return;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
214 silc_buffer_pull(&buf, 8);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
215
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
216 purple_whiteboard_draw_line(wb, x, y, x + dx, y + dy,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
217 brush_color, brush_size);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
218 x += dx;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
219 y += dy;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
220 }
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
221 }
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
222
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
223 if (command == SILCPURPLE_WB_CLEAR)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
224 purple_whiteboard_clear(wb);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
225 }
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
226
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
227 typedef struct {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
228 unsigned char *message;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
229 SilcUInt32 message_len;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
230 SilcPurple sg;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
231 SilcClientEntry sender;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
232 SilcChannelEntry channel;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
233 } *SilcPurpleWbRequest;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
234
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
235 static void
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
236 silcpurple_wb_request_cb(SilcPurpleWbRequest req, gint id)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
237 {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
238 PurpleWhiteboard *wb;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
239
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
240 if (id != 1)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
241 goto out;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
242
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
243 if (!req->channel)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
244 wb = silcpurple_wb_init(req->sg, req->sender);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
245 else
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
246 wb = silcpurple_wb_init_ch(req->sg, req->channel);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
247
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
248 silcpurple_wb_parse(wb->proto_data, wb, req->message, req->message_len);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
249
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
250 out:
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
251 silc_free(req->message);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
252 silc_free(req);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
253 }
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
254
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
255 static void
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
256 silcpurple_wb_request(SilcClient client, const unsigned char *message,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
257 SilcUInt32 message_len, SilcClientEntry sender,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
258 SilcChannelEntry channel)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
259 {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
260 char tmp[128];
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
261 SilcPurpleWbRequest req;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
262 PurpleConnection *gc;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
263 SilcPurple sg;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
264
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
265 gc = client->application;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
266 sg = gc->proto_data;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
267
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
268 /* Open whiteboard automatically if requested */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
269 if (purple_account_get_bool(sg->account, "open-wb", FALSE)) {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
270 PurpleWhiteboard *wb;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
271
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
272 if (!channel)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
273 wb = silcpurple_wb_init(sg, sender);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
274 else
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
275 wb = silcpurple_wb_init_ch(sg, channel);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
276
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
277 silcpurple_wb_parse(wb->proto_data, wb, (unsigned char *)message,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
278 message_len);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
279 return;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
280 }
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
281
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
282 if (!channel) {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
283 g_snprintf(tmp, sizeof(tmp),
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
284 _("%s sent message to whiteboard. Would you like "
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
285 "to open the whiteboard?"), sender->nickname);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
286 } else {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
287 g_snprintf(tmp, sizeof(tmp),
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
288 _("%s sent message to whiteboard on %s channel. "
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
289 "Would you like to open the whiteboard?"),
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
290 sender->nickname, channel->channel_name);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
291 }
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
292
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
293 req = silc_calloc(1, sizeof(*req));
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
294 if (!req)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
295 return;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
296 req->message = silc_memdup(message, message_len);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
297 req->message_len = message_len;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
298 req->sender = sender;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
299 req->channel = channel;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
300 req->sg = sg;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
301
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
302 purple_request_action(gc, _("Whiteboard"), tmp, NULL, 1,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
303 sg->account, sender->nickname, NULL, req, 2,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
304 _("Yes"), G_CALLBACK(silcpurple_wb_request_cb),
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
305 _("No"), G_CALLBACK(silcpurple_wb_request_cb));
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
306 }
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
307
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
308 /* Process incoming whiteboard message */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
309
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
310 void silcpurple_wb_receive(SilcClient client, SilcClientConnection conn,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
311 SilcClientEntry sender, SilcMessagePayload payload,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
312 SilcMessageFlags flags, const unsigned char *message,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
313 SilcUInt32 message_len)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
314 {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
315 SilcPurple sg;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
316 PurpleConnection *gc;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
317 PurpleWhiteboard *wb;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
318 SilcPurpleWb wbs;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
319
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
320 gc = client->application;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
321 sg = gc->proto_data;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
322
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
323 wb = purple_whiteboard_get_session(sg->account, sender->nickname);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
324 if (!wb) {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
325 /* Ask user if they want to open the whiteboard */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
326 silcpurple_wb_request(client, message, message_len,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
327 sender, NULL);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
328 return;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
329 }
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
330
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
331 wbs = wb->proto_data;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
332 silcpurple_wb_parse(wbs, wb, (unsigned char *)message, message_len);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
333 }
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
334
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
335 /* Process incoming whiteboard message on channel */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
336
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
337 void silcpurple_wb_receive_ch(SilcClient client, SilcClientConnection conn,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
338 SilcClientEntry sender, SilcChannelEntry channel,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
339 SilcMessagePayload payload,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
340 SilcMessageFlags flags,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
341 const unsigned char *message,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
342 SilcUInt32 message_len)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
343 {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
344 SilcPurple sg;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
345 PurpleConnection *gc;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
346 PurpleWhiteboard *wb;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
347 SilcPurpleWb wbs;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
348
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
349 gc = client->application;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
350 sg = gc->proto_data;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
351
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
352 wb = purple_whiteboard_get_session(sg->account, channel->channel_name);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
353 if (!wb) {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
354 /* Ask user if they want to open the whiteboard */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
355 silcpurple_wb_request(client, message, message_len,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
356 sender, channel);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
357 return;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
358 }
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
359
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
360 wbs = wb->proto_data;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
361 silcpurple_wb_parse(wbs, wb, (unsigned char *)message, message_len);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
362 }
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
363
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
364 /* Send whiteboard message */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
365
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
366 void silcpurple_wb_send(PurpleWhiteboard *wb, GList *draw_list)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
367 {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
368 SilcPurpleWb wbs = wb->proto_data;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
369 SilcBuffer packet;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
370 GList *list;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
371 int len;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
372 PurpleConnection *gc;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
373 SilcPurple sg;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
374
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
375 g_return_if_fail(draw_list);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
376 gc = purple_account_get_connection(wb->account);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
377 g_return_if_fail(gc);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
378 sg = gc->proto_data;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
379 g_return_if_fail(sg);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
380
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
381 len = SILCPURPLE_WB_HEADER;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
382 for (list = draw_list; list; list = list->next)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
383 len += 4;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
384
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
385 packet = silc_buffer_alloc_size(len);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
386 if (!packet)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
387 return;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
388
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
389 /* Assmeble packet */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
390 silc_buffer_format(packet,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
391 SILC_STR_UI32_STRING(SILCPURPLE_WB_MIME),
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
392 SILC_STR_UI_CHAR(SILCPURPLE_WB_DRAW),
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
393 SILC_STR_UI_SHORT(wbs->width),
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
394 SILC_STR_UI_SHORT(wbs->height),
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
395 SILC_STR_UI_INT(wbs->brush_color),
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
396 SILC_STR_UI_SHORT(wbs->brush_size),
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
397 SILC_STR_END);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
398 silc_buffer_pull(packet, SILCPURPLE_WB_HEADER);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
399 for (list = draw_list; list; list = list->next) {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
400 silc_buffer_format(packet,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
401 SILC_STR_UI_INT(GPOINTER_TO_INT(list->data)),
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
402 SILC_STR_END);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
403 silc_buffer_pull(packet, 4);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
404 }
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
405
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
406 /* Send the message */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
407 if (wbs->type == 0) {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
408 /* Private message */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
409 silc_client_send_private_message(sg->client, sg->conn,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
410 wbs->u.client,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
411 SILC_MESSAGE_FLAG_DATA,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
412 packet->head, len, TRUE);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
413 } else if (wbs->type == 1) {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
414 /* Channel message. Channel private keys are not supported. */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
415 silc_client_send_channel_message(sg->client, sg->conn,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
416 wbs->u.channel, NULL,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
417 SILC_MESSAGE_FLAG_DATA,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
418 packet->head, len, TRUE);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
419 }
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
420
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
421 silc_buffer_free(packet);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
422 }
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
423
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
424 /* Purple Whiteboard operations */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
425
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
426 void silcpurple_wb_start(PurpleWhiteboard *wb)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
427 {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
428 /* Nothing here. Everything is in initialization */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
429 }
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
430
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
431 void silcpurple_wb_end(PurpleWhiteboard *wb)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
432 {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
433 silc_free(wb->proto_data);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
434 wb->proto_data = NULL;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
435 }
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
436
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
437 void silcpurple_wb_get_dimensions(const PurpleWhiteboard *wb, int *width, int *height)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
438 {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
439 SilcPurpleWb wbs = wb->proto_data;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
440 *width = wbs->width;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
441 *height = wbs->height;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
442 }
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
443
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
444 void silcpurple_wb_set_dimensions(PurpleWhiteboard *wb, int width, int height)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
445 {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
446 SilcPurpleWb wbs = wb->proto_data;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
447 wbs->width = width > SILCPURPLE_WB_WIDTH_MAX ? SILCPURPLE_WB_WIDTH_MAX :
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
448 width;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
449 wbs->height = height > SILCPURPLE_WB_HEIGHT_MAX ? SILCPURPLE_WB_HEIGHT_MAX :
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
450 height;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
451
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
452 /* Update whiteboard */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
453 purple_whiteboard_set_dimensions(wb, wbs->width, wbs->height);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
454 }
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
455
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
456 void silcpurple_wb_get_brush(const PurpleWhiteboard *wb, int *size, int *color)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
457 {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
458 SilcPurpleWb wbs = wb->proto_data;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
459 *size = wbs->brush_size;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
460 *color = wbs->brush_color;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
461 }
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
462
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
463 void silcpurple_wb_set_brush(PurpleWhiteboard *wb, int size, int color)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
464 {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
465 SilcPurpleWb wbs = wb->proto_data;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
466 wbs->brush_size = size;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
467 wbs->brush_color = color;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
468
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
469 /* Update whiteboard */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
470 purple_whiteboard_set_brush(wb, size, color);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
471 }
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
472
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
473 void silcpurple_wb_clear(PurpleWhiteboard *wb)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
474 {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
475 SilcPurpleWb wbs = wb->proto_data;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
476 SilcBuffer packet;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
477 int len;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
478 PurpleConnection *gc;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
479 SilcPurple sg;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
480
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
481 gc = purple_account_get_connection(wb->account);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
482 g_return_if_fail(gc);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
483 sg = gc->proto_data;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
484 g_return_if_fail(sg);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
485
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
486 len = SILCPURPLE_WB_HEADER;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
487 packet = silc_buffer_alloc_size(len);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
488 if (!packet)
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
489 return;
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
490
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
491 /* Assmeble packet */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
492 silc_buffer_format(packet,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
493 SILC_STR_UI32_STRING(SILCPURPLE_WB_MIME),
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
494 SILC_STR_UI_CHAR(SILCPURPLE_WB_CLEAR),
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
495 SILC_STR_UI_SHORT(wbs->width),
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
496 SILC_STR_UI_SHORT(wbs->height),
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
497 SILC_STR_UI_INT(wbs->brush_color),
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
498 SILC_STR_UI_SHORT(wbs->brush_size),
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
499 SILC_STR_END);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
500
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
501 /* Send the message */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
502 if (wbs->type == 0) {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
503 /* Private message */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
504 silc_client_send_private_message(sg->client, sg->conn,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
505 wbs->u.client,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
506 SILC_MESSAGE_FLAG_DATA,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
507 packet->head, len, TRUE);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
508 } else if (wbs->type == 1) {
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
509 /* Channel message */
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
510 silc_client_send_channel_message(sg->client, sg->conn,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
511 wbs->u.channel, NULL,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
512 SILC_MESSAGE_FLAG_DATA,
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
513 packet->head, len, TRUE);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
514 }
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
515
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
516 silc_buffer_free(packet);
aafdd7bed36d Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff changeset
517 }

mercurial