4 * @file gmyth/gmyth_recprofile.c
6 * @brief <p> This file contains the recprofile class.
8 * Copyright (C) 2007 INdT - Instituto Nokia de Tecnologia.
9 * @author Artur Duque de Souza <artur.souza@indt.org.br>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35 #include "gmyth_recprofile.h"
36 #include "gmyth_util.h"
37 #include "gmyth_debug.h"
38 #include "gmyth_http.h"
40 static void gmyth_recprofile_class_init(GMythRecProfileClass * klass);
41 static void gmyth_recprofile_init(GMythRecProfile * object);
43 static void gmyth_recprofile_dispose(GObject * object);
44 static void gmyth_recprofile_finalize(GObject * object);
46 G_DEFINE_TYPE(GMythRecProfile, gmyth_recprofile, G_TYPE_OBJECT)
47 static void gmyth_recprofile_class_init(GMythRecProfileClass *
50 GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
52 gobject_class->dispose = gmyth_recprofile_dispose;
53 gobject_class->finalize = gmyth_recprofile_finalize;
57 gmyth_recprofile_init(GMythRecProfile * recprofile)
62 gmyth_recprofile_dispose(GObject * object)
64 GMythRecProfile *recprofile = GMYTH_RECPROFILE(object);
67 g_free(recprofile->name);
69 if (recprofile->group)
70 g_free(recprofile->group);
72 if (recprofile->vcodec)
73 g_free(recprofile->vcodec);
75 if (recprofile->acodec)
76 g_free(recprofile->acodec);
78 if (recprofile->options)
79 g_free(recprofile->options);
81 G_OBJECT_CLASS(gmyth_recprofile_parent_class)->dispose(object);
85 gmyth_recprofile_finalize(GObject * object)
87 g_signal_handlers_destroy(object);
88 G_OBJECT_CLASS(gmyth_recprofile_parent_class)->finalize(object);
92 * Creates a new instance of GMythRecProfile.
94 * @return a new instance of GMythRecProfile.
97 gmyth_recprofile_new(void)
99 GMythRecProfile *recprofile = GMYTH_RECPROFILE
100 (g_object_new(GMYTH_RECPROFILE_TYPE, NULL));
103 recprofile->name = NULL;
104 recprofile->group = NULL;
105 recprofile->vcodec = NULL;
106 recprofile->acodec = NULL;
107 recprofile->options = NULL;
115 * gmyth_recprofile_get_profile_list
116 * @brief get profile list from the backend
117 * @param backend_info GMythBackendInfo*
122 gmyth_recprofile_get_profile_list(GMythBackendInfo * backend_info)
124 return gmyth_http_retrieve_rec_profiles(backend_info, "Transcoders");
129 * gmyth_recprofile_create_profile
130 * @brief get profile list from the backend
131 * @param backend_info GMythBackendInfo*
132 * @param profile GMythRecProfile*
133 * @return gint representing the result
137 gmyth_recprofile_create_profile(GMythBackendInfo * backend_info,
138 GMythRecProfile * profile)
140 return gmyth_http_create_rec_profile(backend_info, profile);
145 * gmyth_recprofile_del_profile
146 * @brief del profile from the backend
147 * @param backend_info GMythBackendInfo*
148 * @param id profile's id
149 * @return gint representing the result
153 gmyth_recprofile_del_profile_list(GMythBackendInfo * backend_info, gint id)
155 return gmyth_http_del_rec_profile(backend_info, id);
160 * gmyth_recprofile_set_id
161 * @brief set recprofile's id
162 * @param rec GMythRecProfile*
163 * @param id profile's id
164 * @return gint representing the result
168 gmyth_recprofile_set_id(GMythRecProfile * rec, gint id)
176 * gmyth_recprofile_set
177 * @brief set recprofile's property
178 * @param rec GMythRecProfile*
179 * @param member the member you want to modify
180 * @param value the value
181 * @return gint representing the result
185 gmyth_recprofile_set(GMythRecProfile * rec, gchar * member, gchar * value)
190 if (g_ascii_strcasecmp(member, "name") == 0)
191 rec->name = g_strndup(value, strlen(value));
192 else if (g_ascii_strcasecmp(member, "group") == 0)
193 rec->group = g_strndup(value, strlen(value));
194 else if (g_ascii_strcasecmp(member, "vcodec") == 0)
195 rec->vcodec = g_strndup(value, strlen(value));
196 else if (g_ascii_strcasecmp(member, "acodec") == 0)
197 rec->acodec = g_strndup(value, strlen(value));
208 * gmyth_recprofile_set_name
209 * @brief set recprofile's name
210 * @param rec GMythRecProfile*
211 * @param name profile's name
212 * @return gint representing the result
216 gmyth_recprofile_set_name(GMythRecProfile * rec, gchar * name)
218 return gmyth_recprofile_set(rec, "name", name);
223 * gmyth_recprofile_set_group
224 * @brief set recprofile's group
225 * @param rec GMythRecProfile*
226 * @param group profile's group
227 * @return gint representing the result
231 gmyth_recprofile_set_group(GMythRecProfile * rec, gchar * group)
233 return gmyth_recprofile_set(rec, "group", group);
238 * gmyth_recprofile_set_vcodec
239 * @brief set recprofile's vcodec
240 * @param rec GMythRecProfile*
241 * @param vcodec profile's vcodec
242 * @return gint representing the result
246 gmyth_recprofile_set_vcodec(GMythRecProfile * rec, gchar * vcodec)
248 return gmyth_recprofile_set(rec, "vcodec", vcodec);
253 * gmyth_recprofile_set_acodec
254 * @brief set recprofile's acodec
255 * @param rec GMythRecProfile*
256 * @param acodec profile's acodec
257 * @return gint representing the result
261 gmyth_recprofile_set_acodec(GMythRecProfile * rec, gchar * acodec)
263 return gmyth_recprofile_set(rec, "acodec", acodec);