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

📄 bonjour.c

📁 Linux下的多协议即时通讯程序源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
	const char *status_description;	const char *message;	presence = purple_buddy_get_presence(buddy);	status = purple_presence_get_active_status(presence);	message = purple_status_get_attr_string(status, "message");	if (purple_presence_is_available(presence))		status_description = purple_status_get_name(status);	else if (purple_presence_is_idle(presence))		status_description = _("Idle");	else		status_description = purple_status_get_name(status);	purple_notify_user_info_add_pair(user_info, _("Status"), status_description);	if (message != NULL)		purple_notify_user_info_add_pair(user_info, _("Message"), message);}static gbooleanplugin_unload(PurplePlugin *plugin){	/* These shouldn't happen here because they are allocated in _init() */	g_free(default_firstname);	g_free(default_lastname);	g_free(default_hostname);	return TRUE;}static PurplePlugin *my_protocol = NULL;static PurplePluginProtocolInfo prpl_info ={	OPT_PROTO_NO_PASSWORD,	NULL,                                                    /* user_splits */	NULL,                                                    /* protocol_options */	/* {"png", 0, 0, 96, 96, 0, PURPLE_ICON_SCALE_DISPLAY}, */ /* icon_spec */	NO_BUDDY_ICONS, /* not yet */                            /* icon_spec */	bonjour_list_icon,                                       /* list_icon */	NULL,													 /* list_emblem */	bonjour_status_text,                                     /* status_text */	bonjour_tooltip_text,                                    /* tooltip_text */	bonjour_status_types,                                    /* status_types */	NULL,                                                    /* blist_node_menu */	NULL,                                                    /* chat_info */	NULL,                                                    /* chat_info_defaults */	bonjour_login,                                           /* login */	bonjour_close,                                           /* close */	bonjour_send_im,                                         /* send_im */	NULL,                                                    /* set_info */	NULL,                                                    /* send_typing */	NULL,                                                    /* get_info */	bonjour_set_status,                                      /* set_status */	NULL,                                                    /* set_idle */	NULL,                                                    /* change_passwd */	NULL,                                                    /* add_buddy */	NULL,                                                    /* add_buddies */	NULL,                                                    /* remove_buddy */	NULL,                                                    /* remove_buddies */	NULL,                                                    /* add_permit */	NULL,                                                    /* add_deny */	NULL,                                                    /* rem_permit */	NULL,                                                    /* rem_deny */	NULL,                                                    /* set_permit_deny */	NULL,                                                    /* join_chat */	NULL,                                                    /* reject_chat */	NULL,                                                    /* get_chat_name */	NULL,                                                    /* chat_invite */	NULL,                                                    /* chat_leave */	NULL,                                                    /* chat_whisper */	NULL,                                                    /* chat_send */	NULL,                                                    /* keepalive */	NULL,                                                    /* register_user */	NULL,                                                    /* get_cb_info */	NULL,                                                    /* get_cb_away */	NULL,                                                    /* alias_buddy */	NULL,                                                    /* group_buddy */	NULL,                                                    /* rename_group */	NULL,                                                    /* buddy_free */	bonjour_convo_closed,                                    /* convo_closed */	NULL,                                                    /* normalize */	NULL,                                                    /* set_buddy_icon */	NULL,                                                    /* remove_group */	NULL,                                                    /* get_cb_real_name */	NULL,                                                    /* set_chat_topic */	NULL,                                                    /* find_blist_chat */	NULL,                                                    /* roomlist_get_list */	NULL,                                                    /* roomlist_cancel */	NULL,                                                    /* roomlist_expand_category */	NULL,                                                    /* can_receive_file */	NULL,                                                    /* send_file */	NULL,                                                    /* new_xfer */	NULL,                                                    /* offline_message */	NULL,                                                    /* whiteboard_prpl_ops */	NULL,                                                    /* send_raw */	NULL,                                                    /* roomlist_room_serialize */	/* padding */	NULL,	NULL,	NULL,	NULL};static PurplePluginInfo info ={	PURPLE_PLUGIN_MAGIC,	PURPLE_MAJOR_VERSION,	PURPLE_MINOR_VERSION,	PURPLE_PLUGIN_PROTOCOL,                             /**< type           */	NULL,                                             /**< ui_requirement */	0,                                                /**< flags          */	NULL,                                             /**< dependencies   */	PURPLE_PRIORITY_DEFAULT,                            /**< priority       */	"prpl-bonjour",                                   /**< id             */	"Bonjour",                                        /**< name           */	VERSION,                                          /**< version        */	                                                  /**  summary        */	N_("Bonjour Protocol Plugin"),	                                                  /**  description    */	N_("Bonjour Protocol Plugin"),	NULL,                                             /**< author         */	PURPLE_WEBSITE,                                     /**< homepage       */	NULL,                                             /**< load           */	plugin_unload,                                             /**< unload         */	NULL,                                             /**< destroy        */	NULL,                                             /**< ui_info        */	&prpl_info,                                       /**< extra_info     */	NULL,                                             /**< prefs_info     */	NULL,	/* padding */	NULL,	NULL,	NULL,	NULL};static voidinitialize_default_account_values(){#ifdef _WIN32	char *fullname = NULL;#else	struct passwd *info;	const char *fullname = NULL;#endif	char *splitpoint = NULL;	char *tmp;	char hostname[255];#ifndef _WIN32	/* Try to figure out the user's real name */	info = getpwuid(getuid());	if ((info != NULL) && (info->pw_gecos != NULL) && (info->pw_gecos[0] != '\0'))		fullname = info->pw_gecos;	else if ((info != NULL) && (info->pw_name != NULL) && (info->pw_name[0] != '\0'))		fullname = info->pw_name;	else if (((fullname = getlogin()) != NULL) && (fullname[0] != '\0'))		;	else		fullname = _("Purple Person");	/* Make sure fullname is valid UTF-8.  If not, try to convert it. */	if (!g_utf8_validate(fullname, -1, NULL))	{		gchar *tmp;		tmp = g_locale_to_utf8(fullname, -1, NULL, NULL, NULL);		if ((tmp == NULL) || (*tmp == '\0'))			fullname = _("Purple Person");	}#else	FARPROC myNetUserGetInfo = wpurple_find_and_loadproc("Netapi32.dll",		"NetUserGetInfo");	if (myNetUserGetInfo) {		LPUSER_INFO_10 user_info = NULL;		LPSERVER_INFO_100 server_info = NULL;		wchar_t *servername = NULL;		wchar_t username[UNLEN + 1];		DWORD dwLenUsername = UNLEN + 1;		FARPROC myNetServerEnum = wpurple_find_and_loadproc(			"Netapi32.dll", "NetServerEnum");		FARPROC myNetApiBufferFree = wpurple_find_and_loadproc(			"Netapi32.dll", "NetApiBufferFree");		if (myNetServerEnum && myNetApiBufferFree) {			DWORD dwEntriesRead = 0;			DWORD dwTotalEntries = 0;			DWORD dwResumeHandle = 0;			NET_API_STATUS nStatus = (myNetServerEnum)(NULL, 100,				&server_info, MAX_PREFERRED_LENGTH,				&dwEntriesRead, &dwTotalEntries,				SV_TYPE_DOMAIN_CTRL, NULL, &dwResumeHandle);			if ((nStatus == NERR_Success					|| nStatus == ERROR_MORE_DATA)					&& dwEntriesRead > 0) {				servername = server_info->sv100_name;			} else {				purple_debug_warning("bonjour", "Unable to look up domain controller. NET_API_STATUS = %d, Entries Read = %d, Total Entries = %d\n", nStatus, dwEntriesRead, dwTotalEntries);			}		}		if (!GetUserNameW((LPWSTR) &username, &dwLenUsername)) {			purple_debug_warning("bonjour",				"Unable to look up username\n");		}		if (username != NULL && *username != '\0'				&& (myNetUserGetInfo)(servername, username, 10,					&user_info) == NERR_Success) {			if (user_info != NULL) {				fullname = g_utf16_to_utf8(					user_info->usri10_full_name,					-1, NULL, NULL, NULL);			}		}		if (user_info != NULL)			(myNetApiBufferFree)(user_info);		if (server_info != NULL)			(myNetApiBufferFree)(server_info);	}	if (!fullname)		fullname = g_strdup(_("Purple Person"));#endif	/* Split the real name into a first and last name */	splitpoint = strchr(fullname, ' ');	if (splitpoint != NULL)	{		default_firstname = g_strndup(fullname, splitpoint - fullname);		tmp = &splitpoint[1];				/* The last name may be followed by a comma and additional data.		 * Only use the last name itself.		 */		splitpoint = strchr(tmp, ',');		if (splitpoint != NULL)			default_lastname = g_strndup(tmp, splitpoint - tmp);		else			default_lastname = g_strdup(tmp);	}	else	{		default_firstname = g_strdup(fullname);		default_lastname = g_strdup("");	}#ifdef _WIN32	g_free(fullname);#endif	/* Try to figure out a good host name to use */	/* TODO: Avoid 'localhost,' if possible */	if (gethostname(hostname, 255) != 0) {		purple_debug_warning("bonjour", "Error when getting host name: %s.  Using \"localhost.\"\n",				strerror(errno));		strcpy(hostname, "localhost");	}	default_hostname = g_strdup(hostname);}static voidinit_plugin(PurplePlugin *plugin){	PurpleAccountUserSplit *split;	PurpleAccountOption *option;	initialize_default_account_values();	/* Creating the user splits */	split = purple_account_user_split_new(_("Hostname"), default_hostname, '@');	prpl_info.user_splits = g_list_append(prpl_info.user_splits, split);	/* Creating the options for the protocol */	option = purple_account_option_string_new(_("First name"), "first", default_firstname);	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);	option = purple_account_option_string_new(_("Last name"), "last", default_lastname);	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);	option = purple_account_option_string_new(_("E-mail"), "email", "");	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);	option = purple_account_option_string_new(_("AIM Account"), "AIM", "");	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);	option = purple_account_option_string_new(_("XMPP Account"), "jid", "");	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);	my_protocol = plugin;}PURPLE_INIT_PLUGIN(bonjour, init_plugin, info);

⌨️ 快捷键说明

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