2 * irreco - Ir Remote Control
3 * Copyright (C) 2008 Joni Kokko (t5kojo01@students.oamk.fi)
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include "irreco_webdb_remote.h"
23 * @addtogroup IrrecoWebdbRemote
24 * @ingroup IrrecoWebdb
26 * Contains information of remote.
33 * Source file of @ref IrrecoWebdbRemote.
36 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
38 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
41 * @name Construction & Destruction
45 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
46 /* Construction & Destruction */
47 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
48 IrrecoWebdbRemote
*irreco_webdb_remote_new()
50 IrrecoWebdbRemote
*self
;
53 self
= g_slice_new0(IrrecoWebdbRemote
);
56 self
->name
= g_string_new("");
57 self
->creator
= g_string_new("");
58 self
->comment
= g_string_new("");
59 self
->category
= g_string_new("");
60 self
->manufacturer
= g_string_new("");
61 self
->model
= g_string_new("");
62 self
->file_hash
= g_string_new("");
63 self
->file_name
= g_string_new("");
64 self
->uploaded
= g_string_new("");
65 self
->modified
= g_string_new("");
66 self
->downloaded
= g_string_new("");
67 self
->download_count
= 0;
69 self
->configurations
= NULL
;
73 IRRECO_RETURN_PTR(self
);
76 void irreco_webdb_remote_free(IrrecoWebdbRemote
*self
)
80 g_assert(self
!= NULL
);
82 g_string_free(self
->name
, TRUE
);
85 g_string_free(self
->creator
, TRUE
);
88 g_string_free(self
->comment
, TRUE
);
91 g_string_free(self
->category
, TRUE
);
92 self
->category
= NULL
;
94 g_string_free(self
->manufacturer
, TRUE
);
95 self
->manufacturer
= NULL
;
97 g_string_free(self
->model
, TRUE
);
100 g_string_free(self
->file_hash
, TRUE
);
101 self
->file_hash
= NULL
;
103 g_string_free(self
->file_name
, TRUE
);
104 self
->file_name
= NULL
;
106 g_string_free(self
->uploaded
, TRUE
);
107 self
->uploaded
= NULL
;
109 g_string_free(self
->modified
, TRUE
);
110 self
->modified
= NULL
;
112 g_string_free(self
->downloaded
, TRUE
);
113 self
->downloaded
= NULL
;
115 if (self
->configurations
!= NULL
) {
116 g_list_free(self
->configurations
);
117 self
->configurations
= NULL
;
119 if (self
->themes
!= NULL
) {
120 g_list_free(self
->themes
);
124 g_slice_free(IrrecoWebdbRemote
, self
);
132 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
133 /* Private Functions */
134 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
137 * @name Public Functions
142 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
144 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
146 void irreco_webdb_remote_set(IrrecoWebdbRemote
*self
,
151 const char *category
,
152 const char *manufacturer
,
154 const char *file_hash
,
155 const char *file_name
,
156 const char *uploaded
,
157 const char *modified
,
158 const char *downloaded
,
163 g_assert(self
!= NULL
);
166 g_string_printf(self
->name
, "%s", name
);
167 g_string_printf(self
->creator
, "%s", creator
);
168 g_string_printf(self
->comment
, "%s", comment
);
169 g_string_printf(self
->category
, "%s", category
);
170 g_string_printf(self
->manufacturer
, "%s", manufacturer
);
171 g_string_printf(self
->model
, "%s", model
);
172 g_string_printf(self
->file_hash
, "%s", file_hash
);
173 g_string_printf(self
->file_name
, "%s", file_name
);
174 g_string_printf(self
->uploaded
, "%s", uploaded
);
175 g_string_printf(self
->modified
, "%s", modified
);
176 g_string_printf(self
->downloaded
, "%s", downloaded
);
177 self
->download_count
= download_count
;
182 void irreco_webdb_remote_add_configuration_id(IrrecoWebdbRemote
*self
, gint id
)
186 g_assert(self
!= NULL
);
188 self
->configurations
= g_list_append(self
->configurations
,
189 GINT_TO_POINTER(id
));
191 self
->configurations
= g_list_first(self
->configurations
);
196 void irreco_webdb_remote_add_theme_id(IrrecoWebdbRemote
*self
, gint id
)
200 g_assert(self
!= NULL
);
202 self
->themes
= g_list_append(self
->themes
, GINT_TO_POINTER(id
));
204 self
->themes
= g_list_first(self
->themes
);
209 void irreco_webdb_remote_print(IrrecoWebdbRemote
*self
)
211 GList
*configurations
;
215 g_assert(self
!= NULL
);
217 IRRECO_PRINTF("ID: %d\n", self
->id
);
218 IRRECO_PRINTF("Name: %s\n", self
->name
->str
);
219 IRRECO_PRINTF("Creator: %s\n", self
->creator
->str
);
220 IRRECO_PRINTF("Comment: %s\n", self
->comment
->str
);
221 IRRECO_PRINTF("Category: %s\n", self
->category
->str
);
222 IRRECO_PRINTF("Manufacturer: %s\n", self
->manufacturer
->str
);
223 IRRECO_PRINTF("Model: %s\n", self
->model
->str
);
224 IRRECO_PRINTF("File hash: %s\n", self
->file_hash
->str
);
225 IRRECO_PRINTF("File name: %s\n", self
->file_name
->str
);
226 IRRECO_PRINTF("Uploaded: %s\n", self
->uploaded
->str
);
227 IRRECO_PRINTF("Modified: %s\n", self
->modified
->str
);
228 IRRECO_PRINTF("Last download: %s\n", self
->downloaded
->str
);
229 IRRECO_PRINTF("Download_count: %d\n", self
->download_count
);
231 configurations
= g_list_first(self
->configurations
);
232 if (configurations
!= NULL
) IRRECO_PRINTF("Configurations:");
233 while(configurations
) {
234 g_print(" (%d)", GPOINTER_TO_INT(configurations
->data
));
236 configurations
= configurations
->next
;
239 themes
= g_list_first(self
->themes
);
240 if (themes
!= NULL
) IRRECO_PRINTF("Themes:");
242 g_print(" (%d)", GPOINTER_TO_INT(themes
->data
));
244 themes
= themes
->next
;
253 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
254 /* Events and Callbacks */
255 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/