2 * Copyright (C) 2007 Benjamin Otte <otte@gnome.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library 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 GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301 USA
24 #include "swfdec_system.h"
25 #include "swfdec_debug.h"
30 * SECTION:SwfdecSystem
31 * @title: SwfdecSystem
32 * @short_description: object holding system settings
33 * @see_also: SwfdecPlayer
35 * This object is used to provide information about the system Swfdec currently
38 * Almost all of this information can be categorized into three types:
39 * Information about the current playback engine like manufacturer or version,
40 * information about the current operating system and capabilities of the output
41 * capabilities of the System like screen size.
43 * The information provided by this object is used by the Actionscript
44 * System.capabilities.Query() function that is usually only run once during
45 * initialization of the Flash player. If you want to set custom properties and
46 * have them affect a running #SwfdecPlayer, you should change them before the
47 * player gets initialized.
49 * Note that the System.capabilites object in Flash provides more functionality
50 * than provided by this object. That information can be and is determined
51 * automatically by Swfdec.
57 * This is the object used for holding information about the current system. See
58 * the introduction for details.
61 /*** SwfdecSystem ***/
67 PROP_SERVER_MANUFACTURER
,
81 G_DEFINE_TYPE (SwfdecSystem
, swfdec_system
, G_TYPE_OBJECT
)
84 swfdec_system_get_property (GObject
*object
, guint param_id
, GValue
*value
,
87 SwfdecSystem
*system
= SWFDEC_SYSTEM (object
);
91 g_value_set_boolean (value
, system
->debugger
);
93 case PROP_MANUFACTURER
:
94 g_value_set_string (value
, system
->manufacturer
);
96 case PROP_SERVER_MANUFACTURER
:
97 g_value_set_string (value
, system
->server_manufacturer
);
100 g_value_set_string (value
, system
->os
);
103 g_value_set_string (value
, system
->os_type
);
105 case PROP_PLAYER_TYPE
:
106 g_value_set_string (value
, system
->player_type
);
109 g_value_set_string (value
, system
->version
);
112 g_value_set_string (value
, system
->language
);
114 case PROP_SCREEN_WIDTH
:
115 g_value_set_uint (value
, system
->screen_width
);
117 case PROP_SCREEN_HEIGHT
:
118 g_value_set_uint (value
, system
->screen_height
);
121 g_value_set_double (value
, system
->par
);
124 g_value_set_uint (value
, system
->dpi
);
126 case PROP_COLOR_MODE
:
127 g_value_set_string (value
, system
->color_mode
);
129 case PROP_UTC_OFFSET
:
130 g_value_set_int (value
, system
->utc_offset
);
133 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, param_id
, pspec
);
139 swfdec_system_set_property (GObject
*object
, guint param_id
, const GValue
*value
,
142 SwfdecSystem
*system
= SWFDEC_SYSTEM (object
);
147 system
->debugger
= g_value_get_boolean (value
);
149 case PROP_MANUFACTURER
:
150 s
= g_value_dup_string (value
);
152 g_free (system
->manufacturer
);
153 system
->manufacturer
= s
;
156 case PROP_SERVER_MANUFACTURER
:
157 s
= g_value_dup_string (value
);
159 g_free (system
->server_manufacturer
);
160 system
->server_manufacturer
= s
;
164 s
= g_value_dup_string (value
);
171 s
= g_value_dup_string (value
);
173 g_free (system
->os_type
);
177 case PROP_PLAYER_TYPE
:
178 s
= g_value_dup_string (value
);
180 g_free (system
->player_type
);
181 system
->player_type
= s
;
185 s
= g_value_dup_string (value
);
187 g_free (system
->version
);
192 s
= g_value_dup_string (value
);
194 g_free (system
->language
);
195 system
->language
= s
;
198 case PROP_SCREEN_WIDTH
:
199 system
->screen_width
= g_value_get_uint (value
);
201 case PROP_SCREEN_HEIGHT
:
202 system
->screen_height
= g_value_get_uint (value
);
205 system
->par
= g_value_get_double (value
);
208 system
->dpi
= g_value_get_uint (value
);
210 case PROP_COLOR_MODE
:
211 s
= g_value_dup_string (value
);
213 g_free (system
->color_mode
);
214 system
->color_mode
= s
;
217 case PROP_UTC_OFFSET
:
218 system
->utc_offset
= g_value_get_int (value
);
221 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, param_id
, pspec
);
227 swfdec_system_finalize (GObject
*object
)
229 SwfdecSystem
*system
= SWFDEC_SYSTEM (object
);
231 g_free (system
->manufacturer
);
232 g_free (system
->server_manufacturer
);
234 g_free (system
->os_type
);
235 g_free (system
->player_type
);
236 g_free (system
->version
);
237 g_free (system
->language
);
238 g_free (system
->color_mode
);
240 G_OBJECT_CLASS (swfdec_system_parent_class
)->finalize (object
);
244 swfdec_system_class_init (SwfdecSystemClass
*klass
)
246 GObjectClass
*object_class
= G_OBJECT_CLASS (klass
);
248 object_class
->finalize
= swfdec_system_finalize
;
249 object_class
->get_property
= swfdec_system_get_property
;
250 object_class
->set_property
= swfdec_system_set_property
;
252 g_object_class_install_property (object_class
, PROP_DEBUGGER
,
253 g_param_spec_boolean ("debugger", "debugger", "TRUE if this player is supposed to be a debugger",
254 FALSE
, G_PARAM_READWRITE
| G_PARAM_CONSTRUCT
));
255 g_object_class_install_property (object_class
, PROP_MANUFACTURER
,
256 g_param_spec_string ("manufacturer", "manufacturer", "string describing the manufacturer of this system",
257 "Macromedia Windows", G_PARAM_READWRITE
| G_PARAM_CONSTRUCT
));
258 g_object_class_install_property (object_class
, PROP_SERVER_MANUFACTURER
,
259 g_param_spec_string ("server-manufacturer", "server-manufacturer", "manufacturer of this system as used in serverString",
260 "Adobe Windows", G_PARAM_READWRITE
| G_PARAM_CONSTRUCT
));
261 g_object_class_install_property (object_class
, PROP_OS
,
262 g_param_spec_string ("os", "os", "description of the operating system",
263 "Windows XP", G_PARAM_READWRITE
| G_PARAM_CONSTRUCT
));
264 g_object_class_install_property (object_class
, PROP_OS_TYPE
,
265 g_param_spec_string ("os-type", "os type", "the operating system type: WIN, LIN or MAC",
266 "WIN", G_PARAM_READWRITE
| G_PARAM_CONSTRUCT
));
267 g_object_class_install_property (object_class
, PROP_PLAYER_TYPE
,
268 g_param_spec_string ("player-type", "player type", "\"StandAlone\", \"External\", \"PlugIn\" or \"ActiveX\"",
269 "StandAlone", G_PARAM_READWRITE
| G_PARAM_CONSTRUCT
));
270 g_object_class_install_property (object_class
, PROP_VERSION
,
271 g_param_spec_string ("version", "version", "version string",
272 "WIN 9,0,999,0", G_PARAM_READWRITE
| G_PARAM_CONSTRUCT
));
273 g_object_class_install_property (object_class
, PROP_LANGUAGE
,
274 g_param_spec_string ("language", "language", "ISO 639-1 language code",
275 "en", G_PARAM_READWRITE
| G_PARAM_CONSTRUCT
));
276 g_object_class_install_property (object_class
, PROP_SCREEN_WIDTH
,
277 g_param_spec_uint ("screen-width", "screen width", "width of the screen in pixels",
278 0, G_MAXUINT
, 1024, G_PARAM_READWRITE
| G_PARAM_CONSTRUCT
));
279 g_object_class_install_property (object_class
, PROP_SCREEN_HEIGHT
,
280 g_param_spec_uint ("screen-height", "screen height", "height of the screen in pixels",
281 0, G_MAXUINT
, 768, G_PARAM_READWRITE
| G_PARAM_CONSTRUCT
));
282 g_object_class_install_property (object_class
, PROP_PAR
,
283 g_param_spec_double ("pixel-aspect-ratio", "pixel aspect ratio", "the screen's pixel aspect ratio",
284 G_MINDOUBLE
, G_MAXDOUBLE
, 1.0, G_PARAM_READWRITE
| G_PARAM_CONSTRUCT
));
285 g_object_class_install_property (object_class
, PROP_DPI
,
286 g_param_spec_uint ("dpi", "dpi", "DPI setting of screen",
287 0, G_MAXUINT
, 96, G_PARAM_READWRITE
| G_PARAM_CONSTRUCT
));
288 g_object_class_install_property (object_class
, PROP_COLOR_MODE
,
289 g_param_spec_string ("color-mode", "color mode", "\"color\", \"gray\" or \"bw\"",
290 "color", G_PARAM_READWRITE
| G_PARAM_CONSTRUCT
));
291 g_object_class_install_property (object_class
, PROP_UTC_OFFSET
,
292 g_param_spec_int ("utc-offset", "utc offset",
293 "Difference between UTC and local timezone in minutes",
294 -12 * 60, 12 * 60, 0, G_PARAM_READWRITE
| G_PARAM_CONSTRUCT
));
298 swfdec_system_init (SwfdecSystem
*system
)
305 * Creates a new #SwfdecSystem object using default settings. These settings are
306 * mirroring the most common settings used by a Flash player. Currently this is
307 * equivalent to a Flash player running on Windows XP.
309 * Returns: a new #SwfdecSystem object
312 swfdec_system_new (void)
314 return g_object_new (SWFDEC_TYPE_SYSTEM
, NULL
);