void xmpp_iq_confirm_notification(const char *notif) { char *notif_id = get_info(notif, "id='", "'", NULL); enum e_notif_type notif_type = get_info_int(notif, "type='", "'", NULL); switch (notif_type) { /* Confirm consecutive logins */ case NOTIF_CONS_LOGIN: puts("Getting consecutive reward"); /* Accept any friend requests */ case NOTIF_FRIEND_REQUEST: send_stream_format(session.wfs, "<iq to='masterserver@warface/%s' type='get'>" " <query xmlns='urn:cryonline:k01'>" " <confirm_notification>" " <notif id='%s' type='%d'>" " <confirmation result='0' status='%d'" " location=''/>" " </notif>" " </confirm_notification>" " </query>" "</iq>", session.channel, notif_id, notif_type, session.status); break; /* Old fashion peer_status_update */ case NOTIF_STATUS_UPDATE: { char *jid = get_info(notif, "jid='", "'", NULL); char *nick = get_info(notif, "nickname='", "'", NULL); char *pid = get_info(notif, "profile_id='", "'", NULL); int status = get_info_int(notif, "status='", "'", NULL); int exp = get_info_int(notif, "experience='", "'", NULL); if (status <= STATUS_OFFLINE) jid = NULL; friend_list_add(jid, nick, pid, status, exp); xmpp_iq_peer_status_update(jid); free(jid); free(nick); free(pid); } break; default: break; } free(notif_id); }
static void xmpp_iq_friend_list_cb ( const char *msg_id, const char *msg, void *args ) { /* Record friends to list <iq from='masterserver@warface/pve_12' type='get'> <query xmlns='urn:cryonline:k01'> <friend_list> <friend jid='XXX' profile_id='XXX' nickname='XXX' status='XXX' experience='XXX' location='XXX'/> <friend jid='XXX' profile_id='XXX' nickname='XXX' status='XXX' experience='XXX' location='XXX'/> </friend_list> </query> </iq> */ char *data = wf_get_query_content ( msg ); #if 0 printf ( "\n\nDECODED:\n%s\n\n", data ); #endif //friend_list_empty(); unsigned int old_friends = session.profile.friends->length; unsigned int new_friends = 0; const char *m = strstr ( data, "<friend_list" ); const char *tmp = m + sizeof ( "<friend_list" ); while ( ( tmp = strstr ( tmp, "<friend" ) ) ) { new_friends++; tmp += sizeof ( "<friend" ); } if ( new_friends < old_friends ) friend_list_empty ( ); if ( m != NULL ) { m += sizeof ( "<friend_list" ); while ( ( m = strstr ( m, "<friend" ) ) ) { m += sizeof ( "<friend" ); char *jid = get_info ( m, "jid='", "'", NULL ); char *nick = get_info ( m, "nickname='", "'", NULL ); char *pid = get_info ( m, "profile_id='", "'", NULL ); int status = get_info_int ( m, "status='", "'", NULL ); int exp = get_info_int ( m, "experience='", "'", NULL ); if ( list_get ( session.profile.friends, nick ) ) friend_list_update ( jid, nick, pid, status, exp, "", "", "", "" ); else { if ( jid && *jid ) if ( !( status & ( STATUS_AFK | STATUS_PLAYING ) ) ) LOGPRINT ( "Friend: " KGRN BOLD "%s" KWHT "\n", nick ); else if ( status & STATUS_PLAYING ) LOGPRINT ( "Friend: " KMAG BOLD "%s" KWHT "\n", nick ); else LOGPRINT ( "Friend: " KYEL BOLD "%s" KWHT "\n", nick ); else LOGPRINT ( "Friend: " KCYN BOLD "%s" KWHT "\n", nick ); struct friend *f = friend_list_add ( jid, nick, pid, status, exp ); if ( f->jid ) xmpp_iq_peer_status_update ( f ); } free ( jid ); free ( nick ); free ( pid ); } }