Ejemplo n.º 1
0
/**
 * Process the user entered message. The fetion prococol dont allow us
 * to send messages to an online buddy who's conversation channel is not
 * ready, so before chating with an online buddy, we should first start
 * a new conversation channel, and invite the buddy to the conversation,
 * but when the channel is ready? yes, when we got the User-Entered
 * message through the new channel established, the channel is ready!
 */
static void
process_enter_cb(fetion_account *ac, const gchar *sipmsg)
{
    GSList             *pos;
    fetion_transaction *trans;

    g_return_if_fail(ac != NULL);
    g_return_if_fail(sipmsg != NULL);

    hybrid_debug_info("fetion", "user entered:\n%s", sipmsg);

    /* Set the channel's ready flag. */
    ac->channel_ready = TRUE;

    /* Check the transaction waiting list, wakeup the sleeping transaction,
     * the transaction is either sending a SMS or sending a nudge, we got
     * the information from the transaction context, and restore the transaction. */
    while (ac->trans_wait_list) {
        pos = ac->trans_wait_list;
        trans = (fetion_transaction*)pos->data;

        if (trans->msg && *(trans->msg) != '\0') {
            fetion_message_send(ac, trans->userid, trans->msg);
        }

        transaction_wakeup(ac, trans);
    }
}
Ejemplo n.º 2
0
static gint
invite_buddy_cb(fetion_account *account, const gchar *sipmsg,
				fetion_transaction *trans)
{
	hybrid_debug_info("fetion", "invite buddy response:\n%s", sipmsg);

	if (trans->msg && *(trans->msg) != '\0') {
		fetion_message_send(account, trans->userid, trans->msg);
	}

	return HYBRID_OK;
}
Ejemplo n.º 3
0
static void
fx_chat_send(HybridAccount *account, HybridBuddy *buddy, const gchar *text)
{
    fetion_account *ac;
    fetion_account *tmp_ac;
    extern GSList  *channel_list;
    GSList         *pos;

    ac = hybrid_account_get_protocol_data(account);

    if (BUDDY_IS_OFFLINE(buddy) || BUDDY_IS_INVISIBLE(buddy)) {
        fetion_message_send(ac, buddy->id, text);

    } else {
        /*
         * If the buddy's state is greater than 0, then we should
         * invite the buddy first to start a new socket channel,
         * then we can send the message through the new channel.
         * Now, we check whether a channel related to this buddy has
         * been established, if so, just send the message through
         * the existing one, otherwise, start a new channel.
         */
        for (pos = channel_list; pos; pos = pos->next) {
            tmp_ac = (fetion_account*)pos->data;

            if (g_strcmp0(tmp_ac->who, buddy->id) == 0) {
                /* yes, we got one. */
                fetion_message_send(tmp_ac, tmp_ac->who, text);

                return;
            }
        }

        fetion_message_new_chat(ac, buddy->id, text);
    }
}