[pkg-otr-team] [irssi-plugin-otr] 09/167: * Conform to the new libotr API.

Holger Levsen holger at moszumanska.debian.org
Mon Mar 3 21:55:28 UTC 2014


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to tag 4.0.0
in repository irssi-plugin-otr.

commit 90a50ff1dd4a4418a827e1acb9235b336ee26788
Author: cypherpunk <cypherpunk>
Date:   Sun Oct 16 15:59:34 2005 +0000

    	* Conform to the new libotr API.
---
 ChangeLog    |   4 +++
 NEWS         |  10 ++++--
 dialogs.c    |  26 ++++++++------
 dialogs.h    |  26 ++++++++------
 gtk-dialog.c | 114 +++++++++++++++++++++++++++++++++++++++++++++++------------
 gtk-ui.c     |  56 ++++++++++++++++++-----------
 otr-plugin.c |  45 +++++++++++------------
 otr-plugin.h |   3 +-
 ui.c         |  16 +++++----
 ui.h         |   2 +-
 10 files changed, 205 insertions(+), 97 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 582bc20..1d5216e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2005-10-16
+
+	* Conform to the new libotr API.
+
 2005-08-04
 
 	* otr-plugin.c: Disconnect all contexts when gaim is about to
diff --git a/NEWS b/NEWS
index 4e1a54f..115fc52 100644
--- a/NEWS
+++ b/NEWS
@@ -1,11 +1,17 @@
-24 Jun 2005:
-- There are now three states a conversation can be in:
+16 Oct 2005:
+- There are now four states a conversation can be in:
     * Not Private (not using OTR)
     * Unverified (using OTR, but to a fingerprint that hasn't
 		  been verified, so you are subject to a straightforward
 		  active attack)
     * Private (using OTR with a verified fingerprint)
+    * Finished (the other person has ended his side of the OTR
+		conversation, so we won't send any more messages at all
+		until we either end our side, or start a new OTR
+		conversatrion)
 - There are new icons for these states that appear in the OTR button.
+
+24 Jun 2005:
 - Right-clicking the OTR button now produces an OTR menu, with options
   to start or end the private conversation, verify the fingerprint, view
   the secure session id, or get help.
diff --git a/dialogs.c b/dialogs.c
index 0eebe41..a2eb25b 100644
--- a/dialogs.c
+++ b/dialogs.c
@@ -114,9 +114,9 @@ void otrg_dialog_private_key_wait_done(OtrgDialogWaitHandle handle)
 /* Show a dialog informing the user that a correspondent (who) has sent
  * us a Key Exchange Message (kem) that contains an unknown fingerprint. */
 void otrg_dialog_unknown_fingerprint(OtrlUserState us, const char *accountname,
-	const char *protocol, const char *who, OTRKeyExchangeMsg kem)
+	const char *protocol, const char *who, unsigned char fingerprint[20])
 {
-    ui_ops->unknown_fingerprint(us, accountname, protocol, who, kem);
+    ui_ops->unknown_fingerprint(us, accountname, protocol, who, fingerprint);
 }
 
 /* Show a dialog asking the user to verify the given fingerprint. */
@@ -125,15 +125,13 @@ void otrg_dialog_verify_fingerprint(Fingerprint *fprint)
     ui_ops->verify_fingerprint(fprint);
 }
 
-/* Call this when a context transitions from (a state other than
- * CONN_CONNECTED) to CONN_CONNECTED. */
-void otrg_dialog_connected(ConnContext *context)
+/* Call this when a context transitions to ENCRYPTED. */
+void otrg_dialog_connected(ConnContext *context, int protocol_version)
 {
-    ui_ops->connected(context);
+    ui_ops->connected(context, protocol_version);
 }
 
-/* Call this when a context transitions from CONN_CONNECTED to
- * (a state other than CONN_CONNECTED). */
+/* Call this when a context transitions to PLAINTEXT. */
 void otrg_dialog_disconnected(ConnContext *context)
 {
     ui_ops->disconnected(context);
@@ -141,9 +139,17 @@ void otrg_dialog_disconnected(ConnContext *context)
 
 /* Call this when we receive a Key Exchange message that doesn't cause
  * our state to change (because it was just the keys we knew already). */
-void otrg_dialog_stillconnected(ConnContext *context)
+void otrg_dialog_stillconnected(ConnContext *context, int protocol_version)
 {
-    ui_ops->stillconnected(context);
+    ui_ops->stillconnected(context, protocol_version);
+}
+
+/* Call this if the remote user terminates his end of an ENCRYPTED
+ * connection, and lets us know. */
+void otrg_dialog_finished(const char *accountname, const char *protocol,
+	const char *username)
+{
+    ui_ops->finished(accountname, protocol, username);
 }
 
 /* Set all OTR buttons to "sensitive" or "insensitive" as appropriate.
diff --git a/dialogs.h b/dialogs.h
index a335f10..02c0ea5 100644
--- a/dialogs.h
+++ b/dialogs.h
@@ -50,15 +50,18 @@ typedef struct {
     void (*private_key_wait_done)(OtrgDialogWaitHandle handle);
 
     void (*unknown_fingerprint)(OtrlUserState us, const char *accountname,
-	const char *protocol, const char *who, OTRKeyExchangeMsg kem);
+	const char *protocol, const char *who, unsigned char fingerprint[20]);
 
     void (*verify_fingerprint)(Fingerprint *fprint);
 
-    void (*connected)(ConnContext *context);
+    void (*connected)(ConnContext *context, int protocol_version);
 
     void (*disconnected)(ConnContext *context);
 
-    void (*stillconnected)(ConnContext *context);
+    void (*stillconnected)(ConnContext *context, int protocol_version);
+
+    void (*finished)(const char *accountname, const char *protocol,
+	    const char *username);
 
     void (*resensitize_all)(void);
 
@@ -113,22 +116,25 @@ void otrg_dialog_private_key_wait_done(OtrgDialogWaitHandle handle);
 /* Show a dialog informing the user that a correspondent (who) has sent
  * us a Key Exchange Message (kem) that contains an unknown fingerprint. */
 void otrg_dialog_unknown_fingerprint(OtrlUserState us, const char *accountname,
-	const char *protocol, const char *who, OTRKeyExchangeMsg kem);
+	const char *protocol, const char *who, unsigned char fingerprint[20]);
 
 /* Show a dialog asking the user to verify the given fingerprint. */
 void otrg_dialog_verify_fingerprint(Fingerprint *fprint);
 
-/* Call this when a context transitions from (a state other than
- * CONN_CONNECTED) to CONN_CONNECTED. */
-void otrg_dialog_connected(ConnContext *context);
+/* Call this when a context transitions to ENCRYPTED. */
+void otrg_dialog_connected(ConnContext *context, int protocol_version);
 
-/* Call this when a context transitions from CONN_CONNECTED to
- * (a state other than CONN_CONNECTED). */
+/* Call this when a context transitions to PLAINTEXT. */
 void otrg_dialog_disconnected(ConnContext *context);
 
 /* Call this when we receive a Key Exchange message that doesn't cause
  * our state to change (because it was just the keys we knew already). */
-void otrg_dialog_stillconnected(ConnContext *context);
+void otrg_dialog_stillconnected(ConnContext *context, int protocol_version);
+
+/* Call this if the remote user terminates his end of an ENCRYPTED
+ * connection, and lets us know. */
+void otrg_dialog_finished(const char *accountname, const char *protocol,
+	const char *username);
 
 /* Set all OTR buttons to "sensitive" or "insensitive" as appropriate.
  * Call this when accounts are logged in or out. */
diff --git a/gtk-dialog.c b/gtk-dialog.c
index b735dfd..0551505 100644
--- a/gtk-dialog.c
+++ b/gtk-dialog.c
@@ -138,6 +138,37 @@ static const char * private_xpm[] = {
 " .++++.               ",
 "  ....                "};
 
+static const char * finished_xpm[] = {
+"24 24 4 1",
+" 	c None",
+".	c #000000",
+"+	c #FF0000",
+"@	c #FFFFFF",
+"         ......         ",
+"      ...++++++...      ",
+"     .++++++++++++.     ",
+"    .++++++++++++++.    ",
+"   .++++++++++++++++.   ",
+"  .++++++++++++++++++.  ",
+" .++++++++++++++++++++. ",
+" .++++++++++++++++++++. ",
+" .++++++++++++++++++++. ",
+".++++++++++++++++++++++.",
+".++@@@@@@@@@@@@@@@@@@++.",
+".++@@@@@@@@@@@@@@@@@@++.",
+".++@@@@@@@@@@@@@@@@@@++.",
+".++@@@@@@@@@@@@@@@@@@++.",
+".++++++++++++++++++++++.",
+" .++++++++++++++++++++. ",
+" .++++++++++++++++++++. ",
+" .++++++++++++++++++++. ",
+"  .++++++++++++++++++.  ",
+"   .++++++++++++++++.   ",
+"    .++++++++++++++.    ",
+"     .++++++++++++.     ",
+"      ...++++++...      ",
+"         ......         "};
+
 static GtkWidget *otr_icon(GtkWidget *image, TrustLevel level)
 {
     GdkPixbuf *pixbuf = NULL;
@@ -153,6 +184,9 @@ static GtkWidget *otr_icon(GtkWidget *image, TrustLevel level)
 	case TRUST_PRIVATE:
 	    data = private_xpm;
 	    break;
+	case TRUST_FINISHED:
+	    data = finished_xpm;
+	    break;
     }
 
     pixbuf = gdk_pixbuf_new_from_xpm_data(data);
@@ -418,13 +452,13 @@ static void add_unk_fingerprint_expander(GtkWidget *vbox, void *data)
  * resp = -1. */
 static void otrg_gtk_dialog_unknown_fingerprint(OtrlUserState us,
 	const char *accountname, const char *protocol, const char *who,
-	OTRKeyExchangeMsg kem)
+	unsigned char fingerprint[20])
 {
     char hash[45];
     char *primary, *secondary;
     GaimPlugin *p = gaim_find_prpl(protocol);
     
-    otrl_privkey_hash_to_human(hash, kem->key_fingerprint);
+    otrl_privkey_hash_to_human(hash, fingerprint);
     primary = g_strdup_printf("%s (%s) has received an unknown fingerprint "
 	    "from %s:", accountname, 
 	    (p && p->info->name) ? p->info->name : "Unknown", who);
@@ -466,6 +500,7 @@ static void dialog_update_label_conv(GaimConversation *conv, TrustLevel level)
     /* Set the button's icon, label and tooltip. */
     otr_icon(icon, level);
     gtk_label_set_text(GTK_LABEL(label),
+	    level == TRUST_FINISHED ? "Finished" :
 	    level == TRUST_PRIVATE ? "Private" :
 	    level == TRUST_UNVERIFIED ? "Unverified" :
 	    "Not private");
@@ -546,19 +581,21 @@ static GtkWidget* otrg_gtk_dialog_view_sessionid(ConnContext *context)
 	    "established.", context->username);
     char *secondary;
     int i;
-    SessionDirection dir = context->sessiondir;
+    OtrlSessionIdHalf whichhalf = context->sessionid_half;
+    size_t idhalflen = (context->sessionid_len) / 2;
 
     /* Make a human-readable version of the sessionid (in two parts) */
     sessionid = context->sessionid;
-    for(i=0;i<10;++i) sprintf(sess1+(2*i), "%02x", sessionid[i]);
-    sess1[20] = '\0';
-    for(i=0;i<10;++i) sprintf(sess2+(2*i), "%02x", sessionid[i+10]);
-    sess2[20] = '\0';
+    for(i=0;i<idhalflen;++i) sprintf(sess1+(2*i), "%02x", sessionid[i]);
+    for(i=0;i<idhalflen;++i) sprintf(sess2+(2*i), "%02x",
+	    sessionid[i+idhalflen]);
     
     secondary = g_strdup_printf("Secure session id:\n"
 	    "<span %s>%s</span> <span %s>%s</span>\n",
-	    dir == SESS_DIR_LOW ? "weight=\"bold\"" : "", sess1,
-	    dir == SESS_DIR_HIGH ? "weight=\"bold\"" : "", sess2);
+	    whichhalf == OTRL_SESSIONID_FIRST_HALF_BOLD ?
+		    "weight=\"bold\"" : "", sess1,
+	    whichhalf == OTRL_SESSIONID_SECOND_HALF_BOLD ?
+		    "weight=\"bold\"" : "", sess2);
 
     dialog = create_dialog(GAIM_NOTIFY_MSG_INFO, "Private connection "
 	    "established", primary, secondary, 1, NULL,
@@ -735,9 +772,9 @@ static void otrg_gtk_dialog_verify_fingerprint(Fingerprint *fprint)
     g_free(secondary);
 }
 
-/* Call this when a context transitions from (a state other than
- * CONN_CONNECTED) to CONN_CONNECTED. */
-static void otrg_gtk_dialog_connected(ConnContext *context)
+/* Call this when a context transitions to ENCRYPTED. */
+static void otrg_gtk_dialog_connected(ConnContext *context,
+	int protocol_version)
 {
     GaimConversation *conv;
     char *buf;
@@ -746,14 +783,16 @@ static void otrg_gtk_dialog_connected(ConnContext *context)
     conv = otrg_plugin_context_to_conv(context, 1);
     level = otrg_plugin_context_to_trust(context);
 
-    buf = g_strdup_printf("%s conversation with %s started.",
+    buf = g_strdup_printf("%s conversation with %s started.%s",
 		level == TRUST_PRIVATE ? "Private" :
 		level == TRUST_UNVERIFIED ? "<a href=\"" UNVERIFIED_HELPURL
 			"\">Unverified</a>" :
 		    /* This last case should never happen, since we know
-		     * we're in CONN_CONNECTED. */
+		     * we're in ENCRYPTED. */
 		    "Not private",
-		gaim_conversation_get_name(conv));
+		gaim_conversation_get_name(conv),
+		protocol_version == 1 ? "  Warning: using old protocol "
+		    "version 1." : "");
 
     gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL));
     g_free(buf);
@@ -761,8 +800,7 @@ static void otrg_gtk_dialog_connected(ConnContext *context)
     dialog_update_label(context);
 }
 
-/* Call this when a context transitions from CONN_CONNECTED to
- * (a state other than CONN_CONNECTED). */
+/* Call this when a context transitions to PLAINTEXT. */
 static void otrg_gtk_dialog_disconnected(ConnContext *context)
 {
     GaimConversation *conv;
@@ -778,9 +816,34 @@ static void otrg_gtk_dialog_disconnected(ConnContext *context)
     dialog_update_label(context);
 }
 
+/* Call this if the remote user terminates his end of an ENCRYPTED
+ * connection, and lets us know. */
+static void otrg_gtk_dialog_finished(const char *accountname,
+	const char *protocol, const char *username)
+{
+    /* See if there's a conversation window we can put this in. */
+    GaimAccount *account;
+    GaimConversation *conv;
+    char *buf;
+
+    account = gaim_accounts_find(accountname, protocol);
+    if (!account) return;
+
+    conv = gaim_find_conversation_with_account(username, account);
+    if (!conv) return;
+
+    buf = g_strdup_printf("%s has ended his private conversation with you; "
+	    "you should do the same.", gaim_conversation_get_name(conv));
+    gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL));
+    g_free(buf);
+
+    dialog_update_label_conv(conv, TRUST_FINISHED);
+}
+
 /* Call this when we receive a Key Exchange message that doesn't cause
  * our state to change (because it was just the keys we knew already). */
-static void otrg_gtk_dialog_stillconnected(ConnContext *context)
+static void otrg_gtk_dialog_stillconnected(ConnContext *context,
+	int protocol_version)
 {
     GaimConversation *conv;
     char *buf;
@@ -790,14 +853,16 @@ static void otrg_gtk_dialog_stillconnected(ConnContext *context)
     level = otrg_plugin_context_to_trust(context);
 
     buf = g_strdup_printf("Successfully refreshed the %s conversation "
-		"with %s.",
+		"with %s.%s",
 		level == TRUST_PRIVATE ? "private" :
 		level == TRUST_UNVERIFIED ? "<a href=\"" UNVERIFIED_HELPURL
 			"\">unverified</a>" :
 		    /* This last case should never happen, since we know
-		     * we're in CONN_CONNECTED. */
+		     * we're in ENCRYPTED. */
 		    "not private",
-		gaim_conversation_get_name(conv));
+		gaim_conversation_get_name(conv),
+		protocol_version == 1 ? "  Warning: using old protocol "
+		    "version 1." : "");
 
     gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL));
     g_free(buf);
@@ -830,7 +895,8 @@ static void view_sessionid(GtkWidget *widget, gpointer data)
     GaimConversation *conv = data;
     ConnContext *context = otrg_plugin_conv_to_context(conv);
 
-    if (context == NULL || context->state != CONN_CONNECTED) return;
+    if (context == NULL || context->msgstate != OTRL_MSGSTATE_ENCRYPTED)
+	return;
 
     otrg_gtk_dialog_view_sessionid(context);
 }
@@ -840,7 +906,8 @@ static void verify_fingerprint(GtkWidget *widget, gpointer data)
     GaimConversation *conv = data;
     ConnContext *context = otrg_plugin_conv_to_context(conv);
 
-    if (context == NULL || context->state != CONN_CONNECTED) return;
+    if (context == NULL || context->msgstate != OTRL_MSGSTATE_ENCRYPTED)
+	return;
 
     otrg_gtk_dialog_verify_fingerprint(context->active_fingerprint);
 }
@@ -1084,6 +1151,7 @@ static const OtrgDialogUiOps gtk_dialog_ui_ops = {
     otrg_gtk_dialog_connected,
     otrg_gtk_dialog_disconnected,
     otrg_gtk_dialog_stillconnected,
+    otrg_gtk_dialog_finished,
     otrg_gtk_dialog_resensitize_all,
     otrg_gtk_dialog_new_conv,
     otrg_gtk_dialog_remove_conv
diff --git a/gtk-ui.c b/gtk-ui.c
index ea16d82..cae717e 100644
--- a/gtk-ui.c
+++ b/gtk-ui.c
@@ -58,6 +58,13 @@ static struct {
     struct otroptionsdata oo;
 } ui_layout;
 
+static const gchar *trust_states[] = {
+    "Not private",
+    "Unverified",
+    "Private",
+    "Finished"
+};
+
 static void account_menu_changed_cb(GtkWidget *item, GaimAccount *account,
 	void *data)
 {
@@ -170,12 +177,12 @@ static void otrg_gtk_ui_update_keylist(void)
 	 * fingerprints list */
 	while(fingerprint) {
 	    titles[0] = context->username;
-	    if (context->state == CONN_CONNECTED &&
+	    if (context->msgstate == OTRL_MSGSTATE_ENCRYPTED &&
 		    context->active_fingerprint != fingerprint) {
 		titles[1] = "Unused";
 	    } else {
-		titles[1] =
-		    (gchar *) otrl_context_statestr[context->state];
+		titles[1] = (gchar *)
+		    trust_states[otrg_plugin_context_to_trust(context)];
 	    }
 	    titles[2] = (fingerprint->trust && fingerprint->trust[0]) ?
 		"Yes" : "No";
@@ -246,21 +253,21 @@ static void clist_selected(GtkWidget *widget, gint row, gint column,
     int verify_sensitive = 0;
     Fingerprint *f = gtk_clist_get_row_data(GTK_CLIST(ui_layout.keylist),
 	    row);
-    if (f && f->context->state == CONN_CONNECTED &&
+    if (f && f->context->msgstate == OTRL_MSGSTATE_ENCRYPTED &&
 	    f->context->active_fingerprint == f) {
 	disconnect_sensitive = 1;
     }
-    if (f && f->context->state == CONN_SETUP) {
+    if (f && f->context->msgstate == OTRL_MSGSTATE_FINISHED) {
 	disconnect_sensitive = 1;
     }
-    if (f && f->context->state == CONN_CONNECTED &&
-	    f->context->active_fingerprint != f) {
+    if (f && (f->context->msgstate != OTRL_MSGSTATE_ENCRYPTED ||
+	    f->context->active_fingerprint != f)) {
 	forget_sensitive = 1;
     }
-    if (f && f->context->state == CONN_UNCONNECTED) {
-	forget_sensitive = 1;
+    if (f && f->context->msgstate == OTRL_MSGSTATE_PLAINTEXT) {
+	connect_sensitive = 1;
     }
-    if (f && f->context->state == CONN_UNCONNECTED) {
+    if (f && f->context->msgstate == OTRL_MSGSTATE_FINISHED) {
 	connect_sensitive = 1;
     }
     if (f) {
@@ -283,16 +290,23 @@ static void clist_unselected(GtkWidget *widget, gint row, gint column,
 
 static int fngsortval(Fingerprint *f)
 {
-    if (f->context->state == CONN_CONNECTED &&
-	    f->context->active_fingerprint == f) {
-	return 0;
-    } else if (f->context->state == CONN_SETUP) {
-	return 1;
-    } else if (f->context->state == CONN_UNCONNECTED) {
-	return 2;
-    } else {
-	return 3;
+    int is_active = (f->context->msgstate == OTRL_MSGSTATE_ENCRYPTED &&
+	    f->context->active_fingerprint == f);
+    TrustLevel level = otrg_plugin_context_to_trust(f->context);
+
+    switch(level) {
+	case TRUST_PRIVATE:
+	    return is_active ? 0 : 100;
+	case TRUST_UNVERIFIED:
+	    return is_active ? 1 : 100;
+	case TRUST_FINISHED:
+	    return 2;
+	case TRUST_NOT_PRIVATE:
+	    return 3;
     }
+
+    /* Shouldn't get here, but anyway. */
+    return 200;
 }
 
 static gint statuscmp(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2)
@@ -348,8 +362,8 @@ static void disconnect_connection(GtkWidget *widget, gpointer data)
     if (context == NULL) return;
 	
     /* Don't do anything with fingerprints other than the active one
-     * if we're in the CONNECTED state */
-    if (context->state == CONN_CONNECTED &&
+     * if we're in the ENCRYPTED state */
+    if (context->msgstate == OTRL_MSGSTATE_ENCRYPTED &&
 	    context->active_fingerprint != ui_layout.selected_fprint) {
 	return;
     }
diff --git a/otr-plugin.c b/otr-plugin.c
index 4e83b07..c44b8a3 100644
--- a/otr-plugin.c
+++ b/otr-plugin.c
@@ -211,9 +211,10 @@ static void update_context_list_cb(void *opdata)
 
 static void confirm_fingerprint_cb(void *opdata, OtrlUserState us,
 	const char *accountname, const char *protocol, const char *username,
-	OTRKeyExchangeMsg kem)
+	unsigned char fingerprint[20])
 {
-    otrg_dialog_unknown_fingerprint(us, accountname, protocol, username, kem);
+    otrg_dialog_unknown_fingerprint(us, accountname, protocol, username,
+	    fingerprint);
 }
 
 static void write_fingerprints_cb(void *opdata)
@@ -221,9 +222,10 @@ static void write_fingerprints_cb(void *opdata)
     otrg_plugin_write_fingerprints();
 }
 
-static void gone_secure_cb(void *opdata, ConnContext *context)
+static void gone_secure_cb(void *opdata, ConnContext *context,
+	int protocol_version)
 {
-    otrg_dialog_connected(context);
+    otrg_dialog_connected(context, protocol_version);
 }
 
 static void gone_insecure_cb(void *opdata, ConnContext *context)
@@ -231,10 +233,11 @@ static void gone_insecure_cb(void *opdata, ConnContext *context)
     otrg_dialog_disconnected(context);
 }
 
-static void still_secure_cb(void *opdata, ConnContext *context, int is_reply)
+static void still_secure_cb(void *opdata, ConnContext *context, int is_reply,
+	int protocol_version)
 {
     if (is_reply == 0) {
-	otrg_dialog_stillconnected(context);
+	otrg_dialog_stillconnected(context, protocol_version);
     }
 }
 
@@ -300,11 +303,13 @@ static void process_sending_im(GaimAccount *account, char *who, char **message,
  * context, from the given account.  [account is actually a
  * GaimAccount*, but it's declared here as void* so this can be passed
  * as a callback.] */
-void otrg_plugin_send_default_query(ConnContext *context, void *account)
+void otrg_plugin_send_default_query(ConnContext *context, void *vaccount)
 {
-    char *msg = otrl_proto_default_query_msg(context->accountname);
-    otrg_plugin_inject_message((GaimAccount *)account, context->username,
-	    msg ? msg : "?OTR?");
+    GaimAccount *account = vaccount;
+    char *msg = otrl_proto_default_query_msg(context->accountname,
+	    otrg_ui_find_policy(account, context->username));
+    otrg_plugin_inject_message(account, context->username,
+	    msg ? msg : "?OTRv2?");
     free(msg);
 }
 
@@ -320,8 +325,9 @@ void otrg_plugin_send_default_query_conv(GaimConversation *conv)
     accountname = gaim_account_get_username(account);
     username = gaim_conversation_get_name(conv);
     
-    msg = otrl_proto_default_query_msg(accountname);
-    otrg_plugin_inject_message(account, username, msg ? msg : "?OTR?");
+    msg = otrl_proto_default_query_msg(accountname,
+	    otrg_ui_find_policy(account, username));
+    otrg_plugin_inject_message(account, username, msg ? msg : "?OTRv2?");
     free(msg);
 }
 
@@ -360,15 +366,8 @@ static gboolean process_receiving_im(GaimAccount *account, char **who,
     tlv = otrl_tlv_find(tlvs, OTRL_TLV_DISCONNECTED);
     if (tlv) {
 	/* Notify the user that the other side disconnected. */
-
-	char *msg = g_strdup_printf("OTR: %s has closed his private "
-		"connection to you; you should do the same.", username);
-
-	if (msg) {
-	    otrg_dialog_display_otr_message(accountname, protocol,
-		    username, msg);
-	    g_free(msg);
-	}
+	otrg_dialog_finished(accountname, protocol, username);
+	otrg_ui_update_keylist();
     }
     
     otrl_tlv_free(tlvs);
@@ -498,13 +497,15 @@ TrustLevel otrg_plugin_context_to_trust(ConnContext *context)
 {
     TrustLevel level = TRUST_NOT_PRIVATE;
 
-    if (context && context->state == CONN_CONNECTED) {
+    if (context && context->msgstate == OTRL_MSGSTATE_ENCRYPTED) {
 	if (context->active_fingerprint->trust &&
 		context->active_fingerprint->trust[0] != '\0') {
 	    level = TRUST_PRIVATE;
 	} else {
 	    level = TRUST_UNVERIFIED;
 	}
+    } else if (context && context->msgstate == OTRL_MSGSTATE_FINISHED) {
+	level = TRUST_FINISHED;
     }
 
     return level;
diff --git a/otr-plugin.h b/otr-plugin.h
index 6ead10a..46733d3 100644
--- a/otr-plugin.h
+++ b/otr-plugin.h
@@ -72,7 +72,8 @@ GaimConversation *otrg_plugin_context_to_conv(ConnContext *context,
 typedef enum {
     TRUST_NOT_PRIVATE,
     TRUST_UNVERIFIED,
-    TRUST_PRIVATE
+    TRUST_PRIVATE,
+    TRUST_FINISHED
 } TrustLevel;
 
 /* What level of trust do we have in the privacy of this ConnContext? */
diff --git a/ui.c b/ui.c
index 34e898c..f12361e 100644
--- a/ui.c
+++ b/ui.c
@@ -72,8 +72,9 @@ void otrg_ui_connect_connection(ConnContext *context)
     GaimAccount *account;
     char *msg;
 	
-    /* Only do anything for UNCONNECTED fingerprints */
-    if (context == NULL || context->state != CONN_UNCONNECTED) return;
+    /* Don't do this if we're already ENCRYPTED */
+    if (context == NULL || context->msgstate == OTRL_MSGSTATE_ENCRYPTED)
+	return;
 	
     account = gaim_accounts_find(context->accountname, context->protocol);
     if (!account) {
@@ -89,11 +90,12 @@ void otrg_ui_connect_connection(ConnContext *context)
     otrg_plugin_send_default_query(context, account);	
 }
 
-/* Drop a context to UNCONNECTED state */
+/* Drop a context to PLAINTEXT state */
 void otrg_ui_disconnect_connection(ConnContext *context)
 {
-    /* Don't do anything with UNCONNECTED fingerprints */
-    if (context == NULL || context->state == CONN_UNCONNECTED) return;
+    /* Don't do anything with PLAINTEXT fingerprints */
+    if (context == NULL || context->msgstate == OTRL_MSGSTATE_PLAINTEXT)
+	return;
 		
     otrg_plugin_disconnect(context);
     otrg_dialog_disconnected(context);	
@@ -107,9 +109,9 @@ void otrg_ui_forget_fingerprint(Fingerprint *fingerprint)
     if (fingerprint == NULL) return;
 
     /* Don't do anything with the active fingerprint if we're in the
-     * CONNECTED state. */
+     * ENCRYPTED state. */
     context = fingerprint->context;
-    if (context->state == CONN_CONNECTED &&
+    if (context->msgstate == OTRL_MSGSTATE_ENCRYPTED &&
 	    context->active_fingerprint == fingerprint) return;
 	
     otrl_context_forget_fingerprint(fingerprint, 1);
diff --git a/ui.h b/ui.h
index 6ea7ce7..10896df 100644
--- a/ui.h
+++ b/ui.h
@@ -48,7 +48,7 @@ void otrg_ui_update_keylist(void);
 /* Send an OTR Query Message to attempt to start a connection */
 void otrg_ui_connect_connection(ConnContext *context);
 
-/* Drop a context to UNCONNECTED state */
+/* Drop a context to PLAINTEXT state */
 void otrg_ui_disconnect_connection(ConnContext *context);
 
 /* Forget a fingerprint */

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-otr/packages/irssi-plugin-otr.git



More information about the Pkg-otr-team mailing list