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

« back to all changes in this revision

Viewing changes to src/plugins/tracker/rygel-tracker-item-factory.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:
33
33
public abstract class Rygel.Tracker.ItemFactory {
34
34
    protected enum Metadata {
35
35
        URL,
 
36
        PLACE_HOLDER,
36
37
        FILE_NAME,
37
38
        TITLE,
38
39
        DLNA_PROFILE,
44
45
    }
45
46
 
46
47
    public string category;
 
48
    public string category_iri;
47
49
    public string upnp_class;
48
50
    public string upload_dir;
49
51
 
52
54
    private DLNADiscoverer discoverer;
53
55
 
54
56
    public ItemFactory (string  category,
 
57
                        string  category_iri,
55
58
                        string  upnp_class,
56
59
                        string? upload_dir) {
57
60
        this.category = category;
 
61
        this.category_iri = category_iri;
58
62
        this.upnp_class = upnp_class;
59
63
        this.upload_dir = upload_dir;
60
64
 
 
65
        message ("Using %s as upload directory for %s",
 
66
                 upload_dir == null ? "none" : upload_dir,
 
67
                 upnp_class);
 
68
 
61
69
        // FIXME: In order to work around bug#647575, we take mime-type from
62
70
        //        gupnp-dlna rather than Tracker.
63
71
        this.discoverer = new DLNADiscoverer ((ClockTime) SECOND, true, true);
66
74
 
67
75
        // These must be the same order as enum Metadata
68
76
        this.properties.add ("res");
 
77
        this.properties.add ("place_holder");
69
78
        this.properties.add ("fileName");
70
79
        this.properties.add ("dc:title");
71
80
        this.properties.add ("dlnaProfile");
80
89
                                      string[]        metadata)
81
90
                                      throws GLib.Error;
82
91
 
 
92
    protected void set_ref_id (MediaItem item, string prefix) {
 
93
        if (item.id.has_prefix (prefix)) {
 
94
            return;
 
95
        }
 
96
 
 
97
        var split_id = item.id.split (",");
 
98
        if (split_id.length != 2) {
 
99
            return;
 
100
        }
 
101
 
 
102
        item.ref_id = prefix + "," + split_id[1];
 
103
    }
 
104
 
83
105
    protected virtual void set_metadata (MediaItem item,
84
106
                                         string    uri,
85
107
                                         string[]  metadata) throws GLib.Error {
97
119
            // created).
98
120
            item.size = 0;
99
121
 
 
122
        item.place_holder = bool.parse (metadata[Metadata.PLACE_HOLDER]);
 
123
 
100
124
        if (metadata[Metadata.DATE] != "")
101
125
            item.date = metadata[Metadata.DATE];
102
126