set the 'from' address in outbound jabber messages
authorerickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Wed, 29 Jul 2009 13:23:55 +0000 (13:23 +0000)
committererickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Wed, 29 Jul 2009 13:23:55 +0000 (13:23 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1731 9efc2488-bf62-4759-914b-345cdb29e865

include/opensrf/transport_client.h
src/libopensrf/transport_client.c

index 2bd7605..d7dffb9 100644 (file)
@@ -20,6 +20,8 @@ struct transport_client_struct {
        transport_message* msg_q_tail;
        transport_session* session;
        int error;
+    char* host;
+    char* xmpp_id;
 };
 typedef struct transport_client_struct transport_client;
 
index be83eb7..1d9f7fe 100644 (file)
@@ -62,6 +62,7 @@ transport_client* client_init( const char* server, int port, const char* unix_pa
 
        client->session->message_callback = client_message_handler;
        client->error = 0;
+    client->host = strdup(server);
 
        return client;
 }
@@ -71,6 +72,7 @@ int client_connect( transport_client* client,
                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_connected( const transport_client* client ) {
 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 @@ int client_free( transport_client* client ){
                current = next;
        }
 
+    free(client->host);
+    free(client->xmpp_id);
        free( client );
        return 1;
 }