Move all the way to a subelement user/miker/lp-1703411-xmpp-opensrf-message-subelement
authorMike Rylander <mrylander@gmail.com>
Thu, 6 Sep 2018 17:53:51 +0000 (13:53 -0400)
committerMike Rylander <mrylander@gmail.com>
Thu, 6 Sep 2018 17:53:51 +0000 (13:53 -0400)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
src/libopensrf/transport_message.c
src/libopensrf/transport_session.c
src/perl/lib/OpenSRF/Transport/SlimJabber/XMPPMessage.pm
src/perl/lib/OpenSRF/Transport/SlimJabber/XMPPReader.pm

index 40217d2..f95debc 100644 (file)
@@ -396,11 +396,6 @@ int message_prepare_xml( transport_message* msg ) {
        /* set from and to */
        xmlNewProp( message_node, BAD_CAST "to", BAD_CAST msg->recipient );
        xmlNewProp( message_node, BAD_CAST "from", BAD_CAST msg->sender );
-       xmlNewProp( message_node, BAD_CAST "router_from", BAD_CAST msg->router_from );
-       xmlNewProp( message_node, BAD_CAST "router_to", BAD_CAST msg->router_to );
-       xmlNewProp( message_node, BAD_CAST "router_class", BAD_CAST msg->router_class );
-       xmlNewProp( message_node, BAD_CAST "router_command", BAD_CAST msg->router_command );
-       xmlNewProp( message_node, BAD_CAST "osrf_xid", BAD_CAST msg->osrf_xid );
 
        /* set from and to on a new node, also */
        opensrf_node = xmlNewChild(message_node, NULL, (xmlChar*) "opensrf", NULL );
@@ -413,7 +408,6 @@ int message_prepare_xml( transport_message* msg ) {
        xmlAddChild(message_node, opensrf_node);
 
        if( msg->broadcast ) {
-               xmlNewProp( message_node, BAD_CAST "broadcast", BAD_CAST "1" );
                xmlNewProp( opensrf_node, BAD_CAST "broadcast", BAD_CAST "1" );
        }
 
index 99b1a3f..7ea15d5 100644 (file)
@@ -573,14 +573,6 @@ static void startElementHandler(
                ses->state_machine->in_message = 1;
                buffer_add( ses->from_buffer, get_xml_attr( atts, "from" ) );
                buffer_add( ses->recipient_buffer, get_xml_attr( atts, "to" ) );
-               buffer_add( ses->router_from_buffer, get_xml_attr( atts, "router_from" ) );
-               buffer_add( ses->osrf_xid_buffer, get_xml_attr( atts, "osrf_xid" ) );
-               buffer_add( ses->router_to_buffer, get_xml_attr( atts, "router_to" ) );
-               buffer_add( ses->router_class_buffer, get_xml_attr( atts, "router_class" ) );
-               buffer_add( ses->router_command_buffer, get_xml_attr( atts, "router_command" ) );
-               const char* broadcast = get_xml_attr( atts, "broadcast" );
-               if( broadcast )
-                       ses->router_broadcast = atoi( broadcast );
 
                return;
        }
index cc10054..44e2040 100644 (file)
@@ -6,7 +6,7 @@ use strict; use warnings;
 use XML::LibXML;
 
 use constant JABBER_MESSAGE =>
-    "<message to='%s' from='%s router_command='%s' router_class='%s' osrf_xid='%s''>".
+    "<message to='%s' from='%s>".
     "<opensrf router_command='%s' router_class='%s' osrf_xid='%s'/>".
     "<thread>%s</thread><body>%s</body></message>";
 
@@ -100,11 +100,6 @@ sub to_xml {
         JABBER_MESSAGE,
         $self->{to},
         $self->{from},
-        # once on <message>
-        $self->{router_command},
-        $self->{router_class},
-        $self->{osrf_xid},
-        # and again on <opensrf/>
         $self->{router_command},
         $self->{router_class},
         $self->{osrf_xid},
@@ -131,17 +126,13 @@ sub parse_xml {
     $self->{body} = $root->findnodes('/message/body').'';
     $self->{thread} = $root->findnodes('/message/thread').'';
 
-    $self->{from} = $root->getAttribute('router_from');
-    $self->{from} = $osrf_node->getAttribute('router_from') if $osrf_node;
+    $self->{from} = $osrf_node->getAttribute('router_from');
     $self->{from} = $root->getAttribute('from') unless $self->{from};
 
     $self->{to} = $root->getAttribute('to');
 
-    $self->{type} = $root->getAttribute('type');
-    $self->{osrf_xid} = $root->getAttribute('osrf_xid');
-
-    $self->{type} = $osrf_node->getAttribute('type') if $osrf_node;
-    $self->{osrf_xid} = $osrf_node->getAttribute('osrf_xid') if $osrf_node;
+    $self->{type} = $osrf_node->getAttribute('type');
+    $self->{osrf_xid} = $osrf_node->getAttribute('osrf_xid');
 }
 
 
index c68b8bc..737cf96 100644 (file)
@@ -306,18 +306,15 @@ sub start_element {
 
         my $msg = $self->{message};
         $msg->{to} = $attrs{'to'};
-        $msg->{from} = $attrs{router_from} if $attrs{router_from};
-        $msg->{from} = $attrs{from} unless $msg->{from};
-        $msg->{osrf_xid} = $attrs{'osrf_xid'};
-        $msg->{type} = $attrs{type};
+        $msg->{from} = $attrs{from};
 
     } elsif($name eq 'opensrf') {
 
         # These will be authoritative if they exist
         my $msg = $self->{message};
-        $msg->{from} = $attrs{router_from} if $attrs{router_from};
-        $msg->{osrf_xid} = $attrs{'osrf_xid'} if $attrs{'osrf_xid'};
-        $msg->{type} = $attrs{type} if $attrs{type};
+        $msg->{from} = $attrs{router_from};
+        $msg->{osrf_xid} = $attrs{'osrf_xid'};
+        $msg->{type} = $attrs{type};
 
     } elsif($name eq 'body') {
         $self->{xml_state} = IN_BODY;