Ignore:
Timestamp:
2010-05-20T20:59:01+12:00 (14 years ago)
Author:
davidb
Message:

For the CGI 'e' variable to be inter-changable between mod_gsdl and library.cgi then they need to have exactly the same actions. The code has been refactored so they now use a shared function to do this, the ensure this is the case.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/runtime-src/src/recpt/librarymain.cpp

    r22067 r22142  
    3636
    3737#include "action.h"
    38 #include "authenaction.h"
    39 #include "browseaction.h"
    40 #include "collectoraction.h"
    41 #include "depositoraction.h"
    42 #include "documentaction.h"
    43 #include "dynamicclassifieraction.h"
    44 #include "extlinkaction.h"
    45 #include "pageaction.h"
    46 #ifdef ENABLE_MGPP
    47 #include "phindaction.h"
    48 #endif
    49 #include "pingaction.h"
    50 #include "queryaction.h"
    51 
    52 #if defined(USE_SQLITE)
    53 #include "sqlqueryaction.h"
    54 #endif
    55 
    56 #include "tipaction.h"
    57 #include "statusaction.h"
    58 #include "usersaction.h"
    59 
    6038#include "browserclass.h"
    61 #include "vlistbrowserclass.h"
    62 #include "hlistbrowserclass.h"
    63 #include "datelistbrowserclass.h"
    64 #include "invbrowserclass.h"
    65 #include "pagedbrowserclass.h"
    66 #include "htmlbrowserclass.h"
    67 #include "phindbrowserclass.h"
    6839
    6940
     
    12293#endif
    12394
    124   // the list of actions. Note: these actions will become invalid
    125   // at the end of this function. We will clean them.
    126 
    127 #ifdef GSDL_USE_TIP_ACTION
    128   recpt.add_action (new tipaction());
    129 #endif
    130 
    131 #ifdef GSDL_USE_STATUS_ACTION
    132   statusaction *astatusaction = new statusaction();
    133   astatusaction->set_receptionist (&recpt);
    134   recpt.add_action (astatusaction);
    135 #endif
    136 
    137   pageaction *apageaction = new pageaction();
    138   apageaction->set_receptionist (&recpt);
    139   recpt.add_action (apageaction);
    140 
    141 #ifdef GSDL_USE_PING_ACTION
    142   recpt.add_action (new pingaction());
    143 #endif
    144 
    145   queryaction *aqueryaction = new queryaction();
    146   aqueryaction->set_receptionist (&recpt);
    147   recpt.add_action (aqueryaction);
    148 
    149 #if defined(USE_SQLITE)
    150   sqlqueryaction *asqlqueryaction = new sqlqueryaction();
    151   asqlqueryaction->set_receptionist (&recpt);
    152   recpt.add_action (asqlqueryaction);
    153 #endif
    154 
    155   documentaction *adocumentaction = new documentaction();
    156   adocumentaction->set_receptionist (&recpt);
    157   recpt.add_action (adocumentaction);
    158 
    15995  userdbclass *udb = new userdbclass(gsdlhome);
    16096  keydbclass *kdb = new keydbclass(gsdlhome);
    16197
    162 #ifdef GSDL_USE_USERS_ACTION
    163   usersaction *ausersaction = new usersaction();
    164   ausersaction->set_userdb(udb);
    165   recpt.add_action (ausersaction);
    166 #endif
     98  add_all_actions(recpt,udb,kdb);
     99  // Note: these actions will become invalid at the end of this function.
     100  // => We will retrieve them from the receptionist and delete them
    167101
    168 #ifdef GSDL_USE_EXTLINK_ACTION
    169   extlinkaction *aextlinkaction = new extlinkaction();
    170   aextlinkaction->set_receptionist(&recpt);
    171   recpt.add_action (aextlinkaction);
    172 #endif
    173        
    174 #ifdef GSDL_USE_AUTHEN_ACTION
    175   authenaction *aauthenaction = new authenaction();
    176   aauthenaction->set_userdb(udb);
    177   aauthenaction->set_keydb(kdb);
    178   aauthenaction->set_receptionist(&recpt);
    179   recpt.add_action (aauthenaction);
    180 #endif
    181 
    182 #ifdef GSDL_USE_COLLECTOR_ACTION
    183   collectoraction *acollectoraction = new collectoraction();
    184   acollectoraction->set_receptionist (&recpt);
    185   recpt.add_action(acollectoraction);
    186 #endif
    187 
    188 #ifdef GSDL_USE_DEPOSITOR_ACTION
    189   depositoraction *adepositoraction = new depositoraction();
    190   adepositoraction->set_receptionist (&recpt);
    191   recpt.add_action(adepositoraction);
    192 #endif
    193 
    194 #ifdef GSDL_USE_BROWSE_ACTION
    195   browseaction *abrowseaction = new browseaction();
    196   abrowseaction->set_receptionist (&recpt);
    197   recpt.add_action(abrowseaction);
    198 #endif
    199 
    200 #ifdef GSDL_USE_PHIND_ACTION
    201   recpt.add_action(new phindaction());
    202 #endif
    203 
    204 #ifdef GSDL_USE_GTI_ACTION
    205   gtiaction *agtiaction = new gtiaction();
    206   agtiaction->set_receptionist(&recpt);
    207   recpt.add_action(agtiaction);
    208 #endif
    209 
    210   dynamicclassifieraction *adynamicclassifieraction = new dynamicclassifieraction();
    211   adynamicclassifieraction->set_receptionist(&recpt);
    212   recpt.add_action(adynamicclassifieraction); 
    213 
    214   // list of browsers
    215   vlistbrowserclass avlistbrowserclass;
    216   avlistbrowserclass.set_receptionist(&recpt);
    217   recpt.add_browser (&avlistbrowserclass);
    218   recpt.setdefaultbrowser ("VList");
    219 
    220   hlistbrowserclass ahlistbrowserclass;
    221   ahlistbrowserclass.set_receptionist(&recpt);
    222   recpt.add_browser (&ahlistbrowserclass);
    223 
    224 #ifdef GSDL_USE_DATELIST_BROWSER
    225   datelistbrowserclass adatelistbrowserclass;
    226   recpt.add_browser (&adatelistbrowserclass);
    227 #endif
    228 
    229   invbrowserclass ainvbrowserclass;
    230   recpt.add_browser (&ainvbrowserclass);
    231 
    232 #ifdef GSDL_USE_PAGED_BROWSER
    233   pagedbrowserclass apagedbrowserclass;
    234   recpt.add_browser (&apagedbrowserclass);
    235 #endif
    236 
    237 #ifdef GSDL_USE_HTML_BROWSER
    238   htmlbrowserclass ahtmlbrowserclass;
    239   recpt.add_browser (&ahtmlbrowserclass);
    240 #endif
    241 
    242 #ifdef GSDL_USE_PHIND_BROWSER
    243   phindbrowserclass aphindbrowserclass;
    244   recpt.add_browser (&aphindbrowserclass);
    245 #endif
     102  add_all_browsers(recpt);
     103  // Browsers are not currently deleted (at all?) in code.  Seems likely they
     104  // should be treated in a similar fashion to actions
    246105
    247106  cgiwrapper (recpt, "");
     
    252111  // clean up the actions
    253112  actionmapclass::iterator thisAction = recpt.get_actionmap_ptr()->begin();
    254   actionmapclass::iterator endAction = recpt.get_actionmap_ptr()->begin();
     113  actionmapclass::iterator endAction = recpt.get_actionmap_ptr()->end();
    255114  while (thisAction != endAction) {
    256     delete thisAction->second.a; thisAction->second.a = NULL;
     115    delete thisAction->second.a;
     116    thisAction->second.a = NULL;
    257117    ++thisAction;
    258118  }
     
    260120  recpt.get_actionmap_ptr()->erase(thisAction, endAction);
    261121
     122
     123  /*
     124  // clean up the browsers
     125  browsermapclass::iterator thisBrowser = recpt.get_browsermap_ptr()->begin();
     126  browsermapclass::iterator endBrowser = recpt.get_browsermap_ptr()->end();
     127  while (thisBrowser != endBrowser) {
     128    delete thisBrowser->second.a;
     129    thisBrowser->second.a = NULL;
     130    ++thisBrowser;
     131  }
     132  thisBrowser = recpt.get_browsermap_ptr()->begin();
     133  recpt.get_browsermap_ptr()->erase(thisBrowser, endBrowser);
     134  */
     135
    262136  return 0;
    263137}
Note: See TracChangeset for help on using the changeset viewer.