The SSH host key has changed on 8 April, 2022 to this one: SHA256:573uTBSeh74kvOo0HJXi5ijdzRm8me27suzNEDlGyrQ

wip: automatically calculate request id, start implementing whoami

initial-version
Gergely Polonkai 4 years ago
parent 373d9ace84
commit 80178d5406
  1. 31
      ssb-gtk/sbot.c
  2. 1
      ssb-gtk/sbot.h

@ -26,6 +26,7 @@ struct _SsbScuttler {
gboolean wrote_goodbye;
GSocketClient *socket_client;
GSocketConnection *connection;
guint request_id;
};
typedef enum {
@ -816,11 +817,11 @@ ssb_scuttler_muxrpc_call(SsbScuttler *scuttler,
const gchar *argument,
SsbRPCType type,
const gchar *typestr,
int req_id,
GError **error)
{
gchar *request;
gsize request_len;
gint req_id;
gboolean is_request = (type == SSB_RPC_ASYNC);
JsonObject *req_object = json_object_new();
JsonNode *req_node = json_node_new(JSON_NODE_OBJECT);
@ -843,6 +844,8 @@ ssb_scuttler_muxrpc_call(SsbScuttler *scuttler,
return;
}
req_id = g_atomic_int_add(&(scuttler->request_id), 1);
if (!ssb_scuttler_send_packet(scuttler, SSB_PACKET_TYPE_JSON, request, request_len, req_id, !is_request, FALSE, &err)) {
g_propagate_error(error, err);
@ -939,6 +942,31 @@ ssb_scuttler_class_init(SsbScuttlerClass *klass)
g_object_class_install_properties(gobject_class, PROP_COUNT, ssb_scuttler_properties);
}
void
ssb_scuttler_whoami_async(SsbScuttler *scuttler,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GTask *task;
GError *err = NULL;
g_return_if_fail(SSB_IS_SCUTTLER(scuttler));
g_return_if_fail((cancellable == NULL) || G_IS_CANCELLABLE(cancellable));
task = g_task_new(scuttler, cancellable, callback, user_data);
if (!scuttler->connection) {
g_task_return_new_error(task, SSB_SCUTTLER_ERROR, SSB_SCUTTLER_ERROR_NOTCONNECTED, "Scuttler is not connected");
g_object_unref(task);
return;
}
ssb_scuttler_muxrpc_call(scuttler, "whoami", NULL, SSB_RPC_ASYNC, NULL, &err);
}
static void
ssb_scuttler_init(SsbScuttler *scuttler)
{
@ -949,6 +977,7 @@ ssb_scuttler_init(SsbScuttler *scuttler)
scuttler->app_key = NULL;
scuttler->private_key = NULL;
scuttler->encrypt_key = NULL;
scuttler->request_id = 0;
}
SsbScuttler *

@ -14,6 +14,7 @@ typedef enum {
SSB_SCUTTLER_ERROR_AUTH,
SSB_SCUTTLER_ERROR_REQUEST_TOO_LARGE,
SSB_SCUTTLER_ERROR_SEND,
SSB_SCUTTLER_ERROR_NOTCONNECTED,
} SsbScuttlerError;
G_BEGIN_DECLS

Loading…
Cancel
Save