web sockets are hard

This commit is contained in:
2019-07-08 23:29:08 +02:00
parent c3f4f5a180
commit 91bdd23a72
12 changed files with 670 additions and 86 deletions

View File

@@ -47,6 +47,7 @@ extern GHashTable *accounts;
extern dc_account_t current_account;
extern dc_api_t api;
extern dc_loop_t loop;
extern char *ncdc_private_dir;
extern void *config;

View File

@@ -7,6 +7,7 @@ bool ncdc_cmd_login(ncdc_mainwindow_t n, size_t ac, wchar_t **av)
char *arg = NULL;
bool ret = false;
dc_account_t acc = NULL;
dc_gateway_t gw = NULL;
goto_if_true(ac <= 1, cleanup);
@@ -29,22 +30,22 @@ bool ncdc_cmd_login(ncdc_mainwindow_t n, size_t ac, wchar_t **av)
}
}
if (!dc_api_authenticate(api, acc)) {
if (!dc_api_login(api, acc)) {
LOG(n, L"login: %ls: authentication failed; wrong password?", av[1]);
goto cleanup;
}
if (!dc_api_get_userinfo(api, acc, acc)) {
LOG(n, L"login: %ls: failed to get basic user information", av[1]);
gw = dc_api_establish_gateway(api, acc);
if (gw == NULL) {
LOG(n, L"login: %ls: failed to establish gateway", av[1]);
goto cleanup;
}
if (!dc_api_get_friends(api, acc)) {
LOG(n, L"login: %ls: failed to load friends", av[1]);
goto cleanup;
}
dc_loop_add_gateway(loop, gw);
dc_unref(current_account);
current_account = dc_ref(acc);
LOG(n, L"login: %ls: authentication successful", av[1]);
ret = true;