~ubuntu-branches/ubuntu/trusty/rygel/trusty

« back to all changes in this revision

Viewing changes to src/rygel/rygel-thumbnailer.vala

  • Committer: Package Import Robot
  • Author(s): Andreas Henriksson
  • Date: 2011-12-16 15:21:25 UTC
  • mfrom: (14.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20111216152125-qgn31dkfmhouhrf0
Upload to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
    private Thumbnail template;
40
40
    private string extension;
41
41
 
 
42
    private DbusThumbnailer thumbler = null;
 
43
 
42
44
    private Thumbnailer () throws ThumbnailerError {
43
45
        var dir = Path.build_filename (Environment.get_home_dir (),
44
46
                                       ".thumbnails",
72
74
        }
73
75
 
74
76
        this.directory = dir;
 
77
 
 
78
        try {
 
79
            this.thumbler = new DbusThumbnailer ();
 
80
       } catch (GLib.Error error) { }
 
81
 
75
82
    }
76
83
 
77
84
    public static Thumbnailer? get_default () {
88
95
        return thumbnailer;
89
96
    }
90
97
 
91
 
    public Thumbnail get_thumbnail (string uri) throws Error {
 
98
    public Thumbnail get_thumbnail (string uri, string mime_type) throws Error {
92
99
        Thumbnail thumbnail = null;
93
100
 
94
101
        var path = Checksum.compute_for_string (ChecksumType.MD5, uri) +
96
103
        var full_path = Path.build_filename (this.directory, path);
97
104
        var file = File.new_for_path (full_path);
98
105
 
 
106
        // send a request to create thumbnail if it does not exist
 
107
        if ((this.thumbler != null) && (!file.query_exists ())) {
 
108
            this.thumbler.queue_thumbnail_task (uri, mime_type);
 
109
        }
 
110
 
99
111
        var info = file.query_info (FILE_ATTRIBUTE_ACCESS_CAN_READ + "," +
100
112
                                    FILE_ATTRIBUTE_STANDARD_SIZE,
101
113
                                    FileQueryInfoFlags.NONE,
106
118
                                        (_("No thumbnail available"));
107
119
        }
108
120
 
109
 
        thumbnail = new Thumbnail ();
 
121
        thumbnail = new Thumbnail (this.template.mime_type,
 
122
                                   this.template.dlna_profile,
 
123
                                   this.template.file_extension);
110
124
        thumbnail.width = this.template.width;
111
125
        thumbnail.height = this.template.height;
112
126
        thumbnail.depth = this.template.depth;