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

📄 ops.c

📁 Linux下的多协议即时通讯程序源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
			if (geostr) {				purple_notify_user_info_add_pair(user_info, _("Geolocation"), geostr);				g_free(geostr);			}			if (client_entry->server)				purple_notify_user_info_add_pair(user_info, _("Server"), client_entry->server);			if (channels && user_modes) {				SilcUInt32 *umodes;				SilcDList list =					silc_channel_payload_parse_list(channels->data,							channels->len);				if (list && silc_get_mode_list(user_modes,							silc_dlist_count(list),							&umodes)) {					SilcChannelPayload entry;					int i = 0;					memset(tmp, 0, sizeof(tmp));					silc_dlist_start(list);					while ((entry = silc_dlist_get(list))							!= SILC_LIST_END) {						SilcUInt32 name_len;						char *m = silc_client_chumode_char(umodes[i++]);						char *name = (char *)silc_channel_get_name(entry, &name_len);						if (m)							silc_strncat(tmp, sizeof(tmp) - 1, m, strlen(m));						silc_strncat(tmp, sizeof(tmp) - 1, name, name_len);						silc_strncat(tmp, sizeof(tmp) - 1, "  ", 1);						silc_free(m);					}					tmp2 = g_markup_escape_text(tmp, -1);					purple_notify_user_info_add_pair(user_info, _("Currently on"), tmp2);					g_free(tmp2);					silc_free(umodes);				}			}			if (client_entry->public_key) {				char *fingerprint, *babbleprint;				unsigned char *pk;				SilcUInt32 pk_len;				pk = silc_pkcs_public_key_encode(client_entry->public_key, &pk_len);				fingerprint = silc_hash_fingerprint(NULL, pk, pk_len);				babbleprint = silc_hash_babbleprint(NULL, pk, pk_len);				purple_notify_user_info_add_pair(user_info, _("Public Key Fingerprint"), fingerprint);				purple_notify_user_info_add_pair(user_info, _("Public Key Babbleprint"), babbleprint);				silc_free(fingerprint);				silc_free(babbleprint);				silc_free(pk);			}#if 0 /* XXX for now, let's not show attrs here */			if (client_entry->attrs)				purple_request_action(gc, _("User Information"),						_("User Information"),						buf, 1, client_entry, 2,						_("OK"), G_CALLBACK(silcpurple_whois_more),						_("_More..."), G_CALLBACK(silcpurple_whois_more), gc->account, NULL, NULL);			else#endif			purple_notify_userinfo(gc, client_entry->nickname, user_info, NULL, NULL);			purple_notify_user_info_destroy(user_info);		}		break;	case SILC_COMMAND_WHOWAS:		{			SilcClientEntry client_entry;			char *nickname, *realname, *username, *tmp;			PurpleNotifyUserInfo *user_info;			if (!success) {				purple_notify_error(gc, _("User Information"),						  _("Cannot get user information"),						  silc_get_status_message(status));				break;			}			client_entry = va_arg(vp, SilcClientEntry);			nickname = va_arg(vp, char *);			username = va_arg(vp, char *);			realname = va_arg(vp, char *);			if (!nickname)				break;			user_info = purple_notify_user_info_new();			tmp = g_markup_escape_text(nickname, -1);			purple_notify_user_info_add_pair(user_info, _("Nickname"), tmp);			g_free(tmp);			if (realname) {				tmp = g_markup_escape_text(realname, -1);				purple_notify_user_info_add_pair(user_info, _("Real Name"), tmp);				g_free(tmp);			}			if (username) {				tmp = g_markup_escape_text(username, -1);				if (client_entry && client_entry->hostname) {					gchar *tmp3;					tmp3 = g_strdup_printf("%s@%s", tmp, client_entry->hostname);					purple_notify_user_info_add_pair(user_info, _("Username"), tmp3);					g_free(tmp3);				} else					purple_notify_user_info_add_pair(user_info, _("Username"), tmp);				g_free(tmp);			}			if (client_entry && client_entry->server)				purple_notify_user_info_add_pair(user_info, _("Server"), client_entry->server);			if (client_entry && client_entry->public_key) {				char *fingerprint, *babbleprint;				unsigned char *pk;				SilcUInt32 pk_len;				pk = silc_pkcs_public_key_encode(client_entry->public_key, &pk_len);				fingerprint = silc_hash_fingerprint(NULL, pk, pk_len);				babbleprint = silc_hash_babbleprint(NULL, pk, pk_len);				purple_notify_user_info_add_pair(user_info, _("Public Key Fingerprint"), fingerprint);				purple_notify_user_info_add_pair(user_info, _("Public Key Babbleprint"), babbleprint);				silc_free(fingerprint);				silc_free(babbleprint);				silc_free(pk);			}			purple_notify_userinfo(gc, nickname, user_info, NULL, NULL);			purple_notify_user_info_destroy(user_info);		}		break;	case SILC_COMMAND_DETACH:		if (!success) {			purple_notify_error(gc, _("Detach From Server"), _("Cannot detach"),					  silc_get_status_message(status));			return;		}		break;	case SILC_COMMAND_TOPIC:		{			SilcChannelEntry channel;			if (!success) {				purple_notify_error(gc, _("Topic"), _("Cannot set topic"),						  silc_get_status_message(status));				return;			}			channel = va_arg(vp, SilcChannelEntry);			convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT,									channel->channel_name, sg->account);			if (!convo) {				purple_debug_error("silc", "Got a topic for %s, which doesn't exist\n",								 channel->channel_name);				break;			}			/* Set topic */			if (channel->topic)				purple_conv_chat_set_topic(PURPLE_CONV_CHAT(convo), NULL, channel->topic);		}		break;	case SILC_COMMAND_NICK:		{			/* I don't think we should need to do this because the server should			 * be sending a SILC_NOTIFY_TYPE_NICK_CHANGE when we change our own			 * nick, but it isn't, so we deal with it here instead. Stu. */			SilcClientEntry local_entry;			SilcHashTableList htl;			SilcChannelUser chu;			const char *oldnick;			if (!success) {				purple_notify_error(gc, _("Nick"), _("Failed to change nickname"),						silc_get_status_message(status));				return;			}			local_entry = va_arg(vp, SilcClientEntry);			/* Change nick on all channels */			silc_hash_table_list(local_entry->channels, &htl);			while (silc_hash_table_get(&htl, NULL, (void *)&chu)) {				convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT,									chu->channel->channel_name, sg->account);				if (!convo)					continue;				oldnick = purple_conv_chat_get_nick(PURPLE_CONV_CHAT(convo));				if (strcmp(oldnick, purple_normalize(purple_conversation_get_account(convo), local_entry->nickname))) {					purple_conv_chat_rename_user(PURPLE_CONV_CHAT(convo),							oldnick, local_entry->nickname);					purple_conv_chat_set_nick(PURPLE_CONV_CHAT(convo), local_entry->nickname);				}			}			silc_hash_table_list_reset(&htl);			purple_connection_set_display_name(gc, local_entry->nickname);		}		break;	case SILC_COMMAND_LIST:		{			char *topic, *name;			int usercount;			PurpleRoomlistRoom *room;			if (sg->roomlist_canceled)				break;			if (!success) {				purple_notify_error(gc, _("Error"), _("Error retrieving room list"),						  silc_get_status_message(status));				purple_roomlist_set_in_progress(sg->roomlist, FALSE);				purple_roomlist_unref(sg->roomlist);				sg->roomlist = NULL;				return;			}			(void)va_arg(vp, SilcChannelEntry);			name = va_arg(vp, char *);			if (!name) {				purple_notify_error(gc, _("Roomlist"), _("Cannot get room list"),						  silc_get_status_message(status));				purple_roomlist_set_in_progress(sg->roomlist, FALSE);				purple_roomlist_unref(sg->roomlist);				sg->roomlist = NULL;				return;			}			topic = va_arg(vp, char *);			usercount = va_arg(vp, int);			room = purple_roomlist_room_new(PURPLE_ROOMLIST_ROOMTYPE_ROOM, name, NULL);			purple_roomlist_room_add_field(sg->roomlist, room, name);			purple_roomlist_room_add_field(sg->roomlist, room,						     SILC_32_TO_PTR(usercount));			purple_roomlist_room_add_field(sg->roomlist, room,						     topic ? topic : "");			purple_roomlist_room_add(sg->roomlist, room);			if (status == SILC_STATUS_LIST_END ||			    status == SILC_STATUS_OK) {				purple_roomlist_set_in_progress(sg->roomlist, FALSE);				purple_roomlist_unref(sg->roomlist);				sg->roomlist = NULL;			}		}		break;	case SILC_COMMAND_GETKEY:		{			SilcPublicKey public_key;			if (!success) {				purple_notify_error(gc, _("Get Public Key"),						  _("Cannot fetch the public key"),						  silc_get_status_message(status));				return;			}			(void)va_arg(vp, SilcUInt32);			(void)va_arg(vp, void *);			public_key = va_arg(vp, SilcPublicKey);			if (!public_key)				purple_notify_error(gc, _("Get Public Key"),						  _("Cannot fetch the public key"),						  _("No public key was received"));		}		break;	case SILC_COMMAND_INFO:		{			char *server_name;			char *server_info;			char tmp[256];			if (!success) {				purple_notify_error(gc, _("Server Information"),						  _("Cannot get server information"),						  silc_get_status_message(status));				return;			}			(void)va_arg(vp, SilcServerEntry);			server_name = va_arg(vp, char *);			server_info = va_arg(vp, char *);			if (server_name && server_info) {				g_snprintf(tmp, sizeof(tmp), "Server: %s\n%s",					   server_name, server_info);				purple_notify_info(gc, NULL, _("Server Information"), tmp);			}		}		break;	case SILC_COMMAND_STATS:		{			SilcUInt32 starttime, uptime, my_clients, my_channels, my_server_ops,			my_router_ops, cell_clients, cell_channels, cell_servers,			clients, channels, servers, routers, server_ops, router_ops;			SilcUInt32 buffer_length;			SilcBufferStruct buf;			unsigned char *server_stats;			char *msg;			if (!success) {				purple_notify_error(gc, _("Server Statistics"),						_("Cannot get server statistics"),						silc_get_status_message(status));				return;			}			server_stats = va_arg(vp, unsigned char *);			buffer_length = va_arg(vp, SilcUInt32);			if (!server_stats || !buffer_length) {				purple_notify_error(gc, _("Server Statistics"),						_("No server statistics available"), NULL);				break;			}			silc_buffer_set(&buf, server_stats, buffer_length);			silc_buffer_unformat(&buf,					SILC_STR_UI_INT(&starttime),					SILC_STR_UI_INT(&uptime),					SILC_STR_UI_INT(&my_clients),					SILC_STR_UI_INT(&my_channels),					SILC_STR_UI_INT(&my_server_ops),					SILC_STR_UI_INT(&my_router_ops),					SILC_STR_UI_INT(&cell_clients),					SILC_STR_UI_INT(&cell_channels),					SILC_STR_UI_INT(&cell_servers),					SILC_STR_UI_INT(&clients),					SILC_STR_UI_INT(&channels),					SILC_STR_UI_INT(&servers),					SILC_STR_UI_INT(&routers),					SILC_STR_UI_INT(&server_ops),					SILC_STR_UI_INT(&router_ops),					SILC_STR_END);			msg = g_strdup_printf(_("Local server start time: %s\n"					"Local server uptime: %s\n"					"Local server clients: %d\n"					"Local server channels: %d\n"					"Local server operators: %d\n"					"Local router operators: %d\n"					"Local cell clients: %d\n"					"Local cell channels: %d\n"					"Local cell servers: %d\n"					"Total clients: %d\n"					"Total channels: %d\n"					"Total servers: %d\n"					"Total routers: %d\n"					"Total server operators: %d\n"					"Total router operators: %d\n"),					silc_get_time(starttime),					purple_str_seconds_to_string((int)uptime),					(int)my_clients, (int)my_channels, (int)my_server_ops, (int)my_router_ops,					(int)cell_clients, (int)cell_channels, (int)cell_servers,					(int)clients, (int)channels, (int)servers, (int)routers,					(int)server_ops, (int)router_ops);			purple_notify_info(gc, NULL,					_("Network Statistics"), msg);			g_free(msg);		}		break;	case SILC_COMMAND_PING:		{			if (!success) {				purple_notify_error(gc, _("Ping"), _("Ping failed"),								  silc_get_status_message(status));				return;			}			purple_notify_info(gc, _("Ping"), _("Ping reply received from server"),							 NULL);		}		break;	case SILC_COMMAND_KILL:		if (!success) {			purple_notify_error(gc, _("Kill User"),					  _("Could not kill user"),					  silc_get_status_message(status));			return;		}		break;	case SILC_COMMAND_CMODE:		{			SilcChannelEntry channel_entry;			SilcBuffer channel_pubkeys;			if (!success)				return;			channel_entry = va_arg(vp, SilcChannelEntry);			(void)va_arg(vp, SilcUInt32);			(void)va_arg(vp, SilcPublicKey);			channel_pubkeys = va_arg(vp, SilcBuffer);			if (sg->chpk)				silcpurple_chat_chauth_show(sg, channel_entry, channel_pubkeys);		}		break;

⌨️ 快捷键说明

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