static void xmpp_iq_peer_clan_member_update_cb(const char *msg,
                                               enum xmpp_msg_type type,
                                               void *args)
{
    struct clanmate *cp = (struct clanmate *) args;

    /* If user is not reachable, it means he disconnected */
    if (type & XMPP_TYPE_ERROR)
    {
        cp->status = STATUS_OFFLINE;

        clanmate_list_update(NULL,
                             cp->nickname,
                             cp->profile_id,
                             cp->status,
                             cp->experience,
                             cp->clan_points,
                             cp->clan_role);

#ifdef DBUS_API
        dbus_api_emit_status_update(cp->nickname, cp->status,
                                    cp->experience, cp->clan_points);
#endif /* DBUS_API */

    }

    clanmate_free(cp);
}
예제 #2
0
void xmpp_iq_player_status(int status)
{
    xmpp_send_iq_get(
        JID_K01,
        NULL, NULL,
        "<query xmlns='urn:cryonline:k01'>"
        "<player_status prev_status='%u' new_status='%u' to='%s'/>"
        "</query>",
        session.online.status,
        status,
        session.gameroom.jid != NULL ? session.online.channel : "");

    session.online.status = status;
    session.online.last_status_update = time(NULL);

    /* Broadcast to every buddy */

    list_foreach(session.profile.friends,
                 (f_list_callback) xmpp_iq_peer_status_update_friend,
                 NULL);

    list_foreach(session.profile.clanmates,
                 (f_list_callback) xmpp_iq_peer_clan_member_update_clanmate,
                 NULL);
#ifdef DBUS_API
    dbus_api_emit_status_update(session.profile.nickname,
                                session.online.status,
                                session.profile.experience,
                                session.profile.clan.points);
#endif
}
예제 #3
0
void xmpp_iq_player_status(int status)
{
    send_stream_format(session.wfs,
                       "<iq to='k01.warface' type='get'>"
                       "<query xmlns='urn:cryonline:k01'>"
                       "<player_status prev_status='%u' new_status='%u'"
                       "               to='%s'/>"
                       "</query>"
                       "</iq>",
                       session.status, status, "");

    session.status = status;

    list_foreach(session.friends,
                 (f_list_callback) xmpp_iq_peer_status_update_friend,
                 NULL);

    list_foreach(session.clanmates,
                 (f_list_callback) xmpp_iq_peer_clan_member_update_clanmate,
                 NULL);
#ifdef DBUS_API
    dbus_api_emit_status_update(session.nickname,
                                session.status,
                                session.experience,
                                session.clan_points);
#endif
}
static void xmpp_iq_peer_status_update_cb(const char *msg_id,
                                          const char *msg,
                                          void *args)
{
    /* Answer
       <iq from='xxxxxxx@warface/GameClient' type='get'>
        <query xmlns='urn:cryonline:k01'>
         <peer_status_update nickname='xxxx' profile_id='xxxx' status='13'
                             experience='xxxx' place_token=''
                             place_info_token=''/>
        </query>
       </iq>
    */

    char *data = wf_get_query_content(msg);

    if (data == NULL)
        return;

    char *jid = get_info(msg, "from='", "'", NULL);
    char *nick = get_info(data, "nickname='", "'", NULL);
    char *pid = get_info(data, "profile_id='", "'", NULL);
    int status = get_info_int(data, "status='", "'", NULL);
    int exp = get_info_int(data, "experience='", "'", NULL);

#ifdef DBUS_API
    dbus_api_emit_status_update(nick, status, exp, 0);
#endif /* DBUS_API */

    if (status == STATUS_OFFLINE || status & STATUS_LEFT)
        friend_list_update(NULL, nick, pid, status, exp);
    else
        friend_list_update(jid, nick, pid, status, exp);

    xmpp_send_iq_result(
        JID(jid),
        msg_id,
        "<query xmlns='urn:cryonline:k01'>"
        " <peer_status_update/>"
        "</query>",
        NULL);

    free(jid);
    free(nick);
    free(pid);
    free(data);
}
예제 #5
0
파일: status.c 프로젝트: Levak/warfacebot
void status_set(enum status status)
{
    enum status old_status = session.online.status;
    time_t now = time(NULL);

    /* Check if status is different */
    if ((old_status ^ STATUS_AFK)
         != (status ^ STATUS_AFK))
    {
        session.online.last_status_change = now;
    }

    xmpp_iq_player_status(status);

    session.online.status = status;
    session.online.last_status_update = now;

    /* Update cached infos */
    status_update_location();

    /* Broadcast to every buddy */

    list_foreach(session.profile.friends,
                 (f_list_callback) xmpp_iq_peer_status_update_friend,
                 NULL);

    list_foreach(session.profile.clanmates,
                 (f_list_callback) xmpp_iq_peer_clan_member_update_clanmate,
                 NULL);

#ifdef DBUS_API
    /* Broadcast to DBus */
    dbus_api_emit_status_update(session.profile.nickname,
                                session.online.status,
                                session.profile.experience,
                                session.profile.clan.points);
#endif
}