began work on a msg command
This commit is contained in:
@@ -69,11 +69,16 @@ void dc_account_set_token(dc_account_t a, char const *token);
|
||||
char const *dc_account_token(dc_account_t a);
|
||||
bool dc_account_has_token(dc_account_t a);
|
||||
|
||||
/* compare
|
||||
*/
|
||||
bool dc_account_equal(dc_account_t a, dc_account_t b);
|
||||
|
||||
/* relationships
|
||||
*/
|
||||
void dc_account_set_friends(dc_account_t a, dc_account_t *ptr, size_t len);
|
||||
dc_account_t dc_account_nthfriend(dc_account_t a, size_t i);
|
||||
size_t dc_account_friends_size(dc_account_t a);
|
||||
dc_account_t dc_account_findfriend(dc_account_t a, char const *fullname);
|
||||
|
||||
int dc_account_friend_state(dc_account_t a);
|
||||
void dc_account_set_friend_state(dc_account_t a, int state);
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <stdint.h>
|
||||
#include <jansson.h>
|
||||
|
||||
#include <dc/account.h>
|
||||
|
||||
/**
|
||||
* A discord channel. Exactly what it says on the tin. A place where one
|
||||
* or more guardsmen can exchange Slaaneshi heresy without their commissars
|
||||
@@ -50,4 +52,7 @@ dc_channel_t dc_channel_from_json(json_t *j);
|
||||
dc_channel_type_t dc_channel_type(dc_channel_t c);
|
||||
void dc_channel_set_type(dc_channel_t c, dc_channel_type_t t);
|
||||
|
||||
size_t dc_channel_recipients(dc_channel_t c);
|
||||
dc_account_t dc_channel_nthrecipient(dc_channel_t c, size_t i);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -282,6 +282,13 @@ char const *dc_account_fullname(dc_account_t a)
|
||||
return a->full;
|
||||
}
|
||||
|
||||
bool dc_account_equal(dc_account_t a, dc_account_t b)
|
||||
{
|
||||
return_if_true(a == NULL && b == NULL, true);
|
||||
return_if_true(a == NULL || b == NULL, false);
|
||||
return (strcmp(a->full, b->full) == 0);
|
||||
}
|
||||
|
||||
void dc_account_set_friends(dc_account_t a, dc_account_t *friends, size_t len)
|
||||
{
|
||||
size_t i = 0;
|
||||
@@ -293,6 +300,21 @@ void dc_account_set_friends(dc_account_t a, dc_account_t *friends, size_t len)
|
||||
}
|
||||
}
|
||||
|
||||
dc_account_t dc_account_findfriend(dc_account_t a, char const *fullname)
|
||||
{
|
||||
size_t i = 0;
|
||||
return_if_true(a == NULL || fullname == NULL, NULL);
|
||||
|
||||
for (i = 0; i < a->friends->len; i++) {
|
||||
dc_account_t f = g_ptr_array_index(a->friends, i);
|
||||
if (strcmp(f->full, fullname) == 0) {
|
||||
return f;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dc_account_t dc_account_nthfriend(dc_account_t a, size_t i)
|
||||
{
|
||||
return_if_true(a == NULL || a->friends == NULL, NULL);
|
||||
|
||||
@@ -18,7 +18,7 @@ bool dc_api_create_channel(dc_api_t api, dc_account_t login,
|
||||
goto_if_true(url == NULL, cleanup);
|
||||
|
||||
/* build a JSON object that contains one array called "recipients":
|
||||
* {"recipients": ["snowflake#1", "snowflake#N"]}
|
||||
* {"recipients": ["snowflake#1", ..., "snowflake#N"]}
|
||||
*/
|
||||
data = json_object();
|
||||
array = json_array();
|
||||
@@ -42,6 +42,7 @@ bool dc_api_create_channel(dc_api_t api, dc_account_t login,
|
||||
goto_if_true(c == NULL, cleanup);
|
||||
|
||||
*channel = c;
|
||||
ret = true;
|
||||
|
||||
cleanup:
|
||||
|
||||
|
||||
@@ -225,3 +225,16 @@ void dc_channel_set_type(dc_channel_t c, dc_channel_type_t t)
|
||||
return_if_true(c == NULL,);
|
||||
c->type = t;
|
||||
}
|
||||
|
||||
size_t dc_channel_recipients(dc_channel_t c)
|
||||
{
|
||||
return_if_true(c == NULL || c->recipients == NULL, 0);
|
||||
return c->recipients->len;
|
||||
}
|
||||
|
||||
dc_account_t dc_channel_nthrecipient(dc_channel_t c, size_t i)
|
||||
{
|
||||
return_if_true(c == NULL || c->recipients == NULL, NULL);
|
||||
return_if_true(i >= c->recipients->len, NULL);
|
||||
return g_ptr_array_index(c->recipients, i);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user