PXML support for file associations, and spitting out extra .desktop files for them...
[pandora-libraries.git] / include / pnd_desktop.h
1
2 #ifndef h_pnd_desktop_h
3 #define h_pnd_desktop_h
4
5 #ifdef __cplusplus
6 extern "C" {
7 #endif
8
9 #define PND_PNDHUP_KEY "launcher.hupscript"
10 #define PND_PNDHUP_FILENAME "pnd_hup.sh"
11
12 // emit_dotdesktop() will determine a filename and create a FILENAME.desktop file in the targetpath
13 // TODO: Copy the icon into this directory as well, if its source is a .pnd or info is in the dico struct
14 #define PND_DOTDESKTOP_HEADER "[Desktop Entry]"
15 #define PND_DOTDESKTOP_SOURCE "X-Pandora-Source=libpnd"
16 unsigned char pnd_emit_dotdesktop ( char *targetpath, char *pndrun, pnd_disco_t *p );
17
18 #define PND_DOTDESKTOP_LIBPND_ONLY 1 /* convenience flag; caller can do this himself as well */
19 pnd_disco_t *pnd_parse_dotdesktop ( char *ddpath, unsigned int flags ); // sets object_flag PND_DISCO_LIBPND_DD for libpnd-origin
20
21 // emit_dotinfo() will spit out a .desktop 'info entry', similar to the way emit_dotdesktop does its thing
22 // - rather than slide this into emit_dotdesktop(), we wish to allow apps to do this or not by calling this
23 //   function, and also let them specify an alternate path to emit to.. without adding all these
24 //   extra fields to emit_dotdesktop()'s function and breaking apps, or annoying callers down the road
25 unsigned char pnd_emit_dotinfo ( char *targetpath, char *pndrun, pnd_disco_t *p );
26
27 // emit_dotassoc() will spit out a .desktop executable entry (more or less similar to the emit_dotdesktop above)
28 // however in this variation the executable line is set up for invokation of a file association instead of the
29 // normal executable line.
30 // - lame code is a copy from emit_dotdesktop() .. I really need to clean this up and paramterize a subfunction..
31 // - this function will emit all file association .desktops (not just one of them)
32 unsigned char pnd_emit_dotassoc ( char *targetpath, char *pndrun, pnd_disco_t *p );
33 unsigned char _pnd_emit_dotassoc ( char *targetpath, char *pndrun, pnd_disco_t *p, unsigned char i ); // will only emit the requested assoc 1, 2, 3
34
35 // emit_icon() will attempt to copy the icon from a PXML directory, or from a pnd file if appended,
36 // to the given directory; returns 1 on sucess, otherwise is a fail.
37 unsigned char pnd_emit_icon ( char *targetpath, pnd_disco_t *p );
38 unsigned char *pnd_emit_icon_to_buffer ( pnd_disco_t *p, unsigned int *r_buflen ); // returns length of malloc in r_buflen if !NULL
39
40 // pnd_map_dotdesktop_categories() will attempt to find an appropriate standard .desktop category(s) based
41 // on the provided PXML-style category.
42 //   In essence, the PXML top-level (and alternate) category will be used, but if (for example) the top
43 // level primary cat is no good, then it will descend into the alternates for that to find the mapping. 
44 //   NOTE: PXML has a prime and alt category, with sub-category; the standard only supports a flat list of
45 // categories to show an entry in (though any number of 'alternates.' so the formats are not directly
46 // compatible.
47 //   Pass in the PXML handle, and the target buffer will be filled up
48 //   Returns the number of successful mappings on success, or -1 for error (0 for no matches of course.)
49 // QUESTION: It possible makes sense to just copy over verbatim any categories that are unmapped, as a 'best guess'
50 //   scenario, but it currently is not coded like that.
51 int pnd_map_dotdesktop_categories ( pnd_conf_handle c, char *target_buffer, unsigned short int len, pnd_disco_t *d ); // <---
52 char *pnd_map_dotdesktop_category ( pnd_conf_handle c, char *single_category ); // not likely needed by anyone
53 // this default is only used if the conf file's "default" key cannot be found, and the category cannot be mapped
54 #define PND_DOTDESKTOP_DEFAULT_CATEGORY "Application;Utility;"
55
56 #ifdef __cplusplus
57 } /* "C" */
58 #endif
59
60 #endif