diff options
-rw-r--r-- | deadbeef.h | 11 | ||||
-rw-r--r-- | plugins.c | 12 |
2 files changed, 18 insertions, 5 deletions
@@ -825,6 +825,10 @@ enum { /* deprecated in API 1.5 */ DB_ACTION_PLAYLIST__DEPRECATED = 1 << 5, + + /* this flag is added automatically, and means that the plugin was compiled + * with API <=1.4, and work-around must be used to make it work */ + DB_ACTION_USING_API_14 = 1 << 6, }; // action contexts @@ -839,11 +843,8 @@ enum { struct DB_plugin_action_s; -// userdata is kept for compatibility with API 1.4 and below -// should not be used in newly written actions; -// ctx is one of the above DDB_ACTION_CTX constants -typedef int (*DB_plugin_action_callback_t) (struct DB_plugin_action_s *action, void *userdata, int ctx); -#define DDB_ACTION_CALLBACK(x)((int (*)(struct DB_plugin_action_s *action, void *userdata, int ctx))x) +typedef int (*DB_plugin_action_callback_t) (struct DB_plugin_action_s *action, int ctx); +#define DDB_ACTION_CALLBACK(x)((int (*)(struct DB_plugin_action_s *action, int ctx))x) typedef struct DB_plugin_action_s { const char *title; @@ -514,6 +514,18 @@ plug_init_plugin (DB_plugin_t* (*loadfunc)(DB_functions_t *), void *handle) { trace ("\033[0;31mWARNING: plugin \"%s\" has disabled version check. please don't distribute it!\033[0;m\n", plugin_api->name); } #endif + + // deprecated 1.4 DB_plugin_action_t hack + // this allows to check if the action is coming from pre-1.5 plugin without + // having a plugin pointer + if (plugin_api->get_actions && plugin_api->api_vmajor == 1 && plugin_api->api_vminor <= 4) { + DB_plugin_action_t *actions = plugin_api->get_actions (NULL); + while (actions) { + actions->flags |= DB_ACTION_USING_API_14; + actions = actions->next; + } + } + plugin_t *plug = malloc (sizeof (plugin_t)); memset (plug, 0, sizeof (plugin_t)); plug->plugin = plugin_api; |