PurpleWhiteboard *silcpurple_wb_init_ch(SilcPurple sg, SilcChannelEntry channel) { PurpleWhiteboard *wb; SilcPurpleWb wbs; wb = purple_whiteboard_get_session(sg->account, channel->channel_name); if (!wb) wb = purple_whiteboard_create(sg->account, channel->channel_name, 0); if (!wb) return NULL; if (!wb->proto_data) { wbs = silc_calloc(1, sizeof(*wbs)); if (!wbs) return NULL; wbs->type = 1; wbs->u.channel = channel; wbs->width = SILCPURPLE_WB_WIDTH; wbs->height = SILCPURPLE_WB_HEIGHT; wbs->brush_size = SILCPURPLE_WB_BRUSH_SMALL; wbs->brush_color = SILCPURPLE_WB_COLOR_BLACK; wb->proto_data = wbs; /* Start the whiteboard */ purple_whiteboard_start(wb); purple_whiteboard_clear(wb); } return wb; }
PurpleWhiteboard *silcpurple_wb_init(SilcPurple sg, SilcClientEntry client_entry) { SilcClientConnection conn; PurpleWhiteboard *wb; SilcPurpleWb wbs; conn = sg->conn; wb = purple_whiteboard_get_session(sg->account, client_entry->nickname); if (!wb) wb = purple_whiteboard_create(sg->account, client_entry->nickname, 0); if (!wb) return NULL; if (!wb->proto_data) { wbs = silc_calloc(1, sizeof(*wbs)); if (!wbs) return NULL; wbs->type = 0; wbs->u.client = client_entry; wbs->width = SILCPURPLE_WB_WIDTH; wbs->height = SILCPURPLE_WB_HEIGHT; wbs->brush_size = SILCPURPLE_WB_BRUSH_SMALL; wbs->brush_color = SILCPURPLE_WB_COLOR_BLACK; wb->proto_data = wbs; /* Start the whiteboard */ purple_whiteboard_start(wb); purple_whiteboard_clear(wb); } return wb; }
static void yahoo_doodle_command_got_ready(PurpleConnection *gc, const char *from, const char *imv_key) { PurpleAccount *account; PurpleWhiteboard *wb; purple_debug_info("yahoo", "doodle: Got Ready(%s)\n", from); account = purple_connection_get_account(gc); /* Only handle this if local client requested Doodle session (else local * client would have sent one) */ wb = purple_whiteboard_get_session(account, from); if(wb == NULL) return; if(wb->state == DOODLE_STATE_REQUESTING) { doodle_session *ds = wb->proto_data; purple_whiteboard_start(wb); wb->state = DOODLE_STATE_ESTABLISHED; yahoo_doodle_command_send_confirm(gc, from, imv_key); /* Let's steal the imv_key and reuse it */ g_free(ds->imv_key); ds->imv_key = g_strdup(imv_key); } else if(wb->state == DOODLE_STATE_ESTABLISHED) { /* TODO Ask whether to save picture too */ purple_whiteboard_clear(wb); } /* NOTE Not sure about this... I am trying to handle if the remote user * already thinks we're in a session with them (when their chat message * contains the doodle imv key) */ else if(wb->state == DOODLE_STATE_REQUESTED) { /* purple_whiteboard_start(wb); */ yahoo_doodle_command_send_ready(gc, from, imv_key); } }
static void yahoo_doodle_command_got_confirm(PurpleConnection *gc, const char *from) { PurpleAccount *account; PurpleWhiteboard *wb; purple_debug_info("yahoo", "doodle: Got Confirm (%s)\n", from); /* Get the doodle session */ account = purple_connection_get_account(gc); /* Only handle this if local client requested Doodle session (else local * client would have sent one) */ wb = purple_whiteboard_get_session(account, from); if(wb == NULL) return; /* TODO Combine the following IF's? */ /* Check if we requested a doodle session */ /*if(wb->state == DOODLE_STATE_REQUESTING) { wb->state = DOODLE_STATE_ESTABLISHED; purple_whiteboard_start(wb); yahoo_doodle_command_send_confirm(gc, from); }*/ /* Check if we accepted a request for a doodle session */ if(wb->state == DOODLE_STATE_REQUESTED) { wb->state = DOODLE_STATE_ESTABLISHED; purple_whiteboard_start(wb); } }