📄 gg.c
字号:
n = (ev->type == GG_EVENT_NOTIFY) ? ev->event.notify : ev->event.notify_descr.notify; for (; n->uin; n++) { descr = (ev->type == GG_EVENT_NOTIFY) ? NULL : ev->event.notify_descr.descr; purple_debug_info("gg", "notify: (%d) status: %d; descr: %s\n", n->uin, n->status, descr ? descr : "(null)"); ggp_generic_status_handler(gc, n->uin, n->status, descr); } } break; case GG_EVENT_NOTIFY60: purple_debug_info("gg", "notify60_pre: (%d) status=%d; version=%d; descr=%s\n", ev->event.notify60->uin, ev->event.notify60->status, ev->event.notify60->version, ev->event.notify60->descr ? ev->event.notify60->descr : "(null)"); for (i = 0; ev->event.notify60[i].uin; i++) { purple_debug_info("gg", "notify60: (%d) status=%d; version=%d; descr=%s\n", ev->event.notify60[i].uin, ev->event.notify60[i].status, ev->event.notify60[i].version, ev->event.notify60[i].descr ? ev->event.notify60[i].descr : "(null)"); ggp_generic_status_handler(gc, ev->event.notify60[i].uin, ev->event.notify60[i].status, ev->event.notify60[i].descr); } break; case GG_EVENT_STATUS: purple_debug_info("gg", "status: (%d) status=%d; descr=%s\n", ev->event.status.uin, ev->event.status.status, ev->event.status.descr ? ev->event.status.descr : "(null)"); ggp_generic_status_handler(gc, ev->event.status.uin, ev->event.status.status, ev->event.status.descr); break; case GG_EVENT_STATUS60: purple_debug_info("gg", "status60: (%d) status=%d; version=%d; descr=%s\n", ev->event.status60.uin, ev->event.status60.status, ev->event.status60.version, ev->event.status60.descr ? ev->event.status60.descr : "(null)"); ggp_generic_status_handler(gc, ev->event.status60.uin, ev->event.status60.status, ev->event.status60.descr); break; case GG_EVENT_USERLIST: if (ev->event.userlist.type == GG_USERLIST_GET_REPLY) { purple_debug_info("gg", "GG_USERLIST_GET_REPLY\n"); purple_notify_info(gc, NULL, _("Buddy list downloaded"), _("Your buddy list was downloaded from the server.")); if (ev->event.userlist.reply != NULL) { ggp_buddylist_load(gc, ev->event.userlist.reply); } } else { purple_debug_info("gg", "GG_USERLIST_PUT_REPLY\n"); purple_notify_info(gc, NULL, _("Buddy list uploaded"), _("Your buddy list was stored on the server.")); } break; case GG_EVENT_PUBDIR50_SEARCH_REPLY: ggp_pubdir_reply_handler(gc, ev->event.pubdir50); break; default: purple_debug_error("gg", "unsupported event type=%d\n", ev->type); break; } gg_free_event(ev);}/* }}} *//* *//* static void ggp_async_login_handler(gpointer _gc, gint fd, PurpleInputCondition cond) {{{ */static void ggp_async_login_handler(gpointer _gc, gint fd, PurpleInputCondition cond){ PurpleConnection *gc = _gc; GGPInfo *info; struct gg_event *ev; g_return_if_fail(PURPLE_CONNECTION_IS_VALID(gc)); info = gc->proto_data; purple_debug_info("gg", "login_handler: session: check = %d; state = %d;\n", info->session->check, info->session->state); switch (info->session->state) { case GG_STATE_RESOLVING: purple_debug_info("gg", "GG_STATE_RESOLVING\n"); break; case GG_STATE_CONNECTING_HUB: purple_debug_info("gg", "GG_STATE_CONNECTING_HUB\n"); break; case GG_STATE_READING_DATA: purple_debug_info("gg", "GG_STATE_READING_DATA\n"); break; case GG_STATE_CONNECTING_GG: purple_debug_info("gg", "GG_STATE_CONNECTING_GG\n"); break; case GG_STATE_READING_KEY: purple_debug_info("gg", "GG_STATE_READING_KEY\n"); break; case GG_STATE_READING_REPLY: purple_debug_info("gg", "GG_STATE_READING_REPLY\n"); break; default: purple_debug_error("gg", "unknown state = %d\n", info->session->state); break; } if (!(ev = gg_watch_fd(info->session))) { purple_debug_error("gg", "login_handler: gg_watch_fd failed!\n"); purple_connection_error(gc, _("Unable to read socket")); return; } purple_debug_info("gg", "login_handler: session->fd = %d\n", info->session->fd); purple_debug_info("gg", "login_handler: session: check = %d; state = %d;\n", info->session->check, info->session->state); purple_input_remove(gc->inpa); /** XXX I think that this shouldn't be done if ev->type is GG_EVENT_CONN_FAILED or GG_EVENT_CONN_SUCCESS -datallah */ gc->inpa = purple_input_add(info->session->fd, (info->session->check == 1) ? PURPLE_INPUT_WRITE : PURPLE_INPUT_READ, ggp_async_login_handler, gc); switch (ev->type) { case GG_EVENT_NONE: /* Nothing happened. */ purple_debug_info("gg", "GG_EVENT_NONE\n"); break; case GG_EVENT_CONN_SUCCESS: { PurpleAccount *account; PurplePresence *presence; PurpleStatus *status; purple_debug_info("gg", "GG_EVENT_CONN_SUCCESS\n"); purple_input_remove(gc->inpa); gc->inpa = purple_input_add(info->session->fd, PURPLE_INPUT_READ, ggp_callback_recv, gc); /* gg_change_status(info->session, GG_STATUS_AVAIL); */ account = purple_connection_get_account(gc); presence = purple_account_get_presence(account); status = purple_presence_get_active_status(presence); ggp_set_status(account, status); purple_connection_set_state(gc, PURPLE_CONNECTED); ggp_buddylist_send(gc); } break; case GG_EVENT_CONN_FAILED: purple_input_remove(gc->inpa); gc->inpa = 0; purple_connection_error(gc, _("Connection failed.")); break; default: purple_debug_error("gg", "strange event: %d\n", ev->type); break; } gg_free_event(ev);}/* }}} *//* ---------------------------------------------------------------------- *//* ----- PurplePluginProtocolInfo ----------------------------------------- *//* ---------------------------------------------------------------------- *//* static const char *ggp_list_icon(PurpleAccount *account, PurpleBuddy *buddy) {{{ */static const char *ggp_list_icon(PurpleAccount *account, PurpleBuddy *buddy){ return "gadu-gadu";}/* }}} *//* static char *ggp_status_text(PurpleBuddy *b) {{{ */static char *ggp_status_text(PurpleBuddy *b){ PurpleStatus *status; const char *msg; char *text; char *tmp; status = purple_presence_get_active_status(purple_buddy_get_presence(b)); msg = purple_status_get_attr_string(status, "message"); if (msg != NULL) { tmp = purple_markup_strip_html(msg); text = g_markup_escape_text(tmp, -1); g_free(tmp); return text; } else { tmp = purple_utf8_salvage(purple_status_get_name(status)); text = g_markup_escape_text(tmp, -1); g_free(tmp); return text; }}/* }}} *//* static void ggp_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) {{{ */static void ggp_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full){ PurpleStatus *status; char *text, *tmp; const char *msg, *name; g_return_if_fail(b != NULL); status = purple_presence_get_active_status(purple_buddy_get_presence(b)); msg = purple_status_get_attr_string(status, "message"); name = purple_status_get_name(status); if (msg != NULL) { text = g_markup_escape_text(msg, -1); if (PURPLE_BUDDY_IS_ONLINE(b)) { tmp = g_strdup_printf("%s: %s", name, text); purple_notify_user_info_add_pair(user_info, _("Status"), tmp); g_free(tmp); } else { purple_notify_user_info_add_pair(user_info, _("Message"), text); } g_free(text); /* We don't want to duplicate 'Status: Offline'. */ } else if (PURPLE_BUDDY_IS_ONLINE(b)) { purple_notify_user_info_add_pair(user_info, _("Status"), name); }}/* }}} *//* static GList *ggp_status_types(PurpleAccount *account) {{{ */static GList *ggp_status_types(PurpleAccount *account){ PurpleStatusType *type; GList *types = NULL; type = purple_status_type_new_with_attrs( PURPLE_STATUS_AVAILABLE, NULL, NULL, TRUE, TRUE, FALSE, "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), NULL); types = g_list_append(types, type); /* * Without this selecting Invisible as own status doesn't * work. It's not used and not needed to show status of buddies. */ type = purple_status_type_new_with_attrs( PURPLE_STATUS_INVISIBLE, NULL, NULL, TRUE, TRUE, FALSE, "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), NULL); types = g_list_append(types, type); type = purple_status_type_new_with_attrs( PURPLE_STATUS_AWAY, NULL, NULL, TRUE, TRUE, FALSE, "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), NULL); types = g_list_append(types, type); /* * This status is necessary to display guys who are blocking *us*. */ type = purple_status_type_new_with_attrs( PURPLE_STATUS_INVISIBLE, "blocked", _("Blocked"), TRUE, FALSE, FALSE, "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), NULL); types = g_list_append(types, type); type = purple_status_type_new_with_attrs( PURPLE_STATUS_OFFLINE, NULL, NULL, TRUE, TRUE, FALSE, "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), NULL); types = g_list_append(types, type); return types;}/* }}} *//* static GList *ggp_blist_node_menu(PurpleBlistNode *node) {{{ */static GList *ggp_blist_node_menu(PurpleBlistNode *node){ PurpleMenuAction *act; GList *m = NULL; if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) return NULL; act = purple_menu_action_new(_("Add to chat"), PURPLE_CALLBACK(ggp_bmenu_add_to_chat), NULL, NULL); m = g_list_append(m, act); /* Using a blist node boolean here is also wrong. * Once the Block and Unblock actions are added to the core, * this will have to go. -- rlaager */ if (purple_blist_node_get_bool(node, "blocked")) { act = purple_menu_action_new(_("Unblock"), PURPLE_CALLBACK(ggp_bmenu_block), NULL, NULL); } else { act = purple_menu_action_new(_("Block"), PURPLE_CALLBACK(ggp_bmenu_block), NULL, NULL); } m = g_list_append(m, act); return m;}/* }}} *//* static GList *ggp_chat_info(PurpleConnection *gc) {{{ */static GList *ggp_chat_info(PurpleConnection *gc){ GList *m = NULL; struct proto_chat_entry *pce; pce = g_new0(struct proto_chat_entry, 1); pce->label = _("Chat _name:"); pce->identifier = "name"; pce->required = TRUE; m = g_list_append(m, pce); return m;}/* }}} *//* static void ggp_login(PurpleAccount *account) {{{ */static void ggp_login(PurpleAccount *account){ PurpleConnection *gc; struct gg_login_params *glp; GGPInfo *info; if (ggp_setup_proxy(account) == -1) return; gc = purple_account_get_connection(account); glp = g_new0(struct gg_login_params, 1); info = g_new0(GGPInfo, 1); /* Probably this should be moved to *_new() function. */ info->session = NULL; info->chats = NULL; info->chats_count = 0; info->token = NULL; info->searches = ggp_search_new(); gc->proto_data = info; glp->uin = ggp_get_uin(account); glp->password = (char *)purple_account_get_password(account); glp->async = 1; glp->status = GG_STATUS_AVAIL; glp->tls = 0; info->session = gg_login(glp); if (info->session == NULL) { purple_connection_error(gc, _("Connection failed.")); g_free(glp); return; } gc->inpa = purple_input_add(info->session->fd, PURPLE_INPUT_READ, ggp_async_login_handler, gc);}/* }}} *//* static void ggp_close(PurpleConnection *gc) {{{ */static void ggp_close(PurpleConnection *gc){ if (gc == NULL) { purple_debug_info("gg", "gc == NULL\n"); return; } if (gc->proto_data) { PurpleAccount *account = purple_connection_get_account(gc); PurpleStatus *status; GGPInfo *info = gc->proto_data; status = purple_account_get_active_status(account); if (info->session != NULL) { ggp_set_status(account, status); gg_logoff(info->session); gg_free_session(info->session); } /* Immediately close any notifications on this handle since that process depends * upon the contents of info->searches, which we are about to destroy. */ purple_notify_close_with_handle(gc); ggp_search_destroy(info->searches); g_free(info); gc->proto_data = NULL; } if (gc->inpa > 0) purple_input_remove(gc->inpa); ggp_buddylist_offline(gc); purple_debug_info("gg", "Connection closed.\n");}/* }}} *//* static int ggp_send_im(PurpleConnection *gc, const char *who, const char *msg, PurpleMessageFlags flags) {{{ */static int ggp_send_im(PurpleConnection *gc, const char *who, const char *msg, PurpleMessageFlags flags){ GGPInfo *info = gc->proto_data; char *tmp, *plain; int ret = 0; if (strlen(msg) == 0) { return 0; } purple_debug_info("gg", "ggp_send_im: msg = %s\n", msg); plain = purple_unescape_html(msg); tmp = charset_convert(plain, "UTF-8", "CP1250");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -