summaryrefslogtreecommitdiff
path: root/apps/open_plugin.h
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2020-07-31 22:45:10 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2020-08-17 10:15:14 -0400
commit35502834423049b319fde41ff305b48de67d2d51 (patch)
tree00d638d9348cd38f15cf6d341e700bc36153b3f8 /apps/open_plugin.h
parentd553bb1149800daf16dcb92bc0608fe6248e1dab (diff)
Add open_plugin to core
open_plugin allows arbitrary plugins to be called in hotkey and start screen replaces PictureFlow Integration shortcuts menu plays plugins now too rather than store paths and parameters in the settings that reside in memory instead entries in a file are searched by hash. after all, the plugin has to be loaded from disk anyways ---------------------------------------------------------------------------- shortcut_viewer.rock-- can now call plugins rather than taking you to them in the browser ----------------------------------------------------------------------------- Added a new option to menus: F_CB_ON_SELECT_ONLY instead of option callback every time a item is accessed F_CB_ON_SELECT_ONLY fires callback only when item is selected ----------------------------------------------------------------------------- Added manual entries ----------------------------------------------------------------------------- Change-Id: I078b57b1d2b4dd633c89212c1082fcbc1b516e6a
Diffstat (limited to 'apps/open_plugin.h')
-rw-r--r--apps/open_plugin.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/apps/open_plugin.h b/apps/open_plugin.h
new file mode 100644
index 0000000000..2d8a527073
--- /dev/null
+++ b/apps/open_plugin.h
@@ -0,0 +1,66 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2020 by William Wilgus
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef OPEN_PLUGIN_H
+#define OPEN_PLUGIN_H
+
+/* Open_plugin module
+ * OP stores and retrieves plugin path and parameters by key
+ * from a dictionary file
+ *
+ * plugins can load other plugins
+ * return rb->plugin_open(path, parameter);
+ */
+
+#ifndef __PCTOOL__
+/* open_plugin path lookup */
+#define OPEN_PLUGIN_DAT PLUGIN_DIR "/plugin.dat"
+#define OPEN_PLUGIN_BUFSZ MAX_PATH
+#define OPEN_PLUGIN_NAMESZ 32
+struct open_plugin_entry_t
+{
+ uint32_t hash;
+ int32_t lang_id;
+ char name[OPEN_PLUGIN_NAMESZ+1];
+ /*char key[OPEN_PLUGIN_BUFSZ+1];*/
+ char path[OPEN_PLUGIN_BUFSZ+1];
+ char param[OPEN_PLUGIN_BUFSZ+1];
+};
+
+inline static void open_plugin_get_hash(const char *key, uint32_t *hash)
+{
+ /* Calculate modified FNV1a hash of string */
+ const uint32_t p = 16777619;
+ *hash = 0x811C9DC5; //seed, 2166136261;
+ while(*key)
+ *hash = (*key++ ^ *hash) * p;
+}
+
+#ifndef PLUGIN
+extern struct open_plugin_entry_t open_plugin_entry;
+uint32_t open_plugin_add_path(const char *key, const char *plugin, const char *parameter);
+int open_plugin_get_entry(const char *key, struct open_plugin_entry_t *entry);
+void open_plugin_browse(const char *key);
+void open_plugin_remove(const char *key);
+int open_plugin_run(const char *key);
+#endif
+
+#endif /*ndef __PCTOOL__ */
+#endif /* OPEN_PLUGIN_H */