Files
lotherk 2f3511ebf2 dtchat: run the configured accounts as adapters in the UI
accounts_run.c loads accounts.json (id, protocol, label, adapter, settings, enabled) and secrets.json (per account id) and starts one DcAdapter per enabled account, pumping the DcLoop from an Xt timeout. Its events go into the model and the panel: state into the status line, conversation (direct/channel/group) and roster entries into the model (roster sets presence), messages into the transcript via dtchat_ui_message_added, presence/typing/errors into the status/dialog, request events into the existing request dialog with the answer routed to that adapter. The UI send hook resolves the selected account (dtchat_ui_current_account) or the account that owns the conversation and calls dc_adapter_send_text; dtchat_accounts_join/_typing expose join and XEP-0085 for menus and tests. Normal GUI runs (not --demo/--local/--perf/--smoke) start with an empty model and the configured accounts; the demo peers are gone in that mode. dtchat-irc is installed next to dtchat and listed in the PLIST; dtchat-xmpp and the demo adapter remain build artifacts. Verified with the fake adapter under Xvfb (accounts fake: starting/online/sent alice/message alice), including the real UI send path (DTCHAT_TEST_UI_SEND), screenshot build/mcde-shots/dtchat-accounts.png; --smoke-test still passes.
2026-11-17 10:22:27 +00:00

41 lines
1.4 KiB
C

/*
* accounts_run.h -- the configured accounts, each as its adapter process
*
* License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
*/
#ifndef _Dtchat_accounts_run_h
#define _Dtchat_accounts_run_h
#include <X11/Intrinsic.h>
#include "dc_internal.h"
#include "ui_main.h"
typedef struct DtAccounts DtAccounts;
/*
* Start one adapter per enabled account in accounts.json (CONFIG_DIR, or
* ~/.dt/dtchat when NULL). An account names its "adapter" (absolute, or
* relative to ADAPTER_DIR), "protocol", "label" and "settings"; the secrets
* come from secrets.json under the same id. Events are routed into MODEL
* and the UI, and the send hook of the UI goes through the adapter of the
* selected account.
*/
DtAccounts *dtchat_accounts_start(Widget shell, DtChatUi *ui, DcModel *model,
const char *config_dir, const char *adapter_dir);
void dtchat_accounts_stop(DtAccounts *accounts);
size_t dtchat_accounts_count(const DtAccounts *accounts);
int dtchat_accounts_online(const DtAccounts *accounts);
/* the explicit calls behind the UI hooks, for a caller that knows the
* account (a menu, a test) */
int dtchat_accounts_send(DtAccounts *accounts, const char *account,
const char *conv, const char *text);
int dtchat_accounts_join(DtAccounts *accounts, const char *account,
const char *conv);
int dtchat_accounts_typing(DtAccounts *accounts, const char *account,
const char *conv, int on);
#endif /* _Dtchat_accounts_run_h */