⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 yahoo_doodle.c

📁 Linux下的多协议即时通讯程序源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * purple * * Purple is the legal property of its developers, whose names are too numerous * to list here.  Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA * *//****************************************************************************** * INCLUDES *****************************************************************************/#include "internal.h"#include "account.h"#include "accountopt.h"#include "blist.h"#include "cipher.h"#include "cmds.h"#include "debug.h"#include "notify.h"#include "privacy.h"#include "prpl.h"#include "proxy.h"#include "request.h"#include "server.h"#include "util.h"#include "version.h"#include "yahoo.h"#include "yahoo_packet.h"#include "yahoo_friend.h"#include "yahoochat.h"#include "ycht.h"#include "yahoo_auth.h"#include "yahoo_filexfer.h"#include "yahoo_picture.h"#include "whiteboard.h"#include "yahoo_doodle.h"/****************************************************************************** * Globals *****************************************************************************/#if 0const int DefaultColorRGB24[] ={	DOODLE_COLOR_RED,	DOODLE_COLOR_ORANGE,	DOODLE_COLOR_YELLOW,	DOODLE_COLOR_GREEN,	DOODLE_COLOR_CYAN,	DOODLE_COLOR_BLUE,	DOODLE_COLOR_VIOLET,	DOODLE_COLOR_PURPLE,	DOODLE_COLOR_TAN,	DOODLE_COLOR_BROWN,	DOODLE_COLOR_BLACK,	DOODLE_COLOR_GREY,	DOODLE_COLOR_WHITE};#endif/****************************************************************************** * Functions *****************************************************************************/PurpleCmdRet yahoo_doodle_purple_cmd_start(PurpleConversation *conv, const char *cmd, char **args, char **error, void *data){	PurpleAccount *account;	PurpleConnection *gc;	const gchar *name;	if(*args && args[0])		return PURPLE_CMD_RET_FAILED;	account = purple_conversation_get_account(conv);	gc = purple_account_get_connection(account);	name = purple_conversation_get_name(conv);	yahoo_doodle_initiate(gc, name);	/* Write a local message to this conversation showing that a request for a	 * Doodle session has been made	 */	purple_conv_im_write(PURPLE_CONV_IM(conv), "", _("Sent Doodle request."),					   PURPLE_MESSAGE_NICK | PURPLE_MESSAGE_RECV, time(NULL));	return PURPLE_CMD_RET_OK;}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.		 */		purple_whiteboard_create(account, to, DOODLE_STATE_REQUESTING);	}	/* NOTE Perhaps some careful handling of remote assumed established	 * sessions	 */	yahoo_doodle_command_send_request(gc, to);	yahoo_doodle_command_send_ready(gc, to);}void yahoo_doodle_process(PurpleConnection *gc, const char *me, const char *from,						  const char *command, const char *message){	if(!command)		return;	/* Now check to see what sort of Doodle message it is */	switch(atoi(command))	{		case DOODLE_CMD_REQUEST:			yahoo_doodle_command_got_request(gc, from);			break;		case DOODLE_CMD_READY:			yahoo_doodle_command_got_ready(gc, from);			break;		case DOODLE_CMD_CLEAR:			yahoo_doodle_command_got_clear(gc, from);			break;		case DOODLE_CMD_DRAW:			yahoo_doodle_command_got_draw(gc, from, message);			break;		case DOODLE_CMD_EXTRA:			yahoo_doodle_command_got_extra(gc, from, message);			break;		case DOODLE_CMD_CONFIRM:			yahoo_doodle_command_got_confirm(gc, from);			break;	}}void yahoo_doodle_command_got_request(PurpleConnection *gc, const char *from){	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)	{		/* 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);		*/		purple_whiteboard_create(account, from, DOODLE_STATE_REQUESTED);		yahoo_doodle_command_send_request(gc, from);	}	/* TODO Might be required to clear the canvas of an existing doodle	 * session at this point	 */}void yahoo_doodle_command_got_ready(PurpleConnection *gc, const char *from){	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)	{		purple_whiteboard_start(wb);		wb->state = DOODLE_STATE_ESTABLISHED;		yahoo_doodle_command_send_confirm(gc, from);	}	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;11 imv key)	 */	if(wb->state == DOODLE_STATE_REQUESTED)	{		/* purple_whiteboard_start(wb); */		yahoo_doodle_command_send_request(gc, from);	}}void yahoo_doodle_command_got_draw(PurpleConnection *gc, const char *from, const char *message){	PurpleAccount *account;	PurpleWhiteboard *wb;	char **tokens;	int i;	GList *d_list = NULL; /* a local list of drawing info */	g_return_if_fail(message != NULL);	purple_debug_info("yahoo", "doodle: Got Draw (%s)\n", from);	purple_debug_info("yahoo", "doodle: Draw message: %s\n", message);	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 Functionalize	 * Convert drawing packet message to an integer list	 */	/* Check to see if the message begans and ends with quotes */	if((message[0] != '\"') || (message[strlen(message) - 1] != '\"'))		return;	/* Ignore the inital quotation mark. */	message += 1;	tokens = g_strsplit(message, ",", 0);	/* Traverse and extract all integers divided by commas */	for (i = 0; tokens[i] != NULL; i++)	{		int last = strlen(tokens[i]) - 1;		if (tokens[i][last] == '"')			tokens[i][last] = '\0';		d_list = g_list_prepend(d_list, GINT_TO_POINTER(atoi(tokens[i])));	}	d_list = g_list_reverse(d_list);	g_strfreev(tokens);	yahoo_doodle_draw_stroke(wb, d_list);	/* goodle_doodle_session_set_canvas_as_icon(ds); */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -