54 lines2.5 KBC
1/*
2store.h: what the app keeps on the PS3, and where downloads go.
3
4 USRDIR/cache/catalog.json the last index that parsed (the app opens offline)
5 USRDIR/cache/files/<sha256> pages and search.txt files, named by their sha256
6 (a cached one is good exactly when the index's sha256 matches)
7 USRDIR/cache/icons/<id>-<url hash>.jpg icons, fetched once (again when the catalogue moves one)
8 USRDIR/cache/previews/<id>-<url hash> previews (JPEG or PNG), the same
9 USRDIR/downloaded.txt "id<TAB>sha256<TAB>path<TAB>time<TAB>title" for each finished
10 download (before 0.6.0: the first three)
11 USRDIR/settings.txt "avatar_profile=00000001"
12*/
13#ifndef STORE_H
14#define STORE_H
15
16#include "catalog.h"
17
18void store_init(void);
19
20// the cached index (NULL if none, or it no longer parses)
21cat_index_t *store_load_index(void);
22void store_save_index(const char *json, size_t len); // only after it parsed
23
24// a page or search.txt: from the cache if its sha256 matches, else fetched, checked and
25// cached. The bytes (NUL-terminated, caller frees) or NULL with *err_kind / err set
26char *store_get_file(const cat_file_t *f, size_t *len, volatile int *cancel, int *err_kind, char *err, int errsize);
27
28void store_icon_path(const cat_item_t *it, char *out, int size);
29void store_preview_path(const cat_item_t *it, char *out, int size);
30
31// where a finished download of it is, if it's there and still the catalogue's version
32const char *store_downloaded(const cat_item_t *it);
33void store_mark_downloaded(const cat_item_t *it, const char *path);
34
35// the downloads recorded (and still on disk at start), newest first, for My downloads
36typedef struct {
37 const char *id, *sha, *path, *title; // title "" for ones from before 0.6.0
38 long long when, size; // when: time(), 0 if not known
39} store_rec_t;
40int store_num_downloads(void);
41int store_download_at(int i, store_rec_t *out);
42int store_delete_download(int i); // deletes the file and its record; 0 if the file wouldn't go
43
44// where it goes, or why it can't yet (no profile picked...)
45enum { DEST_OK, DEST_NO_PROFILE, DEST_PICK_PROFILE };
46int store_dest(const cat_item_t *it, char *out, int size);
47const char *store_dest_message(int code);
48
49// avatars go into a profile's psn_avatar folder
50int store_profiles(char (*names)[64], int max); // the folders in /dev_hdd0/home
51const char *store_avatar_profile(void); // "" until picked (or there's only one)
52void store_set_avatar_profile(const char *name);
53
54#endif