Пример #1
0
static void
entry_activate_cb(GtkWidget *widget, gpointer user_data)
{
	HybridAccount *account;
	HybridModule *module;
	const gchar *text;

	hide_edit_box();

	account = hybrid_head->edit_account;
	module  = account->proto;
	text    = gtk_entry_get_text(GTK_ENTRY(hybrid_head->edit_entry));

	if (!account) {
		return;
	}

	if (hybrid_head->edit_state == HYBRID_HEAD_EDIT_NAME) {
		/* No change to the nickname. */
		if (g_strcmp0(text, account->nickname) == 0) {
			return;
		}

		if (module->info->modify_name) {
			if (!module->info->modify_name(account, text)) {
				return;
			}

			account = hybrid_blist_get_current_account();
			hybrid_account_set_nickname(account, text);
			hybrid_head_bind_to_account(account);
		}
	}

	if (hybrid_head->edit_state == HYBRID_HEAD_EDIT_STATUS) {
		/* No change to the status text. */
		if (g_strcmp0(text, account->status_text) == 0) {
			return;
		}

		if (module->info->modify_status) {
			if (!module->info->modify_status(account, text)) {
				return;
			}

			account = hybrid_blist_get_current_account();
			hybrid_account_set_status_text(account, text);
			hybrid_head_bind_to_account(account);
		}
	}
}
Пример #2
0
/**
 * Callback function to handle the read event after
 * rendered sipc authentication.
 */
static gint
sipc_auth_cb(fetion_account *ac, const gchar *sipmsg,
             fetion_transaction *trans)
{
    gint   code;
    gint   length;
    gchar *pos;

    code = fetion_sip_get_code(sipmsg);

    hybrid_debug_info("fetion", "sipc recv:\n%s", sipmsg);

    if (code == FETION_SIP_OK) { /**< ok, we got the contact list */

        /* update the portrait. */
        fetion_account_update_portrait(ac);

        length = fetion_sip_get_length(sipmsg);
        pos = strstr(ac->buffer, "\r\n\r\n") + 4;

        parse_sipc_resp(ac, pos, length);

        /* set the nickname of the hybrid account. */
        hybrid_account_set_nickname(ac->account, ac->nickname);

        /* set the mood phrase of the hybrid account. */
        hybrid_account_set_status_text(ac->account, ac->mood_phrase);

        hybrid_account_set_state(ac->account, HYBRID_STATE_INVISIBLE);

        /* set the connection status. */
        hybrid_account_set_connection_status(ac->account,
                HYBRID_CONNECTION_CONNECTED);

        /* init group list */
        fetion_groups_init(ac);

        /* init buddy list */
        fetion_buddies_init(ac);

        /* start scribe the pushed msg */
        fetion_buddy_scribe(ac);

    } else if (420 == code || 421 == code) {

        if (HYBRID_ERROR == parse_sipc_verification(ac, sipmsg)) {
            hybrid_account_error_reason(ac->account,
                                        _("Fetion Protocol ERROR."));
            return FALSE;
        }

        hybrid_debug_error("fetion", "sipc authentication need Verification.");

        verify_data.sipc_conn = ac->sk;
        verify_data.type      = VERIFY_TYPE_SIP;

        hybrid_proxy_connect(NAV_SERVER, 80, pic_download_cb, ac);

        g_free(ac->buffer);
        ac->buffer = NULL;

        return HYBRID_OK;
    } else {
        g_free(ac->buffer);
        ac->buffer = NULL;

        return HYBRID_ERROR;
    }

    return HYBRID_ERROR;
}