New exec(disco-t) for more flexible pnd exec. PXML may specify appdata dirname, and...
[pandora-libraries.git] / include / pnd_apps.h
1
2 #ifndef h_pnd_apps_h
3 #define h_pnd_apps_h
4
5 #ifdef __cplusplus
6 extern "C" {
7 #endif
8
9 #include "pnd_container.h"
10 #include "pnd_discovery.h"
11
12 // default application searchpath (and key to look it up in config)
13 #define PND_APPS_SEARCHPATH "/media/*/pandora/apps:/usr/pandora/apps"
14 #define PND_APPS_KEY "autodiscovery.searchpath"
15
16 #define PND_APPS_APPDATA_PREFIX "/pandora/appdata" /* /media/DEVNAME + PREFIX + unique-id */
17
18 // default notify searchpath (and key to look it up in config)
19 #define PND_APPS_NOTIFYPATH "/media:/media/*/pandora/apps:/usr/pandora/apps"
20 #define PND_APPS_NOTIFY_KEY "autodiscovery.notifypath"
21
22 #define PND_PNDRUN_SEARCHPATH_KEY "pnd.searchpath"
23 #define PND_PNDRUN_KEY "pnd.runscript"
24 #define PND_PNDRUN_FILENAME "pnd_run.sh"
25 #define PND_PNDRUN_DEFAULT "/usr/pandora/scripts/pnd_run.sh"
26
27 #define PND_PXML_OVERRIDE_SEARCHPATH "~/pxml-overrides"
28 #define PND_PXML_OVERRIDE_KEY "overrides.searchpath"
29
30 #define PND_MOUNT_PATH "/mnt/pnd/" /* all mounted PND images should be here.. /mnt/apps/UNIQUE-ID/... */
31
32 // .desktop support
33 #define PND_DESKTOP_DOTDESKTOP_PATH_KEY "desktop.dotdesktoppath"
34 #define PND_DESKTOP_ICONS_PATH_KEY "desktop.iconpath"
35 #define PND_DESKTOP_SEARCH_KEY "desktop.searchpath"
36
37 #define PND_MENU_DOTDESKTOP_PATH_KEY "menu.dotdesktoppath"
38 #define PND_MENU_ICONS_PATH_KEY "menu.iconpath"
39 #define PND_MENU_SEARCH_KEY "menu.searchpath"
40
41 #define PND_DESKTOP_DOTDESKTOP_PATH_DEFAULT "~/.applications"
42 #define PND_DESKTOP_ICONS_PATH_DEFAULT "~/.applications"
43 #define PND_DESKTOP_SEARCH_PATH_DEFAULT "/media/*/pandora/desktop:/usr/pandora/apps"
44
45 // apps
46 #define PND_DEFAULT_WORKDIR "./"
47
48 /* pnd_apps_exec() is used to blindly launch an app, be it a .pnd file bundle or a plain executable
49  * (shell, bin, whatever.) pndrun specifies the full path to the pnd_run sh script, which should be
50  * found using searchpaths and locates.. see locatetest.c for a sample
51  * pnd_run, fullpath, unique_id, rel_exec required
52  * rel_startdir, clockspeed, options are optional
53  * NOTE: Use pnd_locate function to locate the pnd_run, for example
54  * NOTE: if specified, clock speed will be set prior to invoking the script, and set back on exit
55  * NOTE: No values can be except clockspeed; a 0 clockspeed means 'leave alone'. Set startdoir to "." instead of NULL.
56  * fork() is implied; calling this function does not kill this process :)
57  * NOTE: Pass in the full path to the awesomeapp.pnd or to the directory containing PXML.xml (not the PXML.xml itself.)
58  * Options is a set of boolean flags, derived from the #define's below; OR them together.
59  *   option-block, when set, suggests the launch should wait until the invoked application exits (disregarding why app exits)
60  *   example: options = PND_EXEC_OPTION_BLOCK | PND_EXEC_OPTION_2;
61  */
62 #define PND_EXEC_OPTION_NIL        0
63 #define PND_EXEC_OPTION_BLOCK      1 /* wait till children complete; note, children might fork on their own.. */
64 #define PND_EXEC_OPTION_NOUNION    2 /* request pnd_run not use a union, just do the mount/run */
65 #define PND_EXEC_OPTION_NOX11      4 /* request pnd_run to kill x11 and restart it after */
66 #define PND_EXEC_OPTION_NORUN      8 /* don't try to run; just form the pnd_run.sh line and cache it */
67 #define PND_EXEC_OPTION_FUTURE2   16
68
69 unsigned char pnd_apps_exec ( char *pndrun, char *fullpath, char *unique_id,
70                               char *rel_exec, char *rel_startdir,
71                               char *args,
72                               unsigned int clockspeed, unsigned int options );
73 char *pnd_apps_exec_runline ( void ); // returns the cached pnd_run.sh line from last PND_EXEC_OPTION_NORUN
74
75 // this is a superior version of pnd_apps_exec(), but avoiding breaking the pnd_apps_exec() API to
76 // extend it.
77 // - same option booleans
78 // - 'reserved' should be NULL unless you know what to put there (depends on options)
79 // - 'app' should be a return from discovery, or a populated disco-t struct
80 // - 'pndrun' is a reference to a pnd_run.sh script, to avoid seeking it out every time
81 unsigned char pnd_apps_exec_disco ( char *pndrun, pnd_disco_t *app, unsigned int options, void *reserved );
82
83 // should you wish to know where an app will get mounted, call this function to obtain a guess. The
84 // logic is wrapped up in pnd_run.sh, but in theory should be easily determined.
85
86 // get_appdata_path() is the one you probably want.. the appdata path (which includes both the
87 // files in the pnd, and any files updated/written-out from that app. Look up aufs or union-filesystems.)
88 // ie: appdata path is read/write, while ro_mountpoint is read-only
89 // Returns >0 on success, and if not-NULL will fill r_path (up to path_len length.)
90 unsigned char pnd_get_appdata_path ( char *fullpath, char *unique_id, char *r_path, unsigned int path_len );
91 // get_ro_mountpoint() returns the _read only_ mountpoint, where the dir or .pnd is actually
92 // mounted to. This is probably NOT WHAT YOU WANT. You probably want the read/write mountpoint, which
93 // is the union-filesystem version of it.. see pnd_get_appdata_path()
94 //   r_mountpoint (if !NULL) will be populated; mountpoint_len should specify the maxlen of the buffer
95 void pnd_get_ro_mountpoint ( char *fullpath, char *unique_id, char *r_mountpoint, unsigned int mountpoint_len );
96
97 #ifdef __cplusplus
98 } /* "C" */
99 #endif
100
101 #endif