Skip to content

Commit

Permalink
Update to unify callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
olabini committed Oct 15, 2018
1 parent d284849 commit cc2af0c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 32 deletions.
2 changes: 1 addition & 1 deletion gtk-ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ static void generate(GtkWidget *widget, gpointer data) {
}

// Do we actually have to create both keys at the same time?
long_term_keys_create_privkey_v4(purple_account_to_client_id(account));
long_term_keys_create_privkey_v4(purple_account_to_otrng_client(account));
long_term_keys_create_private_key_v3(purple_account_to_otrng_client(account));
}

Expand Down
10 changes: 5 additions & 5 deletions long_term_keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,24 @@
extern otrng_global_state_s *otrng_state;

/* Generate a private key for the given accountname/protocol */
void long_term_keys_create_privkey_v4(const otrng_client_id_s opdata) {
PurpleAccount *account = client_id_to_purple_account(opdata);
void long_term_keys_create_privkey_v4(otrng_client_s *client) {
PurpleAccount *account = client_id_to_purple_account(client->client_id);
if (otrng_succeeded(otrng_global_state_generate_private_key(
otrng_state, purple_account_to_client_id(account)))) {
otrng_ui_update_fingerprint();
}
}

static void load_private_key_v4(const otrng_client_id_s opdata) {
static void load_private_key_v4(otrng_client_s *client) {
persistance_read_private_keys_v4(otrng_state);
}

static void store_private_key_v4(otrng_client_s *client) {
persistance_write_privkey_v4_FILEp(otrng_state);
}

static void create_forging_key(const otrng_client_id_s opdata) {
otrng_global_state_generate_forging_key(otrng_state, opdata);
static void create_forging_key(otrng_client_s *client) {
otrng_global_state_generate_forging_key(otrng_state, client->client_id);
}

static void load_forging_key(struct otrng_client_s *client) {
Expand Down
4 changes: 2 additions & 2 deletions long_term_keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
#include <libotr-ng/client_callbacks.h>
#include <libotr-ng/messaging.h>

void long_term_keys_load_private_key_v4(const otrng_client_id_s opdata);
void long_term_keys_load_private_key_v4(otrng_client_s *client);

void long_term_keys_create_privkey_v4(const otrng_client_id_s opdata);
void long_term_keys_create_privkey_v4(otrng_client_s *client);

void long_term_keys_set_callbacks(otrng_client_callbacks_s *);

Expand Down
14 changes: 2 additions & 12 deletions plugin-all.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ static void create_privkey_cb(void *opdata, const char *account_name,
// This should never happen, so make this an empty callback for now
}

static void create_instag_cb(const otrng_client_id_s opdata) {
otrng_plugin_create_instag(client_id_to_purple_account(opdata));
static void create_instag_cb(otrng_client_s *client) {
otrng_plugin_create_instag(client_id_to_purple_account(client->client_id));
}

static int is_logged_in_cb(void *opdata, const char *accountname,
Expand Down Expand Up @@ -1518,20 +1518,10 @@ get_shared_session_state_cb(const otrng_s *conv) {
};
}

static otrng_result
get_account_and_protocol_cb(char **account_name, char **protocol_name,
const otrng_client_id_s client_id) {
*account_name = g_strdup(client_id.account);
*protocol_name = g_strdup(client_id.protocol);

return OTRNG_SUCCESS;
}

static otrng_client_callbacks_s *otrng_plugin_client_callbacks_new(void) {
otrng_client_callbacks_s *cb =
otrng_xmalloc_z(sizeof(otrng_client_callbacks_s));

cb->get_account_and_protocol = get_account_and_protocol_cb;
cb->create_instag = create_instag_cb;
cb->gone_secure = gone_secure_v4;
cb->gone_insecure = gone_insecure_v4;
Expand Down
20 changes: 8 additions & 12 deletions profiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,27 @@

extern otrng_global_state_s *otrng_state;

static void create_client_profile(otrng_client_s *client,
const otrng_client_id_s opdata) {
otrng_global_state_generate_client_profile(otrng_state, opdata);
static void create_client_profile(otrng_client_s *client) {
otrng_global_state_generate_client_profile(otrng_state, client->client_id);
}

static void load_client_profile(const otrng_client_id_s client_opdata) {
static void load_client_profile(otrng_client_s *client) {
persistance_read_client_profile(otrng_state);
}

static void create_prekey_profile(otrng_client_s *client,
const otrng_client_id_s opdata) {
otrng_global_state_generate_prekey_profile(otrng_state, opdata);
static void create_prekey_profile(otrng_client_s *client) {
otrng_global_state_generate_prekey_profile(otrng_state, client->client_id);
}

static void load_prekey_profile(const otrng_client_id_s client_opdata) {
static void load_prekey_profile(otrng_client_s *client) {
persistance_read_prekey_profile(otrng_state);
}

static void store_client_profile(otrng_client_s *client,
const otrng_client_id_s client_opdata) {
static void store_client_profile(otrng_client_s *client) {
persistance_write_client_profile_FILEp(otrng_state);
}

static void store_prekey_profile(otrng_client_s *client,
const otrng_client_id_s client_opdata) {
static void store_prekey_profile(otrng_client_s *client) {
persistance_write_prekey_profile_FILEp(otrng_state);
}

Expand Down

0 comments on commit cc2af0c

Please sign in to comment.