Ejemplo n.º 1
0
/**
 * What should be done after authenticating successfully,
 * set connection status, set account state, and then fetch
 * the roster.
 */
static void
auth_success(XmppStream *stream)
{
    HybridAccount *account;

    g_return_if_fail(stream != NULL);

    account = stream->account->account;

    if (account->state == HYBRID_STATE_OFFLINE || 
        account->state == HYBRID_STATE_INVISIBLE) {
        account->state = HYBRID_STATE_ONLINE;
    }

    /* set account's presence state. */
    hybrid_account_set_state(account, account->state);

    /*
     * Remember to do this before adding any buddies to the blist,
     * we should set the account to be connected first.
     */
    hybrid_account_set_connection_status(account,
            HYBRID_CONNECTION_CONNECTED);

    /* OK, we request the roster from the server. */
    xmpp_stream_get_vcard(stream);
    xmpp_stream_get_roster(stream);

}
Ejemplo n.º 2
0
Archivo: imap.c Proyecto: GCrean/hybrid
gboolean
imap_auth_cb(hybrid_imap *imap, const gchar *msg, gpointer user_data)
{
    hybrid_debug_info("imap", "recv:\n%s", msg);

    if (HYBRID_OK == check_resp_ok(msg)) {
        hybrid_account_set_connection_string(imap->account,
                                             _("IMAP OK."));
        hybrid_account_set_connection_status(imap->account,
                                             HYBRID_CONNECTION_CONNECTED);

        hybrid_account_set_state(imap->account, HYBRID_STATE_ONLINE);

        imap->mail_check_source = g_timeout_add_seconds(
                                        imap->mail_check_interval,
                                        check_mail, imap);
        return FALSE;
    }

    hybrid_account_error_reason(imap->account,
                                _("IMAP Authenticate Failed."
                                  " Check your username and password."));

    return FALSE;
}
Ejemplo n.º 3
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;
}