changeset 1578:5bb4b580f229

Merge main and crew
author Mikael Berthe <mikael@lilotux.net>
date Mon, 13 Apr 2009 01:16:23 +0200
parents ece4f26bf9ff (current diff) e1a642472f4e (diff)
children a2dd83167bc9
files mcabber/src/jabglue.c
diffstat 3 files changed, 30 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/src/jab_iq.c	Mon Apr 13 00:26:56 2009 +0200
+++ b/mcabber/src/jab_iq.c	Mon Apr 13 01:16:23 2009 +0200
@@ -1190,10 +1190,10 @@
     // I do not think this is useful, user should not have to care of the
     // priority like gossip and gajim do (misc)
     y = xmlnode_insert_tag(x, "field");
-    xmlnode_put_attrib(y, "type", "text-multi");
+    xmlnode_put_attrib(y, "type", "text-single");
     xmlnode_put_attrib(y, "var", "status-message");
     xmlnode_put_attrib(y, "label", "Message");
-  } else if (!strcmp(action, "cancel")) {
+  } else if (action && !strcmp(action, "cancel")) {
     xmlnode_put_attrib(command, "status", "canceled");
   } else  { // (if sessionid and not canceled)
     y = xmlnode_get_tag(x, "x?xmlns=jabber:x:data");
@@ -1203,16 +1203,18 @@
                                    "value");
       message = xmlnode_get_tag_data(xmlnode_get_tag(y,
                                    "field?var=status-message"), "value");
-      for (s = adhoc_status_list; !s->name || strcmp(s->name, value); s++);
-      if (s->name) {
-        char *status = g_strdup_printf("%s %s", s->status,
-                                       message ? message : "");
-        cmd_setstatus(NULL, status);
-        g_free(status);
-        xmlnode_put_attrib(command, "status", "completed");
-        xmlnode_put_attrib(iq, "type", "result");
-        xmlnode_insert_dataform_result_message(command,
-                                               "Status has been changed");
+      if (value) {
+        for (s = adhoc_status_list; s->name && strcmp(s->name, value); s++);
+        if (s->name) {
+          char *status = g_strdup_printf("%s %s", s->status,
+                                         message ? message : "");
+          cmd_setstatus(NULL, status);
+          g_free(status);
+          xmlnode_put_attrib(command, "status", "completed");
+          xmlnode_put_attrib(iq, "type", "result");
+          xmlnode_insert_dataform_result_message(command,
+                                                 "Status has been changed");
+        }
       }
     }
   }
@@ -1295,7 +1297,7 @@
     xmlnode_insert_tag(field, "required");
 
     foreach_buddy(ROSTER_TYPE_ROOM, &_callback_foreach_buddy_groupchat, &field);
-  } else if (!strcmp(action, "cancel")) {
+  } else if (action && !strcmp(action, "cancel")) {
     xmlnode_put_attrib(command, "status", "canceled");
   } else  { // (if sessionid and not canceled)
     xmlnode form = xmlnode_get_tag(x, "x?xmlns=jabber:x:data");
--- a/mcabber/src/jabglue.c	Mon Apr 13 00:26:56 2009 +0200
+++ b/mcabber/src/jabglue.c	Mon Apr 13 01:16:23 2009 +0200
@@ -1813,7 +1813,6 @@
 #ifdef HAVE_LIBOTR
   if (otr_enabled()) {
     decrypted_otr = (char*)body;
-    mc_strtolower(bjid);
     otr_msg = otr_receive(&decrypted_otr, bjid, &free_msg);
     if (!decrypted_otr) {
       goto gotmessage_return;
--- a/mcabber/src/otr.c	Mon Apr 13 00:26:56 2009 +0200
+++ b/mcabber/src/otr.c	Mon Apr 13 01:16:23 2009 +0200
@@ -34,6 +34,7 @@
 #include "settings.h"
 #include "nohtml.h"
 
+#define OTR_PROTOCOL_NAME "jabber"
 
 static OtrlUserState userstate = NULL;
 static char * account = NULL;
@@ -128,7 +129,7 @@
 
   OTRL_INIT;
 
-  userstate = otrl_userstate_create ();
+  userstate = otrl_userstate_create();
 
   root = otr_get_dir();
   account = jidtodisp(fjid);
@@ -138,7 +139,7 @@
 
   if (otrl_privkey_read(userstate, keyfile)){
     scr_LogPrint(LPRINT_LOGNORM, "Could not read OTR key from %s", keyfile);
-    cb_create_privkey(NULL, account, "jabber");
+    cb_create_privkey(NULL, account, OTR_PROTOCOL_NAME);
   }
   if (otrl_privkey_read_fingerprints(userstate, fprfile, NULL, NULL)){
     scr_LogPrint(LPRINT_LOGNORM, "Could not read OTR fingerprints from %s",
@@ -204,8 +205,8 @@
   char * lowcasebuddy = g_strdup(buddy);
 
   mc_strtolower(lowcasebuddy);
-  ctx = otrl_context_find(userstate, lowcasebuddy, account, "jabber", 1, &null,
-                          NULL, NULL);
+  ctx = otrl_context_find(userstate, lowcasebuddy, account, OTR_PROTOCOL_NAME,
+                          1, &null, NULL, NULL);
   g_free(lowcasebuddy);
   return ctx;
 }
@@ -365,18 +366,20 @@
   OtrlTLV *tlv = NULL;
   ConnContext * ctx;
 
+  ctx = otr_get_context(buddy);
   *free_msg = 0;
-  ignore_message = otrl_message_receiving(userstate, &ops, NULL, account,
-    "jabber", buddy, *otr_data, &newmessage, &tlvs, NULL, NULL);
+  ignore_message = otrl_message_receiving(userstate, &ops, NULL,
+                                          ctx->accountname, ctx->protocol,
+                                          ctx->username, *otr_data,
+                                          &newmessage, &tlvs,NULL, NULL);
 
-  ctx = otr_get_context(buddy);
 
   tlv = otrl_tlv_find(tlvs, OTRL_TLV_DISCONNECTED);
   if (tlv) {
     /* Notify the user that the other side disconnected. */
     if (ctx) {
       cb_gone_insecure(NULL, ctx);
-      otr_disconnect(buddy);
+      otr_disconnect(ctx->username);
     }
   }
 
@@ -407,8 +410,9 @@
 
   htmlmsg = html_escape(*msg);
 
-  err = otrl_message_sending(userstate, &ops, NULL, account, "jabber", buddy,
-                             htmlmsg, NULL, &newmessage, NULL, NULL);
+  err = otrl_message_sending(userstate, &ops, NULL, ctx->accountname,
+                             ctx->protocol, ctx->username, htmlmsg, NULL,
+                             &newmessage, NULL, NULL);
 
   g_free(htmlmsg);
 
@@ -430,7 +434,7 @@
 {
   const char *state, *auth, *policy;
   ConnContext * ctx = otr_get_context(buddy);
-  OtrlPolicy p = cb_policy (ctx->app_data, ctx);
+  OtrlPolicy p = cb_policy(ctx->app_data, ctx);
 
   if (!userstate || !ctx)
     return;