File: vala-image-record.vala

package info (click to toggle)
libdmapsharing 3.9.13-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,340 kB
  • sloc: ansic: 17,285; sh: 4,782; xml: 556; makefile: 459
file content (145 lines) | stat: -rw-r--r-- 3,813 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*   FILE: vala-dmap-image-record.vala -- A DMAP.ImageRecord implementation in Vala
 * AUTHOR: W. Michael Petullo <mike@flyn.org>
 *   DATE: 21 December 2010
 *
 * Copyright (c) 2010 W. Michael Petullo <new@flyn.org>
 * All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

private class ValaImageRecord : GLib.Object, Dmap.Record, Dmap.ImageRecord {
	private string _location;
	private string _filename;
	private string _aspect_ratio;
	private string _format;
	private GLib.Array _hash;
	private string _comments;
	private GLib.Array _thumbnail;
	private int _large_filesize;
	private int _pixel_height;
	private int _pixel_width;
	private int _rating;
	private int _creation_date;

	public string location {
		owned get { return _location; }
		set { _location = value; }
	}

	public string filename {
		owned get { return _filename; }
		set { _filename = value; }
	}

	public string aspect_ratio {
		owned get { return _aspect_ratio; }
		set { _aspect_ratio = value; }
	}

	public string format {
		owned get { return _format; }
		set { _format = value; }
	}

	public  GLib.Array<void *> hash {
		owned get { return _hash; }
		set {
			_hash = new GLib.Array<void *> (false, false, 1);
			_hash.append_vals (value.data, value.data.length);
		}
	}

	public GLib.Array<void *> thumbnail {
		owned get { return _thumbnail; }
		set {
			_thumbnail = new GLib.Array<void *> (false, false, 1);
			_thumbnail.append_vals (value.data, value.data.length);
		}
	}

	public string comments {
		owned get { return _comments; }
		set { _comments = value; }
	}

	public int large_filesize {
		get { return _large_filesize; }
		set { _large_filesize = value; }
	}

	public int pixel_height {
		get { return _pixel_height; }
		set { _pixel_height = value; }
	}

	public int pixel_width {
		get { return _pixel_width; }
		set { _pixel_width = value; }
	}

	public int rating {
		get { return _rating; }
		set { _rating = value; }
	}

	public int creation_date {
		get { return _creation_date; }
		set { _creation_date = value; }
	}

	public GLib.InputStream read () throws GLib.Error {
		GLib.error ("read not implemented");
	}

	public unowned bool set_from_blob (GLib.Array<uint8> blob) {
		GLib.error ("set_from_blob not implemented");
	}

	public GLib.Array<uint8> to_blob () {
		GLib.error ("to_blob not implemented");
	}

	public ValaImageRecord () {
		_location = "file://" + GLib.Environment.get_current_dir () + "/media/test.jpeg";
		_aspect_ratio = "1.333";
		_filename = GLib.Path.get_basename (_location);
		_format = "JPEG";
		_comments = "Comments";
		_large_filesize = 13953;
		_pixel_height = 480;
		_pixel_width = 640;
		_rating = 5;
		_creation_date = 0;

		string path = GLib.Environment.get_current_dir () + "/media/test.jpeg";
		uint8[] data;

		try {
			GLib.FileUtils.get_data (path, out data);
		} catch (Error e) {
			stderr.printf("Error: %s\n", e.message);
		}

		_thumbnail = new GLib.Array<uint8> (false, false, 1);
		_thumbnail.append_vals (data, data.length);
	}
}

private class ValaImageRecordFactory : GLib.Object, Dmap.RecordFactory {
	public Dmap.Record create () {
		return new ValaImageRecord ();
	}
}