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
->creator
= g_string_new("");
57 self
->comment
= g_string_new("");
58 self
->category
= g_string_new("");
59 self
->manufacturer
= g_string_new("");
60 self
->model
= g_string_new("");
61 self
->file_hash
= g_string_new("");
62 self
->file_name
= g_string_new("");
63 self
->uploaded
= g_string_new("");
64 self
->modified
= g_string_new("");
65 self
->downloaded
= g_string_new("");
66 self
->download_count
= 0;
68 self
->configurations
= NULL
;
72 IRRECO_RETURN_PTR(self
);
75 void irreco_webdb_remote_free(IrrecoWebdbRemote
*self
)
79 g_assert(self
!= NULL
);
81 g_string_free(self
->creator
, TRUE
);
84 g_string_free(self
->comment
, TRUE
);
87 g_string_free(self
->category
, TRUE
);
88 self
->category
= NULL
;
90 g_string_free(self
->manufacturer
, TRUE
);
91 self
->manufacturer
= NULL
;
93 g_string_free(self
->model
, TRUE
);
96 g_string_free(self
->file_hash
, TRUE
);
97 self
->file_hash
= NULL
;
99 g_string_free(self
->file_name
, TRUE
);
100 self
->file_name
= NULL
;
102 g_string_free(self
->uploaded
, TRUE
);
103 self
->uploaded
= NULL
;
105 g_string_free(self
->modified
, TRUE
);
106 self
->modified
= NULL
;
108 g_string_free(self
->downloaded
, TRUE
);
109 self
->downloaded
= NULL
;
111 if (self
->configurations
!= NULL
) {
112 g_list_free(self
->configurations
);
113 self
->configurations
= NULL
;
115 if (self
->themes
!= NULL
) {
116 g_list_free(self
->themes
);
120 g_slice_free(IrrecoWebdbRemote
, self
);
128 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
129 /* Private Functions */
130 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
133 * @name Public Functions
138 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
140 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
142 void irreco_webdb_remote_set(IrrecoWebdbRemote
*self
,
146 const char *category
,
147 const char *manufacturer
,
149 const char *file_hash
,
150 const char *file_name
,
151 const char *uploaded
,
152 const char *modified
,
153 const char *downloaded
,
158 g_assert(self
!= NULL
);
161 g_string_printf(self
->creator
, "%s", creator
);
162 g_string_printf(self
->comment
, "%s", comment
);
163 g_string_printf(self
->category
, "%s", category
);
164 g_string_printf(self
->manufacturer
, "%s", manufacturer
);
165 g_string_printf(self
->model
, "%s", model
);
166 g_string_printf(self
->file_hash
, "%s", file_hash
);
167 g_string_printf(self
->file_name
, "%s", file_name
);
168 g_string_printf(self
->uploaded
, "%s", uploaded
);
169 g_string_printf(self
->modified
, "%s", modified
);
170 g_string_printf(self
->downloaded
, "%s", downloaded
);
171 self
->download_count
= download_count
;
176 void irreco_webdb_remote_add_configuration_id(IrrecoWebdbRemote
*self
, gint id
)
180 g_assert(self
!= NULL
);
182 self
->configurations
= g_list_append(self
->configurations
,
183 GINT_TO_POINTER(id
));
185 self
->configurations
= g_list_first(self
->configurations
);
190 void irreco_webdb_remote_add_theme_id(IrrecoWebdbRemote
*self
, gint id
)
194 g_assert(self
!= NULL
);
196 self
->themes
= g_list_append(self
->themes
, GINT_TO_POINTER(id
));
198 self
->themes
= g_list_first(self
->themes
);
203 void irreco_webdb_remote_print(IrrecoWebdbRemote
*self
)
205 GList
*configurations
;
209 g_assert(self
!= NULL
);
211 IRRECO_PRINTF("ID: %d\n", self
->id
);
212 IRRECO_PRINTF("Creator: %s\n", self
->creator
->str
);
213 IRRECO_PRINTF("Comment: %s\n", self
->comment
->str
);
214 IRRECO_PRINTF("Category: %s\n", self
->category
->str
);
215 IRRECO_PRINTF("Manufacturer: %s\n", self
->manufacturer
->str
);
216 IRRECO_PRINTF("Model: %s\n", self
->model
->str
);
217 IRRECO_PRINTF("File hash: %s\n", self
->file_hash
->str
);
218 IRRECO_PRINTF("File name: %s\n", self
->file_name
->str
);
219 IRRECO_PRINTF("Uploaded: %s\n", self
->uploaded
->str
);
220 IRRECO_PRINTF("Modified: %s\n", self
->modified
->str
);
221 IRRECO_PRINTF("Last download: %s\n", self
->downloaded
->str
);
222 IRRECO_PRINTF("Download_count: %d\n", self
->download_count
);
224 configurations
= g_list_first(self
->configurations
);
225 if (configurations
!= NULL
) IRRECO_PRINTF("Configurations:");
226 while(configurations
) {
227 g_print(" (%d)", GPOINTER_TO_INT(configurations
->data
));
229 configurations
= configurations
->next
;
232 themes
= g_list_first(self
->themes
);
233 if (themes
!= NULL
) IRRECO_PRINTF("Themes:");
235 g_print(" (%d)", GPOINTER_TO_INT(themes
->data
));
237 themes
= themes
->next
;
246 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
247 /* Events and Callbacks */
248 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/