changeset 2347:db8de1b464d3 default tip

Reordered some lines of code for clarity
author franky
date Sat, 18 May 2019 20:41:52 +0200
parents 7921c8d671c8
children
files mcabber/mcabber/xmpp.c mcabber/mcabber/xmpp_iq.c mcabber/mcabber/xmpp_muc.c
diffstat 3 files changed, 7 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/mcabber/xmpp.c	Tue May 14 22:19:33 2019 +0200
+++ b/mcabber/mcabber/xmpp.c	Sat May 18 20:41:52 2019 +0200
@@ -1385,9 +1385,6 @@
   LmMessageNode *muc_packet, *caps;
   LmMessageSubType mstype = lm_message_get_sub_type(m);
 
-  // Check for MUC presence packet
-  muc_packet = lm_message_node_find_xmlns(m->node, NS_MUC_USER);
-
   from = lm_message_get_from(m);
   if (!from) {
     scr_LogPrint(LPRINT_LOGNORM, "Unexpected presence packet!");
@@ -1400,8 +1397,6 @@
     return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
   }
 
-  rname = jid_get_resource_name(from);
-
   if (settings_opt_get_int("ignore_self_presence")) {
     const char *self_fjid = lm_connection_get_jid(connection);
     if (self_fjid && !strcasecmp(self_fjid, from)) {
@@ -1464,6 +1459,9 @@
 
   // Timestamp?
   timestamp = lm_message_node_get_timestamp(m->node);
+  // Check for MUC presence packet
+  muc_packet = lm_message_node_find_xmlns(m->node, NS_MUC_USER);
+  rname = jid_get_resource_name(from);
 
   if (muc_packet) {
     // This is a MUC presence message
@@ -1596,8 +1594,7 @@
   const char *msg = lm_message_node_get_child_value(m->node, "status");
 
   if (mstype == LM_MESSAGE_SUB_TYPE_ERROR) {
-    display_server_error(lm_message_node_get_child(m->node, "error"),
-                         lm_message_get_from(m));
+    display_server_error(lm_message_node_get_child(m->node, "error"), from);
     return LM_HANDLER_RESULT_REMOVE_MESSAGE;
   }
 
--- a/mcabber/mcabber/xmpp_iq.c	Tue May 14 22:19:33 2019 +0200
+++ b/mcabber/mcabber/xmpp_iq.c	Sat May 18 20:41:52 2019 +0200
@@ -739,7 +739,6 @@
   }
 
   r = lm_message_new_iq_from_query(m, LM_MESSAGE_SUB_TYPE_RESULT);
-
   query = lm_message_node_add_child(r->node, "query", NULL);
   lm_message_node_set_attribute(query, "xmlns", NS_VERSION);
 
@@ -778,8 +777,6 @@
   time_t now_t;
   struct tm *now;
 
-  time(&now_t);
-
   if (!settings_opt_get_int("iq_hide_requests")) {
     scr_LogPrint(LPRINT_LOGNORM, "Received an IQ time request from <%s>",
                  lm_message_get_from(m));
@@ -796,6 +793,7 @@
   query = lm_message_node_add_child(r->node, "query", NULL);
   lm_message_node_set_attribute(query, "xmlns", NS_TIME);
 
+  time(&now_t);
   now = gmtime(&now_t);
 
   strftime(buf, 512, "%Y%m%dT%T", now);
@@ -833,8 +831,6 @@
   char const *sign;
   int diff = 0;
 
-  time(&now_t);
-
   if (!settings_opt_get_int("iq_hide_requests")) {
     scr_LogPrint(LPRINT_LOGNORM, "Received an IQ time request from <%s>",
                  lm_message_get_from(m));
@@ -851,6 +847,7 @@
   query = lm_message_node_add_child(r->node, "time", NULL);
   lm_message_node_set_attribute(query, "xmlns", NS_XMPP_TIME);
 
+  time(&now_t);
   now = localtime(&now_t);
 
   if (now->tm_isdst >= 0) {
--- a/mcabber/mcabber/xmpp_muc.c	Tue May 14 22:19:33 2019 +0200
+++ b/mcabber/mcabber/xmpp_muc.c	Sat May 18 20:41:52 2019 +0200
@@ -122,9 +122,8 @@
   gchar *roomid;
   GSList *room_elt;
 
-  if (!xmpp_is_online() || !room)
+  if (!xmpp_is_online() || !room || !nickname)
     return;
-  if (!nickname)        return;
 
   roomid = g_strdup_printf("%s/%s", room, nickname);
   if (check_jid_syntax(roomid)) {