diff options
Diffstat (limited to '')
-rw-r--r-- | common/subscriptions.c | 7 | ||||
-rw-r--r-- | common/subscriptions.h | 5 | ||||
-rw-r--r-- | maar/main.c | 2 | ||||
-rw-r--r-- | restapi/subscriptions.c | 5 |
4 files changed, 11 insertions, 8 deletions
diff --git a/common/subscriptions.c b/common/subscriptions.c index 529c339..60ce002 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* rid, const char* name, enum subscription_type type, size_t unread) +void common_subscription_add(struct subscription** subscriptions, const char* rid, const char* name, enum subscription_type type, size_t unread, char alert) { - struct subscription * subscription = common_subscription_new(rid, name, type, unread); + struct subscription * subscription = common_subscription_new(rid, name, type, unread, alert); HASH_ADD_KEYPTR(hh, *subscriptions, subscription->rid, strlen(rid), subscription); } -struct subscription* common_subscription_new(const char* rid, const char* name, enum subscription_type type, size_t unread) +struct subscription* common_subscription_new(const char* rid, const char* name, enum subscription_type type, size_t unread, char alert) { struct subscription* subscription = malloc(sizeof(struct subscription)); subscription->rid = malloc(strlen(rid) + 1); @@ -15,6 +15,7 @@ struct subscription* common_subscription_new(const char* rid, const char* name, strcpy(subscription->name, name); subscription->type = type; subscription->unread = unread; + subscription->alert = alert; return subscription; } diff --git a/common/subscriptions.h b/common/subscriptions.h index e6f4771..1c42ad0 100644 --- a/common/subscriptions.h +++ b/common/subscriptions.h @@ -14,11 +14,12 @@ struct subscription { char* name; enum subscription_type type; size_t unread; + char alert; UT_hash_handle hh; }; -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* rid, const char* name, enum subscription_type type, size_t unread); +void common_subscription_add(struct subscription** subscriptions, const char* id, const char* name, enum subscription_type type, size_t unread, char alert); +struct subscription* common_subscription_new(const char* rid, const char* name, enum subscription_type type, size_t unread, char alert); void common_subscriptions_free(struct subscription* subscriptions); void common_subscriptions_const_walk(const struct subscription* subscriptions, void (*func)(const struct subscription*)); size_t common_subscriptions_count(const struct subscription* subscriptions); diff --git a/maar/main.c b/maar/main.c index dc93a86..ee13907 100644 --- a/maar/main.c +++ b/maar/main.c @@ -11,7 +11,7 @@ void maar_subscription(const struct subscription* subscription) { - if (subscription->unread >0) { + if (subscription->unread >0 || subscription->alert) { printf("%s\n", subscription->name); liveapi_mark_read(subscription->rid); liveapi_step(); diff --git a/restapi/subscriptions.c b/restapi/subscriptions.c index 5a1abe6..a296b1c 100644 --- a/restapi/subscriptions.c +++ b/restapi/subscriptions.c @@ -42,8 +42,9 @@ restapi_subscriptions_get(void) const cJSON* type = cJSON_GetObjectItemCaseSensitive(update, "t"); const cJSON* open = cJSON_GetObjectItemCaseSensitive(update, "open"); const cJSON* unread = cJSON_GetObjectItemCaseSensitive(update, "unread"); + const cJSON* alert = cJSON_GetObjectItemCaseSensitive(update, "alert"); enum subscription_type etype; - if (!cJSON_IsString(rid) || rid->valuestring == NULL || !cJSON_IsString(name) || name->valuestring == NULL || !cJSON_IsString(type) || type->valuestring == NULL || !cJSON_IsTrue(open) || !cJSON_IsNumber(unread)) + if (!cJSON_IsString(rid) || rid->valuestring == NULL || !cJSON_IsString(name) || name->valuestring == NULL || !cJSON_IsString(type) || type->valuestring == NULL || !cJSON_IsTrue(open) || !cJSON_IsNumber(unread) || !(cJSON_IsTrue(alert) || cJSON_IsFalse(alert))) continue; if (strcmp(type->valuestring, "c") == 0) etype = SUBSCRIPTION_CHANNEL; @@ -55,7 +56,7 @@ restapi_subscriptions_get(void) fprintf(stderr, "Bug found : Unknown subscription type %s\n%s\n", type->valuestring, buffer); exit(999); } - common_subscription_add(&subscriptions, rid->valuestring, name->valuestring, etype, unread->valueint); + common_subscription_add(&subscriptions, rid->valuestring, name->valuestring, etype, unread->valueint, cJSON_IsTrue(alert)); } } get_json_cleanup: |