src/protocols/silc/wb.c

changeset 12167
f3ad3170f09d
parent 12058
6d4b6e3bd0ba
equal deleted inserted replaced
12166:f70f508e87f6 12167:f3ad3170f09d
109 SilcGaimWb wbs; 109 SilcGaimWb wbs;
110 110
111 conn = sg->conn; 111 conn = sg->conn;
112 wb = gaim_whiteboard_get_session(sg->account, client_entry->nickname); 112 wb = gaim_whiteboard_get_session(sg->account, client_entry->nickname);
113 if (!wb) 113 if (!wb)
114 wb = gaim_whiteboard_create(sg->account, client_entry->nickname, 114 wb = gaim_whiteboard_create(sg->account, client_entry->nickname, 0);
115 0);
116 if (!wb) 115 if (!wb)
117 return NULL; 116 return NULL;
118 117
119 wbs = silc_calloc(1, sizeof(*wbs)); 118 if (!wb->proto_data) {
120 if (!wbs) 119 wbs = silc_calloc(1, sizeof(*wbs));
121 return NULL; 120 if (!wbs)
122 wbs->type = 0; 121 return NULL;
123 wbs->u.client = client_entry; 122 wbs->type = 0;
124 wbs->width = SILCGAIM_WB_WIDTH; 123 wbs->u.client = client_entry;
125 wbs->height = SILCGAIM_WB_HEIGHT; 124 wbs->width = SILCGAIM_WB_WIDTH;
126 wbs->brush_size = SILCGAIM_WB_BRUSH_SMALL; 125 wbs->height = SILCGAIM_WB_HEIGHT;
127 wbs->brush_color = SILCGAIM_WB_COLOR_BLACK; 126 wbs->brush_size = SILCGAIM_WB_BRUSH_SMALL;
128 wb->proto_data = wbs; 127 wbs->brush_color = SILCGAIM_WB_COLOR_BLACK;
129 128 wb->proto_data = wbs;
130 /* Start the whiteboard */ 129
131 gaim_whiteboard_start(wb); 130 /* Start the whiteboard */
132 gaim_whiteboard_clear(wb); 131 gaim_whiteboard_start(wb);
132 gaim_whiteboard_clear(wb);
133 }
133 134
134 return wb; 135 return wb;
135 } 136 }
136 137
137 GaimWhiteboard *silcgaim_wb_init_ch(SilcGaim sg, SilcChannelEntry channel) 138 GaimWhiteboard *silcgaim_wb_init_ch(SilcGaim sg, SilcChannelEntry channel)
139 GaimWhiteboard *wb; 140 GaimWhiteboard *wb;
140 SilcGaimWb wbs; 141 SilcGaimWb wbs;
141 142
142 wb = gaim_whiteboard_get_session(sg->account, channel->channel_name); 143 wb = gaim_whiteboard_get_session(sg->account, channel->channel_name);
143 if (!wb) 144 if (!wb)
144 wb = gaim_whiteboard_create(sg->account, channel->channel_name, 145 wb = gaim_whiteboard_create(sg->account, channel->channel_name, 0);
145 0);
146 if (!wb) 146 if (!wb)
147 return NULL; 147 return NULL;
148 148
149 wbs = silc_calloc(1, sizeof(*wbs)); 149 if (!wb->proto_data) {
150 if (!wbs) 150 wbs = silc_calloc(1, sizeof(*wbs));
151 return NULL; 151 if (!wbs)
152 wbs->type = 1; 152 return NULL;
153 wbs->u.channel = channel; 153 wbs->type = 1;
154 wbs->width = SILCGAIM_WB_WIDTH; 154 wbs->u.channel = channel;
155 wbs->height = SILCGAIM_WB_HEIGHT; 155 wbs->width = SILCGAIM_WB_WIDTH;
156 wbs->brush_size = SILCGAIM_WB_BRUSH_SMALL; 156 wbs->height = SILCGAIM_WB_HEIGHT;
157 wbs->brush_color = SILCGAIM_WB_COLOR_BLACK; 157 wbs->brush_size = SILCGAIM_WB_BRUSH_SMALL;
158 wb->proto_data = wbs; 158 wbs->brush_color = SILCGAIM_WB_COLOR_BLACK;
159 159 wb->proto_data = wbs;
160 /* Start the whiteboard */ 160
161 gaim_whiteboard_start(wb); 161 /* Start the whiteboard */
162 gaim_whiteboard_clear(wb); 162 gaim_whiteboard_start(wb);
163 gaim_whiteboard_clear(wb);
164 }
163 165
164 return wb; 166 return wb;
165 } 167 }
166 168
167 static void 169 static void
258 char tmp[128]; 260 char tmp[128];
259 SilcGaimWbRequest req; 261 SilcGaimWbRequest req;
260 GaimConnection *gc; 262 GaimConnection *gc;
261 SilcGaim sg; 263 SilcGaim sg;
262 264
265 gc = client->application;
266 sg = gc->proto_data;
267
268 /* Open whiteboard automatically if requested */
269 if (gaim_account_get_bool(sg->account, "open-wb", FALSE)) {
270 GaimWhiteboard *wb;
271
272 if (!channel)
273 wb = silcgaim_wb_init(sg, sender);
274 else
275 wb = silcgaim_wb_init_ch(sg, channel);
276
277 silcgaim_wb_parse(wb->proto_data, wb, (unsigned char *)message,
278 message_len);
279 return;
280 }
281
263 if (!channel) { 282 if (!channel) {
264 g_snprintf(tmp, sizeof(tmp), 283 g_snprintf(tmp, sizeof(tmp),
265 _("%s sent message to whiteboard. Would you like " 284 _("%s sent message to whiteboard. Would you like "
266 "to open the whiteboard?"), sender->nickname); 285 "to open the whiteboard?"), sender->nickname);
267 } else { 286 } else {
268 g_snprintf(tmp, sizeof(tmp), 287 g_snprintf(tmp, sizeof(tmp),
269 _("%s sent message to whiteboard on %s channel. " 288 _("%s sent message to whiteboard on %s channel. "
270 "Would you like to open the whiteboard?"), 289 "Would you like to open the whiteboard?"),
271 sender->nickname, channel->channel_name); 290 sender->nickname, channel->channel_name);
272 } 291 }
273
274 gc = client->application;
275 sg = gc->proto_data;
276 292
277 req = silc_calloc(1, sizeof(*req)); 293 req = silc_calloc(1, sizeof(*req));
278 if (!req) 294 if (!req)
279 return; 295 return;
280 req->message = silc_memdup(message, message_len); 296 req->message = silc_memdup(message, message_len);
392 silc_client_send_private_message(sg->client, sg->conn, 408 silc_client_send_private_message(sg->client, sg->conn,
393 wbs->u.client, 409 wbs->u.client,
394 SILC_MESSAGE_FLAG_DATA, 410 SILC_MESSAGE_FLAG_DATA,
395 packet->head, len, TRUE); 411 packet->head, len, TRUE);
396 } else if (wbs->type == 1) { 412 } else if (wbs->type == 1) {
397 /* Channel message */ 413 /* Channel message. Channel private keys are not supported. */
398 silc_client_send_channel_message(sg->client, sg->conn, 414 silc_client_send_channel_message(sg->client, sg->conn,
399 wbs->u.channel, NULL, 415 wbs->u.channel, NULL,
400 SILC_MESSAGE_FLAG_DATA, 416 SILC_MESSAGE_FLAG_DATA,
401 packet->head, len, TRUE); 417 packet->head, len, TRUE);
402 } 418 }
431 width; 447 width;
432 wbs->height = height > SILCGAIM_WB_HEIGHT_MAX ? SILCGAIM_WB_HEIGHT_MAX : 448 wbs->height = height > SILCGAIM_WB_HEIGHT_MAX ? SILCGAIM_WB_HEIGHT_MAX :
433 height; 449 height;
434 450
435 /* Update whiteboard */ 451 /* Update whiteboard */
436 gaim_whiteboard_set_dimensions(wb, width, height); 452 gaim_whiteboard_set_dimensions(wb, wbs->width, wbs->height);
437 } 453 }
438 454
439 void silcgaim_wb_get_brush(GaimWhiteboard *wb, int *size, int *color) 455 void silcgaim_wb_get_brush(GaimWhiteboard *wb, int *size, int *color)
440 { 456 {
441 SilcGaimWb wbs = wb->proto_data; 457 SilcGaimWb wbs = wb->proto_data;

mercurial