| 1 | /* |
| 2 | store.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 |
|
| 18 | void store_init(void); |
| 19 |
|
| 20 | // the cached index (NULL if none, or it no longer parses) |
| 21 | cat_index_t *store_load_index(void); |
| 22 | void 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 |
| 26 | char *store_get_file(const cat_file_t *f, size_t *len, volatile int *cancel, int *err_kind, char *err, int errsize); |
| 27 |
|
| 28 | void store_icon_path(const cat_item_t *it, char *out, int size); |
| 29 | void 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 |
| 32 | const char *store_downloaded(const cat_item_t *it); |
| 33 | void 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 |
| 36 | typedef 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; |
| 40 | int store_num_downloads(void); |
| 41 | int store_download_at(int i, store_rec_t *out); |
| 42 | int 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...) |
| 45 | enum { DEST_OK, DEST_NO_PROFILE, DEST_PICK_PROFILE }; |
| 46 | int store_dest(const cat_item_t *it, char *out, int size); |
| 47 | const char *store_dest_message(int code); |
| 48 |
|
| 49 | // avatars go into a profile's psn_avatar folder |
| 50 | int store_profiles(char (*names)[64], int max); // the folders in /dev_hdd0/home |
| 51 | const char *store_avatar_profile(void); // "" until picked (or there's only one) |
| 52 | void store_set_avatar_profile(const char *name); |
| 53 |
|
| 54 | #endif |