Beispiel #1
0
/*
 * Create a plugin event 
 */
int generate_plugin_event(JCR *jcr, bsdEventType eventType, void *value)
{
   bpContext *plugin_ctx;
   bsdEvent event;
   Plugin *plugin;
   int i = 0;
   bRC rc = bRC_OK;

   if (!bplugin_list || !jcr || !jcr->plugin_ctx_list) {
      return bRC_OK;                  /* Return if no plugins loaded */
   }
   if (jcr->is_job_canceled()) {
      return bRC_Cancel;
   }

   bpContext *plugin_ctx_list = (bpContext *)jcr->plugin_ctx_list;
   event.eventType = eventType;

   Dmsg2(dbglvl, "sd-plugin_ctx_list=%p JobId=%d\n", jcr->plugin_ctx_list, jcr->JobId);

   foreach_alist(plugin, bplugin_list) {
      plugin_ctx = &plugin_ctx_list[i++];
      if (is_plugin_disabled(plugin_ctx)) {
         continue;
      }
      rc = sdplug_func(plugin)->handlePluginEvent(plugin_ctx, &event, value);
      if (rc != bRC_OK) {
         break;
      }
   }
Beispiel #2
0
static inline bRC trigger_plugin_event(JCR *jcr, bsdEventType eventType, bsdEvent *event, bpContext *ctx, void *value)
{
   if (!is_event_enabled(ctx, eventType)) {
      Dmsg1(dbglvl, "Event %d disabled for this plugin.\n", eventType);
      return bRC_OK;
   }

   if (is_plugin_disabled(ctx)) {
      Dmsg0(dbglvl, "Plugin disabled.\n");
      return bRC_OK;
   }

   return sdplug_func(ctx->plugin)->handlePluginEvent(ctx, event, value);
}
Beispiel #3
0
static inline bRC trigger_plugin_event(JCR *jcr, bDirEventType eventType, bDirEvent *event,
                                       Plugin *plugin, bpContext *plugin_ctx_list,
                                       int index, void *value)
{
    bpContext *ctx;

    ctx = &plugin_ctx_list[index];
    if (!is_event_enabled(ctx, eventType)) {
        Dmsg1(dbglvl, "Event %d disabled for this plugin.\n", eventType);
        return bRC_OK;
    }

    if (is_plugin_disabled(ctx)) {
        Dmsg0(dbglvl, "Plugin disabled.\n");
        return bRC_OK;
    }

    return dirplug_func(plugin)->handlePluginEvent(ctx, event, value);
}
Beispiel #4
0
static inline bool is_plugin_disabled(JCR *jcr)
{
   return is_plugin_disabled(jcr->plugin_ctx);
}
Beispiel #5
0
static inline bool trigger_plugin_event(JCR *jcr, bDirEventType eventType,
                                        bDirEvent *event, bpContext *ctx,
                                        void *value, alist *plugin_ctx_list,
                                        int *index, bRC *rc)
{
   bool stop = false;

   if (!is_event_enabled(ctx, eventType)) {
      Dmsg1(dbglvl, "Event %d disabled for this plugin.\n", eventType);
      goto bail_out;
   }

   if (is_plugin_disabled(ctx)) {
      Dmsg0(dbglvl, "Plugin disabled.\n");
      goto bail_out;
   }

   /*
    * See if we should care about the return code.
    */
   if (rc) {
      *rc = dirplug_func(ctx->plugin)->handlePluginEvent(ctx, event, value);
      switch (*rc) {
      case bRC_OK:
         break;
      case bRC_Stop:
      case bRC_Error:
         stop = true;
         break;
      case bRC_More:
         break;
      case bRC_Term:
         /*
          * Request to unload this plugin.
          * As we remove the plugin from the list of plugins we decrement
          * the running index value so the next plugin gets triggered as
          * that moved back a position in the alist.
          */
         if (index) {
            unload_plugin(plugin_ctx_list, ctx->plugin, *index);
            *index = ((*index) - 1);
         }
         break;
      case bRC_Seen:
         break;
      case bRC_Core:
         break;
      case bRC_Skip:
         stop = true;
         break;
      case bRC_Cancel:
         break;
      default:
         break;
      }
   } else {
      dirplug_func(ctx->plugin)->handlePluginEvent(ctx, event, value);
   }

bail_out:
   return stop;
}