Ejemplo n.º 1
0
static int
yahoo_doodle_accept_request(PurpleRequestAcceptData *data)
{
	PurpleWhiteboard *wb;
	PurpleAccount *account;

	account = purple_connection_get_account(data->gc);
	wb = purple_whiteboard_get_session(account, data->from);

	/* If a session with the remote user doesn't exist */
	if(wb == NULL)
	{
		doodle_session *ds;

		wb = purple_whiteboard_create(account, data->from, DOODLE_STATE_REQUESTED);
		ds = wb->proto_data;
		ds->imv_key = g_strdup(data->imv_key);

		yahoo_doodle_command_send_ready(data->gc, data->from,
				data->imv_key);
	}

	/* TODO Might be required to clear the canvas of an existing doodle
	* session at this point
	*/
	return 0;
}
Ejemplo n.º 2
0
void yahoo_doodle_initiate(PurpleConnection *gc, const char *name)
{
	PurpleAccount *account;
	char *to = (char*)name;
	PurpleWhiteboard *wb;

	g_return_if_fail(gc);
	g_return_if_fail(name);

	account = purple_connection_get_account(gc);
	wb = purple_whiteboard_get_session(account, to);

	if(wb == NULL)
	{
		/* Insert this 'session' in the list.  At this point, it's only a
		 * requested session.
		 */
		wb = purple_whiteboard_create(account, to, DOODLE_STATE_REQUESTING);
	}

	/* NOTE Perhaps some careful handling of remote assumed established
	 * sessions
	 */

	yahoo_doodle_command_send_ready(gc, to, DOODLE_IMV_KEY);
	yahoo_doodle_command_send_request(gc, to, DOODLE_IMV_KEY);

}
Ejemplo n.º 3
0
static void pidginwhiteboard_button_start_press(GtkButton *button, gpointer data)
{
	PurpleConversation *conv = data;
	PurpleAccount *account = purple_conversation_get_account(conv);
	PurpleConnection *gc = purple_account_get_connection(account);
	char *to = (char*)(purple_conversation_get_name(conv));

	/* Only handle this if local client requested Doodle session (else local
	 * client would have sent one)
	 */
	PurpleWhiteboard *wb = purple_whiteboard_get(account, to);

	/* Write a local message to this conversation showing that a request for a
	 * Doodle session has been made
	 */
	/* XXXX because otherwise gettext will see this string, even though it's
	 * in an #if 0 block. Remove the XXXX if you want to use this code.
	 * But, it really shouldn't be a Yahoo-specific string. ;) */
	purple_conv_im_write(PURPLE_CONV_IM(conv), "", XXXX_("Sent Doodle request."),
					   PURPLE_MESSAGE_NICK | PURPLE_MESSAGE_RECV, time(NULL));

	yahoo_doodle_command_send_request(gc, to);
	yahoo_doodle_command_send_ready(gc, to);

	/* Insert this 'session' in the list.  At this point, it's only a requested
	 * session.
	 */
	wb = purple_whiteboard_create(account, to, DOODLE_STATE_REQUESTING);
}
Ejemplo n.º 4
0
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);
	}
}
Ejemplo n.º 5
0
static void yahoo_doodle_command_got_request(PurpleConnection *gc, const char *from, const char *imv_key)
{
	PurpleAccount *account;
	PurpleWhiteboard *wb;

	purple_debug_info("yahoo", "doodle: Got Request (%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 a session with the remote user doesn't exist */
	if(wb == NULL)
	{
		doodle_session *ds;
		/* Ask user if they wish to accept the request for a doodle session */
		/* TODO Ask local user to start Doodle session with remote user */
		/* NOTE This if/else statement won't work right--must use dialog
		 * results
		 */

		/* char dialog_message[64];
		g_sprintf(dialog_message, "%s is requesting to start a Doodle session with you.", from);

		purple_notify_message(NULL, PURPLE_NOTIFY_MSG_INFO, "Doodle",
		dialog_message, NULL, NULL, NULL);
		*/

		wb = purple_whiteboard_new(account, from, DOODLE_STATE_REQUESTED);
		ds = purple_whiteboard_get_protocol_data(wb);
		ds->imv_key = g_strdup(imv_key);

		yahoo_doodle_command_send_ready(gc, from, imv_key);
	}

	/* TODO Might be required to clear the canvas of an existing doodle
	 * session at this point
	 */
}