Skip to content

Commit

Permalink
Closes connection when session is going to close
Browse files Browse the repository at this point in the history
- Get all OTR conversations and close each one
- Related to #65 and #69
  • Loading branch information
pedropalau committed Aug 14, 2019
1 parent 0145537 commit e2c5c4f
Showing 1 changed file with 29 additions and 17 deletions.
46 changes: 29 additions & 17 deletions gtk-dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,8 @@ static char *create_verify_fingerprint_label_v4(
p = purple_find_prpl(protocol);
proto_name = (p && p->info->name) ? p->info->name : _("Unknown");

otrng_fingerprint_hash_to_human(their_human_fprint, their_fprint->fp, sizeof(their_fprint->fp));
otrng_fingerprint_hash_to_human(their_human_fprint, their_fprint->fp,
sizeof(their_fprint->fp));

label_text = g_strdup_printf(_("Fingerprint for you, %s (%s):\n%s\n\n"
"Purported fingerprint for %s:\n%s\n"),
Expand Down Expand Up @@ -3075,23 +3076,34 @@ static gboolean check_incoming_instance_change(PurpleAccount *account,
return 0;
}

static void connection_signing_off_cb(PurpleConnection *gc) {
GList *convs = NULL;
PurpleConversation *conv;
otrng_conversation_s *otr_conv;
otrng_plugin_conversation *otr_plugin_conv;

for (convs = purple_get_conversations(); convs != NULL; convs = convs->next) {
conv = convs->data;
if (conv) {
otr_conv = purple_conversation_to_otrng_conversation(conv);
otr_plugin_conv = purple_conversation_to_plugin_conversation(conv);
if (otr_conv && otr_plugin_conv &&
otrng_conversation_is_encrypted(otr_conv)) {
otrng_ui_disconnect_connection(otr_plugin_conv);
otrng_plugin_conversation_free(otr_plugin_conv);
}
static void connection_signing_off_cb(PurpleConnection *conn) {
PurpleAccount *account;
otrng_client_s *client = NULL;
list_element_s *el = NULL;
otrng_conversation_s *otr_conv = NULL;
otrng_plugin_conversation *otr_plugin_conv = NULL;

account = purple_connection_get_account(conn);

if (!account) {
return;
}

client = purple_account_to_otrng_client(account);
if (!client) {
return;
}

for (el = client->conversations; el; el = el->next) {

This comment has been minimized.

Copy link
@claucece

claucece Aug 14, 2019

Member

This should also check if the conversation is encrypted.

This comment has been minimized.

Copy link
@pedropalau

pedropalau Aug 14, 2019

Author Member

Really? I thought that in this case they were already encrypted

This comment has been minimized.

Copy link
@claucece

claucece Aug 15, 2019

Member

Mmm.. I have to test this ;)

otr_conv = el->data;

otr_plugin_conv = otrng_plugin_conversation_new(otr_conv->conn);

This comment has been minimized.

Copy link
@claucece

claucece Aug 14, 2019

Member

Mmm.. why the new?

This comment has been minimized.

Copy link
@pedropalau

pedropalau Aug 14, 2019

Author Member

Good question, I did not find any function to get a plugin conversation from an OTR conversation.

This comment has been minimized.

Copy link
@claucece

claucece Aug 15, 2019

Member

Yeah, but this basically will create a new conversation if it does not find one. I'll search for the function.

if (!otr_conv) {
continue;
}

otrng_ui_disconnect_connection(otr_plugin_conv);
otrng_plugin_conversation_free(otr_plugin_conv);
}
}

Expand Down

0 comments on commit e2c5c4f

Please sign in to comment.