~jpakkane/mediascanner/quickfix

« back to all changes in this revision

Viewing changes to src/mediascanner/mediaartcache.h

  • Committer: Tarmac
  • Author(s): Jussi Pakkanen
  • Date: 2013-08-29 14:22:59 UTC
  • mfrom: (370.3.15 media-scanner)
  • Revision ID: tarmac-20130829142259-074e8px82vtyq0od
A class to store image data of media elements.

Approved by James Henstridge, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 * Contact: Jim Hodapp <jim.hodapp@canonical.com>
 
18
 * Authored by: Jussi Pakkanen <jussi.pakkanen@canonical.com>
 
19
 */
 
20
 
 
21
#ifndef MEDIAARTCACHE_H
 
22
#define MEDIAARTCACHE_H
 
23
 
 
24
#include<string>
 
25
 
 
26
namespace mediascanner {
 
27
 
 
28
/*
 
29
 * A class to store thumbnails for files according to
 
30
 * https://wiki.gnome.org/MediaArtStorageSpec
 
31
 *
 
32
 * As this class deals mostly with the filesystem, all
 
33
 * errors are reported with runtime_error exceptions.
 
34
 */
 
35
 
 
36
 
 
37
class MediaArtCache {
 
38
private:
 
39
    std::string root_dir;
 
40
 
 
41
    std::string compute_base_name(const std::string &artist, const std::string &album) const;
 
42
    std::string get_full_filename(const std::string &artist, const std::string & album) const;
 
43
 
 
44
public:
 
45
    static const unsigned int MAX_SIZE = 200;
 
46
 
 
47
    MediaArtCache();
 
48
    bool has_art(const std::string &artist, const std::string &album) const;
 
49
    void add_art(const std::string &artist, const std::string &album,
 
50
            char *data, unsigned int datalen);
 
51
    std::string get_art_file(const std::string &artist, const std::string &album) const;
 
52
    void clear() const;
 
53
    void prune();
 
54
    std::string get_cache_dir() const { return root_dir; }
 
55
};
 
56
 
 
57
}
 
58
 
 
59
#endif