Rockbox Development > Starting Development and Compiling
Executing a file from a plugin
(1/1)
Job Van Dam:
I've created a small plugin that selects a random .cfg file from the themes folder.
I've written the code all the way up to the point where it selects a random .cfg file but I can't find the way to actually execute it. I've tried:
open(const char* pathname, int flags);
and that seems to open the file for actual reading.
set_current_file(char* path);
I tried this one too and it doesn't work. I'm not sure what it does...
Any help would be greatly appreciated. I've been toiling on this plugin for 3 long, hard days considering I don't know C I'm kinda proud of what I've accomplished but I just wanna get this thing working and behind me. Thank you.
linuxstb:
I think you want:
bool settings_load_config(const char* file, bool apply)
which is defined in apps/settings.c
Job Van Dam:
Thanks alot for the help but for seem reason I'm getting a undefined reference to "_settings_load_config" error. It's spelled properly in my code, the error message puts an underscore at the begining for some reason.
I put #include "settings.h" at the top of the file and I'm passing the settings_load_config() a char variable with the full path to the file and true as the second argument.
I've tried #include "settings.c" and that gave me an error about lang something. I didn't pursue that because I've never seen a file that actually calls the c file.
I've looked at other plugins include's and they don't have to specify the path to the header file, even still I tried specifying the path(../settings.h) with no luck. text_editor.c include's action.h which is in the apps folder with no problems but then again I can't seem to find what exactly it uses from that particular file.
In the comments of settings.h it says **function prototypes** above the function. I'm not completely versed in function prototypes but from what I read does that mean I gotta rewrite settings_load_config() function? Is there a way to just use the existing function there?
linuxstb:
You can't access core Rockbox functions directly in plugins - you have to access them via the plugin API. Plugins MUST NOT #include any header files apart from plugin.h and the headers in the plugin library (apps/plugins/lib/).
Functions are only added to the plugin API as they are needed by plugins - settings_load_config() isn't there, so you would need to add it. If you look at apps/plugin.c and apps/plugin.h (and read the comments) it should be obvious how to add an extra function.
In your plugin, you then call rb->settings_load_config().
Job Van Dam:
HiYOOOOO!
Got it to work!
Thank you very much linuxstb. I can't thank you enough. I owe you one buddy. If you ever want a theme made or you need something in Canada I'm your guy. I :heart: teh linuxstb.
Seriously thank you very much.
Navigation
[0] Message Index
Go to full version