1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2  *
3  * Copyright (C) 2016 Richard Hughes <richard@hughsie.com>
4  *
5  * SPDX-License-Identifier: LGPL-2.1+
6  */
7 
8 #pragma once
9 
10 #if !defined (__APPSTREAM_GLIB_H_INSIDE__) && !defined (AS_COMPILATION)
11 #error "Only <appstream-glib.h> can be included directly."
12 #endif
13 
14 #include <glib-object.h>
15 
16 G_BEGIN_DECLS
17 
18 #define AS_TYPE_CONTENT (as_content_rating_get_type ())
19 G_DECLARE_DERIVABLE_TYPE (AsContentRating, as_content_rating, AS, CONTENT_RATING, GObject)
20 
21 struct _AsContentRatingClass
22 {
23 	GObjectClass		parent_class;
24 	/*< private >*/
25 	void (*_as_reserved1)	(void);
26 	void (*_as_reserved2)	(void);
27 	void (*_as_reserved3)	(void);
28 	void (*_as_reserved4)	(void);
29 	void (*_as_reserved5)	(void);
30 	void (*_as_reserved6)	(void);
31 	void (*_as_reserved7)	(void);
32 	void (*_as_reserved8)	(void);
33 };
34 
35 /**
36  * AsContentRatingValue:
37  * @AS_CONTENT_RATING_VALUE_UNKNOWN:		Unknown value
38  * @AS_CONTENT_RATING_VALUE_NONE:		None
39  * @AS_CONTENT_RATING_VALUE_MILD:		A small amount
40  * @AS_CONTENT_RATING_VALUE_MODERATE:		A moderate amount
41  * @AS_CONTENT_RATING_VALUE_INTENSE:		An intense amount
42  *
43  * The specified level of an content_rating rating ID.
44  **/
45 typedef enum {
46 	AS_CONTENT_RATING_VALUE_UNKNOWN,
47 	AS_CONTENT_RATING_VALUE_NONE,
48 	AS_CONTENT_RATING_VALUE_MILD,
49 	AS_CONTENT_RATING_VALUE_MODERATE,
50 	AS_CONTENT_RATING_VALUE_INTENSE,
51 	/*< private >*/
52 	AS_CONTENT_RATING_VALUE_LAST
53 } AsContentRatingValue;
54 
55 /**
56  * AsContentRatingSystem:
57  * @AS_CONTENT_RATING_SYSTEM_UNKNOWN: Unknown ratings system
58  * @AS_CONTENT_RATING_SYSTEM_INCAA: INCAA
59  * @AS_CONTENT_RATING_SYSTEM_ACB: ACB
60  * @AS_CONTENT_RATING_SYSTEM_DJCTQ: DJCTQ
61  * @AS_CONTENT_RATING_SYSTEM_GSRR: GSRR
62  * @AS_CONTENT_RATING_SYSTEM_PEGI: PEGI
63  * @AS_CONTENT_RATING_SYSTEM_KAVI: KAVI
64  * @AS_CONTENT_RATING_SYSTEM_USK: USK
65  * @AS_CONTENT_RATING_SYSTEM_ESRA: ESRA
66  * @AS_CONTENT_RATING_SYSTEM_CERO: CERO
67  * @AS_CONTENT_RATING_SYSTEM_OFLCNZ: OFLCNZ
68  * @AS_CONTENT_RATING_SYSTEM_RUSSIA: Russia
69  * @AS_CONTENT_RATING_SYSTEM_MDA: MDA
70  * @AS_CONTENT_RATING_SYSTEM_GRAC: GRAC
71  * @AS_CONTENT_RATING_SYSTEM_ESRB: ESRB
72  * @AS_CONTENT_RATING_SYSTEM_IARC: IARC
73  *
74  * A content rating system for a particular territory.
75  *
76  * Since: 0.7.18
77  */
78 typedef enum {
79 	AS_CONTENT_RATING_SYSTEM_UNKNOWN,
80 	AS_CONTENT_RATING_SYSTEM_INCAA,
81 	AS_CONTENT_RATING_SYSTEM_ACB,
82 	AS_CONTENT_RATING_SYSTEM_DJCTQ,
83 	AS_CONTENT_RATING_SYSTEM_GSRR,
84 	AS_CONTENT_RATING_SYSTEM_PEGI,
85 	AS_CONTENT_RATING_SYSTEM_KAVI,
86 	AS_CONTENT_RATING_SYSTEM_USK,
87 	AS_CONTENT_RATING_SYSTEM_ESRA,
88 	AS_CONTENT_RATING_SYSTEM_CERO,
89 	AS_CONTENT_RATING_SYSTEM_OFLCNZ,
90 	AS_CONTENT_RATING_SYSTEM_RUSSIA,
91 	AS_CONTENT_RATING_SYSTEM_MDA,
92 	AS_CONTENT_RATING_SYSTEM_GRAC,
93 	AS_CONTENT_RATING_SYSTEM_ESRB,
94 	AS_CONTENT_RATING_SYSTEM_IARC,
95 	/*< private >*/
96 	AS_CONTENT_RATING_SYSTEM_LAST
97 } AsContentRatingSystem;
98 
99 AsContentRating	*as_content_rating_new		(void);
100 
101 /* helpers */
102 const gchar	*as_content_rating_value_to_string	(AsContentRatingValue	 value);
103 AsContentRatingValue	 as_content_rating_value_from_string	(const gchar	*value);
104 
105 const gchar	*as_content_rating_system_to_string	(AsContentRatingSystem	 system);
106 gchar		*as_content_rating_system_format_age	(AsContentRatingSystem	 system,
107 							 guint			 age);
108 
109 AsContentRatingSystem	 as_content_rating_system_from_locale	(const gchar	*locale);
110 
111 gchar		**as_content_rating_system_get_formatted_ages	(AsContentRatingSystem	 system);
112 const guint	 *as_content_rating_system_get_csm_ages		(AsContentRatingSystem	 system,
113 								 gsize			*length_out);
114 
115 /* getters */
116 const gchar	*as_content_rating_get_kind	(AsContentRating	*content_rating);
117 guint		 as_content_rating_get_minimum_age (AsContentRating	*content_rating);
118 AsContentRatingValue as_content_rating_get_value (AsContentRating	*content_rating,
119 						 const gchar		*id);
120 void		 as_content_rating_add_attribute(AsContentRating	*content_rating,
121 						 const gchar		*id,
122 						 AsContentRatingValue	 value);
123 
124 const gchar	**as_content_rating_get_rating_ids (AsContentRating	*content_rating);
125 
126 guint		as_content_rating_attribute_to_csm_age (const gchar		*id,
127 							AsContentRatingValue 	 value);
128 AsContentRatingValue	as_content_rating_attribute_from_csm_age	(const gchar	*id,
129 									 guint		 age);
130 const gchar	*as_content_rating_attribute_get_description (const gchar	*id,
131 							      AsContentRatingValue	value);
132 const gchar	**as_content_rating_get_all_rating_ids (void);
133 
134 /* setters */
135 void		 as_content_rating_set_kind	(AsContentRating	*content_rating,
136 						 const gchar		*kind);
137 
138 G_END_DECLS
139