summaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
Diffstat (limited to 'data.c')
-rw-r--r--data.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/data.c b/data.c
index f8be1ff..f19075c 100644
--- a/data.c
+++ b/data.c
@@ -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));