on 551c708 help sign in
unity8/plugins/Utils/mediaartcache.h
54 lines 1.8 kB history raw
1/*
2 * This file is part of the Ubuntu TV Media Scanner
3 * Copyright (C) 2012-2013 Canonical Ltd.
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authored by: Jussi Pakkanen <jussi.pakkanen@canonical.com>
18 */
20#ifndef MEDIAARTCACHE_H
21#define MEDIAARTCACHE_H
23#include<string>
25/*
26 * A class to store thumbnails for files according to
27 * https://wiki.gnome.org/MediaArtStorageSpec
28 *
29 * As this class deals mostly with the filesystem, all
30 * errors are reported with runtime_error exceptions.
31 */
34class MediaArtCache {
35private:
36 std::string root_dir;
38 std::string compute_base_name(const std::string &artist, const std::string &album) const;
39 std::string get_full_filename(const std::string &artist, const std::string & album) const;
41public:
42 static const unsigned int MAX_SIZE = 200;
44 MediaArtCache();
45 bool has_art(const std::string &artist, const std::string &album) const;
46 void add_art(const std::string &artist, const std::string &album,
47 char *data, unsigned int datalen);
48 std::string get_art_file(const std::string &artist, const std::string &album) const;
49 void clear() const;
50 void prune();
51 std::string get_cache_dir() const { return root_dir; }
52};
54#endif