began work on a msg command

This commit is contained in:
2019-07-05 16:40:16 +02:00
parent e2bdd05775
commit a164afe170
16 changed files with 231 additions and 4 deletions

View File

@@ -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);

View File

@@ -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:

View File

@@ -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);
}