📄 ops.c
字号:
SilcUInt32 argc, unsigned char **argv){ PurpleConnection *gc = client->application; SilcPurple sg = gc->proto_data; switch (command) { case SILC_COMMAND_CMODE: if (argc == 3 && !strcmp((char *)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. Delivers a reply to command that was sent earlier. The `conn' is the associated client connection. The `command' indicates the command reply type. If the `status' other than SILC_STATUS_OK an error occurred. In this case the `error' will indicate the error. It is possible to receive list of command replies and list of errors. In this case the `status' will indicate it is an list entry (the `status' is SILC_STATUS_LIST_START, SILC_STATUS_LIST_ITEM and/or SILC_STATUS_LIST_END). The arguments received in `ap' are command specific. See a separate documentation in the Toolkit Reference Manual for the command reply arguments. */static voidsilc_command_reply(SilcClient client, SilcClientConnection conn, SilcCommand command, SilcStatus status, SilcStatus error, va_list ap){ PurpleConnection *gc = client->application; SilcPurple sg = gc->proto_data; PurpleConversation *convo; switch (command) { case SILC_COMMAND_JOIN: { SilcChannelEntry channel; PurpleConversation *convo; SilcHashTableList *user_list; SilcChannelUser chu; GList *users = NULL, *flags = NULL; char tmp[256], *topic; if (status != SILC_STATUS_OK) { purple_notify_error(gc, _("Join Chat"), _("Cannot join channel"), silc_get_status_message(error)); return; } (void)va_arg(ap, char *); channel = va_arg(ap, SilcChannelEntry); (void)va_arg(ap, SilcUInt32); user_list = va_arg(ap, SilcHashTableList *); topic = va_arg(ap, char *); /* Add channel to Purple */ channel->context = SILC_32_TO_PTR(++sg->channel_ids); serv_got_joined_chat(gc, sg->channel_ids, channel->channel_name); convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, channel->channel_name, sg->account); if (!convo) return; /* Add all users to channel */ while (silc_hash_table_get(user_list, NULL, (void *)&chu)) { PurpleConvChatBuddyFlags f = PURPLE_CBFLAGS_NONE; chu->context = SILC_32_TO_PTR(sg->channel_ids); if (chu->mode & SILC_CHANNEL_UMODE_CHANFO) f |= PURPLE_CBFLAGS_FOUNDER; if (chu->mode & SILC_CHANNEL_UMODE_CHANOP) f |= PURPLE_CBFLAGS_OP; users = g_list_append(users, g_strdup(chu->client->nickname)); flags = g_list_append(flags, GINT_TO_POINTER(f)); if (chu->mode & SILC_CHANNEL_UMODE_CHANFO) { if (chu->client == conn->local_entry) g_snprintf(tmp, sizeof(tmp), _("You are channel founder on <I>%s</I>"), channel->channel_name); else g_snprintf(tmp, sizeof(tmp), _("Channel founder on <I>%s</I> is <I>%s</I>"), channel->channel_name, chu->client->nickname); purple_conversation_write(convo, NULL, tmp, PURPLE_MESSAGE_SYSTEM, time(NULL)); } } purple_conv_chat_add_users(PURPLE_CONV_CHAT(convo), users, NULL, flags, FALSE); g_list_free(users); g_list_free(flags); /* Set topic */ if (topic) purple_conv_chat_set_topic(PURPLE_CONV_CHAT(convo), NULL, topic); /* Set nick */ purple_conv_chat_set_nick(PURPLE_CONV_CHAT(convo), conn->local_entry->nickname); } break; case SILC_COMMAND_LEAVE: break; case SILC_COMMAND_USERS: break; case SILC_COMMAND_WHOIS: { SilcUInt32 idle, *user_modes; SilcDList channels; SilcClientEntry client_entry; char tmp[1024], *tmp2; char *moodstr, *statusstr, *contactstr, *langstr, *devicestr, *tzstr, *geostr; PurpleNotifyUserInfo *user_info; if (status != SILC_STATUS_OK) { purple_notify_error(gc, _("User Information"), _("Cannot get user information"), silc_get_status_message(error)); break; } client_entry = va_arg(ap, SilcClientEntry); (void)va_arg(ap, char *); (void)va_arg(ap, char *); (void)va_arg(ap, char *); channels = va_arg(ap, SilcDList); (void)va_arg(ap, SilcUInt32); idle = va_arg(ap, SilcUInt32); (void)va_arg(ap, unsigned char *); user_modes = va_arg(ap, SilcUInt32 *); 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); } 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); } 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) { SilcChannelPayload entry; int i = 0; memset(tmp, 0, sizeof(tmp)); silc_dlist_start(channels); while ((entry = silc_dlist_get(channels))) { SilcUInt32 name_len; char *m = silc_client_chumode_char(user_modes[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); } 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 /* 0 */ 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 (status != SILC_STATUS_OK) { purple_notify_error(gc, _("User Information"), _("Cannot get user information"), silc_get_status_message(error)); break; } client_entry = va_arg(ap, SilcClientEntry); nickname = va_arg(ap, char *); username = va_arg(ap, char *); realname = va_arg(ap, 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: { const char *file; SilcBuffer detach_data; if (status != SILC_STATUS_OK) { purple_notify_error(gc, _("Detach From Server"), _("Cannot detach"), silc_get_status_message(error)); return; } detach_data = va_arg(ap, SilcBuffer); /* Save the detachment data to file. */ file = silcpurple_session_file(purple_account_get_username(sg->account)); g_unlink(file); silc_file_writefile(file, (const char *)silc_buffer_data(detach_data), silc_buffer_len(detach_data)); } break; case SILC_COMMAND_TOPIC: { SilcChannelEntry channel; if (status != SILC_STATUS_OK) { purple_notify_error(gc, _("Topic"), _("Cannot set topic"), silc_get_status_message(error)); return; } channel = va_arg(ap, 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 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -