Adding argument support to PXML; pnd_run.sh already had it, but PXML did not.
[pandora-libraries.git] / include / pnd_discovery.h
1
2 #ifndef h_pnd_discovery_h
3 #define h_pnd_discovery_h
4
5 #ifdef __cplusplus
6 extern "C" {
7 #endif
8
9 // this code is for doing the application discovery against a given directory and its children (ie: this
10 // code could be called on appliction startup, or as a result of media eject/insert, and so forth.)
11
12 /* disco_search() will walk the given search path (one or more paths, colon separated) in order left to
13  * right; as PXML's are found, basic analysis is performed to verfy validity. A list of valid applications
14  * is returned, the union of all matches in the search path
15  * If no matches are found, NULL is returned (to save you deleting the container)
16  * overridespath may be NULL if you do not wish to search for pxml overrides
17  */
18 pnd_box_handle pnd_disco_search ( char *searchpath, char *overridespath );
19
20 /* pnd_disco_t describes a given entry found by the discovery code; ie: the containers key is the path to
21  * the PXML file (since this is relatively unique), with the fields below detailing the executable path,
22  * application name, unique-id and so on
23  *
24  * NOTE: this struct is dynamicly populated; you are responsible for invoking the destroy() function to
25  * kill its contents, and the pnt_box_destroy() to kill the container at the end
26  *
27  * NOTE: The PXML path (or .pnd file path in bundle files) is used as a key since it is unique. The
28  * application 'unique id' will be unique for a given app, but that app could be in multiple directories
29  * or on multiple SD cards or wifi or whatever, so only the mounted path is truly unique. The key
30  * is only used internally so the consumer can refer to multiple versions of the same app without
31  * confusion.. it is not displayed. So no big deal.
32  */
33
34 typedef enum {
35   pnd_object_type_unknown = 0,
36   pnd_object_type_directory,
37   pnd_object_type_pnd,
38   pnd_object_type_max
39 } pnd_object_type_t;
40
41 // another struct? Have always intended discovery_t to have minimal members.. just enough to lead to an
42 // application (PXML, xecutable, name); if the apps want more details, they can use the pnd_pxml code to
43 // fetch the full PXML and get all the details. But I think we got out of control here :)
44 // NOTE: We really need to rework disco-t so it can include non-english titles/desc; perhaps more info as optional,
45 //   or a name/value pairing system so it can have extra data in it, without a complex structure.
46 typedef struct {
47   // base
48   unsigned char object_type;   // see enum above
49   char *object_path;           // directory containing pnd or PXML.xml (does not include filename)
50   char *object_filename;       // filename within object_path of the app: the PXML.xml or awesomeapp.pnd file itself
51   unsigned int pnd_icon_pos;   // offset to the byte after end of PXML in a pnd file (should be icon if present)
52   unsigned char subapp_number; // # of app within PXML (ie: 0, 1, 2, 3, up to the number of apps within the PXML)
53   // strdup'd from PXML -- hey, who was the idiot who thought it was a reat idea not to just re-use the pxml-struct?
54   char *title_en;
55   char *desc_en;
56   char *unique_id;
57   char *icon;
58   char *exec;
59   char *execargs;
60   char *clockspeed;
61   char *startdir;
62   char *option_no_x11;
63   char *main_category;
64   char *main_category1;
65   char *main_category2;
66   char *alt_category;
67   char *alt_category1;
68   char *alt_category2;
69   char *preview_pic1;
70   char *preview_pic2;
71   char *mkdir_sp;
72 } pnd_disco_t;
73
74 void pnd_disco_destroy ( pnd_disco_t *p ); // a function name that simply could not be avoided
75
76 // TODO: A way to release the disco-lists and reclaim RAM :)
77
78 #ifdef __cplusplus
79 } /* "C" */
80 #endif
81
82 #endif