started work on xul-based requestor/recipient holds
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 8 Dec 2005 23:18:00 +0000 (23:18 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 8 Dec 2005 23:18:00 +0000 (23:18 +0000)
avoided (but not fixed) bug in the gateway modules where you cannot send
escaped URL params to vsnprintf.  This will need to be fixed.

git-svn-id: svn://svn.open-ils.org/ILS/trunk@2299 dcc99617-32d9-48b4-a31d-7c20da2025e4

14 files changed:
Open-ILS/src/apachemods/mod_rest_gateway.c
Open-ILS/src/extras/fieldmapper.pl
Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
Open-ILS/web/opac/common/js/config.js
Open-ILS/web/opac/common/js/opac_utils.js
Open-ILS/web/opac/locale/en-US/lang.dtd
Open-ILS/web/opac/skin/default/js/holds.js
Open-ILS/web/opac/skin/default/xml/altcanvas.xml
Open-ILS/web/opac/skin/default/xml/holds.xml
Open-ILS/web/opac/skin/default/xml/ilsevents.xml
OpenSRF/src/gateway/mod_ils_gateway.c
OpenSRF/src/libstack/osrf_system.c
OpenSRF/src/objson/json_parser.c
OpenSRF/src/utils/log.c

index 9fd4beb..8231ea1 100644 (file)
@@ -1,4 +1,5 @@
 #include "mod_rest_gateway.h"
+#include "http_log.h"
 
 char* ils_rest_gateway_config_file;
 
@@ -35,7 +36,6 @@ static void mod_ils_gateway_child_init(apr_pool_t *p, server_rec *s) {
                osrfLogError("Unable to load gateway config file...");
                return;
        }
-       osrfLogSetAppname("oils_rest_gw");
        fprintf(stderr, "Bootstrapping %d\n", getpid() );
        fflush(stderr);
 }
@@ -46,6 +46,8 @@ static int mod_ils_gateway_method_handler (request_rec *r) {
        if (strcmp(r->handler, MODULE_NAME )) 
                return DECLINED;
 
+       osrfLogSetAppname("oils_rest_gw");
+
        apr_pool_t *p = r->pool;        /* memory pool */
        char* arg = r->args;                    /* url query string */
 
@@ -73,7 +75,6 @@ static int mod_ils_gateway_method_handler (request_rec *r) {
        }
 
 
-
        /* gather the post args and append them to the url query string */
        if( !strcmp(r->method,"POST") ) {
 
@@ -88,7 +89,6 @@ static int mod_ils_gateway_method_handler (request_rec *r) {
                buffer = buffer_init(1025);
 
                while(ap_get_client_block(r, body, 1024)) {
-                       osrfLogDebug("Apache read POST block data: %s\n", body);
                        buffer_add( buffer, body );
                        memset(body,0,1025);
                }
@@ -106,7 +106,7 @@ static int mod_ils_gateway_method_handler (request_rec *r) {
 
        } 
 
-       osrfLogDebug("params args are %s", arg);
+       ap_log_rerror( APLOG_MARK, APLOG_DEBUG, 0, r, "URL: %s", arg );
 
 
        if( ! arg || !arg[0] ) { /* we received no request */
index 9dd2ed0..23c719e 100755 (executable)
@@ -11,10 +11,10 @@ if(!$web) { $web = ""; }
 
 # List of classes needed by the opac
 my @web_hints = qw/asv asva asvr asvq 
-               circ acp acpl acn ccs ahn aua ac 
-               actscecm crcd crmf crrf mbts aoc aus mous/;
+               circ acp acpl acn ccs ahn  
+               crcd crmf crrf mbts aoc aus mous/;
 
-my @web_core = qw/ aou au perm_ex ex aout mvr ccs ahr /;
+my @web_core = qw/ aou au perm_ex ex aout mvr ccs ahr aua ac actscecm /;
 
 my @reports = qw/ perm_ex ex ao aou aout /;
 
index d58fb1d..94c5d5d 100644 (file)
@@ -14,6 +14,8 @@ use OpenILS::Application::AppUtils;
 use OpenILS::Utils::Fieldmapper;
 use OpenILS::Application::Search::Actor;
 use OpenILS::Utils::ModsParser;
+use OpenSRF::Utils::Logger;
+my $logger = "OpenSRF::Utils::Logger";
 
 use OpenSRF::Utils::Cache;
 
@@ -684,8 +686,11 @@ __PACKAGE__->register_method(
 
 sub user_retrieve_by_barcode {
        my($self, $client, $user_session, $barcode) = @_;
-       warn "Searching for user with barcode $barcode\n";
-       my $user_obj = $apputils->check_user_session( $user_session ); 
+
+       $logger->debug("Searching for user with barcode $barcode");
+       #my $user_obj = $apputils->check_user_session( $user_session ); 
+       my ($user_obj, $evt) = $apputils->check_ses($user_session);
+       return $evt if $evt;
 
        my $session = OpenSRF::AppSession->create("open-ils.storage");
 
index e3ee5cb..e7cce81 100644 (file)
@@ -209,6 +209,7 @@ var CHECK_SPELL                                     = "open-ils.search:open-ils.search.spell_check";
 var FETCH_REVIEWS                                      = "open-ils.search:open-ils.search.added_content.review.retrieve.all";
 var FETCH_TOC                                          = "open-ils.search:open-ils.search.added_content.toc.retrieve";
 var FETCH_ACONT_SUMMARY                        = "open-ils.search:open-ils.search.added_content.summary.retrieve";
+var FETCH_USER_BYBARCODE               = "open-ils.actor:open-ils.actor.user.fleshed.retrieve_by_barcode";
 /* ---------------------------------------------------------------------------- */
 
 
index 3c929ec..494e0b6 100644 (file)
@@ -279,7 +279,6 @@ function grabUser(ses, force) {
        //new AuthTimer(20).run();
 
        return G.user;
-
 }
 
 
@@ -643,3 +642,9 @@ function _authTimerAlert() {
 }
 
 
+function grabUserByBarcode( authtoken, barcode ) {
+       var req = new Request( FETCH_USER_BYBARCODE, authtoken, barcode );
+       req.send(true);
+       return req.result();
+}
+
index 793e0b3..f6ec32b 100644 (file)
@@ -22,6 +22,8 @@
 <!ENTITY common.library "Library">
 <!ENTITY common.username "Username">
 <!ENTITY common.password "Password">
+<!ENTITY common.submit "Submit">
+<!ENTITY common.user_not_found "User not found">
 
 
 <!--   ======================================================================================= 
@@ -50,7 +52,7 @@
 <!ENTITY opac.llt "&lt;">
 <!ENTITY opac.ggt "&gt;">
 
-<!ENTITY opac.session_expiring "Your login session will soon expire.\nClick 'OK' to logout and return to the home page.\nClick 'Cancel' to continue browsing.">
+<!ENTITY opac.session_expiring "Your login session will soon expire. Click 'OK' to logout and return to the home page.  Click 'Cancel' to continue browsing.">
 <!ENTITY opac.session_expired "Your login session has expired">
 
 <!-- Navigations links -->
 <!ENTITY rdetail.detailMain.viewMarc "View MARC">
 <!ENTITY rdetail.detailMain.hideMarc "Return to title details">
 
-<!ENTITY opac.holds.placeHold "Place a hold on the following item">
+<!ENTITY opac.holds.xulRecipient "Enter recipient barcode">
+<!ENTITY opac.holds.recipient "Recipient">
+<!ENTITY opac.holds.placeHold "Place Hold">
 <!ENTITY opac.holds.contactPhone "Concact telephone number">
 <!ENTITY opac.holds.concactEmail "Concact email address">
 <!ENTITY opac.holds.pickupLocation "Pickup location">
index 5ff95d1..142e897 100644 (file)
@@ -2,16 +2,50 @@
 var currentHoldRecord;
 var currentHoldRecordObj;
 var holdsOrgSelectorBuilt = false;
+var holdRecipient;
+var holdRequestor
+var holdEmail;
+var holdPhone;
+
+
+function holdsHandleStaff() {
+       swapCanvas($('xulholds_box'));
+       $('xul_recipient_barcode').focus();
+       $('xul_recipient_barcode').onkeypress = function(evt) 
+               {if(userPressedEnter(evt)) { _holdsHandleStaff(); } };
+       $('xul_recipient_barcode_submit').onclick = _holdsHandleStaff;
+}
+
+function _holdsHandleStaff() {
+       var barcode = $('xul_recipient_barcode').value;
+       var user = grabUserByBarcode( G.user.session, barcode );
+       if(!user) {
+               alert( '(' + barcode + ') => ' + $('user_not_found').innerHTML );
+               showCanvas();
+               return;
+       }
+       holdRecipient = user;
+       holdsDrawWindow( currentHoldRecord, null );
+}
 
 function holdsDrawWindow(recid, type) {
 
        if(recid == null) {
                recid = currentHoldRecord;
                if(recid == null) return;
-       }
+       }       
        currentHoldRecord = recid;
+       
+       //if(isXUL() && holdRecipient == null ) { 
+       if(holdRecipient == null ) { 
+               holdsHandleStaff();
+               return;
+       }
+
+       if( holdRecipient == null ) holdRecipient = G.user;
+       if( holdRequestor == null ) holdRequestor = G.user;
 
-       if(!(G.user && G.user.session)) {
+       if(!(holdRequestor && holdRequestor.session)) {
 
                detachAllEvt('common','locationChanged');
                attachEvt('common','loggedIn', holdsDrawWindow)
@@ -28,15 +62,13 @@ function holdsDrawWindow(recid, type) {
                holdsOrgSelectorBuilt = true;
        }
 
-       removeChildren($('holds_title'));
-       removeChildren($('holds_author'));
-       removeChildren($('holds_format'));
-       removeChildren($('holds_email'));
-       removeChildren($('holds_email'));
-
-       $('holds_title').appendChild(text(rec.title()));
-       $('holds_author').appendChild(text(rec.author()));
+       appendClear($('holds_recipient'), text(
+               holdRecipient.family_name() + ', ' +  
+                       holdRecipient.first_given_name()));
+       appendClear($('holds_title'), text(rec.title()));
+       appendClear($('holds_author'), text(rec.author()));
 
+       //removeChildren($('holds_format'));
        for( var i in rec.types_of_resource() ) {
                var res = rec.types_of_resource()[i];
                var img = elem("img");
@@ -46,8 +78,8 @@ function holdsDrawWindow(recid, type) {
                $('holds_format').appendChild(text(' '));
        }
 
-       $('holds_phone').appendChild(text(G.user.day_phone()));
-       $('holds_email').appendChild(text(G.user.email()));
+       appendClear( $('holds_phone'), text(holdRecipient.day_phone()));
+       appendClear( $('holds_email'), text(holdRecipient.email()));
        $('holds_cancel').onclick = showCanvas;
        $('holds_submit').onclick = holdsPlaceHold; 
 }
@@ -81,7 +113,7 @@ function holdsBuildOrgSelector(node, depth) {
                selector.options[index] = select;
        }       
 
-       if( node.id() == G.user.home_ou() ) {
+       if( node.id() == holdRecipient.home_ou() ) {
                selector.selectedIndex = index;
                selector.options[index].selected = true;        
        }
@@ -95,33 +127,35 @@ function holdsBuildOrgSelector(node, depth) {
 }
 
 function holdsPlaceHold() {
-       //alert("placing hold for " + currentHoldRecord );
 
-       var org = $('holds_org_selector').options[$('holds_org_selector').selectedIndex].value;
+       var org = $('holds_org_selector').options[
+               $('holds_org_selector').selectedIndex].value;
 
        var hold = new ahr();
        hold.pickup_lib(org); 
        hold.request_lib(org); 
-       hold.requestor(G.user.id());
-       hold.usr(G.user.id());
+       hold.requestor(holdRequestor.id());
+       hold.usr(holdRecipient.id());
        hold.hold_type('T');
-       hold.email_notify(G.user.email());
-       hold.phone_notify(G.user.day_phone());
+       hold.email_notify(holdRecipient.email());
+       hold.phone_notify(holdRecipient.day_phone());
        hold.target(currentHoldRecord);
        
-       var req = new Request( CREATE_HOLD, G.user.session, hold );
+       var req = new Request( CREATE_HOLD, holdRequestor.session, hold );
        req.send(true);
        var res = req.result();
 
-       /* XMLize me  XXX */
        if( res == '1' ) alert($('holds_success').innerHTML);
        else alert($('holds_failure').innerHTML);
        
        showCanvas();
+       holdRecipient = null;
+       holdRequestor = null;
 }
 
-function holdsCancel(holdid) {
-       var req = new Request(CANCEL_HOLD, G.user.session, holdid);
+function holdsCancel(holdid, user) {
+       if(!user) user = G.user;
+       var req = new Request(CANCEL_HOLD, user.session, holdid);
        req.send(true);
        return req.result();
 }
index 2cc0292..448ede5 100644 (file)
@@ -17,6 +17,7 @@
                config.ids.altcanvas.login                      = config.ids.login.box;
                config.ids.altcanvas.org_tree           = config.ids.common.org_container;
                config.ids.altcanvas.holds                      = 'holds_box';
+               config.ids.altcanvas.xulholds           = 'xulholds_box';
                config.ids.altcanvas.loading            = 'loading_alt';
        </script>
 
index 939786d..f2ebdbb 100644 (file)
@@ -1,51 +1,72 @@
 <?xml version='1.0'?>
 
-<div id='holds_box' class='hide_me non_canvas' style='margin-top: 6px;'>
-
-       <br/><br/>
-       <table width='75%'>
-               <tbody>
-                       <tr>
-                               <td class='holds_cell color_1' 
-                                       align='center' colspan='2'>&opac.holds.placeHold;</td>
-                       </tr>
-                       <tr>
-                               <td class='holds_cell'>&common.title;:</td>
-                               <td class='holds_cell' id='holds_title'> </td>
-                       </tr>
-                       <tr>
-                               <td class='holds_cell'>&common.author;:</td>
-                               <td class='holds_cell' id='holds_author'> </td>
-                       </tr>
-                       <tr>
-                               <td class='holds_cell'>&common.format;:</td>
-                               <td class='holds_cell' id='holds_format'> </td>
-                       </tr>
-                       <tr>
-                               <td class='holds_cell'>&opac.holds.contactPhone;:</td>
-                               <td class='holds_cell' id='holds_phone'> </td>
-                       </tr>
-                       <tr>
-                               <td class='holds_cell'>&opac.holds.concactEmail;:</td>
-                               <td class='holds_cell' id='holds_email'> </td>
-                       </tr>
-                       <tr>
-                               <td class='holds_cell'>&opac.holds.pickupLocation;</td>
-                               <td class='holds_cell'>
-                                       <select id='holds_org_selector'> </select>
-                               </td>
-                       </tr>
-                       <tr>
-                               <td class='holds_cell' align='center' colspan='2'>
-                                       <button id='holds_submit'>&opac.holds.placeHold;</button>
-                                       <span style='padding: 20px;'> </span>
-                                       <button id='holds_cancel'>&common.cancel;</button>
-                               </td>
-                       </tr>
-               </tbody>
-       </table>
-
-       <div class='hide_me' id='holds_success'>&opac.holds.success;</div>
-       <div class='hide_me' id='holds_failure'>&opac.holds.failure;</div>
+<div>
+       <div id='xulholds_box' class='hide_me non_canvas' style='margin-top: 6px;'>
+               <center>
+                       <table class='data_grid' style='margin-top: 20px;'>
+                               <tbody>
+                                       <tr>
+                                               <td>&opac.holds.xulRecipient;:</td>
+                                               <td><input type='text' id='xul_recipient_barcode'> </input></td>
+                                               <td><input type='submit' value='&common.submit;' 
+                                                       id='xul_recipient_barcode_submit'> </input></td>
+                                       </tr>
+                               </tbody>
+                       </table>
+               </center>
+       </div>
 
+       <div id='holds_box' class='hide_me non_canvas' style='margin-top: 6px;'>
+       
+               <br/><br/>
+               <table width='75%'>
+                       <tbody>
+                               <tr>
+                                       <td class='holds_cell color_1' 
+                                               align='center' colspan='2'>&opac.holds.placeHold;</td>
+                               </tr>
+                               <tr>
+                                       <td class='holds_cell'>&opac.holds.recipient;:</td>
+                                       <td class='holds_cell' id='holds_recipient'> </td>
+                               </tr>
+                               <tr>
+                                       <td class='holds_cell'>&common.title;:</td>
+                                       <td class='holds_cell' id='holds_title'> </td>
+                               </tr>
+                               <tr>
+                                       <td class='holds_cell'>&common.author;:</td>
+                                       <td class='holds_cell' id='holds_author'> </td>
+                               </tr>
+                               <tr>
+                                       <td class='holds_cell'>&common.format;:</td>
+                                       <td class='holds_cell' id='holds_format'> </td>
+                               </tr>
+                               <tr>
+                                       <td class='holds_cell'>&opac.holds.contactPhone;:</td>
+                                       <td class='holds_cell' id='holds_phone'> </td>
+                               </tr>
+                               <tr>
+                                       <td class='holds_cell'>&opac.holds.concactEmail;:</td>
+                                       <td class='holds_cell' id='holds_email'> </td>
+                               </tr>
+                               <tr>
+                                       <td class='holds_cell'>&opac.holds.pickupLocation;</td>
+                                       <td class='holds_cell'>
+                                               <select id='holds_org_selector'> </select>
+                                       </td>
+                               </tr>
+                               <tr>
+                                       <td class='holds_cell' align='center' colspan='2'>
+                                               <button id='holds_submit'>&opac.holds.placeHold;</button>
+                                               <span style='padding: 20px;'> </span>
+                                               <button id='holds_cancel'>&common.cancel;</button>
+                                       </td>
+                               </tr>
+                       </tbody>
+               </table>
+       
+               <div class='hide_me' id='holds_success'>&opac.holds.success;</div>
+               <div class='hide_me' id='holds_failure'>&opac.holds.failure;</div>
+       
+       </div>
 </div>
index 6db5f47..3279ca4 100644 (file)
@@ -6,5 +6,6 @@
        <!-- Local OPAC Specific strings/events -->
        <span id='auth_session_expiring'>&opac.session_expiring;</span>
        <span id='auth_session_expired'>&opac.session_expired;</span>
+       <span id='user_not_found'>&common.user_not_found;</span>
 </span>
 
index 21067ec..82a9a3c 100644 (file)
@@ -1,7 +1,8 @@
 #include "mod_ils_gateway.h"
+#include "http_log.h"
 
-char* ils_gateway_config_file;
-char* ils_rest_gateway_config_file;
+char* ils_gateway_config_file = NULL;
+char* ils_rest_gateway_config_file = NULL;
 
 static const char* ils_gateway_set_config(cmd_parms *parms, void *config, const char *arg) {
        ils_gateway_config  *cfg;
@@ -29,10 +30,9 @@ static void mod_ils_gateway_child_init(apr_pool_t *p, server_rec *s) {
 
        char* cfg = ils_gateway_config_file;
        if( ! osrf_system_bootstrap_client( cfg, CONFIG_CONTEXT) ) {
-               osrfLogError("Unable to load gateway config file...");
+               osrfLogError("Unable to bootstrap client in gateway...");
                return;
        }
-       osrfLogSetAppname("osrf_json_gw");
        fprintf(stderr, "Bootstrapping %d\n", getpid() );
        fflush(stderr);
 }
@@ -42,6 +42,8 @@ static int mod_ils_gateway_method_handler (request_rec *r) {
        /* make sure we're needed first thing*/
        if (strcmp(r->handler, MODULE_NAME )) 
                return DECLINED;
+       
+       osrfLogSetAppname("osrf_json_gw");
 
        apr_pool_t *p = r->pool;        /* memory pool */
        char* arg = r->args;                    /* url query string */
@@ -49,8 +51,6 @@ static int mod_ils_gateway_method_handler (request_rec *r) {
        char* service                                   = NULL; /* service to connect to */
        char* method                                    = NULL; /* method to perform */
 
-       //json* exception                               = NULL; /* returned in error conditions */
-       //jsonObject* exception         = NULL; /* returned in error conditions */
        string_array* sarray                    = init_string_array(12); /* method parameters */
 
        growing_buffer* buffer          = NULL; /* POST data */
@@ -59,20 +59,18 @@ static int mod_ils_gateway_method_handler (request_rec *r) {
        char* key                                               = NULL; /* query item name */
        char* val                                               = NULL; /* query item value */
 
-       jsonObject* response                    = jsonParseString("{\"status\":0,\"debug\":\"\"}");
-       jsonObject* payload                     = jsonParseString("[]");
+       jsonObject* response                    = jsonParseString("{ }");
+       jsonObject* payload                     = jsonParseString("[ ]");
        jsonObjectSetKey(response, "payload", payload );
 
-
-
        /* verify we are connected */
        if(!osrf_system_get_transport_client()) {
                osrfLogError("Bootstrap Failed, no transport client");
                return HTTP_INTERNAL_SERVER_ERROR;
        }
 
-
        ap_set_content_type(r, "text/plain");
+       osrfLogDebug("Apache request method: %s", r->method );
 
        /* gather the post args and append them to the url query string */
        if( !strcmp(r->method,"POST") ) {
@@ -81,20 +79,28 @@ static int mod_ils_gateway_method_handler (request_rec *r) {
 
                if(! ap_should_client_block(r)) {
                        osrfLogWarning("No Post Body");
+                       ap_rputs("null", r);
+                       return OK;
                }
 
-               char body[1025];
-               memset(body,0,1025);
-               buffer = buffer_init(1025);
+               int BUFL = 1024;
+               char body[BUFL];
+               bzero(body, BUFL);
+               buffer = buffer_init(BUFL);
 
-               while(ap_get_client_block(r, body, 1024)) {
-                       osrfLogDebug("Apache read POST block data: %s\n", body);
+               while(ap_get_client_block(r, body, BUFL - 1 )) {
                        buffer_add( buffer, body );
-                       memset(body,0,1025);
+                       bzero(body, BUFL);
+               }
+
+               if( buffer->n_used < 1 ) {
+                       osrfLogWarning("No Post Body");
+                       ap_rputs("null", r);
+                       return OK;
                }
 
-               if(arg && arg[0]) {
-                       tmp_buf = buffer_init(1024);
+               if(arg && strlen(arg) > 0 ) {
+                       tmp_buf = buffer_init(BUFL);
                        buffer_add(tmp_buf,arg);
                        buffer_add(tmp_buf,buffer->buf);
                        arg = (char*) apr_pstrdup(p, tmp_buf->buf);
@@ -106,17 +112,16 @@ static int mod_ils_gateway_method_handler (request_rec *r) {
 
        } 
 
-       osrfLogDebug("params args are %s", arg);
-
-
-       if( ! arg || !arg[0] ) { /* we received no request */
+       if( ! arg || strlen(arg) == 0 ) { /* we received no request */
                osrfLogWarning("No Args");
+               ap_rputs("null", r);
                return OK;
        }
 
+       ap_log_rerror( APLOG_MARK, APLOG_DEBUG, 0, r, "URL: %s", arg );
+
        r->allowed |= (AP_METHOD_BIT << M_GET);
        r->allowed |= (AP_METHOD_BIT << M_POST);
-
        
        while( arg && (val = ap_getword(p, (const char**) &arg, '&'))) {
 
@@ -138,7 +143,7 @@ static int mod_ils_gateway_method_handler (request_rec *r) {
 
        }
 
-       osrfLogInfo("\nPerforming(%d):  service %s "
+       osrfLogInfo("\r\nPerforming(%d):  service %s "
                        "| method %s |", getpid(), service, method );
 
        int k;
@@ -148,7 +153,7 @@ static int mod_ils_gateway_method_handler (request_rec *r) {
 
        osrf_app_session* session = osrf_app_client_session_init(service);
 
-       osrfLogDebug("MOD session service: %s", session->remote_service );
+       osrfLogDebug("session service: %s", session->remote_service );
 
        int req_id = osrf_app_session_make_req( session, NULL, method, 1, sarray );
        string_array_destroy(sarray);
@@ -164,12 +169,14 @@ static int mod_ils_gateway_method_handler (request_rec *r) {
        
                } else {
 
-                       char* s = omsg->status_name ? omsg->status_name : "Unknown Error";
-                       char* t = omsg->status_text ? omsg->status_text : "No Error Message";
-                       jsonObjectSetKey(response, "debug", jsonNewObject("\n\n%s:\n%s\n", s, t));
-                       osrfLogError( "Gateway received error: %s", 
-                                       jsonObjectGetString(jsonObjectGetKey(response, "debug")));
-                       break;
+                       if( omsg->status_code > 299 ) {
+                               char* s = omsg->status_name ? omsg->status_name : "Unknown Error";
+                               char* t = omsg->status_text ? omsg->status_text : "No Error Message";
+                               jsonObjectSetKey(response, "debug", jsonNewObject("\n\n%s:\n%s\n", s, t));
+                               osrfLogError( "Gateway received error: %s", 
+                                               jsonObjectGetString(jsonObjectGetKey(response, "debug")));
+                               break;
+                       }
                }
 
                osrf_message_free(omsg);
index ac698f7..794a1f5 100644 (file)
@@ -5,7 +5,7 @@
 
 void __osrfSystemSignalHandler( int sig );
 
-transport_client* __osrfGlobalTransportClient;
+transport_client* __osrfGlobalTransportClient = NULL;
 
 transport_client* osrfSystemGetTransportClient() {
        return __osrfGlobalTransportClient;
index 63ba6b3..159eca1 100644 (file)
@@ -718,6 +718,7 @@ int json_handle_error(char* string, unsigned long* index, char* err_msg) {
                        "\nError parsing json string at charracter %c "
                        "(code %d) and index %ld\nMsg:\t%s\nNear:\t%s\n\n", 
                        string[*index], string[*index], *index, err_msg, buf );
+
        return -1;
 }
 
index 40ec051..03c8809 100644 (file)
@@ -78,9 +78,9 @@ void osrfLogDetail( int level, char* filename, int line, char* func, char* msg,
        if(!filename) filename = "";
        if(!func) func = "";
 
-       char lb[8];
-       bzero(lb,8);
-       if(line >= 0) snprintf(lb,8,"%d", line);
+       char lb[12];
+       bzero(lb,12);
+       if(line >= 0) snprintf(lb,12,"%d", line);
 
        char* l = "INFO";               /* level name */
        int lvl = LOG_INFO;     /* syslog level */
@@ -126,6 +126,7 @@ void osrfLogDetail( int level, char* filename, int line, char* func, char* msg,
 
        else if( __osrfLogType == OSRF_LOG_TYPE_FILE )
                _osrfLogToFile("[%s:%d:%s:%s:%s] %s", l, getpid(), filename, lb, func, VA_BUF );
+
 }
 
 
@@ -140,7 +141,6 @@ void _osrfLogToFile( char* msg, ... ) {
        char buf[l];
        bzero(buf,l);
 
-
        char datebuf[36];
        bzero(datebuf,36);
        time_t t = time(NULL);