6ee21083f8547df0e3e2e814cac359aa9c24eabf
[pandora-libraries.git] / minimenu / mmcat.h
1
2 #ifndef h_mmcat_h
3 #define h_mmcat_h
4
5 /* code for storing/retrieving/messing with 'categories' (ie: tabs, more or less)
6  */
7
8 // an appreg is a minimenu registered app, that in turn points to the libpnd disco-t entry, but also stores anything
9 // minimenu specific about it.
10 typedef struct _mm_appref_t {
11   pnd_disco_t *ref;
12   pnd_conf_handle ovrh;
13   // anything else?
14   struct _mm_appref_t *next;
15 } mm_appref_t;
16
17 // an actual category reference; points to a list of appref's and supplies a tabname, a filesystem mountpoint, etc.
18 typedef struct _mm_category_t {
19   char *catname;          // name of the category
20   char *parent_catname;   // if known, parent cat name
21   unsigned int catflags;  // flags
22
23   // current applications
24   mm_appref_t *refs;      // apps (from g_active_apps) that are in this category
25   unsigned int refcount;  // how many apps in this category
26
27   // if a directory browser category, additional info is needed
28   char *fspath;           // NULL if a pnd-category (not a filesystem category)
29   pnd_box_handle disco;   // faux-applications generated from filesystem (so that refs can point to here)
30
31 } mm_category_t;
32
33 // the flags available for the above mm_category_t.catflags
34 #define CFNORMAL 1 // catflag
35 #define CFHIDDEN 2 // catflag: 1, 2, 4,...
36 #define CFSUBCAT 4 // catflag
37
38 // how many cats can we handle?
39 #define MAX_CATS 250
40
41 // what do we call the "All" tab, if present
42 #define CATEGORY_ALL "All"
43
44 // try to populate as many cats as necessary
45 void category_init ( void ); // set up; call first!
46 unsigned char category_push ( char *catname, char *parentcatname, pnd_disco_t *app, pnd_conf_handle ovrh, char *fspath, unsigned char visiblep ); // catname is not pulled from app, so we can make them up on the fly (ie: "All");
47 void category_dump ( void ); // sort the apprefs
48 void category_freeall ( void );
49 int cat_sort_score ( mm_category_t *cat, mm_appref_t *s1, mm_appref_t *s2 ); // like strcmp, but used to sort apps by title
50 void category_sort ( void ); // for sorting categories
51
52 // category mapping hack
53 typedef struct {
54   mm_category_t *target;  // mapping a category _to_ this other category
55   char *from;             // from this category
56 } mm_catmap_t;
57
58 unsigned char category_map_setup ( void ); // set up the mappings
59 mm_category_t *category_map_query ( char *cat );
60 unsigned char category_meta_push ( char *catname, char *parentcatname, pnd_disco_t *app, pnd_conf_handle ovrh, unsigned char visiblep, unsigned char parentp );
61
62 // filesystem browser
63 unsigned char category_fs_restock ( mm_category_t *cat );
64
65 // apps within cats
66 unsigned char category_contains_app ( char *catname, char *parentcatname, char *unique_id );
67
68 // advertising to rest of the system
69 //
70 extern mm_category_t *g_categories [ MAX_CATS ];
71 extern unsigned char g_categorycount;
72 #define CFALL    0xFF // filter mask
73 #define CFBYNAME 0xFE // filter mask; the name param is used to pick a single category to populate
74 void category_publish ( unsigned int filter_mask, char *param ); // populates g_categories and g_categorycount; pass in CFNORMAL or CFHIDDEN or CFALL or whatever
75 unsigned int category_count ( unsigned int filter_mask );
76 int category_index ( char *catname ); // figure out index in g_categories of named cat
77
78 #endif