diff options
-rw-r--r-- | data.c | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -3,6 +3,7 @@ #include <string.h> #include <stdlib.h> #include <stdio.h> +#include <stdbool.h> #include "gui.h" #include "data.h" @@ -11,10 +12,29 @@ static roster_item_t* roster = NULL; +/* check if JID is already in roster data structure */ +bool is_jid_known(const char* jid) { + + roster_item_t* i; + + // iterate over all roster items + for (i = roster; i != NULL; i=i->next) { + if (strcmp(i->jid, jid) == 0) { + return true; + } + } + + return false; + +} + void data_add_roster_item(const char* jid, const char* subscription, const char* name) { - // FIXME check if roster item already exists and handle updates + // FIXME handle roster updates + if (is_jid_known(jid)) { + return; + } // allocate datastructures roster_item_t* item = malloc(sizeof(roster_item_t)); |