aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorJulien Dessaux2019-08-06 19:55:31 +0200
committerJulien Dessaux2019-08-06 19:55:31 +0200
commita753a35c37ac9b01f7e22912f8cad50603fc5ec0 (patch)
tree6758289f6456b116a25fa1aa476d9746d5d247b7 /common
parentHave the login function return the authToken (diff)
downloadrocket-cli-client-a753a35c37ac9b01f7e22912f8cad50603fc5ec0.tar.gz
rocket-cli-client-a753a35c37ac9b01f7e22912f8cad50603fc5ec0.tar.bz2
rocket-cli-client-a753a35c37ac9b01f7e22912f8cad50603fc5ec0.zip
Have the subscription struct hold the unread counters
Diffstat (limited to 'common')
-rw-r--r--common/subscriptions.c7
-rw-r--r--common/subscriptions.h5
2 files changed, 7 insertions, 5 deletions
diff --git a/common/subscriptions.c b/common/subscriptions.c
index d6d15aa..0874cb0 100644
--- a/common/subscriptions.c
+++ b/common/subscriptions.c
@@ -1,12 +1,12 @@
#include "subscriptions.h"
-void common_subscription_add(struct subscription** subscriptions, const char* id, const char* name, enum subscription_type type)
+void common_subscription_add(struct subscription** subscriptions, const char* id, const char* name, enum subscription_type type, size_t unread)
{
- struct subscription * subscription = common_subscription_new(id, name, type);
+ struct subscription * subscription = common_subscription_new(id, name, type, unread);
HASH_ADD_KEYPTR(hh, *subscriptions, subscription->id, strlen(id), subscription);
}
-struct subscription* common_subscription_new(const char* id, const char* name, enum subscription_type type)
+struct subscription* common_subscription_new(const char* id, const char* name, enum subscription_type type, size_t unread)
{
struct subscription* subscription = malloc(sizeof(struct subscription));
subscription->id = malloc(strlen(id) + 1);
@@ -14,6 +14,7 @@ struct subscription* common_subscription_new(const char* id, const char* name, e
subscription->name = malloc(strlen(name) + 1);
strcpy(subscription->name, name);
subscription->type = type;
+ subscription->unread = unread;
return subscription;
}
diff --git a/common/subscriptions.h b/common/subscriptions.h
index 6c10a24..a152345 100644
--- a/common/subscriptions.h
+++ b/common/subscriptions.h
@@ -17,11 +17,12 @@ struct subscription {
char* id;
char* name;
enum subscription_type type;
+ size_t unread;
UT_hash_handle hh;
};
-void common_subscription_add(struct subscription** subscriptions, const char* id, const char* name, enum subscription_type type);
-struct subscription* common_subscription_new(const char* id, const char* name, enum subscription_type type);
+void common_subscription_add(struct subscription** subscriptions, const char* id, const char* name, enum subscription_type type, size_t unread);
+struct subscription* common_subscription_new(const char* id, const char* name, enum subscription_type type, size_t unread);
void common_subscriptions_free(struct subscription* subscriptions);
void common_subscriptions_const_walk(const struct subscription* subscriptions, void (*func)(const struct subscription*));