Rockbox.org home
Downloads
Release release
Dev builds dev builds
Extras extras
themes themes
Documentation
Manual manual
Wiki wiki
Device Status device status
Support
Forums forums
Mailing lists mailing lists
IRC IRC
Development
Bugs bugs
Patches patches
Dev Guide dev guide
Search



Donate

Rockbox Technical Forums


Login with username, password and session length
Home Help Search Staff List Login Register
News:

Welcome to the Rockbox Technical Forums!

+  Rockbox Technical Forums
|-+  Rockbox Development
| |-+  Starting Development and Compiling
| | |-+  Executing a file from a plugin
« previous next »
  • Print
Pages: [1]

Author Topic: Executing a file from a plugin  (Read 1748 times)

Offline Job Van Dam

  • Member
  • *
  • Posts: 167
Executing a file from a plugin
« on: October 31, 2007, 02:00:56 AM »
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.
Logged

Offline linuxstb

  • Developer
  • Member
  • *
  • Posts: 1163
Re: Executing a file from a plugin
« Reply #1 on: October 31, 2007, 04:17:44 AM »
I think you want:

bool settings_load_config(const char* file, bool apply)

which is defined in apps/settings.c
Logged

Offline Job Van Dam

  • Member
  • *
  • Posts: 167
Re: Executing a file from a plugin
« Reply #2 on: October 31, 2007, 01:20:04 PM »
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?
Logged

Offline linuxstb

  • Developer
  • Member
  • *
  • Posts: 1163
Re: Executing a file from a plugin
« Reply #3 on: October 31, 2007, 05:06:07 PM »
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().
Logged

Offline Job Van Dam

  • Member
  • *
  • Posts: 167
Re: Executing a file from a plugin
« Reply #4 on: October 31, 2007, 06:27:14 PM »
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.
Logged

  • Print
Pages: [1]
« previous next »
+  Rockbox Technical Forums
|-+  Rockbox Development
| |-+  Starting Development and Compiling
| | |-+  Executing a file from a plugin
 

  • SMF 2.0.17 | SMF © 2019, Simple Machines
  • Rockbox Privacy Policy
  • XHTML
  • RSS
  • WAP2

Page created in 0.072 seconds with 15 queries.