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