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

📄 ops.c

📁 Linux下的多协议即时通讯程序源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
					if (!convo)						continue;					purple_conv_chat_remove_user(PURPLE_CONV_CHAT(convo),								   clients[i]->nickname,								   _("Server signoff"));				}				silc_hash_table_list_reset(&htl);			}		}		break;	case SILC_NOTIFY_TYPE_ERROR:		{			SilcStatus error = va_arg(va, int);			purple_notify_error(gc, "Error Notify",					  silc_get_status_message(error),					  NULL);		}		break;	case SILC_NOTIFY_TYPE_WATCH:		{			SilcPublicKey public_key;			unsigned char *pk;			SilcUInt32 pk_len;			char *fingerprint;			client_entry = va_arg(va, SilcClientEntry);			(void)va_arg(va, char *);			mode = va_arg(va, SilcUInt32);			notify = va_arg(va, int);			public_key = va_arg(va, SilcPublicKey);			b = NULL;			if (public_key) {				PurpleBlistNode *gnode, *cnode, *bnode;				const char *f;				pk = silc_pkcs_public_key_encode(public_key, &pk_len);				if (!pk)					break;				fingerprint = silc_hash_fingerprint(NULL, pk, pk_len);				for (i = 0; i < strlen(fingerprint); i++)					if (fingerprint[i] == ' ')						fingerprint[i] = '_';				g_snprintf(buf, sizeof(buf) - 1,					   "%s" G_DIR_SEPARATOR_S "clientkeys"					   G_DIR_SEPARATOR_S "clientkey_%s.pub",					   silcpurple_silcdir(), fingerprint);				silc_free(fingerprint);				silc_free(pk);				/* Find buddy by associated public key */				for (gnode = purple_get_blist()->root; gnode;				     gnode = gnode->next) {					if (!PURPLE_BLIST_NODE_IS_GROUP(gnode))						continue;					for (cnode = gnode->child; cnode; cnode = cnode->next) {						if( !PURPLE_BLIST_NODE_IS_CONTACT(cnode))							continue;						for (bnode = cnode->child; bnode;						     bnode = bnode->next) {							if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode))								continue;							b = (PurpleBuddy *)bnode;							if (b->account != gc->account)								continue;							f = purple_blist_node_get_string(bnode, "public-key");							if (f && !strcmp(f, buf))								goto cont;							b = NULL;						}					}				}			}		cont:			if (!b) {				/* Find buddy by nickname */				b = purple_find_buddy(sg->account, client_entry->nickname);				if (!b) {					purple_debug_warning("silc", "WATCH for %s, unknown buddy",						client_entry->nickname);					break;				}			}			silc_free(b->proto_data);			b->proto_data = silc_memdup(client_entry->id,						    sizeof(*client_entry->id));			if (notify == SILC_NOTIFY_TYPE_NICK_CHANGE) {				break;			} else if (notify == SILC_NOTIFY_TYPE_UMODE_CHANGE) {				/* See if client was away and is now present */				if (!(mode & (SILC_UMODE_GONE | SILC_UMODE_INDISPOSED |					      SILC_UMODE_BUSY | SILC_UMODE_PAGE |					      SILC_UMODE_DETACHED)) &&				    (client_entry->mode & SILC_UMODE_GONE ||				     client_entry->mode & SILC_UMODE_INDISPOSED ||				     client_entry->mode & SILC_UMODE_BUSY ||				     client_entry->mode & SILC_UMODE_PAGE ||				     client_entry->mode & SILC_UMODE_DETACHED)) {					client_entry->mode = mode;					purple_prpl_got_user_status(purple_buddy_get_account(b), purple_buddy_get_name(b), SILCPURPLE_STATUS_ID_AVAILABLE, NULL);				}				else if ((mode & SILC_UMODE_GONE) ||					 (mode & SILC_UMODE_INDISPOSED) ||					 (mode & SILC_UMODE_BUSY) ||					 (mode & SILC_UMODE_PAGE) ||					 (mode & SILC_UMODE_DETACHED)) {					client_entry->mode = mode;					purple_prpl_got_user_status(purple_buddy_get_account(b), purple_buddy_get_name(b), SILCPURPLE_STATUS_ID_OFFLINE, NULL);				}			} else if (notify == SILC_NOTIFY_TYPE_SIGNOFF ||				   notify == SILC_NOTIFY_TYPE_SERVER_SIGNOFF ||				   notify == SILC_NOTIFY_TYPE_KILLED) {				client_entry->mode = mode;				purple_prpl_got_user_status(purple_buddy_get_account(b), purple_buddy_get_name(b), SILCPURPLE_STATUS_ID_OFFLINE, NULL);			} else if (notify == SILC_NOTIFY_TYPE_NONE) {				client_entry->mode = mode;				purple_prpl_got_user_status(purple_buddy_get_account(b), purple_buddy_get_name(b), SILCPURPLE_STATUS_ID_AVAILABLE, NULL);			}		}		break;	default:		purple_debug_info("silc", "Unhandled notification: %d\n", type);		break;	}	va_end(va);}/* Command handler. This function is called always in the command function.   If error occurs it will be called as well. `conn' is the associated   client connection. `cmd_context' is the command context that was   originally sent to the command. `success' is FALSE if error occurred   during command. `command' is the command being processed. It must be   noted that this is not reply from server. This is merely called just   after application has called the command. Just to tell application   that the command really was processed. */static voidsilc_command(SilcClient client, SilcClientConnection conn,	     SilcClientCommandContext cmd_context, bool success,	     SilcCommand command, SilcStatus status){	PurpleConnection *gc = client->application;	SilcPurple sg = gc->proto_data;	switch (command) {	case SILC_COMMAND_CMODE:		if (cmd_context->argc == 3 &&		    !strcmp((char *)cmd_context->argv[2], "+C"))			sg->chpk = TRUE;		else			sg->chpk = FALSE;		break;	default:		break;	}}#if 0static voidsilcpurple_whois_more(SilcClientEntry client_entry, gint id){	SilcAttributePayload attr;	SilcAttribute attribute;	char *buf;	GString *s;	SilcVCardStruct vcard;	int i;	if (id != 0)		return;	memset(&vcard, 0, sizeof(vcard));	s = g_string_new("");	silc_dlist_start(client_entry->attrs);	while ((attr = silc_dlist_get(client_entry->attrs)) != SILC_LIST_END) {		attribute = silc_attribute_get_attribute(attr);		switch (attribute) {		case SILC_ATTRIBUTE_USER_INFO:			if (!silc_attribute_get_object(attr, (void *)&vcard,						       sizeof(vcard)))				continue;			g_string_append_printf(s, "%s:\n\n", _("Personal Information"));			if (vcard.full_name)				g_string_append_printf(s, "%s:\t\t%s\n",						       _("Full Name"),						       vcard.full_name);			if (vcard.first_name)				g_string_append_printf(s, "%s:\t%s\n",						       _("First Name"),						       vcard.first_name);			if (vcard.middle_names)				g_string_append_printf(s, "%s:\t%s\n",						       _("Middle Name"),						       vcard.middle_names);			if (vcard.family_name)				g_string_append_printf(s, "%s:\t%s\n",						       _("Family Name"),						       vcard.family_name);			if (vcard.nickname)				g_string_append_printf(s, "%s:\t\t%s\n",						       _("Nickname"),						       vcard.nickname);			if (vcard.bday)				g_string_append_printf(s, "%s:\t\t%s\n",						       _("Birth Day"),						       vcard.bday);			if (vcard.title)				g_string_append_printf(s, "%s:\t\t%s\n",						       _("Job Title"),						       vcard.title);			if (vcard.role)				g_string_append_printf(s, "%s:\t\t%s\n",						       _("Job Role"),						       vcard.role);			if (vcard.org_name)				g_string_append_printf(s, "%s:\t%s\n",						       _("Organization"),						       vcard.org_name);			if (vcard.org_unit)				g_string_append_printf(s, "%s:\t\t%s\n",						       _("Unit"),						       vcard.org_unit);			if (vcard.url)				g_string_append_printf(s, "%s:\t%s\n",						       _("Homepage"),						       vcard.url);			if (vcard.label)				g_string_append_printf(s, "%s:\t%s\n",						       _("Address"),						       vcard.label);			for (i = 0; i < vcard.num_tels; i++) {				if (vcard.tels[i].telnum)					g_string_append_printf(s, "%s:\t\t\t%s\n",							       _("Phone"),							       vcard.tels[i].telnum);			}			for (i = 0; i < vcard.num_emails; i++) {				if (vcard.emails[i].address)					g_string_append_printf(s, "%s:\t\t%s\n",							       _("E-Mail"),							       vcard.emails[i].address);			}			if (vcard.note)				g_string_append_printf(s, "\n%s:\t\t%s\n",						       _("Note"),						       vcard.note);			break;		}	}	buf = g_string_free(s, FALSE);	purple_notify_info(NULL, _("User Information"), _("User Information"),			 buf);	g_free(buf);}#endif/* Command reply handler. This function is called always in the command reply   function. If error occurs it will be called as well. Normal scenario   is that it will be called after the received command data has been parsed   and processed. The function is used to pass the received command data to   the application.   `conn' is the associated client connection. `cmd_payload' is the command   payload data received from server and it can be ignored. It is provided   if the application would like to re-parse the received command data,   however, it must be noted that the data is parsed already by the library   thus the payload can be ignored. `success' is FALSE if error occurred.   In this case arguments are not sent to the application. The `status' is   the command reply status server returned. The `command' is the command   reply being processed. The function has variable argument list and each   command defines the number and type of arguments it passes to the   application (on error they are not sent). */static voidsilc_command_reply(SilcClient client, SilcClientConnection conn,		   SilcCommandPayload cmd_payload, bool success,		   SilcCommand command, SilcStatus status, ...){	PurpleConnection *gc = client->application;	SilcPurple sg = gc->proto_data;	PurpleConversation *convo;	va_list vp;	va_start(vp, status);	switch (command) {	case SILC_COMMAND_JOIN:		{			SilcChannelEntry channel_entry;			if (!success) {				purple_notify_error(gc, _("Join Chat"), _("Cannot join channel"),						  silc_get_status_message(status));				return;			}			(void)va_arg(vp, char *);			channel_entry = va_arg(vp, SilcChannelEntry);			/* Resolve users on channel */			silc_client_get_clients_by_channel(client, conn, channel_entry,							   silcpurple_chat_join_done,							   channel_entry);		}		break;	case SILC_COMMAND_LEAVE:		break;	case SILC_COMMAND_USERS:		break;	case SILC_COMMAND_WHOIS:		{			SilcUInt32 idle, mode;			SilcBuffer channels, user_modes;			SilcClientEntry client_entry;			char tmp[1024], *tmp2;			char *moodstr, *statusstr, *contactstr, *langstr, *devicestr, *tzstr, *geostr;			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);			if (!client_entry->nickname)				break;			(void)va_arg(vp, char *);			(void)va_arg(vp, char *);			(void)va_arg(vp, char *);			channels = va_arg(vp, SilcBuffer);			mode = va_arg(vp, SilcUInt32);			idle = va_arg(vp, SilcUInt32);			(void)va_arg(vp, unsigned char *);			user_modes = va_arg(vp, SilcBuffer);			user_info = purple_notify_user_info_new();			tmp2 = g_markup_escape_text(client_entry->nickname, -1);			purple_notify_user_info_add_pair(user_info, _("Nickname"), tmp2);			g_free(tmp2);			if (client_entry->realname) {				tmp2 = g_markup_escape_text(client_entry->realname, -1);				purple_notify_user_info_add_pair(user_info, _("Real Name"), tmp2);				g_free(tmp2);			}			if (client_entry->username) {				tmp2 = g_markup_escape_text(client_entry->username, -1);				if (client_entry->hostname) {					gchar *tmp3;					tmp3 = g_strdup_printf("%s@%s", tmp2, 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"), tmp2);				g_free(tmp2);			}			if (client_entry->mode) {				memset(tmp, 0, sizeof(tmp));				silcpurple_get_umode_string(client_entry->mode,						tmp, sizeof(tmp) - strlen(tmp));				purple_notify_user_info_add_pair(user_info, _("User Modes"), tmp);			}			silcpurple_parse_attrs(client_entry->attrs, &moodstr, &statusstr, &contactstr, &langstr, &devicestr, &tzstr, &geostr);			if (moodstr) {				purple_notify_user_info_add_pair(user_info, _("Mood"), moodstr);				g_free(moodstr);			}			if (statusstr) {				tmp2 = g_markup_escape_text(statusstr, -1);				purple_notify_user_info_add_pair(user_info, _("Status Text"), tmp2);				g_free(statusstr);				g_free(tmp2);			}			if (contactstr) {				purple_notify_user_info_add_pair(user_info, _("Preferred Contact"), contactstr);				g_free(contactstr);			}			if (langstr) {				purple_notify_user_info_add_pair(user_info, _("Preferred Language"), langstr);				g_free(langstr);			}			if (devicestr) {				purple_notify_user_info_add_pair(user_info, _("Device"), devicestr);				g_free(devicestr);			}			if (tzstr) {				purple_notify_user_info_add_pair(user_info, _("Timezone"), tzstr);				g_free(tzstr);			}

⌨️ 快捷键说明

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