Changeset 5836:81ccac5ddc61 in roaraudio


Ignore:
Timestamp:
01/06/13 20:38:43 (11 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

Added half of the support for AppSched? Triggers ABOUT, HELP and PREFERENCES. This includes support in roarpluginrunner

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r5834 r5836  
    77        * Improved CSI: Make it easier to register and access services. 
    88        * Allow seperation of plugin's stdvios (See: #296) 
     9        * Added half of the support for AppSched Triggers 
     10          ABOUT, HELP and PREFERENCES. 
    911 
    1012v. 1.0beta8 - Mon Dec 10 2012 12:42 CET 
  • doc/man1/roarpluginrunner.1

    r5801 r5836  
    7979Set plugin arguments. 
    8080 
     81.SH "RUNNER OPTIONS" 
     82 
     83.TP 
     84\fB--option-touch\fR 
     85Do not keep the plugin running: Do a single UPDATE cycle. 
     86 
     87.TP 
     88\fB--option-no-touch\fR 
     89Disable touch option. 
     90 
     91.TP 
     92\fB--option-about\fR 
     93Show an about dialog after startup. 
     94 
     95.TP 
     96\fB--option-no-about\fR 
     97Disable about option. 
     98 
     99.TP 
     100\fB--option-help\fR 
     101Show onlion help after startup. 
     102 
     103.TP 
     104\fB--option-no-help\fR 
     105Disable help option. 
     106 
     107.TP 
     108\fB--option-preferences\fR 
     109Show preferences dialog after startup. 
     110 
     111.TP 
     112\fB--option-no-preferences\fR 
     113Disable preferences option. 
     114 
    81115.SH "CPI OPTIONS" 
    82116 
  • include/libroar/roardl.h

    r5823 r5836  
    274274 ROAR_DL_APPSCHED_TICK, 
    275275#define ROAR_DL_APPSCHED_TICK ROAR_DL_APPSCHED_TICK 
    276  ROAR_DL_APPSCHED_WAIT 
     276 ROAR_DL_APPSCHED_WAIT, 
    277277#define ROAR_DL_APPSCHED_WAIT ROAR_DL_APPSCHED_WAIT 
     278 ROAR_DL_APPSCHED_ABOUT, 
     279#define ROAR_DL_APPSCHED_ABOUT ROAR_DL_APPSCHED_ABOUT 
     280 ROAR_DL_APPSCHED_HELP, 
     281#define ROAR_DL_APPSCHED_HELP ROAR_DL_APPSCHED_HELP 
     282 ROAR_DL_APPSCHED_PREFERENCES 
     283#define ROAR_DL_APPSCHED_PREFERENCES ROAR_DL_APPSCHED_PREFERENCES 
    278284}; 
    279285 
  • include/libroar/services.h

    r5823 r5836  
    6464 
    6565// help: 
     66#define ROAR_SERVICE_HELP_NAME "help" 
     67#define ROAR_SERVICE_HELP_ABI  "1.0beta9" 
    6668struct roar_service_help { 
    6769 int (*show)(const struct roar_dl_libraryname * libname, const char * topic); 
  • libroar/roardl.c

    r5835 r5836  
    820820} 
    821821 
     822int                      roar_dl_appsched_trigger__handle_about(struct roar_dl_lhandle * lhandle) { 
     823 libroar_dl_service_apitype(roar_service_about) api; 
     824 int ret, err; 
     825 
     826 if ( roar_dl_service_get_api(NULL, ROAR_SERVICE_ABOUT_NAME, ROAR_SERVICE_ABOUT_ABI, &api) == -1 ) 
     827  return -1; 
     828 
     829 ret = libroar_dl_service_run_func(api, show, int, roar_dl_getlibname(lhandle)); 
     830 err = roar_error; 
     831 
     832 libroar_dl_service_free_api(api); 
     833 
     834 roar_error = err; 
     835 return ret; 
     836} 
     837 
     838int                      roar_dl_appsched_trigger__handle_help(struct roar_dl_lhandle * lhandle) { 
     839 libroar_dl_service_apitype(roar_service_help) api; 
     840 int ret, err; 
     841 
     842 if ( roar_dl_service_get_api(NULL, ROAR_SERVICE_HELP_NAME, ROAR_SERVICE_HELP_ABI, &api) == -1 ) 
     843  return -1; 
     844 
     845 ret = libroar_dl_service_run_func(api, show, int, roar_dl_getlibname(lhandle), NULL); 
     846 err = roar_error; 
     847 
     848 libroar_dl_service_free_api(api); 
     849 
     850 roar_error = err; 
     851 return ret; 
     852} 
     853 
     854int                      roar_dl_appsched_trigger__handle_preferences(struct roar_dl_lhandle * lhandle) { 
     855 roar_err_set(ROAR_ERROR_NOSYS); 
     856 return -1; 
     857} 
     858 
    822859int                      roar_dl_appsched_trigger(struct roar_dl_lhandle * lhandle, enum roar_dl_appsched_trigger trigger) { 
    823860 int (*func)  (struct roar_dl_librarypara * para) = NULL; 
     
    849886  _trig(tick, TICK); 
    850887  _trig(wait, WAIT); 
     888 
     889  // not yet supported by struct roar_dl_appsched. 
     890  case ROAR_DL_APPSCHED_ABOUT: 
     891  case ROAR_DL_APPSCHED_HELP: 
     892  case ROAR_DL_APPSCHED_PREFERENCES: 
     893    func = NULL; 
     894   break; 
    851895// use ifndef here so warnings of unhandled enum values will be shown in DEBUG mode. 
    852896#ifndef DEBUG 
     
    866910   lhandle->runtime_flags -= RTF_APPSCHED_INITED; 
    867911  } 
    868   roar_err_set(ROAR_ERROR_NOENT); 
    869   return -1; 
     912  switch (trigger) { 
     913   case ROAR_DL_APPSCHED_ABOUT: 
     914     return roar_dl_appsched_trigger__handle_about(lhandle); 
     915    break; 
     916   case ROAR_DL_APPSCHED_HELP: 
     917     return roar_dl_appsched_trigger__handle_help(lhandle); 
     918    break; 
     919   case ROAR_DL_APPSCHED_PREFERENCES: 
     920     return roar_dl_appsched_trigger__handle_preferences(lhandle); 
     921    break; 
     922   default: 
     923     roar_err_set(ROAR_ERROR_NOENT); 
     924     return -1; 
     925    break; 
     926  } 
    870927 } 
    871928 
  • roarclients/roarpluginrunner.c

    r5823 r5836  
    3535}; 
    3636 
     37#define OPTION_NONE        0x0000 
     38#define OPTION_TOUCH       0x0001 
     39#define OPTION_ABOUT       0x0100 
     40#define OPTION_HELP        0x0200 
     41#define OPTION_PREFERENCES 0x0400 
     42 
    3743static struct roar_dl_librarypara * g_para  = NULL; 
    3844static struct roar_scheduler      * g_sched = NULL; 
     
    5662        ); 
    5763 
     64 fprintf(stderr, "\nRunner Options:\n\n"); 
     65 fprintf(stderr, "    --option-touch       - Do not keep the plugin running:" 
     66                 "                           Do a single UPDATE cycle.\n" 
     67                 "    --option-no-touch    - Disable touch option.\n" 
     68                 "    --option-about       - Show an about dialog after startup.\n" 
     69                 "    --option-no-about    - Disable about option.\n" 
     70                 "    --option-help        - Show onlion help after startup.\n" 
     71                 "    --option-no-help     - Disable help option.\n" 
     72                 "    --option-preferences - Show preferences dialog after startup.\n" 
     73                 "    --option-no-preferences\n" 
     74                 "                         - Disable preferences option.\n" 
     75        ); 
     76 
    5877 fprintf(stderr, "\nCPI Options:\n\n"); 
    5978 fprintf(stderr, " -t --tcp                - Use TCP listen socket\n" 
     
    6988} 
    7089 
    71 static int do_run(const char * name) { 
     90static int do_run(const char * name, int options) { 
    7291 struct roar_scheduler_source s_container; 
    7392 struct roar_plugincontainer * cont = roar_plugincontainer_new(g_para); 
     
    92111 roar_plugincontainer_appsched_trigger(cont, ROAR_DL_APPSCHED_INIT); 
    93112 
    94  roar_scheduler_run(g_sched); 
     113 if ( options & OPTION_ABOUT ) { 
     114  if ( roar_plugincontainer_appsched_trigger(cont, ROAR_DL_APPSCHED_ABOUT) == -1 ) { 
     115   ROAR_WARN("Can not call ABOUT trigger: %s", roar_errorstring); 
     116  } 
     117 } 
     118 
     119 if ( options & OPTION_HELP ) { 
     120  if ( roar_plugincontainer_appsched_trigger(cont, ROAR_DL_APPSCHED_HELP) == -1 ) { 
     121   ROAR_WARN("Can not call HELP trigger: %s", roar_errorstring); 
     122  } 
     123 } 
     124 
     125 if ( options & OPTION_PREFERENCES ) { 
     126  if ( roar_plugincontainer_appsched_trigger(cont, ROAR_DL_APPSCHED_PREFERENCES) == -1 ) { 
     127   ROAR_WARN("Can not call PREFERENCES trigger: %s", roar_errorstring); 
     128  } 
     129 } 
     130 
     131 
     132 if ( !(options & OPTION_TOUCH) ) 
     133  roar_scheduler_run(g_sched); 
    95134 
    96135 roar_plugincontainer_appsched_trigger(cont, ROAR_DL_APPSCHED_UPDATE); 
     
    303342} 
    304343 
    305 static int do_plugin(enum action action, const char * name) { 
     344static int do_plugin(enum action action, const char * name, int options) { 
    306345 switch (action) { 
    307346  case EXPLAIN: 
     
    310349  case RUN: 
    311350  case RUN_AS_APPLICATION: 
    312     return do_run(name); 
     351    return do_run(name, options); 
    313352   break; 
    314353  default: 
     
    558597 int cpi_touched = 0; 
    559598 const char * cpi_host = NULL; 
     599 int options = OPTION_NONE; 
    560600 
    561601 g_sched = roar_scheduler_new(ROAR_SCHEDULER_FLAG_NONE, ROAR_SCHEDULER_STRATEGY_DEFAULT); 
     
    618658   } 
    619659 
     660#define _option(name) \ 
     661  } else if ( !strcasecmp(k, "--option-" #name) ) { \ 
     662   options |= OPTION_ ## name; \ 
     663  } else if ( !strcasecmp(k, "--option-no-" #name) ) { \ 
     664   options |= OPTION_ ## name; \ 
     665   options -= OPTION_ ## name; 
     666#define __fix_vim_syntax_highlight } 
     667  _option(TOUCH) 
     668  _option(ABOUT) 
     669  _option(HELP) 
     670  _option(PREFERENCES) 
     671 
    620672  } else if ( !strcmp(k, "--appname") ) { 
    621673   appname = argv[++i]; 
     
    640692   } else { 
    641693    roar_err_set(ROAR_ERROR_NONE); 
    642     if ( do_plugin(action, k) == -1 ) { 
     694    if ( do_plugin(action, k, options) == -1 ) { 
    643695     fprintf(stderr, "Error loading plugin: %s\n", 
    644696                     roar_error != ROAR_ERROR_NONE ? roar_error2str(roar_error) : roar_dl_errstr(NULL)); 
Note: See TracChangeset for help on using the changeset viewer.