[Opensrf-commits] r1861 - in branches/rel_1_2: include/opensrf src/libopensrf src/perl/lib/OpenSRF/Transport/SlimJabber (dbs)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Nov 20 15:56:30 EST 2009
Author: dbs
Date: 2009-11-20 15:56:25 -0500 (Fri, 20 Nov 2009)
New Revision: 1861
Modified:
branches/rel_1_2/include/opensrf/transport_client.h
branches/rel_1_2/src/libopensrf/transport_client.c
branches/rel_1_2/src/perl/lib/OpenSRF/Transport/SlimJabber/Client.pm
Log:
Merge Bill Erickson's fixes (r1730, r1731) from trunk for recent versions of ejabberd
Set the 'from' address in outbound xmpp messages
Modified: branches/rel_1_2/include/opensrf/transport_client.h
===================================================================
--- branches/rel_1_2/include/opensrf/transport_client.h 2009-11-20 20:46:51 UTC (rev 1860)
+++ branches/rel_1_2/include/opensrf/transport_client.h 2009-11-20 20:56:25 UTC (rev 1861)
@@ -20,6 +20,8 @@
transport_message* msg_q_tail;
transport_session* session;
int error;
+ char* host;
+ char* xmpp_id;
};
typedef struct transport_client_struct transport_client;
Modified: branches/rel_1_2/src/libopensrf/transport_client.c
===================================================================
--- branches/rel_1_2/src/libopensrf/transport_client.c 2009-11-20 20:46:51 UTC (rev 1860)
+++ branches/rel_1_2/src/libopensrf/transport_client.c 2009-11-20 20:56:25 UTC (rev 1861)
@@ -62,6 +62,7 @@
client->session->message_callback = client_message_handler;
client->error = 0;
+ client->host = strdup(server);
return client;
}
@@ -71,6 +72,7 @@
const char* username, const char* password, const char* resource,
int connect_timeout, enum TRANSPORT_AUTH_TYPE auth_type ) {
if(client == NULL) return 0;
+ client->xmpp_id = va_list_to_string("%s@%s/%s", username, client->host, resource);
return session_connect( client->session, username,
password, resource, connect_timeout, auth_type );
}
@@ -89,6 +91,7 @@
int client_send_message( transport_client* client, transport_message* msg ) {
if(client == NULL) return 0;
if( client->error ) return -1;
+ msg->sender = strdup(client->xmpp_id); // free'd in message_free
return session_send_msg( client->session, msg );
}
@@ -186,6 +189,8 @@
current = next;
}
+ free(client->host);
+ free(client->xmpp_id);
free( client );
return 1;
}
Modified: branches/rel_1_2/src/perl/lib/OpenSRF/Transport/SlimJabber/Client.pm
===================================================================
--- branches/rel_1_2/src/perl/lib/OpenSRF/Transport/SlimJabber/Client.pm 2009-11-20 20:46:51 UTC (rev 1860)
+++ branches/rel_1_2/src/perl/lib/OpenSRF/Transport/SlimJabber/Client.pm 2009-11-20 20:56:25 UTC (rev 1861)
@@ -113,6 +113,7 @@
my $self = shift;
my $msg = OpenSRF::Transport::SlimJabber::XMPPMessage->new(@_);
$msg->osrf_xid($logger->get_osrf_xid);
+ $msg->from($self->xmpp_id);
$self->reader->send($msg->to_xml);
}
@@ -130,8 +131,6 @@
my $resource = $self->params->{resource};
my $password = $self->params->{password};
- my $jid = "$username\@$host/$resource";
-
my $conf = OpenSRF::Utils::Config->current;
my $tail = "_$$";
@@ -153,10 +152,19 @@
throw OpenSRF::EX::Jabber("Could not authenticate with Jabber server: $@")
unless ( $self->reader->connected );
+ $self->xmpp_id("$username\@$host/$resource");
return $self;
}
+# Our full login: username at host/resource
+sub xmpp_id {
+ my($self, $xmpp_id) = @_;
+ $self->{xmpp_id} = $xmpp_id if $xmpp_id;
+ return $self->{xmpp_id};
+}
+
+
=head2 construct
=cut
More information about the opensrf-commits
mailing list