[svn r707] Fixed the wrong commentary indentation.
1.1 --- a/gmyth/src/Makefile.am Wed May 23 19:21:26 2007 +0100
1.2 +++ b/gmyth/src/Makefile.am Wed May 23 19:50:41 2007 +0100
1.3 @@ -100,10 +100,10 @@
1.4 if HAVE_INDENT
1.5 indent:
1.6 @for src_file in $(libgmyth_la_SOURCES); do \
1.7 - ./gst-indent.sh $$src_file; \
1.8 + ./gmyth-indent.sh $$src_file; \
1.9 done; \
1.10 for inc_file in $(libgmyth_include_HEADERS); do \
1.11 - ./gst-indent.sh $$inc_file; \
1.12 + ./gmyth-indent.sh $$inc_file; \
1.13 done;
1.14 endif
1.15
2.1 --- a/gmyth/src/gmyth.h Wed May 23 19:21:26 2007 +0100
2.2 +++ b/gmyth/src/gmyth.h Wed May 23 19:50:41 2007 +0100
2.3 @@ -7,22 +7,22 @@
2.4 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
2.5 * @author Renato Filho <renato.filho@indt.org.br>
2.6 *
2.7 - *//*
2.8 - *
2.9 - * This program is free software; you can redistribute it and/or modify
2.10 - * it under the terms of the GNU Lesser General Public License as published by
2.11 - * the Free Software Foundation; either version 2 of the License, or
2.12 - * (at your option) any later version.
2.13 - *
2.14 - * This program is distributed in the hope that it will be useful,
2.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
2.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2.17 - * GNU General Public License for more details.
2.18 - *
2.19 - * You should have received a copy of the GNU Lesser General Public License
2.20 - * along with this program; if not, write to the Free Software
2.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2.22 - */
2.23 + *//*
2.24 + *
2.25 + * This program is free software; you can redistribute it and/or modify
2.26 + * it under the terms of the GNU Lesser General Public License as published by
2.27 + * the Free Software Foundation; either version 2 of the License, or
2.28 + * (at your option) any later version.
2.29 + *
2.30 + * This program is distributed in the hope that it will be useful,
2.31 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2.32 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2.33 + * GNU General Public License for more details.
2.34 + *
2.35 + * You should have received a copy of the GNU Lesser General Public License
2.36 + * along with this program; if not, write to the Free Software
2.37 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2.38 + */
2.39
2.40
2.41
3.1 --- a/gmyth/src/gmyth_backendinfo.c Wed May 23 19:21:26 2007 +0100
3.2 +++ b/gmyth/src/gmyth_backendinfo.c Wed May 23 19:50:41 2007 +0100
3.3 @@ -10,22 +10,21 @@
3.4 * @author Hallyson Melo <hallyson.melo@indt.org.br>
3.5 * @author Rosfran Borges <rosfran.borges@indt.org.br>
3.6 *
3.7 - *//*
3.8 - *
3.9 - * This program is free software; you can redistribute it and/or modify
3.10 - * it under the terms of the GNU Lesser General Public License as published by
3.11 - * the Free Software Foundation; either version 2 of the License, or
3.12 - * (at your option) any later version.
3.13 - *
3.14 - * This program is distributed in the hope that it will be useful,
3.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
3.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3.17 - * GNU General Public License for more details.
3.18 - *
3.19 - * You should have received a copy of the GNU Lesser General Public License
3.20 - * along with this program; if not, write to the Free Software
3.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3.22 - */
3.23 + *
3.24 + * This program is free software; you can redistribute it and/or modify
3.25 + * it under the terms of the GNU Lesser General Public License as published by
3.26 + * the Free Software Foundation; either version 2 of the License, or
3.27 + * (at your option) any later version.
3.28 + *
3.29 + * This program is distributed in the hope that it will be useful,
3.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3.32 + * GNU General Public License for more details.
3.33 + *
3.34 + * You should have received a copy of the GNU Lesser General Public License
3.35 + * along with this program; if not, write to the Free Software
3.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3.37 + */
3.38
3.39 #ifdef HAVE_CONFIG_H
3.40 #include "config.h"
3.41 @@ -35,25 +34,25 @@
3.42 #include "gmyth_uri.h"
3.43 #include "gmyth_debug.h"
3.44
3.45 -static void gmyth_backend_info_class_init (GMythBackendInfoClass * klass);
3.46 -static void gmyth_backend_info_init (GMythBackendInfo * object);
3.47 +static void gmyth_backend_info_class_init ( GMythBackendInfoClass * klass );
3.48 +static void gmyth_backend_info_init ( GMythBackendInfo * object );
3.49
3.50 -static void gmyth_backend_info_dispose (GObject * object);
3.51 -static void gmyth_backend_info_finalize (GObject * object);
3.52 +static void gmyth_backend_info_dispose ( GObject * object );
3.53 +static void gmyth_backend_info_finalize ( GObject * object );
3.54
3.55 -G_DEFINE_TYPE (GMythBackendInfo, gmyth_backend_info, G_TYPE_OBJECT)
3.56 - static void gmyth_backend_info_class_init (GMythBackendInfoClass * klass)
3.57 +G_DEFINE_TYPE ( GMythBackendInfo, gmyth_backend_info, G_TYPE_OBJECT )
3.58 + static void gmyth_backend_info_class_init ( GMythBackendInfoClass * klass )
3.59 {
3.60 GObjectClass *gobject_class;
3.61
3.62 - gobject_class = (GObjectClass *) klass;
3.63 + gobject_class = ( GObjectClass * ) klass;
3.64
3.65 gobject_class->dispose = gmyth_backend_info_dispose;
3.66 gobject_class->finalize = gmyth_backend_info_finalize;
3.67 }
3.68
3.69 static void
3.70 -gmyth_backend_info_init (GMythBackendInfo * backend_info)
3.71 +gmyth_backend_info_init ( GMythBackendInfo * backend_info )
3.72 {
3.73 backend_info->hostname = NULL;
3.74 backend_info->username = NULL;
3.75 @@ -64,14 +63,14 @@
3.76 }
3.77
3.78 static void
3.79 -gmyth_backend_info_dispose (GObject * object)
3.80 +gmyth_backend_info_dispose ( GObject * object )
3.81 {
3.82 - GMythBackendInfo *backend_info = GMYTH_BACKEND_INFO (object);
3.83 + GMythBackendInfo *backend_info = GMYTH_BACKEND_INFO ( object );
3.84
3.85 - g_free (backend_info->hostname);
3.86 - g_free (backend_info->username);
3.87 - g_free (backend_info->password);
3.88 - g_free (backend_info->db_name);
3.89 + g_free ( backend_info->hostname );
3.90 + g_free ( backend_info->username );
3.91 + g_free ( backend_info->password );
3.92 + g_free ( backend_info->db_name );
3.93
3.94 backend_info->hostname = NULL;
3.95 backend_info->username = NULL;
3.96 @@ -80,15 +79,15 @@
3.97 backend_info->port = -1;
3.98 backend_info->status_port = -1;
3.99
3.100 - G_OBJECT_CLASS (gmyth_backend_info_parent_class)->dispose (object);
3.101 + G_OBJECT_CLASS ( gmyth_backend_info_parent_class )->dispose ( object );
3.102 }
3.103
3.104 static void
3.105 -gmyth_backend_info_finalize (GObject * object)
3.106 +gmyth_backend_info_finalize ( GObject * object )
3.107 {
3.108 - g_signal_handlers_destroy (object);
3.109 + g_signal_handlers_destroy ( object );
3.110
3.111 - G_OBJECT_CLASS (gmyth_backend_info_parent_class)->finalize (object);
3.112 + G_OBJECT_CLASS ( gmyth_backend_info_parent_class )->finalize ( object );
3.113 }
3.114
3.115 /**
3.116 @@ -97,10 +96,10 @@
3.117 * @return a new instance of GMythBackendInfo.
3.118 */
3.119 GMythBackendInfo *
3.120 -gmyth_backend_info_new ()
3.121 +gmyth_backend_info_new ( )
3.122 {
3.123 GMythBackendInfo *backend_info =
3.124 - GMYTH_BACKEND_INFO (g_object_new (GMYTH_BACKEND_INFO_TYPE, NULL));
3.125 + GMYTH_BACKEND_INFO ( g_object_new ( GMYTH_BACKEND_INFO_TYPE, NULL ) );
3.126
3.127 return backend_info;
3.128 }
3.129 @@ -118,17 +117,18 @@
3.130 * @return a new instance of GMythBackendInfo.
3.131 */
3.132 GMythBackendInfo *
3.133 -gmyth_backend_info_new_full (const gchar * hostname, const gchar * username,
3.134 - const gchar * password, const gchar * db_name, gint port)
3.135 +gmyth_backend_info_new_full ( const gchar * hostname, const gchar * username,
3.136 + const gchar * password, const gchar * db_name,
3.137 + gint port )
3.138 {
3.139 GMythBackendInfo *backend_info =
3.140 - GMYTH_BACKEND_INFO (g_object_new (GMYTH_BACKEND_INFO_TYPE, NULL));
3.141 + GMYTH_BACKEND_INFO ( g_object_new ( GMYTH_BACKEND_INFO_TYPE, NULL ) );
3.142
3.143 - gmyth_backend_info_set_hostname (backend_info, hostname);
3.144 - gmyth_backend_info_set_username (backend_info, username);
3.145 - gmyth_backend_info_set_password (backend_info, password);
3.146 - gmyth_backend_info_set_db_name (backend_info, db_name);
3.147 - gmyth_backend_info_set_port (backend_info, port);
3.148 + gmyth_backend_info_set_hostname ( backend_info, hostname );
3.149 + gmyth_backend_info_set_username ( backend_info, username );
3.150 + gmyth_backend_info_set_password ( backend_info, password );
3.151 + gmyth_backend_info_set_db_name ( backend_info, db_name );
3.152 + gmyth_backend_info_set_port ( backend_info, port );
3.153
3.154 return backend_info;
3.155 }
3.156 @@ -142,134 +142,149 @@
3.157 * @return a new instance of GMythBackendInfo.
3.158 */
3.159 GMythBackendInfo *
3.160 -gmyth_backend_info_new_with_uri (const gchar * uri_str)
3.161 +gmyth_backend_info_new_with_uri ( const gchar * uri_str )
3.162 {
3.163 GMythBackendInfo *backend_info =
3.164 - GMYTH_BACKEND_INFO (g_object_new (GMYTH_BACKEND_INFO_TYPE, NULL));
3.165 + GMYTH_BACKEND_INFO ( g_object_new ( GMYTH_BACKEND_INFO_TYPE, NULL ) );
3.166
3.167 - GMythURI *uri = gmyth_uri_new_with_value (uri_str);
3.168 + GMythURI *uri = gmyth_uri_new_with_value ( uri_str );
3.169
3.170 - gchar **path_parts = g_strsplit (gmyth_uri_get_path (uri), "&", -1);
3.171 + gchar **path_parts = g_strsplit ( gmyth_uri_get_path ( uri ), "&", -1 );
3.172
3.173 - gmyth_backend_info_set_hostname (backend_info, gmyth_uri_get_host (uri));
3.174 - gmyth_backend_info_set_username (backend_info, gmyth_uri_get_user (uri));
3.175 - gmyth_backend_info_set_password (backend_info,
3.176 - gmyth_uri_get_password (uri));
3.177 + gmyth_backend_info_set_hostname ( backend_info,
3.178 + gmyth_uri_get_host ( uri ) );
3.179 + gmyth_backend_info_set_username ( backend_info,
3.180 + gmyth_uri_get_user ( uri ) );
3.181 + gmyth_backend_info_set_password ( backend_info,
3.182 + gmyth_uri_get_password ( uri ) );
3.183
3.184 /* gets the path info to database name, from the URI, and removes the trash chars */
3.185 - gmyth_backend_info_set_db_name (backend_info, path_parts != NULL &&
3.186 - strlen (path_parts[0]) > 0 ?
3.187 - g_strstrip (g_strdelimit
3.188 - (path_parts[0], "/?", ' ')) : gmyth_uri_get_path (uri));
3.189 + gmyth_backend_info_set_db_name ( backend_info, path_parts != NULL &&
3.190 + strlen ( path_parts[0] ) > 0 ?
3.191 + g_strstrip ( g_strdelimit
3.192 + ( path_parts[0], "/?",
3.193 + ' ' ) ) :
3.194 + gmyth_uri_get_path ( uri ) );
3.195
3.196 - gmyth_backend_info_set_port (backend_info, gmyth_uri_get_port (uri));
3.197 + gmyth_backend_info_set_port ( backend_info, gmyth_uri_get_port ( uri ) );
3.198
3.199 - g_object_unref (uri);
3.200 - g_strfreev (path_parts);
3.201 + g_object_unref ( uri );
3.202 + g_strfreev ( path_parts );
3.203
3.204 return backend_info;
3.205 }
3.206
3.207 void
3.208 -gmyth_backend_info_set_hostname (GMythBackendInfo * backend_info,
3.209 - const gchar * hostname)
3.210 +gmyth_backend_info_set_hostname ( GMythBackendInfo * backend_info,
3.211 + const gchar * hostname )
3.212 {
3.213 - g_return_if_fail (backend_info != NULL);
3.214 + g_return_if_fail ( backend_info != NULL );
3.215
3.216 - if (NULL == hostname || strlen (hostname) <= 0) {
3.217 - gmyth_debug ("Error trying to set a hostname equals to NULL.");
3.218 - } else {
3.219 - backend_info->hostname = g_strdup (hostname);
3.220 + if ( NULL == hostname || strlen ( hostname ) <= 0 )
3.221 + {
3.222 + gmyth_debug ( "Error trying to set a hostname equals to NULL." );
3.223 + }
3.224 + else
3.225 + {
3.226 + backend_info->hostname = g_strdup ( hostname );
3.227 }
3.228 }
3.229
3.230 void
3.231 -gmyth_backend_info_set_username (GMythBackendInfo * backend_info,
3.232 - const gchar * username)
3.233 +gmyth_backend_info_set_username ( GMythBackendInfo * backend_info,
3.234 + const gchar * username )
3.235 {
3.236 - g_return_if_fail (backend_info != NULL);
3.237 + g_return_if_fail ( backend_info != NULL );
3.238
3.239 - backend_info->username = g_strdup (username);
3.240 + backend_info->username = g_strdup ( username );
3.241 }
3.242
3.243 void
3.244 -gmyth_backend_info_set_password (GMythBackendInfo * backend_info,
3.245 - const gchar * password)
3.246 +gmyth_backend_info_set_password ( GMythBackendInfo * backend_info,
3.247 + const gchar * password )
3.248 {
3.249 - g_return_if_fail (backend_info != NULL);
3.250 + g_return_if_fail ( backend_info != NULL );
3.251
3.252 - backend_info->password = g_strdup (password);
3.253 + backend_info->password = g_strdup ( password );
3.254 }
3.255
3.256 void
3.257 -gmyth_backend_info_set_db_name (GMythBackendInfo * backend_info,
3.258 - const gchar * db_name)
3.259 +gmyth_backend_info_set_db_name ( GMythBackendInfo * backend_info,
3.260 + const gchar * db_name )
3.261 {
3.262 - g_return_if_fail (backend_info != NULL);
3.263 + g_return_if_fail ( backend_info != NULL );
3.264
3.265 - backend_info->db_name = g_strdup (db_name);
3.266 + backend_info->db_name = g_strdup ( db_name );
3.267 }
3.268
3.269 void
3.270 -gmyth_backend_info_set_port (GMythBackendInfo * backend_info, gint port)
3.271 +gmyth_backend_info_set_port ( GMythBackendInfo * backend_info, gint port )
3.272 {
3.273 - g_return_if_fail (backend_info != NULL);
3.274 + g_return_if_fail ( backend_info != NULL );
3.275
3.276 - if (port <= 0) {
3.277 - gmyth_debug ("Error trying to set a port less than 0.");
3.278 - } else {
3.279 + if ( port <= 0 )
3.280 + {
3.281 + gmyth_debug ( "Error trying to set a port less than 0." );
3.282 + }
3.283 + else
3.284 + {
3.285 backend_info->port = port;
3.286 }
3.287 }
3.288
3.289 void
3.290 -gmyth_backend_info_set_status_port (GMythBackendInfo * backend_info, gint port)
3.291 +gmyth_backend_info_set_status_port ( GMythBackendInfo * backend_info,
3.292 + gint port )
3.293 {
3.294 - g_return_if_fail (backend_info != NULL);
3.295 + g_return_if_fail ( backend_info != NULL );
3.296
3.297 - if (port <= 0) {
3.298 - gmyth_debug ("Error trying to set the status port to less than zero.");
3.299 - } else {
3.300 + if ( port <= 0 )
3.301 + {
3.302 + gmyth_debug
3.303 + ( "Error trying to set the status port to less than zero." );
3.304 + }
3.305 + else
3.306 + {
3.307 backend_info->status_port = port;
3.308 }
3.309 }
3.310
3.311 const gchar *
3.312 -gmyth_backend_info_get_hostname (GMythBackendInfo * backend_info)
3.313 +gmyth_backend_info_get_hostname ( GMythBackendInfo * backend_info )
3.314 {
3.315 - g_return_val_if_fail (backend_info != NULL, NULL);
3.316 + g_return_val_if_fail ( backend_info != NULL, NULL );
3.317
3.318 return backend_info->hostname;
3.319 }
3.320
3.321 const gchar *
3.322 -gmyth_backend_info_get_username (GMythBackendInfo * backend_info)
3.323 +gmyth_backend_info_get_username ( GMythBackendInfo * backend_info )
3.324 {
3.325 - g_return_val_if_fail (backend_info != NULL, NULL);
3.326 + g_return_val_if_fail ( backend_info != NULL, NULL );
3.327
3.328 return backend_info->username;
3.329 }
3.330
3.331 const gchar *
3.332 -gmyth_backend_info_get_password (GMythBackendInfo * backend_info)
3.333 +gmyth_backend_info_get_password ( GMythBackendInfo * backend_info )
3.334 {
3.335 - g_return_val_if_fail (backend_info != NULL, NULL);
3.336 + g_return_val_if_fail ( backend_info != NULL, NULL );
3.337
3.338 return backend_info->password;
3.339 }
3.340
3.341 const gchar *
3.342 -gmyth_backend_info_get_db_name (GMythBackendInfo * backend_info)
3.343 +gmyth_backend_info_get_db_name ( GMythBackendInfo * backend_info )
3.344 {
3.345 - g_return_val_if_fail (backend_info != NULL, NULL);
3.346 + g_return_val_if_fail ( backend_info != NULL, NULL );
3.347
3.348 return backend_info->db_name;
3.349 }
3.350
3.351 gint
3.352 -gmyth_backend_info_get_port (GMythBackendInfo * backend_info)
3.353 +gmyth_backend_info_get_port ( GMythBackendInfo * backend_info )
3.354 {
3.355 - g_return_val_if_fail (backend_info != NULL, -1);
3.356 + g_return_val_if_fail ( backend_info != NULL, -1 );
3.357
3.358 return backend_info->port;
3.359 }
3.360 @@ -283,48 +298,52 @@
3.361 * @return an instance of GMythURI, created from a GMythBackendInfo.
3.362 */
3.363 GMythURI *
3.364 -gmyth_backend_info_get_uri (GMythBackendInfo * backend_info)
3.365 +gmyth_backend_info_get_uri ( GMythBackendInfo * backend_info )
3.366 {
3.367 GMythURI *uri = NULL;
3.368 gchar *uri_str = NULL;
3.369 gchar *user_info = NULL;
3.370 gchar *db_data = NULL;
3.371
3.372 - if ((backend_info->username != NULL && strlen (backend_info->username) > 0))
3.373 + if ( ( backend_info->username != NULL
3.374 + && strlen ( backend_info->username ) > 0 ) )
3.375 user_info =
3.376 - g_strdup_printf ("%s:%s@", backend_info->username,
3.377 - backend_info->password);
3.378 + g_strdup_printf ( "%s:%s@", backend_info->username,
3.379 + backend_info->password );
3.380
3.381 - if (backend_info->db_name != NULL && strlen (backend_info->db_name) > 0) {
3.382 - if ((g_strrstr (backend_info->db_name, "_") != NULL))
3.383 - db_data = g_strdup (backend_info->db_name);
3.384 + if ( backend_info->db_name != NULL && strlen ( backend_info->db_name ) > 0 )
3.385 + {
3.386 + if ( ( g_strrstr ( backend_info->db_name, "_" ) != NULL ) )
3.387 + db_data = g_strdup ( backend_info->db_name );
3.388 else
3.389 - db_data = g_strdup_printf ("?%s&", backend_info->db_name);
3.390 + db_data = g_strdup_printf ( "?%s&", backend_info->db_name );
3.391 }
3.392 //else if ( ( ( g_strrstr( backend_info->path, "livetv" ) != NULL ) ||
3.393 // ( g_strrstr( backend_info->path, "/?" ) != NULL ) )
3.394
3.395 - uri_str = g_strdup_printf ("myth://%s%s:%d/%s", user_info != NULL
3.396 - && strlen (user_info) > 0 ? user_info : "",
3.397 - backend_info->hostname, backend_info->port,
3.398 - db_data != NULL && strlen (db_data) > 0 ? db_data : "");
3.399 - uri = gmyth_uri_new_with_value (uri_str);
3.400 + uri_str = g_strdup_printf ( "myth://%s%s:%d/%s", user_info != NULL
3.401 + && strlen ( user_info ) > 0 ? user_info : "",
3.402 + backend_info->hostname, backend_info->port,
3.403 + db_data != NULL
3.404 + && strlen ( db_data ) > 0 ? db_data : "" );
3.405 + uri = gmyth_uri_new_with_value ( uri_str );
3.406
3.407 - if (user_info != NULL)
3.408 - g_free (user_info);
3.409 + if ( user_info != NULL )
3.410 + g_free ( user_info );
3.411
3.412 - if (db_data != NULL)
3.413 - g_free (db_data);
3.414 + if ( db_data != NULL )
3.415 + g_free ( db_data );
3.416
3.417 - g_free (uri_str);
3.418 + g_free ( uri_str );
3.419
3.420 return uri;
3.421 }
3.422
3.423 gboolean
3.424 -gmyth_backend_info_is_local_file (GMythBackendInfo * backend_info)
3.425 +gmyth_backend_info_is_local_file ( GMythBackendInfo * backend_info )
3.426 {
3.427 - g_return_val_if_fail (backend_info != NULL, FALSE);
3.428 + g_return_val_if_fail ( backend_info != NULL, FALSE );
3.429
3.430 - return gmyth_uri_is_local_file (gmyth_backend_info_get_uri (backend_info));
3.431 + return
3.432 + gmyth_uri_is_local_file ( gmyth_backend_info_get_uri ( backend_info ) );
3.433 }
4.1 --- a/gmyth/src/gmyth_backendinfo.h Wed May 23 19:21:26 2007 +0100
4.2 +++ b/gmyth/src/gmyth_backendinfo.h Wed May 23 19:50:41 2007 +0100
4.3 @@ -10,22 +10,21 @@
4.4 * @author Hallyson Melo <hallyson.melo@indt.org.br>
4.5 * @author Rosfran Borges <rosfran.borges@indt.org.br>
4.6 *
4.7 - *//*
4.8 - *
4.9 - * This program is free software; you can redistribute it and/or modify
4.10 - * it under the terms of the GNU Lesser General Public License as published by
4.11 - * the Free Software Foundation; either version 2 of the License, or
4.12 - * (at your option) any later version.
4.13 - *
4.14 - * This program is distributed in the hope that it will be useful,
4.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
4.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4.17 - * GNU General Public License for more details.
4.18 - *
4.19 - * You should have received a copy of the GNU Lesser General Public License
4.20 - * along with this program; if not, write to the Free Software
4.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
4.22 - */
4.23 +*
4.24 +* This program is free software; you can redistribute it and/or modify
4.25 +* it under the terms of the GNU Lesser General Public License as published by
4.26 +* the Free Software Foundation; either version 2 of the License, or
4.27 +* (at your option) any later version.
4.28 +*
4.29 +* This program is distributed in the hope that it will be useful,
4.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4.32 + * GNU General Public License for more details.
4.33 + *
4.34 + * You should have received a copy of the GNU Lesser General Public License
4.35 + * along with this program; if not, write to the Free Software
4.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
4.37 + */
4.38
4.39 #ifndef __GMYTH_BACKEND_INFO_H__
4.40 #define __GMYTH_BACKEND_INFO_H__
4.41 @@ -45,62 +44,67 @@
4.42 typedef struct _GMythBackendInfoClass GMythBackendInfoClass;
4.43
4.44 struct _GMythBackendInfoClass
4.45 -{
4.46 - GObjectClass parent_class;
4.47 + {
4.48 + GObjectClass parent_class;
4.49
4.50 - /* callbacks */
4.51 - /* no one for now */
4.52 -};
4.53 + /* callbacks */
4.54 + /* no one for now */
4.55 + };
4.56
4.57 struct _GMythBackendInfo
4.58 -{
4.59 - GObject parent;
4.60 + {
4.61 + GObject parent;
4.62
4.63 /** The backend hostname or ip address. */
4.64 - gchar *hostname;
4.65 + gchar *hostname;
4.66 /** The username to connect to the mysql server. */
4.67 - gchar *username;
4.68 + gchar *username;
4.69 /** The password to connect to the mysql server. */
4.70 - gchar *password;
4.71 + gchar *password;
4.72 /** The mythtv's mysql database name. */
4.73 - gchar *db_name;
4.74 + gchar *db_name;
4.75 /** The backend port. */
4.76 - gint port;
4.77 + gint port;
4.78 /** The backend status port for http connection */
4.79 - gint status_port;
4.80 - //gchar *path;
4.81 + gint status_port;
4.82 + //gchar *path;
4.83
4.84 - //GMythURI* uri;
4.85 -};
4.86 + //GMythURI* uri;
4.87 + };
4.88
4.89
4.90 -GType gmyth_backend_info_get_type (void);
4.91 -GMythBackendInfo *gmyth_backend_info_new (void);
4.92 -GMythBackendInfo *gmyth_backend_info_new_full (const gchar * hostname,
4.93 - const gchar * username,
4.94 - const gchar * password, const gchar * db_name, gint port);
4.95 -GMythBackendInfo *gmyth_backend_info_new_with_uri (const gchar * uri_str);
4.96 -void gmyth_backend_info_set_hostname (GMythBackendInfo * backend_info,
4.97 - const gchar * hostname);
4.98 -void gmyth_backend_info_set_username (GMythBackendInfo * backend_info,
4.99 - const gchar * username);
4.100 -void gmyth_backend_info_set_password (GMythBackendInfo * backend_info,
4.101 - const gchar * password);
4.102 -void gmyth_backend_info_set_db_name (GMythBackendInfo * backend_info,
4.103 - const gchar * db_name);
4.104 -void gmyth_backend_info_set_port (GMythBackendInfo * backend_info, gint port);
4.105 -void gmyth_backend_info_set_status_port (GMythBackendInfo * backend_info,
4.106 - gint port);
4.107 +GType gmyth_backend_info_get_type ( void );
4.108 +GMythBackendInfo *gmyth_backend_info_new ( void );
4.109 +GMythBackendInfo *gmyth_backend_info_new_full ( const gchar * hostname,
4.110 + const gchar * username,
4.111 + const gchar * password,
4.112 + const gchar * db_name,
4.113 + gint port );
4.114 +GMythBackendInfo *gmyth_backend_info_new_with_uri ( const gchar * uri_str );
4.115 +void gmyth_backend_info_set_hostname ( GMythBackendInfo * backend_info,
4.116 + const gchar * hostname );
4.117 +void gmyth_backend_info_set_username ( GMythBackendInfo * backend_info,
4.118 + const gchar * username );
4.119 +void gmyth_backend_info_set_password ( GMythBackendInfo * backend_info,
4.120 + const gchar * password );
4.121 +void gmyth_backend_info_set_db_name ( GMythBackendInfo * backend_info,
4.122 + const gchar * db_name );
4.123 +void gmyth_backend_info_set_port ( GMythBackendInfo * backend_info, gint port );
4.124 +void gmyth_backend_info_set_status_port ( GMythBackendInfo * backend_info,
4.125 + gint port );
4.126
4.127 -const gchar *gmyth_backend_info_get_hostname (GMythBackendInfo * backend_info);
4.128 -const gchar *gmyth_backend_info_get_username (GMythBackendInfo * backend_info);
4.129 -const gchar *gmyth_backend_info_get_password (GMythBackendInfo * backend_info);
4.130 -const gchar *gmyth_backend_info_get_db_name (GMythBackendInfo * backend_info);
4.131 -gint gmyth_backend_info_get_port (GMythBackendInfo * backend_info);
4.132 +const gchar *gmyth_backend_info_get_hostname ( GMythBackendInfo *
4.133 + backend_info );
4.134 +const gchar *gmyth_backend_info_get_username ( GMythBackendInfo *
4.135 + backend_info );
4.136 +const gchar *gmyth_backend_info_get_password ( GMythBackendInfo *
4.137 + backend_info );
4.138 +const gchar *gmyth_backend_info_get_db_name ( GMythBackendInfo * backend_info );
4.139 +gint gmyth_backend_info_get_port ( GMythBackendInfo * backend_info );
4.140
4.141 -GMythURI *gmyth_backend_info_get_uri (GMythBackendInfo * backend_info);
4.142 +GMythURI *gmyth_backend_info_get_uri ( GMythBackendInfo * backend_info );
4.143
4.144 -gboolean gmyth_backend_info_is_local_file (GMythBackendInfo * backend_info);
4.145 +gboolean gmyth_backend_info_is_local_file ( GMythBackendInfo * backend_info );
4.146
4.147 G_END_DECLS
4.148 #endif /* __GMYTH_BACKEND_INFO_H__ */
5.1 --- a/gmyth/src/gmyth_common.c Wed May 23 19:21:26 2007 +0100
5.2 +++ b/gmyth/src/gmyth_common.c Wed May 23 19:50:41 2007 +0100
5.3 @@ -9,22 +9,21 @@
5.4 * @author Leonardo Sobral Cunha <leonardo.cunha@indt.org.br>
5.5 * @author Rosfran Borges <rosfran.borges@indt.org.br>
5.6 *
5.7 - *//*
5.8 - *
5.9 - * This program is free software; you can redistribute it and/or modify
5.10 - * it under the terms of the GNU Lesser General Public License as published by
5.11 - * the Free Software Foundation; either version 2 of the License, or
5.12 - * (at your option) any later version.
5.13 - *
5.14 - * This program is distributed in the hope that it will be useful,
5.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
5.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5.17 - * GNU General Public License for more details.
5.18 - *
5.19 - * You should have received a copy of the GNU Lesser General Public License
5.20 - * along with this program; if not, write to the Free Software
5.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
5.22 - */
5.23 +*
5.24 +* This program is free software; you can redistribute it and/or modify
5.25 +* it under the terms of the GNU Lesser General Public License as published by
5.26 +* the Free Software Foundation; either version 2 of the License, or
5.27 +* (at your option) any later version.
5.28 +*
5.29 +* This program is distributed in the hope that it will be useful,
5.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
5.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5.32 + * GNU General Public License for more details.
5.33 + *
5.34 + * You should have received a copy of the GNU Lesser General Public License
5.35 + * along with this program; if not, write to the Free Software
5.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
5.37 + */
5.38
5.39 #ifdef HAVE_CONFIG_H
5.40 #include "config.h"
5.41 @@ -34,23 +33,23 @@
5.42 #include "gmyth_debug.h"
5.43 #include "gmyth_util.h"
5.44
5.45 -static void free_channel_data (gpointer data, gpointer user_data);
5.46 -static void free_program_data (gpointer data, gpointer user_data);
5.47 +static void free_channel_data ( gpointer data, gpointer user_data );
5.48 +static void free_program_data ( gpointer data, gpointer user_data );
5.49
5.50 -/**
5.51 - * Frees the memory allocated to the GMythChannelInfo objects inside list.
5.52 - * The list memory is also released by g_list_free(). If LIST is NULL it
5.53 - * simply returns.
5.54 - *
5.55 - * @param list the GList containing a list of GMythChannelInfo to free.
5.56 - */
5.57 + /**
5.58 + * Frees the memory allocated to the GMythChannelInfo objects inside list.
5.59 + * The list memory is also released by g_list_free(). If LIST is NULL it
5.60 + * simply returns.
5.61 + *
5.62 + * @param list the GList containing a list of GMythChannelInfo to free.
5.63 + */
5.64 void
5.65 -gmyth_free_channel_list (GList * list)
5.66 +gmyth_free_channel_list ( GList * list )
5.67 {
5.68 - g_return_if_fail (list != NULL);
5.69 + g_return_if_fail ( list != NULL );
5.70
5.71 - g_list_foreach (list, free_channel_data, NULL);
5.72 - g_list_free (list);
5.73 + g_list_foreach ( list, free_channel_data, NULL );
5.74 + g_list_free ( list );
5.75 }
5.76
5.77 /**
5.78 @@ -61,29 +60,29 @@
5.79 * @param list the GList containing a list of GMythProgramInfo to free.
5.80 */
5.81 void
5.82 -gmyth_free_program_list (GList * list)
5.83 +gmyth_free_program_list ( GList * list )
5.84 {
5.85 - g_return_if_fail (list != NULL);
5.86 + g_return_if_fail ( list != NULL );
5.87
5.88 - g_list_foreach (list, free_program_data, NULL);
5.89 - g_list_free (list);
5.90 + g_list_foreach ( list, free_program_data, NULL );
5.91 + g_list_free ( list );
5.92 }
5.93
5.94 void
5.95 -gmyth_channel_info_free (GMythChannelInfo * channel)
5.96 +gmyth_channel_info_free ( GMythChannelInfo * channel )
5.97 {
5.98 - g_return_if_fail (channel != NULL);
5.99 + g_return_if_fail ( channel != NULL );
5.100
5.101 - if (channel->channel_num)
5.102 - g_string_free (channel->channel_num, TRUE);
5.103 + if ( channel->channel_num )
5.104 + g_string_free ( channel->channel_num, TRUE );
5.105
5.106 - if (channel->channel_name)
5.107 - g_string_free (channel->channel_name, TRUE);
5.108 + if ( channel->channel_name )
5.109 + g_string_free ( channel->channel_name, TRUE );
5.110
5.111 - if (channel->channel_icon)
5.112 - g_string_free (channel->channel_icon, TRUE);
5.113 + if ( channel->channel_icon )
5.114 + g_string_free ( channel->channel_icon, TRUE );
5.115
5.116 - g_free (channel);
5.117 + g_free ( channel );
5.118 }
5.119
5.120 /**
5.121 @@ -91,16 +90,18 @@
5.122 * @param channel_info the GMythChannelInfo instance
5.123 */
5.124 void
5.125 -gmyth_channel_info_print (GMythChannelInfo * channel_info)
5.126 +gmyth_channel_info_print ( GMythChannelInfo * channel_info )
5.127 {
5.128 #ifdef GMYTH_USE_DEBUG
5.129 - if (channel_info != NULL) {
5.130 - g_return_if_fail (channel_info->channel_name != NULL);
5.131 - g_return_if_fail (channel_info->channel_num != NULL);
5.132 + if ( channel_info != NULL )
5.133 + {
5.134 + g_return_if_fail ( channel_info->channel_name != NULL );
5.135 + g_return_if_fail ( channel_info->channel_num != NULL );
5.136
5.137 - gmyth_debug ("ChannelInfo (Name, Num, ID) = (%s, %s, %d)\n",
5.138 - channel_info->channel_name->str,
5.139 - channel_info->channel_num->str, channel_info->channel_ID);
5.140 + gmyth_debug ( "ChannelInfo (Name, Num, ID) = (%s, %s, %d)\n",
5.141 + channel_info->channel_name->str,
5.142 + channel_info->channel_num->str,
5.143 + channel_info->channel_ID );
5.144
5.145 }
5.146 #endif
5.147 @@ -111,42 +112,42 @@
5.148 * @param channel_info the GMythProgramInfo instance
5.149 */
5.150 void
5.151 -gmyth_program_info_print (GMythProgramInfo * program_info)
5.152 +gmyth_program_info_print ( GMythProgramInfo * program_info )
5.153 {
5.154 #ifdef GMYTH_USE_DEBUG
5.155 - g_return_if_fail (program_info);
5.156 + g_return_if_fail ( program_info );
5.157
5.158 - gmyth_debug ("ProgramInfo\n\tTitle = %s\n\t"
5.159 - "Description = %s\n\t"
5.160 - "Start time= %s\t"
5.161 - "End time = %s\n"
5.162 - "Path name = %s\n"
5.163 - "File size = %lld\n",
5.164 - program_info->title ? program_info->title->str : "NULL",
5.165 - program_info->description ? program_info->description->
5.166 - str : "NULL",
5.167 - gmyth_util_time_to_string_from_time_val (program_info->
5.168 - startts),
5.169 - gmyth_util_time_to_string_from_time_val (program_info->
5.170 - endts),
5.171 - program_info->pathname ? program_info->pathname->str : "NULL",
5.172 - program_info->filesize);
5.173 + gmyth_debug ( "ProgramInfo\n\tTitle = %s\n\t"
5.174 + "Description = %s\n\t"
5.175 + "Start time= %s\t"
5.176 + "End time = %s\n"
5.177 + "Path name = %s\n"
5.178 + "File size = %lld\n",
5.179 + program_info->title ? program_info->title->str : "NULL",
5.180 + program_info->description ? program_info->description->
5.181 + str : "NULL",
5.182 + gmyth_util_time_to_string_from_time_val ( program_info->
5.183 + startts ),
5.184 + gmyth_util_time_to_string_from_time_val ( program_info->
5.185 + endts ),
5.186 + program_info->pathname ? program_info->pathname->str : "NULL",
5.187 + program_info->filesize );
5.188 #endif
5.189 }
5.190
5.191 static void
5.192 -free_channel_data (gpointer data, gpointer user_data)
5.193 +free_channel_data ( gpointer data, gpointer user_data )
5.194 {
5.195 /* Frees the GMythChannelInfo structure */
5.196 - GMythChannelInfo *channel = (GMythChannelInfo *) data;
5.197 + GMythChannelInfo *channel = ( GMythChannelInfo * ) data;
5.198
5.199 - gmyth_channel_info_free (channel);
5.200 + gmyth_channel_info_free ( channel );
5.201 }
5.202
5.203 static void
5.204 -free_program_data (gpointer data, gpointer user_data)
5.205 +free_program_data ( gpointer data, gpointer user_data )
5.206 {
5.207 - g_return_if_fail (data != NULL);
5.208 + g_return_if_fail ( data != NULL );
5.209
5.210 - g_object_unref ((GMythProgramInfo *) data);
5.211 + g_object_unref ( ( GMythProgramInfo * ) data );
5.212 }
6.1 --- a/gmyth/src/gmyth_common.h Wed May 23 19:21:26 2007 +0100
6.2 +++ b/gmyth/src/gmyth_common.h Wed May 23 19:50:41 2007 +0100
6.3 @@ -9,22 +9,21 @@
6.4 * @author Leonardo Sobral Cunha <leonardo.cunha@indt.org.br>
6.5 * @author Rosfran Borges <rosfran.borges@indt.org.br>
6.6 *
6.7 - *//*
6.8 - *
6.9 - * This program is free software; you can redistribute it and/or modify
6.10 - * it under the terms of the GNU Lesser General Public License as published by
6.11 - * the Free Software Foundation; either version 2 of the License, or
6.12 - * (at your option) any later version.
6.13 - *
6.14 - * This program is distributed in the hope that it will be useful,
6.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
6.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6.17 - * GNU General Public License for more details.
6.18 - *
6.19 - * You should have received a copy of the GNU Lesser General Public License
6.20 - * along with this program; if not, write to the Free Software
6.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6.22 - */
6.23 + *
6.24 + * This program is free software; you can redistribute it and/or modify
6.25 + * it under the terms of the GNU Lesser General Public License as published by
6.26 + * the Free Software Foundation; either version 2 of the License, or
6.27 + * (at your option) any later version.
6.28 + *
6.29 + * This program is distributed in the hope that it will be useful,
6.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
6.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6.32 + * GNU General Public License for more details.
6.33 + *
6.34 + * You should have received a copy of the GNU Lesser General Public License
6.35 + * along with this program; if not, write to the Free Software
6.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6.37 + */
6.38
6.39 #ifndef GMYTH_COMMON_H_
6.40 #define GMYTH_COMMON_H_
6.41 @@ -40,29 +39,29 @@
6.42 * stored in the backend database.
6.43 */
6.44 typedef struct
6.45 -{
6.46 - /** The channel ID in backend database */
6.47 - gint channel_ID;
6.48 + {
6.49 + /** The channel ID in backend database */
6.50 + gint channel_ID;
6.51
6.52 - /** The channel number */
6.53 - GString *channel_num;
6.54 + /** The channel number */
6.55 + GString *channel_num;
6.56
6.57 - /** The channel name in backend database */
6.58 - GString *channel_name;
6.59 + /** The channel name in backend database */
6.60 + GString *channel_name;
6.61
6.62 - /** The channel icon path in the backend database */
6.63 - GString *channel_icon;
6.64 + /** The channel icon path in the backend database */
6.65 + GString *channel_icon;
6.66
6.67 -} GMythChannelInfo;
6.68 + } GMythChannelInfo;
6.69
6.70 -void gmyth_free_channel_list (GList * list);
6.71 -void gmyth_free_program_list (GList * list);
6.72 +void gmyth_free_channel_list ( GList * list );
6.73 +void gmyth_free_program_list ( GList * list );
6.74
6.75 -void gmyth_channel_info_free (GMythChannelInfo * channel_info);
6.76 +void gmyth_channel_info_free ( GMythChannelInfo * channel_info );
6.77
6.78
6.79 -void gmyth_channel_info_print (GMythChannelInfo * channel_info);
6.80 -void gmyth_program_info_print (GMythProgramInfo * program_info);
6.81 +void gmyth_channel_info_print ( GMythChannelInfo * channel_info );
6.82 +void gmyth_program_info_print ( GMythProgramInfo * program_info );
6.83
6.84 G_END_DECLS
6.85 #endif /* GMYTH_COMMON_H_ */
7.1 --- a/gmyth/src/gmyth_debug.c Wed May 23 19:21:26 2007 +0100
7.2 +++ b/gmyth/src/gmyth_debug.c Wed May 23 19:50:41 2007 +0100
7.3 @@ -7,22 +7,21 @@
7.4 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
7.5 * @author Renato Filho <renato.filho@indt.org.br>
7.6 *
7.7 - *//*
7.8 - *
7.9 - * This program is free software; you can redistribute it and/or modify
7.10 - * it under the terms of the GNU Lesser General Public License as published by
7.11 - * the Free Software Foundation; either version 2 of the License, or
7.12 - * (at your option) any later version.
7.13 - *
7.14 - * This program is distributed in the hope that it will be useful,
7.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
7.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7.17 - * GNU General Public License for more details.
7.18 - *
7.19 - * You should have received a copy of the GNU Lesser General Public License
7.20 - * along with this program; if not, write to the Free Software
7.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
7.22 - */
7.23 + *
7.24 + * This program is free software; you can redistribute it and/or modify
7.25 + * it under the terms of the GNU Lesser General Public License as published by
7.26 + * the Free Software Foundation; either version 2 of the License, or
7.27 + * (at your option) any later version.
7.28 + *
7.29 + * This program is distributed in the hope that it will be useful,
7.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
7.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7.32 + * GNU General Public License for more details.
7.33 + *
7.34 + * You should have received a copy of the GNU Lesser General Public License
7.35 + * along with this program; if not, write to the Free Software
7.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
7.37 + */
7.38
7.39 #ifdef HAVE_CONFIG_H
7.40 #include "config.h"
7.41 @@ -31,24 +30,25 @@
7.42 #include "gmyth_debug.h"
7.43
7.44 void
7.45 -gmyth_debug_real (const char *func,
7.46 - const char *file, const int line, gboolean newline, const char *format, ...)
7.47 +gmyth_debug_real ( const char *func,
7.48 + const char *file, const int line, gboolean newline,
7.49 + const char *format, ... )
7.50 {
7.51 va_list args;
7.52 char buffer[1025];
7.53 char str_time[255];
7.54 time_t the_time;
7.55
7.56 - va_start (args, format);
7.57 + va_start ( args, format );
7.58
7.59 - g_vsnprintf (buffer, 1024, format, args);
7.60 + g_vsnprintf ( buffer, 1024, format, args );
7.61
7.62 - va_end (args);
7.63 + va_end ( args );
7.64
7.65 - time (&the_time);
7.66 - strftime (str_time, 254, "%H:%M:%S", localtime (&the_time));
7.67 + time ( &the_time );
7.68 + strftime ( str_time, 254, "%H:%M:%S", localtime ( &the_time ) );
7.69
7.70 - g_printerr (newline ? "(%s) [%p] [%s] %s:%d: %s\n" :
7.71 - "(%s) [%p] [%s] %s:%d: %s", str_time, g_thread_self (), func,
7.72 - file, line, buffer);
7.73 + g_printerr ( newline ? "(%s) [%p] [%s] %s:%d: %s\n" :
7.74 + "(%s) [%p] [%s] %s:%d: %s", str_time, g_thread_self ( ), func,
7.75 + file, line, buffer );
7.76 }
8.1 --- a/gmyth/src/gmyth_debug.h Wed May 23 19:21:26 2007 +0100
8.2 +++ b/gmyth/src/gmyth_debug.h Wed May 23 19:50:41 2007 +0100
8.3 @@ -7,22 +7,21 @@
8.4 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
8.5 * @author Renato Filho <renato.filho@indt.org.br>
8.6 *
8.7 - *//*
8.8 - *
8.9 - * This program is free software; you can redistribute it and/or modify
8.10 - * it under the terms of the GNU Lesser General Public License as published by
8.11 - * the Free Software Foundation; either version 2 of the License, or
8.12 - * (at your option) any later version.
8.13 - *
8.14 - * This program is distributed in the hope that it will be useful,
8.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
8.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8.17 - * GNU General Public License for more details.
8.18 - *
8.19 - * You should have received a copy of the GNU Lesser General Public License
8.20 - * along with this program; if not, write to the Free Software
8.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
8.22 - */
8.23 +*
8.24 +* This program is free software; you can redistribute it and/or modify
8.25 +* it under the terms of the GNU Lesser General Public License as published by
8.26 +* the Free Software Foundation; either version 2 of the License, or
8.27 +* (at your option) any later version.
8.28 +*
8.29 +* This program is distributed in the hope that it will be useful,
8.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
8.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8.32 + * GNU General Public License for more details.
8.33 + *
8.34 + * You should have received a copy of the GNU Lesser General Public License
8.35 + * along with this program; if not, write to the Free Software
8.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
8.37 + */
8.38
8.39 #ifndef __GMYTH_DEBUG_H__
8.40 #define __GMYTH_DEBUG_H__
8.41 @@ -38,9 +37,10 @@
8.42 #define gmyth_debug(...)
8.43 #endif
8.44 void
8.45 -gmyth_debug_real (const char *func,
8.46 - const char *file, int line, gboolean newline, const char *format, ...)
8.47 -G_GNUC_PRINTF (5, 6);
8.48 +gmyth_debug_real ( const char *func,
8.49 + const char *file, int line, gboolean newline,
8.50 + const char *format, ... )
8.51 +G_GNUC_PRINTF ( 5, 6 );
8.52
8.53 G_END_DECLS
8.54 #endif
9.1 --- a/gmyth/src/gmyth_epg.c Wed May 23 19:21:26 2007 +0100
9.2 +++ b/gmyth/src/gmyth_epg.c Wed May 23 19:50:41 2007 +0100
9.3 @@ -9,22 +9,21 @@
9.4 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
9.5 * @author Leonardo Sobral Cunha <leonardo.cunha@indt.org.br>
9.6 *
9.7 - *//*
9.8 - *
9.9 - * This program is free software; you can redistribute it and/or modify
9.10 - * it under the terms of the GNU Lesser General Public License as published by
9.11 - * the Free Software Foundation; either version 2 of the License, or
9.12 - * (at your option) any later version.
9.13 - *
9.14 - * This program is distributed in the hope that it will be useful,
9.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
9.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9.17 - * GNU General Public License for more details.
9.18 - *
9.19 - * You should have received a copy of the GNU Lesser General Public License
9.20 - * along with this program; if not, write to the Free Software
9.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
9.22 - */
9.23 +*
9.24 +* This program is free software; you can redistribute it and/or modify
9.25 +* it under the terms of the GNU Lesser General Public License as published by
9.26 +* the Free Software Foundation; either version 2 of the License, or
9.27 +* (at your option) any later version.
9.28 +*
9.29 +* This program is distributed in the hope that it will be useful,
9.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
9.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9.32 + * GNU General Public License for more details.
9.33 + *
9.34 + * You should have received a copy of the GNU Lesser General Public License
9.35 + * along with this program; if not, write to the Free Software
9.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
9.37 + */
9.38
9.39 #ifdef HAVE_CONFIG_H
9.40 #include "config.h"
9.41 @@ -41,46 +40,47 @@
9.42 #include "gmyth_file_transfer.h"
9.43 #include "gmyth_debug.h"
9.44
9.45 -static void gmyth_epg_class_init (GMythEPGClass * klass);
9.46 -static void gmyth_epg_init (GMythEPG * object);
9.47 +static void gmyth_epg_class_init ( GMythEPGClass * klass );
9.48 +static void gmyth_epg_init ( GMythEPG * object );
9.49
9.50 -static void gmyth_epg_dispose (GObject * object);
9.51 -static void gmyth_epg_finalize (GObject * object);
9.52 +static void gmyth_epg_dispose ( GObject * object );
9.53 +static void gmyth_epg_finalize ( GObject * object );
9.54
9.55 -G_DEFINE_TYPE (GMythEPG, gmyth_epg, G_TYPE_OBJECT)
9.56 - static void gmyth_epg_class_init (GMythEPGClass * klass)
9.57 +G_DEFINE_TYPE ( GMythEPG, gmyth_epg, G_TYPE_OBJECT )
9.58 + static void gmyth_epg_class_init ( GMythEPGClass * klass )
9.59 {
9.60 - GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
9.61 + GObjectClass *gobject_class = G_OBJECT_CLASS ( klass );
9.62
9.63 gobject_class->dispose = gmyth_epg_dispose;
9.64 gobject_class->finalize = gmyth_epg_finalize;
9.65 }
9.66
9.67 static void
9.68 -gmyth_epg_init (GMythEPG * gmyth_epg)
9.69 +gmyth_epg_init ( GMythEPG * gmyth_epg )
9.70 {
9.71
9.72 }
9.73
9.74 static void
9.75 -gmyth_epg_dispose (GObject * object)
9.76 +gmyth_epg_dispose ( GObject * object )
9.77 {
9.78 - GMythEPG *gmyth_epg = GMYTH_EPG (object);
9.79 + GMythEPG *gmyth_epg = GMYTH_EPG ( object );
9.80
9.81 - if (gmyth_epg->sqlquery != NULL) {
9.82 - g_object_unref (gmyth_epg->sqlquery);
9.83 + if ( gmyth_epg->sqlquery != NULL )
9.84 + {
9.85 + g_object_unref ( gmyth_epg->sqlquery );
9.86 gmyth_epg->sqlquery = NULL;
9.87 }
9.88
9.89 - G_OBJECT_CLASS (gmyth_epg_parent_class)->dispose (object);
9.90 + G_OBJECT_CLASS ( gmyth_epg_parent_class )->dispose ( object );
9.91 }
9.92
9.93 static void
9.94 -gmyth_epg_finalize (GObject * object)
9.95 +gmyth_epg_finalize ( GObject * object )
9.96 {
9.97 - g_signal_handlers_destroy (object);
9.98 + g_signal_handlers_destroy ( object );
9.99
9.100 - G_OBJECT_CLASS (gmyth_epg_parent_class)->finalize (object);
9.101 + G_OBJECT_CLASS ( gmyth_epg_parent_class )->finalize ( object );
9.102 }
9.103
9.104 /**
9.105 @@ -89,9 +89,9 @@
9.106 * @return a new instance of GMythEPG.
9.107 */
9.108 GMythEPG *
9.109 -gmyth_epg_new (void)
9.110 +gmyth_epg_new ( void )
9.111 {
9.112 - GMythEPG *epg = GMYTH_EPG (g_object_new (GMYTH_EPG_TYPE, NULL));
9.113 + GMythEPG *epg = GMYTH_EPG ( g_object_new ( GMYTH_EPG_TYPE, NULL ) );
9.114
9.115 return epg;
9.116 }
9.117 @@ -103,22 +103,24 @@
9.118 * @return true if connection was success, false if failed.
9.119 */
9.120 gboolean
9.121 -gmyth_epg_connect (GMythEPG * gmyth_epg, GMythBackendInfo * backend_info)
9.122 +gmyth_epg_connect ( GMythEPG * gmyth_epg, GMythBackendInfo * backend_info )
9.123 {
9.124 - g_return_val_if_fail (gmyth_epg != NULL, FALSE);
9.125 + g_return_val_if_fail ( gmyth_epg != NULL, FALSE );
9.126
9.127 - if (gmyth_epg->sqlquery == NULL) {
9.128 - gmyth_debug ("[%s] Creating gmyth_query", __FUNCTION__);
9.129 - gmyth_epg->sqlquery = gmyth_query_new ();
9.130 + if ( gmyth_epg->sqlquery == NULL )
9.131 + {
9.132 + gmyth_debug ( "[%s] Creating gmyth_query", __FUNCTION__ );
9.133 + gmyth_epg->sqlquery = gmyth_query_new ( );
9.134 }
9.135
9.136 - if (!gmyth_query_connect (gmyth_epg->sqlquery, backend_info)) {
9.137 - gmyth_debug ("[%s] Error while connecting to db", __FUNCTION__);
9.138 + if ( !gmyth_query_connect ( gmyth_epg->sqlquery, backend_info ) )
9.139 + {
9.140 + gmyth_debug ( "[%s] Error while connecting to db", __FUNCTION__ );
9.141 return FALSE;
9.142 }
9.143
9.144 gmyth_epg->backend_info = backend_info;
9.145 - g_object_ref (backend_info);
9.146 + g_object_ref ( backend_info );
9.147
9.148 return TRUE;
9.149 }
9.150 @@ -129,18 +131,20 @@
9.151 * @return true if disconnection was success, false if failed.
9.152 */
9.153 gboolean
9.154 -gmyth_epg_disconnect (GMythEPG * gmyth_epg)
9.155 +gmyth_epg_disconnect ( GMythEPG * gmyth_epg )
9.156 {
9.157 - g_return_val_if_fail (gmyth_epg != NULL, FALSE);
9.158 + g_return_val_if_fail ( gmyth_epg != NULL, FALSE );
9.159
9.160 - if (gmyth_epg->sqlquery != NULL) {
9.161 - gmyth_query_disconnect (gmyth_epg->sqlquery);
9.162 - g_object_unref (gmyth_epg->sqlquery);
9.163 + if ( gmyth_epg->sqlquery != NULL )
9.164 + {
9.165 + gmyth_query_disconnect ( gmyth_epg->sqlquery );
9.166 + g_object_unref ( gmyth_epg->sqlquery );
9.167 gmyth_epg->sqlquery = NULL;
9.168 }
9.169
9.170 - if (gmyth_epg->backend_info != NULL) {
9.171 - g_object_unref (gmyth_epg->backend_info);
9.172 + if ( gmyth_epg->backend_info != NULL )
9.173 + {
9.174 + g_object_unref ( gmyth_epg->backend_info );
9.175 gmyth_epg->backend_info = NULL;
9.176 }
9.177
9.178 @@ -154,77 +158,85 @@
9.179 * @return The amount of channels retrieved from database, or -1 if error.
9.180 */
9.181 gint
9.182 -gmyth_epg_get_channel_list (GMythEPG * gmyth_epg, GList ** glist_ptr)
9.183 +gmyth_epg_get_channel_list ( GMythEPG * gmyth_epg, GList ** glist_ptr )
9.184 {
9.185 MYSQL_RES *msql_res;
9.186
9.187 - g_return_val_if_fail (gmyth_epg != NULL, -1);
9.188 + g_return_val_if_fail ( gmyth_epg != NULL, -1 );
9.189
9.190 - msql_res = gmyth_query_process_statement (gmyth_epg->sqlquery,
9.191 - "SELECT chanid, channum, name, icon FROM channel;");
9.192 + msql_res = gmyth_query_process_statement ( gmyth_epg->sqlquery,
9.193 + "SELECT chanid, channum, name, icon FROM channel;" );
9.194
9.195 - (*glist_ptr) = NULL;
9.196 + ( *glist_ptr ) = NULL;
9.197
9.198 - if (msql_res == NULL) {
9.199 - gmyth_debug ("[%s] msql query returned NULL MYSQL_RES", __FUNCTION__);
9.200 + if ( msql_res == NULL )
9.201 + {
9.202 + gmyth_debug ( "[%s] msql query returned NULL MYSQL_RES", __FUNCTION__ );
9.203 return -1;
9.204 - } else {
9.205 + }
9.206 + else
9.207 + {
9.208 MYSQL_ROW row;
9.209 GMythChannelInfo *channel_info;
9.210
9.211 - while ((row = mysql_fetch_row (msql_res)) != NULL) {
9.212 + while ( ( row = mysql_fetch_row ( msql_res ) ) != NULL )
9.213 + {
9.214
9.215 - channel_info = g_new0 (GMythChannelInfo, 1);
9.216 + channel_info = g_new0 ( GMythChannelInfo, 1 );
9.217 channel_info->channel_ID =
9.218 - (gint) g_ascii_strtoull (row[0], NULL, 10);
9.219 - channel_info->channel_num = g_string_new (row[1]);
9.220 - channel_info->channel_name = g_string_new (row[2]);
9.221 - channel_info->channel_icon = g_string_new (row[3]);
9.222 + ( gint ) g_ascii_strtoull ( row[0], NULL, 10 );
9.223 + channel_info->channel_num = g_string_new ( row[1] );
9.224 + channel_info->channel_name = g_string_new ( row[2] );
9.225 + channel_info->channel_icon = g_string_new ( row[3] );
9.226 #ifdef GMYTH_USE_DEBUG
9.227 - gmyth_channel_info_print (channel_info);
9.228 + gmyth_channel_info_print ( channel_info );
9.229 #endif
9.230 - (*glist_ptr) = g_list_append ((*glist_ptr), channel_info);
9.231 + ( *glist_ptr ) = g_list_append ( ( *glist_ptr ), channel_info );
9.232 }
9.233 }
9.234 - mysql_free_result (msql_res);
9.235 + mysql_free_result ( msql_res );
9.236
9.237 - return (!(*glist_ptr)) ? 0 : g_list_length (*glist_ptr);
9.238 + return ( !( *glist_ptr ) ) ? 0 : g_list_length ( *glist_ptr );
9.239 }
9.240
9.241 GMythChannelInfo *
9.242 -gmyth_epg_get_channel_info (GMythEPG * gmyth_epg, gint channel_id)
9.243 +gmyth_epg_get_channel_info ( GMythEPG * gmyth_epg, gint channel_id )
9.244 {
9.245 GMythChannelInfo *channel_info = NULL;
9.246 MYSQL_RES *msql_res;
9.247 gchar *query_str;
9.248
9.249 - g_return_val_if_fail (gmyth_epg != NULL, NULL);
9.250 + g_return_val_if_fail ( gmyth_epg != NULL, NULL );
9.251
9.252 query_str =
9.253 g_strdup_printf
9.254 - ("SELECT channum, name, icon FROM channel WHERE chanid=%d;",
9.255 - channel_id);
9.256 - msql_res = gmyth_query_process_statement (gmyth_epg->sqlquery, query_str);
9.257 + ( "SELECT channum, name, icon FROM channel WHERE chanid=%d;",
9.258 + channel_id );
9.259 + msql_res = gmyth_query_process_statement ( gmyth_epg->sqlquery, query_str );
9.260
9.261 - if (msql_res == NULL) {
9.262 - gmyth_debug ("[%s] msql query returned NULL MYSQL_RES", __FUNCTION__);
9.263 + if ( msql_res == NULL )
9.264 + {
9.265 + gmyth_debug ( "[%s] msql query returned NULL MYSQL_RES", __FUNCTION__ );
9.266 return NULL;
9.267 - } else {
9.268 + }
9.269 + else
9.270 + {
9.271 MYSQL_ROW row;
9.272
9.273 - if ((row = mysql_fetch_row (msql_res)) != NULL) {
9.274 + if ( ( row = mysql_fetch_row ( msql_res ) ) != NULL )
9.275 + {
9.276
9.277 - channel_info = g_new0 (GMythChannelInfo, 1);
9.278 + channel_info = g_new0 ( GMythChannelInfo, 1 );
9.279 channel_info->channel_ID = channel_id;
9.280 - channel_info->channel_num = g_string_new (row[0]);
9.281 - channel_info->channel_name = g_string_new (row[1]);
9.282 - channel_info->channel_icon = g_string_new (row[2]);
9.283 + channel_info->channel_num = g_string_new ( row[0] );
9.284 + channel_info->channel_name = g_string_new ( row[1] );
9.285 + channel_info->channel_icon = g_string_new ( row[2] );
9.286 #ifdef GMYTH_USE_DEBUG
9.287 - gmyth_channel_info_print (channel_info);
9.288 + gmyth_channel_info_print ( channel_info );
9.289 #endif
9.290 }
9.291 }
9.292 - mysql_free_result (msql_res);
9.293 + mysql_free_result ( msql_res );
9.294
9.295 return channel_info;
9.296 }
9.297 @@ -240,130 +252,138 @@
9.298 * @return The amount of channels retrieved from database, or -1 if error.
9.299 */
9.300 gint
9.301 -gmyth_epg_get_program_list (GMythEPG * gmyth_epg, GList ** proglist,
9.302 - const gint chan_num, GTimeVal * starttime, GTimeVal * endtime)
9.303 +gmyth_epg_get_program_list ( GMythEPG * gmyth_epg, GList ** proglist,
9.304 + const gint chan_num, GTimeVal * starttime,
9.305 + GTimeVal * endtime )
9.306 {
9.307
9.308 - gchar *startts = gmyth_util_time_to_string_from_time_val (starttime);
9.309 - gchar *endts = gmyth_util_time_to_string_from_time_val (endtime);
9.310 + gchar *startts = gmyth_util_time_to_string_from_time_val ( starttime );
9.311 + gchar *endts = gmyth_util_time_to_string_from_time_val ( endtime );
9.312 MYSQL_ROW row;
9.313 GString *querystr;
9.314
9.315 - assert (gmyth_epg);
9.316 + assert ( gmyth_epg );
9.317
9.318 querystr =
9.319 g_string_new
9.320 - ("SELECT DISTINCT program.chanid, program.starttime, program.endtime, "
9.321 - " program.title, program.subtitle, program.description, "
9.322 - " program.category, channel.channum, channel.callsign, "
9.323 - " channel.name, program.previouslyshown, channel.commfree, "
9.324 - " channel.outputfilters, program.seriesid, program.programid, "
9.325 - " program.airdate, program.stars, program.originalairdate, "
9.326 - " program.category_type, oldrecstatus.recordid, "
9.327 - " oldrecstatus.rectype, oldrecstatus.recstatus, "
9.328 - " oldrecstatus.findid " "FROM program "
9.329 - "LEFT JOIN channel ON program.chanid = channel.chanid "
9.330 - "LEFT JOIN oldrecorded AS oldrecstatus ON "
9.331 - " program.title = oldrecstatus.title AND "
9.332 - " channel.callsign = oldrecstatus.station AND "
9.333 - " program.starttime = oldrecstatus.starttime ");
9.334 + ( "SELECT DISTINCT program.chanid, program.starttime, program.endtime, "
9.335 + " program.title, program.subtitle, program.description, "
9.336 + " program.category, channel.channum, channel.callsign, "
9.337 + " channel.name, program.previouslyshown, channel.commfree, "
9.338 + " channel.outputfilters, program.seriesid, program.programid, "
9.339 + " program.airdate, program.stars, program.originalairdate, "
9.340 + " program.category_type, oldrecstatus.recordid, "
9.341 + " oldrecstatus.rectype, oldrecstatus.recstatus, "
9.342 + " oldrecstatus.findid " "FROM program "
9.343 + "LEFT JOIN channel ON program.chanid = channel.chanid "
9.344 + "LEFT JOIN oldrecorded AS oldrecstatus ON "
9.345 + " program.title = oldrecstatus.title AND "
9.346 + " channel.callsign = oldrecstatus.station AND "
9.347 + " program.starttime = oldrecstatus.starttime " );
9.348
9.349 - g_string_append_printf (querystr,
9.350 - "WHERE program.chanid = %d "
9.351 - " AND program.endtime >= '%s' "
9.352 - " AND program.starttime <= '%s' "
9.353 - " AND program.manualid = 0 ", chan_num, startts, endts);
9.354 + g_string_append_printf ( querystr,
9.355 + "WHERE program.chanid = %d "
9.356 + " AND program.endtime >= '%s' "
9.357 + " AND program.starttime <= '%s' "
9.358 + " AND program.manualid = 0 ", chan_num, startts,
9.359 + endts );
9.360
9.361 - if (!g_strrstr (querystr->str, " GROUP BY "))
9.362 - querystr = g_string_append (querystr,
9.363 - " GROUP BY program.starttime, channel.channum, "
9.364 - " channel.callsign, program.title ");
9.365 + if ( !g_strrstr ( querystr->str, " GROUP BY " ) )
9.366 + querystr = g_string_append ( querystr,
9.367 + " GROUP BY program.starttime, channel.channum, "
9.368 + " channel.callsign, program.title " );
9.369
9.370 - if (!g_strrstr (querystr->str, " LIMIT "))
9.371 - querystr = g_string_append (querystr, " LIMIT 1000 ");
9.372 + if ( !g_strrstr ( querystr->str, " LIMIT " ) )
9.373 + querystr = g_string_append ( querystr, " LIMIT 1000 " );
9.374
9.375 MYSQL_RES *res_set =
9.376 - gmyth_query_process_statement (gmyth_epg->sqlquery, querystr->str);
9.377 + gmyth_query_process_statement ( gmyth_epg->sqlquery, querystr->str );
9.378
9.379 - if (res_set == NULL) {
9.380 - gmyth_debug ("[%s] msql query returned NULL MYSQL_RES", __FUNCTION__);
9.381 + if ( res_set == NULL )
9.382 + {
9.383 + gmyth_debug ( "[%s] msql query returned NULL MYSQL_RES", __FUNCTION__ );
9.384 return -1;
9.385 }
9.386
9.387 - (*proglist) = NULL;
9.388 - while ((row = mysql_fetch_row (res_set)) != NULL) {
9.389 + ( *proglist ) = NULL;
9.390 + while ( ( row = mysql_fetch_row ( res_set ) ) != NULL )
9.391 + {
9.392
9.393 - GMythProgramInfo *p = gmyth_program_info_new ();
9.394 + GMythProgramInfo *p = gmyth_program_info_new ( );
9.395
9.396 - p->chanid = g_string_new (row[0]);
9.397 + p->chanid = g_string_new ( row[0] );
9.398
9.399 - p->startts = gmyth_util_string_to_time_val (row[1]);
9.400 - p->endts = gmyth_util_string_to_time_val (row[2]);
9.401 + p->startts = gmyth_util_string_to_time_val ( row[1] );
9.402 + p->endts = gmyth_util_string_to_time_val ( row[2] );
9.403
9.404 - p->recstartts = g_new0 (GTimeVal, 1);
9.405 + p->recstartts = g_new0 ( GTimeVal, 1 );
9.406 p->recstartts->tv_sec = p->startts->tv_sec;
9.407 p->recstartts->tv_usec = p->startts->tv_usec;
9.408
9.409 - p->recendts = g_new0 (GTimeVal, 1);
9.410 + p->recendts = g_new0 ( GTimeVal, 1 );
9.411 p->recendts->tv_sec = p->endts->tv_sec;
9.412 p->recendts->tv_usec = p->endts->tv_usec;
9.413
9.414 - p->lastmodified = g_new0 (GTimeVal, 1);
9.415 + p->lastmodified = g_new0 ( GTimeVal, 1 );
9.416 p->lastmodified->tv_sec = p->startts->tv_sec;
9.417 p->lastmodified->tv_usec = p->startts->tv_usec;
9.418
9.419 - p->title = g_string_new (row[3]);
9.420 - p->subtitle = g_string_new (row[4]);
9.421 - p->description = g_string_new (row[5]);
9.422 - p->category = g_string_new (row[6]);
9.423 - p->chanstr = g_string_new (row[7]);
9.424 - p->chansign = g_string_new (row[8]);
9.425 - p->channame = g_string_new (row[9]);
9.426 - p->repeat = g_ascii_strtoull (row[10], NULL, 10);
9.427 - p->chancommfree = g_ascii_strtoull (row[11], NULL, 10);
9.428 - p->chanOutputFilters = g_string_new (row[12]);
9.429 - p->seriesid = g_string_new (row[13]);
9.430 - p->programid = g_string_new (row[14]);
9.431 - p->year = g_string_new (row[15]);
9.432 - p->stars = g_ascii_strtod (row[16], NULL);
9.433 + p->title = g_string_new ( row[3] );
9.434 + p->subtitle = g_string_new ( row[4] );
9.435 + p->description = g_string_new ( row[5] );
9.436 + p->category = g_string_new ( row[6] );
9.437 + p->chanstr = g_string_new ( row[7] );
9.438 + p->chansign = g_string_new ( row[8] );
9.439 + p->channame = g_string_new ( row[9] );
9.440 + p->repeat = g_ascii_strtoull ( row[10], NULL, 10 );
9.441 + p->chancommfree = g_ascii_strtoull ( row[11], NULL, 10 );
9.442 + p->chanOutputFilters = g_string_new ( row[12] );
9.443 + p->seriesid = g_string_new ( row[13] );
9.444 + p->programid = g_string_new ( row[14] );
9.445 + p->year = g_string_new ( row[15] );
9.446 + p->stars = g_ascii_strtod ( row[16], NULL );
9.447
9.448 - if (!row[17] || !strcmp (row[17], "")) {
9.449 + if ( !row[17] || !strcmp ( row[17], "" ) )
9.450 + {
9.451 p->originalAirDate = 0;
9.452 p->hasAirDate = FALSE;
9.453 - } else {
9.454 - p->originalAirDate = gmyth_util_string_to_time_val (row[17]);
9.455 + }
9.456 + else
9.457 + {
9.458 + p->originalAirDate = gmyth_util_string_to_time_val ( row[17] );
9.459 p->hasAirDate = TRUE;
9.460 }
9.461
9.462 - p->catType = g_string_new (row[18]);
9.463 + p->catType = g_string_new ( row[18] );
9.464
9.465 - *proglist = g_list_append ((*proglist), p);
9.466 + *proglist = g_list_append ( ( *proglist ), p );
9.467
9.468 #ifdef GMYTH_USE_DEBUG
9.469 - gmyth_program_info_print (p);
9.470 + gmyth_program_info_print ( p );
9.471 #endif
9.472 }
9.473
9.474 /* deallocate */
9.475 - mysql_free_result (res_set);
9.476 - g_string_free (querystr, TRUE);
9.477 + mysql_free_result ( res_set );
9.478 + g_string_free ( querystr, TRUE );
9.479
9.480 return TRUE;
9.481 }
9.482
9.483 gboolean
9.484 -gmyth_epg_channel_has_icon (GMythEPG * gmyth_epg,
9.485 - GMythChannelInfo * channel_info)
9.486 +gmyth_epg_channel_has_icon ( GMythEPG * gmyth_epg,
9.487 + GMythChannelInfo * channel_info )
9.488 {
9.489 gboolean res = FALSE;
9.490
9.491 - g_return_val_if_fail (gmyth_epg != NULL, FALSE);
9.492 - g_return_val_if_fail (channel_info != NULL, FALSE);
9.493 + g_return_val_if_fail ( gmyth_epg != NULL, FALSE );
9.494 + g_return_val_if_fail ( channel_info != NULL, FALSE );
9.495
9.496 - if (channel_info->channel_icon != NULL) {
9.497 + if ( channel_info->channel_icon != NULL )
9.498 + {
9.499 res =
9.500 - gmyth_util_file_exists (gmyth_epg->backend_info,
9.501 - channel_info->channel_icon->str);
9.502 + gmyth_util_file_exists ( gmyth_epg->backend_info,
9.503 + channel_info->channel_icon->str );
9.504 }
9.505
9.506 return res;
9.507 @@ -376,47 +396,55 @@
9.508 * @return TRUE if success, FALSE if any error happens.
9.509 */
9.510 gboolean
9.511 -gmyth_epg_channel_get_icon (GMythEPG * gmyth_epg,
9.512 - GMythChannelInfo * channel_info, guint8 ** data, guint * length)
9.513 +gmyth_epg_channel_get_icon ( GMythEPG * gmyth_epg,
9.514 + GMythChannelInfo * channel_info, guint8 ** data,
9.515 + guint * length )
9.516 {
9.517 gboolean res = FALSE;
9.518
9.519 - g_return_val_if_fail (gmyth_epg != NULL, FALSE);
9.520 - g_return_val_if_fail (channel_info != NULL, FALSE);
9.521 + g_return_val_if_fail ( gmyth_epg != NULL, FALSE );
9.522 + g_return_val_if_fail ( channel_info != NULL, FALSE );
9.523
9.524 - if (gmyth_epg_channel_has_icon (gmyth_epg, channel_info)) {
9.525 + if ( gmyth_epg_channel_has_icon ( gmyth_epg, channel_info ) )
9.526 + {
9.527 GMythFileTransfer *transfer =
9.528 - gmyth_file_transfer_new (gmyth_epg->backend_info);
9.529 + gmyth_file_transfer_new ( gmyth_epg->backend_info );
9.530 GMythFileReadResult gmyth_res;
9.531 GByteArray *icon_data;
9.532 guint64 icon_length = 0;
9.533
9.534 res =
9.535 - gmyth_file_transfer_open (transfer,
9.536 - channel_info->channel_icon->str);
9.537 - if (!res) {
9.538 - gmyth_debug ("Channel icon could not be opened");
9.539 + gmyth_file_transfer_open ( transfer,
9.540 + channel_info->channel_icon->str );
9.541 + if ( !res )
9.542 + {
9.543 + gmyth_debug ( "Channel icon could not be opened" );
9.544 return FALSE;
9.545 }
9.546
9.547 - icon_length = gmyth_file_transfer_get_filesize (transfer);
9.548 - if (icon_length <= 0) {
9.549 - gmyth_debug ("Channel icon file size is zero or negative");
9.550 + icon_length = gmyth_file_transfer_get_filesize ( transfer );
9.551 + if ( icon_length <= 0 )
9.552 + {
9.553 + gmyth_debug ( "Channel icon file size is zero or negative" );
9.554 return FALSE;
9.555 }
9.556
9.557 - icon_data = g_byte_array_new ();
9.558 + icon_data = g_byte_array_new ( );
9.559 gmyth_res =
9.560 - gmyth_file_transfer_read (transfer, icon_data, icon_length, FALSE);
9.561 - if (gmyth_res == GMYTH_FILE_READ_EOF) {
9.562 + gmyth_file_transfer_read ( transfer, icon_data, icon_length,
9.563 + FALSE );
9.564 + if ( gmyth_res == GMYTH_FILE_READ_EOF )
9.565 + {
9.566 *length = icon_length;
9.567 *data = icon_data->data;
9.568 - g_byte_array_free (icon_data, FALSE);
9.569 + g_byte_array_free ( icon_data, FALSE );
9.570 res = TRUE;
9.571 - } else {
9.572 + }
9.573 + else
9.574 + {
9.575 *length = 0;
9.576 *data = NULL;
9.577 - g_byte_array_free (icon_data, TRUE);
9.578 + g_byte_array_free ( icon_data, TRUE );
9.579 }
9.580 }
9.581
10.1 --- a/gmyth/src/gmyth_epg.h Wed May 23 19:21:26 2007 +0100
10.2 +++ b/gmyth/src/gmyth_epg.h Wed May 23 19:50:41 2007 +0100
10.3 @@ -9,22 +9,21 @@
10.4 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
10.5 * @author Leonardo Sobral Cunha <leonardo.cunha@indt.org.br>
10.6 *
10.7 - *//*
10.8 - *
10.9 - * This program is free software; you can redistribute it and/or modify
10.10 - * it under the terms of the GNU Lesser General Public License as published by
10.11 - * the Free Software Foundation; either version 2 of the License, or
10.12 - * (at your option) any later version.
10.13 - *
10.14 - * This program is distributed in the hope that it will be useful,
10.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
10.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10.17 - * GNU General Public License for more details.
10.18 - *
10.19 - * You should have received a copy of the GNU Lesser General Public License
10.20 - * along with this program; if not, write to the Free Software
10.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
10.22 - */
10.23 +*
10.24 +* This program is free software; you can redistribute it and/or modify
10.25 +* it under the terms of the GNU Lesser General Public License as published by
10.26 +* the Free Software Foundation; either version 2 of the License, or
10.27 +* (at your option) any later version.
10.28 +*
10.29 +* This program is distributed in the hope that it will be useful,
10.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
10.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10.32 + * GNU General Public License for more details.
10.33 + *
10.34 + * You should have received a copy of the GNU Lesser General Public License
10.35 + * along with this program; if not, write to the Free Software
10.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
10.37 + */
10.38
10.39 #ifndef GMYTH_EPG_H_
10.40 #define GMYTH_EPG_H_
10.41 @@ -45,41 +44,43 @@
10.42 typedef struct _GMythEPGClass GMythEPGClass;
10.43
10.44 struct _GMythEPGClass
10.45 -{
10.46 - GObjectClass parent_class;
10.47 + {
10.48 + GObjectClass parent_class;
10.49
10.50 - /* callbacks */
10.51 - /* no one for now */
10.52 -};
10.53 + /* callbacks */
10.54 + /* no one for now */
10.55 + };
10.56
10.57 struct _GMythEPG
10.58 -{
10.59 - GObject parent;
10.60 + {
10.61 + GObject parent;
10.62
10.63 - GMythQuery *sqlquery;
10.64 - GMythBackendInfo *backend_info;
10.65 -};
10.66 + GMythQuery *sqlquery;
10.67 + GMythBackendInfo *backend_info;
10.68 + };
10.69
10.70 -GType gmyth_epg_get_type (void);
10.71 +GType gmyth_epg_get_type ( void );
10.72
10.73 -GMythEPG *gmyth_epg_new (void);
10.74 +GMythEPG *gmyth_epg_new ( void );
10.75
10.76 -gboolean gmyth_epg_connect (GMythEPG * gmyth_epg,
10.77 - GMythBackendInfo * backend_info);
10.78 -gboolean gmyth_epg_disconnect (GMythEPG * gmyth_epg);
10.79 +gboolean gmyth_epg_connect ( GMythEPG * gmyth_epg,
10.80 + GMythBackendInfo * backend_info );
10.81 +gboolean gmyth_epg_disconnect ( GMythEPG * gmyth_epg );
10.82
10.83 -gint gmyth_epg_get_channel_list (GMythEPG * gmyth_epg, GList ** glist_ptr);
10.84 -gint gmyth_epg_get_program_list (GMythEPG * gmyth_epg, GList ** proglist,
10.85 - const gint chanNum, GTimeVal * starttime, GTimeVal * endtime);
10.86 +gint gmyth_epg_get_channel_list ( GMythEPG * gmyth_epg, GList ** glist_ptr );
10.87 +gint gmyth_epg_get_program_list ( GMythEPG * gmyth_epg, GList ** proglist,
10.88 + const gint chanNum, GTimeVal * starttime,
10.89 + GTimeVal * endtime );
10.90
10.91 -GMythChannelInfo *gmyth_epg_get_channel_info (GMythEPG * gmyth_epg,
10.92 - gint channel_id);
10.93 +GMythChannelInfo *gmyth_epg_get_channel_info ( GMythEPG * gmyth_epg,
10.94 + gint channel_id );
10.95
10.96
10.97 -gboolean gmyth_epg_channel_has_icon (GMythEPG * gmyth_epg,
10.98 - GMythChannelInfo * channel);
10.99 -gboolean gmyth_epg_channel_get_icon (GMythEPG * gmyth_epg,
10.100 - GMythChannelInfo * channel, guint8 ** data, guint * length);
10.101 +gboolean gmyth_epg_channel_has_icon ( GMythEPG * gmyth_epg,
10.102 + GMythChannelInfo * channel );
10.103 +gboolean gmyth_epg_channel_get_icon ( GMythEPG * gmyth_epg,
10.104 + GMythChannelInfo * channel,
10.105 + guint8 ** data, guint * length );
10.106
10.107
10.108 #endif /*GMYTH_EPG_H_ */
11.1 --- a/gmyth/src/gmyth_file.c Wed May 23 19:21:26 2007 +0100
11.2 +++ b/gmyth/src/gmyth_file.c Wed May 23 19:50:41 2007 +0100
11.3 @@ -9,22 +9,21 @@
11.4 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
11.5 * @author Rosfran Lins Borges <rosfran.borges@indt.org.br>
11.6 *
11.7 - *//*
11.8 - *
11.9 - * This program is free software; you can redistribute it and/or modify
11.10 - * it under the terms of the GNU Lesser General Public License as published by
11.11 - * the Free Software Foundation; either version 2 of the License, or
11.12 - * (at your option) any later version.
11.13 - *
11.14 - * This program is distributed in the hope that it will be useful,
11.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
11.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11.17 - * GNU General Public License for more details.
11.18 - *
11.19 - * You should have received a copy of the GNU Lesser General Public License
11.20 - * along with this program; if not, write to the Free Software
11.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
11.22 - */
11.23 + *
11.24 + * This program is free software; you can redistribute it and/or modify
11.25 + * it under the terms of the GNU Lesser General Public License as published by
11.26 + * the Free Software Foundation; either version 2 of the License, or
11.27 + * (at your option) any later version.
11.28 + *
11.29 + * This program is distributed in the hope that it will be useful,
11.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
11.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11.32 + * GNU General Public License for more details.
11.33 + *
11.34 + * You should have received a copy of the GNU Lesser General Public License
11.35 + * along with this program; if not, write to the Free Software
11.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
11.37 + */
11.38
11.39 #ifdef HAVE_CONFIG_H
11.40 #include "config.h"
11.41 @@ -51,50 +50,51 @@
11.42 #include <assert.h>
11.43
11.44 #define GMYTH_FILE_GET_PRIVATE(obj) \
11.45 - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GMYTH_FILE_TYPE, GMythFilePrivate))
11.46 + (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GMYTH_FILE_TYPE, GMythFilePrivate))
11.47
11.48 struct _GMythFilePrivate
11.49 -{
11.50 - gboolean disposed;
11.51 - gint64 offset;
11.52 - guint64 filesize;
11.53 + {
11.54 + gboolean disposed;
11.55 + gint64 offset;
11.56 + guint64 filesize;
11.57
11.58 - GMythBackendInfo *backend_info;
11.59 + GMythBackendInfo *backend_info;
11.60
11.61 - /* Myth URI structure */
11.62 - gchar *filename;
11.63 + /* Myth URI structure */
11.64 + gchar *filename;
11.65
11.66 - gint file_id;
11.67 -};
11.68 + gint file_id;
11.69 + };
11.70
11.71 enum
11.72 -{
11.73 - PROP_GMYTH_FILE_DUMMY,
11.74 - PROP_GMYTH_FILE_FILENAME,
11.75 - PROP_GMYTH_FILE_OFFSET,
11.76 - PROP_GMYTH_FILE_FILESIZE,
11.77 - PROP_GMYTH_FILE_BACKEND_INFO,
11.78 - PROP_GMYTH_FILE_FILEID
11.79 -};
11.80 + {
11.81 + PROP_GMYTH_FILE_DUMMY,
11.82 + PROP_GMYTH_FILE_FILENAME,
11.83 + PROP_GMYTH_FILE_OFFSET,
11.84 + PROP_GMYTH_FILE_FILESIZE,
11.85 + PROP_GMYTH_FILE_BACKEND_INFO,
11.86 + PROP_GMYTH_FILE_FILEID
11.87 + };
11.88
11.89 -static void gmyth_file_set_property (GObject * object, guint prop_id,
11.90 - const GValue * value, GParamSpec * pspec);
11.91 -static void gmyth_file_get_property (GObject * object, guint prop_id,
11.92 - GValue * value, GParamSpec * pspec);
11.93 +static void gmyth_file_set_property ( GObject * object, guint prop_id,
11.94 + const GValue * value,
11.95 + GParamSpec * pspec );
11.96 +static void gmyth_file_get_property ( GObject * object, guint prop_id,
11.97 + GValue * value, GParamSpec * pspec );
11.98
11.99 -static void gmyth_file_class_init (GMythFileClass * klass);
11.100 -static void gmyth_file_init (GMythFile * object);
11.101 -static void gmyth_file_dispose (GObject * object);
11.102 -static void gmyth_file_finalize (GObject * object);
11.103 +static void gmyth_file_class_init ( GMythFileClass * klass );
11.104 +static void gmyth_file_init ( GMythFile * object );
11.105 +static void gmyth_file_dispose ( GObject * object );
11.106 +static void gmyth_file_finalize ( GObject * object );
11.107
11.108 -G_DEFINE_TYPE (GMythFile, gmyth_file, G_TYPE_OBJECT)
11.109 - static void gmyth_file_class_init (GMythFileClass * klass)
11.110 +G_DEFINE_TYPE ( GMythFile, gmyth_file, G_TYPE_OBJECT )
11.111 + static void gmyth_file_class_init ( GMythFileClass * klass )
11.112 {
11.113 GObjectClass *gobject_class;
11.114 GMythFileClass *gtransfer_class;
11.115
11.116 - gobject_class = (GObjectClass *) klass;
11.117 - gtransfer_class = (GMythFileClass *) gobject_class;
11.118 + gobject_class = ( GObjectClass * ) klass;
11.119 + gtransfer_class = ( GMythFileClass * ) gobject_class;
11.120
11.121 gobject_class->dispose = gmyth_file_dispose;
11.122 gobject_class->finalize = gmyth_file_finalize;
11.123 @@ -103,67 +103,73 @@
11.124 gobject_class->get_property = gmyth_file_get_property;
11.125
11.126 g_object_class_install_property
11.127 - (gobject_class, PROP_GMYTH_FILE_FILENAME,
11.128 - g_param_spec_string ("filename", "filename",
11.129 - "The file name.",
11.130 - "",
11.131 - G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK |
11.132 - G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
11.133 + ( gobject_class, PROP_GMYTH_FILE_FILENAME,
11.134 + g_param_spec_string ( "filename", "filename",
11.135 + "The file name.",
11.136 + "",
11.137 + G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK |
11.138 + G_PARAM_STATIC_BLURB | G_PARAM_READABLE |
11.139 + G_PARAM_WRITABLE ) );
11.140
11.141 g_object_class_install_property
11.142 - (gobject_class, PROP_GMYTH_FILE_OFFSET,
11.143 - g_param_spec_int64 ("file-offset", "file-offset",
11.144 - "The offset (position) of this file", 0,
11.145 - G_MAXINT64, 0,
11.146 - G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK |
11.147 - G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
11.148 + ( gobject_class, PROP_GMYTH_FILE_OFFSET,
11.149 + g_param_spec_int64 ( "file-offset", "file-offset",
11.150 + "The offset (position) of this file", 0,
11.151 + G_MAXINT64, 0,
11.152 + G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK |
11.153 + G_PARAM_STATIC_BLURB | G_PARAM_READABLE |
11.154 + G_PARAM_WRITABLE ) );
11.155
11.156 g_object_class_install_property
11.157 - (gobject_class, PROP_GMYTH_FILE_FILESIZE,
11.158 - g_param_spec_uint64 ("file-size", "file-size",
11.159 - "The file size in bytes",
11.160 - 0, G_MAXUINT64, 0,
11.161 - G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK |
11.162 - G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
11.163 + ( gobject_class, PROP_GMYTH_FILE_FILESIZE,
11.164 + g_param_spec_uint64 ( "file-size", "file-size",
11.165 + "The file size in bytes",
11.166 + 0, G_MAXUINT64, 0,
11.167 + G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK |
11.168 + G_PARAM_STATIC_BLURB | G_PARAM_READABLE |
11.169 + G_PARAM_WRITABLE ) );
11.170
11.171 g_object_class_install_property
11.172 - (gobject_class, PROP_GMYTH_FILE_BACKEND_INFO,
11.173 - g_param_spec_object ("backend-info", "backend-info",
11.174 - "The Backend Information about the remote server",
11.175 - G_TYPE_OBJECT,
11.176 - G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK |
11.177 - G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
11.178 + ( gobject_class, PROP_GMYTH_FILE_BACKEND_INFO,
11.179 + g_param_spec_object ( "backend-info", "backend-info",
11.180 + "The Backend Information about the remote server",
11.181 + G_TYPE_OBJECT,
11.182 + G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK |
11.183 + G_PARAM_STATIC_BLURB | G_PARAM_READABLE |
11.184 + G_PARAM_WRITABLE ) );
11.185
11.186 g_object_class_install_property
11.187 - (gobject_class, PROP_GMYTH_FILE_FILEID,
11.188 - g_param_spec_int ("file-id", "file-id",
11.189 - "The file ID", 0, G_MAXINT, 0,
11.190 - G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK |
11.191 - G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
11.192 + ( gobject_class, PROP_GMYTH_FILE_FILEID,
11.193 + g_param_spec_int ( "file-id", "file-id",
11.194 + "The file ID", 0, G_MAXINT, 0,
11.195 + G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK |
11.196 + G_PARAM_STATIC_BLURB | G_PARAM_READABLE |
11.197 + G_PARAM_WRITABLE ) );
11.198
11.199 - g_type_class_add_private (gobject_class, sizeof (GMythFilePrivate));
11.200 + g_type_class_add_private ( gobject_class, sizeof ( GMythFilePrivate ) );
11.201
11.202 }
11.203
11.204 static void
11.205 -gmyth_file_init (GMythFile * file)
11.206 +gmyth_file_init ( GMythFile * file )
11.207 {
11.208 - g_return_if_fail (file != NULL);
11.209 + g_return_if_fail ( file != NULL );
11.210
11.211 - file->priv = GMYTH_FILE_GET_PRIVATE (file);
11.212 + file->priv = GMYTH_FILE_GET_PRIVATE ( file );
11.213 }
11.214
11.215 static void
11.216 -gmyth_file_dispose (GObject * object)
11.217 +gmyth_file_dispose ( GObject * object )
11.218 {
11.219 GMythFilePrivate *priv;
11.220 - GMythFile *file = GMYTH_FILE (object);
11.221 + GMythFile *file = GMYTH_FILE ( object );
11.222
11.223 - g_return_if_fail (file != NULL);
11.224 + g_return_if_fail ( file != NULL );
11.225
11.226 - priv = GMYTH_FILE_GET_PRIVATE (file);
11.227 + priv = GMYTH_FILE_GET_PRIVATE ( file );
11.228
11.229 - if (priv->disposed) {
11.230 + if ( priv->disposed )
11.231 + {
11.232 /* If dispose did already run, return. */
11.233 return;
11.234 }
11.235 @@ -171,25 +177,27 @@
11.236 /* Make sure dispose does not run twice. */
11.237 priv->disposed = TRUE;
11.238
11.239 - if (priv->backend_info != NULL) {
11.240 - g_object_unref (priv->backend_info);
11.241 + if ( priv->backend_info != NULL )
11.242 + {
11.243 + g_object_unref ( priv->backend_info );
11.244 priv->backend_info = NULL;
11.245 }
11.246
11.247 - if (priv->filename != NULL) {
11.248 - g_free (priv->filename);
11.249 + if ( priv->filename != NULL )
11.250 + {
11.251 + g_free ( priv->filename );
11.252 priv->filename = NULL;
11.253 }
11.254
11.255 - G_OBJECT_CLASS (gmyth_file_parent_class)->dispose (object);
11.256 + G_OBJECT_CLASS ( gmyth_file_parent_class )->dispose ( object );
11.257 }
11.258
11.259 static void
11.260 -gmyth_file_finalize (GObject * object)
11.261 +gmyth_file_finalize ( GObject * object )
11.262 {
11.263 - g_signal_handlers_destroy (object);
11.264 + g_signal_handlers_destroy ( object );
11.265
11.266 - G_OBJECT_CLASS (gmyth_file_parent_class)->finalize (object);
11.267 + G_OBJECT_CLASS ( gmyth_file_parent_class )->finalize ( object );
11.268 }
11.269
11.270 /**
11.271 @@ -201,49 +209,51 @@
11.272 * @return a new instance of the File Transfer.
11.273 */
11.274 GMythFile *
11.275 -gmyth_file_new (GMythBackendInfo * backend_info)
11.276 +gmyth_file_new ( GMythBackendInfo * backend_info )
11.277 {
11.278 GMythFile *file = NULL;
11.279
11.280 - g_return_val_if_fail (backend_info != NULL, NULL);
11.281 + g_return_val_if_fail ( backend_info != NULL, NULL );
11.282
11.283 - GParameter *__params = g_new0 (GParameter, 1);
11.284 + GParameter *__params = g_new0 ( GParameter, 1 );
11.285 GParameter *__params_it = __params;
11.286
11.287 - (__params_it->name =
11.288 - "backend-info", g_value_init (&__params_it->value, G_TYPE_OBJECT),
11.289 - g_value_set_object (&__params_it->value, backend_info), __params_it++);
11.290 - file = g_object_newv (GMYTH_FILE_TYPE, __params_it - __params, __params);
11.291 + ( __params_it->name =
11.292 + "backend-info", g_value_init ( &__params_it->value, G_TYPE_OBJECT ),
11.293 + g_value_set_object ( &__params_it->value, backend_info ), __params_it++ );
11.294 + file = g_object_newv ( GMYTH_FILE_TYPE, __params_it - __params, __params );
11.295
11.296 return file;
11.297 }
11.298
11.299 gchar *
11.300 -gmyth_file_get_file_name (GMythFile * file)
11.301 +gmyth_file_get_file_name ( GMythFile * file )
11.302 {
11.303 - GMythFilePrivate *priv = GMYTH_FILE_GET_PRIVATE (file);
11.304 + GMythFilePrivate *priv = GMYTH_FILE_GET_PRIVATE ( file );
11.305
11.306 - g_return_val_if_fail (file != NULL, NULL);
11.307 + g_return_val_if_fail ( file != NULL, NULL );
11.308
11.309 return priv->filename;
11.310 }
11.311
11.312 void
11.313 -gmyth_file_set_file_name (GMythFile * file, const gchar * filename)
11.314 +gmyth_file_set_file_name ( GMythFile * file, const gchar * filename )
11.315 {
11.316 - g_return_if_fail (file != NULL);
11.317 - g_return_if_fail (filename != NULL);
11.318 + g_return_if_fail ( file != NULL );
11.319 + g_return_if_fail ( filename != NULL );
11.320
11.321 gchar *__temp2 = NULL;
11.322 const gchar *__temp1 = NULL;
11.323
11.324 - file->priv->filename = (__temp2 = (__temp1 = filename, (__temp1 == NULL ?
11.325 - NULL :
11.326 - g_strdup
11.327 - (__temp1))),
11.328 - (file->priv->filename ==
11.329 - NULL ? NULL : (file->priv->filename =
11.330 - (g_free (file->priv->filename), NULL))), __temp2);
11.331 + file->priv->filename = ( __temp2 = ( __temp1 = filename, ( __temp1 == NULL ?
11.332 + NULL :
11.333 + g_strdup
11.334 + ( __temp1 ) ) ),
11.335 + ( file->priv->filename ==
11.336 + NULL ? NULL : ( file->priv->filename =
11.337 + ( g_free
11.338 + ( file->priv->filename ),
11.339 + NULL ) ) ), __temp2 );
11.340 }
11.341
11.342 /**
11.343 @@ -254,12 +264,12 @@
11.344 * @return a new instance of the File Transfer.
11.345 */
11.346 GMythFile *
11.347 -gmyth_file_new_with_uri (const gchar * uri_str)
11.348 +gmyth_file_new_with_uri ( const gchar * uri_str )
11.349 {
11.350 - GMythFile *file = GMYTH_FILE (g_object_new (GMYTH_FILE_TYPE, NULL));
11.351 - GMythFilePrivate *priv = GMYTH_FILE_GET_PRIVATE (file);
11.352 + GMythFile *file = GMYTH_FILE ( g_object_new ( GMYTH_FILE_TYPE, NULL ) );
11.353 + GMythFilePrivate *priv = GMYTH_FILE_GET_PRIVATE ( file );
11.354
11.355 - priv->backend_info = gmyth_backend_info_new_with_uri (uri_str);
11.356 + priv->backend_info = gmyth_backend_info_new_with_uri ( uri_str );
11.357 return file;
11.358 }
11.359
11.360 @@ -272,21 +282,22 @@
11.361 * @return <code>true</code>, if the connection opening had been done successfully.
11.362 */
11.363 gboolean
11.364 -gmyth_file_setup (GMythFile * file, const gchar * filename)
11.365 +gmyth_file_setup ( GMythFile * file, const gchar * filename )
11.366 {
11.367 gboolean ret = TRUE;
11.368 GMythFilePrivate *priv;
11.369
11.370 - g_return_val_if_fail (file != NULL, FALSE);
11.371 - g_return_val_if_fail (filename != NULL && strlen (filename) > 0, FALSE);
11.372 + g_return_val_if_fail ( file != NULL, FALSE );
11.373 + g_return_val_if_fail ( filename != NULL && strlen ( filename ) > 0, FALSE );
11.374
11.375 - priv = GMYTH_FILE_GET_PRIVATE (file);
11.376 + priv = GMYTH_FILE_GET_PRIVATE ( file );
11.377
11.378 - if (priv->filename != NULL) {
11.379 - gmyth_file_close (file);
11.380 + if ( priv->filename != NULL )
11.381 + {
11.382 + gmyth_file_close ( file );
11.383 }
11.384
11.385 - priv->filename = g_strdup (filename);
11.386 + priv->filename = g_strdup ( filename );
11.387
11.388 return ret;
11.389 }
11.390 @@ -297,14 +308,15 @@
11.391 * @param file The actual File Transfer instance.
11.392 */
11.393 void
11.394 -gmyth_file_close (GMythFile * file)
11.395 +gmyth_file_close ( GMythFile * file )
11.396 {
11.397 GMythFilePrivate *priv;
11.398
11.399 - priv = GMYTH_FILE_GET_PRIVATE (file);
11.400 + priv = GMYTH_FILE_GET_PRIVATE ( file );
11.401
11.402 - if (priv->filename) {
11.403 - g_free (priv->filename);
11.404 + if ( priv->filename )
11.405 + {
11.406 + g_free ( priv->filename );
11.407 priv->filename = NULL;
11.408 }
11.409
11.410 @@ -318,13 +330,13 @@
11.411 * @return The actual file size in bytes.
11.412 */
11.413 guint64
11.414 -gmyth_file_get_filesize (GMythFile * file)
11.415 +gmyth_file_get_filesize ( GMythFile * file )
11.416 {
11.417 GMythFilePrivate *priv;
11.418
11.419 - g_return_val_if_fail (file != NULL, 0);
11.420 + g_return_val_if_fail ( file != NULL, 0 );
11.421
11.422 - priv = GMYTH_FILE_GET_PRIVATE (file);
11.423 + priv = GMYTH_FILE_GET_PRIVATE ( file );
11.424 return priv->filesize;
11.425 }
11.426
11.427 @@ -335,11 +347,11 @@
11.428 * @param filesize The actual File Transfer size, in bytes.
11.429 */
11.430 void
11.431 -gmyth_file_set_filesize (GMythFile * file, guint64 filesize)
11.432 +gmyth_file_set_filesize ( GMythFile * file, guint64 filesize )
11.433 {
11.434 GMythFilePrivate *priv;
11.435
11.436 - priv = GMYTH_FILE_GET_PRIVATE (file);
11.437 + priv = GMYTH_FILE_GET_PRIVATE ( file );
11.438
11.439 priv->filesize = filesize;
11.440 }
11.441 @@ -352,9 +364,9 @@
11.442 * @return The actual file offset in bytes.
11.443 */
11.444 gint64
11.445 -gmyth_file_get_offset (GMythFile * file)
11.446 +gmyth_file_get_offset ( GMythFile * file )
11.447 {
11.448 - g_return_val_if_fail (file != NULL, 0);
11.449 + g_return_val_if_fail ( file != NULL, 0 );
11.450
11.451 return file->priv->offset;
11.452 }
11.453 @@ -366,125 +378,135 @@
11.454 * @param filesize The actual File offset, in bytes.
11.455 */
11.456 void
11.457 -gmyth_file_set_offset (GMythFile * file, gint64 offset)
11.458 +gmyth_file_set_offset ( GMythFile * file, gint64 offset )
11.459 {
11.460 GMythFilePrivate *priv;
11.461
11.462 - priv = GMYTH_FILE_GET_PRIVATE (file);
11.463 + priv = GMYTH_FILE_GET_PRIVATE ( file );
11.464
11.465 priv->offset = offset;
11.466 }
11.467
11.468 gchar *
11.469 -gmyth_file_get_uri (GMythFile * file)
11.470 +gmyth_file_get_uri ( GMythFile * file )
11.471 {
11.472 - GMythFilePrivate *priv = GMYTH_FILE_GET_PRIVATE (file);
11.473 + GMythFilePrivate *priv = GMYTH_FILE_GET_PRIVATE ( file );
11.474 gchar *uri = NULL;
11.475
11.476 - g_return_val_if_fail (file != NULL, NULL);
11.477 + g_return_val_if_fail ( file != NULL, NULL );
11.478
11.479 - if (g_strstr_len (priv->filename, strlen (priv->filename), "://") != NULL)
11.480 - uri = g_strdup (priv->filename);
11.481 + if ( g_strstr_len ( priv->filename, strlen ( priv->filename ), "://" ) !=
11.482 + NULL )
11.483 + uri = g_strdup ( priv->filename );
11.484 else
11.485 uri =
11.486 - g_strdup_printf ("myth://%s:%d/%s",
11.487 - gmyth_backend_info_get_hostname (priv->
11.488 - backend_info),
11.489 - gmyth_backend_info_get_port (priv->backend_info), priv->filename);
11.490 + g_strdup_printf ( "myth://%s:%d/%s",
11.491 + gmyth_backend_info_get_hostname ( priv->
11.492 + backend_info ),
11.493 + gmyth_backend_info_get_port ( priv->
11.494 + backend_info ),
11.495 + priv->filename );
11.496
11.497 return uri;
11.498 }
11.499
11.500 static void
11.501 -gmyth_file_set_property (GObject * object, guint prop_id,
11.502 - const GValue * value, GParamSpec * pspec)
11.503 +gmyth_file_set_property ( GObject * object, guint prop_id,
11.504 + const GValue * value, GParamSpec * pspec )
11.505 {
11.506 - GMythFilePrivate *priv = GMYTH_FILE_GET_PRIVATE (GMYTH_FILE (object));
11.507 + GMythFilePrivate *priv = GMYTH_FILE_GET_PRIVATE ( GMYTH_FILE ( object ) );
11.508
11.509 - switch (prop_id) {
11.510 - case PROP_GMYTH_FILE_FILENAME:
11.511 + switch ( prop_id )
11.512 + {
11.513 + case PROP_GMYTH_FILE_FILENAME:
11.514 {
11.515 - if (!g_value_get_string (value)) {
11.516 + if ( !g_value_get_string ( value ) )
11.517 + {
11.518 break;
11.519 }
11.520
11.521 - if (priv->filename != NULL) {
11.522 - g_free (priv->filename);
11.523 + if ( priv->filename != NULL )
11.524 + {
11.525 + g_free ( priv->filename );
11.526 priv->filename = NULL;
11.527 }
11.528 - priv->filename = g_value_dup_string (value);
11.529 - gmyth_debug ("Changed the filename to [%s]!", priv->filename);
11.530 + priv->filename = g_value_dup_string ( value );
11.531 + gmyth_debug ( "Changed the filename to [%s]!", priv->filename );
11.532 break;
11.533 }
11.534 - case PROP_GMYTH_FILE_OFFSET:
11.535 + case PROP_GMYTH_FILE_OFFSET:
11.536 {
11.537 - priv->offset = g_value_get_int64 (value);
11.538 + priv->offset = g_value_get_int64 ( value );
11.539 break;
11.540 }
11.541 - case PROP_GMYTH_FILE_FILESIZE:
11.542 + case PROP_GMYTH_FILE_FILESIZE:
11.543 {
11.544 - priv->filesize = g_value_get_uint64 (value);
11.545 + priv->filesize = g_value_get_uint64 ( value );
11.546 break;
11.547 }
11.548 - case PROP_GMYTH_FILE_BACKEND_INFO:
11.549 + case PROP_GMYTH_FILE_BACKEND_INFO:
11.550 {
11.551 - if (!g_value_get_object (value)) {
11.552 + if ( !g_value_get_object ( value ) )
11.553 + {
11.554 break;
11.555 }
11.556
11.557 - if (priv->backend_info != NULL) {
11.558 - g_object_unref (priv->backend_info);
11.559 + if ( priv->backend_info != NULL )
11.560 + {
11.561 + g_object_unref ( priv->backend_info );
11.562 priv->backend_info = NULL;
11.563 }
11.564 - priv->backend_info = g_value_get_object (value);
11.565 - gmyth_debug ("Changed the backend info to [%s]!",
11.566 - gmyth_backend_info_get_hostname (priv->backend_info));
11.567 + priv->backend_info = g_value_get_object ( value );
11.568 + gmyth_debug ( "Changed the backend info to [%s]!",
11.569 + gmyth_backend_info_get_hostname ( priv->
11.570 + backend_info ) );
11.571 break;
11.572 }
11.573 - case PROP_GMYTH_FILE_FILEID:
11.574 + case PROP_GMYTH_FILE_FILEID:
11.575 {
11.576 - priv->file_id = g_value_get_int (value);
11.577 + priv->file_id = g_value_get_int ( value );
11.578 break;
11.579 }
11.580 - default:
11.581 - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
11.582 - break;
11.583 + default:
11.584 + G_OBJECT_WARN_INVALID_PROPERTY_ID ( object, prop_id, pspec );
11.585 + break;
11.586 }
11.587
11.588 }
11.589
11.590 static void
11.591 -gmyth_file_get_property (GObject * object, guint prop_id,
11.592 - GValue * value, GParamSpec * pspec)
11.593 +gmyth_file_get_property ( GObject * object, guint prop_id,
11.594 + GValue * value, GParamSpec * pspec )
11.595 {
11.596 - GMythFilePrivate *priv = GMYTH_FILE_GET_PRIVATE (GMYTH_FILE (object));
11.597 + GMythFilePrivate *priv = GMYTH_FILE_GET_PRIVATE ( GMYTH_FILE ( object ) );
11.598
11.599 - switch (prop_id) {
11.600 - case PROP_GMYTH_FILE_FILENAME:
11.601 + switch ( prop_id )
11.602 + {
11.603 + case PROP_GMYTH_FILE_FILENAME:
11.604 {
11.605 - gmyth_debug ("Got the filename to [%s]!", priv->filename);
11.606 - g_value_set_string (value, priv->filename);
11.607 + gmyth_debug ( "Got the filename to [%s]!", priv->filename );
11.608 + g_value_set_string ( value, priv->filename );
11.609 break;
11.610 }
11.611 - case PROP_GMYTH_FILE_OFFSET:
11.612 + case PROP_GMYTH_FILE_OFFSET:
11.613 {
11.614 - g_value_set_int64 (value, priv->offset);
11.615 + g_value_set_int64 ( value, priv->offset );
11.616 break;
11.617 }
11.618 - case PROP_GMYTH_FILE_FILESIZE:
11.619 + case PROP_GMYTH_FILE_FILESIZE:
11.620 {
11.621 - g_value_set_uint64 (value, priv->filesize);
11.622 + g_value_set_uint64 ( value, priv->filesize );
11.623 break;
11.624 }
11.625 - case PROP_GMYTH_FILE_BACKEND_INFO:
11.626 - g_value_set_object (value, priv->backend_info);
11.627 - break;
11.628 - case PROP_GMYTH_FILE_FILEID:
11.629 - g_value_set_int (value, priv->file_id);
11.630 - break;
11.631 - default:
11.632 - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
11.633 - break;
11.634 + case PROP_GMYTH_FILE_BACKEND_INFO:
11.635 + g_value_set_object ( value, priv->backend_info );
11.636 + break;
11.637 + case PROP_GMYTH_FILE_FILEID:
11.638 + g_value_set_int ( value, priv->file_id );
11.639 + break;
11.640 + default:
11.641 + G_OBJECT_WARN_INVALID_PROPERTY_ID ( object, prop_id, pspec );
11.642 + break;
11.643 }
11.644
11.645 }
12.1 --- a/gmyth/src/gmyth_file.h Wed May 23 19:21:26 2007 +0100
12.2 +++ b/gmyth/src/gmyth_file.h Wed May 23 19:50:41 2007 +0100
12.3 @@ -9,22 +9,21 @@
12.4 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
12.5 * @author Rosfran Lins Borges <rosfran.borges@indt.org.br>
12.6 *
12.7 - *//*
12.8 - *
12.9 - * This program is free software; you can redistribute it and/or modify
12.10 - * it under the terms of the GNU Lesser General Public License as published by
12.11 - * the Free Software Foundation; either version 2 of the License, or
12.12 - * (at your option) any later version.
12.13 - *
12.14 - * This program is distributed in the hope that it will be useful,
12.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
12.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12.17 - * GNU General Public License for more details.
12.18 - *
12.19 - * You should have received a copy of the GNU Lesser General Public License
12.20 - * along with this program; if not, write to the Free Software
12.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
12.22 - */
12.23 + *
12.24 + * This program is free software; you can redistribute it and/or modify
12.25 + * it under the terms of the GNU Lesser General Public License as published by
12.26 + * the Free Software Foundation; either version 2 of the License, or
12.27 + * (at your option) any later version.
12.28 + *
12.29 + * This program is distributed in the hope that it will be useful,
12.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
12.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12.32 + * GNU General Public License for more details.
12.33 + *
12.34 + * You should have received a copy of the GNU Lesser General Public License
12.35 + * along with this program; if not, write to the Free Software
12.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
12.37 + */
12.38
12.39 #ifndef __GMYTH_FILE_H__
12.40 #define __GMYTH_FILE_H__
12.41 @@ -50,43 +49,43 @@
12.42 #define IS_GMYTH_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_FILE_TYPE))
12.43 #define GMYTH_FILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_FILE_TYPE, GMythFileClass))
12.44 typedef enum
12.45 -{
12.46 - GMYTH_FILE_READ_OK = 0,
12.47 - GMYTH_FILE_READ_NEXT_PROG_CHAIN = 1,
12.48 - GMYTH_FILE_READ_ERROR = 2,
12.49 - GMYTH_FILE_READ_EOF = 3
12.50 -} GMythFileReadResult;
12.51 + {
12.52 + GMYTH_FILE_READ_OK = 0,
12.53 + GMYTH_FILE_READ_NEXT_PROG_CHAIN = 1,
12.54 + GMYTH_FILE_READ_ERROR = 2,
12.55 + GMYTH_FILE_READ_EOF = 3
12.56 + } GMythFileReadResult;
12.57
12.58 typedef struct _GMythFile GMythFile;
12.59 typedef struct _GMythFileClass GMythFileClass;
12.60 typedef struct _GMythFilePrivate GMythFilePrivate;
12.61
12.62 struct _GMythFile
12.63 -{
12.64 - GObject parent;
12.65 - GMythFilePrivate *priv;
12.66 -};
12.67 + {
12.68 + GObject parent;
12.69 + GMythFilePrivate *priv;
12.70 + };
12.71
12.72 struct _GMythFileClass
12.73 -{
12.74 - GObjectClass parent_class;
12.75 -};
12.76 + {
12.77 + GObjectClass parent_class;
12.78 + };
12.79
12.80 -GType gmyth_file_get_type (void);
12.81 -GMythFile *gmyth_file_new (GMythBackendInfo * backend_info);
12.82 -gchar *gmyth_file_get_file_name (GMythFile * file);
12.83 -void gmyth_file_set_file_name (GMythFile * file, const gchar * filename);
12.84 -gboolean gmyth_file_setup (GMythFile * file, const gchar * filename);
12.85 -void gmyth_file_close (GMythFile * file);
12.86 -gboolean gmyth_file_is_open (GMythFile * file);
12.87 +GType gmyth_file_get_type ( void );
12.88 +GMythFile *gmyth_file_new ( GMythBackendInfo * backend_info );
12.89 +gchar *gmyth_file_get_file_name ( GMythFile * file );
12.90 +void gmyth_file_set_file_name ( GMythFile * file, const gchar * filename );
12.91 +gboolean gmyth_file_setup ( GMythFile * file, const gchar * filename );
12.92 +void gmyth_file_close ( GMythFile * file );
12.93 +gboolean gmyth_file_is_open ( GMythFile * file );
12.94
12.95 -guint64 gmyth_file_get_filesize (GMythFile * file);
12.96 -void gmyth_file_set_filesize (GMythFile * file, guint64 filesize);
12.97 +guint64 gmyth_file_get_filesize ( GMythFile * file );
12.98 +void gmyth_file_set_filesize ( GMythFile * file, guint64 filesize );
12.99
12.100 -gint64 gmyth_file_get_offset (GMythFile * file);
12.101 -void gmyth_file_set_offset (GMythFile * file, gint64 offset);
12.102 +gint64 gmyth_file_get_offset ( GMythFile * file );
12.103 +void gmyth_file_set_offset ( GMythFile * file, gint64 offset );
12.104
12.105 -gchar *gmyth_file_get_uri (GMythFile * file);
12.106 +gchar *gmyth_file_get_uri ( GMythFile * file );
12.107
12.108 G_END_DECLS
12.109 #endif /* __GMYTH_FILE_H__ */
13.1 --- a/gmyth/src/gmyth_file_local.c Wed May 23 19:21:26 2007 +0100
13.2 +++ b/gmyth/src/gmyth_file_local.c Wed May 23 19:50:41 2007 +0100
13.3 @@ -9,22 +9,21 @@
13.4 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
13.5 * @author Rosfran Lins Borges <rosfran.borges@indt.org.br>
13.6 *
13.7 - *//*
13.8 - *
13.9 - * This program is free software; you can redistribute it and/or modify
13.10 - * it under the terms of the GNU Lesser General Public License as published by
13.11 - * the Free Software Foundation; either version 2 of the License, or
13.12 - * (at your option) any later version.
13.13 - *
13.14 - * This program is distributed in the hope that it will be useful,
13.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
13.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13.17 - * GNU General Public License for more details.
13.18 - *
13.19 - * You should have received a copy of the GNU Lesser General Public License
13.20 - * along with this program; if not, write to the Free Software
13.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
13.22 - */
13.23 + *
13.24 + * This program is free software; you can redistribute it and/or modify
13.25 + * it under the terms of the GNU Lesser General Public License as published by
13.26 + * the Free Software Foundation; either version 2 of the License, or
13.27 + * (at your option) any later version.
13.28 + *
13.29 + * This program is distributed in the hope that it will be useful,
13.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
13.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13.32 + * GNU General Public License for more details.
13.33 + *
13.34 + * You should have received a copy of the GNU Lesser General Public License
13.35 + * along with this program; if not, write to the Free Software
13.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
13.37 + */
13.38
13.39 #ifdef HAVE_CONFIG_H
13.40 #include "config.h"
13.41 @@ -51,70 +50,72 @@
13.42 #include <assert.h>
13.43
13.44 #define GMYTH_FILE_LOCAL_GET_PRIVATE(obj) \
13.45 - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GMYTH_FILE_LOCAL_TYPE, GMythFileLocalPrivate))
13.46 + (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GMYTH_FILE_LOCAL_TYPE, GMythFileLocalPrivate))
13.47
13.48 struct _GMythFileLocalPrivate
13.49 -{
13.50 + {
13.51
13.52 - gboolean disposed;
13.53 + gboolean disposed;
13.54
13.55 - GMutex *mutex;
13.56 + GMutex *mutex;
13.57
13.58 - gint fd;
13.59 + gint fd;
13.60
13.61 - GIOChannel *file_io;
13.62 + GIOChannel *file_io;
13.63
13.64 -};
13.65 + };
13.66
13.67 -static void gmyth_file_local_class_init (GMythFileLocalClass * klass);
13.68 -static void gmyth_file_local_init (GMythFileLocal * object);
13.69 -static void gmyth_file_local_dispose (GObject * object);
13.70 -static void gmyth_file_local_finalize (GObject * object);
13.71 +static void gmyth_file_local_class_init ( GMythFileLocalClass * klass );
13.72 +static void gmyth_file_local_init ( GMythFileLocal * object );
13.73 +static void gmyth_file_local_dispose ( GObject * object );
13.74 +static void gmyth_file_local_finalize ( GObject * object );
13.75
13.76 -static gboolean _control_acquire_context (GMythFileLocal * file_local,
13.77 - gboolean do_wait);
13.78 +static gboolean _control_acquire_context ( GMythFileLocal * file_local,
13.79 + gboolean do_wait );
13.80
13.81 -static gboolean _control_release_context (GMythFileLocal * file_local);
13.82 +static gboolean _control_release_context ( GMythFileLocal * file_local );
13.83
13.84 -G_DEFINE_TYPE (GMythFileLocal, gmyth_file_local, GMYTH_FILE_TYPE)
13.85 - static void gmyth_file_local_class_init (GMythFileLocalClass * klass)
13.86 +G_DEFINE_TYPE ( GMythFileLocal, gmyth_file_local, GMYTH_FILE_TYPE )
13.87 + static void gmyth_file_local_class_init ( GMythFileLocalClass * klass )
13.88 {
13.89 GObjectClass *gobject_class;
13.90 GMythFileLocalClass *gtransfer_class;
13.91
13.92 - gobject_class = (GObjectClass *) klass;
13.93 - gtransfer_class = (GMythFileLocalClass *) gobject_class;
13.94 + gobject_class = ( GObjectClass * ) klass;
13.95 + gtransfer_class = ( GMythFileLocalClass * ) gobject_class;
13.96
13.97 gobject_class->dispose = gmyth_file_local_dispose;
13.98 gobject_class->finalize = gmyth_file_local_finalize;
13.99
13.100 - g_type_class_add_private (gobject_class, sizeof (GMythFileLocalPrivate));
13.101 + g_type_class_add_private ( gobject_class,
13.102 + sizeof ( GMythFileLocalPrivate ) );
13.103
13.104 }
13.105
13.106 static void
13.107 -gmyth_file_local_init (GMythFileLocal * file_local)
13.108 +gmyth_file_local_init ( GMythFileLocal * file_local )
13.109 {
13.110 GMythFileLocalPrivate *priv;
13.111
13.112 - g_return_if_fail (file_local != NULL);
13.113 + g_return_if_fail ( file_local != NULL );
13.114
13.115 - priv = GMYTH_FILE_LOCAL_GET_PRIVATE (file_local);
13.116 + priv = GMYTH_FILE_LOCAL_GET_PRIVATE ( file_local );
13.117
13.118 - priv->mutex = g_mutex_new ();
13.119 + priv->mutex = g_mutex_new ( );
13.120 }
13.121
13.122 static void
13.123 -gmyth_file_local_dispose (GObject * object)
13.124 +gmyth_file_local_dispose ( GObject * object )
13.125 {
13.126 GMythFileLocalPrivate *priv;
13.127 - GMythFileLocal *file_local = GMYTH_FILE_LOCAL (object);
13.128 + GMythFileLocal *file_local = GMYTH_FILE_LOCAL ( object );
13.129
13.130 - g_return_if_fail (file_local != NULL);
13.131 + g_return_if_fail ( file_local != NULL );
13.132
13.133 - priv = GMYTH_FILE_LOCAL_GET_PRIVATE (file_local);
13.134 + priv = GMYTH_FILE_LOCAL_GET_PRIVATE ( file_local );
13.135
13.136 - if (priv->disposed) {
13.137 + if ( priv->disposed )
13.138 + {
13.139 /* If dispose did already run, return. */
13.140 return;
13.141 }
13.142 @@ -122,25 +123,27 @@
13.143 /* Make sure dispose does not run twice. */
13.144 priv->disposed = TRUE;
13.145
13.146 - if (priv->mutex != NULL) {
13.147 - g_mutex_free (priv->mutex);
13.148 + if ( priv->mutex != NULL )
13.149 + {
13.150 + g_mutex_free ( priv->mutex );
13.151 priv->mutex = NULL;
13.152 }
13.153
13.154 - if (priv->file_io != NULL) {
13.155 - g_io_channel_unref (priv->file_io);
13.156 + if ( priv->file_io != NULL )
13.157 + {
13.158 + g_io_channel_unref ( priv->file_io );
13.159 priv->file_io = NULL;
13.160 }
13.161
13.162 - G_OBJECT_CLASS (gmyth_file_local_parent_class)->dispose (object);
13.163 + G_OBJECT_CLASS ( gmyth_file_local_parent_class )->dispose ( object );
13.164 }
13.165
13.166 static void
13.167 -gmyth_file_local_finalize (GObject * object)
13.168 +gmyth_file_local_finalize ( GObject * object )
13.169 {
13.170 - g_signal_handlers_destroy (object);
13.171 + g_signal_handlers_destroy ( object );
13.172
13.173 - G_OBJECT_CLASS (gmyth_file_local_parent_class)->finalize (object);
13.174 + G_OBJECT_CLASS ( gmyth_file_local_parent_class )->finalize ( object );
13.175 }
13.176
13.177 /**
13.178 @@ -152,12 +155,13 @@
13.179 * @return a new instance of the File Transfer.
13.180 */
13.181 GMythFileLocal *
13.182 -gmyth_file_local_new (GMythBackendInfo * backend_info)
13.183 +gmyth_file_local_new ( GMythBackendInfo * backend_info )
13.184 {
13.185 GMythFileLocal *file_local =
13.186 - GMYTH_FILE_LOCAL (g_object_new (GMYTH_FILE_LOCAL_TYPE, NULL));
13.187 + GMYTH_FILE_LOCAL ( g_object_new ( GMYTH_FILE_LOCAL_TYPE, NULL ) );
13.188
13.189 - g_object_set (GMYTH_FILE (file_local), "backend-info", &backend_info, NULL);
13.190 + g_object_set ( GMYTH_FILE ( file_local ), "backend-info", &backend_info,
13.191 + NULL );
13.192
13.193 return file_local;
13.194 }
13.195 @@ -170,34 +174,34 @@
13.196 * @return a new instance of the File Transfer.
13.197 */
13.198 GMythFileLocal *
13.199 -gmyth_file_local_new_with_uri (const gchar * uri_str)
13.200 +gmyth_file_local_new_with_uri ( const gchar * uri_str )
13.201 {
13.202 GMythFileLocal *file_local =
13.203 - GMYTH_FILE_LOCAL (g_object_new (GMYTH_FILE_LOCAL_TYPE, NULL));
13.204 - GMythURI *uri = gmyth_uri_new_with_value (uri_str);
13.205 + GMYTH_FILE_LOCAL ( g_object_new ( GMYTH_FILE_LOCAL_TYPE, NULL ) );
13.206 + GMythURI *uri = gmyth_uri_new_with_value ( uri_str );
13.207
13.208 - gmyth_debug ("GMythURI path segment = %s", gmyth_uri_get_path (uri));
13.209 + gmyth_debug ( "GMythURI path segment = %s", gmyth_uri_get_path ( uri ) );
13.210
13.211 - g_object_set (GMYTH_FILE (file_local),
13.212 - "backend-info", gmyth_backend_info_new_with_uri (uri_str),
13.213 - "filename", g_strdup (gmyth_uri_get_path (uri)), NULL);
13.214 + g_object_set ( GMYTH_FILE ( file_local ),
13.215 + "backend-info", gmyth_backend_info_new_with_uri ( uri_str ),
13.216 + "filename", g_strdup ( gmyth_uri_get_path ( uri ) ), NULL );
13.217
13.218 - g_object_unref (uri);
13.219 + g_object_unref ( uri );
13.220
13.221 return file_local;
13.222 }
13.223
13.224 gchar *
13.225 -gmyth_file_local_get_file_name (GMythFileLocal * file_local)
13.226 +gmyth_file_local_get_file_name ( GMythFileLocal * file_local )
13.227 {
13.228 - return gmyth_file_get_file_name (GMYTH_FILE (file_local));
13.229 + return gmyth_file_get_file_name ( GMYTH_FILE ( file_local ) );
13.230 }
13.231
13.232 void
13.233 -gmyth_file_local_set_file_name (GMythFileLocal * file_local,
13.234 - const gchar * filename)
13.235 +gmyth_file_local_set_file_name ( GMythFileLocal * file_local,
13.236 + const gchar * filename )
13.237 {
13.238 - gmyth_file_set_file_name (GMYTH_FILE (file_local), filename);
13.239 + gmyth_file_set_file_name ( GMYTH_FILE ( file_local ), filename );
13.240 }
13.241
13.242 /**
13.243 @@ -208,24 +212,25 @@
13.244 * @return <code>true</code>, if the connection opening had been done successfully.
13.245 */
13.246 gboolean
13.247 -gmyth_file_local_open (GMythFileLocal * file_local)
13.248 +gmyth_file_local_open ( GMythFileLocal * file_local )
13.249 {
13.250 gboolean ret = TRUE;
13.251 GMythFileLocalPrivate *priv;
13.252 gchar *file_name_uri = NULL;
13.253
13.254 - g_return_val_if_fail (file_local != NULL, FALSE);
13.255 + g_return_val_if_fail ( file_local != NULL, FALSE );
13.256
13.257 - priv = GMYTH_FILE_LOCAL_GET_PRIVATE (file_local);
13.258 - file_name_uri = gmyth_file_local_get_file_name (file_local);
13.259 + priv = GMYTH_FILE_LOCAL_GET_PRIVATE ( file_local );
13.260 + file_name_uri = gmyth_file_local_get_file_name ( file_local );
13.261
13.262 - if (file_name_uri != NULL) {
13.263 + if ( file_name_uri != NULL )
13.264 + {
13.265 priv->file_io =
13.266 - g_io_channel_new_file (g_strdup (file_name_uri), "r+", NULL);
13.267 - g_free (file_name_uri);
13.268 + g_io_channel_new_file ( g_strdup ( file_name_uri ), "r+", NULL );
13.269 + g_free ( file_name_uri );
13.270 }
13.271
13.272 - if (priv->file_io < 0)
13.273 + if ( priv->file_io < 0 )
13.274 ret = FALSE;
13.275
13.276 return ret;
13.277 @@ -237,9 +242,9 @@
13.278 * @param file_local The actual File Transfer instance.
13.279 */
13.280 void
13.281 -gmyth_file_local_close (GMythFileLocal * file_local)
13.282 +gmyth_file_local_close ( GMythFileLocal * file_local )
13.283 {
13.284 - g_return_if_fail (file_local != NULL);
13.285 + g_return_if_fail ( file_local != NULL );
13.286 }
13.287
13.288 /**
13.289 @@ -251,15 +256,15 @@
13.290 * @return <code>true</code>, if the acquire had been got.
13.291 */
13.292 static gboolean
13.293 -_control_acquire_context (GMythFileLocal * file_local, gboolean do_wait)
13.294 +_control_acquire_context ( GMythFileLocal * file_local, gboolean do_wait )
13.295 {
13.296 gboolean ret = TRUE;
13.297 GMythFileLocalPrivate *priv;
13.298
13.299 - g_return_val_if_fail (file_local != NULL, FALSE);
13.300 - priv = GMYTH_FILE_LOCAL_GET_PRIVATE (file_local);
13.301 + g_return_val_if_fail ( file_local != NULL, FALSE );
13.302 + priv = GMYTH_FILE_LOCAL_GET_PRIVATE ( file_local );
13.303
13.304 - g_mutex_lock (priv->mutex);
13.305 + g_mutex_lock ( priv->mutex );
13.306 return ret;
13.307 }
13.308
13.309 @@ -271,15 +276,15 @@
13.310 * @return <code>true</code>, if the local file read/write permissions had been releaseds.
13.311 */
13.312 static gboolean
13.313 -_control_release_context (GMythFileLocal * file_local)
13.314 +_control_release_context ( GMythFileLocal * file_local )
13.315 {
13.316 gboolean ret = TRUE;
13.317 GMythFileLocalPrivate *priv;
13.318
13.319 - g_return_val_if_fail (file_local != NULL, FALSE);
13.320 - priv = GMYTH_FILE_LOCAL_GET_PRIVATE (file_local);
13.321 + g_return_val_if_fail ( file_local != NULL, FALSE );
13.322 + priv = GMYTH_FILE_LOCAL_GET_PRIVATE ( file_local );
13.323
13.324 - g_mutex_unlock (priv->mutex);
13.325 + g_mutex_unlock ( priv->mutex );
13.326
13.327 return ret;
13.328 }
13.329 @@ -298,8 +303,8 @@
13.330 * or the error code.
13.331 */
13.332 GMythFileReadResult
13.333 -gmyth_file_local_read (GMythFileLocal * file_local, GByteArray * data,
13.334 - gint size, gboolean read_unlimited)
13.335 +gmyth_file_local_read ( GMythFileLocal * file_local, GByteArray * data,
13.336 + gint size, gboolean read_unlimited )
13.337 {
13.338 gsize bytes_read = 0;
13.339 gint64 total_read = 0;
13.340 @@ -311,69 +316,78 @@
13.341 GIOCondition io_cond;
13.342 GIOStatus io_status = G_IO_STATUS_NORMAL;
13.343
13.344 - g_return_val_if_fail (file_local != NULL, FALSE);
13.345 - g_return_val_if_fail (data != NULL, GMYTH_FILE_READ_ERROR);
13.346 + g_return_val_if_fail ( file_local != NULL, FALSE );
13.347 + g_return_val_if_fail ( data != NULL, GMYTH_FILE_READ_ERROR );
13.348
13.349 - priv = GMYTH_FILE_LOCAL_GET_PRIVATE (file_local);
13.350 + priv = GMYTH_FILE_LOCAL_GET_PRIVATE ( file_local );
13.351
13.352 - io_status = g_io_channel_set_encoding (priv->file_io, NULL, &error);
13.353 - if (io_status == G_IO_STATUS_NORMAL)
13.354 - gmyth_debug ("Setting encoding to binary file data stream.\n");
13.355 + io_status = g_io_channel_set_encoding ( priv->file_io, NULL, &error );
13.356 + if ( io_status == G_IO_STATUS_NORMAL )
13.357 + gmyth_debug ( "Setting encoding to binary file data stream.\n" );
13.358
13.359 - io_cond = g_io_channel_get_buffer_condition (priv->file_io);
13.360 + io_cond = g_io_channel_get_buffer_condition ( priv->file_io );
13.361
13.362 - _control_acquire_context (file_local, TRUE);
13.363 + _control_acquire_context ( file_local, TRUE );
13.364
13.365 - if (size > 0) {
13.366 - gchar *data_buffer = g_new0 (gchar, size);
13.367 + if ( size > 0 )
13.368 + {
13.369 + gchar *data_buffer = g_new0 ( gchar, size );
13.370
13.371 - io_status = g_io_channel_read_chars (priv->file_io,
13.372 - data_buffer, (gsize) size, &bytes_read, &error);
13.373 + io_status = g_io_channel_read_chars ( priv->file_io,
13.374 + data_buffer, ( gsize ) size,
13.375 + &bytes_read, &error );
13.376
13.377 - if (io_status != G_IO_STATUS_NORMAL) {
13.378 - gmyth_debug ("Error on io_channel");
13.379 - g_free (data_buffer);
13.380 + if ( io_status != G_IO_STATUS_NORMAL )
13.381 + {
13.382 + gmyth_debug ( "Error on io_channel" );
13.383 + g_free ( data_buffer );
13.384 retval = GMYTH_FILE_READ_ERROR;
13.385 goto error;
13.386 }
13.387
13.388 /* append new data to the increasing byte array */
13.389 data =
13.390 - g_byte_array_append (data, (const guint8 *) data_buffer,
13.391 - bytes_read);
13.392 + g_byte_array_append ( data, ( const guint8 * ) data_buffer,
13.393 + bytes_read );
13.394 total_read += bytes_read;
13.395
13.396 - if (!read_unlimited && (gmyth_file_local_get_filesize (file_local) > 0)
13.397 - && (gmyth_file_local_get_offset (file_local) ==
13.398 - gmyth_file_local_get_filesize (file_local))) {
13.399 + if ( !read_unlimited
13.400 + && ( gmyth_file_local_get_filesize ( file_local ) > 0 )
13.401 + && ( gmyth_file_local_get_offset ( file_local ) ==
13.402 + gmyth_file_local_get_filesize ( file_local ) ) )
13.403 + {
13.404 retval = GMYTH_FILE_READ_EOF;
13.405 goto error;
13.406 }
13.407
13.408 - g_free (data_buffer);
13.409 - } else {
13.410 + g_free ( data_buffer );
13.411 + }
13.412 + else
13.413 + {
13.414 retval = GMYTH_FILE_READ_ERROR;
13.415 }
13.416
13.417 error:
13.418 - _control_release_context (file_local);
13.419 + _control_release_context ( file_local );
13.420
13.421 - if (error != NULL) {
13.422 - gmyth_debug ("Cleaning-up ERROR: [msg = %s, code = %d]\n",
13.423 - error->message, error->code);
13.424 - g_error_free (error);
13.425 + if ( error != NULL )
13.426 + {
13.427 + gmyth_debug ( "Cleaning-up ERROR: [msg = %s, code = %d]\n",
13.428 + error->message, error->code );
13.429 + g_error_free ( error );
13.430 }
13.431
13.432 - if (total_read > 0)
13.433 - gmyth_file_local_set_offset (file_local,
13.434 - (gmyth_file_local_get_offset (file_local) + total_read));
13.435 + if ( total_read > 0 )
13.436 + gmyth_file_local_set_offset ( file_local,
13.437 + ( gmyth_file_local_get_offset
13.438 + ( file_local ) + total_read ) );
13.439
13.440 return retval;
13.441 }
13.442
13.443 gint64
13.444 -gmyth_file_local_seek (GMythFileLocal * file_local, gint64 pos,
13.445 - GSeekType whence)
13.446 +gmyth_file_local_seek ( GMythFileLocal * file_local, gint64 pos,
13.447 + GSeekType whence )
13.448 {
13.449 GMythFileLocalPrivate *priv;
13.450
13.451 @@ -381,13 +395,14 @@
13.452
13.453 GIOStatus io_status = G_IO_STATUS_NORMAL;
13.454
13.455 - g_return_val_if_fail (file_local != NULL, -1);
13.456 + g_return_val_if_fail ( file_local != NULL, -1 );
13.457
13.458 - priv = GMYTH_FILE_LOCAL_GET_PRIVATE (file_local);
13.459 + priv = GMYTH_FILE_LOCAL_GET_PRIVATE ( file_local );
13.460
13.461 - io_status = g_io_channel_seek_position (priv->file_io, pos, whence, &error);
13.462 + io_status =
13.463 + g_io_channel_seek_position ( priv->file_io, pos, whence, &error );
13.464
13.465 - if (io_status == G_IO_STATUS_ERROR)
13.466 + if ( io_status == G_IO_STATUS_ERROR )
13.467 pos = -1;
13.468
13.469 return pos;
13.470 @@ -402,11 +417,11 @@
13.471 * @return The actual file_local size in bytes.
13.472 */
13.473 guint64
13.474 -gmyth_file_local_get_filesize (GMythFileLocal * file_local)
13.475 +gmyth_file_local_get_filesize ( GMythFileLocal * file_local )
13.476 {
13.477 - g_return_val_if_fail (file_local != NULL, 0);
13.478 + g_return_val_if_fail ( file_local != NULL, 0 );
13.479
13.480 - return gmyth_file_get_filesize (GMYTH_FILE (file_local));
13.481 + return gmyth_file_get_filesize ( GMYTH_FILE ( file_local ) );
13.482 }
13.483
13.484 /**
13.485 @@ -416,11 +431,11 @@
13.486 * @param filesize The actual File Transfer size, in bytes.
13.487 */
13.488 void
13.489 -gmyth_file_local_set_filesize (GMythFileLocal * file_local, guint64 filesize)
13.490 +gmyth_file_local_set_filesize ( GMythFileLocal * file_local, guint64 filesize )
13.491 {
13.492 - g_return_if_fail (file_local != NULL);
13.493 + g_return_if_fail ( file_local != NULL );
13.494
13.495 - gmyth_file_set_filesize (GMYTH_FILE (file_local), filesize);
13.496 + gmyth_file_set_filesize ( GMYTH_FILE ( file_local ), filesize );
13.497 }
13.498
13.499 /**
13.500 @@ -431,11 +446,11 @@
13.501 * @return The actual file offset in bytes.
13.502 */
13.503 gint64
13.504 -gmyth_file_local_get_offset (GMythFileLocal * file_local)
13.505 +gmyth_file_local_get_offset ( GMythFileLocal * file_local )
13.506 {
13.507 - g_return_val_if_fail (file_local != NULL, 0);
13.508 + g_return_val_if_fail ( file_local != NULL, 0 );
13.509
13.510 - return gmyth_file_get_offset (GMYTH_FILE (file_local));
13.511 + return gmyth_file_get_offset ( GMYTH_FILE ( file_local ) );
13.512 }
13.513
13.514 /**
13.515 @@ -445,9 +460,9 @@
13.516 * @param offset The actual File Local offset, in bytes.
13.517 */
13.518 void
13.519 -gmyth_file_local_set_offset (GMythFileLocal * file_local, gint64 offset)
13.520 +gmyth_file_local_set_offset ( GMythFileLocal * file_local, gint64 offset )
13.521 {
13.522 - g_return_if_fail (file_local != NULL);
13.523 + g_return_if_fail ( file_local != NULL );
13.524
13.525 - gmyth_file_set_offset (GMYTH_FILE (file_local), offset);
13.526 + gmyth_file_set_offset ( GMYTH_FILE ( file_local ), offset );
13.527 }
14.1 --- a/gmyth/src/gmyth_file_local.h Wed May 23 19:21:26 2007 +0100
14.2 +++ b/gmyth/src/gmyth_file_local.h Wed May 23 19:50:41 2007 +0100
14.3 @@ -9,22 +9,21 @@
14.4 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
14.5 * @author Rosfran Lins Borges <rosfran.borges@indt.org.br>
14.6 *
14.7 - *//*
14.8 - *
14.9 - * This program is free software; you can redistribute it and/or modify
14.10 - * it under the terms of the GNU Lesser General Public License as published by
14.11 - * the Free Software Foundation; either version 2 of the License, or
14.12 - * (at your option) any later version.
14.13 - *
14.14 - * This program is distributed in the hope that it will be useful,
14.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
14.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14.17 - * GNU General Public License for more details.
14.18 - *
14.19 - * You should have received a copy of the GNU Lesser General Public License
14.20 - * along with this program; if not, write to the Free Software
14.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14.22 - */
14.23 + *
14.24 + * This program is free software; you can redistribute it and/or modify
14.25 + * it under the terms of the GNU Lesser General Public License as published by
14.26 + * the Free Software Foundation; either version 2 of the License, or
14.27 + * (at your option) any later version.
14.28 + *
14.29 + * This program is distributed in the hope that it will be useful,
14.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
14.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14.32 + * GNU General Public License for more details.
14.33 + *
14.34 + * You should have received a copy of the GNU Lesser General Public License
14.35 + * along with this program; if not, write to the Free Software
14.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14.37 + */
14.38
14.39 #ifndef __GMYTH_FILE_LOCAL_H__
14.40 #define __GMYTH_FILE_LOCAL_H__
14.41 @@ -55,38 +54,38 @@
14.42 typedef struct _GMythFileLocalPrivate GMythFileLocalPrivate;
14.43
14.44 struct _GMythFileLocal
14.45 -{
14.46 - GMythFile parent;
14.47 -};
14.48 + {
14.49 + GMythFile parent;
14.50 + };
14.51
14.52 struct _GMythFileLocalClass
14.53 -{
14.54 - GMythFileClass parent_class;
14.55 -};
14.56 + {
14.57 + GMythFileClass parent_class;
14.58 + };
14.59
14.60
14.61 -GType gmyth_file_local_get_type (void);
14.62 -GMythFileLocal *gmyth_file_local_new (GMythBackendInfo * backend_info);
14.63 -GMythFileLocal *gmyth_file_local_new_with_uri (const gchar * uri);
14.64 -gchar *gmyth_file_local_get_file_name (GMythFileLocal * file_local);
14.65 -void gmyth_file_local_set_file_name (GMythFileLocal * file_local,
14.66 - const gchar * filename);
14.67 -gboolean gmyth_file_local_open (GMythFileLocal * file_local);
14.68 -void gmyth_file_local_close (GMythFileLocal * file_local);
14.69 -gboolean gmyth_file_local_is_open (GMythFileLocal * file_local);
14.70 +GType gmyth_file_local_get_type ( void );
14.71 +GMythFileLocal *gmyth_file_local_new ( GMythBackendInfo * backend_info );
14.72 +GMythFileLocal *gmyth_file_local_new_with_uri ( const gchar * uri );
14.73 +gchar *gmyth_file_local_get_file_name ( GMythFileLocal * file_local );
14.74 +void gmyth_file_local_set_file_name ( GMythFileLocal * file_local,
14.75 + const gchar * filename );
14.76 +gboolean gmyth_file_local_open ( GMythFileLocal * file_local );
14.77 +void gmyth_file_local_close ( GMythFileLocal * file_local );
14.78 +gboolean gmyth_file_local_is_open ( GMythFileLocal * file_local );
14.79
14.80 GMythFileReadResult
14.81 -gmyth_file_local_read (GMythFileLocal * file_local,
14.82 - GByteArray * data, gint size, gboolean read_unlimited);
14.83 +gmyth_file_local_read ( GMythFileLocal * file_local,
14.84 + GByteArray * data, gint size, gboolean read_unlimited );
14.85
14.86 -gint64 gmyth_file_local_seek (GMythFileLocal * file_local,
14.87 - gint64 pos, GSeekType whence);
14.88 +gint64 gmyth_file_local_seek ( GMythFileLocal * file_local,
14.89 + gint64 pos, GSeekType whence );
14.90
14.91 -guint64 gmyth_file_local_get_filesize (GMythFileLocal * file_local);
14.92 -void gmyth_file_local_set_filesize (GMythFileLocal * file, guint64 filesize);
14.93 +guint64 gmyth_file_local_get_filesize ( GMythFileLocal * file_local );
14.94 +void gmyth_file_local_set_filesize ( GMythFileLocal * file, guint64 filesize );
14.95
14.96 -gint64 gmyth_file_local_get_offset (GMythFileLocal * file_local);
14.97 -void gmyth_file_local_set_offset (GMythFileLocal * file_local, gint64 offset);
14.98 +gint64 gmyth_file_local_get_offset ( GMythFileLocal * file_local );
14.99 +void gmyth_file_local_set_offset ( GMythFileLocal * file_local, gint64 offset );
14.100
14.101 G_END_DECLS
14.102 #endif /* __GMYTH_FILE_LOCAL_H__ */
15.1 --- a/gmyth/src/gmyth_file_transfer.c Wed May 23 19:21:26 2007 +0100
15.2 +++ b/gmyth/src/gmyth_file_transfer.c Wed May 23 19:50:41 2007 +0100
15.3 @@ -9,27 +9,26 @@
15.4 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
15.5 * @author Rosfran Lins Borges <rosfran.borges@indt.org.br>
15.6 *
15.7 - *//*
15.8 - *
15.9 - * This program is free software; you can redistribute it and/or modify
15.10 - * it under the terms of the GNU Lesser General Public License as published by
15.11 - * the Free Software Foundation; either version 2 of the License, or
15.12 - * (at your option) any later version.
15.13 - *
15.14 - * This program is distributed in the hope that it will be useful,
15.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
15.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15.17 - * GNU General Public License for more details.
15.18 - *
15.19 - * You should have received a copy of the GNU Lesser General Public License
15.20 - * along with this program; if not, write to the Free Software
15.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15.22 - *
15.23 - * GStreamer MythTV plug-in properties:
15.24 - * - location (backend server hostname/URL) [ex.: myth://192.168.1.73:28722/1000_1092091.nuv]
15.25 - * - path (qurl - remote file to be opened)
15.26 - * - port number *
15.27 - */
15.28 + *
15.29 + * This program is free software; you can redistribute it and/or modify
15.30 + * it under the terms of the GNU Lesser General Public License as published by
15.31 + * the Free Software Foundation; either version 2 of the License, or
15.32 + * (at your option) any later version.
15.33 + *
15.34 + * This program is distributed in the hope that it will be useful,
15.35 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
15.36 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15.37 + * GNU General Public License for more details.
15.38 + *
15.39 + * You should have received a copy of the GNU Lesser General Public License
15.40 + * along with this program; if not, write to the Free Software
15.41 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15.42 + *
15.43 + * GStreamer MythTV plug-in properties:
15.44 + * - location (backend server hostname/URL) [ex.: myth://192.168.1.73:28722/1000_1092091.nuv]
15.45 + * - path (qurl - remote file to be opened)
15.46 + * - port number *
15.47 + */
15.48
15.49 #ifdef HAVE_CONFIG_H
15.50 #include "config.h"
15.51 @@ -59,96 +58,101 @@
15.52
15.53
15.54 #define GMYTH_FILE_TRANSFER_GET_PRIVATE(obj) \
15.55 - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GMYTH_FILE_TRANSFER_TYPE, GMythFileTransferPrivate))
15.56 + (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GMYTH_FILE_TRANSFER_TYPE, GMythFileTransferPrivate))
15.57
15.58 enum myth_sock_types
15.59 -{
15.60 - GMYTH_PLAYBACK_TYPE = 0,
15.61 - GMYTH_MONITOR_TYPE,
15.62 - GMYTH_FILETRANSFER_TYPE,
15.63 - GMYTH_RINGBUFFER_TYPE
15.64 -};
15.65 + {
15.66 + GMYTH_PLAYBACK_TYPE = 0,
15.67 + GMYTH_MONITOR_TYPE,
15.68 + GMYTH_FILETRANSFER_TYPE,
15.69 + GMYTH_RINGBUFFER_TYPE
15.70 + };
15.71
15.72 struct _GMythFileTransferPrivate
15.73 -{
15.74 - GMythRecorder *recorder;
15.75 + {
15.76 + GMythRecorder *recorder;
15.77
15.78 - gboolean do_next_program_chain;
15.79 - gboolean disposed;
15.80 - gboolean livetv_wait;
15.81 + gboolean do_next_program_chain;
15.82 + gboolean disposed;
15.83 + gboolean livetv_wait;
15.84
15.85 - /* MythTV version number */
15.86 - gint mythtv_version;
15.87 + /* MythTV version number */
15.88 + gint mythtv_version;
15.89
15.90 - /* socket descriptors */
15.91 - GMythSocket *control_sock;
15.92 - GMythSocket *sock;
15.93 - GMutex *mutex;
15.94 - gint file_id;
15.95 -};
15.96 + /* socket descriptors */
15.97 + GMythSocket *control_sock;
15.98 + GMythSocket *sock;
15.99 + GMutex *mutex;
15.100 + gint file_id;
15.101 + };
15.102
15.103 -static void gmyth_file_transfer_class_init (GMythFileTransferClass * klass);
15.104 -static void gmyth_file_transfer_init (GMythFileTransfer * object);
15.105 -static void gmyth_file_transfer_dispose (GObject * object);
15.106 -static void gmyth_file_transfer_finalize (GObject * object);
15.107 -static void _file_transfer_program_info_changed (GMythFileTransfer * transfer,
15.108 - gint msg_code, gpointer livetv_recorder);
15.109 -static gboolean _connect_to_backend (GMythFileTransfer * transfer);
15.110 -static gboolean _control_acquire_context (GMythFileTransfer * transfer,
15.111 - gboolean do_wait);
15.112 -static gboolean _control_release_context (GMythFileTransfer * transfer);
15.113 +static void gmyth_file_transfer_class_init ( GMythFileTransferClass * klass );
15.114 +static void gmyth_file_transfer_init ( GMythFileTransfer * object );
15.115 +static void gmyth_file_transfer_dispose ( GObject * object );
15.116 +static void gmyth_file_transfer_finalize ( GObject * object );
15.117 +static void _file_transfer_program_info_changed ( GMythFileTransfer * transfer,
15.118 + gint msg_code,
15.119 + gpointer livetv_recorder );
15.120 +static gboolean _connect_to_backend ( GMythFileTransfer * transfer );
15.121 +static gboolean _control_acquire_context ( GMythFileTransfer * transfer,
15.122 + gboolean do_wait );
15.123 +static gboolean _control_release_context ( GMythFileTransfer * transfer );
15.124
15.125 -G_DEFINE_TYPE (GMythFileTransfer, gmyth_file_transfer, GMYTH_FILE_TYPE)
15.126 - static void gmyth_file_transfer_class_init (GMythFileTransferClass * klass)
15.127 +G_DEFINE_TYPE ( GMythFileTransfer, gmyth_file_transfer, GMYTH_FILE_TYPE )
15.128 + static void gmyth_file_transfer_class_init ( GMythFileTransferClass *
15.129 + klass )
15.130 {
15.131 GObjectClass *gobject_class;
15.132 GMythFileTransferClass *gtransfer_class;
15.133
15.134 - gobject_class = (GObjectClass *) klass;
15.135 - gtransfer_class = (GMythFileTransferClass *) gobject_class;
15.136 + gobject_class = ( GObjectClass * ) klass;
15.137 + gtransfer_class = ( GMythFileTransferClass * ) gobject_class;
15.138
15.139 gobject_class->dispose = gmyth_file_transfer_dispose;
15.140 gobject_class->finalize = gmyth_file_transfer_finalize;
15.141
15.142 - g_type_class_add_private (gobject_class, sizeof (GMythFileTransferPrivate));
15.143 + g_type_class_add_private ( gobject_class,
15.144 + sizeof ( GMythFileTransferPrivate ) );
15.145
15.146 gtransfer_class->program_info_changed_handler =
15.147 _file_transfer_program_info_changed;
15.148
15.149 gtransfer_class->program_info_changed_handler_signal_id =
15.150 - g_signal_new ("program-info-changed",
15.151 - G_TYPE_FROM_CLASS (gtransfer_class),
15.152 - G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE |
15.153 - G_SIGNAL_NO_HOOKS, 0, NULL, NULL,
15.154 - gmyth_marshal_VOID__INT_POINTER, G_TYPE_NONE, 2,
15.155 - G_TYPE_INT, G_TYPE_POINTER);
15.156 + g_signal_new ( "program-info-changed",
15.157 + G_TYPE_FROM_CLASS ( gtransfer_class ),
15.158 + G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE |
15.159 + G_SIGNAL_NO_HOOKS, 0, NULL, NULL,
15.160 + gmyth_marshal_VOID__INT_POINTER, G_TYPE_NONE, 2,
15.161 + G_TYPE_INT, G_TYPE_POINTER );
15.162
15.163 }
15.164
15.165 static void
15.166 -gmyth_file_transfer_init (GMythFileTransfer * transfer)
15.167 +gmyth_file_transfer_init ( GMythFileTransfer * transfer )
15.168 {
15.169 - g_return_if_fail (transfer != NULL);
15.170 + g_return_if_fail ( transfer != NULL );
15.171
15.172 - transfer->priv = GMYTH_FILE_TRANSFER_GET_PRIVATE (transfer);
15.173 - transfer->priv->mutex = g_mutex_new ();
15.174 + transfer->priv = GMYTH_FILE_TRANSFER_GET_PRIVATE ( transfer );
15.175 + transfer->priv->mutex = g_mutex_new ( );
15.176
15.177 - g_signal_connect (G_OBJECT (transfer), "program-info-changed",
15.178 - (GCallback) (GMYTH_FILE_TRANSFER_GET_CLASS
15.179 - (transfer)->program_info_changed_handler), NULL);
15.180 + g_signal_connect ( G_OBJECT ( transfer ), "program-info-changed",
15.181 + ( GCallback ) ( GMYTH_FILE_TRANSFER_GET_CLASS
15.182 + ( transfer )->
15.183 + program_info_changed_handler ), NULL );
15.184 }
15.185
15.186 static void
15.187 -gmyth_file_transfer_dispose (GObject * object)
15.188 +gmyth_file_transfer_dispose ( GObject * object )
15.189 {
15.190 GMythFileTransferPrivate *priv;
15.191 - GMythFileTransfer *transfer = GMYTH_FILE_TRANSFER (object);
15.192 + GMythFileTransfer *transfer = GMYTH_FILE_TRANSFER ( object );
15.193
15.194 - g_return_if_fail (transfer != NULL);
15.195 + g_return_if_fail ( transfer != NULL );
15.196
15.197 - priv = GMYTH_FILE_TRANSFER_GET_PRIVATE (transfer);
15.198 + priv = GMYTH_FILE_TRANSFER_GET_PRIVATE ( transfer );
15.199
15.200 - if (priv->disposed) {
15.201 + if ( priv->disposed )
15.202 + {
15.203 /* If dispose did already run, return. */
15.204 return;
15.205 }
15.206 @@ -156,35 +160,39 @@
15.207 /* Make sure dispose does not run twice. */
15.208 priv->disposed = TRUE;
15.209
15.210 - if (priv->mutex != NULL) {
15.211 - g_mutex_free (priv->mutex);
15.212 + if ( priv->mutex != NULL )
15.213 + {
15.214 + g_mutex_free ( priv->mutex );
15.215 priv->mutex = NULL;
15.216 }
15.217
15.218 - if (priv->control_sock != NULL) {
15.219 - g_object_unref (priv->control_sock);
15.220 + if ( priv->control_sock != NULL )
15.221 + {
15.222 + g_object_unref ( priv->control_sock );
15.223 priv->control_sock = NULL;
15.224 }
15.225
15.226 - if (priv->sock != NULL) {
15.227 - g_object_unref (priv->sock);
15.228 + if ( priv->sock != NULL )
15.229 + {
15.230 + g_object_unref ( priv->sock );
15.231 priv->sock = NULL;
15.232 }
15.233
15.234 - if (priv->recorder != NULL) {
15.235 - g_object_unref (priv->recorder);
15.236 + if ( priv->recorder != NULL )
15.237 + {
15.238 + g_object_unref ( priv->recorder );
15.239 priv->recorder = NULL;
15.240 }
15.241
15.242 - G_OBJECT_CLASS (gmyth_file_transfer_parent_class)->dispose (object);
15.243 + G_OBJECT_CLASS ( gmyth_file_transfer_parent_class )->dispose ( object );
15.244 }
15.245
15.246 static void
15.247 -gmyth_file_transfer_finalize (GObject * object)
15.248 +gmyth_file_transfer_finalize ( GObject * object )
15.249 {
15.250 - g_signal_handlers_destroy (object);
15.251 + g_signal_handlers_destroy ( object );
15.252
15.253 - G_OBJECT_CLASS (gmyth_file_transfer_parent_class)->finalize (object);
15.254 + G_OBJECT_CLASS ( gmyth_file_transfer_parent_class )->finalize ( object );
15.255 }
15.256
15.257 /**
15.258 @@ -196,16 +204,16 @@
15.259 * @return a new instance of the File Transfer.
15.260 */
15.261 GMythFileTransfer *
15.262 -gmyth_file_transfer_new (GMythBackendInfo * backend_info)
15.263 +gmyth_file_transfer_new ( GMythBackendInfo * backend_info )
15.264 {
15.265 - GMythFileTransfer *transfer = g_object_new (GMYTH_FILE_TRANSFER_TYPE,
15.266 - "backend-info", backend_info,
15.267 - NULL);
15.268 + GMythFileTransfer *transfer = g_object_new ( GMYTH_FILE_TRANSFER_TYPE,
15.269 + "backend-info", backend_info,
15.270 + NULL );
15.271
15.272 //GValue val = {0,};
15.273 //backend_info = g_object_ref( backend_info );
15.274 - gmyth_debug ("Creating FileTransfer BackendInfo hostname = %s",
15.275 - gmyth_backend_info_get_hostname (backend_info));
15.276 + gmyth_debug ( "Creating FileTransfer BackendInfo hostname = %s",
15.277 + gmyth_backend_info_get_hostname ( backend_info ) );
15.278 //GMythBackendInfo *backend_info = gmyth_backend_info_new_with_uri (uri_str);
15.279 //g_value_init (&val, G_TYPE_OBJECT);
15.280 //g_value_set_object (&val, backend_info);
15.281 @@ -215,11 +223,11 @@
15.282 }
15.283
15.284 gchar *
15.285 -gmyth_file_transfer_get_file_name (GMythFileTransfer * transfer)
15.286 +gmyth_file_transfer_get_file_name ( GMythFileTransfer * transfer )
15.287 {
15.288 gchar *filename;
15.289
15.290 - g_object_get (G_OBJECT (transfer), "filename", &filename, NULL);
15.291 + g_object_get ( G_OBJECT ( transfer ), "filename", &filename, NULL );
15.292
15.293 return filename;
15.294 }
15.295 @@ -232,16 +240,16 @@
15.296 * @return a new instance of the File Transfer.
15.297 */
15.298 GMythFileTransfer *
15.299 -gmyth_file_transfer_new_with_uri (const gchar * uri_str)
15.300 +gmyth_file_transfer_new_with_uri ( const gchar * uri_str )
15.301 {
15.302 GMythFileTransfer *transfer =
15.303 - GMYTH_FILE_TRANSFER (g_object_new (GMYTH_FILE_TRANSFER_TYPE, NULL));
15.304 - gmyth_debug ("URI str = %s", uri_str);
15.305 + GMYTH_FILE_TRANSFER ( g_object_new ( GMYTH_FILE_TRANSFER_TYPE, NULL ) );
15.306 + gmyth_debug ( "URI str = %s", uri_str );
15.307 //GMythBackendInfo *backend_info = gmyth_backend_info_new_with_uri (uri_str);
15.308 GValue val = { 0, };
15.309 - g_value_init (&val, G_TYPE_OBJECT);
15.310 - g_value_set_object (&val, gmyth_backend_info_new_with_uri (uri_str));
15.311 - g_object_set (G_OBJECT (transfer), "backend-info", &val, NULL);
15.312 + g_value_init ( &val, G_TYPE_OBJECT );
15.313 + g_value_set_object ( &val, gmyth_backend_info_new_with_uri ( uri_str ) );
15.314 + g_object_set ( G_OBJECT ( transfer ), "backend-info", &val, NULL );
15.315
15.316 return transfer;
15.317 }
15.318 @@ -255,64 +263,75 @@
15.319 * @return <code>true</code>, if the connection opening had been done successfully.
15.320 */
15.321 gboolean
15.322 -gmyth_file_transfer_open (GMythFileTransfer * transfer, const gchar * filename)
15.323 +gmyth_file_transfer_open ( GMythFileTransfer * transfer,
15.324 + const gchar * filename )
15.325 {
15.326 gboolean ret = TRUE;
15.327 GMythFileTransferPrivate *priv;
15.328
15.329 - g_return_val_if_fail (transfer != NULL, FALSE);
15.330 - g_return_val_if_fail (filename != NULL && strlen (filename) > 0, FALSE);
15.331 + g_return_val_if_fail ( transfer != NULL, FALSE );
15.332 + g_return_val_if_fail ( filename != NULL && strlen ( filename ) > 0, FALSE );
15.333
15.334 - priv = GMYTH_FILE_TRANSFER_GET_PRIVATE (transfer);
15.335 + priv = GMYTH_FILE_TRANSFER_GET_PRIVATE ( transfer );
15.336
15.337 - gmyth_debug ("Opening the FileTransfer... (%s)", filename);
15.338 + gmyth_debug ( "Opening the FileTransfer... (%s)", filename );
15.339
15.340 - g_object_set (GMYTH_FILE (transfer), "filename", filename, NULL);
15.341 + g_object_set ( GMYTH_FILE ( transfer ), "filename", filename, NULL );
15.342
15.343 /* configure the control socket */
15.344 - if (TRUE /*priv->control_sock == NULL */ ) {
15.345 - if (!_connect_to_backend (transfer)) {
15.346 - gmyth_debug ("Connection to backend failed (Control Socket).");
15.347 + if ( TRUE /*priv->control_sock == NULL */ )
15.348 + {
15.349 + if ( !_connect_to_backend ( transfer ) )
15.350 + {
15.351 + gmyth_debug ( "Connection to backend failed (Control Socket)." );
15.352 ret = FALSE;
15.353 }
15.354
15.355 - if (priv->do_next_program_chain) {
15.356 + if ( priv->do_next_program_chain )
15.357 + {
15.358 priv->do_next_program_chain = FALSE; // fixme
15.359 gmyth_debug
15.360 - ("New file available before the current file was opened");
15.361 + ( "New file available before the current file was opened" );
15.362 GMythProgramInfo *prog_info =
15.363 - gmyth_recorder_get_current_program_info (priv->recorder);
15.364 + gmyth_recorder_get_current_program_info ( priv->recorder );
15.365
15.366 - if (prog_info != NULL && prog_info->pathname != NULL
15.367 - && strlen (prog_info->pathname->str) > 0
15.368 - && g_ascii_strcasecmp (prog_info->pathname->str,
15.369 - gmyth_file_get_file_name (GMYTH_FILE (transfer)))
15.370 - != 0)
15.371 + if ( prog_info != NULL && prog_info->pathname != NULL
15.372 + && strlen ( prog_info->pathname->str ) > 0
15.373 + && g_ascii_strcasecmp ( prog_info->pathname->str,
15.374 + gmyth_file_get_file_name ( GMYTH_FILE
15.375 + ( transfer ) ) )
15.376 + != 0 )
15.377 ret =
15.378 - gmyth_file_transfer_open (transfer,
15.379 - g_strrstr (prog_info->pathname->str, "/"));
15.380 + gmyth_file_transfer_open ( transfer,
15.381 + g_strrstr ( prog_info->pathname->
15.382 + str, "/" ) );
15.383
15.384 - if (prog_info != NULL)
15.385 - g_object_unref (prog_info);
15.386 + if ( prog_info != NULL )
15.387 + g_object_unref ( prog_info );
15.388
15.389 - if (!ret)
15.390 - gmyth_debug ("Cannot change to the next program info!");
15.391 + if ( !ret )
15.392 + gmyth_debug ( "Cannot change to the next program info!" );
15.393 else
15.394 - gmyth_debug ("OK!!! MOVED to the next program info [%s]!",
15.395 - gmyth_file_get_file_name (GMYTH_FILE (transfer)));
15.396 + gmyth_debug ( "OK!!! MOVED to the next program info [%s]!",
15.397 + gmyth_file_get_file_name ( GMYTH_FILE
15.398 + ( transfer ) ) );
15.399
15.400 - } else {
15.401 - gmyth_debug ("XXXXXXXXXXXXXX Oulu tests XXXXXXXXXXXXXXXX");
15.402 + }
15.403 + else
15.404 + {
15.405 + gmyth_debug ( "XXXXXXXXXXXXXX Oulu tests XXXXXXXXXXXXXXXX" );
15.406 gmyth_debug
15.407 - ("None new file found. We continue with the same file opened before");
15.408 + ( "None new file found. We continue with the same file opened before" );
15.409 }
15.410
15.411 - } else {
15.412 - gmyth_debug ("Remote transfer control socket already created.");
15.413 + }
15.414 + else
15.415 + {
15.416 + gmyth_debug ( "Remote transfer control socket already created." );
15.417 }
15.418
15.419 - gmyth_debug ("Got file with size = %lld.\n",
15.420 - gmyth_file_get_filesize (GMYTH_FILE (transfer)));
15.421 + gmyth_debug ( "Got file with size = %lld.\n",
15.422 + gmyth_file_get_filesize ( GMYTH_FILE ( transfer ) ) );
15.423
15.424 return ret;
15.425 }
15.426 @@ -325,7 +344,7 @@
15.427 * @return <code>true</code>, if the connection had been configured successfully.
15.428 */
15.429 static gboolean
15.430 -_connect_to_backend (GMythFileTransfer * transfer)
15.431 +_connect_to_backend ( GMythFileTransfer * transfer )
15.432 {
15.433 GString *base_str = NULL;
15.434 GString *hostname = NULL;
15.435 @@ -334,93 +353,100 @@
15.436 GMythFileTransferPrivate *priv;
15.437 GMythBackendInfo *backend_info;
15.438
15.439 - g_return_val_if_fail (transfer != NULL, FALSE);
15.440 + g_return_val_if_fail ( transfer != NULL, FALSE );
15.441
15.442 - g_object_get (GMYTH_FILE (transfer), "backend-info", &backend_info, NULL);
15.443 + g_object_get ( GMYTH_FILE ( transfer ), "backend-info", &backend_info,
15.444 + NULL );
15.445
15.446 - priv = GMYTH_FILE_TRANSFER_GET_PRIVATE (transfer);
15.447 - _control_acquire_context (transfer, TRUE);
15.448 + priv = GMYTH_FILE_TRANSFER_GET_PRIVATE ( transfer );
15.449 + _control_acquire_context ( transfer, TRUE );
15.450
15.451 /* Creates the control socket */
15.452
15.453 - if (priv->control_sock != NULL) {
15.454 - g_object_unref (priv->control_sock);
15.455 + if ( priv->control_sock != NULL )
15.456 + {
15.457 + g_object_unref ( priv->control_sock );
15.458 priv->control_sock = NULL;
15.459 }
15.460
15.461 - base_str = g_string_new ("");
15.462 + base_str = g_string_new ( "" );
15.463
15.464 - priv->control_sock = gmyth_socket_new ();
15.465 + priv->control_sock = gmyth_socket_new ( );
15.466 // Connects the socket, send Mythtv ANN command and verify Mythtv protocol version
15.467 - if (!gmyth_socket_connect_to_backend (priv->control_sock,
15.468 - backend_info->hostname, backend_info->port, TRUE)) {
15.469 + if ( !gmyth_socket_connect_to_backend ( priv->control_sock,
15.470 + backend_info->hostname,
15.471 + backend_info->port, TRUE ) )
15.472 + {
15.473
15.474 - g_object_unref (priv->control_sock);
15.475 + g_object_unref ( priv->control_sock );
15.476 priv->control_sock = NULL;
15.477 return FALSE;
15.478 }
15.479
15.480 /* Creates the data socket */
15.481 - if (priv->sock != NULL) {
15.482 - g_object_unref (priv->sock);
15.483 + if ( priv->sock != NULL )
15.484 + {
15.485 + g_object_unref ( priv->sock );
15.486 priv->sock = NULL;
15.487 }
15.488
15.489 - priv->sock = gmyth_socket_new ();
15.490 - gmyth_socket_connect (priv->sock, backend_info->hostname,
15.491 - backend_info->port);
15.492 - gmyth_debug ("Connecting file transfer... (%s, %d)",
15.493 - backend_info->hostname, backend_info->port);
15.494 + priv->sock = gmyth_socket_new ( );
15.495 + gmyth_socket_connect ( priv->sock, backend_info->hostname,
15.496 + backend_info->port );
15.497 + gmyth_debug ( "Connecting file transfer... (%s, %d)",
15.498 + backend_info->hostname, backend_info->port );
15.499
15.500 - strlist = gmyth_string_list_new ();
15.501 - hostname = gmyth_socket_get_local_hostname ();
15.502 - gmyth_debug ("[%s] MythTV version (from backend) = %d.\n", __FUNCTION__,
15.503 - priv->control_sock->mythtv_version);
15.504 - if (priv->control_sock->mythtv_version > 26)
15.505 - g_string_printf (base_str, "ANN FileTransfer %s 1 -1", hostname->str);
15.506 + strlist = gmyth_string_list_new ( );
15.507 + hostname = gmyth_socket_get_local_hostname ( );
15.508 + gmyth_debug ( "[%s] MythTV version (from backend) = %d.\n", __FUNCTION__,
15.509 + priv->control_sock->mythtv_version );
15.510 + if ( priv->control_sock->mythtv_version > 26 )
15.511 + g_string_printf ( base_str, "ANN FileTransfer %s 1 -1", hostname->str );
15.512 else
15.513 - g_string_printf (base_str, "ANN FileTransfer %s", hostname->str);
15.514 + g_string_printf ( base_str, "ANN FileTransfer %s", hostname->str );
15.515
15.516 - gmyth_string_list_append_string (strlist, base_str);
15.517 - gmyth_string_list_append_char_array (strlist,
15.518 - gmyth_file_get_file_name (GMYTH_FILE (transfer)));
15.519 + gmyth_string_list_append_string ( strlist, base_str );
15.520 + gmyth_string_list_append_char_array ( strlist,
15.521 + gmyth_file_get_file_name ( GMYTH_FILE
15.522 + ( transfer ) ) );
15.523
15.524 - gmyth_socket_write_stringlist (priv->sock, strlist);
15.525 + gmyth_socket_write_stringlist ( priv->sock, strlist );
15.526
15.527 /* MONITOR Handler - DVB TV Chain update messages!!! */
15.528
15.529 - gmyth_socket_read_stringlist (priv->sock, strlist);
15.530 + gmyth_socket_read_stringlist ( priv->sock, strlist );
15.531
15.532 /* file identification used in future file transfer requests to backend */
15.533 - priv->file_id = gmyth_string_list_get_int (strlist, 1);
15.534 + priv->file_id = gmyth_string_list_get_int ( strlist, 1 );
15.535
15.536 /* Myth URI stream file size - decoded using two 8-bytes sequences (64 bits/long long types) */
15.537 - gmyth_file_set_filesize (GMYTH_FILE (transfer),
15.538 - gmyth_string_list_get_int64 (strlist, 2));
15.539 + gmyth_file_set_filesize ( GMYTH_FILE ( transfer ),
15.540 + gmyth_string_list_get_int64 ( strlist, 2 ) );
15.541
15.542 - gmyth_debug ("***** Received: recordernum = %d, filesize = %"
15.543 - G_GUINT64_FORMAT "\n", priv->file_id,
15.544 - gmyth_file_get_filesize (GMYTH_FILE (transfer)));
15.545 + gmyth_debug ( "***** Received: recordernum = %d, filesize = %"
15.546 + G_GUINT64_FORMAT "\n", priv->file_id,
15.547 + gmyth_file_get_filesize ( GMYTH_FILE ( transfer ) ) );
15.548
15.549 - if (gmyth_file_get_filesize (GMYTH_FILE (transfer)) < 0) {
15.550 + if ( gmyth_file_get_filesize ( GMYTH_FILE ( transfer ) ) < 0 )
15.551 + {
15.552 gmyth_debug
15.553 - ("Got filesize equals to %llu is lesser than 0 [invalid stream file]\n",
15.554 - gmyth_file_get_filesize (GMYTH_FILE (transfer)));
15.555 - g_object_unref (priv->sock);
15.556 + ( "Got filesize equals to %llu is lesser than 0 [invalid stream file]\n",
15.557 + gmyth_file_get_filesize ( GMYTH_FILE ( transfer ) ) );
15.558 + g_object_unref ( priv->sock );
15.559 priv->sock = NULL;
15.560 ret = FALSE;
15.561 }
15.562
15.563 - _control_release_context (transfer);
15.564 + _control_release_context ( transfer );
15.565
15.566 - if (strlist != NULL)
15.567 - g_object_unref (strlist);
15.568 + if ( strlist != NULL )
15.569 + g_object_unref ( strlist );
15.570
15.571 - if (base_str != NULL)
15.572 - g_string_free (base_str, TRUE);
15.573 + if ( base_str != NULL )
15.574 + g_string_free ( base_str, TRUE );
15.575
15.576 - if (hostname != NULL)
15.577 - g_string_free (hostname, TRUE);
15.578 + if ( hostname != NULL )
15.579 + g_string_free ( hostname, TRUE );
15.580
15.581 return ret;
15.582 }
15.583 @@ -434,13 +460,15 @@
15.584 * @param live_tv A pointer to the LiveTV instance. *
15.585 */
15.586 void
15.587 -gmyth_file_transfer_emit_program_info_changed_signal (GMythFileTransfer *
15.588 - transfer, gint msg_code, gpointer live_tv_recorder)
15.589 +gmyth_file_transfer_emit_program_info_changed_signal ( GMythFileTransfer *
15.590 + transfer, gint msg_code,
15.591 + gpointer
15.592 + live_tv_recorder )
15.593 {
15.594 - gmyth_debug ("Calling signal handler... [FILE_TRANSFER]");
15.595 + gmyth_debug ( "Calling signal handler... [FILE_TRANSFER]" );
15.596
15.597 - g_signal_emit (transfer, GMYTH_FILE_TRANSFER_GET_CLASS (transfer)->program_info_changed_handler_signal_id, 0, /* details */
15.598 - msg_code, live_tv_recorder);
15.599 + g_signal_emit ( transfer, GMYTH_FILE_TRANSFER_GET_CLASS ( transfer )->program_info_changed_handler_signal_id, 0, /* details */
15.600 + msg_code, live_tv_recorder );
15.601
15.602 }
15.603
15.604 @@ -452,36 +480,36 @@
15.605 * @return <code>true</code>, if the File Transfer connection is opened.
15.606 */
15.607 gboolean
15.608 -gmyth_file_transfer_is_open (GMythFileTransfer * transfer)
15.609 +gmyth_file_transfer_is_open ( GMythFileTransfer * transfer )
15.610 {
15.611 GMythStringList *strlist;
15.612 GMythFileTransferPrivate *priv;
15.613 GString *query;
15.614
15.615 - g_return_val_if_fail (transfer != NULL, FALSE);
15.616 + g_return_val_if_fail ( transfer != NULL, FALSE );
15.617
15.618 - priv = GMYTH_FILE_TRANSFER_GET_PRIVATE (transfer);
15.619 - g_return_val_if_fail (priv->control_sock != NULL, FALSE);
15.620 - g_return_val_if_fail (priv->sock != NULL, FALSE);
15.621 + priv = GMYTH_FILE_TRANSFER_GET_PRIVATE ( transfer );
15.622 + g_return_val_if_fail ( priv->control_sock != NULL, FALSE );
15.623 + g_return_val_if_fail ( priv->sock != NULL, FALSE );
15.624
15.625 - _control_acquire_context (transfer, TRUE);
15.626 + _control_acquire_context ( transfer, TRUE );
15.627
15.628 - strlist = gmyth_string_list_new ();
15.629 - query = g_string_new (GMYTHTV_QUERY_HEADER);
15.630 - g_string_append_printf (query, "%d", priv->file_id);
15.631 + strlist = gmyth_string_list_new ( );
15.632 + query = g_string_new ( GMYTHTV_QUERY_HEADER );
15.633 + g_string_append_printf ( query, "%d", priv->file_id );
15.634
15.635 - gmyth_string_list_append_string (strlist, query);
15.636 - gmyth_string_list_append_char_array (strlist, "IS_OPEN");
15.637 + gmyth_string_list_append_string ( strlist, query );
15.638 + gmyth_string_list_append_char_array ( strlist, "IS_OPEN" );
15.639
15.640 - gmyth_socket_write_stringlist (priv->control_sock, strlist);
15.641 - gmyth_socket_read_stringlist (priv->control_sock, strlist);
15.642 + gmyth_socket_write_stringlist ( priv->control_sock, strlist );
15.643 + gmyth_socket_read_stringlist ( priv->control_sock, strlist );
15.644
15.645 - _control_release_context (transfer);
15.646 + _control_release_context ( transfer );
15.647
15.648 - g_string_free (query, TRUE);
15.649 - g_object_unref (strlist);
15.650 + g_string_free ( query, TRUE );
15.651 + g_object_unref ( strlist );
15.652
15.653 - return (strlist != NULL && gmyth_string_list_get_int (strlist, 0) == 1);
15.654 + return ( strlist != NULL && gmyth_string_list_get_int ( strlist, 0 ) == 1 );
15.655 }
15.656
15.657 /**
15.658 @@ -490,47 +518,51 @@
15.659 * @param transfer The actual File Transfer instance.
15.660 */
15.661 void
15.662 -gmyth_file_transfer_close (GMythFileTransfer * transfer)
15.663 +gmyth_file_transfer_close ( GMythFileTransfer * transfer )
15.664 {
15.665 GMythStringList *strlist;
15.666 GMythFileTransferPrivate *priv;
15.667 GString *query;
15.668
15.669 - g_return_if_fail (transfer != NULL);
15.670 + g_return_if_fail ( transfer != NULL );
15.671
15.672 - priv = GMYTH_FILE_TRANSFER_GET_PRIVATE (transfer);
15.673 + priv = GMYTH_FILE_TRANSFER_GET_PRIVATE ( transfer );
15.674
15.675 - if (priv->control_sock == NULL)
15.676 + if ( priv->control_sock == NULL )
15.677 return;
15.678
15.679 - _control_acquire_context (transfer, TRUE);
15.680 + _control_acquire_context ( transfer, TRUE );
15.681
15.682 - strlist = gmyth_string_list_new ();
15.683 - query = g_string_new (GMYTHTV_QUERY_HEADER);
15.684 - g_string_append_printf (query, "%d", priv->file_id);
15.685 + strlist = gmyth_string_list_new ( );
15.686 + query = g_string_new ( GMYTHTV_QUERY_HEADER );
15.687 + g_string_append_printf ( query, "%d", priv->file_id );
15.688
15.689 - gmyth_string_list_append_string (strlist, query);
15.690 - gmyth_string_list_append_char_array (strlist, "DONE");
15.691 + gmyth_string_list_append_string ( strlist, query );
15.692 + gmyth_string_list_append_char_array ( strlist, "DONE" );
15.693
15.694 - if (gmyth_socket_sendreceive_stringlist (priv->control_sock, strlist) <= 0) {
15.695 + if ( gmyth_socket_sendreceive_stringlist ( priv->control_sock, strlist ) <=
15.696 + 0 )
15.697 + {
15.698 // fixme: time out???
15.699 - gmyth_debug ("Remote file timeout.\n");
15.700 + gmyth_debug ( "Remote file timeout.\n" );
15.701 }
15.702
15.703 - g_string_free (query, TRUE);
15.704 - g_object_unref (strlist);
15.705 + g_string_free ( query, TRUE );
15.706 + g_object_unref ( strlist );
15.707
15.708 - if (priv->sock) {
15.709 - g_object_unref (priv->sock);
15.710 + if ( priv->sock )
15.711 + {
15.712 + g_object_unref ( priv->sock );
15.713 priv->sock = NULL;
15.714 }
15.715
15.716 - if (priv->control_sock) {
15.717 - g_object_unref (priv->control_sock);
15.718 + if ( priv->control_sock )
15.719 + {
15.720 + g_object_unref ( priv->control_sock );
15.721 priv->control_sock = NULL;
15.722 }
15.723
15.724 - _control_release_context (transfer);
15.725 + _control_release_context ( transfer );
15.726 }
15.727
15.728 /**
15.729 @@ -543,47 +575,48 @@
15.730 * @return The actual position on the remote file (after seek has been done).
15.731 */
15.732 gint64
15.733 -gmyth_file_transfer_seek (GMythFileTransfer * transfer, guint64 pos,
15.734 - gint whence)
15.735 +gmyth_file_transfer_seek ( GMythFileTransfer * transfer, guint64 pos,
15.736 + gint whence )
15.737 {
15.738 - GMythStringList *strlist = gmyth_string_list_new ();
15.739 + GMythStringList *strlist = gmyth_string_list_new ( );
15.740 GMythFileTransferPrivate *priv;
15.741 GString *query;
15.742
15.743 - g_return_val_if_fail (transfer != NULL, FALSE);
15.744 - priv = GMYTH_FILE_TRANSFER_GET_PRIVATE (transfer);
15.745 + g_return_val_if_fail ( transfer != NULL, FALSE );
15.746 + priv = GMYTH_FILE_TRANSFER_GET_PRIVATE ( transfer );
15.747
15.748 - g_return_val_if_fail (priv->sock != NULL, -1);
15.749 - g_return_val_if_fail (priv->control_sock != NULL, -1);
15.750 + g_return_val_if_fail ( priv->sock != NULL, -1 );
15.751 + g_return_val_if_fail ( priv->control_sock != NULL, -1 );
15.752
15.753 - strlist = gmyth_string_list_new ();
15.754 - query = g_string_new (GMYTHTV_QUERY_HEADER);
15.755 - g_string_append_printf (query, "%d", priv->file_id);
15.756 + strlist = gmyth_string_list_new ( );
15.757 + query = g_string_new ( GMYTHTV_QUERY_HEADER );
15.758 + g_string_append_printf ( query, "%d", priv->file_id );
15.759
15.760 /* myth_control_acquire_context( transfer, TRUE ); */
15.761
15.762 - gmyth_string_list_append_string (strlist, query);
15.763 - gmyth_string_list_append_char_array (strlist, "SEEK");
15.764 - gmyth_string_list_append_uint64 (strlist, pos);
15.765 + gmyth_string_list_append_string ( strlist, query );
15.766 + gmyth_string_list_append_char_array ( strlist, "SEEK" );
15.767 + gmyth_string_list_append_uint64 ( strlist, pos );
15.768
15.769 - gmyth_string_list_append_int (strlist, whence);
15.770 + gmyth_string_list_append_int ( strlist, whence );
15.771
15.772 - if (pos > 0)
15.773 - gmyth_string_list_append_uint64 (strlist, pos);
15.774 + if ( pos > 0 )
15.775 + gmyth_string_list_append_uint64 ( strlist, pos );
15.776 else
15.777 - gmyth_string_list_append_uint64 (strlist,
15.778 - gmyth_file_get_offset (GMYTH_FILE (transfer)));
15.779 + gmyth_string_list_append_uint64 ( strlist,
15.780 + gmyth_file_get_offset ( GMYTH_FILE
15.781 + ( transfer ) ) );
15.782
15.783 - gmyth_socket_sendreceive_stringlist (priv->control_sock, strlist);
15.784 + gmyth_socket_sendreceive_stringlist ( priv->control_sock, strlist );
15.785
15.786 - gint64 retval = gmyth_string_list_get_int64 (strlist, 0);
15.787 + gint64 retval = gmyth_string_list_get_int64 ( strlist, 0 );
15.788
15.789 - gmyth_file_set_offset (GMYTH_FILE (transfer), retval);
15.790 - gmyth_debug ("Got reading position pointer from the streaming = %lld\n",
15.791 - retval);
15.792 + gmyth_file_set_offset ( GMYTH_FILE ( transfer ), retval );
15.793 + gmyth_debug ( "Got reading position pointer from the streaming = %lld\n",
15.794 + retval );
15.795
15.796 - g_object_unref (strlist);
15.797 - g_string_free (query, TRUE);
15.798 + g_object_unref ( strlist );
15.799 + g_string_free ( query, TRUE );
15.800
15.801 /* myth_control_release_context( transfer ); */
15.802
15.803 @@ -599,15 +632,15 @@
15.804 * @return <code>true</code>, if the acquire had been got.
15.805 */
15.806 static gboolean
15.807 -_control_acquire_context (GMythFileTransfer * transfer, gboolean do_wait)
15.808 +_control_acquire_context ( GMythFileTransfer * transfer, gboolean do_wait )
15.809 {
15.810 gboolean ret = TRUE;
15.811 GMythFileTransferPrivate *priv;
15.812
15.813 - g_return_val_if_fail (transfer != NULL, FALSE);
15.814 - priv = GMYTH_FILE_TRANSFER_GET_PRIVATE (transfer);
15.815 + g_return_val_if_fail ( transfer != NULL, FALSE );
15.816 + priv = GMYTH_FILE_TRANSFER_GET_PRIVATE ( transfer );
15.817
15.818 - g_mutex_lock (priv->mutex);
15.819 + g_mutex_lock ( priv->mutex );
15.820 return ret;
15.821 }
15.822
15.823 @@ -619,15 +652,15 @@
15.824 * @return <code>true</code>, if the socket read/write permissions had been releaseds.
15.825 */
15.826 static gboolean
15.827 -_control_release_context (GMythFileTransfer * transfer)
15.828 +_control_release_context ( GMythFileTransfer * transfer )
15.829 {
15.830 gboolean ret = TRUE;
15.831 GMythFileTransferPrivate *priv;
15.832
15.833 - g_return_val_if_fail (transfer != NULL, FALSE);
15.834 - priv = GMYTH_FILE_TRANSFER_GET_PRIVATE (transfer);
15.835 + g_return_val_if_fail ( transfer != NULL, FALSE );
15.836 + priv = GMYTH_FILE_TRANSFER_GET_PRIVATE ( transfer );
15.837
15.838 - g_mutex_unlock (priv->mutex);
15.839 + g_mutex_unlock ( priv->mutex );
15.840
15.841 return ret;
15.842 }
15.843 @@ -646,8 +679,8 @@
15.844 * or the error code.
15.845 */
15.846 GMythFileReadResult
15.847 -gmyth_file_transfer_read (GMythFileTransfer * transfer, GByteArray * data,
15.848 - gint size, gboolean read_unlimited)
15.849 +gmyth_file_transfer_read ( GMythFileTransfer * transfer, GByteArray * data,
15.850 + gint size, gboolean read_unlimited )
15.851 {
15.852 gint bytes_sent = 0;
15.853 gsize bytes_read = 0;
15.854 @@ -670,194 +703,221 @@
15.855 gboolean ret = TRUE;
15.856 GString *query;
15.857
15.858 - g_return_val_if_fail (transfer != NULL, FALSE);
15.859 - g_return_val_if_fail (data != NULL, GMYTH_FILE_READ_ERROR);
15.860 + g_return_val_if_fail ( transfer != NULL, FALSE );
15.861 + g_return_val_if_fail ( data != NULL, GMYTH_FILE_READ_ERROR );
15.862
15.863 - priv = GMYTH_FILE_TRANSFER_GET_PRIVATE (transfer);
15.864 + priv = GMYTH_FILE_TRANSFER_GET_PRIVATE ( transfer );
15.865
15.866 - strlist = gmyth_string_list_new ();
15.867 + strlist = gmyth_string_list_new ( );
15.868
15.869 io_channel = priv->sock->sd_io_ch;
15.870 io_channel_control = priv->control_sock->sd_io_ch;
15.871
15.872 - io_status = g_io_channel_set_encoding (io_channel, NULL, &error);
15.873 - if (io_status == G_IO_STATUS_NORMAL)
15.874 - gmyth_debug ("[%s] Setting encoding to binary data socket).\n",
15.875 - __FUNCTION__);
15.876 + io_status = g_io_channel_set_encoding ( io_channel, NULL, &error );
15.877 + if ( io_status == G_IO_STATUS_NORMAL )
15.878 + gmyth_debug ( "[%s] Setting encoding to binary data socket).\n",
15.879 + __FUNCTION__ );
15.880
15.881 - io_cond = g_io_channel_get_buffer_condition (io_channel);
15.882 + io_cond = g_io_channel_get_buffer_condition ( io_channel );
15.883
15.884 - io_cond_control = g_io_channel_get_buffer_condition (io_channel);
15.885 - if (priv->sock == NULL || (io_status == G_IO_STATUS_ERROR)) {
15.886 - g_printerr ("gmyth_file_transfer_read(): Called with no raw socket.\n");
15.887 + io_cond_control = g_io_channel_get_buffer_condition ( io_channel );
15.888 + if ( priv->sock == NULL || ( io_status == G_IO_STATUS_ERROR ) )
15.889 + {
15.890 + g_printerr
15.891 + ( "gmyth_file_transfer_read(): Called with no raw socket.\n" );
15.892 return GMYTH_FILE_READ_ERROR;
15.893 }
15.894
15.895 - if (priv->control_sock == NULL || (io_status_control == G_IO_STATUS_ERROR)) {
15.896 + if ( priv->control_sock == NULL
15.897 + || ( io_status_control == G_IO_STATUS_ERROR ) )
15.898 + {
15.899 g_printerr
15.900 - ("gmyth_file_transfer_read(): Called with no control socket.\n");
15.901 + ( "gmyth_file_transfer_read(): Called with no control socket.\n" );
15.902 return GMYTH_FILE_READ_ERROR;
15.903 }
15.904
15.905 - query = g_string_new (GMYTHTV_QUERY_HEADER);
15.906 - g_string_append_printf (query, "%d", priv->file_id);
15.907 - gmyth_debug ("[%s] Transfer_query = %s\n", __FUNCTION__, query->str);
15.908 + query = g_string_new ( GMYTHTV_QUERY_HEADER );
15.909 + g_string_append_printf ( query, "%d", priv->file_id );
15.910 + gmyth_debug ( "[%s] Transfer_query = %s\n", __FUNCTION__, query->str );
15.911
15.912 - _control_acquire_context (transfer, TRUE);
15.913 + _control_acquire_context ( transfer, TRUE );
15.914 //Do Read
15.915 - gmyth_string_list_append_char_array (strlist, query->str);
15.916 - gmyth_string_list_append_char_array (strlist, "REQUEST_BLOCK");
15.917 - gmyth_string_list_append_int (strlist, size - total_read);
15.918 + gmyth_string_list_append_char_array ( strlist, query->str );
15.919 + gmyth_string_list_append_char_array ( strlist, "REQUEST_BLOCK" );
15.920 + gmyth_string_list_append_int ( strlist, size - total_read );
15.921
15.922 guint iter_count = 3;
15.923
15.924 - do {
15.925 + do
15.926 + {
15.927 bytes_sent = 0;
15.928
15.929 // Request the block to the backend
15.930 - gmyth_socket_write_stringlist (priv->control_sock, strlist);
15.931 + gmyth_socket_write_stringlist ( priv->control_sock, strlist );
15.932
15.933 - if (ret_strlist != NULL)
15.934 - g_object_unref (ret_strlist);
15.935 + if ( ret_strlist != NULL )
15.936 + g_object_unref ( ret_strlist );
15.937
15.938 - ret_strlist = gmyth_string_list_new ();
15.939 + ret_strlist = gmyth_string_list_new ( );
15.940 // Receives the backand answer
15.941 - gmyth_socket_read_stringlist (priv->control_sock, ret_strlist);
15.942 + gmyth_socket_read_stringlist ( priv->control_sock, ret_strlist );
15.943
15.944 - if (ret_strlist != NULL && gmyth_string_list_length (ret_strlist) > 0) {
15.945 - bytes_sent = gmyth_string_list_get_int (ret_strlist, 0); // -1 on backend error
15.946 - gmyth_debug ("[%s] got SENT buffer message = %d\n", __FUNCTION__,
15.947 - bytes_sent);
15.948 + if ( ret_strlist != NULL
15.949 + && gmyth_string_list_length ( ret_strlist ) > 0 )
15.950 + {
15.951 + bytes_sent = gmyth_string_list_get_int ( ret_strlist, 0 ); // -1 on backend error
15.952 + gmyth_debug ( "[%s] got SENT buffer message = %d\n", __FUNCTION__,
15.953 + bytes_sent );
15.954 }
15.955
15.956 - if (read_unlimited && (bytes_sent == 0)) {
15.957 - g_usleep (300);
15.958 + if ( read_unlimited && ( bytes_sent == 0 ) )
15.959 + {
15.960 + g_usleep ( 300 );
15.961 }
15.962
15.963 --iter_count;
15.964
15.965 }
15.966 - while (read_unlimited && (bytes_sent == 0) && iter_count > 0);
15.967 + while ( read_unlimited && ( bytes_sent == 0 ) && iter_count > 0 );
15.968
15.969 - if (bytes_sent > 0) {
15.970 - gchar *data_buffer = g_new0 (gchar, bytes_sent);
15.971 + if ( bytes_sent > 0 )
15.972 + {
15.973 + gchar *data_buffer = g_new0 ( gchar, bytes_sent );
15.974
15.975 - io_status = g_io_channel_read_chars (io_channel,
15.976 - data_buffer, (gsize) bytes_sent, &bytes_read, &error);
15.977 + io_status = g_io_channel_read_chars ( io_channel,
15.978 + data_buffer, ( gsize ) bytes_sent,
15.979 + &bytes_read, &error );
15.980
15.981 - if (io_status != G_IO_STATUS_NORMAL) {
15.982 - gmyth_debug ("Error on io_channel");
15.983 - g_free (data_buffer);
15.984 - g_object_unref (strlist);
15.985 + if ( io_status != G_IO_STATUS_NORMAL )
15.986 + {
15.987 + gmyth_debug ( "Error on io_channel" );
15.988 + g_free ( data_buffer );
15.989 + g_object_unref ( strlist );
15.990 retval = GMYTH_FILE_READ_ERROR;
15.991 goto error;
15.992 }
15.993
15.994 /* append new data to the increasing byte array */
15.995 data =
15.996 - g_byte_array_append (data, (const guint8 *) data_buffer,
15.997 - bytes_read);
15.998 - gmyth_file_set_offset (GMYTH_FILE (transfer),
15.999 - gmyth_file_get_offset (GMYTH_FILE (transfer)) + bytes_read);
15.1000 + g_byte_array_append ( data, ( const guint8 * ) data_buffer,
15.1001 + bytes_read );
15.1002 + gmyth_file_set_offset ( GMYTH_FILE ( transfer ),
15.1003 + gmyth_file_get_offset ( GMYTH_FILE
15.1004 + ( transfer ) ) +
15.1005 + bytes_read );
15.1006
15.1007 - if (!read_unlimited
15.1008 - && (gmyth_file_get_filesize (GMYTH_FILE (transfer)) > 0)
15.1009 - && (gmyth_file_get_offset (GMYTH_FILE (transfer)) ==
15.1010 - gmyth_file_get_filesize (GMYTH_FILE (transfer)))) {
15.1011 + if ( !read_unlimited
15.1012 + && ( gmyth_file_get_filesize ( GMYTH_FILE ( transfer ) ) > 0 )
15.1013 + && ( gmyth_file_get_offset ( GMYTH_FILE ( transfer ) ) ==
15.1014 + gmyth_file_get_filesize ( GMYTH_FILE ( transfer ) ) ) )
15.1015 + {
15.1016 retval = GMYTH_FILE_READ_EOF;
15.1017 goto error;
15.1018 }
15.1019
15.1020 - g_free (data_buffer);
15.1021 - } else {
15.1022 + g_free ( data_buffer );
15.1023 + }
15.1024 + else
15.1025 + {
15.1026 retval = GMYTH_FILE_READ_ERROR;
15.1027 }
15.1028
15.1029 - if (strlist != NULL) {
15.1030 - g_object_unref (strlist);
15.1031 + if ( strlist != NULL )
15.1032 + {
15.1033 + g_object_unref ( strlist );
15.1034 strlist = NULL;
15.1035 }
15.1036
15.1037 - if (ret_strlist != NULL) {
15.1038 - g_object_unref (ret_strlist);
15.1039 + if ( ret_strlist != NULL )
15.1040 + {
15.1041 + g_object_unref ( ret_strlist );
15.1042 ret_strlist = NULL;
15.1043 }
15.1044
15.1045 - if (read_unlimited && (bytes_sent == 0)) {
15.1046 - gmyth_debug ("Trying to move to the next program chain...");
15.1047 - if (priv->recorder != NULL && priv->do_next_program_chain) {
15.1048 + if ( read_unlimited && ( bytes_sent == 0 ) )
15.1049 + {
15.1050 + gmyth_debug ( "Trying to move to the next program chain..." );
15.1051 + if ( priv->recorder != NULL && priv->do_next_program_chain )
15.1052 + {
15.1053 priv->do_next_program_chain = FALSE;
15.1054 retval = GMYTH_FILE_READ_NEXT_PROG_CHAIN;
15.1055 GMythProgramInfo *prog_info =
15.1056 - gmyth_recorder_get_current_program_info (priv->recorder);
15.1057 + gmyth_recorder_get_current_program_info ( priv->recorder );
15.1058
15.1059 - if (prog_info != NULL && prog_info->pathname != NULL
15.1060 - && strlen (prog_info->pathname->str) > 0
15.1061 - && g_ascii_strcasecmp (prog_info->pathname->str,
15.1062 - gmyth_file_get_file_name (GMYTH_FILE (transfer)))
15.1063 - != 0)
15.1064 + if ( prog_info != NULL && prog_info->pathname != NULL
15.1065 + && strlen ( prog_info->pathname->str ) > 0
15.1066 + && g_ascii_strcasecmp ( prog_info->pathname->str,
15.1067 + gmyth_file_get_file_name ( GMYTH_FILE
15.1068 + ( transfer ) ) )
15.1069 + != 0 )
15.1070
15.1071 /* releasing context got at this function starting... */
15.1072 - _control_release_context (transfer);
15.1073 + _control_release_context ( transfer );
15.1074 ret =
15.1075 - gmyth_file_transfer_open (transfer,
15.1076 - g_strrstr (prog_info->pathname->str, "/"));
15.1077 - _control_acquire_context (transfer, TRUE);
15.1078 + gmyth_file_transfer_open ( transfer,
15.1079 + g_strrstr ( prog_info->pathname->str,
15.1080 + "/" ) );
15.1081 + _control_acquire_context ( transfer, TRUE );
15.1082 /* acquiring context released at this function stopping... */
15.1083
15.1084 - if (prog_info != NULL)
15.1085 - g_object_unref (prog_info);
15.1086 + if ( prog_info != NULL )
15.1087 + g_object_unref ( prog_info );
15.1088
15.1089 - if (!ret)
15.1090 - gmyth_debug ("Cannot change to the next program info!");
15.1091 + if ( !ret )
15.1092 + gmyth_debug ( "Cannot change to the next program info!" );
15.1093 else
15.1094 - gmyth_debug ("OK!!! MOVED to the next program info [%s]!",
15.1095 - gmyth_file_get_file_name (GMYTH_FILE (transfer)));
15.1096 + gmyth_debug ( "OK!!! MOVED to the next program info [%s]!",
15.1097 + gmyth_file_get_file_name ( GMYTH_FILE
15.1098 + ( transfer ) ) );
15.1099 }
15.1100
15.1101 }
15.1102 /* if */
15.1103 error:
15.1104
15.1105 - _control_release_context (transfer);
15.1106 - g_string_free (query, TRUE);
15.1107 + _control_release_context ( transfer );
15.1108 + g_string_free ( query, TRUE );
15.1109
15.1110 - if (error != NULL) {
15.1111 - gmyth_debug ("Cleaning-up ERROR: %s [msg = %s, code = %d]\n",
15.1112 - __FUNCTION__, error->message, error->code);
15.1113 - g_error_free (error);
15.1114 + if ( error != NULL )
15.1115 + {
15.1116 + gmyth_debug ( "Cleaning-up ERROR: %s [msg = %s, code = %d]\n",
15.1117 + __FUNCTION__, error->message, error->code );
15.1118 + g_error_free ( error );
15.1119 }
15.1120
15.1121 - if (total_read > 0)
15.1122 - gmyth_file_set_offset (GMYTH_FILE (transfer),
15.1123 - gmyth_file_get_offset (GMYTH_FILE (transfer)) + total_read);
15.1124 + if ( total_read > 0 )
15.1125 + gmyth_file_set_offset ( GMYTH_FILE ( transfer ),
15.1126 + gmyth_file_get_offset ( GMYTH_FILE
15.1127 + ( transfer ) ) +
15.1128 + total_read );
15.1129
15.1130 return retval;
15.1131 }
15.1132
15.1133 static void
15.1134 -_file_transfer_program_info_changed (GMythFileTransfer * transfer,
15.1135 - gint msg_code, gpointer livetv_recorder)
15.1136 +_file_transfer_program_info_changed ( GMythFileTransfer * transfer,
15.1137 + gint msg_code, gpointer livetv_recorder )
15.1138 {
15.1139 GMythRecorder *recorder;
15.1140 GMythFileTransferPrivate *priv;
15.1141
15.1142 - g_return_if_fail (transfer != NULL);
15.1143 + g_return_if_fail ( transfer != NULL );
15.1144
15.1145 - priv = GMYTH_FILE_TRANSFER_GET_PRIVATE (transfer);
15.1146 + priv = GMYTH_FILE_TRANSFER_GET_PRIVATE ( transfer );
15.1147
15.1148 - recorder = GMYTH_RECORDER (livetv_recorder);
15.1149 + recorder = GMYTH_RECORDER ( livetv_recorder );
15.1150 gmyth_debug
15.1151 - ("Program info changed! ( file transfer orig. = %p, ptr. = [%s] )",
15.1152 - transfer, livetv_recorder != NULL ? "[NOT NULL]" : "[NULL]");
15.1153 + ( "Program info changed! ( file transfer orig. = %p, ptr. = [%s] )",
15.1154 + transfer, livetv_recorder != NULL ? "[NOT NULL]" : "[NULL]" );
15.1155
15.1156 - if (NULL != recorder) {
15.1157 + if ( NULL != recorder )
15.1158 + {
15.1159 gmyth_debug
15.1160 - ("YES, the requested program info movement on the LiveTV transfer is authentical!");
15.1161 + ( "YES, the requested program info movement on the LiveTV transfer is authentical!" );
15.1162 }
15.1163
15.1164 - priv = GMYTH_FILE_TRANSFER_GET_PRIVATE (transfer);
15.1165 - g_object_ref (recorder);
15.1166 + priv = GMYTH_FILE_TRANSFER_GET_PRIVATE ( transfer );
15.1167 + g_object_ref ( recorder );
15.1168 priv->recorder = recorder;
15.1169 priv->do_next_program_chain = TRUE;
15.1170 }
15.1171 @@ -872,40 +932,41 @@
15.1172 * @return <code>true</code>, if the acquire had been got.
15.1173 */
15.1174 gboolean
15.1175 -gmyth_file_transfer_settimeout (GMythFileTransfer * transfer, gboolean fast)
15.1176 +gmyth_file_transfer_settimeout ( GMythFileTransfer * transfer, gboolean fast )
15.1177 {
15.1178 GMythFileTransferPrivate *priv;
15.1179 GMythStringList *strlist = NULL;
15.1180
15.1181 - g_return_val_if_fail (transfer != NULL, FALSE);
15.1182 + g_return_val_if_fail ( transfer != NULL, FALSE );
15.1183
15.1184 - priv = GMYTH_FILE_TRANSFER_GET_PRIVATE (transfer);
15.1185 + priv = GMYTH_FILE_TRANSFER_GET_PRIVATE ( transfer );
15.1186
15.1187 - g_return_val_if_fail (priv->sock != NULL, FALSE);
15.1188 - g_return_val_if_fail (priv->control_sock != NULL, FALSE);
15.1189 + g_return_val_if_fail ( priv->sock != NULL, FALSE );
15.1190 + g_return_val_if_fail ( priv->control_sock != NULL, FALSE );
15.1191
15.1192 - _control_acquire_context (transfer, TRUE);
15.1193 + _control_acquire_context ( transfer, TRUE );
15.1194
15.1195 - strlist = gmyth_string_list_new ();
15.1196 - gmyth_string_list_append_char_array (strlist, GMYTHTV_QUERY_HEADER);
15.1197 - gmyth_string_list_append_char_array (strlist, "SET_TIMEOUT");
15.1198 - gmyth_string_list_append_int (strlist, fast);
15.1199 + strlist = gmyth_string_list_new ( );
15.1200 + gmyth_string_list_append_char_array ( strlist, GMYTHTV_QUERY_HEADER );
15.1201 + gmyth_string_list_append_char_array ( strlist, "SET_TIMEOUT" );
15.1202 + gmyth_string_list_append_int ( strlist, fast );
15.1203
15.1204 - gint strlist_len = gmyth_socket_sendreceive_stringlist (priv->control_sock,
15.1205 - strlist);
15.1206 + gint strlist_len = gmyth_socket_sendreceive_stringlist ( priv->control_sock,
15.1207 + strlist );
15.1208
15.1209 - if (strlist_len > 0)
15.1210 - gmyth_debug ("Yes, timeout was changed: %s.",
15.1211 - gmyth_string_list_get_char_array (strlist, 0));
15.1212 + if ( strlist_len > 0 )
15.1213 + gmyth_debug ( "Yes, timeout was changed: %s.",
15.1214 + gmyth_string_list_get_char_array ( strlist, 0 ) );
15.1215 else
15.1216 - gmyth_debug ("Timeout cannot be changed!");
15.1217 + gmyth_debug ( "Timeout cannot be changed!" );
15.1218
15.1219 - _control_release_context (transfer);
15.1220 + _control_release_context ( transfer );
15.1221
15.1222 - gmyth_debug ("%s setting timeout flag of this file transfer = %s\n",
15.1223 - strlist_len > 0 ? "Yes," : "NOT", fast ? "FAST" : "NOT FAST");
15.1224 + gmyth_debug ( "%s setting timeout flag of this file transfer = %s\n",
15.1225 + strlist_len > 0 ? "Yes," : "NOT",
15.1226 + fast ? "FAST" : "NOT FAST" );
15.1227
15.1228 - g_object_unref (strlist);
15.1229 + g_object_unref ( strlist );
15.1230
15.1231 return TRUE;
15.1232 }
15.1233 @@ -918,13 +979,13 @@
15.1234 * @return The actual file size in bytes.
15.1235 */
15.1236 guint64
15.1237 -gmyth_file_transfer_get_filesize (GMythFileTransfer * transfer)
15.1238 +gmyth_file_transfer_get_filesize ( GMythFileTransfer * transfer )
15.1239 {
15.1240 guint64 filesize;
15.1241
15.1242 - g_return_val_if_fail (transfer != NULL, 0);
15.1243 + g_return_val_if_fail ( transfer != NULL, 0 );
15.1244
15.1245 - g_object_get (GMYTH_FILE (transfer), "file-size", &filesize, NULL);
15.1246 + g_object_get ( GMYTH_FILE ( transfer ), "file-size", &filesize, NULL );
15.1247
15.1248 return filesize;
15.1249 }
16.1 --- a/gmyth/src/gmyth_file_transfer.h Wed May 23 19:21:26 2007 +0100
16.2 +++ b/gmyth/src/gmyth_file_transfer.h Wed May 23 19:50:41 2007 +0100
16.3 @@ -9,22 +9,21 @@
16.4 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
16.5 * @author Rosfran Lins Borges <rosfran.borges@indt.org.br>
16.6 *
16.7 - *//*
16.8 - *
16.9 - * This program is free software; you can redistribute it and/or modify
16.10 - * it under the terms of the GNU Lesser General Public License as published by
16.11 - * the Free Software Foundation; either version 2 of the License, or
16.12 - * (at your option) any later version.
16.13 - *
16.14 - * This program is distributed in the hope that it will be useful,
16.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
16.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16.17 - * GNU General Public License for more details.
16.18 - *
16.19 - * You should have received a copy of the GNU Lesser General Public License
16.20 - * along with this program; if not, write to the Free Software
16.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16.22 - */
16.23 + *
16.24 + * This program is free software; you can redistribute it and/or modify
16.25 + * it under the terms of the GNU Lesser General Public License as published by
16.26 + * the Free Software Foundation; either version 2 of the License, or
16.27 + * (at your option) any later version.
16.28 + *
16.29 + * This program is distributed in the hope that it will be useful,
16.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
16.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16.32 + * GNU General Public License for more details.
16.33 + *
16.34 + * You should have received a copy of the GNU Lesser General Public License
16.35 + * along with this program; if not, write to the Free Software
16.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16.37 + */
16.38
16.39 #ifndef __GMYTH_FILE_TRANSFER_H__
16.40 #define __GMYTH_FILE_TRANSFER_H__
16.41 @@ -56,43 +55,48 @@
16.42 typedef struct _GMythFileTransferPrivate GMythFileTransferPrivate;
16.43
16.44 struct _GMythFileTransfer
16.45 -{
16.46 - GMythFile parent;
16.47 - GMythFileTransferPrivate *priv;
16.48 -};
16.49 + {
16.50 + GMythFile parent;
16.51 + GMythFileTransferPrivate *priv;
16.52 + };
16.53
16.54 struct _GMythFileTransferClass
16.55 -{
16.56 - GMythFileClass parent_class;
16.57 + {
16.58 + GMythFileClass parent_class;
16.59
16.60 - /* callbacks */
16.61 - guint program_info_changed_handler_signal_id;
16.62 + /* callbacks */
16.63 + guint program_info_changed_handler_signal_id;
16.64
16.65 - /* signal default handlers */
16.66 - void (*program_info_changed_handler) (GMythFileTransfer * transfer,
16.67 - gint msg_code, gpointer livetv_recorder);
16.68 -};
16.69 + /* signal default handlers */
16.70 + void ( *program_info_changed_handler ) ( GMythFileTransfer * transfer,
16.71 + gint msg_code,
16.72 + gpointer livetv_recorder );
16.73 + };
16.74
16.75
16.76 -GType gmyth_file_transfer_get_type (void);
16.77 -GMythFileTransfer *gmyth_file_transfer_new (GMythBackendInfo * backend_info);
16.78 -gchar *gmyth_file_transfer_get_file_name (GMythFileTransfer * transfer);
16.79 -gboolean gmyth_file_transfer_open (GMythFileTransfer * transfer,
16.80 - const gchar * filename);
16.81 -void gmyth_file_transfer_close (GMythFileTransfer * transfer);
16.82 -gboolean gmyth_file_transfer_is_open (GMythFileTransfer * transfer);
16.83 +GType gmyth_file_transfer_get_type ( void );
16.84 +GMythFileTransfer *gmyth_file_transfer_new ( GMythBackendInfo * backend_info );
16.85 +gchar *gmyth_file_transfer_get_file_name ( GMythFileTransfer * transfer );
16.86 +gboolean gmyth_file_transfer_open ( GMythFileTransfer * transfer,
16.87 + const gchar * filename );
16.88 +void gmyth_file_transfer_close ( GMythFileTransfer * transfer );
16.89 +gboolean gmyth_file_transfer_is_open ( GMythFileTransfer * transfer );
16.90
16.91 GMythFileReadResult
16.92 -gmyth_file_transfer_read (GMythFileTransfer * transfer,
16.93 - GByteArray * data, gint size, gboolean read_unlimited);
16.94 -gint64 gmyth_file_transfer_seek (GMythFileTransfer * transfer, guint64 pos,
16.95 - gint whence);
16.96 -gboolean gmyth_file_transfer_settimeout (GMythFileTransfer * transfer,
16.97 - gboolean fast);
16.98 -guint64 gmyth_file_transfer_get_filesize (GMythFileTransfer * transfer);
16.99 +gmyth_file_transfer_read ( GMythFileTransfer * transfer,
16.100 + GByteArray * data, gint size,
16.101 + gboolean read_unlimited );
16.102 +gint64 gmyth_file_transfer_seek ( GMythFileTransfer * transfer, guint64 pos,
16.103 + gint whence );
16.104 +gboolean gmyth_file_transfer_settimeout ( GMythFileTransfer * transfer,
16.105 + gboolean fast );
16.106 +guint64 gmyth_file_transfer_get_filesize ( GMythFileTransfer * transfer );
16.107
16.108 -void gmyth_file_transfer_emit_program_info_changed_signal (GMythFileTransfer *
16.109 - transfer, gint msg_code, gpointer live_tv_recorder);
16.110 +void gmyth_file_transfer_emit_program_info_changed_signal ( GMythFileTransfer *
16.111 + transfer,
16.112 + gint msg_code,
16.113 + gpointer
16.114 + live_tv_recorder );
16.115
16.116 G_END_DECLS
16.117 #endif /* __GMYTH_FILE_TRANSFER_H__ */
17.1 --- a/gmyth/src/gmyth_http.c Wed May 23 19:21:26 2007 +0100
17.2 +++ b/gmyth/src/gmyth_http.c Wed May 23 19:50:41 2007 +0100
17.3 @@ -40,33 +40,35 @@
17.4 #include "gmyth_socket.h"
17.5
17.6 xmlXPathObjectPtr
17.7 -getnodeset (xmlDocPtr doc, xmlChar * xpath)
17.8 +getnodeset ( xmlDocPtr doc, xmlChar * xpath )
17.9 {
17.10
17.11 xmlXPathContextPtr context;
17.12 xmlXPathObjectPtr result;
17.13
17.14 - context = xmlXPathNewContext (doc);
17.15 - result = xmlXPathEvalExpression (xpath, context);
17.16 + context = xmlXPathNewContext ( doc );
17.17 + result = xmlXPathEvalExpression ( xpath, context );
17.18
17.19 - if (xmlXPathNodeSetIsEmpty (result->nodesetval)) {
17.20 - g_fprintf (stderr, "Error: No result at XPath\n");
17.21 + if ( xmlXPathNodeSetIsEmpty ( result->nodesetval ) )
17.22 + {
17.23 + g_fprintf ( stderr, "Error: No result at XPath\n" );
17.24 return NULL;
17.25 }
17.26
17.27 - xmlXPathFreeContext (context);
17.28 + xmlXPathFreeContext ( context );
17.29 return result;
17.30 }
17.31
17.32
17.33 xmlDocPtr
17.34 -XMLParse (const char *content, int length)
17.35 +XMLParse ( const char *content, int length )
17.36 {
17.37 xmlDocPtr doc; /* the resulting document tree */
17.38
17.39 - doc = xmlReadMemory (content, length, NULL, NULL, 0);
17.40 - if (doc == NULL) {
17.41 - g_fprintf (stderr, "Error: Failed to parse XML document\n");
17.42 + doc = xmlReadMemory ( content, length, NULL, NULL, 0 );
17.43 + if ( doc == NULL )
17.44 + {
17.45 + g_fprintf ( stderr, "Error: Failed to parse XML document\n" );
17.46 return NULL;
17.47 }
17.48
17.49 @@ -74,11 +76,11 @@
17.50 }
17.51
17.52 xmlXPathObjectPtr
17.53 -getXPath (xmlChar * xpath, xmlDocPtr doc)
17.54 +getXPath ( xmlChar * xpath, xmlDocPtr doc )
17.55 {
17.56 xmlXPathObjectPtr result;
17.57
17.58 - result = getnodeset (doc, xpath);
17.59 + result = getnodeset ( doc, xpath );
17.60 return result;
17.61 }
17.62
17.63 @@ -89,40 +91,43 @@
17.64 * @return A GSList containing a list of all the programs
17.65 */
17.66 GSList *
17.67 -get_Program_List (xmlNodePtr node)
17.68 +get_Program_List ( xmlNodePtr node )
17.69 {
17.70 GSList *program_list = NULL;
17.71
17.72 - while (node != NULL) {
17.73 - if (g_ascii_strcasecmp ((char *) node->name, "text") != 0) {
17.74 - GMythProgram *program = (GMythProgram *)
17.75 - g_malloc (sizeof (struct _GMythProgram));
17.76 + while ( node != NULL )
17.77 + {
17.78 + if ( g_ascii_strcasecmp ( ( char * ) node->name, "text" ) != 0 )
17.79 + {
17.80 + GMythProgram *program = ( GMythProgram * )
17.81 + g_malloc ( sizeof ( struct _GMythProgram ) );
17.82
17.83 - program->title = g_strdup ((char *)
17.84 - xmlGetProp (node, (xmlChar *) "title"));
17.85 + program->title = g_strdup ( ( char * )
17.86 + xmlGetProp ( node,
17.87 + ( xmlChar * ) "title" ) );
17.88
17.89 - program->subtitle = g_strdup ((char *)
17.90 - xmlGetProp (node, (xmlChar *)
17.91 - "subtitle"));
17.92 + program->subtitle = g_strdup ( ( char * )
17.93 + xmlGetProp ( node, ( xmlChar * )
17.94 + "subtitle" ) );
17.95
17.96 - program->catType = g_strdup ((char *)
17.97 - xmlGetProp (node, (xmlChar *)
17.98 - "catType"));
17.99 + program->catType = g_strdup ( ( char * )
17.100 + xmlGetProp ( node, ( xmlChar * )
17.101 + "catType" ) );
17.102
17.103 - program->category = g_strdup ((char *)
17.104 - xmlGetProp (node, (xmlChar *)
17.105 - "category"));
17.106 + program->category = g_strdup ( ( char * )
17.107 + xmlGetProp ( node, ( xmlChar * )
17.108 + "category" ) );
17.109
17.110 - sscanf ((char *) xmlGetProp (node, (xmlChar *) "repeat"),
17.111 - "%d", &(program->repeat));
17.112 + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "repeat" ),
17.113 + "%d", &( program->repeat ) );
17.114
17.115 program->startTime = gmyth_util_string_to_time_val
17.116 - ((char *) xmlGetProp (node, (xmlChar *) "startTime"));
17.117 + ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "startTime" ) );
17.118
17.119 program->endTime = gmyth_util_string_to_time_val
17.120 - ((char *) xmlGetProp (node, (xmlChar *) "endTime"));
17.121 + ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "endTime" ) );
17.122
17.123 - program_list = g_slist_append (program_list, program);
17.124 + program_list = g_slist_append ( program_list, program );
17.125 }
17.126
17.127 node = node->next;
17.128 @@ -138,33 +143,35 @@
17.129 * @return The epg from "param" updated
17.130 */
17.131 void
17.132 -get_Channel_List (xmlNodePtr node, GMythEpg * epg)
17.133 +get_Channel_List ( xmlNodePtr node, GMythEpg * epg )
17.134 {
17.135 epg->channelList = NULL;
17.136
17.137 - while (node != NULL) {
17.138 + while ( node != NULL )
17.139 + {
17.140
17.141 - if (g_ascii_strcasecmp ((char *) node->name, "text") != 0) {
17.142 - GMythChannel *channel = (GMythChannel *) g_malloc
17.143 - (sizeof (struct _GMythChannel));
17.144 + if ( g_ascii_strcasecmp ( ( char * ) node->name, "text" ) != 0 )
17.145 + {
17.146 + GMythChannel *channel = ( GMythChannel * ) g_malloc
17.147 + ( sizeof ( struct _GMythChannel ) );
17.148
17.149 - channel->channelName = g_strdup ((char *)
17.150 - xmlGetProp (node, (xmlChar *)
17.151 - "channelName"));
17.152 + channel->channelName = g_strdup ( ( char * )
17.153 + xmlGetProp ( node, ( xmlChar * )
17.154 + "channelName" ) );
17.155
17.156 - channel->chanNum = g_strdup ((char *)
17.157 - xmlGetProp (node, (xmlChar *)
17.158 - "chanNum"));
17.159 + channel->chanNum = g_strdup ( ( char * )
17.160 + xmlGetProp ( node, ( xmlChar * )
17.161 + "chanNum" ) );
17.162
17.163 - sscanf ((char *) xmlGetProp (node, (xmlChar *) "chanId"),
17.164 - "%d", &(channel->chanId));
17.165 + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "chanId" ),
17.166 + "%d", &( channel->chanId ) );
17.167
17.168 - sscanf ((char *) xmlGetProp (node, (xmlChar *) "callSign"),
17.169 - "%d", &(channel->callSign));
17.170 + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "callSign" ),
17.171 + "%d", &( channel->callSign ) );
17.172
17.173 - channel->programList = get_Program_List (node->children);
17.174 + channel->programList = get_Program_List ( node->children );
17.175
17.176 - epg->channelList = g_slist_append (epg->channelList, channel);
17.177 + epg->channelList = g_slist_append ( epg->channelList, channel );
17.178
17.179 }
17.180
17.181 @@ -179,44 +186,44 @@
17.182 * @return The epg from "param" updated
17.183 */
17.184 void
17.185 -get_ProgramGuide_Properties (xmlNodePtr nodeTab, GMythEpg * epg)
17.186 +get_ProgramGuide_Properties ( xmlNodePtr nodeTab, GMythEpg * epg )
17.187 {
17.188
17.189 xmlNode *ptr = nodeTab->children->next->children;
17.190
17.191 - epg->startTime = gmyth_util_string_to_time_val ((char *) ptr->content);
17.192 + epg->startTime = gmyth_util_string_to_time_val ( ( char * ) ptr->content );
17.193
17.194 ptr = ptr->parent->next->next->children;
17.195 - epg->endTime = gmyth_util_string_to_time_val ((char *) ptr->content);
17.196 + epg->endTime = gmyth_util_string_to_time_val ( ( char * ) ptr->content );
17.197
17.198 ptr = ptr->parent->next->next->children;
17.199 - sscanf ((char *) ptr->content, "%d", &(epg->startChanId));
17.200 + sscanf ( ( char * ) ptr->content, "%d", &( epg->startChanId ) );
17.201
17.202 ptr = ptr->parent->next->next->children;
17.203 - sscanf ((char *) ptr->content, "%d", &(epg->endChanId));
17.204 + sscanf ( ( char * ) ptr->content, "%d", &( epg->endChanId ) );
17.205
17.206 ptr = ptr->parent->next->next->children;
17.207 - sscanf ((char *) ptr->content, "%d", &(epg->numOfChannels));
17.208 + sscanf ( ( char * ) ptr->content, "%d", &( epg->numOfChannels ) );
17.209
17.210 ptr = ptr->parent->next->next->children;
17.211 - sscanf ((char *) ptr->content, "%d", &(epg->details));
17.212 + sscanf ( ( char * ) ptr->content, "%d", &( epg->details ) );
17.213
17.214 ptr = ptr->parent->next->next->children;
17.215 - sscanf ((char *) ptr->content, "%d", &(epg->totalCount));
17.216 + sscanf ( ( char * ) ptr->content, "%d", &( epg->totalCount ) );
17.217
17.218 ptr = ptr->parent->next->next->children;
17.219 - epg->asOf = gmyth_util_string_to_time_val ((char *) ptr->content);
17.220 + epg->asOf = gmyth_util_string_to_time_val ( ( char * ) ptr->content );
17.221
17.222 ptr = ptr->parent->next->next->children;
17.223 - epg->version = g_strdup ((char *) ptr->content);
17.224 + epg->version = g_strdup ( ( char * ) ptr->content );
17.225
17.226 ptr = ptr->parent->next->next->children;
17.227 - sscanf ((char *) ptr->content, "%d", &(epg->protoVer));
17.228 + sscanf ( ( char * ) ptr->content, "%d", &( epg->protoVer ) );
17.229
17.230 ptr = ptr->parent->next->next->children;
17.231 // go to Channel section and retrieve Channels and Programs
17.232 - if (epg->numOfChannels > 0)
17.233 - get_Channel_List (ptr, epg);
17.234 + if ( epg->numOfChannels > 0 )
17.235 + get_Channel_List ( ptr, epg );
17.236 else
17.237 epg->channelList = NULL;
17.238 }
17.239 @@ -227,7 +234,7 @@
17.240 * @return The epg
17.241 */
17.242 void
17.243 -getEpg (xmlDocPtr doc, GMythEpg * epg)
17.244 +getEpg ( xmlDocPtr doc, GMythEpg * epg )
17.245 {
17.246 xmlXPathObjectPtr result;
17.247 xmlNodeSetPtr nodeset;
17.248 @@ -235,19 +242,22 @@
17.249
17.250 int i;
17.251
17.252 - result = getXPath ((xmlChar *) "/*", doc);
17.253 + result = getXPath ( ( xmlChar * ) "/*", doc );
17.254
17.255 - if (result) {
17.256 + if ( result )
17.257 + {
17.258 nodeset = result->nodesetval;
17.259 - for (i = 0; i < nodeset->nodeNr; i++) {
17.260 - keyword = (xmlChar *) nodeset->nodeTab[i]->name;
17.261 - if (g_ascii_strcasecmp
17.262 - ((char *) keyword, "GetProgramGuideResponse") == 0) {
17.263 - get_ProgramGuide_Properties (nodeset->nodeTab[i], epg);
17.264 + for ( i = 0; i < nodeset->nodeNr; i++ )
17.265 + {
17.266 + keyword = ( xmlChar * ) nodeset->nodeTab[i]->name;
17.267 + if ( g_ascii_strcasecmp
17.268 + ( ( char * ) keyword, "GetProgramGuideResponse" ) == 0 )
17.269 + {
17.270 + get_ProgramGuide_Properties ( nodeset->nodeTab[i], epg );
17.271 break;
17.272 }
17.273 }
17.274 - xmlXPathFreeObject (result);
17.275 + xmlXPathFreeObject ( result );
17.276 }
17.277
17.278 }
17.279 @@ -260,9 +270,10 @@
17.280 * @return The epg
17.281 */
17.282 GMythEpg
17.283 -gmyth_http_retrieve_epg (GMythBackendInfo * backend_info,
17.284 - GTimeVal * StartTime, GTimeVal * EndTime,
17.285 - gint StartChanId, gint NumOfChannels, gchar * Details)
17.286 +gmyth_http_retrieve_epg ( GMythBackendInfo * backend_info,
17.287 + GTimeVal * StartTime, GTimeVal * EndTime,
17.288 + gint StartChanId, gint NumOfChannels,
17.289 + gchar * Details )
17.290 {
17.291 GMythEpg epg;
17.292 MemoryStruct chunk;
17.293 @@ -272,28 +283,31 @@
17.294
17.295 gchar *starttime;
17.296
17.297 - starttime = (gchar *) xmlURIEscapeStr ((const xmlChar *)
17.298 - gmyth_util_time_to_mythformat_from_time_val (StartTime), NULL);
17.299 + starttime = ( gchar * ) xmlURIEscapeStr ( ( const xmlChar * )
17.300 + gmyth_util_time_to_mythformat_from_time_val
17.301 + ( StartTime ), NULL );
17.302
17.303 gchar *endtime;
17.304
17.305 - endtime = (gchar *) xmlURIEscapeStr ((const xmlChar *)
17.306 - gmyth_util_time_to_mythformat_from_time_val (EndTime), NULL);
17.307 + endtime = ( gchar * ) xmlURIEscapeStr ( ( const xmlChar * )
17.308 + gmyth_util_time_to_mythformat_from_time_val
17.309 + ( EndTime ), NULL );
17.310
17.311 - GString *command = g_string_new ("");
17.312 + GString *command = g_string_new ( "" );
17.313
17.314 - g_string_printf (command,
17.315 - "GetProgramGuide?StartTime=%s&EndTime=%s&StartChanId=%d"
17.316 - "&NumOfChannels=%d&Details=%s", starttime, endtime,
17.317 - StartChanId, NumOfChannels, Details);
17.318 - gmyth_debug ("HTTP Request command = %s\n", command->str);
17.319 + g_string_printf ( command,
17.320 + "GetProgramGuide?StartTime=%s&EndTime=%s&StartChanId=%d"
17.321 + "&NumOfChannels=%d&Details=%s", starttime, endtime,
17.322 + StartChanId, NumOfChannels, Details );
17.323 + gmyth_debug ( "HTTP Request command = %s\n", command->str );
17.324
17.325 - chunk = gmyth_http_request (backend_info, command);
17.326 - if (chunk.memory != NULL) {
17.327 - xmlDocPtr doc = XMLParse (chunk.memory, strlen (chunk.memory));
17.328 + chunk = gmyth_http_request ( backend_info, command );
17.329 + if ( chunk.memory != NULL )
17.330 + {
17.331 + xmlDocPtr doc = XMLParse ( chunk.memory, strlen ( chunk.memory ) );
17.332
17.333 - getEpg (doc, &epg);
17.334 - free (chunk.memory);
17.335 + getEpg ( doc, &epg );
17.336 + free ( chunk.memory );
17.337 }
17.338
17.339 return epg;
17.340 @@ -301,50 +315,51 @@
17.341
17.342
17.343 GMythRecorded_Recording
17.344 -retrieve_recorded_recording (xmlNodePtr node)
17.345 +retrieve_recorded_recording ( xmlNodePtr node )
17.346 {
17.347 GMythRecorded_Recording recording;
17.348
17.349 - if (g_ascii_strcasecmp ((char *) node->name, "text") != 0) {
17.350 + if ( g_ascii_strcasecmp ( ( char * ) node->name, "text" ) != 0 )
17.351 + {
17.352
17.353 - sscanf ((char *) xmlGetProp (node, (xmlChar *) "dupInType"),
17.354 - "%d", &(recording.dupInType));
17.355 + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "dupInType" ),
17.356 + "%d", &( recording.dupInType ) );
17.357
17.358 - sscanf ((char *) xmlGetProp (node, (xmlChar *) "dupMethod"),
17.359 - "%d", &(recording.dupMethod));
17.360 + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "dupMethod" ),
17.361 + "%d", &( recording.dupMethod ) );
17.362
17.363 - sscanf ((char *) xmlGetProp (node, (xmlChar *) "recStatus"),
17.364 - "%d", &(recording.recStatus));
17.365 + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "recStatus" ),
17.366 + "%d", &( recording.recStatus ) );
17.367
17.368 - sscanf ((char *) xmlGetProp (node, (xmlChar *) "encoderId"),
17.369 - "%d", &(recording.encoderId));
17.370 + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "encoderId" ),
17.371 + "%d", &( recording.encoderId ) );
17.372
17.373 - sscanf ((char *) xmlGetProp (node, (xmlChar *) "recordId"),
17.374 - "%d", &(recording.recordId));
17.375 + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "recordId" ),
17.376 + "%d", &( recording.recordId ) );
17.377
17.378 - sscanf ((char *) xmlGetProp (node, (xmlChar *) "recType"),
17.379 - "%d", &(recording.recType));
17.380 + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "recType" ),
17.381 + "%d", &( recording.recType ) );
17.382
17.383 - recording.playGroup = g_strdup ((char *)
17.384 - xmlGetProp (node, (xmlChar *)
17.385 - "playGroup"));
17.386 + recording.playGroup = g_strdup ( ( char * )
17.387 + xmlGetProp ( node, ( xmlChar * )
17.388 + "playGroup" ) );
17.389
17.390 - recording.recGroup = g_strdup ((char *)
17.391 - xmlGetProp (node, (xmlChar *)
17.392 - "recGroup"));
17.393 + recording.recGroup = g_strdup ( ( char * )
17.394 + xmlGetProp ( node, ( xmlChar * )
17.395 + "recGroup" ) );
17.396
17.397 - recording.recProfile = g_strdup ((char *)
17.398 - xmlGetProp (node, (xmlChar *)
17.399 - "recProfile"));
17.400 + recording.recProfile = g_strdup ( ( char * )
17.401 + xmlGetProp ( node, ( xmlChar * )
17.402 + "recProfile" ) );
17.403
17.404 - sscanf ((char *) xmlGetProp (node, (xmlChar *) "recPriority"),
17.405 - "%d", &(recording.recPriority));
17.406 + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "recPriority" ),
17.407 + "%d", &( recording.recPriority ) );
17.408
17.409 recording.recStartTs = gmyth_util_string_to_time_val
17.410 - ((char *) xmlGetProp (node, (xmlChar *) "recStartTs"));
17.411 + ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "recStartTs" ) );
17.412
17.413 recording.recEndTs = gmyth_util_string_to_time_val
17.414 - ((char *) xmlGetProp (node, (xmlChar *) "recEndTs"));
17.415 + ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "recEndTs" ) );
17.416 }
17.417
17.418 return recording;
17.419 @@ -352,37 +367,38 @@
17.420
17.421
17.422 GMythRecorded_Channel
17.423 -retrieve_recorded_channel (xmlNodePtr node)
17.424 +retrieve_recorded_channel ( xmlNodePtr node )
17.425 {
17.426 GMythRecorded_Channel channel;
17.427
17.428 - if (g_ascii_strcasecmp ((char *) node->name, "text") != 0) {
17.429 + if ( g_ascii_strcasecmp ( ( char * ) node->name, "text" ) != 0 )
17.430 + {
17.431
17.432 - channel.chanFilters = g_strdup ((char *)
17.433 - xmlGetProp (node, (xmlChar *)
17.434 - "chanFilters"));
17.435 + channel.chanFilters = g_strdup ( ( char * )
17.436 + xmlGetProp ( node, ( xmlChar * )
17.437 + "chanFilters" ) );
17.438
17.439 - channel.channelName = g_strdup ((char *)
17.440 - xmlGetProp (node, (xmlChar *)
17.441 - "channelName"));
17.442 + channel.channelName = g_strdup ( ( char * )
17.443 + xmlGetProp ( node, ( xmlChar * )
17.444 + "channelName" ) );
17.445
17.446 - sscanf ((char *) xmlGetProp (node, (xmlChar *) "chanNum"),
17.447 - "%d", &(channel.chanNum));
17.448 + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "chanNum" ),
17.449 + "%d", &( channel.chanNum ) );
17.450
17.451 - sscanf ((char *) xmlGetProp (node, (xmlChar *) "sourceId"),
17.452 - "%d", &(channel.sourceId));
17.453 + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "sourceId" ),
17.454 + "%d", &( channel.sourceId ) );
17.455
17.456 - sscanf ((char *) xmlGetProp (node, (xmlChar *) "commFree"),
17.457 - "%d", &(channel.commFree));
17.458 + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "commFree" ),
17.459 + "%d", &( channel.commFree ) );
17.460
17.461 - sscanf ((char *) xmlGetProp (node, (xmlChar *) "inputId"),
17.462 - "%d", &(channel.inputId));
17.463 + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "inputId" ),
17.464 + "%d", &( channel.inputId ) );
17.465
17.466 - sscanf ((char *) xmlGetProp (node, (xmlChar *) "chanId"),
17.467 - "%d", &(channel.chanId));
17.468 + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "chanId" ),
17.469 + "%d", &( channel.chanId ) );
17.470
17.471 - sscanf ((char *) xmlGetProp (node, (xmlChar *) "callSign"),
17.472 - "%d", &(channel.callSign));
17.473 + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "callSign" ),
17.474 + "%d", &( channel.callSign ) );
17.475 }
17.476
17.477 return channel;
17.478 @@ -397,77 +413,84 @@
17.479 * @return list with all the recorded programs
17.480 */
17.481 GSList *
17.482 -get_Recorded_Programs (xmlNodePtr node)
17.483 +get_Recorded_Programs ( xmlNodePtr node )
17.484 {
17.485 GSList *programList = NULL;
17.486
17.487 - while (node != NULL) {
17.488 + while ( node != NULL )
17.489 + {
17.490
17.491 - if (g_ascii_strcasecmp ((char *) node->name, "text") != 0) {
17.492 + if ( g_ascii_strcasecmp ( ( char * ) node->name, "text" ) != 0 )
17.493 + {
17.494
17.495 - GMythRecorded_Program *program = (GMythRecorded_Program *)
17.496 - g_malloc (sizeof (struct _GMythRecorded_Program));
17.497 + GMythRecorded_Program *program = ( GMythRecorded_Program * )
17.498 + g_malloc ( sizeof ( struct _GMythRecorded_Program ) );
17.499
17.500 - sscanf ((char *)
17.501 - xmlGetProp (node, (xmlChar *) "programFlags"), "%d",
17.502 - &(program->programFlags));
17.503 + sscanf ( ( char * )
17.504 + xmlGetProp ( node, ( xmlChar * ) "programFlags" ), "%d",
17.505 + &( program->programFlags ) );
17.506
17.507 - program->title = g_strdup ((char *)
17.508 - xmlGetProp (node, (xmlChar *) "title"));
17.509 + program->title = g_strdup ( ( char * )
17.510 + xmlGetProp ( node,
17.511 + ( xmlChar * ) "title" ) );
17.512
17.513 - sscanf ((char *) xmlGetProp (node, (xmlChar *) "programId"),
17.514 - "%d", &(program->programId));
17.515 + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "programId" ),
17.516 + "%d", &( program->programId ) );
17.517
17.518 - program->catType = g_strdup ((char *)
17.519 - xmlGetProp (node, (xmlChar *)
17.520 - "catType"));
17.521 + program->catType = g_strdup ( ( char * )
17.522 + xmlGetProp ( node, ( xmlChar * )
17.523 + "catType" ) );
17.524
17.525 - program->category = g_strdup ((char *)
17.526 - xmlGetProp (node, (xmlChar *)
17.527 - "category"));
17.528 + program->category = g_strdup ( ( char * )
17.529 + xmlGetProp ( node, ( xmlChar * )
17.530 + "category" ) );
17.531
17.532 - sscanf ((char *) xmlGetProp (node, (xmlChar *) "seriesId"),
17.533 - "%d", &(program->seriesId));
17.534 + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "seriesId" ),
17.535 + "%d", &( program->seriesId ) );
17.536
17.537
17.538 program->startTime = gmyth_util_string_to_time_val
17.539 - ((char *) xmlGetProp (node, (xmlChar *) "startTime"));
17.540 + ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "startTime" ) );
17.541
17.542 program->endTime = gmyth_util_string_to_time_val
17.543 - ((char *) xmlGetProp (node, (xmlChar *) "endTime"));
17.544 + ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "endTime" ) );
17.545
17.546 - program->lastModified = gmyth_util_string_to_time_val ((char *)
17.547 - xmlGetProp (node, (xmlChar *) "lastModified"));
17.548 + program->lastModified = gmyth_util_string_to_time_val ( ( char * )
17.549 + xmlGetProp
17.550 + ( node,
17.551 + ( xmlChar
17.552 + * )
17.553 + "lastModified" ) );
17.554
17.555 /* TODO: FIX ME at gmyth_util
17.556 program->asOf = gmyth_util_string_to_time_val\
17.557 ((char *)xmlGetProp(node, (xmlChar *)"airdate")); */
17.558
17.559 - program->subTitle = g_strdup ((char *)
17.560 - xmlGetProp (node, (xmlChar *)
17.561 - "subTitle"));
17.562 + program->subTitle = g_strdup ( ( char * )
17.563 + xmlGetProp ( node, ( xmlChar * )
17.564 + "subTitle" ) );
17.565
17.566 - sscanf ((char *) xmlGetProp (node, (xmlChar *) "stars"),
17.567 - "%d", &(program->stars));
17.568 + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "stars" ),
17.569 + "%d", &( program->stars ) );
17.570
17.571 - sscanf ((char *) xmlGetProp (node, (xmlChar *) "repeat"),
17.572 - "%d", &(program->repeat));
17.573 + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "repeat" ),
17.574 + "%d", &( program->repeat ) );
17.575
17.576 - sscanf ((char *) xmlGetProp (node, (xmlChar *) "fileSize"),
17.577 - "%d", &(program->repeat));
17.578 + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "fileSize" ),
17.579 + "%d", &( program->repeat ) );
17.580
17.581 - program->hostname = g_strdup ((char *)
17.582 - xmlGetProp (node, (xmlChar *)
17.583 - "hostname"));
17.584 + program->hostname = g_strdup ( ( char * )
17.585 + xmlGetProp ( node, ( xmlChar * )
17.586 + "hostname" ) );
17.587
17.588 - program->channel = retrieve_recorded_channel (node->children);
17.589 + program->channel = retrieve_recorded_channel ( node->children );
17.590
17.591 // Skip the \n
17.592 program->recording =
17.593 - retrieve_recorded_recording (node->children->next->next);
17.594 + retrieve_recorded_recording ( node->children->next->next );
17.595
17.596 // add to the list
17.597 - programList = g_slist_append (programList, program);
17.598 + programList = g_slist_append ( programList, program );
17.599 }
17.600
17.601 node = node->next;
17.602 @@ -483,25 +506,25 @@
17.603 * @return "recorded" from "param" updated
17.604 */
17.605 void
17.606 -get_Recorded_Properties (xmlNodePtr nodeTab, GMythRecorded * recorded)
17.607 +get_Recorded_Properties ( xmlNodePtr nodeTab, GMythRecorded * recorded )
17.608 {
17.609 xmlNode *ptr = nodeTab->children->next->children;
17.610
17.611 - sscanf ((char *) ptr->content, "%d", &(recorded->totalCount));
17.612 + sscanf ( ( char * ) ptr->content, "%d", &( recorded->totalCount ) );
17.613
17.614
17.615 ptr = ptr->parent->next->next->children;
17.616 - recorded->asOf = gmyth_util_string_to_time_val ((char *) ptr->content);
17.617 + recorded->asOf = gmyth_util_string_to_time_val ( ( char * ) ptr->content );
17.618
17.619 ptr = ptr->parent->next->next->children;
17.620 - recorded->version = g_strdup ((char *) ptr->content);
17.621 + recorded->version = g_strdup ( ( char * ) ptr->content );
17.622
17.623 ptr = ptr->parent->next->next->children;
17.624 - sscanf ((char *) ptr->content, "%d", &(recorded->protoVer));
17.625 + sscanf ( ( char * ) ptr->content, "%d", &( recorded->protoVer ) );
17.626
17.627 ptr = ptr->parent->next->next->children;
17.628 - if (recorded->totalCount > 0)
17.629 - recorded->programList = get_Recorded_Programs (ptr->children);
17.630 + if ( recorded->totalCount > 0 )
17.631 + recorded->programList = get_Recorded_Programs ( ptr->children );
17.632
17.633 }
17.634
17.635 @@ -512,7 +535,7 @@
17.636 * @return The recorded var updated
17.637 */
17.638 void
17.639 -getRecorded (xmlDocPtr doc, GMythRecorded * recorded)
17.640 +getRecorded ( xmlDocPtr doc, GMythRecorded * recorded )
17.641 {
17.642 xmlXPathObjectPtr result;
17.643 xmlNodeSetPtr nodeset;
17.644 @@ -520,19 +543,22 @@
17.645
17.646 int i;
17.647
17.648 - result = getXPath ((xmlChar *) "/*", doc);
17.649 + result = getXPath ( ( xmlChar * ) "/*", doc );
17.650
17.651 - if (result) {
17.652 + if ( result )
17.653 + {
17.654 nodeset = result->nodesetval;
17.655 - for (i = 0; i < nodeset->nodeNr; i++) {
17.656 - keyword = (xmlChar *) nodeset->nodeTab[i]->name;
17.657 - if (g_ascii_strcasecmp
17.658 - ((char *) keyword, "GetRecordedResponse") == 0) {
17.659 - get_Recorded_Properties (nodeset->nodeTab[i], recorded);
17.660 + for ( i = 0; i < nodeset->nodeNr; i++ )
17.661 + {
17.662 + keyword = ( xmlChar * ) nodeset->nodeTab[i]->name;
17.663 + if ( g_ascii_strcasecmp
17.664 + ( ( char * ) keyword, "GetRecordedResponse" ) == 0 )
17.665 + {
17.666 + get_Recorded_Properties ( nodeset->nodeTab[i], recorded );
17.667 break;
17.668 }
17.669 }
17.670 - xmlXPathFreeObject (result);
17.671 + xmlXPathFreeObject ( result );
17.672 }
17.673
17.674 }
17.675 @@ -542,7 +568,7 @@
17.676 *
17.677 */
17.678 GMythRecorded
17.679 -gmyth_http_retrieve_recorded (GMythBackendInfo * backend_info)
17.680 +gmyth_http_retrieve_recorded ( GMythBackendInfo * backend_info )
17.681 {
17.682 GMythRecorded recorded;
17.683 MemoryStruct chunk;
17.684 @@ -550,16 +576,17 @@
17.685 chunk.memory = NULL;
17.686 chunk.size = 0;
17.687
17.688 - GString *command = g_string_new ("");
17.689 + GString *command = g_string_new ( "" );
17.690
17.691 - g_string_printf (command, "GetRecorded");
17.692 + g_string_printf ( command, "GetRecorded" );
17.693
17.694 - chunk = gmyth_http_request (backend_info, command);
17.695 - if (chunk.memory != NULL) {
17.696 - xmlDocPtr doc = XMLParse (chunk.memory, strlen (chunk.memory));
17.697 + chunk = gmyth_http_request ( backend_info, command );
17.698 + if ( chunk.memory != NULL )
17.699 + {
17.700 + xmlDocPtr doc = XMLParse ( chunk.memory, strlen ( chunk.memory ) );
17.701
17.702 - getRecorded (doc, &recorded);
17.703 - free (chunk.memory);
17.704 + getRecorded ( doc, &recorded );
17.705 + free ( chunk.memory );
17.706 }
17.707
17.708 return recorded;
17.709 @@ -571,8 +598,8 @@
17.710 *
17.711 */
17.712 gint
17.713 -gmyth_http_retrieve_job_status (GMythBackendInfo * backend_info,
17.714 - gint chanid, GTimeVal * start)
17.715 +gmyth_http_retrieve_job_status ( GMythBackendInfo * backend_info,
17.716 + gint chanid, GTimeVal * start )
17.717 {
17.718 gint status = 0;
17.719 gint count = 0;
17.720 @@ -588,43 +615,52 @@
17.721 chunk.memory = NULL;
17.722 chunk.size = 0;
17.723
17.724 - GString *command = g_string_new ("");
17.725 + GString *command = g_string_new ( "" );
17.726
17.727 - g_string_printf (command, "GetStatus");
17.728 + g_string_printf ( command, "GetStatus" );
17.729
17.730 - chunk = gmyth_http_request (backend_info, command);
17.731 + chunk = gmyth_http_request ( backend_info, command );
17.732
17.733 - if (chunk.memory != NULL) {
17.734 - xmlDocPtr doc = XMLParse (chunk.memory, strlen (chunk.memory));
17.735 + if ( chunk.memory != NULL )
17.736 + {
17.737 + xmlDocPtr doc = XMLParse ( chunk.memory, strlen ( chunk.memory ) );
17.738
17.739 - result = getXPath ((xmlChar *) "/Status/JobQueue", doc);
17.740 - if (result) {
17.741 + result = getXPath ( ( xmlChar * ) "/Status/JobQueue", doc );
17.742 + if ( result )
17.743 + {
17.744 nodeset = result->nodesetval;
17.745 node = nodeset->nodeTab[0];
17.746 - sscanf ((char *) xmlGetProp (node, (xmlChar *) "count"),
17.747 - "%d", &count);
17.748 + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * ) "count" ),
17.749 + "%d", &count );
17.750
17.751 - if (count > 0) {
17.752 + if ( count > 0 )
17.753 + {
17.754
17.755 // Get the first child
17.756 node = node->children->next;
17.757
17.758 - for (i = 0; i < count; i++) {
17.759 + for ( i = 0; i < count; i++ )
17.760 + {
17.761
17.762 - sscanf ((char *)
17.763 - xmlGetProp (node, (xmlChar *) "chanId"), "%d",
17.764 - &temp_chanid);
17.765 + sscanf ( ( char * )
17.766 + xmlGetProp ( node, ( xmlChar * ) "chanId" ), "%d",
17.767 + &temp_chanid );
17.768
17.769 - if (chanid == temp_chanid) {
17.770 - temp_start = gmyth_util_string_to_time_val ((char *)
17.771 - xmlGetProp (node, (xmlChar *)
17.772 - "startTime"));
17.773 + if ( chanid == temp_chanid )
17.774 + {
17.775 + temp_start = gmyth_util_string_to_time_val ( ( char * )
17.776 + xmlGetProp
17.777 + ( node,
17.778 + ( xmlChar
17.779 + * )
17.780 + "startTime" ) );
17.781
17.782 - if ((temp_start->tv_sec == start->tv_sec) &&
17.783 - (temp_start->tv_usec == start->tv_usec))
17.784 - sscanf ((char *)
17.785 - xmlGetProp (node,
17.786 - (xmlChar *) "status"), "%d", &status);
17.787 + if ( ( temp_start->tv_sec == start->tv_sec ) &&
17.788 + ( temp_start->tv_usec == start->tv_usec ) )
17.789 + sscanf ( ( char * )
17.790 + xmlGetProp ( node,
17.791 + ( xmlChar * ) "status" ),
17.792 + "%d", &status );
17.793 }
17.794 // Escape "text" node
17.795 node = node->next->next;
17.796 @@ -633,8 +669,8 @@
17.797
17.798 }
17.799
17.800 - xmlXPathFreeObject (result);
17.801 - free (chunk.memory);
17.802 + xmlXPathFreeObject ( result );
17.803 + free ( chunk.memory );
17.804
17.805 }
17.806
17.807 @@ -651,8 +687,8 @@
17.808 * @return the value of the key
17.809 */
17.810 gchar *
17.811 -gmyth_http_retrieve_setting (GMythBackendInfo * backend_info,
17.812 - gchar * key, gchar * hostname)
17.813 +gmyth_http_retrieve_setting ( GMythBackendInfo * backend_info,
17.814 + gchar * key, gchar * hostname )
17.815 {
17.816 xmlXPathObjectPtr result;
17.817 xmlNodeSetPtr nodeset;
17.818 @@ -663,29 +699,32 @@
17.819 chunk.memory = NULL;
17.820 chunk.size = 0;
17.821
17.822 - GString *command = g_string_new ("");
17.823 + GString *command = g_string_new ( "" );
17.824
17.825 - g_string_printf (command, "GetSetting?Key=%s&HostName=%s&Default=NULL",
17.826 - key, hostname);
17.827 + g_string_printf ( command, "GetSetting?Key=%s&HostName=%s&Default=NULL",
17.828 + key, hostname );
17.829
17.830 - chunk = gmyth_http_request (backend_info, command);
17.831 + chunk = gmyth_http_request ( backend_info, command );
17.832
17.833 - if (chunk.memory != NULL) {
17.834 - xmlDocPtr doc = XMLParse (chunk.memory, strlen (chunk.memory));
17.835 + if ( chunk.memory != NULL )
17.836 + {
17.837 + xmlDocPtr doc = XMLParse ( chunk.memory, strlen ( chunk.memory ) );
17.838
17.839 - result = getXPath ((xmlChar *) "/GetSettingResponse/Values/*", doc);
17.840 + result = getXPath ( ( xmlChar * ) "/GetSettingResponse/Values/*", doc );
17.841
17.842 - if (result) {
17.843 + if ( result )
17.844 + {
17.845 nodeset = result->nodesetval;
17.846 - keyword = (xmlChar *) nodeset->nodeTab[0]->name;
17.847 - if (g_ascii_strcasecmp ((char *) keyword, "Value") == 0) {
17.848 + keyword = ( xmlChar * ) nodeset->nodeTab[0]->name;
17.849 + if ( g_ascii_strcasecmp ( ( char * ) keyword, "Value" ) == 0 )
17.850 + {
17.851 // Here we have the value
17.852 - value = (gchar *) nodeset->nodeTab[0]->children->content;
17.853 + value = ( gchar * ) nodeset->nodeTab[0]->children->content;
17.854 }
17.855 - xmlXPathFreeObject (result);
17.856 + xmlXPathFreeObject ( result );
17.857 }
17.858
17.859 - free (chunk.memory);
17.860 + free ( chunk.memory );
17.861 }
17.862
17.863 return value;
17.864 @@ -698,7 +737,7 @@
17.865 * @return 0 if OK
17.866 */
17.867 gint
17.868 -rec_profile_common (GMythBackendInfo * backend_info, GString * command)
17.869 +rec_profile_common ( GMythBackendInfo * backend_info, GString * command )
17.870 {
17.871 xmlXPathObjectPtr result;
17.872 xmlNodeSetPtr nodeset;
17.873 @@ -710,24 +749,26 @@
17.874
17.875 int ret = -1;
17.876
17.877 - chunk = gmyth_http_request (backend_info, command);
17.878 + chunk = gmyth_http_request ( backend_info, command );
17.879
17.880 - if (chunk.memory != NULL) {
17.881 - xmlDocPtr doc = XMLParse (chunk.memory, strlen (chunk.memory));
17.882 + if ( chunk.memory != NULL )
17.883 + {
17.884 + xmlDocPtr doc = XMLParse ( chunk.memory, strlen ( chunk.memory ) );
17.885
17.886 - result = getXPath ((xmlChar *) "/*", doc);
17.887 + result = getXPath ( ( xmlChar * ) "/*", doc );
17.888
17.889 - if (result) {
17.890 + if ( result )
17.891 + {
17.892 nodeset = result->nodesetval;
17.893 - keyword = (xmlChar *) nodeset->nodeTab[0]->name;
17.894 + keyword = ( xmlChar * ) nodeset->nodeTab[0]->name;
17.895
17.896 - if (g_ascii_strcasecmp ((char *) keyword, "Success") == 0)
17.897 + if ( g_ascii_strcasecmp ( ( char * ) keyword, "Success" ) == 0 )
17.898 ret = 0;
17.899
17.900 - xmlXPathFreeObject (result);
17.901 + xmlXPathFreeObject ( result );
17.902 }
17.903
17.904 - free (chunk.memory);
17.905 + free ( chunk.memory );
17.906 }
17.907
17.908 return ret;
17.909 @@ -741,15 +782,15 @@
17.910 * @return 0 if OK
17.911 */
17.912 gint
17.913 -gmyth_http_del_rec_profile (GMythBackendInfo * backend_info, gint id)
17.914 +gmyth_http_del_rec_profile ( GMythBackendInfo * backend_info, gint id )
17.915 {
17.916
17.917 - GString *command = g_string_new ("");
17.918 + GString *command = g_string_new ( "" );
17.919
17.920 - g_string_printf (command, "delRecProfiles?id=%d", id);
17.921 + g_string_printf ( command, "delRecProfiles?id=%d", id );
17.922
17.923
17.924 - return rec_profile_common (backend_info, command);
17.925 + return rec_profile_common ( backend_info, command );
17.926 }
17.927
17.928 /** Function to create recording profiles
17.929 @@ -762,67 +803,69 @@
17.930 * @return 0 if OK
17.931 */
17.932 gint
17.933 -gmyth_http_create_rec_profile (GMythBackendInfo * backend_info,
17.934 - GMythRecProfile * profile)
17.935 +gmyth_http_create_rec_profile ( GMythBackendInfo * backend_info,
17.936 + GMythRecProfile * profile )
17.937 {
17.938
17.939 - if (profile->name != NULL && profile->group != NULL &&
17.940 - profile->vcodec && profile->acodec && profile->options != NULL) {
17.941 - GString *command = g_string_new ("");
17.942 + if ( profile->name != NULL && profile->group != NULL &&
17.943 + profile->vcodec && profile->acodec && profile->options != NULL )
17.944 + {
17.945 + GString *command = g_string_new ( "" );
17.946
17.947 - g_string_printf (command, "createRecProfiles?profilename=%s&"
17.948 - "groupname=%s&vcodec=%s&acodec=%s&"
17.949 - "transcodelossless=%d&transcoderesize=%d&"
17.950 - "width=%d&height=%d&rtjpegquality=%d&"
17.951 - "rtjpeglumafilter=%d&rtjpegchromafilter=%d&"
17.952 - "mpeg4bitrate=%d&mpeg4maxquality=%d&"
17.953 - "mpeg4minquality=%d&mpeg4qualdiff=%d&"
17.954 - "mpeg4scalebitrate=%d&mpeg4optionvhq=%d&"
17.955 - "mpeg4option4mv=%d&mpeg4optionidct=%d&"
17.956 - "mpeg4optionime=%d&hardwaremjpegquality=%d&"
17.957 - "hardwaremjpeghdecimation=%d&hardwaremjpegvdecimation=%d&"
17.958 - "mpeg2streamtype=%s&mpeg2aspectratio=%s&"
17.959 - "mpeg2bitrate=%d&mpeg2maxbitrate=%d&"
17.960 - "samplerate=%d&mp3quality=%d&"
17.961 - "volume=%d&mpeg2audtype=%s&"
17.962 - "mpeg2audbitratel1=%d&mpeg2audbitratel2=%d&"
17.963 - "mpeg2audvolume=%d",
17.964 - profile->name, profile->group,
17.965 - profile->vcodec, profile->acodec,
17.966 - profile->options->transcodelossless,
17.967 - profile->options->transcoderesize,
17.968 - profile->options->width,
17.969 - profile->options->height,
17.970 - profile->options->rtjpegquality,
17.971 - profile->options->rtjpeglumafilter,
17.972 - profile->options->rtjpegchromafilter,
17.973 - profile->options->mpeg4bitrate,
17.974 - profile->options->mpeg4maxquality,
17.975 - profile->options->mpeg4minquality,
17.976 - profile->options->mpeg4qualdiff,
17.977 - profile->options->mpeg4scalebitrate,
17.978 - profile->options->mpeg4optionvhq,
17.979 - profile->options->mpeg4option4mv,
17.980 - profile->options->mpeg4optionidct,
17.981 - profile->options->mpeg4optionime,
17.982 - profile->options->hardwaremjpegquality,
17.983 - profile->options->hardwaremjpeghdecimation,
17.984 - profile->options->hardwaremjpegvdecimation,
17.985 - profile->options->mpeg2streamtype,
17.986 - profile->options->mpeg2aspectratio,
17.987 - profile->options->mpeg2bitrate,
17.988 - profile->options->mpeg2maxbitrate,
17.989 - profile->options->samplerate,
17.990 - profile->options->mp3quality,
17.991 - profile->options->volume,
17.992 - profile->options->mpeg2audtype,
17.993 - profile->options->mpeg2audbitratel1,
17.994 - profile->options->mpeg2audbitratel2,
17.995 - profile->options->mpeg2audvolume);
17.996 + g_string_printf ( command, "createRecProfiles?profilename=%s&"
17.997 + "groupname=%s&vcodec=%s&acodec=%s&"
17.998 + "transcodelossless=%d&transcoderesize=%d&"
17.999 + "width=%d&height=%d&rtjpegquality=%d&"
17.1000 + "rtjpeglumafilter=%d&rtjpegchromafilter=%d&"
17.1001 + "mpeg4bitrate=%d&mpeg4maxquality=%d&"
17.1002 + "mpeg4minquality=%d&mpeg4qualdiff=%d&"
17.1003 + "mpeg4scalebitrate=%d&mpeg4optionvhq=%d&"
17.1004 + "mpeg4option4mv=%d&mpeg4optionidct=%d&"
17.1005 + "mpeg4optionime=%d&hardwaremjpegquality=%d&"
17.1006 + "hardwaremjpeghdecimation=%d&hardwaremjpegvdecimation=%d&"
17.1007 + "mpeg2streamtype=%s&mpeg2aspectratio=%s&"
17.1008 + "mpeg2bitrate=%d&mpeg2maxbitrate=%d&"
17.1009 + "samplerate=%d&mp3quality=%d&"
17.1010 + "volume=%d&mpeg2audtype=%s&"
17.1011 + "mpeg2audbitratel1=%d&mpeg2audbitratel2=%d&"
17.1012 + "mpeg2audvolume=%d",
17.1013 + profile->name, profile->group,
17.1014 + profile->vcodec, profile->acodec,
17.1015 + profile->options->transcodelossless,
17.1016 + profile->options->transcoderesize,
17.1017 + profile->options->width,
17.1018 + profile->options->height,
17.1019 + profile->options->rtjpegquality,
17.1020 + profile->options->rtjpeglumafilter,
17.1021 + profile->options->rtjpegchromafilter,
17.1022 + profile->options->mpeg4bitrate,
17.1023 + profile->options->mpeg4maxquality,
17.1024 + profile->options->mpeg4minquality,
17.1025 + profile->options->mpeg4qualdiff,
17.1026 + profile->options->mpeg4scalebitrate,
17.1027 + profile->options->mpeg4optionvhq,
17.1028 + profile->options->mpeg4option4mv,
17.1029 + profile->options->mpeg4optionidct,
17.1030 + profile->options->mpeg4optionime,
17.1031 + profile->options->hardwaremjpegquality,
17.1032 + profile->options->hardwaremjpeghdecimation,
17.1033 + profile->options->hardwaremjpegvdecimation,
17.1034 + profile->options->mpeg2streamtype,
17.1035 + profile->options->mpeg2aspectratio,
17.1036 + profile->options->mpeg2bitrate,
17.1037 + profile->options->mpeg2maxbitrate,
17.1038 + profile->options->samplerate,
17.1039 + profile->options->mp3quality,
17.1040 + profile->options->volume,
17.1041 + profile->options->mpeg2audtype,
17.1042 + profile->options->mpeg2audbitratel1,
17.1043 + profile->options->mpeg2audbitratel2,
17.1044 + profile->options->mpeg2audvolume );
17.1045
17.1046
17.1047 - return rec_profile_common (backend_info, command);
17.1048 - } else
17.1049 + return rec_profile_common ( backend_info, command );
17.1050 + }
17.1051 + else
17.1052 return -1;
17.1053 }
17.1054
17.1055 @@ -833,8 +876,8 @@
17.1056 * @return the list of profiles
17.1057 */
17.1058 GSList *
17.1059 -gmyth_http_retrieve_rec_profiles (GMythBackendInfo * backend_info,
17.1060 - gchar * groupname)
17.1061 +gmyth_http_retrieve_rec_profiles ( GMythBackendInfo * backend_info,
17.1062 + gchar * groupname )
17.1063 {
17.1064 xmlXPathObjectPtr result;
17.1065 xmlNodeSetPtr nodeset;
17.1066 @@ -845,56 +888,66 @@
17.1067 chunk.memory = NULL;
17.1068 chunk.size = 0;
17.1069
17.1070 - GString *command = g_string_new ("");
17.1071 + GString *command = g_string_new ( "" );
17.1072
17.1073 - g_string_printf (command, "GetRecProfiles?groupname=%s", groupname);
17.1074 + g_string_printf ( command, "GetRecProfiles?groupname=%s", groupname );
17.1075
17.1076 - chunk = gmyth_http_request (backend_info, command);
17.1077 + chunk = gmyth_http_request ( backend_info, command );
17.1078
17.1079 - if (chunk.memory != NULL) {
17.1080 - xmlDocPtr doc = XMLParse (chunk.memory, strlen (chunk.memory));
17.1081 + if ( chunk.memory != NULL )
17.1082 + {
17.1083 + xmlDocPtr doc = XMLParse ( chunk.memory, strlen ( chunk.memory ) );
17.1084
17.1085 - result = getXPath ((xmlChar *) "/*", doc);
17.1086 + result = getXPath ( ( xmlChar * ) "/*", doc );
17.1087
17.1088 - if (result) {
17.1089 + if ( result )
17.1090 + {
17.1091 nodeset = result->nodesetval;
17.1092 - keyword = (xmlChar *) nodeset->nodeTab[0]->name;
17.1093 + keyword = ( xmlChar * ) nodeset->nodeTab[0]->name;
17.1094
17.1095 - if (g_ascii_strcasecmp ((char *) keyword, "Profiles") == 0) {
17.1096 + if ( g_ascii_strcasecmp ( ( char * ) keyword, "Profiles" ) == 0 )
17.1097 + {
17.1098 xmlNodePtr node = nodeset->nodeTab[0]->children->next;
17.1099 GMythRecProfile *profile;
17.1100
17.1101 - while (node != NULL) {
17.1102 - if (g_ascii_strcasecmp ((char *) node->name, "text") != 0) {
17.1103 - profile = gmyth_recprofile_new ();
17.1104 + while ( node != NULL )
17.1105 + {
17.1106 + if ( g_ascii_strcasecmp ( ( char * ) node->name, "text" ) !=
17.1107 + 0 )
17.1108 + {
17.1109 + profile = gmyth_recprofile_new ( );
17.1110
17.1111 - sscanf ((char *) xmlGetProp (node, (xmlChar *)
17.1112 - "id"), "%d", &(profile->id));
17.1113 + sscanf ( ( char * ) xmlGetProp ( node, ( xmlChar * )
17.1114 + "id" ), "%d",
17.1115 + &( profile->id ) );
17.1116
17.1117 - profile->name = g_strdup ((char *)
17.1118 - xmlGetProp (node, (xmlChar *)
17.1119 - "name"));
17.1120 + profile->name = g_strdup ( ( char * )
17.1121 + xmlGetProp ( node,
17.1122 + ( xmlChar * )
17.1123 + "name" ) );
17.1124
17.1125 - profile->vcodec = g_strdup ((char *)
17.1126 - xmlGetProp (node, (xmlChar *)
17.1127 - "vcodec"));
17.1128 + profile->vcodec = g_strdup ( ( char * )
17.1129 + xmlGetProp ( node,
17.1130 + ( xmlChar * )
17.1131 + "vcodec" ) );
17.1132
17.1133 - profile->acodec = g_strdup ((char *)
17.1134 - xmlGetProp (node, (xmlChar *)
17.1135 - "acodec"));
17.1136 + profile->acodec = g_strdup ( ( char * )
17.1137 + xmlGetProp ( node,
17.1138 + ( xmlChar * )
17.1139 + "acodec" ) );
17.1140
17.1141 - profile->group = g_strdup (groupname);
17.1142 + profile->group = g_strdup ( groupname );
17.1143
17.1144 - profiles = g_slist_append (profiles, profile);
17.1145 + profiles = g_slist_append ( profiles, profile );
17.1146 }
17.1147 node = node->next;
17.1148 }
17.1149
17.1150 }
17.1151 - xmlXPathFreeObject (result);
17.1152 + xmlXPathFreeObject ( result );
17.1153 }
17.1154
17.1155 - free (chunk.memory);
17.1156 + free ( chunk.memory );
17.1157 }
17.1158
17.1159 return profiles;
17.1160 @@ -904,25 +957,27 @@
17.1161
17.1162 /* Aux functions got from libcurl */
17.1163 void *
17.1164 -myrealloc (void *ptr, size_t size)
17.1165 +myrealloc ( void *ptr, size_t size )
17.1166 {
17.1167 /* There might be a realloc() out there that doesn't like reallocing
17.1168 NULL pointers, so we take care of it here */
17.1169 - if (ptr)
17.1170 - return realloc (ptr, size);
17.1171 + if ( ptr )
17.1172 + return realloc ( ptr, size );
17.1173 else
17.1174 - return malloc (size);
17.1175 + return malloc ( size );
17.1176 }
17.1177
17.1178 size_t
17.1179 -WriteMemoryCallback (void *ptr, size_t size, size_t nmemb, void *data)
17.1180 +WriteMemoryCallback ( void *ptr, size_t size, size_t nmemb, void *data )
17.1181 {
17.1182 size_t realsize = size * nmemb;
17.1183 - MemoryStruct *mem = (struct _MemoryStruct *) data;
17.1184 + MemoryStruct *mem = ( struct _MemoryStruct * ) data;
17.1185
17.1186 - mem->memory = (char *) myrealloc (mem->memory, mem->size + realsize + 1);
17.1187 - if (mem->memory) {
17.1188 - memcpy (&(mem->memory[mem->size]), ptr, realsize);
17.1189 + mem->memory =
17.1190 + ( char * ) myrealloc ( mem->memory, mem->size + realsize + 1 );
17.1191 + if ( mem->memory )
17.1192 + {
17.1193 + memcpy ( &( mem->memory[mem->size] ), ptr, realsize );
17.1194 mem->size += realsize;
17.1195 mem->memory[mem->size] = 0;
17.1196 }
17.1197 @@ -937,24 +992,26 @@
17.1198 * NULL if there is no response.
17.1199 */
17.1200 MemoryStruct
17.1201 -gmyth_http_request (GMythBackendInfo * backend_info, GString * command)
17.1202 +gmyth_http_request ( GMythBackendInfo * backend_info, GString * command )
17.1203 {
17.1204 LIBXML_TEST_VERSION
17.1205 - size_t size = strlen (backend_info->hostname) +
17.1206 - strlen (command->str) + 20;
17.1207 + size_t size = strlen ( backend_info->hostname ) +
17.1208 + strlen ( command->str ) + 20;
17.1209
17.1210 - gchar *URL = (gchar *) g_malloc (sizeof (gchar) * size);
17.1211 - gchar *mid = (gchar *) g_malloc (sizeof (gchar) * 6);
17.1212 + gchar *URL = ( gchar * ) g_malloc ( sizeof ( gchar ) * size );
17.1213 + gchar *mid = ( gchar * ) g_malloc ( sizeof ( gchar ) * 6 );
17.1214
17.1215 mid = "";
17.1216
17.1217 - if (g_ascii_strcasecmp (command->str, "GetStatus") &&
17.1218 - g_ascii_strcasecmp (command->str, "GetStatusHTML")) {
17.1219 + if ( g_ascii_strcasecmp ( command->str, "GetStatus" ) &&
17.1220 + g_ascii_strcasecmp ( command->str, "GetStatusHTML" ) )
17.1221 + {
17.1222 mid = "Myth/";
17.1223 }
17.1224
17.1225 - g_snprintf (URL, size, "http://%s:%d/%s%s",
17.1226 - backend_info->hostname, backend_info->status_port, mid, command->str);
17.1227 + g_snprintf ( URL, size, "http://%s:%d/%s%s",
17.1228 + backend_info->hostname, backend_info->status_port, mid,
17.1229 + command->str );
17.1230
17.1231 CURL *curl_handle;
17.1232
17.1233 @@ -963,32 +1020,33 @@
17.1234 chunk.memory = NULL; /* we expect realloc(NULL, size) to work */
17.1235 chunk.size = 0; /* no data at this point */
17.1236
17.1237 - curl_global_init (CURL_GLOBAL_ALL);
17.1238 + curl_global_init ( CURL_GLOBAL_ALL );
17.1239
17.1240 /* init the curl session */
17.1241 - curl_handle = curl_easy_init ();
17.1242 + curl_handle = curl_easy_init ( );
17.1243
17.1244 /* specify URL to get */
17.1245 - curl_easy_setopt (curl_handle, CURLOPT_URL, URL);
17.1246 + curl_easy_setopt ( curl_handle, CURLOPT_URL, URL );
17.1247
17.1248 /* send all data to this function */
17.1249 - curl_easy_setopt (curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
17.1250 + curl_easy_setopt ( curl_handle, CURLOPT_WRITEFUNCTION,
17.1251 + WriteMemoryCallback );
17.1252
17.1253 /* we pass our 'chunk' struct to the callback function */
17.1254 - curl_easy_setopt (curl_handle, CURLOPT_WRITEDATA, (void *) &chunk);
17.1255 + curl_easy_setopt ( curl_handle, CURLOPT_WRITEDATA, ( void * ) &chunk );
17.1256
17.1257 /* some servers don't like requests that are made without a user-agent
17.1258 field, so we provide one */
17.1259 - curl_easy_setopt (curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0");
17.1260 + curl_easy_setopt ( curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0" );
17.1261
17.1262 /* set timeout */
17.1263 - curl_easy_setopt (curl_handle, CURLOPT_CONNECTTIMEOUT, 20);
17.1264 + curl_easy_setopt ( curl_handle, CURLOPT_CONNECTTIMEOUT, 20 );
17.1265
17.1266 /* get it! */
17.1267 - curl_easy_perform (curl_handle);
17.1268 + curl_easy_perform ( curl_handle );
17.1269
17.1270 /* cleanup curl stuff */
17.1271 - curl_easy_cleanup (curl_handle);
17.1272 + curl_easy_cleanup ( curl_handle );
17.1273
17.1274 return chunk;
17.1275 }
18.1 --- a/gmyth/src/gmyth_http.h Wed May 23 19:21:26 2007 +0100
18.2 +++ b/gmyth/src/gmyth_http.h Wed May 23 19:50:41 2007 +0100
18.3 @@ -74,130 +74,131 @@
18.4 typedef struct _MemoryStruct MemoryStruct;
18.5
18.6 struct _MemoryStruct
18.7 -{
18.8 - char *memory;
18.9 - size_t size;
18.10 -};
18.11 + {
18.12 + char *memory;
18.13 + size_t size;
18.14 + };
18.15
18.16 struct _GMythProgram
18.17 -{
18.18 - gchar *title;
18.19 - gchar *subtitle;
18.20 - gchar *catType;
18.21 - gchar *category;
18.22 - gint repeat;
18.23 - GTimeVal *startTime;
18.24 - GTimeVal *endTime;
18.25 -};
18.26 + {
18.27 + gchar *title;
18.28 + gchar *subtitle;
18.29 + gchar *catType;
18.30 + gchar *category;
18.31 + gint repeat;
18.32 + GTimeVal *startTime;
18.33 + GTimeVal *endTime;
18.34 + };
18.35
18.36 struct _GMythChannel
18.37 -{
18.38 - gchar *channelName;
18.39 - gchar *chanNum;
18.40 - gint chanId;
18.41 - gint callSign;
18.42 - GSList *programList;
18.43 -};
18.44 + {
18.45 + gchar *channelName;
18.46 + gchar *chanNum;
18.47 + gint chanId;
18.48 + gint callSign;
18.49 + GSList *programList;
18.50 + };
18.51
18.52 struct _GMythEpg
18.53 -{
18.54 - gint startChanId;
18.55 - gint endChanId;
18.56 - gchar *version;
18.57 - gint protoVer;
18.58 - gint totalCount;
18.59 - gint numOfChannels;
18.60 - GTimeVal *asOf;
18.61 - GTimeVal *startTime;
18.62 - GTimeVal *endTime;
18.63 - gint details;
18.64 - GSList *channelList;
18.65 -};
18.66 + {
18.67 + gint startChanId;
18.68 + gint endChanId;
18.69 + gchar *version;
18.70 + gint protoVer;
18.71 + gint totalCount;
18.72 + gint numOfChannels;
18.73 + GTimeVal *asOf;
18.74 + GTimeVal *startTime;
18.75 + GTimeVal *endTime;
18.76 + gint details;
18.77 + GSList *channelList;
18.78 + };
18.79
18.80
18.81 struct _GMythRecorded_Recording
18.82 -{
18.83 - gint dupInType;
18.84 - gint dupMethod;
18.85 - gchar *playGroup;
18.86 - gchar *recGroup;
18.87 - gchar *recProfile;
18.88 - gint recPriority;
18.89 - gint recStatus;
18.90 - gint encoderId;
18.91 - gint recordId;
18.92 - gint recType;
18.93 - GTimeVal *recStartTs;
18.94 - GTimeVal *recEndTs;
18.95 -};
18.96 + {
18.97 + gint dupInType;
18.98 + gint dupMethod;
18.99 + gchar *playGroup;
18.100 + gchar *recGroup;
18.101 + gchar *recProfile;
18.102 + gint recPriority;
18.103 + gint recStatus;
18.104 + gint encoderId;
18.105 + gint recordId;
18.106 + gint recType;
18.107 + GTimeVal *recStartTs;
18.108 + GTimeVal *recEndTs;
18.109 + };
18.110
18.111
18.112 struct _GMythRecorded_Channel
18.113 -{
18.114 - gchar *chanFilters;
18.115 - gchar *channelName;
18.116 - gint chanNum;
18.117 - gint sourceId;
18.118 - gint commFree;
18.119 - gint inputId;
18.120 - gint chanId;
18.121 - gint callSign;
18.122 -};
18.123 + {
18.124 + gchar *chanFilters;
18.125 + gchar *channelName;
18.126 + gint chanNum;
18.127 + gint sourceId;
18.128 + gint commFree;
18.129 + gint inputId;
18.130 + gint chanId;
18.131 + gint callSign;
18.132 + };
18.133
18.134
18.135 struct _GMythRecorded_Program
18.136 -{
18.137 - gint programFlags;
18.138 - gchar *title;
18.139 - gint programId;
18.140 - gchar *catType;
18.141 - gchar *category;
18.142 - gint seriesId;
18.143 - GTimeVal *startTime;
18.144 - GTimeVal *endTime;
18.145 - GTimeVal *airdate; //?
18.146 - GTimeVal *lastModified;
18.147 - gchar *subTitle;
18.148 - gint stars;
18.149 - gint repeat;
18.150 - gint fileSize;
18.151 - gchar *hostname;
18.152 - GMythRecorded_Channel channel;
18.153 - GMythRecorded_Recording recording;
18.154 -};
18.155 + {
18.156 + gint programFlags;
18.157 + gchar *title;
18.158 + gint programId;
18.159 + gchar *catType;
18.160 + gchar *category;
18.161 + gint seriesId;
18.162 + GTimeVal *startTime;
18.163 + GTimeVal *endTime;
18.164 + GTimeVal *airdate; //?
18.165 + GTimeVal *lastModified;
18.166 + gchar *subTitle;
18.167 + gint stars;
18.168 + gint repeat;
18.169 + gint fileSize;
18.170 + gchar *hostname;
18.171 + GMythRecorded_Channel channel;
18.172 + GMythRecorded_Recording recording;
18.173 + };
18.174
18.175 struct _GMythRecorded
18.176 -{
18.177 - gchar *version;
18.178 - gint protoVer;
18.179 - gint totalCount;
18.180 - GTimeVal *asOf;
18.181 - GSList *programList;
18.182 -};
18.183 + {
18.184 + gchar *version;
18.185 + gint protoVer;
18.186 + gint totalCount;
18.187 + GTimeVal *asOf;
18.188 + GSList *programList;
18.189 + };
18.190
18.191
18.192 -gint gmyth_http_retrieve_job_status (GMythBackendInfo * backend_info,
18.193 - gint chanid, GTimeVal * start);
18.194 +gint gmyth_http_retrieve_job_status ( GMythBackendInfo * backend_info,
18.195 + gint chanid, GTimeVal * start );
18.196
18.197 -gchar *gmyth_http_retrieve_setting (GMythBackendInfo * backend_info,
18.198 - gchar * key, gchar * hostname);
18.199 +gchar *gmyth_http_retrieve_setting ( GMythBackendInfo * backend_info,
18.200 + gchar * key, gchar * hostname );
18.201
18.202 -GMythEpg gmyth_http_retrieve_epg (GMythBackendInfo * backend_info,
18.203 - GTimeVal * StartTime, GTimeVal * EndTime,
18.204 - gint StartChanId, gint NumOfChannels, gchar * Details);
18.205 +GMythEpg gmyth_http_retrieve_epg ( GMythBackendInfo * backend_info,
18.206 + GTimeVal * StartTime, GTimeVal * EndTime,
18.207 + gint StartChanId, gint NumOfChannels,
18.208 + gchar * Details );
18.209
18.210 -GMythRecorded gmyth_http_retrieve_recorded (GMythBackendInfo * backend_info);
18.211 +GMythRecorded gmyth_http_retrieve_recorded ( GMythBackendInfo * backend_info );
18.212
18.213 -GSList *gmyth_http_retrieve_rec_profiles (GMythBackendInfo * backend_info,
18.214 - gchar * groupname);
18.215 +GSList *gmyth_http_retrieve_rec_profiles ( GMythBackendInfo * backend_info,
18.216 + gchar * groupname );
18.217
18.218 -gint gmyth_http_create_rec_profile (GMythBackendInfo * backend_info,
18.219 - GMythRecProfile * profile);
18.220 +gint gmyth_http_create_rec_profile ( GMythBackendInfo * backend_info,
18.221 + GMythRecProfile * profile );
18.222
18.223 -gint gmyth_http_del_rec_profile (GMythBackendInfo * backend_info, gint id);
18.224 +gint gmyth_http_del_rec_profile ( GMythBackendInfo * backend_info, gint id );
18.225
18.226 -MemoryStruct gmyth_http_request (GMythBackendInfo * backend_info,
18.227 - GString * command);
18.228 +MemoryStruct gmyth_http_request ( GMythBackendInfo * backend_info,
18.229 + GString * command );
18.230
18.231 G_END_DECLS
18.232 #endif /* __GMYTH_HTTP_H__ */
19.1 --- a/gmyth/src/gmyth_jobqueue.c Wed May 23 19:21:26 2007 +0100
19.2 +++ b/gmyth/src/gmyth_jobqueue.c Wed May 23 19:50:41 2007 +0100
19.3 @@ -40,18 +40,22 @@
19.4 *
19.5 */
19.6 static GMythSocket *
19.7 -backend_connect (GMythBackendInfo * backend_info)
19.8 +backend_connect ( GMythBackendInfo * backend_info )
19.9 {
19.10 - GMythSocket *socket = gmyth_socket_new ();
19.11 + GMythSocket *socket = gmyth_socket_new ( );
19.12
19.13 - if (gmyth_socket_connect_to_backend (socket,
19.14 - gmyth_backend_info_get_hostname
19.15 - (backend_info),
19.16 - gmyth_backend_info_get_port (backend_info), TRUE) == TRUE) {
19.17 - gmyth_debug ("Backend socket connection success");
19.18 + if ( gmyth_socket_connect_to_backend ( socket,
19.19 + gmyth_backend_info_get_hostname
19.20 + ( backend_info ),
19.21 + gmyth_backend_info_get_port
19.22 + ( backend_info ), TRUE ) == TRUE )
19.23 + {
19.24 + gmyth_debug ( "Backend socket connection success" );
19.25 return socket;
19.26 - } else {
19.27 - gmyth_debug ("Connection failed");
19.28 + }
19.29 + else
19.30 + {
19.31 + gmyth_debug ( "Connection failed" );
19.32 return NULL;
19.33 }
19.34 }
19.35 @@ -69,31 +73,31 @@
19.36 *
19.37 */
19.38 static gchar *
19.39 -send_command (GMythSocket * socket, gchar * action,
19.40 - gchar * job, gint chanid, gchar * starttime, gchar * options)
19.41 +send_command ( GMythSocket * socket, gchar * action,
19.42 + gchar * job, gint chanid, gchar * starttime, gchar * options )
19.43 {
19.44 - GString *command = g_string_new ("");
19.45 + GString *command = g_string_new ( "" );
19.46 GString *ret_str;
19.47 gchar *ret;
19.48
19.49 - GMythStringList *retlist = gmyth_string_list_new ();
19.50 + GMythStringList *retlist = gmyth_string_list_new ( );
19.51
19.52 - g_string_printf (command, "JOBQUEUE %s %s %d %s %s", action, job,
19.53 - chanid, starttime, options);
19.54 + g_string_printf ( command, "JOBQUEUE %s %s %d %s %s", action, job,
19.55 + chanid, starttime, options );
19.56
19.57 - gmyth_string_list_append_string (retlist, command);
19.58 - gmyth_socket_write_stringlist (socket, retlist);
19.59 + gmyth_string_list_append_string ( retlist, command );
19.60 + gmyth_socket_write_stringlist ( socket, retlist );
19.61
19.62 // receive answer
19.63 - gmyth_socket_read_stringlist (socket, retlist);
19.64 - ret_str = gmyth_string_list_get_string (retlist, 0);
19.65 + gmyth_socket_read_stringlist ( socket, retlist );
19.66 + ret_str = gmyth_string_list_get_string ( retlist, 0 );
19.67
19.68 //ret = ret_str->str;
19.69 - ret = g_string_free (ret_str, FALSE);
19.70 - g_string_free (command, TRUE);
19.71 + ret = g_string_free ( ret_str, FALSE );
19.72 + g_string_free ( command, TRUE );
19.73
19.74 - gmyth_string_list_clear_all (retlist);
19.75 - g_object_unref (retlist);
19.76 + gmyth_string_list_clear_all ( retlist );
19.77 + g_object_unref ( retlist );
19.78
19.79 return ret;
19.80 }
19.81 @@ -107,12 +111,15 @@
19.82 *
19.83 */
19.84 static gboolean
19.85 -test_result (gchar * ret, gchar * value)
19.86 +test_result ( gchar * ret, gchar * value )
19.87 {
19.88 - if (g_ascii_strcasecmp (ret, value) == 0) {
19.89 + if ( g_ascii_strcasecmp ( ret, value ) == 0 )
19.90 + {
19.91 return TRUE;
19.92 - } else {
19.93 - gmyth_debug ("JobQueue Error: %s", ret);
19.94 + }
19.95 + else
19.96 + {
19.97 + gmyth_debug ( "JobQueue Error: %s", ret );
19.98 return FALSE;
19.99 }
19.100 }
19.101 @@ -125,40 +132,44 @@
19.102 *
19.103 */
19.104 gboolean
19.105 -gmyth_jobqueue_add_job (GMythTranscoder * transcode, gchar * job)
19.106 +gmyth_jobqueue_add_job ( GMythTranscoder * transcode, gchar * job )
19.107 {
19.108 - GMythSocket *socket = backend_connect (transcode->backend_info);
19.109 + GMythSocket *socket = backend_connect ( transcode->backend_info );
19.110 gboolean res = FALSE;
19.111
19.112 - if (socket != NULL) {
19.113 - GString *options = g_string_new ("");
19.114 + if ( socket != NULL )
19.115 + {
19.116 + GString *options = g_string_new ( "" );
19.117 gchar *ret = NULL;
19.118
19.119 - if (g_ascii_strcasecmp (job, "JOB_TRANSCODE") == 0) {
19.120 - if (transcode->cutlist)
19.121 - g_string_append (options, " JOB_USE_CUTLIST");
19.122 + if ( g_ascii_strcasecmp ( job, "JOB_TRANSCODE" ) == 0 )
19.123 + {
19.124 + if ( transcode->cutlist )
19.125 + g_string_append ( options, " JOB_USE_CUTLIST" );
19.126
19.127 - if (transcode->output)
19.128 - g_string_append_printf (options, " JOB_OUTPUT %s",
19.129 - transcode->output_filename);
19.130 + if ( transcode->output )
19.131 + g_string_append_printf ( options, " JOB_OUTPUT %s",
19.132 + transcode->output_filename );
19.133
19.134 - if (transcode->profile != NULL)
19.135 - g_string_append_printf (options, " %s", transcode->profile);
19.136 + if ( transcode->profile != NULL )
19.137 + g_string_append_printf ( options, " %s", transcode->profile );
19.138 }
19.139 - ret = send_command (socket, "ADD", job, transcode->chanid,
19.140 - transcode->starttime, options->str);
19.141 - res = test_result (ret, "JOBQUEUE_OK");
19.142 - gmyth_socket_close_connection (socket);
19.143 + ret = send_command ( socket, "ADD", job, transcode->chanid,
19.144 + transcode->starttime, options->str );
19.145 + res = test_result ( ret, "JOBQUEUE_OK" );
19.146 + gmyth_socket_close_connection ( socket );
19.147
19.148 - g_object_unref (socket);
19.149 + g_object_unref ( socket );
19.150
19.151 - g_string_free (options, TRUE);
19.152 + g_string_free ( options, TRUE );
19.153
19.154 - if (ret)
19.155 - g_free (ret);
19.156 + if ( ret )
19.157 + g_free ( ret );
19.158
19.159 - } else {
19.160 - gmyth_debug ("JobQueue Connection Failed");
19.161 + }
19.162 + else
19.163 + {
19.164 + gmyth_debug ( "JobQueue Connection Failed" );
19.165 }
19.166
19.167 return res;
19.168 @@ -173,26 +184,29 @@
19.169 *
19.170 */
19.171 gboolean
19.172 -gmyth_jobqueue_change_cmd (GMythTranscoder * transcode, gchar * action,
19.173 - gchar * job)
19.174 +gmyth_jobqueue_change_cmd ( GMythTranscoder * transcode, gchar * action,
19.175 + gchar * job )
19.176 {
19.177 - GMythSocket *socket = backend_connect (transcode->backend_info);
19.178 + GMythSocket *socket = backend_connect ( transcode->backend_info );
19.179 gboolean res = FALSE;
19.180
19.181 - if (socket != NULL) {
19.182 - gchar *ret = send_command (socket, action, job,
19.183 - transcode->chanid,
19.184 - transcode->starttime, "");
19.185 + if ( socket != NULL )
19.186 + {
19.187 + gchar *ret = send_command ( socket, action, job,
19.188 + transcode->chanid,
19.189 + transcode->starttime, "" );
19.190
19.191 - res = test_result (ret, "JOBQUEUE_CHANGED_CMD_OK");
19.192 + res = test_result ( ret, "JOBQUEUE_CHANGED_CMD_OK" );
19.193
19.194 - gmyth_socket_close_connection (socket);
19.195 - g_object_unref (socket);
19.196 + gmyth_socket_close_connection ( socket );
19.197 + g_object_unref ( socket );
19.198
19.199 - g_free (ret);
19.200 + g_free ( ret );
19.201
19.202 - } else {
19.203 - gmyth_debug ("JobQueue Connection Failed");
19.204 + }
19.205 + else
19.206 + {
19.207 + gmyth_debug ( "JobQueue Connection Failed" );
19.208 }
19.209
19.210 return res;
20.1 --- a/gmyth/src/gmyth_jobqueue.h Wed May 23 19:21:26 2007 +0100
20.2 +++ b/gmyth/src/gmyth_jobqueue.h Wed May 23 19:50:41 2007 +0100
20.3 @@ -43,9 +43,10 @@
20.4 #include "gmyth_util.h"
20.5
20.6 G_BEGIN_DECLS
20.7 - gboolean gmyth_jobqueue_add_job (GMythTranscoder * transcoder, gchar * job);
20.8 -gboolean gmyth_jobqueue_change_cmd (GMythTranscoder * transcoder,
20.9 - gchar * action, gchar * job);
20.10 + gboolean gmyth_jobqueue_add_job ( GMythTranscoder * transcoder,
20.11 + gchar * job );
20.12 +gboolean gmyth_jobqueue_change_cmd ( GMythTranscoder * transcoder,
20.13 + gchar * action, gchar * job );
20.14
20.15 G_END_DECLS
20.16 #endif /* __GMYTH_JOBQUEUE_H__ */
21.1 --- a/gmyth/src/gmyth_livetv.c Wed May 23 19:21:26 2007 +0100
21.2 +++ b/gmyth/src/gmyth_livetv.c Wed May 23 19:50:41 2007 +0100
21.3 @@ -8,22 +8,21 @@
21.4 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
21.5 * @author Rosfran Lins Borges <rosfran.borges@indt.org.br>
21.6 *
21.7 - *//*
21.8 - *
21.9 - * This program is free software; you can redistribute it and/or modify
21.10 - * it under the terms of the GNU Lesser General Public License as published by
21.11 - * the Free Software Foundation; either version 2 of the License, or
21.12 - * (at your option) any later version.
21.13 - *
21.14 - * This program is distributed in the hope that it will be useful,
21.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
21.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21.17 - * GNU General Public License for more details.
21.18 - *
21.19 - * You should have received a copy of the GNU Lesser General Public License
21.20 - * along with this program; if not, write to the Free Software
21.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21.22 - */
21.23 + *
21.24 + * This program is free software; you can redistribute it and/or modify
21.25 + * it under the terms of the GNU Lesser General Public License as published by
21.26 + * the Free Software Foundation; either version 2 of the License, or
21.27 + * (at your option) any later version.
21.28 + *
21.29 + * This program is distributed in the hope that it will be useful,
21.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
21.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21.32 + * GNU General Public License for more details.
21.33 + *
21.34 + * You should have received a copy of the GNU Lesser General Public License
21.35 + * along with this program; if not, write to the Free Software
21.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21.37 + */
21.38
21.39 #ifdef HAVE_CONFIG_H
21.40 #include "config.h"
21.41 @@ -56,113 +55,113 @@
21.42
21.43 #define GMYTHTV_TRANSFER_MAX_WAITS 100
21.44
21.45 -G_DEFINE_TYPE (GMythLiveTV, gmyth_livetv, G_TYPE_OBJECT)
21.46 - static void gmyth_livetv_class_init (GMythLiveTVClass * klass)
21.47 + G_DEFINE_TYPE (GMythLiveTV, gmyth_livetv, G_TYPE_OBJECT)
21.48 +static void gmyth_livetv_class_init (GMythLiveTVClass * klass)
21.49 {
21.50 - GObjectClass *gobject_class;
21.51 + GObjectClass *gobject_class;
21.52
21.53 - gobject_class = (GObjectClass *) klass;
21.54 + gobject_class = (GObjectClass *) klass;
21.55
21.56 - gobject_class->dispose = gmyth_livetv_dispose;
21.57 - gobject_class->finalize = gmyth_livetv_finalize;
21.58 + gobject_class->dispose = gmyth_livetv_dispose;
21.59 + gobject_class->finalize = gmyth_livetv_finalize;
21.60 }
21.61
21.62 -static void
21.63 + static void
21.64 gmyth_livetv_init (GMythLiveTV * livetv)
21.65 {
21.66 - livetv->monitor = NULL;
21.67 - livetv->backend_info = NULL;
21.68 - livetv->local_hostname = NULL;
21.69 - livetv->file = NULL;
21.70 - livetv->setup_done = FALSE;
21.71 + livetv->monitor = NULL;
21.72 + livetv->backend_info = NULL;
21.73 + livetv->local_hostname = NULL;
21.74 + livetv->file = NULL;
21.75 + livetv->setup_done = FALSE;
21.76
21.77 - livetv->socket = NULL;
21.78 - livetv->recorder = NULL;
21.79 - livetv->tvchain = NULL;
21.80 - livetv->proginfo = NULL;
21.81 - livetv->uri = NULL;
21.82 + livetv->socket = NULL;
21.83 + livetv->recorder = NULL;
21.84 + livetv->tvchain = NULL;
21.85 + livetv->proginfo = NULL;
21.86 + livetv->uri = NULL;
21.87
21.88 - livetv->mutex = g_mutex_new ();
21.89 + livetv->mutex = g_mutex_new ();
21.90 }
21.91
21.92 -static void
21.93 + static void
21.94 gmyth_livetv_dispose (GObject * object)
21.95 {
21.96 - GMythLiveTV *livetv = GMYTH_LIVETV (object);
21.97 + GMythLiveTV *livetv = GMYTH_LIVETV (object);
21.98
21.99
21.100 - if (livetv->disposed) {
21.101 - /* If dispose did already run, return. */
21.102 - return;
21.103 - }
21.104 + if (livetv->disposed) {
21.105 + /* If dispose did already run, return. */
21.106 + return;
21.107 + }
21.108
21.109 - /* Make sure dispose does not run twice. */
21.110 - livetv->disposed = TRUE;
21.111 + /* Make sure dispose does not run twice. */
21.112 + livetv->disposed = TRUE;
21.113
21.114 - if (livetv->monitor != NULL) {
21.115 - g_object_unref (livetv->monitor);
21.116 - livetv->monitor = NULL;
21.117 - }
21.118 + if (livetv->monitor != NULL) {
21.119 + g_object_unref (livetv->monitor);
21.120 + livetv->monitor = NULL;
21.121 + }
21.122
21.123 - if (livetv->file != NULL) {
21.124 - g_object_unref (livetv->file);
21.125 - livetv->file = NULL;
21.126 - }
21.127 + if (livetv->file != NULL) {
21.128 + g_object_unref (livetv->file);
21.129 + livetv->file = NULL;
21.130 + }
21.131
21.132
21.133 - if (livetv->recorder != NULL) {
21.134 - //gmyth_recorder_close(livetv->recorder);
21.135 - g_object_unref (livetv->recorder);
21.136 - livetv->recorder = NULL;
21.137 - }
21.138 + if (livetv->recorder != NULL) {
21.139 + //gmyth_recorder_close(livetv->recorder);
21.140 + g_object_unref (livetv->recorder);
21.141 + livetv->recorder = NULL;
21.142 + }
21.143
21.144 - if (livetv->socket != NULL) {
21.145 - g_object_unref (livetv->socket);
21.146 - livetv->socket = NULL;
21.147 - }
21.148 + if (livetv->socket != NULL) {
21.149 + g_object_unref (livetv->socket);
21.150 + livetv->socket = NULL;
21.151 + }
21.152
21.153 - if (livetv->tvchain != NULL) {
21.154 - g_object_unref (livetv->tvchain);
21.155 - livetv->tvchain = NULL;
21.156 - }
21.157 + if (livetv->tvchain != NULL) {
21.158 + g_object_unref (livetv->tvchain);
21.159 + livetv->tvchain = NULL;
21.160 + }
21.161
21.162
21.163 - if (livetv->proginfo != NULL) {
21.164 - g_object_unref (livetv->proginfo);
21.165 - livetv->proginfo = NULL;
21.166 - }
21.167 + if (livetv->proginfo != NULL) {
21.168 + g_object_unref (livetv->proginfo);
21.169 + livetv->proginfo = NULL;
21.170 + }
21.171
21.172 - if (livetv->backend_info != NULL) {
21.173 - g_object_unref (livetv->backend_info);
21.174 - livetv->backend_info = NULL;
21.175 - }
21.176 + if (livetv->backend_info != NULL) {
21.177 + g_object_unref (livetv->backend_info);
21.178 + livetv->backend_info = NULL;
21.179 + }
21.180
21.181
21.182 - if (livetv->uri != NULL) {
21.183 - g_object_unref (livetv->uri);
21.184 - livetv->uri = NULL;
21.185 - }
21.186 + if (livetv->uri != NULL) {
21.187 + g_object_unref (livetv->uri);
21.188 + livetv->uri = NULL;
21.189 + }
21.190
21.191 - if (livetv->mutex != NULL) {
21.192 - g_mutex_free (livetv->mutex);
21.193 - livetv->mutex = NULL;
21.194 - }
21.195 + if (livetv->mutex != NULL) {
21.196 + g_mutex_free (livetv->mutex);
21.197 + livetv->mutex = NULL;
21.198 + }
21.199
21.200
21.201 - if (livetv->local_hostname != NULL) {
21.202 - g_string_free (livetv->local_hostname, TRUE);
21.203 - livetv->local_hostname = NULL;
21.204 - }
21.205 + if (livetv->local_hostname != NULL) {
21.206 + g_string_free (livetv->local_hostname, TRUE);
21.207 + livetv->local_hostname = NULL;
21.208 + }
21.209
21.210 - G_OBJECT_CLASS (gmyth_livetv_parent_class)->dispose (object);
21.211 + G_OBJECT_CLASS (gmyth_livetv_parent_class)->dispose (object);
21.212 }
21.213
21.214 -static void
21.215 + static void
21.216 gmyth_livetv_finalize (GObject * object)
21.217 {
21.218 - g_signal_handlers_destroy (object);
21.219 + g_signal_handlers_destroy (object);
21.220
21.221 - G_OBJECT_CLASS (gmyth_livetv_parent_class)->finalize (object);
21.222 + G_OBJECT_CLASS (gmyth_livetv_parent_class)->finalize (object);
21.223 }
21.224
21.225 /**
21.226 @@ -170,15 +169,15 @@
21.227 *
21.228 * @return a newly allocated GMythLiveTV instance
21.229 */
21.230 -GMythLiveTV *
21.231 + GMythLiveTV *
21.232 gmyth_livetv_new (GMythBackendInfo * backend_info)
21.233 {
21.234 - GMythLiveTV *livetv = GMYTH_LIVETV (g_object_new (GMYTH_LIVETV_TYPE, NULL));
21.235 + GMythLiveTV *livetv = GMYTH_LIVETV (g_object_new (GMYTH_LIVETV_TYPE, NULL));
21.236
21.237 - livetv->backend_info = backend_info;
21.238 - g_object_ref (livetv->backend_info);
21.239 + livetv->backend_info = backend_info;
21.240 + g_object_ref (livetv->backend_info);
21.241
21.242 - return livetv;
21.243 + return livetv;
21.244 }
21.245
21.246 /**
21.247 @@ -191,96 +190,96 @@
21.248 * @param message the message's string description
21.249 * @param user_data pointer to the GMythLiveTV instance
21.250 */
21.251 -static void
21.252 + static void
21.253 gmyth_livetv_monitor_signal_handler (GMythMonitorHandler * monitor,
21.254 - gint msg_code, gchar * message, gpointer user_data)
21.255 + gint msg_code, gchar * message, gpointer user_data)
21.256 {
21.257 - GMythLiveTV *live_tv = GMYTH_LIVETV (user_data);
21.258 + GMythLiveTV *live_tv = GMYTH_LIVETV (user_data);
21.259
21.260 - gmyth_debug
21.261 - ("LIVETV Signal handler ( msg = %s, code = %d, live_tv param = %s, user_data = %s )\n",
21.262 - message, msg_code, live_tv != NULL ? "" : "NULL",
21.263 - user_data != NULL ? "" : "NULL");
21.264 + gmyth_debug
21.265 + ("LIVETV Signal handler ( msg = %s, code = %d, live_tv param = %s, user_data = %s )\n",
21.266 + message, msg_code, live_tv != NULL ? "" : "NULL",
21.267 + user_data != NULL ? "" : "NULL");
21.268
21.269 - if (NULL == live_tv || !IS_GMYTH_FILE_TRANSFER (live_tv->file)) {
21.270 - gmyth_debug ("LiveTV_obj is equals to NULL!!!");
21.271 - return;
21.272 - }
21.273 + if (NULL == live_tv || !IS_GMYTH_FILE_TRANSFER (live_tv->file)) {
21.274 + gmyth_debug ("LiveTV_obj is equals to NULL!!!");
21.275 + return;
21.276 + }
21.277
21.278 - switch (msg_code) {
21.279 + switch (msg_code) {
21.280
21.281 - case GMYTH_BACKEND_PROGRAM_INFO_CHANGED:
21.282 - {
21.283 - gmyth_debug
21.284 - ("LIVETV Program Changed request received [ msg = %s ]. Watching if the new "
21.285 - "TV Chain ID is the same as the old one...\n", message);
21.286 - if (g_ascii_strcasecmp
21.287 - (message,
21.288 - (gmyth_tvchain_get_id (live_tv->tvchain))->str) != 0) {
21.289 - gmyth_debug
21.290 - ("OK!!! MOVED to the next program chain [actual == %s]!",
21.291 - (gmyth_tvchain_get_id (live_tv->tvchain))->str);
21.292 - /* advertises the FileTransfer about the program info changed */
21.293 - if (live_tv->file != NULL) {
21.294 - gmyth_debug
21.295 - ("Emitting signal to the FileTransfer... [ \"program-info-changed \" ]");
21.296 + case GMYTH_BACKEND_PROGRAM_INFO_CHANGED:
21.297 + {
21.298 + gmyth_debug
21.299 + ("LIVETV Program Changed request received [ msg = %s ]. Watching if the new "
21.300 + "TV Chain ID is the same as the old one...\n", message);
21.301 + if (g_ascii_strcasecmp
21.302 + (message,
21.303 + (gmyth_tvchain_get_id (live_tv->tvchain))->str) != 0) {
21.304 + gmyth_debug
21.305 + ("OK!!! MOVED to the next program chain [actual == %s]!",
21.306 + (gmyth_tvchain_get_id (live_tv->tvchain))->str);
21.307 + /* advertises the FileTransfer about the program info changed */
21.308 + if (live_tv->file != NULL) {
21.309 + gmyth_debug
21.310 + ("Emitting signal to the FileTransfer... [ \"program-info-changed \" ]");
21.311
21.312 - gmyth_file_transfer_emit_program_info_changed_signal
21.313 - (GMYTH_FILE_TRANSFER (live_tv->file), msg_code,
21.314 - (gpointer) (live_tv->recorder));
21.315 + gmyth_file_transfer_emit_program_info_changed_signal
21.316 + (GMYTH_FILE_TRANSFER (live_tv->file), msg_code,
21.317 + (gpointer) (live_tv->recorder));
21.318
21.319 - /* gmyth_livetv_monitor_handler_stop( live_tv ); */
21.320 - } else
21.321 - gmyth_debug
21.322 - ("LIVETV file_transfer is NULL!!! Cannot move to the next program chain event received.\n");
21.323 - }
21.324 - break;
21.325 - }
21.326 - case GMYTH_BACKEND_DONE_RECORDING:
21.327 - {
21.328 - gmyth_debug
21.329 - ("LIVETV Program Changed request received [ msg = %s ]. Watching if the new "
21.330 - "TV Chain ID is the same as the old one...\n", message);
21.331 - if (g_ascii_strcasecmp
21.332 - (message,
21.333 - (gmyth_tvchain_get_id (live_tv->tvchain))->str) != 0) {
21.334 - gmyth_debug
21.335 - ("OK!!! MOVED to the next program chain [actual == %s]!",
21.336 - (gmyth_tvchain_get_id (live_tv->tvchain))->str);
21.337 - /* advertises the FileTransfer about the program info changed */
21.338 - if (live_tv->file != NULL) {
21.339 - gmyth_debug
21.340 - ("Emitting signal to the FileTransfer... [ \"backend-done-recording\" ]");
21.341 + /* gmyth_livetv_monitor_handler_stop( live_tv ); */
21.342 + } else
21.343 + gmyth_debug
21.344 + ("LIVETV file_transfer is NULL!!! Cannot move to the next program chain event received.\n");
21.345 + }
21.346 + break;
21.347 + }
21.348 + case GMYTH_BACKEND_DONE_RECORDING:
21.349 + {
21.350 + gmyth_debug
21.351 + ("LIVETV Program Changed request received [ msg = %s ]. Watching if the new "
21.352 + "TV Chain ID is the same as the old one...\n", message);
21.353 + if (g_ascii_strcasecmp
21.354 + (message,
21.355 + (gmyth_tvchain_get_id (live_tv->tvchain))->str) != 0) {
21.356 + gmyth_debug
21.357 + ("OK!!! MOVED to the next program chain [actual == %s]!",
21.358 + (gmyth_tvchain_get_id (live_tv->tvchain))->str);
21.359 + /* advertises the FileTransfer about the program info changed */
21.360 + if (live_tv->file != NULL) {
21.361 + gmyth_debug
21.362 + ("Emitting signal to the FileTransfer... [ \"backend-done-recording\" ]");
21.363
21.364 - gmyth_file_transfer_emit_program_info_changed_signal
21.365 - (GMYTH_FILE_TRANSFER (live_tv->file), msg_code,
21.366 - (gpointer) (live_tv->recorder));
21.367 + gmyth_file_transfer_emit_program_info_changed_signal
21.368 + (GMYTH_FILE_TRANSFER (live_tv->file), msg_code,
21.369 + (gpointer) (live_tv->recorder));
21.370
21.371 - } else
21.372 - gmyth_debug
21.373 - ("LIVETV file_transfer is NULL!!! Cannot move to the next program chain event received.\n");
21.374 - }
21.375 - break;
21.376 - }
21.377 - case GMYTH_BACKEND_STOP_LIVETV:
21.378 - {
21.379 - gmyth_debug
21.380 - ("LIVETV Stop LiveTV request received [ msg = %s ]. Going out the "
21.381 - "LiveTV...\n", message);
21.382 - /* stops the LiveTV */
21.383 - if (live_tv != NULL) {
21.384 - gmyth_debug ("Going out the LiveTV... [ \"quit-livetv\" ]");
21.385 + } else
21.386 + gmyth_debug
21.387 + ("LIVETV file_transfer is NULL!!! Cannot move to the next program chain event received.\n");
21.388 + }
21.389 + break;
21.390 + }
21.391 + case GMYTH_BACKEND_STOP_LIVETV:
21.392 + {
21.393 + gmyth_debug
21.394 + ("LIVETV Stop LiveTV request received [ msg = %s ]. Going out the "
21.395 + "LiveTV...\n", message);
21.396 + /* stops the LiveTV */
21.397 + if (live_tv != NULL) {
21.398 + gmyth_debug ("Going out the LiveTV... [ \"quit-livetv\" ]");
21.399
21.400 - g_object_unref (live_tv);
21.401 - } else
21.402 - gmyth_debug
21.403 - ("LIVETV file_transfer is NULL!!! Cannot move to the next program chain event received.\n");
21.404 + g_object_unref (live_tv);
21.405 + } else
21.406 + gmyth_debug
21.407 + ("LIVETV file_transfer is NULL!!! Cannot move to the next program chain event received.\n");
21.408
21.409 - break;
21.410 - }
21.411 - default:
21.412 - break;
21.413 - } /* switch (Monitor Handler messages) */
21.414 + break;
21.415 + }
21.416 + default:
21.417 + break;
21.418 + } /* switch (Monitor Handler messages) */
21.419
21.420 }
21.421
21.422 @@ -293,43 +292,43 @@
21.423 * @return <code>true</code> if the Monitor Handler start-up process
21.424 * had been concluded succcesfully
21.425 */
21.426 -gboolean
21.427 + gboolean
21.428 gmyth_livetv_monitor_handler_start (GMythLiveTV * livetv)
21.429 {
21.430 - gboolean res = TRUE;
21.431 + gboolean res = TRUE;
21.432
21.433 - if (livetv->monitor != NULL) {
21.434 - g_object_unref (livetv->monitor);
21.435 - livetv->monitor = NULL;
21.436 - }
21.437 + if (livetv->monitor != NULL) {
21.438 + g_object_unref (livetv->monitor);
21.439 + livetv->monitor = NULL;
21.440 + }
21.441
21.442 - livetv->monitor = gmyth_monitor_handler_new ();
21.443 + livetv->monitor = gmyth_monitor_handler_new ();
21.444
21.445 - res =
21.446 - gmyth_monitor_handler_open (livetv->monitor,
21.447 - livetv->backend_info->hostname, livetv->backend_info->port);
21.448 + res =
21.449 + gmyth_monitor_handler_open (livetv->monitor,
21.450 + livetv->backend_info->hostname, livetv->backend_info->port);
21.451
21.452 - if (res == TRUE) {
21.453 - gmyth_debug
21.454 - ("Connect MythTV Monitor event socket! Trying to start the message handler...");
21.455 + if (res == TRUE) {
21.456 + gmyth_debug
21.457 + ("Connect MythTV Monitor event socket! Trying to start the message handler...");
21.458
21.459 - res = gmyth_monitor_handler_start (livetv->monitor);
21.460 + res = gmyth_monitor_handler_start (livetv->monitor);
21.461
21.462 - if (res) {
21.463 - gmyth_debug
21.464 - ("MythTV Monitor event socket connected and listening!");
21.465 - g_signal_connect (G_OBJECT (livetv->monitor),
21.466 - "backend-events-handler", (GCallback)
21.467 - gmyth_livetv_monitor_signal_handler, livetv);
21.468 - } else {
21.469 - gmyth_debug
21.470 - ("Problems when trying to start MythTV Monitor event socket!");
21.471 - goto error;
21.472 - }
21.473 - }
21.474 + if (res) {
21.475 + gmyth_debug
21.476 + ("MythTV Monitor event socket connected and listening!");
21.477 + g_signal_connect (G_OBJECT (livetv->monitor),
21.478 + "backend-events-handler", (GCallback)
21.479 + gmyth_livetv_monitor_signal_handler, livetv);
21.480 + } else {
21.481 + gmyth_debug
21.482 + ("Problems when trying to start MythTV Monitor event socket!");
21.483 + goto error;
21.484 + }
21.485 + }
21.486
21.487 - error:
21.488 - return res;
21.489 +error:
21.490 + return res;
21.491
21.492 }
21.493
21.494 @@ -342,26 +341,26 @@
21.495 * @return <code>true</code> if the Monitor Handler shutdown process
21.496 * had been concluded succcesfully
21.497 */
21.498 -void
21.499 + void
21.500 gmyth_livetv_monitor_handler_stop (GMythLiveTV * livetv)
21.501 {
21.502
21.503 - if (livetv->monitor != NULL) {
21.504 - g_object_unref (livetv->monitor);
21.505 - livetv->monitor = NULL;
21.506 - }
21.507 + if (livetv->monitor != NULL) {
21.508 + g_object_unref (livetv->monitor);
21.509 + livetv->monitor = NULL;
21.510 + }
21.511
21.512 }
21.513
21.514 #if 0
21.515 -static gchar *
21.516 + static gchar *
21.517 gmyth_livetv_create_remote_url (GMythLiveTV * livetv)
21.518 {
21.519 - gchar *uri = g_strdup ("");
21.520 + gchar *uri = g_strdup ("");
21.521
21.522 - gmyth_backend_info_get_remote_h
21.523 - //gmyth_backend(livetv->backend_info)
21.524 - return uri;
21.525 + gmyth_backend_info_get_remote_h
21.526 + //gmyth_backend(livetv->backend_info)
21.527 + return uri;
21.528 }
21.529 #endif
21.530
21.531 @@ -377,272 +376,272 @@
21.532 * @return <code>true</code> if the LiveTV's recorder instance configuration
21.533 * had been concluded succcesfully
21.534 */
21.535 -static gboolean
21.536 + static gboolean
21.537 gmyth_livetv_setup_recorder_channel_name (GMythLiveTV * livetv, gchar * channel)
21.538 {
21.539 - gboolean res = TRUE;
21.540 + gboolean res = TRUE;
21.541
21.542 - g_return_val_if_fail (livetv != NULL, FALSE);
21.543 + g_return_val_if_fail (livetv != NULL, FALSE);
21.544
21.545 - if (NULL == livetv->socket) {
21.546 - livetv->socket = gmyth_socket_new ();
21.547 + if (NULL == livetv->socket) {
21.548 + livetv->socket = gmyth_socket_new ();
21.549
21.550 - /* FIME: Implement this at gmyth_socket */
21.551 - res =
21.552 - gmyth_socket_connect_to_backend (livetv->socket,
21.553 - livetv->backend_info->hostname, livetv->backend_info->port, TRUE);
21.554 - if (!res) {
21.555 - gmyth_debug ("[%s] LiveTV can not connect to backend",
21.556 - __FUNCTION__);
21.557 - res = FALSE;
21.558 - goto error;
21.559 - }
21.560 - }
21.561 + /* FIME: Implement this at gmyth_socket */
21.562 + res =
21.563 + gmyth_socket_connect_to_backend (livetv->socket,
21.564 + livetv->backend_info->hostname, livetv->backend_info->port, TRUE);
21.565 + if (!res) {
21.566 + gmyth_debug ("[%s] LiveTV can not connect to backend",
21.567 + __FUNCTION__);
21.568 + res = FALSE;
21.569 + goto error;
21.570 + }
21.571 + }
21.572
21.573 - g_mutex_lock (livetv->mutex);
21.574 + g_mutex_lock (livetv->mutex);
21.575
21.576 - livetv->is_livetv = TRUE;
21.577 + livetv->is_livetv = TRUE;
21.578
21.579 - livetv->local_hostname = gmyth_socket_get_local_hostname ();
21.580 + livetv->local_hostname = gmyth_socket_get_local_hostname ();
21.581
21.582 - if (livetv->local_hostname == NULL) {
21.583 - g_warning ("livetv could not retrieve the local hostname");
21.584 - res = FALSE;
21.585 - goto error;
21.586 - } else {
21.587 - gmyth_debug ("Local hostname: %s", livetv->local_hostname->str);
21.588 - }
21.589 + if (livetv->local_hostname == NULL) {
21.590 + g_warning ("livetv could not retrieve the local hostname");
21.591 + res = FALSE;
21.592 + goto error;
21.593 + } else {
21.594 + gmyth_debug ("Local hostname: %s", livetv->local_hostname->str);
21.595 + }
21.596
21.597 - if (livetv->recorder != NULL) {
21.598 - g_object_unref (livetv->recorder);
21.599 - livetv->recorder = NULL;
21.600 - }
21.601 + if (livetv->recorder != NULL) {
21.602 + g_object_unref (livetv->recorder);
21.603 + livetv->recorder = NULL;
21.604 + }
21.605
21.606 - if (gmyth_remote_util_get_free_recorder_count (livetv->socket) <= 0) {
21.607 - gmyth_debug ("No free remote encoder available.");
21.608 - res = FALSE;
21.609 - goto error;
21.610 - }
21.611 + if (gmyth_remote_util_get_free_recorder_count (livetv->socket) <= 0) {
21.612 + gmyth_debug ("No free remote encoder available.");
21.613 + res = FALSE;
21.614 + goto error;
21.615 + }
21.616
21.617 - /* Gets the recorder num */
21.618 - livetv->recorder = remote_request_next_free_recorder (livetv->socket, -1);
21.619 - gmyth_socket_close_connection (livetv->socket);
21.620 + /* Gets the recorder num */
21.621 + livetv->recorder = remote_request_next_free_recorder (livetv->socket, -1);
21.622 + gmyth_socket_close_connection (livetv->socket);
21.623
21.624 - if (NULL == livetv->recorder) {
21.625 - gmyth_debug ("[%s] None remote encoder available", __FUNCTION__);
21.626 - res = FALSE;
21.627 - goto error;
21.628 - }
21.629 + if (NULL == livetv->recorder) {
21.630 + gmyth_debug ("[%s] None remote encoder available", __FUNCTION__);
21.631 + res = FALSE;
21.632 + goto error;
21.633 + }
21.634
21.635 - /* Init remote encoder. Opens its control socket. */
21.636 - res = gmyth_recorder_setup (livetv->recorder);
21.637 - if (!res) {
21.638 - gmyth_debug ("[%s] Fail while setting remote encoder\n", __FUNCTION__);
21.639 - res = FALSE;
21.640 - goto error;
21.641 - }
21.642 + /* Init remote encoder. Opens its control socket. */
21.643 + res = gmyth_recorder_setup (livetv->recorder);
21.644 + if (!res) {
21.645 + gmyth_debug ("[%s] Fail while setting remote encoder\n", __FUNCTION__);
21.646 + res = FALSE;
21.647 + goto error;
21.648 + }
21.649
21.650 - /* Creates livetv chain handler */
21.651 - livetv->tvchain = gmyth_tvchain_new ();
21.652 - gmyth_tvchain_initialize (livetv->tvchain, livetv->backend_info);
21.653 + /* Creates livetv chain handler */
21.654 + livetv->tvchain = gmyth_tvchain_new ();
21.655 + gmyth_tvchain_initialize (livetv->tvchain, livetv->backend_info);
21.656
21.657 - if (livetv->tvchain == NULL || livetv->tvchain->tvchain_id == NULL) {
21.658 - res = FALSE;
21.659 - goto error;
21.660 - }
21.661 - // Spawn live tv. Uses the socket to send mythprotocol data to start livetv in the backend (remotelly)
21.662 - res = gmyth_recorder_spawntv (livetv->recorder,
21.663 - gmyth_tvchain_get_id (livetv->tvchain));
21.664 - if (!res) {
21.665 - gmyth_debug ("[%s] Fail while spawn tv\n", __FUNCTION__);
21.666 - res = FALSE;
21.667 - goto error;
21.668 - }
21.669 + if (livetv->tvchain == NULL || livetv->tvchain->tvchain_id == NULL) {
21.670 + res = FALSE;
21.671 + goto error;
21.672 + }
21.673 + // Spawn live tv. Uses the socket to send mythprotocol data to start livetv in the backend (remotelly)
21.674 + res = gmyth_recorder_spawntv (livetv->recorder,
21.675 + gmyth_tvchain_get_id (livetv->tvchain));
21.676 + if (!res) {
21.677 + gmyth_debug ("[%s] Fail while spawn tv\n", __FUNCTION__);
21.678 + res = FALSE;
21.679 + goto error;
21.680 + }
21.681
21.682 - if (res == TRUE) {
21.683 - /* loop finished, set the max tries variable to zero again... */
21.684 - gint wait_to_transfer = 0;
21.685 + if (res == TRUE) {
21.686 + /* loop finished, set the max tries variable to zero again... */
21.687 + gint wait_to_transfer = 0;
21.688
21.689 - while (wait_to_transfer++ < GMYTHTV_TRANSFER_MAX_WAITS &&
21.690 - (gmyth_recorder_is_recording (livetv->recorder) == FALSE))
21.691 - g_usleep (300);
21.692 + while (wait_to_transfer++ < GMYTHTV_TRANSFER_MAX_WAITS &&
21.693 + (gmyth_recorder_is_recording (livetv->recorder) == FALSE))
21.694 + g_usleep (300);
21.695
21.696 - if (channel != NULL) {
21.697 - /* Pauses remote encoder. */
21.698 - res = gmyth_recorder_pause_recording (livetv->recorder);
21.699 - if (!res) {
21.700 - gmyth_debug ("[%s] Fail while pausing remote encoder\n",
21.701 - __FUNCTION__);
21.702 - res = FALSE;
21.703 - goto error;
21.704 - }
21.705 + if (channel != NULL) {
21.706 + /* Pauses remote encoder. */
21.707 + res = gmyth_recorder_pause_recording (livetv->recorder);
21.708 + if (!res) {
21.709 + gmyth_debug ("[%s] Fail while pausing remote encoder\n",
21.710 + __FUNCTION__);
21.711 + res = FALSE;
21.712 + goto error;
21.713 + }
21.714
21.715 - if (gmyth_recorder_check_channel_name (livetv->recorder, channel)) {
21.716 - if (gmyth_recorder_set_channel_name (livetv->recorder, channel)) {
21.717 - gmyth_debug ("Channel changed!!! [%s].\n", channel);
21.718 - }
21.719 - }
21.720 + if (gmyth_recorder_check_channel_name (livetv->recorder, channel)) {
21.721 + if (gmyth_recorder_set_channel_name (livetv->recorder, channel)) {
21.722 + gmyth_debug ("Channel changed!!! [%s].\n", channel);
21.723 + }
21.724 + }
21.725
21.726 - }
21.727 - /* if - changes the channel number */
21.728 - /* sleep (5); */
21.729 - /* FIXME: this is evil (tpm) */
21.730 - }
21.731 + }
21.732 + /* if - changes the channel number */
21.733 + /* sleep (5); */
21.734 + /* FIXME: this is evil (tpm) */
21.735 + }
21.736
21.737 - /* DEBUG message */
21.738 - GMythProgramInfo *prog_info =
21.739 - gmyth_recorder_get_current_program_info (livetv->recorder);
21.740 + /* DEBUG message */
21.741 + GMythProgramInfo *prog_info =
21.742 + gmyth_recorder_get_current_program_info (livetv->recorder);
21.743
21.744 - if (NULL == prog_info) {
21.745 - gmyth_debug ("ProgramInfo is equals to NULL!!!");
21.746 + if (NULL == prog_info) {
21.747 + gmyth_debug ("ProgramInfo is equals to NULL!!!");
21.748
21.749 - gint i;
21.750 - gchar *channame = NULL;
21.751 + gint i;
21.752 + gchar *channame = NULL;
21.753
21.754 - gmyth_debug ("Problem getting current proginfo!\n");
21.755 + gmyth_debug ("Problem getting current proginfo!\n");
21.756
21.757 - /*
21.758 - * mythbackend must not be tuned in to a channel, so keep
21.759 - * changing channels until we find a valid one, or until
21.760 - * we decide to give up.
21.761 - */
21.762 - for (i = 1; i < 1000; i++) {
21.763 - if (channame != NULL)
21.764 - g_free (channame);
21.765 - channame = g_strdup_printf ("%d", i);
21.766 - if (gmyth_recorder_set_channel_name (livetv->recorder, channame)
21.767 - < 0) {
21.768 - continue;
21.769 - }
21.770 - prog_info =
21.771 - gmyth_recorder_get_next_program_info (livetv->recorder,
21.772 - BROWSE_DIRECTION_UP);
21.773 - gmyth_program_info_print (prog_info);
21.774 - if (prog_info != NULL)
21.775 - break;
21.776 - }
21.777 + /*
21.778 + * mythbackend must not be tuned in to a channel, so keep
21.779 + * changing channels until we find a valid one, or until
21.780 + * we decide to give up.
21.781 + */
21.782 + for (i = 1; i < 1000; i++) {
21.783 + if (channame != NULL)
21.784 + g_free (channame);
21.785 + channame = g_strdup_printf ("%d", i);
21.786 + if (gmyth_recorder_set_channel_name (livetv->recorder, channame)
21.787 + < 0) {
21.788 + continue;
21.789 + }
21.790 + prog_info =
21.791 + gmyth_recorder_get_next_program_info (livetv->recorder,
21.792 + BROWSE_DIRECTION_UP);
21.793 + gmyth_program_info_print (prog_info);
21.794 + if (prog_info != NULL)
21.795 + break;
21.796 + }
21.797
21.798 - }
21.799 + }
21.800
21.801 - /* if - Program Info */
21.802 - /* prints program info data text */
21.803 - gmyth_debug ("New ProgramInfo...\n");
21.804 - gmyth_program_info_print (prog_info);
21.805 + /* if - Program Info */
21.806 + /* prints program info data text */
21.807 + gmyth_debug ("New ProgramInfo...\n");
21.808 + gmyth_program_info_print (prog_info);
21.809
21.810 - /* check if the program chain could be obtained from the MythTV protocol message */
21.811 - if (prog_info != NULL) {
21.812 - gmyth_backend_info_set_username (livetv->tvchain->backend_info,
21.813 - "mythtv");
21.814 - gmyth_backend_info_set_password (livetv->tvchain->backend_info,
21.815 - "mythtv");
21.816 - gmyth_backend_info_set_db_name (livetv->tvchain->backend_info,
21.817 - "mythconverg");
21.818 - GList *prog_list =
21.819 - gmyth_tvchain_get_program_info_from_channel (livetv->tvchain,
21.820 - channel);
21.821 - GMythProgramInfo *ch_prog = NULL;
21.822 + /* check if the program chain could be obtained from the MythTV protocol message */
21.823 + if (prog_info != NULL) {
21.824 + gmyth_backend_info_set_username (livetv->tvchain->backend_info,
21.825 + "mythtv");
21.826 + gmyth_backend_info_set_password (livetv->tvchain->backend_info,
21.827 + "mythtv");
21.828 + gmyth_backend_info_set_db_name (livetv->tvchain->backend_info,
21.829 + "mythconverg");
21.830 + GList *prog_list =
21.831 + gmyth_tvchain_get_program_info_from_channel (livetv->tvchain,
21.832 + channel);
21.833 + GMythProgramInfo *ch_prog = NULL;
21.834
21.835 - if (prog_list != NULL && g_list_length (prog_list) > 0) {
21.836 - ch_prog = (GMythProgramInfo *) g_list_nth_data (prog_list, 0);
21.837 - gmyth_debug ("Channel program info (from a list with size = %d)!",
21.838 - g_list_length (prog_list));
21.839 - gmyth_program_info_print (ch_prog);
21.840 - }
21.841 + if (prog_list != NULL && g_list_length (prog_list) > 0) {
21.842 + ch_prog = (GMythProgramInfo *) g_list_nth_data (prog_list, 0);
21.843 + gmyth_debug ("Channel program info (from a list with size = %d)!",
21.844 + g_list_length (prog_list));
21.845 + gmyth_program_info_print (ch_prog);
21.846 + }
21.847
21.848 - gmyth_debug ("Program Info: %s\n",
21.849 - gmyth_program_info_to_string (prog_info));
21.850 - livetv->proginfo = prog_info;
21.851 - /* testing change channel */
21.852 - //gmyth_recorder_spawntv_no_tvchain( livetv->recorder );
21.853 - } else {
21.854 + gmyth_debug ("Program Info: %s\n",
21.855 + gmyth_program_info_to_string (prog_info));
21.856 + livetv->proginfo = prog_info;
21.857 + /* testing change channel */
21.858 + //gmyth_recorder_spawntv_no_tvchain( livetv->recorder );
21.859 + } else {
21.860
21.861 - /* check for the program info in the TV program chain could be obtained
21.862 - from the MythTV MySQL database */
21.863 + /* check for the program info in the TV program chain could be obtained
21.864 + from the MythTV MySQL database */
21.865
21.866 - /* Reload all TV chain from Mysql database. */
21.867 - gmyth_tvchain_reload_all (livetv->tvchain);
21.868 + /* Reload all TV chain from Mysql database. */
21.869 + gmyth_tvchain_reload_all (livetv->tvchain);
21.870
21.871 - if (livetv->tvchain == NULL) {
21.872 - res = FALSE;
21.873 - goto error;
21.874 - }
21.875 + if (livetv->tvchain == NULL) {
21.876 + res = FALSE;
21.877 + goto error;
21.878 + }
21.879
21.880 - /* Get program info from database using chanid and starttime */
21.881 - livetv->proginfo =
21.882 - gmyth_tvchain_get_program_at (livetv->tvchain,
21.883 - tvchain_curr_index++);
21.884 - if (livetv->proginfo == NULL) {
21.885 - gmyth_debug ("LiveTV not successfully started.\n");
21.886 - res = FALSE;
21.887 - goto error;
21.888 - } else {
21.889 - res = TRUE;
21.890 - gmyth_debug
21.891 - ("GMythLiveTV: All requests to backend to start TV were OK. [%s]\n",
21.892 - livetv->proginfo->pathname->str);
21.893 - }
21.894 + /* Get program info from database using chanid and starttime */
21.895 + livetv->proginfo =
21.896 + gmyth_tvchain_get_program_at (livetv->tvchain,
21.897 + tvchain_curr_index++);
21.898 + if (livetv->proginfo == NULL) {
21.899 + gmyth_debug ("LiveTV not successfully started.\n");
21.900 + res = FALSE;
21.901 + goto error;
21.902 + } else {
21.903 + res = TRUE;
21.904 + gmyth_debug
21.905 + ("GMythLiveTV: All requests to backend to start TV were OK. [%s]\n",
21.906 + livetv->proginfo->pathname->str);
21.907 + }
21.908
21.909 - }
21.910 + }
21.911
21.912 - livetv->uri =
21.913 - (GMythURI *) gmyth_backend_info_get_uri (livetv->backend_info);
21.914 + livetv->uri =
21.915 + (GMythURI *) gmyth_backend_info_get_uri (livetv->backend_info);
21.916
21.917 - g_mutex_unlock (livetv->mutex);
21.918 + g_mutex_unlock (livetv->mutex);
21.919
21.920 - if (!gmyth_livetv_monitor_handler_start (livetv)) {
21.921 - res = FALSE;
21.922 - gmyth_debug ("LiveTV MONITOR handler error on setup!");
21.923 - goto error;
21.924 - }
21.925 + if (!gmyth_livetv_monitor_handler_start (livetv)) {
21.926 + res = FALSE;
21.927 + gmyth_debug ("LiveTV MONITOR handler error on setup!");
21.928 + goto error;
21.929 + }
21.930
21.931 - livetv->setup_done = TRUE;
21.932 + livetv->setup_done = TRUE;
21.933
21.934 - return res;
21.935 + return res;
21.936
21.937 - error:
21.938 - g_mutex_unlock (livetv->mutex);
21.939 +error:
21.940 + g_mutex_unlock (livetv->mutex);
21.941
21.942 - gmyth_debug ("[%s] ERROR running LiveTV setup.\n", __FUNCTION__);
21.943 + gmyth_debug ("[%s] ERROR running LiveTV setup.\n", __FUNCTION__);
21.944
21.945 - res = FALSE;
21.946 + res = FALSE;
21.947
21.948 - if (livetv->local_hostname != NULL) {
21.949 - g_string_free (livetv->local_hostname, TRUE);
21.950 - livetv->local_hostname = NULL;
21.951 - }
21.952 + if (livetv->local_hostname != NULL) {
21.953 + g_string_free (livetv->local_hostname, TRUE);
21.954 + livetv->local_hostname = NULL;
21.955 + }
21.956
21.957 - gmyth_debug ("[%s] ERROR running LiveTV setup.\n", __FUNCTION__);
21.958 + gmyth_debug ("[%s] ERROR running LiveTV setup.\n", __FUNCTION__);
21.959
21.960 - if (livetv->recorder != NULL) {
21.961 - g_object_unref (livetv->recorder);
21.962 - livetv->recorder = NULL;
21.963 - }
21.964 + if (livetv->recorder != NULL) {
21.965 + g_object_unref (livetv->recorder);
21.966 + livetv->recorder = NULL;
21.967 + }
21.968
21.969 - gmyth_debug ("[%s] ERROR running LiveTV setup.\n", __FUNCTION__);
21.970 + gmyth_debug ("[%s] ERROR running LiveTV setup.\n", __FUNCTION__);
21.971
21.972 - if (livetv->tvchain != NULL) {
21.973 - g_object_unref (livetv->tvchain);
21.974 - livetv->tvchain = NULL;
21.975 - }
21.976 + if (livetv->tvchain != NULL) {
21.977 + g_object_unref (livetv->tvchain);
21.978 + livetv->tvchain = NULL;
21.979 + }
21.980
21.981 - gmyth_debug ("[%s] ERROR running LiveTV setup.\n", __FUNCTION__);
21.982 + gmyth_debug ("[%s] ERROR running LiveTV setup.\n", __FUNCTION__);
21.983
21.984 - if (livetv->proginfo != NULL) {
21.985 - g_object_unref (livetv->proginfo);
21.986 - livetv->proginfo = NULL;
21.987 - }
21.988 + if (livetv->proginfo != NULL) {
21.989 + g_object_unref (livetv->proginfo);
21.990 + livetv->proginfo = NULL;
21.991 + }
21.992
21.993 - gmyth_debug ("[%s] ERROR running LiveTV setup.\n", __FUNCTION__);
21.994 + gmyth_debug ("[%s] ERROR running LiveTV setup.\n", __FUNCTION__);
21.995
21.996 - if (livetv->monitor != NULL) {
21.997 - g_object_unref (livetv->monitor);
21.998 - livetv->monitor = NULL;
21.999 - }
21.1000 + if (livetv->monitor != NULL) {
21.1001 + g_object_unref (livetv->monitor);
21.1002 + livetv->monitor = NULL;
21.1003 + }
21.1004
21.1005
21.1006 - gmyth_debug ("[%s] ERROR running LiveTV setup.\n", __FUNCTION__);
21.1007 + gmyth_debug ("[%s] ERROR running LiveTV setup.\n", __FUNCTION__);
21.1008
21.1009 - return res;
21.1010 + return res;
21.1011
21.1012 }
21.1013
21.1014 @@ -658,12 +657,12 @@
21.1015 * @return <code>true</code> if the LiveTV's recorder instance configuration
21.1016 * had been concluded succcesfully
21.1017 */
21.1018 -static gboolean
21.1019 + static gboolean
21.1020 gmyth_livetv_setup_recorder (GMythLiveTV * livetv, gint channel)
21.1021 {
21.1022 - return gmyth_livetv_setup_recorder_channel_name (livetv,
21.1023 - (channel != -1) ? g_strdup_printf ("%d", channel)
21.1024 - : NULL);
21.1025 + return gmyth_livetv_setup_recorder_channel_name (livetv,
21.1026 + (channel != -1) ? g_strdup_printf ("%d", channel)
21.1027 + : NULL);
21.1028 }
21.1029
21.1030 /**
21.1031 @@ -678,10 +677,10 @@
21.1032 * @return <code>true</code> if the LiveTV's recorder instance configuration
21.1033 * had been concluded succcesfully
21.1034 */
21.1035 -gboolean
21.1036 + gboolean
21.1037 gmyth_livetv_channel_setup (GMythLiveTV * livetv, gint channel)
21.1038 {
21.1039 - return gmyth_livetv_setup_recorder (livetv, channel);
21.1040 + return gmyth_livetv_setup_recorder (livetv, channel);
21.1041 }
21.1042
21.1043 /**
21.1044 @@ -696,10 +695,10 @@
21.1045 * @return <code>true</code> if the LiveTV's recorder instance configuration
21.1046 * had been concluded succcesfully
21.1047 */
21.1048 -gboolean
21.1049 + gboolean
21.1050 gmyth_livetv_channel_name_setup (GMythLiveTV * livetv, gchar * channel)
21.1051 {
21.1052 - return gmyth_livetv_setup_recorder_channel_name (livetv, channel);
21.1053 + return gmyth_livetv_setup_recorder_channel_name (livetv, channel);
21.1054 }
21.1055
21.1056 /**
21.1057 @@ -713,10 +712,10 @@
21.1058 * @return <code>true</code> if the LiveTV's recorder instance configuration
21.1059 * had been concluded succcesfully
21.1060 */
21.1061 -gboolean
21.1062 + gboolean
21.1063 gmyth_livetv_setup (GMythLiveTV * livetv)
21.1064 {
21.1065 - return gmyth_livetv_setup_recorder (livetv, -1);
21.1066 + return gmyth_livetv_setup_recorder (livetv, -1);
21.1067 }
21.1068
21.1069 /**
21.1070 @@ -726,72 +725,72 @@
21.1071 *
21.1072 * @return <code>true</code> if the next program info could be got
21.1073 */
21.1074 -gboolean
21.1075 + gboolean
21.1076 gmyth_livetv_next_program_chain (GMythLiveTV * livetv)
21.1077 {
21.1078 - gboolean res = TRUE;
21.1079 - GMythProgramInfo *prog_info = NULL;
21.1080 + gboolean res = TRUE;
21.1081 + GMythProgramInfo *prog_info = NULL;
21.1082
21.1083 - if (!livetv->setup_done) {
21.1084 - gmyth_debug ("Call the setup function first!");
21.1085 - goto error;
21.1086 - }
21.1087 + if (!livetv->setup_done) {
21.1088 + gmyth_debug ("Call the setup function first!");
21.1089 + goto error;
21.1090 + }
21.1091
21.1092 - gmyth_debug ("Current ProgramInfo...\n");
21.1093 - prog_info = gmyth_recorder_get_current_program_info (livetv->recorder);
21.1094 + gmyth_debug ("Current ProgramInfo...\n");
21.1095 + prog_info = gmyth_recorder_get_current_program_info (livetv->recorder);
21.1096
21.1097 - if (prog_info != NULL) {
21.1098 - livetv->proginfo = prog_info;
21.1099 - } else {
21.1100 - gmyth_debug
21.1101 - ("ProgramInfo equals to NULL!!! Getting the next program info...");
21.1102 - prog_info =
21.1103 - gmyth_recorder_get_next_program_info (livetv->recorder,
21.1104 - BROWSE_DIRECTION_RIGHT);
21.1105 - livetv->proginfo = prog_info;
21.1106 - }
21.1107 - /* prints program info data text */
21.1108 - gmyth_program_info_print (prog_info);
21.1109 + if (prog_info != NULL) {
21.1110 + livetv->proginfo = prog_info;
21.1111 + } else {
21.1112 + gmyth_debug
21.1113 + ("ProgramInfo equals to NULL!!! Getting the next program info...");
21.1114 + prog_info =
21.1115 + gmyth_recorder_get_next_program_info (livetv->recorder,
21.1116 + BROWSE_DIRECTION_RIGHT);
21.1117 + livetv->proginfo = prog_info;
21.1118 + }
21.1119 + /* prints program info data text */
21.1120 + gmyth_program_info_print (prog_info);
21.1121
21.1122 - if (prog_info != NULL) {
21.1123 - res = TRUE;
21.1124 - livetv->proginfo = prog_info;
21.1125 - gmyth_debug
21.1126 - ("GMythLiveTV: All requests to backend to start TV were OK, program info changed.");
21.1127 - } else {
21.1128 - gmyth_debug
21.1129 - ("[%s] LiveTV not successfully started on the next program chain.\n",
21.1130 - __FUNCTION__);
21.1131 - goto error;
21.1132 - }
21.1133 + if (prog_info != NULL) {
21.1134 + res = TRUE;
21.1135 + livetv->proginfo = prog_info;
21.1136 + gmyth_debug
21.1137 + ("GMythLiveTV: All requests to backend to start TV were OK, program info changed.");
21.1138 + } else {
21.1139 + gmyth_debug
21.1140 + ("[%s] LiveTV not successfully started on the next program chain.\n",
21.1141 + __FUNCTION__);
21.1142 + goto error;
21.1143 + }
21.1144
21.1145 - livetv->setup_done = TRUE;
21.1146 + livetv->setup_done = TRUE;
21.1147
21.1148 - return res;
21.1149 + return res;
21.1150
21.1151 - error:
21.1152 - gmyth_debug ("ERROR running LiveTV setup.\n");
21.1153 +error:
21.1154 + gmyth_debug ("ERROR running LiveTV setup.\n");
21.1155
21.1156 - res = FALSE;
21.1157 + res = FALSE;
21.1158
21.1159 - g_string_free (livetv->local_hostname, TRUE);
21.1160 + g_string_free (livetv->local_hostname, TRUE);
21.1161
21.1162 - if (livetv->recorder != NULL) {
21.1163 - g_object_unref (livetv->recorder);
21.1164 - livetv->recorder = NULL;
21.1165 - }
21.1166 + if (livetv->recorder != NULL) {
21.1167 + g_object_unref (livetv->recorder);
21.1168 + livetv->recorder = NULL;
21.1169 + }
21.1170
21.1171 - if (livetv->tvchain != NULL) {
21.1172 - g_object_unref (livetv->tvchain);
21.1173 - livetv->tvchain = NULL;
21.1174 - }
21.1175 + if (livetv->tvchain != NULL) {
21.1176 + g_object_unref (livetv->tvchain);
21.1177 + livetv->tvchain = NULL;
21.1178 + }
21.1179
21.1180 - if (livetv->proginfo != NULL) {
21.1181 - g_object_unref (livetv->proginfo);
21.1182 - livetv->proginfo = NULL;
21.1183 - }
21.1184 + if (livetv->proginfo != NULL) {
21.1185 + g_object_unref (livetv->proginfo);
21.1186 + livetv->proginfo = NULL;
21.1187 + }
21.1188
21.1189 - return res;
21.1190 + return res;
21.1191 }
21.1192
21.1193 /**
21.1194 @@ -803,85 +802,85 @@
21.1195 * @return the actual GMythFileTransfer instance, generated using the
21.1196 * data got from the actual program info.
21.1197 */
21.1198 -GMythFile *
21.1199 + GMythFile *
21.1200 gmyth_livetv_create_file_transfer (GMythLiveTV * livetv)
21.1201 {
21.1202 - //GMythURI* uri = NULL;
21.1203 + //GMythURI* uri = NULL;
21.1204
21.1205 - if (NULL == livetv)
21.1206 - goto done;
21.1207 + if (NULL == livetv)
21.1208 + goto done;
21.1209
21.1210 - if (!livetv->setup_done) {
21.1211 - gmyth_debug
21.1212 - ("Error: You must do the LiveTV setup, just before generating the FileTransfer from LiveTV source!");
21.1213 - goto done;
21.1214 - }
21.1215 + if (!livetv->setup_done) {
21.1216 + gmyth_debug
21.1217 + ("Error: You must do the LiveTV setup, just before generating the FileTransfer from LiveTV source!");
21.1218 + goto done;
21.1219 + }
21.1220
21.1221 - if (livetv->proginfo != NULL)
21.1222 - gmyth_debug ("URI path (from program info) = %s.\n",
21.1223 - livetv->proginfo->pathname->str);
21.1224 - else
21.1225 - gmyth_debug ("URI path (from URI) = %s.\n", livetv->uri->uri->str);
21.1226 + if (livetv->proginfo != NULL)
21.1227 + gmyth_debug ("URI path (from program info) = %s.\n",
21.1228 + livetv->proginfo->pathname->str);
21.1229 + else
21.1230 + gmyth_debug ("URI path (from URI) = %s.\n", livetv->uri->uri->str);
21.1231
21.1232 - g_mutex_lock (livetv->mutex);
21.1233 + g_mutex_lock (livetv->mutex);
21.1234
21.1235 - if (livetv->file != NULL) {
21.1236 - /*gmyth_file_transfer_close( livetv->file ); */
21.1237 - g_object_unref (livetv->file);
21.1238 - livetv->file = NULL;
21.1239 - }
21.1240 + if (livetv->file != NULL) {
21.1241 + /*gmyth_file_transfer_close( livetv->file ); */
21.1242 + g_object_unref (livetv->file);
21.1243 + livetv->file = NULL;
21.1244 + }
21.1245
21.1246 - if (livetv->uri != NULL) {
21.1247 - gmyth_debug
21.1248 - ("URI is not NULL, creating from the ProgramInfo pathname... (%s)",
21.1249 - livetv->proginfo->pathname->str);
21.1250 - livetv->uri->path = g_string_erase (livetv->uri->path, 0, -1);
21.1251 - livetv->uri->path =
21.1252 - g_string_new (g_strrstr (livetv->proginfo->pathname->str, "/"));
21.1253 - } else {
21.1254 - gmyth_debug
21.1255 - ("URI is NULL, creating from the ProgramInfo pathname... (%s)",
21.1256 - livetv->proginfo->pathname->str);
21.1257 - livetv->uri =
21.1258 - gmyth_uri_new_with_value (livetv->proginfo->pathname->str);
21.1259 - }
21.1260 + if (livetv->uri != NULL) {
21.1261 + gmyth_debug
21.1262 + ("URI is not NULL, creating from the ProgramInfo pathname... (%s)",
21.1263 + livetv->proginfo->pathname->str);
21.1264 + livetv->uri->path = g_string_erase (livetv->uri->path, 0, -1);
21.1265 + livetv->uri->path =
21.1266 + g_string_new (g_strrstr (livetv->proginfo->pathname->str, "/"));
21.1267 + } else {
21.1268 + gmyth_debug
21.1269 + ("URI is NULL, creating from the ProgramInfo pathname... (%s)",
21.1270 + livetv->proginfo->pathname->str);
21.1271 + livetv->uri =
21.1272 + gmyth_uri_new_with_value (livetv->proginfo->pathname->str);
21.1273 + }
21.1274
21.1275 - if (NULL == livetv->uri) {
21.1276 - gmyth_debug ("Couldn't parse the URI to start LiveTV! [ uri = %s ]",
21.1277 - livetv->proginfo->pathname->str);
21.1278 - goto done;
21.1279 - }
21.1280 + if (NULL == livetv->uri) {
21.1281 + gmyth_debug ("Couldn't parse the URI to start LiveTV! [ uri = %s ]",
21.1282 + livetv->proginfo->pathname->str);
21.1283 + goto done;
21.1284 + }
21.1285
21.1286 - if (gmyth_uri_is_local_file (livetv->uri))
21.1287 - livetv->file = GMYTH_FILE (gmyth_file_local_new (livetv->backend_info));
21.1288 - else {
21.1289 - livetv->file =
21.1290 - GMYTH_FILE (gmyth_file_transfer_new (livetv->backend_info));
21.1291 - /* gmyth_file_transfer_settimeout( GMYTH_FILE_TRANSFER(livetv->file), TRUE ); */
21.1292 - }
21.1293 + if (gmyth_uri_is_local_file (livetv->uri))
21.1294 + livetv->file = GMYTH_FILE (gmyth_file_local_new (livetv->backend_info));
21.1295 + else {
21.1296 + livetv->file =
21.1297 + GMYTH_FILE (gmyth_file_transfer_new (livetv->backend_info));
21.1298 + /* gmyth_file_transfer_settimeout( GMYTH_FILE_TRANSFER(livetv->file), TRUE ); */
21.1299 + }
21.1300
21.1301 - if (NULL == livetv->file) {
21.1302 - gmyth_debug
21.1303 - ("Error: couldn't create the FileTransfer from LiveTV source!");
21.1304 - goto done;
21.1305 - }
21.1306 + if (NULL == livetv->file) {
21.1307 + gmyth_debug
21.1308 + ("Error: couldn't create the FileTransfer from LiveTV source!");
21.1309 + goto done;
21.1310 + }
21.1311
21.1312 - g_object_ref (livetv->file);
21.1313 + g_object_ref (livetv->file);
21.1314
21.1315 - g_mutex_unlock (livetv->mutex);
21.1316 + g_mutex_unlock (livetv->mutex);
21.1317
21.1318 - /* Do some locking procedure with the Monitor Handler messages... */
21.1319 + /* Do some locking procedure with the Monitor Handler messages... */
21.1320
21.1321 - done:
21.1322 - /*
21.1323 - if ( uri != NULL )
21.1324 - {
21.1325 - g_object_unref( uri );
21.1326 - uri = NULL;
21.1327 - }
21.1328 - */
21.1329 +done:
21.1330 + /*
21.1331 + if ( uri != NULL )
21.1332 + {
21.1333 + g_object_unref( uri );
21.1334 + uri = NULL;
21.1335 + }
21.1336 + */
21.1337
21.1338 - return livetv->file;
21.1339 + return livetv->file;
21.1340
21.1341 }
21.1342
21.1343 @@ -890,35 +889,35 @@
21.1344 *
21.1345 * @param live_tv the GMythLiveTV instance
21.1346 */
21.1347 -void
21.1348 + void
21.1349 gmyth_livetv_stop_playing (GMythLiveTV * livetv)
21.1350 {
21.1351 - gmyth_debug ("Stopping the LiveTV...\n");
21.1352 + gmyth_debug ("Stopping the LiveTV...\n");
21.1353
21.1354 - if (livetv->is_livetv) {
21.1355 - if (!gmyth_recorder_stop_livetv (livetv->recorder)) {
21.1356 - gmyth_debug ("[%s] Error while stoping remote encoder",
21.1357 - __FUNCTION__);
21.1358 - }
21.1359 + if (livetv->is_livetv) {
21.1360 + if (!gmyth_recorder_stop_livetv (livetv->recorder)) {
21.1361 + gmyth_debug ("[%s] Error while stoping remote encoder",
21.1362 + __FUNCTION__);
21.1363 + }
21.1364
21.1365 - if (!gmyth_recorder_finish_recording (livetv->recorder)) {
21.1366 - gmyth_debug
21.1367 - ("[%s] Error while finishing recording on remote encoder",
21.1368 - __FUNCTION__);
21.1369 - }
21.1370 - }
21.1371 + if (!gmyth_recorder_finish_recording (livetv->recorder)) {
21.1372 + gmyth_debug
21.1373 + ("[%s] Error while finishing recording on remote encoder",
21.1374 + __FUNCTION__);
21.1375 + }
21.1376 + }
21.1377 }
21.1378
21.1379 -gboolean
21.1380 + gboolean
21.1381 gmyth_livetv_is_playing (GMythLiveTV * livetv)
21.1382 {
21.1383 - return TRUE;
21.1384 + return TRUE;
21.1385 }
21.1386
21.1387 -void
21.1388 + void
21.1389 gmyth_livetv_start_playing (GMythLiveTV * livetv)
21.1390 {
21.1391
21.1392 - // TODO
21.1393 + // TODO
21.1394
21.1395 }
22.1 --- a/gmyth/src/gmyth_livetv.h Wed May 23 19:21:26 2007 +0100
22.2 +++ b/gmyth/src/gmyth_livetv.h Wed May 23 19:50:41 2007 +0100
22.3 @@ -8,22 +8,21 @@
22.4 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
22.5 * @author Rosfran Lins Borges <rosfran.borges@indt.org.br>
22.6 *
22.7 - *//*
22.8 - *
22.9 - * This program is free software; you can redistribute it and/or modify
22.10 - * it under the terms of the GNU Lesser General Public License as published by
22.11 - * the Free Software Foundation; either version 2 of the License, or
22.12 - * (at your option) any later version.
22.13 - *
22.14 - * This program is distributed in the hope that it will be useful,
22.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
22.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22.17 - * GNU General Public License for more details.
22.18 - *
22.19 - * You should have received a copy of the GNU Lesser General Public License
22.20 - * along with this program; if not, write to the Free Software
22.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22.22 - */
22.23 +*
22.24 +* This program is free software; you can redistribute it and/or modify
22.25 +* it under the terms of the GNU Lesser General Public License as published by
22.26 +* the Free Software Foundation; either version 2 of the License, or
22.27 +* (at your option) any later version.
22.28 +*
22.29 +* This program is distributed in the hope that it will be useful,
22.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
22.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22.32 + * GNU General Public License for more details.
22.33 + *
22.34 + * You should have received a copy of the GNU Lesser General Public License
22.35 + * along with this program; if not, write to the Free Software
22.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22.37 + */
22.38
22.39 #ifndef GMYTH_LIVETV_H_
22.40 #define GMYTH_LIVETV_H_
22.41 @@ -49,55 +48,55 @@
22.42 typedef struct _GMythLiveTVClass GMythLiveTVClass;
22.43
22.44 struct _GMythLiveTVClass
22.45 -{
22.46 - GObjectClass parent_class;
22.47 + {
22.48 + GObjectClass parent_class;
22.49
22.50 - /* callbacks */
22.51 -};
22.52 + /* callbacks */
22.53 + };
22.54
22.55 struct _GMythLiveTV
22.56 -{
22.57 - GObject parent;
22.58 + {
22.59 + GObject parent;
22.60
22.61 - GMythSocket *socket;
22.62 + GMythSocket *socket;
22.63
22.64 - GString *local_hostname;
22.65 + GString *local_hostname;
22.66
22.67 - GMythBackendInfo *backend_info;
22.68 + GMythBackendInfo *backend_info;
22.69
22.70 - GMythRecorder *recorder;
22.71 - GMythTVChain *tvchain;
22.72 - GMythProgramInfo *proginfo;
22.73 + GMythRecorder *recorder;
22.74 + GMythTVChain *tvchain;
22.75 + GMythProgramInfo *proginfo;
22.76
22.77 - GMythFile *file;
22.78 + GMythFile *file;
22.79
22.80 - GMythMonitorHandler *monitor;
22.81 - GMythURI *uri;
22.82 + GMythMonitorHandler *monitor;
22.83 + GMythURI *uri;
22.84
22.85 - gboolean is_livetv;
22.86 - gboolean setup_done;
22.87 + gboolean is_livetv;
22.88 + gboolean setup_done;
22.89
22.90 - GMutex *mutex;
22.91 - gboolean disposed;
22.92 -};
22.93 + GMutex *mutex;
22.94 + gboolean disposed;
22.95 + };
22.96
22.97 -GType gmyth_livetv_get_type (void);
22.98 +GType gmyth_livetv_get_type ( void );
22.99
22.100 -GMythLiveTV *gmyth_livetv_new (GMythBackendInfo * backend_info);
22.101 +GMythLiveTV *gmyth_livetv_new ( GMythBackendInfo * backend_info );
22.102
22.103 -void gmyth_livetv_start_playing (GMythLiveTV * livetv);
22.104 -void gmyth_livetv_stop_playing (GMythLiveTV * livetv);
22.105 +void gmyth_livetv_start_playing ( GMythLiveTV * livetv );
22.106 +void gmyth_livetv_stop_playing ( GMythLiveTV * livetv );
22.107
22.108 -gboolean gmyth_livetv_setup (GMythLiveTV * livetv);
22.109 -gboolean gmyth_livetv_channel_setup (GMythLiveTV * livetv, gint channel);
22.110 -gboolean gmyth_livetv_channel_name_setup (GMythLiveTV * livetv,
22.111 - gchar * channel);
22.112 -gboolean gmyth_livetv_next_program_chain (GMythLiveTV * livetv);
22.113 +gboolean gmyth_livetv_setup ( GMythLiveTV * livetv );
22.114 +gboolean gmyth_livetv_channel_setup ( GMythLiveTV * livetv, gint channel );
22.115 +gboolean gmyth_livetv_channel_name_setup ( GMythLiveTV * livetv,
22.116 + gchar * channel );
22.117 +gboolean gmyth_livetv_next_program_chain ( GMythLiveTV * livetv );
22.118
22.119 -GMythFile *gmyth_livetv_create_file_transfer (GMythLiveTV * livetv);
22.120 +GMythFile *gmyth_livetv_create_file_transfer ( GMythLiveTV * livetv );
22.121
22.122 -gboolean gmyth_livetv_monitor_handler_start (GMythLiveTV * livetv);
22.123 -void gmyth_livetv_monitor_handler_stop (GMythLiveTV * livetv);
22.124 +gboolean gmyth_livetv_monitor_handler_start ( GMythLiveTV * livetv );
22.125 +void gmyth_livetv_monitor_handler_stop ( GMythLiveTV * livetv );
22.126
22.127 G_END_DECLS
22.128 #endif /*GMYTH_LIVETV_H_ */
23.1 --- a/gmyth/src/gmyth_monitor_handler.c Wed May 23 19:21:26 2007 +0100
23.2 +++ b/gmyth/src/gmyth_monitor_handler.c Wed May 23 19:50:41 2007 +0100
23.3 @@ -9,27 +9,26 @@
23.4 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
23.5 * @author Rosfran Lins Borges <rosfran.borges@indt.org.br>
23.6 *
23.7 - *//*
23.8 - *
23.9 - * This program is free software; you can redistribute it and/or modify
23.10 - * it under the terms of the GNU Lesser General Public License as published by
23.11 - * the Free Software Foundation; either version 2 of the License, or
23.12 - * (at your option) any later version.
23.13 - *
23.14 - * This program is distributed in the hope that it will be useful,
23.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
23.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23.17 - * GNU General Public License for more details.
23.18 - *
23.19 - * You should have received a copy of the GNU Lesser General Public License
23.20 - * along with this program; if not, write to the Free Software
23.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23.22 - *
23.23 - * GStreamer MythTV plug-in properties:
23.24 - * - location (backend server hostname/URL) [ex.: myth://192.168.1.73:28722/1000_1092091.nuv]
23.25 - * - path (qurl - remote file to be opened)
23.26 - * - port number *
23.27 - */
23.28 + *
23.29 + * This program is free software; you can redistribute it and/or modify
23.30 + * it under the terms of the GNU Lesser General Public License as published by
23.31 + * the Free Software Foundation; either version 2 of the License, or
23.32 + * (at your option) any later version.
23.33 + *
23.34 + * This program is distributed in the hope that it will be useful,
23.35 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
23.36 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23.37 + * GNU General Public License for more details.
23.38 + *
23.39 + * You should have received a copy of the GNU Lesser General Public License
23.40 + * along with this program; if not, write to the Free Software
23.41 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23.42 + *
23.43 + * GStreamer MythTV plug-in properties:
23.44 + * - location (backend server hostname/URL) [ex.: myth://192.168.1.73:28722/1000_1092091.nuv]
23.45 + * - path (qurl - remote file to be opened)
23.46 + * - port number *
23.47 + */
23.48
23.49 #ifdef HAVE_CONFIG_H
23.50 #include "config.h"
23.51 @@ -69,45 +68,47 @@
23.52 #define GMYTHTV_ENABLE_DEBUG 1
23.53 #endif
23.54
23.55 -gpointer gmyth_monitor_handler_listener (gpointer data);
23.56 +gpointer gmyth_monitor_handler_listener ( gpointer data );
23.57
23.58 -static void gmyth_monitor_handler_default_listener (GMythMonitorHandler *
23.59 - monitor, gint msg_code, gchar * message);
23.60 +static void gmyth_monitor_handler_default_listener ( GMythMonitorHandler *
23.61 + monitor, gint msg_code,
23.62 + gchar * message );
23.63
23.64 -static void gmyth_monitor_handler_class_init (GMythMonitorHandlerClass * klass);
23.65 -static void gmyth_monitor_handler_init (GMythMonitorHandler * object);
23.66 +static void gmyth_monitor_handler_class_init ( GMythMonitorHandlerClass *
23.67 + klass );
23.68 +static void gmyth_monitor_handler_init ( GMythMonitorHandler * object );
23.69
23.70 -static void gmyth_monitor_handler_dispose (GObject * object);
23.71 -static void gmyth_monitor_handler_finalize (GObject * object);
23.72 +static void gmyth_monitor_handler_dispose ( GObject * object );
23.73 +static void gmyth_monitor_handler_finalize ( GObject * object );
23.74
23.75 -static gboolean gmyth_connect_to_backend_monitor (GMythMonitorHandler *
23.76 - monitor);
23.77 +static gboolean gmyth_connect_to_backend_monitor ( GMythMonitorHandler *
23.78 + monitor );
23.79
23.80 -static gboolean gmyth_monitor_handler_setup (GMythMonitorHandler * monitor,
23.81 - GIOChannel * channel);
23.82 +static gboolean gmyth_monitor_handler_setup ( GMythMonitorHandler * monitor,
23.83 + GIOChannel * channel );
23.84
23.85 -void gmyth_monitor_handler_close (GMythMonitorHandler * monitor);
23.86 +void gmyth_monitor_handler_close ( GMythMonitorHandler * monitor );
23.87
23.88 -G_DEFINE_TYPE (GMythMonitorHandler, gmyth_monitor_handler, G_TYPE_OBJECT)
23.89 +G_DEFINE_TYPE ( GMythMonitorHandler, gmyth_monitor_handler, G_TYPE_OBJECT )
23.90 static void
23.91 - gmyth_monitor_handler_class_init (GMythMonitorHandlerClass * klass)
23.92 + gmyth_monitor_handler_class_init ( GMythMonitorHandlerClass * klass )
23.93 {
23.94 GObjectClass *gobject_class;
23.95 GMythMonitorHandlerClass *gmonitor_class;
23.96
23.97 - gobject_class = (GObjectClass *) klass;
23.98 - gmonitor_class = (GMythMonitorHandlerClass *) gobject_class;
23.99 + gobject_class = ( GObjectClass * ) klass;
23.100 + gmonitor_class = ( GMythMonitorHandlerClass * ) gobject_class;
23.101
23.102 gobject_class->dispose = gmyth_monitor_handler_dispose;
23.103 gobject_class->finalize = gmyth_monitor_handler_finalize;
23.104
23.105 gmonitor_class->backend_events_handler_signal_id =
23.106 - g_signal_new ("backend-events-handler",
23.107 - G_TYPE_FROM_CLASS (gmonitor_class),
23.108 - G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE |
23.109 - G_SIGNAL_NO_HOOKS, 0, NULL, NULL,
23.110 - gmyth_marshal_VOID__INT_STRING, G_TYPE_NONE, 2,
23.111 - G_TYPE_INT, G_TYPE_STRING);
23.112 + g_signal_new ( "backend-events-handler",
23.113 + G_TYPE_FROM_CLASS ( gmonitor_class ),
23.114 + G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE |
23.115 + G_SIGNAL_NO_HOOKS, 0, NULL, NULL,
23.116 + gmyth_marshal_VOID__INT_STRING, G_TYPE_NONE, 2,
23.117 + G_TYPE_INT, G_TYPE_STRING );
23.118
23.119 gmonitor_class->backend_events_handler =
23.120 gmyth_monitor_handler_default_listener;
23.121 @@ -115,9 +116,9 @@
23.122 }
23.123
23.124 static void
23.125 -gmyth_monitor_handler_init (GMythMonitorHandler * monitor)
23.126 +gmyth_monitor_handler_init ( GMythMonitorHandler * monitor )
23.127 {
23.128 - g_return_if_fail (monitor != NULL);
23.129 + g_return_if_fail ( monitor != NULL );
23.130
23.131 monitor->event_sock = NULL;
23.132 monitor->hostname = NULL;
23.133 @@ -129,7 +130,7 @@
23.134 /* monitor->backend_msgs = g_hash_table_new( g_int_hash, g_int_equal ); */
23.135
23.136 /* it is used for signalizing the event socket consumer thread */
23.137 - monitor->mutex = g_mutex_new ();
23.138 + monitor->mutex = g_mutex_new ( );
23.139
23.140 monitor->th = NULL;
23.141
23.142 @@ -137,43 +138,48 @@
23.143 }
23.144
23.145 static void
23.146 -gmyth_monitor_handler_dispose (GObject * object)
23.147 +gmyth_monitor_handler_dispose ( GObject * object )
23.148 {
23.149 - GMythMonitorHandler *monitor = GMYTH_MONITOR_HANDLER (object);
23.150 + GMythMonitorHandler *monitor = GMYTH_MONITOR_HANDLER ( object );
23.151
23.152 - gmyth_monitor_handler_close (monitor);
23.153 + gmyth_monitor_handler_close ( monitor );
23.154
23.155 monitor->allow_msgs_listener = FALSE;
23.156
23.157 - if (monitor->th != NULL) {
23.158 - gboolean *ret = (gboolean *) g_thread_join (monitor->th);
23.159 + if ( monitor->th != NULL )
23.160 + {
23.161 + gboolean *ret = ( gboolean * ) g_thread_join ( monitor->th );
23.162
23.163 - if (*ret == FALSE)
23.164 - gmyth_debug ("Error closing GThread listener socket!");
23.165 + if ( *ret == FALSE )
23.166 + gmyth_debug ( "Error closing GThread listener socket!" );
23.167 else
23.168 - gmyth_debug ("Closed GThread listener socket.");
23.169 + gmyth_debug ( "Closed GThread listener socket." );
23.170 //g_object_unref( monitor->th );
23.171 }
23.172
23.173 /* mutex to control access to the event socket consumer thread */
23.174 - if (monitor->mutex != NULL) {
23.175 + if ( monitor->mutex != NULL )
23.176 + {
23.177 //g_mutex_unlock( monitor->mutex );
23.178 - g_mutex_free (monitor->mutex);
23.179 + g_mutex_free ( monitor->mutex );
23.180 monitor->mutex = NULL;
23.181 }
23.182
23.183 - if (monitor->event_sock != NULL) {
23.184 - g_object_unref (monitor->event_sock);
23.185 + if ( monitor->event_sock != NULL )
23.186 + {
23.187 + g_object_unref ( monitor->event_sock );
23.188 monitor->event_sock = NULL;
23.189 }
23.190
23.191 - if (monitor->hostname != NULL) {
23.192 - g_free (monitor->hostname);
23.193 + if ( monitor->hostname != NULL )
23.194 + {
23.195 + g_free ( monitor->hostname );
23.196 monitor->hostname = NULL;
23.197 }
23.198
23.199 - if (monitor->backend_msgs != NULL) {
23.200 - g_hash_table_destroy (monitor->backend_msgs);
23.201 + if ( monitor->backend_msgs != NULL )
23.202 + {
23.203 + g_hash_table_destroy ( monitor->backend_msgs );
23.204 monitor->backend_msgs = NULL;
23.205 }
23.206
23.207 @@ -185,15 +191,15 @@
23.208 }
23.209 */
23.210
23.211 - G_OBJECT_CLASS (gmyth_monitor_handler_parent_class)->dispose (object);
23.212 + G_OBJECT_CLASS ( gmyth_monitor_handler_parent_class )->dispose ( object );
23.213 }
23.214
23.215 static void
23.216 -gmyth_monitor_handler_finalize (GObject * object)
23.217 +gmyth_monitor_handler_finalize ( GObject * object )
23.218 {
23.219 - g_signal_handlers_destroy (object);
23.220 + g_signal_handlers_destroy ( object );
23.221
23.222 - G_OBJECT_CLASS (gmyth_monitor_handler_parent_class)->finalize (object);
23.223 + G_OBJECT_CLASS ( gmyth_monitor_handler_parent_class )->finalize ( object );
23.224 }
23.225
23.226 /**
23.227 @@ -202,11 +208,11 @@
23.228 * @return a new instance of the Monitor Handler.
23.229 */
23.230 GMythMonitorHandler *
23.231 -gmyth_monitor_handler_new (void)
23.232 +gmyth_monitor_handler_new ( void )
23.233 {
23.234 GMythMonitorHandler *monitor =
23.235 - GMYTH_MONITOR_HANDLER (g_object_new
23.236 - (GMYTH_MONITOR_HANDLER_TYPE, FALSE));
23.237 + GMYTH_MONITOR_HANDLER ( g_object_new
23.238 + ( GMYTH_MONITOR_HANDLER_TYPE, FALSE ) );
23.239
23.240 return monitor;
23.241 }
23.242 @@ -220,12 +226,12 @@
23.243 * @return <code>true</code>, if the access to IO Watcher was acquired.
23.244 */
23.245 static gboolean
23.246 -myth_control_acquire_context (GMythMonitorHandler * monitor, gboolean do_wait)
23.247 +myth_control_acquire_context ( GMythMonitorHandler * monitor, gboolean do_wait )
23.248 {
23.249
23.250 gboolean ret = TRUE;
23.251
23.252 - g_mutex_lock (monitor->mutex);
23.253 + g_mutex_lock ( monitor->mutex );
23.254
23.255 return ret;
23.256
23.257 @@ -239,32 +245,34 @@
23.258 * @return <code>true</code>, if the access to IO Watcher was released.
23.259 */
23.260 static gboolean
23.261 -myth_control_release_context (GMythMonitorHandler * monitor)
23.262 +myth_control_release_context ( GMythMonitorHandler * monitor )
23.263 {
23.264
23.265 gboolean ret = TRUE;
23.266
23.267 - g_mutex_unlock (monitor->mutex);
23.268 + g_mutex_unlock ( monitor->mutex );
23.269
23.270 return ret;
23.271 }
23.272
23.273 void
23.274 -gmyth_monitor_handler_close (GMythMonitorHandler * monitor)
23.275 +gmyth_monitor_handler_close ( GMythMonitorHandler * monitor )
23.276 {
23.277 monitor->allow_msgs_listener = FALSE;
23.278
23.279 #if 0
23.280 - if (monitor->monitor_th != NULL) {
23.281 - g_thread_pool_free (monitor->monitor_th, TRUE, FALSE);
23.282 + if ( monitor->monitor_th != NULL )
23.283 + {
23.284 + g_thread_pool_free ( monitor->monitor_th, TRUE, FALSE );
23.285 //g_thread_exit( monitor->monitor_th );
23.286 /*if ( monitor->monitor_th != NULL )
23.287 g_object_unref( monitor->monitor_th ); */
23.288 monitor->monitor_th = NULL;
23.289 }
23.290
23.291 - if (monitor->event_sock != NULL) {
23.292 - gmyth_socket_close_connection (monitor->event_sock);
23.293 + if ( monitor->event_sock != NULL )
23.294 + {
23.295 + gmyth_socket_close_connection ( monitor->event_sock );
23.296 }
23.297 #endif
23.298
23.299 @@ -281,42 +289,50 @@
23.300 * @return <code>true</code>, if the connection was successfully opened.
23.301 */
23.302 gboolean
23.303 -gmyth_monitor_handler_open (GMythMonitorHandler * monitor,
23.304 - const gchar * hostname, gint port)
23.305 +gmyth_monitor_handler_open ( GMythMonitorHandler * monitor,
23.306 + const gchar * hostname, gint port )
23.307 {
23.308 gboolean ret = TRUE;
23.309
23.310 - g_return_val_if_fail (hostname != NULL, FALSE);
23.311 + g_return_val_if_fail ( hostname != NULL, FALSE );
23.312
23.313 - if (monitor->hostname != NULL) {
23.314 - g_free (monitor->hostname);
23.315 + if ( monitor->hostname != NULL )
23.316 + {
23.317 + g_free ( monitor->hostname );
23.318 monitor->hostname = NULL;
23.319 }
23.320
23.321 - monitor->hostname = g_strdup (hostname);
23.322 + monitor->hostname = g_strdup ( hostname );
23.323 monitor->port = port;
23.324
23.325 - gmyth_debug ("Monitor event socket --- hostname: %s, port %d\n",
23.326 - monitor->hostname, monitor->port);
23.327 + gmyth_debug ( "Monitor event socket --- hostname: %s, port %d\n",
23.328 + monitor->hostname, monitor->port );
23.329
23.330 - if (NULL != monitor->event_sock) {
23.331 - g_object_unref (monitor->event_sock);
23.332 + if ( NULL != monitor->event_sock )
23.333 + {
23.334 + g_object_unref ( monitor->event_sock );
23.335 monitor->event_sock = NULL;
23.336 }
23.337
23.338 /* configure the event socket */
23.339 - if (NULL == monitor->event_sock) {
23.340 - if (!gmyth_connect_to_backend_monitor (monitor)) {
23.341 - gmyth_debug ("Connection to backend failed (Event Socket)!");
23.342 + if ( NULL == monitor->event_sock )
23.343 + {
23.344 + if ( !gmyth_connect_to_backend_monitor ( monitor ) )
23.345 + {
23.346 + gmyth_debug ( "Connection to backend failed (Event Socket)!" );
23.347 ret = FALSE;
23.348 - } else {
23.349 + }
23.350 + else
23.351 + {
23.352 gmyth_debug
23.353 - ("Remote monitor event socket had been succesfully created. (io_fd == %d)\n",
23.354 - g_io_channel_unix_get_fd (monitor->event_sock->sd_io_ch));
23.355 + ( "Remote monitor event socket had been succesfully created. (io_fd == %d)\n",
23.356 + g_io_channel_unix_get_fd ( monitor->event_sock->sd_io_ch ) );
23.357 }
23.358 - } else {
23.359 + }
23.360 + else
23.361 + {
23.362 gmyth_debug
23.363 - ("ASSERT ERROR: Remote monitor event socket is not NULL at the setup...\n");
23.364 + ( "ASSERT ERROR: Remote monitor event socket is not NULL at the setup...\n" );
23.365 }
23.366
23.367 return ret;
23.368 @@ -334,48 +350,61 @@
23.369 * @return The backend status message code ID.
23.370 */
23.371 static gint
23.372 -gmyth_monitor_handler_is_backend_message (GMythMonitorHandler * monitor,
23.373 - GMythStringList * strlist, gchar ** back_msg_action)
23.374 +gmyth_monitor_handler_is_backend_message ( GMythMonitorHandler * monitor,
23.375 + GMythStringList * strlist,
23.376 + gchar ** back_msg_action )
23.377 {
23.378 gint msg_type = GMYTH_BACKEND_NO_MESSAGE;
23.379 GString *back_msg = NULL;
23.380
23.381 - if (gmyth_string_list_length (strlist) > 0) {
23.382 + if ( gmyth_string_list_length ( strlist ) > 0 )
23.383 + {
23.384
23.385 - back_msg = gmyth_string_list_get_string (strlist, 0);
23.386 - if (back_msg != NULL && back_msg->str != NULL &&
23.387 - strstr (back_msg->str, "BACKEND") != NULL) {
23.388 - gmyth_debug ("MONITOR HANDLER - Received backend message = %s",
23.389 - back_msg->str);
23.390 - *back_msg_action = gmyth_string_list_get_char_array (strlist, 1);
23.391 + back_msg = gmyth_string_list_get_string ( strlist, 0 );
23.392 + if ( back_msg != NULL && back_msg->str != NULL &&
23.393 + strstr ( back_msg->str, "BACKEND" ) != NULL )
23.394 + {
23.395 + gmyth_debug ( "MONITOR HANDLER - Received backend message = %s",
23.396 + back_msg->str );
23.397 + *back_msg_action = gmyth_string_list_get_char_array ( strlist, 1 );
23.398
23.399 - if (back_msg_action != NULL) {
23.400 + if ( back_msg_action != NULL )
23.401 + {
23.402
23.403 - if (g_strstr_len
23.404 - (*back_msg_action, strlen (*back_msg_action),
23.405 - "LIVETV_CHAIN")
23.406 - || g_strstr_len (*back_msg_action,
23.407 - strlen (*back_msg_action), "RECORDING_LIST_CHANGE")
23.408 - || g_strstr_len (*back_msg_action,
23.409 - strlen (*back_msg_action), "SCHEDULE_CHANGE")
23.410 - || g_strstr_len (*back_msg_action,
23.411 - strlen (*back_msg_action), "LIVETV_WATCH")) {
23.412 + if ( g_strstr_len
23.413 + ( *back_msg_action, strlen ( *back_msg_action ),
23.414 + "LIVETV_CHAIN" )
23.415 + || g_strstr_len ( *back_msg_action,
23.416 + strlen ( *back_msg_action ),
23.417 + "RECORDING_LIST_CHANGE" )
23.418 + || g_strstr_len ( *back_msg_action,
23.419 + strlen ( *back_msg_action ),
23.420 + "SCHEDULE_CHANGE" )
23.421 + || g_strstr_len ( *back_msg_action,
23.422 + strlen ( *back_msg_action ),
23.423 + "LIVETV_WATCH" ) )
23.424 + {
23.425 gmyth_debug
23.426 - ("MONITOR: message type == GMYTH_BACKEND_PROGRAM_INFO_CHANGED, msg = %s",
23.427 - *back_msg_action);
23.428 + ( "MONITOR: message type == GMYTH_BACKEND_PROGRAM_INFO_CHANGED, msg = %s",
23.429 + *back_msg_action );
23.430 msg_type = GMYTH_BACKEND_PROGRAM_INFO_CHANGED;
23.431 - } else if (g_strstr_len
23.432 - (*back_msg_action, strlen (*back_msg_action),
23.433 - "DONE_RECORDING")) {
23.434 + }
23.435 + else if ( g_strstr_len
23.436 + ( *back_msg_action, strlen ( *back_msg_action ),
23.437 + "DONE_RECORDING" ) )
23.438 + {
23.439 gmyth_debug
23.440 - ("MONITOR: message type == GMYTH_BACKEND_DONE_RECORDING, msg = %s",
23.441 - *back_msg_action);
23.442 + ( "MONITOR: message type == GMYTH_BACKEND_DONE_RECORDING, msg = %s",
23.443 + *back_msg_action );
23.444 msg_type = GMYTH_BACKEND_DONE_RECORDING;
23.445 - } else if (g_strstr_len
23.446 - (*back_msg_action, strlen (*back_msg_action), "QUIT")) {
23.447 + }
23.448 + else if ( g_strstr_len
23.449 + ( *back_msg_action, strlen ( *back_msg_action ),
23.450 + "QUIT" ) )
23.451 + {
23.452 gmyth_debug
23.453 - ("MONITOR: message type == GMYTH_BACKEND_STOP_LIVETV, msg = %s",
23.454 - *back_msg_action);
23.455 + ( "MONITOR: message type == GMYTH_BACKEND_STOP_LIVETV, msg = %s",
23.456 + *back_msg_action );
23.457 msg_type = GMYTH_BACKEND_STOP_LIVETV;
23.458 }
23.459
23.460 @@ -386,14 +415,16 @@
23.461 /* if */
23.462 }
23.463 /* if */
23.464 - if (back_msg != NULL) {
23.465 - g_string_free (back_msg, TRUE);
23.466 + if ( back_msg != NULL )
23.467 + {
23.468 + g_string_free ( back_msg, TRUE );
23.469 back_msg = NULL;
23.470 }
23.471
23.472 - } /* if - Does Monitor got any message from backend? */
23.473 - else {
23.474 - *back_msg_action = g_strdup ("");
23.475 + } /* if - Does Monitor got any message from backend? */
23.476 + else
23.477 + {
23.478 + *back_msg_action = g_strdup ( "" );
23.479 }
23.480
23.481 return msg_type;
23.482 @@ -401,18 +432,18 @@
23.483 }
23.484
23.485 static void
23.486 -gmyth_monitor_handler_default_listener (GMythMonitorHandler * monitor,
23.487 - gint msg_code, gchar * message)
23.488 +gmyth_monitor_handler_default_listener ( GMythMonitorHandler * monitor,
23.489 + gint msg_code, gchar * message )
23.490 {
23.491 //assert( message!= NULL );
23.492 - gmyth_debug ("DEFAULT Signal handler ( msg = %s, code = %d )\n",
23.493 - message, msg_code);
23.494 + gmyth_debug ( "DEFAULT Signal handler ( msg = %s, code = %d )\n",
23.495 + message, msg_code );
23.496 }
23.497
23.498 static void
23.499 -gmyth_monitor_handler_print (GString * str, gpointer ptr)
23.500 +gmyth_monitor_handler_print ( GString * str, gpointer ptr )
23.501 {
23.502 - gmyth_debug ("Backend message event: %s --- ", str->str);
23.503 + gmyth_debug ( "Backend message event: %s --- ", str->str );
23.504 }
23.505
23.506 /**
23.507 @@ -425,104 +456,114 @@
23.508 * successfully read.
23.509 */
23.510 gpointer
23.511 -gmyth_monitor_handler_listener (gpointer data)
23.512 +gmyth_monitor_handler_listener ( gpointer data )
23.513 {
23.514 - GMythMonitorHandler *monitor = (GMythMonitorHandler *) data;
23.515 + GMythMonitorHandler *monitor = ( GMythMonitorHandler * ) data;
23.516 guint recv = 0;
23.517 - gboolean *ret = g_new0 (gboolean, 1);
23.518 + gboolean *ret = g_new0 ( gboolean, 1 );
23.519 gsize len = 0;
23.520 GIOChannel *io_channel = monitor->event_sock->sd_io_ch;
23.521 - GIOCondition io_cond = g_io_channel_get_buffer_condition (io_channel);
23.522 + GIOCondition io_cond = g_io_channel_get_buffer_condition ( io_channel );
23.523 static guint count = 0;
23.524
23.525 *ret = TRUE;
23.526
23.527 - gmyth_debug ("Entering MONITOR handler listener...");
23.528 + gmyth_debug ( "Entering MONITOR handler listener..." );
23.529
23.530 - myth_control_acquire_context (monitor, TRUE);
23.531 + myth_control_acquire_context ( monitor, TRUE );
23.532
23.533 - if ((io_cond & G_IO_HUP) != 0) {
23.534 + if ( ( io_cond & G_IO_HUP ) != 0 )
23.535 + {
23.536 *ret = FALSE;
23.537 goto clean_up;
23.538 }
23.539
23.540 GMythStringList *strlist = NULL;
23.541
23.542 - if (NULL == io_channel) {
23.543 - gmyth_debug ("Monitor socket is NULL! (GIOChannel)");
23.544 + if ( NULL == io_channel )
23.545 + {
23.546 + gmyth_debug ( "Monitor socket is NULL! (GIOChannel)" );
23.547 *ret = FALSE;
23.548 goto clean_up;
23.549 }
23.550
23.551 - while (monitor->allow_msgs_listener) {
23.552 + while ( monitor->allow_msgs_listener )
23.553 + {
23.554 ++count;
23.555
23.556 - gmyth_debug ("%d - Listening on Monitor socket...!\n", count);
23.557 + gmyth_debug ( "%d - Listening on Monitor socket...!\n", count );
23.558
23.559 - do {
23.560 + do
23.561 + {
23.562
23.563 gint bytes_sent = 0;
23.564
23.565 - strlist = gmyth_string_list_new ();
23.566 + strlist = gmyth_string_list_new ( );
23.567
23.568 - if (monitor->event_sock != NULL) {
23.569 + if ( monitor->event_sock != NULL )
23.570 + {
23.571
23.572 len =
23.573 - gmyth_socket_read_stringlist (monitor->event_sock, strlist);
23.574 + gmyth_socket_read_stringlist ( monitor->event_sock,
23.575 + strlist );
23.576
23.577 - if ((len > 0) && strlist != NULL
23.578 - && gmyth_string_list_length (strlist) > 0) {
23.579 - bytes_sent = gmyth_string_list_get_int (strlist, 0); // -1 on backend error
23.580 + if ( ( len > 0 ) && strlist != NULL
23.581 + && gmyth_string_list_length ( strlist ) > 0 )
23.582 + {
23.583 + bytes_sent = gmyth_string_list_get_int ( strlist, 0 ); // -1 on backend error
23.584
23.585 gmyth_debug
23.586 - ("[%s] MONITOR: received data buffer from IO event channel... %d strings gone!\n",
23.587 - __FUNCTION__, len);
23.588 + ( "[%s] MONITOR: received data buffer from IO event channel... %d strings gone!\n",
23.589 + __FUNCTION__, len );
23.590
23.591 recv += len;
23.592
23.593 /* debug purpose: prints out all the string list elements */
23.594 - g_list_foreach (strlist->glist,
23.595 - (GFunc) gmyth_monitor_handler_print, NULL);
23.596 + g_list_foreach ( strlist->glist,
23.597 + ( GFunc ) gmyth_monitor_handler_print,
23.598 + NULL );
23.599
23.600 - gchar *back_msg_action = g_new0 (gchar, 1);
23.601 + gchar *back_msg_action = g_new0 ( gchar, 1 );
23.602 gint msg_type =
23.603 - gmyth_monitor_handler_is_backend_message (monitor,
23.604 - strlist,
23.605 - &back_msg_action);
23.606 + gmyth_monitor_handler_is_backend_message ( monitor,
23.607 + strlist,
23.608 + &back_msg_action );
23.609
23.610 - if (monitor != NULL && msg_type != GMYTH_BACKEND_NO_MESSAGE)
23.611 - g_signal_emit (monitor, GMYTH_MONITOR_HANDLER_GET_CLASS (monitor)->backend_events_handler_signal_id, 0, /* details */
23.612 - msg_type, back_msg_action);
23.613 + if ( monitor != NULL
23.614 + && msg_type != GMYTH_BACKEND_NO_MESSAGE )
23.615 + g_signal_emit ( monitor, GMYTH_MONITOR_HANDLER_GET_CLASS ( monitor )->backend_events_handler_signal_id, 0, /* details */
23.616 + msg_type, back_msg_action );
23.617
23.618 - if (back_msg_action != NULL)
23.619 - g_free (back_msg_action);
23.620 + if ( back_msg_action != NULL )
23.621 + g_free ( back_msg_action );
23.622
23.623 }
23.624
23.625 }
23.626
23.627 - if (strlist != NULL) {
23.628 - g_object_unref (strlist);
23.629 + if ( strlist != NULL )
23.630 + {
23.631 + g_object_unref ( strlist );
23.632 strlist = NULL;
23.633 }
23.634
23.635 - io_cond = g_io_channel_get_buffer_condition (io_channel);
23.636 + io_cond = g_io_channel_get_buffer_condition ( io_channel );
23.637
23.638 - g_usleep (500);
23.639 + g_usleep ( 500 );
23.640
23.641 }
23.642 - while (recv <= 0 && ((io_cond & G_IO_HUP) == 0));
23.643 + while ( recv <= 0 && ( ( io_cond & G_IO_HUP ) == 0 ) );
23.644
23.645 - gmyth_debug ("\tMONITOR EVENT: Read %d bytes\n", recv);
23.646 + gmyth_debug ( "\tMONITOR EVENT: Read %d bytes\n", recv );
23.647
23.648 } /* main GThread while */
23.649
23.650 clean_up:
23.651 - myth_control_release_context (monitor);
23.652 + myth_control_release_context ( monitor );
23.653
23.654 - g_thread_exit (ret);
23.655 + g_thread_exit ( ret );
23.656
23.657 - return (gpointer) ret;
23.658 + return ( gpointer ) ret;
23.659
23.660 }
23.661
23.662 @@ -535,16 +576,18 @@
23.663 * @return <code>true</code>, if the socket was successfully opened.
23.664 */
23.665 static gboolean
23.666 -gmyth_connect_to_backend_monitor (GMythMonitorHandler * monitor)
23.667 +gmyth_connect_to_backend_monitor ( GMythMonitorHandler * monitor )
23.668 {
23.669 gboolean ret = TRUE;
23.670
23.671 - monitor->event_sock = gmyth_socket_new ();
23.672 + monitor->event_sock = gmyth_socket_new ( );
23.673
23.674 /* Connects the socket, send Mythtv ANN Monitor and verify Mythtv protocol version */
23.675 - if (!gmyth_socket_connect_to_backend_events (monitor->event_sock,
23.676 - monitor->hostname, monitor->port, FALSE)) {
23.677 - g_object_unref (monitor->event_sock);
23.678 + if ( !gmyth_socket_connect_to_backend_events ( monitor->event_sock,
23.679 + monitor->hostname,
23.680 + monitor->port, FALSE ) )
23.681 + {
23.682 + g_object_unref ( monitor->event_sock );
23.683 monitor->event_sock = NULL;
23.684 ret = FALSE;
23.685 }
23.686 @@ -563,27 +606,31 @@
23.687 * GMythMonitorHandler could be configured.
23.688 */
23.689 static gboolean
23.690 -gmyth_monitor_handler_setup (GMythMonitorHandler * monitor,
23.691 - GIOChannel * channel)
23.692 +gmyth_monitor_handler_setup ( GMythMonitorHandler * monitor,
23.693 + GIOChannel * channel )
23.694 {
23.695 gboolean ret = TRUE;
23.696
23.697 - if (channel != NULL) {
23.698 + if ( channel != NULL )
23.699 + {
23.700 monitor->allow_msgs_listener = TRUE;
23.701
23.702 monitor->th =
23.703 - g_thread_create ((GThreadFunc) gmyth_monitor_handler_listener,
23.704 - monitor, TRUE, NULL);
23.705 - gmyth_debug ("MONITOR GThread created!");
23.706 - } else {
23.707 + g_thread_create ( ( GThreadFunc ) gmyth_monitor_handler_listener,
23.708 + monitor, TRUE, NULL );
23.709 + gmyth_debug ( "MONITOR GThread created!" );
23.710 + }
23.711 + else
23.712 + {
23.713 ret = FALSE;
23.714 goto cleanup;
23.715 }
23.716
23.717 - if (NULL == monitor->th) {
23.718 + if ( NULL == monitor->th )
23.719 + {
23.720 gmyth_debug
23.721 - ("[%s] Error adding GThread listener function to the IO control channel!\n",
23.722 - __FUNCTION__);
23.723 + ( "[%s] Error adding GThread listener function to the IO control channel!\n",
23.724 + __FUNCTION__ );
23.725 ret = FALSE;
23.726 goto cleanup;
23.727 }
23.728 @@ -601,30 +648,35 @@
23.729 * @return <code>true</code>, if the MonitorHandler was started.
23.730 */
23.731 gboolean
23.732 -gmyth_monitor_handler_start (GMythMonitorHandler * monitor)
23.733 +gmyth_monitor_handler_start ( GMythMonitorHandler * monitor )
23.734 {
23.735 gboolean ret = TRUE;
23.736
23.737 - if (!(ret = g_thread_supported ())) {
23.738 - gmyth_debug ("Thread system wasn't initialized, starting NOW!!!");
23.739 - g_thread_init (NULL);
23.740 + if ( !( ret = g_thread_supported ( ) ) )
23.741 + {
23.742 + gmyth_debug ( "Thread system wasn't initialized, starting NOW!!!" );
23.743 + g_thread_init ( NULL );
23.744 }
23.745
23.746 - ret = gmyth_monitor_handler_setup (monitor, monitor->event_sock->sd_io_ch);
23.747 - if (ret) {
23.748 + ret =
23.749 + gmyth_monitor_handler_setup ( monitor, monitor->event_sock->sd_io_ch );
23.750 + if ( ret )
23.751 + {
23.752 gmyth_debug
23.753 - ("\n[%s]\tOK! Starting listener on the MONITOR event socket...[thread location = %p]\n",
23.754 - __FUNCTION__, g_thread_self ());
23.755 - } else {
23.756 + ( "\n[%s]\tOK! Starting listener on the MONITOR event socket...[thread location = %p]\n",
23.757 + __FUNCTION__, g_thread_self ( ) );
23.758 + }
23.759 + else
23.760 + {
23.761 gmyth_debug
23.762 - ("\n[%s]\tERROR! Coudn't start listener on the MONITOR event socket...[thread location = %p]\n",
23.763 - __FUNCTION__, g_thread_self ());
23.764 + ( "\n[%s]\tERROR! Coudn't start listener on the MONITOR event socket...[thread location = %p]\n",
23.765 + __FUNCTION__, g_thread_self ( ) );
23.766 ret = FALSE;
23.767 }
23.768
23.769 gmyth_debug
23.770 - ("[%s] Watch listener function over the IO control channel? %s!!!\n",
23.771 - __FUNCTION__, (ret == TRUE ? "YES" : "NO"));
23.772 + ( "[%s] Watch listener function over the IO control channel? %s!!!\n",
23.773 + __FUNCTION__, ( ret == TRUE ? "YES" : "NO" ) );
23.774
23.775 return ret;
23.776 }
24.1 --- a/gmyth/src/gmyth_monitor_handler.h Wed May 23 19:21:26 2007 +0100
24.2 +++ b/gmyth/src/gmyth_monitor_handler.h Wed May 23 19:50:41 2007 +0100
24.3 @@ -1,4 +1,3 @@
24.4 -/* vim: set sw=2: -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2; c-indent-level: 2-*- */
24.5 /**
24.6 * GMyth Library
24.7 *
24.8 @@ -10,22 +9,21 @@
24.9 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
24.10 * @author Rosfran Lins Borges <rosfran.borges@indt.org.br>
24.11 *
24.12 - *//*
24.13 - *
24.14 - * This program is free software; you can redistribute it and/or modify
24.15 - * it under the terms of the GNU Lesser General Public License as published by
24.16 - * the Free Software Foundation; either version 2 of the License, or
24.17 - * (at your option) any later version.
24.18 - *
24.19 - * This program is distributed in the hope that it will be useful,
24.20 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
24.21 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24.22 - * GNU General Public License for more details.
24.23 - *
24.24 - * You should have received a copy of the GNU Lesser General Public License
24.25 - * along with this program; if not, write to the Free Software
24.26 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24.27 - */
24.28 + *
24.29 + * This program is free software; you can redistribute it and/or modify
24.30 + * it under the terms of the GNU Lesser General Public License as published by
24.31 + * the Free Software Foundation; either version 2 of the License, or
24.32 + * (at your option) any later version.
24.33 + *
24.34 + * This program is distributed in the hope that it will be useful,
24.35 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
24.36 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24.37 + * GNU General Public License for more details.
24.38 + *
24.39 + * You should have received a copy of the GNU Lesser General Public License
24.40 + * along with this program; if not, write to the Free Software
24.41 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24.42 + */
24.43
24.44 #ifndef __GMYTH_MONITOR_HANDLER_H__
24.45 #define __GMYTH_MONITOR_HANDLER_H__
24.46 @@ -52,66 +50,66 @@
24.47 #define GMYTH_MONITOR_HANDLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_MONITOR_HANDLER_TYPE, GMythMonitorHandlerClass))
24.48 #define GMYTHTV_MONITOR_HANDLER_READ_ERROR -314
24.49 enum
24.50 -{
24.51 - GMYTH_BACKEND_NO_MESSAGE = 0,
24.52 - GMYTH_BACKEND_PROGRAM_INFO_CHANGED,
24.53 - GMYTH_BACKEND_DONE_RECORDING,
24.54 - GMYTH_BACKEND_STOP_LIVETV
24.55 -};
24.56 + {
24.57 + GMYTH_BACKEND_NO_MESSAGE = 0,
24.58 + GMYTH_BACKEND_PROGRAM_INFO_CHANGED,
24.59 + GMYTH_BACKEND_DONE_RECORDING,
24.60 + GMYTH_BACKEND_STOP_LIVETV
24.61 + };
24.62
24.63 typedef struct _GMythMonitorHandler GMythMonitorHandler;
24.64 typedef struct _GMythMonitorHandlerClass GMythMonitorHandlerClass;
24.65
24.66 struct _GMythMonitorHandlerClass
24.67 -{
24.68 - GObjectClass parent_class;
24.69 + {
24.70 + GObjectClass parent_class;
24.71
24.72 - /* callbacks */
24.73 - guint backend_events_handler_signal_id;
24.74 + /* callbacks */
24.75 + guint backend_events_handler_signal_id;
24.76
24.77 - /* signal default handlers */
24.78 - void (*backend_events_handler) (GMythMonitorHandler * monitor,
24.79 - gint msg_code, gchar * message);
24.80 -};
24.81 + /* signal default handlers */
24.82 + void ( *backend_events_handler ) ( GMythMonitorHandler * monitor,
24.83 + gint msg_code, gchar * message );
24.84 + };
24.85
24.86 struct _GMythMonitorHandler
24.87 -{
24.88 - GObject parent;
24.89 + {
24.90 + GObject parent;
24.91
24.92 - /* MythTV version number */
24.93 - gint mythtv_version;
24.94 + /* MythTV version number */
24.95 + gint mythtv_version;
24.96
24.97 - /* socket descriptors */
24.98 - GMythSocket *event_sock;
24.99 + /* socket descriptors */
24.100 + GMythSocket *event_sock;
24.101
24.102 - gpointer (*gmyth_monitor_handler_listener) (gpointer data);
24.103 + gpointer ( *gmyth_monitor_handler_listener ) ( gpointer data );
24.104
24.105 - gchar *hostname;
24.106 - gint port;
24.107 + gchar *hostname;
24.108 + gint port;
24.109
24.110 - gint64 actual_index;
24.111 + gint64 actual_index;
24.112
24.113 - gboolean allow_msgs_listener;
24.114 + gboolean allow_msgs_listener;
24.115
24.116 - /* stores the messages coming from the backend */
24.117 - GHashTable *backend_msgs;
24.118 + /* stores the messages coming from the backend */
24.119 + GHashTable *backend_msgs;
24.120
24.121 - GMutex *mutex;
24.122 + GMutex *mutex;
24.123
24.124 - GThread *th;
24.125 + GThread *th;
24.126
24.127 -};
24.128 + };
24.129
24.130 -GType gmyth_monitor_handler_get_type (void);
24.131 +GType gmyth_monitor_handler_get_type ( void );
24.132
24.133 -GMythMonitorHandler *gmyth_monitor_handler_new (void);
24.134 +GMythMonitorHandler *gmyth_monitor_handler_new ( void );
24.135
24.136 -gboolean gmyth_monitor_handler_open (GMythMonitorHandler * monitor,
24.137 - const gchar * hostname, gint port);
24.138 +gboolean gmyth_monitor_handler_open ( GMythMonitorHandler * monitor,
24.139 + const gchar * hostname, gint port );
24.140
24.141 -gboolean gmyth_monitor_handler_start (GMythMonitorHandler * monitor);
24.142 +gboolean gmyth_monitor_handler_start ( GMythMonitorHandler * monitor );
24.143
24.144 -void gmyth_monitor_handler_close (GMythMonitorHandler * monitor);
24.145 +void gmyth_monitor_handler_close ( GMythMonitorHandler * monitor );
24.146
24.147 G_END_DECLS
24.148 #endif /* __GMYTH_MONITOR_HANDLER_H__ */
25.1 --- a/gmyth/src/gmyth_programinfo.c Wed May 23 19:21:26 2007 +0100
25.2 +++ b/gmyth/src/gmyth_programinfo.c Wed May 23 19:50:41 2007 +0100
25.3 @@ -10,23 +10,22 @@
25.4 * @author Rosfran Borges <rosfran.borges@indt.org.br>
25.5 * @author Leonardo Sobral Cunha <leonardo.cunha@indt.org.br>
25.6 *
25.7 - *//*
25.8 - *
25.9 - * This program is free software; you can redistribute it and/or modify
25.10 - * it under the terms of the GNU Lesser General Public License as published by
25.11 - * the Free Software Foundation; either version 2 of the License, or
25.12 - * (at your option) any later version.
25.13 - *
25.14 - * This program is distributed in the hope that it will be useful,
25.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
25.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25.17 - * GNU General Public License for more details.
25.18 - *
25.19 - * You should have received a copy of the GNU Lesser General Public License
25.20 - * along with this program; if not, write to the Free Software
25.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25.22 - *
25.23 - */
25.24 + *
25.25 + * This program is free software; you can redistribute it and/or modify
25.26 + * it under the terms of the GNU Lesser General Public License as published by
25.27 + * the Free Software Foundation; either version 2 of the License, or
25.28 + * (at your option) any later version.
25.29 + *
25.30 + * This program is distributed in the hope that it will be useful,
25.31 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
25.32 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25.33 + * GNU General Public License for more details.
25.34 + *
25.35 + * You should have received a copy of the GNU Lesser General Public License
25.36 + * along with this program; if not, write to the Free Software
25.37 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25.38 + *
25.39 + */
25.40
25.41 #ifdef HAVE_CONFIG_H
25.42 #include "config.h"
25.43 @@ -40,30 +39,30 @@
25.44 #include "gmyth_util.h"
25.45 #include "gmyth_debug.h"
25.46
25.47 -static void gmyth_program_info_class_init (GMythProgramInfoClass * klass);
25.48 -static void gmyth_program_info_init (GMythProgramInfo * object);
25.49 +static void gmyth_program_info_class_init ( GMythProgramInfoClass * klass );
25.50 +static void gmyth_program_info_init ( GMythProgramInfo * object );
25.51
25.52 -static void gmyth_program_info_dispose (GObject * object);
25.53 -static void gmyth_program_info_finalize (GObject * object);
25.54 +static void gmyth_program_info_dispose ( GObject * object );
25.55 +static void gmyth_program_info_finalize ( GObject * object );
25.56
25.57 -G_DEFINE_TYPE (GMythProgramInfo, gmyth_program_info, G_TYPE_OBJECT)
25.58 - static const gchar *gmyth_program_info_non_null_value (const GString *
25.59 - str);
25.60 +G_DEFINE_TYPE ( GMythProgramInfo, gmyth_program_info, G_TYPE_OBJECT )
25.61 + static const gchar *gmyth_program_info_non_null_value ( const GString *
25.62 + str );
25.63
25.64 - static void gmyth_program_info_class_init (GMythProgramInfoClass * klass)
25.65 + static void gmyth_program_info_class_init ( GMythProgramInfoClass * klass )
25.66 {
25.67 - GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
25.68 + GObjectClass *gobject_class = G_OBJECT_CLASS ( klass );
25.69
25.70 gobject_class->dispose = gmyth_program_info_dispose;
25.71 gobject_class->finalize = gmyth_program_info_finalize;
25.72 }
25.73
25.74 static void
25.75 -gmyth_program_info_init (GMythProgramInfo * gmyth_program_info)
25.76 +gmyth_program_info_init ( GMythProgramInfo * gmyth_program_info )
25.77 {
25.78 gmyth_program_info->chancommfree = 0;
25.79
25.80 - /** A flag informing if the program has video or not. */
25.81 + /** A flag informing if the program has video or not. */
25.82 gmyth_program_info->isVideo = FALSE;
25.83 gmyth_program_info->lenMins = 0;
25.84
25.85 @@ -97,144 +96,163 @@
25.86
25.87 gmyth_program_info->recpriority = 0;
25.88
25.89 - /** The file size of the recorded program.*/
25.90 + /** The file size of the recorded program.*/
25.91 gmyth_program_info->filesize = -1;
25.92 }
25.93
25.94 static void
25.95 -gmyth_program_info_dispose (GObject * object)
25.96 +gmyth_program_info_dispose ( GObject * object )
25.97 {
25.98 - GMythProgramInfo *gmyth_program_info = GMYTH_PROGRAM_INFO (object);
25.99 + GMythProgramInfo *gmyth_program_info = GMYTH_PROGRAM_INFO ( object );
25.100
25.101 - if (gmyth_program_info->chanid != NULL) {
25.102 - g_string_free (gmyth_program_info->chanid, TRUE);
25.103 + if ( gmyth_program_info->chanid != NULL )
25.104 + {
25.105 + g_string_free ( gmyth_program_info->chanid, TRUE );
25.106 gmyth_program_info->chanid = NULL;
25.107 }
25.108
25.109 /** The program start time. */
25.110 - g_free (gmyth_program_info->startts);
25.111 + g_free ( gmyth_program_info->startts );
25.112
25.113 /** The program end time. */
25.114 - g_free (gmyth_program_info->endts);
25.115 + g_free ( gmyth_program_info->endts );
25.116
25.117 /** The recording schedule start time. */
25.118 - g_free (gmyth_program_info->recstartts);
25.119 + g_free ( gmyth_program_info->recstartts );
25.120
25.121 /** The recording schedule end time */
25.122 - g_free (gmyth_program_info->recendts);
25.123 + g_free ( gmyth_program_info->recendts );
25.124
25.125 /** The program title. */
25.126 - if (gmyth_program_info->title != NULL) {
25.127 - g_string_free (gmyth_program_info->title, TRUE);
25.128 + if ( gmyth_program_info->title != NULL )
25.129 + {
25.130 + g_string_free ( gmyth_program_info->title, TRUE );
25.131 gmyth_program_info->title = NULL;
25.132 }
25.133
25.134 /** The program subtitle. */
25.135 - if (gmyth_program_info->subtitle != NULL) {
25.136 - g_string_free (gmyth_program_info->subtitle, TRUE);
25.137 + if ( gmyth_program_info->subtitle != NULL )
25.138 + {
25.139 + g_string_free ( gmyth_program_info->subtitle, TRUE );
25.140 gmyth_program_info->subtitle = NULL;
25.141 }
25.142
25.143 /** The program description. */
25.144 - if (gmyth_program_info->description != NULL) {
25.145 - g_string_free (gmyth_program_info->description, TRUE);
25.146 + if ( gmyth_program_info->description != NULL )
25.147 + {
25.148 + g_string_free ( gmyth_program_info->description, TRUE );
25.149 gmyth_program_info->description = NULL;
25.150 }
25.151
25.152 /** The program category. */
25.153 - if (gmyth_program_info->category != NULL) {
25.154 - g_string_free (gmyth_program_info->category, TRUE);
25.155 + if ( gmyth_program_info->category != NULL )
25.156 + {
25.157 + g_string_free ( gmyth_program_info->category, TRUE );
25.158 gmyth_program_info->category = NULL;
25.159 }
25.160
25.161 - if (gmyth_program_info->chanstr != NULL) {
25.162 - g_string_free (gmyth_program_info->chanstr, TRUE);
25.163 + if ( gmyth_program_info->chanstr != NULL )
25.164 + {
25.165 + g_string_free ( gmyth_program_info->chanstr, TRUE );
25.166 gmyth_program_info->chanstr = NULL;
25.167 }
25.168
25.169 - if (gmyth_program_info->chansign != NULL) {
25.170 - g_string_free (gmyth_program_info->chansign, TRUE);
25.171 + if ( gmyth_program_info->chansign != NULL )
25.172 + {
25.173 + g_string_free ( gmyth_program_info->chansign, TRUE );
25.174 gmyth_program_info->chansign = NULL;
25.175 }
25.176
25.177 /** The associated channel name. */
25.178 - if (gmyth_program_info->channame != NULL) {
25.179 - g_string_free (gmyth_program_info->channame, TRUE);
25.180 + if ( gmyth_program_info->channame != NULL )
25.181 + {
25.182 + g_string_free ( gmyth_program_info->channame, TRUE );
25.183 gmyth_program_info->channame = NULL;
25.184 }
25.185
25.186 - if (gmyth_program_info->chanOutputFilters != NULL) {
25.187 - g_string_free (gmyth_program_info->chanOutputFilters, TRUE);
25.188 + if ( gmyth_program_info->chanOutputFilters != NULL )
25.189 + {
25.190 + g_string_free ( gmyth_program_info->chanOutputFilters, TRUE );
25.191 gmyth_program_info->chanOutputFilters = NULL;
25.192 }
25.193
25.194 - if (gmyth_program_info->seriesid != NULL) {
25.195 - g_string_free (gmyth_program_info->seriesid, TRUE);
25.196 + if ( gmyth_program_info->seriesid != NULL )
25.197 + {
25.198 + g_string_free ( gmyth_program_info->seriesid, TRUE );
25.199 gmyth_program_info->chanOutputFilters = NULL;
25.200 }
25.201
25.202 /** The program unique id. */
25.203 - if (gmyth_program_info->programid != NULL) {
25.204 - g_string_free (gmyth_program_info->programid, TRUE);
25.205 + if ( gmyth_program_info->programid != NULL )
25.206 + {
25.207 + g_string_free ( gmyth_program_info->programid, TRUE );
25.208 gmyth_program_info->programid = NULL;
25.209 }
25.210
25.211 - if (gmyth_program_info->catType != NULL) {
25.212 - g_string_free (gmyth_program_info->catType, TRUE);
25.213 + if ( gmyth_program_info->catType != NULL )
25.214 + {
25.215 + g_string_free ( gmyth_program_info->catType, TRUE );
25.216 gmyth_program_info->catType = NULL;
25.217 }
25.218
25.219 - if (gmyth_program_info->sortTitle != NULL) {
25.220 - g_string_free (gmyth_program_info->sortTitle, TRUE);
25.221 + if ( gmyth_program_info->sortTitle != NULL )
25.222 + {
25.223 + g_string_free ( gmyth_program_info->sortTitle, TRUE );
25.224 gmyth_program_info->sortTitle = NULL;
25.225 }
25.226
25.227 - if (gmyth_program_info->year != NULL) {
25.228 - g_string_free (gmyth_program_info->year, TRUE);
25.229 + if ( gmyth_program_info->year != NULL )
25.230 + {
25.231 + g_string_free ( gmyth_program_info->year, TRUE );
25.232 gmyth_program_info->year = NULL;
25.233 }
25.234
25.235 - g_free (gmyth_program_info->originalAirDate);
25.236 + g_free ( gmyth_program_info->originalAirDate );
25.237
25.238 - g_free (gmyth_program_info->lastmodified);
25.239 + g_free ( gmyth_program_info->lastmodified );
25.240
25.241 - g_free (gmyth_program_info->lastInUseTime);
25.242 + g_free ( gmyth_program_info->lastInUseTime );
25.243
25.244 - if (gmyth_program_info->schedulerid != NULL) {
25.245 - g_string_free (gmyth_program_info->schedulerid, TRUE);
25.246 + if ( gmyth_program_info->schedulerid != NULL )
25.247 + {
25.248 + g_string_free ( gmyth_program_info->schedulerid, TRUE );
25.249 gmyth_program_info->schedulerid = NULL;
25.250 }
25.251
25.252 - if (gmyth_program_info->recgroup != NULL) {
25.253 - g_string_free (gmyth_program_info->recgroup, TRUE);
25.254 + if ( gmyth_program_info->recgroup != NULL )
25.255 + {
25.256 + g_string_free ( gmyth_program_info->recgroup, TRUE );
25.257 gmyth_program_info->recgroup = NULL;
25.258 }
25.259
25.260 - if (gmyth_program_info->playgroup != NULL) {
25.261 - g_string_free (gmyth_program_info->playgroup, TRUE);
25.262 + if ( gmyth_program_info->playgroup != NULL )
25.263 + {
25.264 + g_string_free ( gmyth_program_info->playgroup, TRUE );
25.265 gmyth_program_info->playgroup = NULL;
25.266 }
25.267
25.268 /** The file name of the recorded program.*/
25.269 - if (gmyth_program_info->pathname != NULL) {
25.270 - g_string_free (gmyth_program_info->pathname, TRUE);
25.271 + if ( gmyth_program_info->pathname != NULL )
25.272 + {
25.273 + g_string_free ( gmyth_program_info->pathname, TRUE );
25.274 gmyth_program_info->pathname = NULL;
25.275 }
25.276
25.277 - if (gmyth_program_info->hostname != NULL) {
25.278 - g_string_free (gmyth_program_info->hostname, TRUE);
25.279 + if ( gmyth_program_info->hostname != NULL )
25.280 + {
25.281 + g_string_free ( gmyth_program_info->hostname, TRUE );
25.282 gmyth_program_info->hostname = NULL;
25.283 }
25.284
25.285 - G_OBJECT_CLASS (gmyth_program_info_parent_class)->dispose (object);
25.286 + G_OBJECT_CLASS ( gmyth_program_info_parent_class )->dispose ( object );
25.287 }
25.288
25.289 static void
25.290 -gmyth_program_info_finalize (GObject * object)
25.291 +gmyth_program_info_finalize ( GObject * object )
25.292 {
25.293 - g_signal_handlers_destroy (object);
25.294 + g_signal_handlers_destroy ( object );
25.295
25.296 - G_OBJECT_CLASS (gmyth_program_info_parent_class)->finalize (object);
25.297 + G_OBJECT_CLASS ( gmyth_program_info_parent_class )->finalize ( object );
25.298 }
25.299
25.300 /**
25.301 @@ -243,10 +261,10 @@
25.302 * @return a new instance of GMythProgramInfo.
25.303 */
25.304 GMythProgramInfo *
25.305 -gmyth_program_info_new (void)
25.306 +gmyth_program_info_new ( void )
25.307 {
25.308 GMythProgramInfo *program_info =
25.309 - GMYTH_PROGRAM_INFO (g_object_new (GMYTH_PROGRAM_INFO_TYPE, NULL));
25.310 + GMYTH_PROGRAM_INFO ( g_object_new ( GMYTH_PROGRAM_INFO_TYPE, NULL ) );
25.311
25.312 return program_info;
25.313 }
25.314 @@ -262,66 +280,66 @@
25.315 * @return a GMythStringList with the program info fields.
25.316 */
25.317 GMythStringList *
25.318 -gmyth_program_info_to_string_list (GMythProgramInfo * prog,
25.319 - GMythStringList * slist)
25.320 +gmyth_program_info_to_string_list ( GMythProgramInfo * prog,
25.321 + GMythStringList * slist )
25.322 {
25.323 - g_return_val_if_fail (prog != NULL, NULL);
25.324 - g_return_val_if_fail (slist != NULL, NULL);
25.325 + g_return_val_if_fail ( prog != NULL, NULL );
25.326 + g_return_val_if_fail ( slist != NULL, NULL );
25.327
25.328 - gmyth_string_list_append_string (slist, prog->title); /* 0 */
25.329 - gmyth_string_list_append_string (slist, prog->subtitle); /* 1 */
25.330 - gmyth_string_list_append_string (slist, prog->description); /* 2 */
25.331 - gmyth_string_list_append_string (slist, prog->category); /* 3 */
25.332 - gmyth_string_list_append_string (slist, prog->chanid); /* 4 */
25.333 - gmyth_string_list_append_string (slist, prog->chanstr); /* 5 */
25.334 - gmyth_string_list_append_string (slist, prog->chansign); /* 6 */
25.335 - gmyth_string_list_append_string (slist, prog->channame); /* 7 */
25.336 - gmyth_string_list_append_string (slist, prog->pathname); /* 8 */
25.337 - gmyth_string_list_append_int64 (slist, 0); /* 9 */
25.338 + gmyth_string_list_append_string ( slist, prog->title ); /* 0 */
25.339 + gmyth_string_list_append_string ( slist, prog->subtitle ); /* 1 */
25.340 + gmyth_string_list_append_string ( slist, prog->description ); /* 2 */
25.341 + gmyth_string_list_append_string ( slist, prog->category ); /* 3 */
25.342 + gmyth_string_list_append_string ( slist, prog->chanid ); /* 4 */
25.343 + gmyth_string_list_append_string ( slist, prog->chanstr ); /* 5 */
25.344 + gmyth_string_list_append_string ( slist, prog->chansign ); /* 6 */
25.345 + gmyth_string_list_append_string ( slist, prog->channame ); /* 7 */
25.346 + gmyth_string_list_append_string ( slist, prog->pathname ); /* 8 */
25.347 + gmyth_string_list_append_int64 ( slist, 0 ); /* 9 */
25.348
25.349 // fixme
25.350 //gmyth_string_list_append_int64 (slist, 100/*prog->filesize*/); /* 9 */
25.351 //gmyth_string_list_append_int (slist, 0); /* 10 */
25.352
25.353 - if (prog->startts)
25.354 - gmyth_string_list_append_int (slist, prog->startts->tv_sec); /* 11 *///DATETIME_TO_LIST(startts)
25.355 + if ( prog->startts )
25.356 + gmyth_string_list_append_int ( slist, prog->startts->tv_sec ); /* 11 *///DATETIME_TO_LIST(startts)
25.357 else
25.358 - gmyth_string_list_append_int (slist, 0);
25.359 + gmyth_string_list_append_int ( slist, 0 );
25.360
25.361 - if (prog->endts)
25.362 - gmyth_string_list_append_int (slist, prog->endts->tv_sec); /* 12 *///DATETIME_TO_LIST(endts)
25.363 + if ( prog->endts )
25.364 + gmyth_string_list_append_int ( slist, prog->endts->tv_sec ); /* 12 *///DATETIME_TO_LIST(endts)
25.365 else
25.366 - gmyth_string_list_append_int (slist, 0);
25.367 + gmyth_string_list_append_int ( slist, 0 );
25.368
25.369 - gmyth_string_list_append_int (slist, prog->duplicate); /* 13 */
25.370 - gmyth_string_list_append_int (slist, prog->shareable); /* 14 */
25.371 - gmyth_string_list_append_int (slist, prog->findid); /* 15 */
25.372 - gmyth_string_list_append_string (slist, prog->hostname); /* 16 */
25.373 - gmyth_string_list_append_int (slist, prog->sourceid); /* 17 */
25.374 - gmyth_string_list_append_int (slist, prog->cardid); /* 18 */
25.375 - gmyth_string_list_append_int (slist, prog->inputid); /* 19 */
25.376 - gmyth_string_list_append_int (slist, prog->recpriority); /* 20 */
25.377 - gmyth_string_list_append_int (slist, 0 /*prog->recstatus */ ); /* 21 */
25.378 - gmyth_string_list_append_int (slist, prog->recordid); /* 22 */
25.379 - gmyth_string_list_append_int (slist, 0 /*prog->rectype */ ); /* 23 */
25.380 - gmyth_string_list_append_int (slist, 0 /*prog->dupin */ ); /* 24 */
25.381 - gmyth_string_list_append_int (slist, 0 /*prog->dupmethod */ ); /* 25 */
25.382 - gmyth_string_list_append_int (slist, prog->recstartts != NULL ? prog->recstartts->tv_sec : 0); /* 26 *///DATETIME_TO_LIST(recstartts)
25.383 - gmyth_string_list_append_int (slist, prog->recendts != NULL ? prog->recendts->tv_sec : 0); /* 27 *///DATETIME_TO_LIST(recendts)
25.384 - gmyth_string_list_append_int (slist, prog->repeat); /* 28 */
25.385 - gmyth_string_list_append_int (slist, prog->programflags); /* 29 */
25.386 - gmyth_string_list_append_char_array (slist, "Default"); /* 30 *///prog->(recgroup != "") ? recgroup : "Default")
25.387 - gmyth_string_list_append_int (slist, prog->chancommfree); /* 31 */
25.388 - gmyth_string_list_append_string (slist, prog->chanOutputFilters); /* 32 */
25.389 - gmyth_string_list_append_string (slist, prog->seriesid); /* 33 */
25.390 - gmyth_string_list_append_string (slist, prog->programid); /* 34 */
25.391 - gmyth_string_list_append_char_array (slist, ""); /* 35 */
25.392 - gmyth_string_list_append_int (slist, prog->lastmodified != NULL ? prog->lastmodified->tv_sec : 0); /* 36 *///DATETIME_TO_LIST(lastmodified)
25.393 - gmyth_string_list_append_int (slist, 0); /* 37 *///FLOAT_TO_LIST(stars)
25.394 - gmyth_string_list_append_int (slist, prog->originalAirDate != NULL ? prog->originalAirDate->tv_sec : 0); /* 38 *///DATETIME_TO_LIST(QDateTime(originalAirDate))
25.395 - gmyth_string_list_append_int (slist, prog->hasAirDate); /* 39 */
25.396 - gmyth_string_list_append_char_array (slist, "Default"); /* 40 *///prog->(playgroup != "") ? playgroup : "Default")
25.397 - gmyth_string_list_append_int (slist, prog->recpriority2); /* 41 */
25.398 + gmyth_string_list_append_int ( slist, prog->duplicate ); /* 13 */
25.399 + gmyth_string_list_append_int ( slist, prog->shareable ); /* 14 */
25.400 + gmyth_string_list_append_int ( slist, prog->findid ); /* 15 */
25.401 + gmyth_string_list_append_string ( slist, prog->hostname ); /* 16 */
25.402 + gmyth_string_list_append_int ( slist, prog->sourceid ); /* 17 */
25.403 + gmyth_string_list_append_int ( slist, prog->cardid ); /* 18 */
25.404 + gmyth_string_list_append_int ( slist, prog->inputid ); /* 19 */
25.405 + gmyth_string_list_append_int ( slist, prog->recpriority ); /* 20 */
25.406 + gmyth_string_list_append_int ( slist, 0 /*prog->recstatus */ ); /* 21 */
25.407 + gmyth_string_list_append_int ( slist, prog->recordid ); /* 22 */
25.408 + gmyth_string_list_append_int ( slist, 0 /*prog->rectype */ ); /* 23 */
25.409 + gmyth_string_list_append_int ( slist, 0 /*prog->dupin */ ); /* 24 */
25.410 + gmyth_string_list_append_int ( slist, 0 /*prog->dupmethod */ ); /* 25 */
25.411 + gmyth_string_list_append_int ( slist, prog->recstartts != NULL ? prog->recstartts->tv_sec : 0 ); /* 26 *///DATETIME_TO_LIST(recstartts)
25.412 + gmyth_string_list_append_int ( slist, prog->recendts != NULL ? prog->recendts->tv_sec : 0 ); /* 27 *///DATETIME_TO_LIST(recendts)
25.413 + gmyth_string_list_append_int ( slist, prog->repeat ); /* 28 */
25.414 + gmyth_string_list_append_int ( slist, prog->programflags ); /* 29 */
25.415 + gmyth_string_list_append_char_array ( slist, "Default" ); /* 30 *///prog->(recgroup != "") ? recgroup : "Default")
25.416 + gmyth_string_list_append_int ( slist, prog->chancommfree ); /* 31 */
25.417 + gmyth_string_list_append_string ( slist, prog->chanOutputFilters ); /* 32 */
25.418 + gmyth_string_list_append_string ( slist, prog->seriesid ); /* 33 */
25.419 + gmyth_string_list_append_string ( slist, prog->programid ); /* 34 */
25.420 + gmyth_string_list_append_char_array ( slist, "" ); /* 35 */
25.421 + gmyth_string_list_append_int ( slist, prog->lastmodified != NULL ? prog->lastmodified->tv_sec : 0 ); /* 36 *///DATETIME_TO_LIST(lastmodified)
25.422 + gmyth_string_list_append_int ( slist, 0 ); /* 37 *///FLOAT_TO_LIST(stars)
25.423 + gmyth_string_list_append_int ( slist, prog->originalAirDate != NULL ? prog->originalAirDate->tv_sec : 0 ); /* 38 *///DATETIME_TO_LIST(QDateTime(originalAirDate))
25.424 + gmyth_string_list_append_int ( slist, prog->hasAirDate ); /* 39 */
25.425 + gmyth_string_list_append_char_array ( slist, "Default" ); /* 40 *///prog->(playgroup != "") ? playgroup : "Default")
25.426 + gmyth_string_list_append_int ( slist, prog->recpriority2 ); /* 41 */
25.427
25.428 return slist;
25.429 }
25.430 @@ -335,69 +353,70 @@
25.431 * @return a GMythProgramInfo representing the string list got from network.
25.432 */
25.433 GMythProgramInfo *
25.434 -gmyth_program_info_from_string_list_from_pos (GMythStringList * slist,
25.435 - guint pos)
25.436 +gmyth_program_info_from_string_list_from_pos ( GMythStringList * slist,
25.437 + guint pos )
25.438 {
25.439 - GMythProgramInfo *prog = gmyth_program_info_new ();
25.440 + GMythProgramInfo *prog = gmyth_program_info_new ( );
25.441
25.442 - g_return_val_if_fail (slist != NULL &&
25.443 - gmyth_string_list_get_string (slist, pos) != NULL, NULL);
25.444 + g_return_val_if_fail ( slist != NULL &&
25.445 + gmyth_string_list_get_string ( slist, pos ) != NULL,
25.446 + NULL );
25.447
25.448 - prog->title = gmyth_string_list_get_string (slist, pos);
25.449 - prog->subtitle = gmyth_string_list_get_string (slist, pos + 1);
25.450 - prog->description = gmyth_string_list_get_string (slist, pos + 2);
25.451 - prog->category = gmyth_string_list_get_string (slist, pos + 3);
25.452 - prog->chanid = gmyth_string_list_get_string (slist, pos + 4);
25.453 - prog->channame = gmyth_string_list_get_string (slist, pos + 5);
25.454 - prog->chanstr = gmyth_string_list_get_string (slist, pos + 6);
25.455 - prog->chansign = gmyth_string_list_get_string (slist, pos + 7);
25.456 - prog->pathname = gmyth_string_list_get_string (slist, pos + 8);
25.457 + prog->title = gmyth_string_list_get_string ( slist, pos );
25.458 + prog->subtitle = gmyth_string_list_get_string ( slist, pos + 1 );
25.459 + prog->description = gmyth_string_list_get_string ( slist, pos + 2 );
25.460 + prog->category = gmyth_string_list_get_string ( slist, pos + 3 );
25.461 + prog->chanid = gmyth_string_list_get_string ( slist, pos + 4 );
25.462 + prog->channame = gmyth_string_list_get_string ( slist, pos + 5 );
25.463 + prog->chanstr = gmyth_string_list_get_string ( slist, pos + 6 );
25.464 + prog->chansign = gmyth_string_list_get_string ( slist, pos + 7 );
25.465 + prog->pathname = gmyth_string_list_get_string ( slist, pos + 8 );
25.466
25.467 - prog->filesize = gmyth_string_list_get_int64 (slist, pos + 9);
25.468 + prog->filesize = gmyth_string_list_get_int64 ( slist, pos + 9 );
25.469
25.470 - gmyth_debug ("Prog info: [ %s, %s, %s, %s, %s, %s, %s, %s, %s, %d ]\n",
25.471 - gmyth_program_info_non_null_value (prog->title),
25.472 - gmyth_program_info_non_null_value (prog->subtitle),
25.473 - gmyth_program_info_non_null_value (prog->description),
25.474 - gmyth_program_info_non_null_value (prog->category),
25.475 - gmyth_program_info_non_null_value (prog->chanid),
25.476 - gmyth_program_info_non_null_value (prog->channame),
25.477 - gmyth_program_info_non_null_value (prog->chanstr),
25.478 - gmyth_program_info_non_null_value (prog->chansign),
25.479 - gmyth_program_info_non_null_value (prog->pathname),
25.480 - gmyth_string_list_get_int (slist, pos + 11));
25.481 + gmyth_debug ( "Prog info: [ %s, %s, %s, %s, %s, %s, %s, %s, %s, %d ]\n",
25.482 + gmyth_program_info_non_null_value ( prog->title ),
25.483 + gmyth_program_info_non_null_value ( prog->subtitle ),
25.484 + gmyth_program_info_non_null_value ( prog->description ),
25.485 + gmyth_program_info_non_null_value ( prog->category ),
25.486 + gmyth_program_info_non_null_value ( prog->chanid ),
25.487 + gmyth_program_info_non_null_value ( prog->channame ),
25.488 + gmyth_program_info_non_null_value ( prog->chanstr ),
25.489 + gmyth_program_info_non_null_value ( prog->chansign ),
25.490 + gmyth_program_info_non_null_value ( prog->pathname ),
25.491 + gmyth_string_list_get_int ( slist, pos + 11 ) );
25.492
25.493 - prog->startts = gmyth_util_string_to_time_val ((gmyth_util_time_to_isoformat ((time_t) gmyth_string_list_get_int (slist, pos + 11)))->str); //DATETIME_TO_LIST(startts)
25.494 - prog->endts = gmyth_util_string_to_time_val ((gmyth_util_time_to_isoformat ((time_t) gmyth_string_list_get_int (slist, pos + 12)))->str); //DATETIME_TO_LIST(endts)
25.495 - prog->duplicate = gmyth_string_list_get_int (slist, pos + 13);
25.496 - prog->shareable = gmyth_string_list_get_int (slist, pos + 14);
25.497 - prog->findid = gmyth_string_list_get_int (slist, pos + 15);
25.498 - prog->hostname = gmyth_string_list_get_string (slist, pos + 16);
25.499 - prog->sourceid = gmyth_string_list_get_int (slist, pos + 17);
25.500 - prog->cardid = gmyth_string_list_get_int (slist, pos + 18);
25.501 - prog->inputid = gmyth_string_list_get_int (slist, pos + 19);
25.502 - prog->recpriority = gmyth_string_list_get_int (slist, pos + 20);
25.503 - prog->reactivate = gmyth_string_list_get_int (slist, pos + 21);
25.504 - prog->recordid = gmyth_string_list_get_int (slist, pos + 22);
25.505 - gmyth_string_list_get_int (slist, pos + 23);
25.506 - gmyth_string_list_get_int (slist, pos + 24);
25.507 - gmyth_string_list_get_int (slist, pos + 25);
25.508 - prog->recstartts = gmyth_util_string_to_time_val ((gmyth_util_time_to_isoformat ((time_t) gmyth_string_list_get_int (slist, pos + 26)))->str); //DATETIME_TO_LIST(recstartts)
25.509 - prog->recendts = gmyth_util_string_to_time_val ((gmyth_util_time_to_isoformat ((time_t) gmyth_string_list_get_int (slist, pos + 27)))->str); //DATETIME_TO_LIST(recendts)
25.510 - prog->repeat = gmyth_string_list_get_int (slist, pos + 28);
25.511 - prog->programflags = gmyth_string_list_get_int (slist, pos + 29);
25.512 - prog->recgroup = gmyth_string_list_get_string (slist, pos + 30); //prog->(recgroup != "") ? recgroup : "Default")
25.513 - prog->chancommfree = gmyth_string_list_get_int (slist, pos + 31);
25.514 - prog->chanOutputFilters = gmyth_string_list_get_string (slist, pos + 32);
25.515 - prog->seriesid = gmyth_string_list_get_string (slist, pos + 33);
25.516 - prog->programid = gmyth_string_list_get_string (slist, pos + 34);
25.517 - gmyth_string_list_get_string (slist, pos + 35);
25.518 - prog->lastmodified = gmyth_util_string_to_time_val ((gmyth_util_time_to_isoformat ((time_t) gmyth_string_list_get_int (slist, pos + 36)))->str); //DATETIME_TO_LIST(lastmodified)
25.519 - gmyth_string_list_get_int (slist, pos + 37); //FLOAT_TO_LIST(stars)
25.520 - prog->originalAirDate = gmyth_util_string_to_time_val ((gmyth_util_time_to_isoformat ((time_t) gmyth_string_list_get_int (slist, pos + 38)))->str); //DATETIME_TO_LIST(QDateTime(originalAirDate))
25.521 - prog->hasAirDate = gmyth_string_list_get_int (slist, pos + 39);
25.522 - prog->playgroup = gmyth_string_list_get_string (slist, pos + 40); //prog->(playgroup != "") ? playgroup : "Default")
25.523 - prog->recpriority2 = gmyth_string_list_get_int (slist, pos + 41);
25.524 + prog->startts = gmyth_util_string_to_time_val ( ( gmyth_util_time_to_isoformat ( ( time_t ) gmyth_string_list_get_int ( slist, pos + 11 ) ) )->str ); //DATETIME_TO_LIST(startts)
25.525 + prog->endts = gmyth_util_string_to_time_val ( ( gmyth_util_time_to_isoformat ( ( time_t ) gmyth_string_list_get_int ( slist, pos + 12 ) ) )->str ); //DATETIME_TO_LIST(endts)
25.526 + prog->duplicate = gmyth_string_list_get_int ( slist, pos + 13 );
25.527 + prog->shareable = gmyth_string_list_get_int ( slist, pos + 14 );
25.528 + prog->findid = gmyth_string_list_get_int ( slist, pos + 15 );
25.529 + prog->hostname = gmyth_string_list_get_string ( slist, pos + 16 );
25.530 + prog->sourceid = gmyth_string_list_get_int ( slist, pos + 17 );
25.531 + prog->cardid = gmyth_string_list_get_int ( slist, pos + 18 );
25.532 + prog->inputid = gmyth_string_list_get_int ( slist, pos + 19 );
25.533 + prog->recpriority = gmyth_string_list_get_int ( slist, pos + 20 );
25.534 + prog->reactivate = gmyth_string_list_get_int ( slist, pos + 21 );
25.535 + prog->recordid = gmyth_string_list_get_int ( slist, pos + 22 );
25.536 + gmyth_string_list_get_int ( slist, pos + 23 );
25.537 + gmyth_string_list_get_int ( slist, pos + 24 );
25.538 + gmyth_string_list_get_int ( slist, pos + 25 );
25.539 + prog->recstartts = gmyth_util_string_to_time_val ( ( gmyth_util_time_to_isoformat ( ( time_t ) gmyth_string_list_get_int ( slist, pos + 26 ) ) )->str ); //DATETIME_TO_LIST(recstartts)
25.540 + prog->recendts = gmyth_util_string_to_time_val ( ( gmyth_util_time_to_isoformat ( ( time_t ) gmyth_string_list_get_int ( slist, pos + 27 ) ) )->str ); //DATETIME_TO_LIST(recendts)
25.541 + prog->repeat = gmyth_string_list_get_int ( slist, pos + 28 );
25.542 + prog->programflags = gmyth_string_list_get_int ( slist, pos + 29 );
25.543 + prog->recgroup = gmyth_string_list_get_string ( slist, pos + 30 ); //prog->(recgroup != "") ? recgroup : "Default")
25.544 + prog->chancommfree = gmyth_string_list_get_int ( slist, pos + 31 );
25.545 + prog->chanOutputFilters = gmyth_string_list_get_string ( slist, pos + 32 );
25.546 + prog->seriesid = gmyth_string_list_get_string ( slist, pos + 33 );
25.547 + prog->programid = gmyth_string_list_get_string ( slist, pos + 34 );
25.548 + gmyth_string_list_get_string ( slist, pos + 35 );
25.549 + prog->lastmodified = gmyth_util_string_to_time_val ( ( gmyth_util_time_to_isoformat ( ( time_t ) gmyth_string_list_get_int ( slist, pos + 36 ) ) )->str ); //DATETIME_TO_LIST(lastmodified)
25.550 + gmyth_string_list_get_int ( slist, pos + 37 ); //FLOAT_TO_LIST(stars)
25.551 + prog->originalAirDate = gmyth_util_string_to_time_val ( ( gmyth_util_time_to_isoformat ( ( time_t ) gmyth_string_list_get_int ( slist, pos + 38 ) ) )->str ); //DATETIME_TO_LIST(QDateTime(originalAirDate))
25.552 + prog->hasAirDate = gmyth_string_list_get_int ( slist, pos + 39 );
25.553 + prog->playgroup = gmyth_string_list_get_string ( slist, pos + 40 ); //prog->(playgroup != "") ? playgroup : "Default")
25.554 + prog->recpriority2 = gmyth_string_list_get_int ( slist, pos + 41 );
25.555
25.556 return prog;
25.557 }
25.558 @@ -410,13 +429,13 @@
25.559 * @return a GMythProgramInfo representing the string list got from network.
25.560 */
25.561 GMythProgramInfo *
25.562 -gmyth_program_info_from_string_list (GMythStringList * slist)
25.563 +gmyth_program_info_from_string_list ( GMythStringList * slist )
25.564 {
25.565 GMythProgramInfo *prog = NULL;
25.566
25.567 - g_return_val_if_fail (slist != NULL, NULL);
25.568 + g_return_val_if_fail ( slist != NULL, NULL );
25.569
25.570 - prog = gmyth_program_info_from_string_list_from_pos (slist, 0);
25.571 + prog = gmyth_program_info_from_string_list_from_pos ( slist, 0 );
25.572
25.573 return prog;
25.574 }
25.575 @@ -429,11 +448,11 @@
25.576 * @return a GMythProgramInfo representing the string list got from network.
25.577 */
25.578 GMythProgramInfo *
25.579 -gmyth_program_info_from_string_list_next_prog (GMythStringList * slist)
25.580 +gmyth_program_info_from_string_list_next_prog ( GMythStringList * slist )
25.581 {
25.582 - GMythProgramInfo *prog = gmyth_program_info_new ();
25.583 + GMythProgramInfo *prog = gmyth_program_info_new ( );
25.584
25.585 - g_return_val_if_fail (slist != NULL, NULL);
25.586 + g_return_val_if_fail ( slist != NULL, NULL );
25.587
25.588 /*
25.589 {Home Improvement[]:[]No, No, Godot[]:[]
25.590 @@ -443,37 +462,37 @@
25.591 /home/hmelo/.mythtv/channels/abc1.jpg[]:[]abc1[]:[]2000[]:[]25725844[]:[] }
25.592 */
25.593
25.594 - prog->title = gmyth_string_list_get_string (slist, 0);
25.595 - prog->subtitle = gmyth_string_list_get_string (slist, 1);
25.596 - prog->description = gmyth_string_list_get_string (slist, 2);
25.597 - prog->category = gmyth_string_list_get_string (slist, 3);
25.598 - prog->startts = gmyth_util_string_to_time_val (gmyth_string_list_get_char_array (slist, 4)); //DATETIME_TO_LIST(startts)
25.599 - prog->endts = gmyth_util_string_to_time_val (gmyth_string_list_get_char_array (slist, 5)); //DATETIME_TO_LIST(endts)
25.600 - prog->channame = gmyth_string_list_get_string (slist, 6);
25.601 - prog->chansign = gmyth_string_list_get_string (slist, 7);
25.602 - prog->chanstr = gmyth_string_list_get_string (slist, 8);
25.603 - prog->chanid = gmyth_string_list_get_string (slist, 9);
25.604 - prog->filesize = gmyth_string_list_get_int64 (slist, 10);
25.605 + prog->title = gmyth_string_list_get_string ( slist, 0 );
25.606 + prog->subtitle = gmyth_string_list_get_string ( slist, 1 );
25.607 + prog->description = gmyth_string_list_get_string ( slist, 2 );
25.608 + prog->category = gmyth_string_list_get_string ( slist, 3 );
25.609 + prog->startts = gmyth_util_string_to_time_val ( gmyth_string_list_get_char_array ( slist, 4 ) ); //DATETIME_TO_LIST(startts)
25.610 + prog->endts = gmyth_util_string_to_time_val ( gmyth_string_list_get_char_array ( slist, 5 ) ); //DATETIME_TO_LIST(endts)
25.611 + prog->channame = gmyth_string_list_get_string ( slist, 6 );
25.612 + prog->chansign = gmyth_string_list_get_string ( slist, 7 );
25.613 + prog->chanstr = gmyth_string_list_get_string ( slist, 8 );
25.614 + prog->chanid = gmyth_string_list_get_string ( slist, 9 );
25.615 + prog->filesize = gmyth_string_list_get_int64 ( slist, 10 );
25.616
25.617 - gmyth_debug ("NEXT program info: [ %s, %s, %s, %s, %s, %s, %s, %s, %s ]\n",
25.618 - gmyth_program_info_non_null_value (prog->title),
25.619 - gmyth_program_info_non_null_value (prog->subtitle),
25.620 - gmyth_program_info_non_null_value (prog->description),
25.621 - gmyth_program_info_non_null_value (prog->category),
25.622 - gmyth_program_info_non_null_value (prog->chanid),
25.623 - gmyth_program_info_non_null_value (prog->channame),
25.624 - gmyth_program_info_non_null_value (prog->chanstr),
25.625 - gmyth_program_info_non_null_value (prog->chansign),
25.626 - gmyth_program_info_non_null_value (prog->pathname));
25.627 + gmyth_debug ( "NEXT program info: [ %s, %s, %s, %s, %s, %s, %s, %s, %s ]\n",
25.628 + gmyth_program_info_non_null_value ( prog->title ),
25.629 + gmyth_program_info_non_null_value ( prog->subtitle ),
25.630 + gmyth_program_info_non_null_value ( prog->description ),
25.631 + gmyth_program_info_non_null_value ( prog->category ),
25.632 + gmyth_program_info_non_null_value ( prog->chanid ),
25.633 + gmyth_program_info_non_null_value ( prog->channame ),
25.634 + gmyth_program_info_non_null_value ( prog->chanstr ),
25.635 + gmyth_program_info_non_null_value ( prog->chansign ),
25.636 + gmyth_program_info_non_null_value ( prog->pathname ) );
25.637
25.638 return prog;
25.639 }
25.640
25.641 static const gchar *
25.642 -gmyth_program_info_non_null_value (const GString * str)
25.643 +gmyth_program_info_non_null_value ( const GString * str )
25.644 {
25.645 - return (str != NULL && str->str != NULL
25.646 - && strlen (str->str) > 0 ? str->str : " ");
25.647 + return ( str != NULL && str->str != NULL
25.648 + && strlen ( str->str ) > 0 ? str->str : " " );
25.649 }
25.650
25.651 /**
25.652 @@ -484,44 +503,45 @@
25.653 * @return a string representing the program info.
25.654 */
25.655 const gchar *
25.656 -gmyth_program_info_to_string (const GMythProgramInfo * prog)
25.657 +gmyth_program_info_to_string ( const GMythProgramInfo * prog )
25.658 {
25.659 return
25.660 g_strdup_printf
25.661 - ("Title: %s, Subtitle: %s, Description: %s, Category: %s, Channel ID: %s, "
25.662 - "Channel Name: %s, Chan str: %s, Channel Sign: %s, Path Name: %s, File Size: %lld, \n"
25.663 - "Start TS: %s, End TS: %s, Duplicate: %d, Shareable: %d, Find ID: %d, Hostname: %s, "
25.664 - "Source ID: %d, Vard ID: %d, Input ID: %d, Rec Priority: %d, Reactivate: %d, \n"
25.665 - "Record ID: %d, Rec Start TS: %s, Rec End TS: %s, Repeat: %d, Program Flags: %d, "
25.666 - "Rec Group: %s, Channel Comm Free: %d, Channel Output Filters: %s, Series ID: %s, \n"
25.667 - "Program ID: %s, Last Modified Date: %s, Original Air Date: %s, Has Air Date: %d, "
25.668 - "Play Group: %s.\n",
25.669 - gmyth_program_info_non_null_value (prog->title),
25.670 - gmyth_program_info_non_null_value (prog->subtitle),
25.671 - gmyth_program_info_non_null_value (prog->description),
25.672 - gmyth_program_info_non_null_value (prog->category),
25.673 - gmyth_program_info_non_null_value (prog->chanid),
25.674 - gmyth_program_info_non_null_value (prog->channame),
25.675 - gmyth_program_info_non_null_value (prog->chanstr),
25.676 - gmyth_program_info_non_null_value (prog->chansign),
25.677 - gmyth_program_info_non_null_value (prog->pathname), prog->filesize,
25.678 - gmyth_util_time_to_string_from_time_val (prog->startts),
25.679 - gmyth_util_time_to_string_from_time_val (prog->endts),
25.680 - prog->duplicate, prog->shareable, prog->findid,
25.681 - gmyth_program_info_non_null_value (prog->hostname), prog->sourceid,
25.682 - prog->cardid, prog->inputid, prog->recpriority, prog->reactivate,
25.683 - prog->recordid,
25.684 - gmyth_util_time_to_string_from_time_val (prog->recstartts),
25.685 - gmyth_util_time_to_string_from_time_val (prog->recendts),
25.686 - prog->repeat, prog->programflags,
25.687 - gmyth_program_info_non_null_value (prog->recgroup),
25.688 - prog->chancommfree,
25.689 - gmyth_program_info_non_null_value (prog->chanOutputFilters),
25.690 - gmyth_program_info_non_null_value (prog->seriesid),
25.691 - gmyth_program_info_non_null_value (prog->programid),
25.692 - gmyth_util_time_to_string_from_time_val (prog->lastmodified),
25.693 - gmyth_util_time_to_string_from_time_val (prog->originalAirDate),
25.694 - prog->hasAirDate, gmyth_program_info_non_null_value (prog->playgroup));
25.695 + ( "Title: %s, Subtitle: %s, Description: %s, Category: %s, Channel ID: %s, "
25.696 + "Channel Name: %s, Chan str: %s, Channel Sign: %s, Path Name: %s, File Size: %lld, \n"
25.697 + "Start TS: %s, End TS: %s, Duplicate: %d, Shareable: %d, Find ID: %d, Hostname: %s, "
25.698 + "Source ID: %d, Vard ID: %d, Input ID: %d, Rec Priority: %d, Reactivate: %d, \n"
25.699 + "Record ID: %d, Rec Start TS: %s, Rec End TS: %s, Repeat: %d, Program Flags: %d, "
25.700 + "Rec Group: %s, Channel Comm Free: %d, Channel Output Filters: %s, Series ID: %s, \n"
25.701 + "Program ID: %s, Last Modified Date: %s, Original Air Date: %s, Has Air Date: %d, "
25.702 + "Play Group: %s.\n",
25.703 + gmyth_program_info_non_null_value ( prog->title ),
25.704 + gmyth_program_info_non_null_value ( prog->subtitle ),
25.705 + gmyth_program_info_non_null_value ( prog->description ),
25.706 + gmyth_program_info_non_null_value ( prog->category ),
25.707 + gmyth_program_info_non_null_value ( prog->chanid ),
25.708 + gmyth_program_info_non_null_value ( prog->channame ),
25.709 + gmyth_program_info_non_null_value ( prog->chanstr ),
25.710 + gmyth_program_info_non_null_value ( prog->chansign ),
25.711 + gmyth_program_info_non_null_value ( prog->pathname ), prog->filesize,
25.712 + gmyth_util_time_to_string_from_time_val ( prog->startts ),
25.713 + gmyth_util_time_to_string_from_time_val ( prog->endts ),
25.714 + prog->duplicate, prog->shareable, prog->findid,
25.715 + gmyth_program_info_non_null_value ( prog->hostname ), prog->sourceid,
25.716 + prog->cardid, prog->inputid, prog->recpriority, prog->reactivate,
25.717 + prog->recordid,
25.718 + gmyth_util_time_to_string_from_time_val ( prog->recstartts ),
25.719 + gmyth_util_time_to_string_from_time_val ( prog->recendts ),
25.720 + prog->repeat, prog->programflags,
25.721 + gmyth_program_info_non_null_value ( prog->recgroup ),
25.722 + prog->chancommfree,
25.723 + gmyth_program_info_non_null_value ( prog->chanOutputFilters ),
25.724 + gmyth_program_info_non_null_value ( prog->seriesid ),
25.725 + gmyth_program_info_non_null_value ( prog->programid ),
25.726 + gmyth_util_time_to_string_from_time_val ( prog->lastmodified ),
25.727 + gmyth_util_time_to_string_from_time_val ( prog->originalAirDate ),
25.728 + prog->hasAirDate,
25.729 + gmyth_program_info_non_null_value ( prog->playgroup ) );
25.730 }
25.731
25.732 /**
25.733 @@ -533,15 +553,15 @@
25.734 * @return <code>true</code>, if the program infos are equals.
25.735 */
25.736 gboolean
25.737 -gmyth_program_info_is_equals (const GMythProgramInfo * prog1,
25.738 - const GMythProgramInfo * prog2)
25.739 +gmyth_program_info_is_equals ( const GMythProgramInfo * prog1,
25.740 + const GMythProgramInfo * prog2 )
25.741 {
25.742 - if ((strcmp (gmyth_program_info_non_null_value (prog1->title),
25.743 - gmyth_program_info_non_null_value (prog2->title)) == 0)
25.744 - ||
25.745 - (strcmp
25.746 - (gmyth_program_info_non_null_value (prog1->pathname),
25.747 - gmyth_program_info_non_null_value (prog2->pathname)) == 0))
25.748 + if ( ( strcmp ( gmyth_program_info_non_null_value ( prog1->title ),
25.749 + gmyth_program_info_non_null_value ( prog2->title ) ) == 0 )
25.750 + ||
25.751 + ( strcmp
25.752 + ( gmyth_program_info_non_null_value ( prog1->pathname ),
25.753 + gmyth_program_info_non_null_value ( prog2->pathname ) ) == 0 ) )
25.754 return TRUE;
25.755 else
25.756 return FALSE;
26.1 --- a/gmyth/src/gmyth_programinfo.h Wed May 23 19:21:26 2007 +0100
26.2 +++ b/gmyth/src/gmyth_programinfo.h Wed May 23 19:50:41 2007 +0100
26.3 @@ -10,23 +10,22 @@
26.4 * @author Rosfran Borges <rosfran.borges@indt.org.br>
26.5 * @author Leonardo Sobral Cunha <leonardo.cunha@indt.org.br>
26.6 *
26.7 - *//*
26.8 - *
26.9 - * This program is free software; you can redistribute it and/or modify
26.10 - * it under the terms of the GNU Lesser General Public License as published by
26.11 - * the Free Software Foundation; either version 2 of the License, or
26.12 - * (at your option) any later version.
26.13 - *
26.14 - * This program is distributed in the hope that it will be useful,
26.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
26.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26.17 - * GNU General Public License for more details.
26.18 - *
26.19 - * You should have received a copy of the GNU Lesser General Public License
26.20 - * along with this program; if not, write to the Free Software
26.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26.22 - *
26.23 - */
26.24 + *
26.25 + * This program is free software; you can redistribute it and/or modify
26.26 + * it under the terms of the GNU Lesser General Public License as published by
26.27 + * the Free Software Foundation; either version 2 of the License, or
26.28 + * (at your option) any later version.
26.29 + *
26.30 + * This program is distributed in the hope that it will be useful,
26.31 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
26.32 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26.33 + * GNU General Public License for more details.
26.34 + *
26.35 + * You should have received a copy of the GNU Lesser General Public License
26.36 + * along with this program; if not, write to the Free Software
26.37 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26.38 + *
26.39 + */
26.40
26.41 #ifndef _GMYTH_PROGRAMINFO_H
26.42 #define _GMYTH_PROGRAMINFO_H
26.43 @@ -47,11 +46,11 @@
26.44 typedef struct _GMythProgramInfoClass GMythProgramInfoClass;
26.45
26.46 struct _GMythProgramInfoClass
26.47 -{
26.48 - GObjectClass parent_class;
26.49 + {
26.50 + GObjectClass parent_class;
26.51
26.52 - /* callbacks */
26.53 -};
26.54 + /* callbacks */
26.55 + };
26.56
26.57 /**
26.58 * The GMythProgramInfo structure represents a program information
26.59 @@ -59,113 +58,115 @@
26.60 * a program scheduled to be recorded, or a program already recorded.
26.61 */
26.62 struct _GMythProgramInfo
26.63 -{
26.64 - GObject parent;
26.65 + {
26.66 + GObject parent;
26.67
26.68 /** The channel unique ID. */
26.69 - GString *chanid;
26.70 + GString *chanid;
26.71
26.72 /** The program start time. */
26.73 - GTimeVal *startts;
26.74 + GTimeVal *startts;
26.75 /** The program end time. */
26.76 - GTimeVal *endts;
26.77 + GTimeVal *endts;
26.78 /** The recording schedule start time. */
26.79 - GTimeVal *recstartts;
26.80 + GTimeVal *recstartts;
26.81 /** The recording schedule end time */
26.82 - GTimeVal *recendts;
26.83 + GTimeVal *recendts;
26.84
26.85 /** The program title. */
26.86 - GString *title;
26.87 + GString *title;
26.88 /** The program subtitle. */
26.89 - GString *subtitle;
26.90 + GString *subtitle;
26.91 /** The program description. */
26.92 - GString *description;
26.93 + GString *description;
26.94 /** The program category. */
26.95 - GString *category;
26.96 + GString *category;
26.97
26.98 - GString *chanstr;
26.99 - GString *chansign;
26.100 + GString *chanstr;
26.101 + GString *chansign;
26.102 /** The associated channel name. */
26.103 - GString *channame;
26.104 - gint chancommfree;
26.105 - GString *chanOutputFilters;
26.106 + GString *channame;
26.107 + gint chancommfree;
26.108 + GString *chanOutputFilters;
26.109
26.110 - GString *seriesid;
26.111 + GString *seriesid;
26.112 /** The program unique id. */
26.113 - GString *programid;
26.114 - GString *catType;
26.115 + GString *programid;
26.116 + GString *catType;
26.117
26.118 - GString *sortTitle;
26.119 + GString *sortTitle;
26.120
26.121 - /** A flag informing if the program has video or not. */
26.122 - gboolean isVideo;
26.123 - gint lenMins;
26.124 + /** A flag informing if the program has video or not. */
26.125 + gboolean isVideo;
26.126 + gint lenMins;
26.127
26.128 - GString *year;
26.129 - gdouble stars;
26.130 - gint repeat;
26.131 + GString *year;
26.132 + gdouble stars;
26.133 + gint repeat;
26.134
26.135 - GTimeVal *originalAirDate;
26.136 - GTimeVal *lastmodified;
26.137 - GTimeVal *lastInUseTime;
26.138 + GTimeVal *originalAirDate;
26.139 + GTimeVal *lastmodified;
26.140 + GTimeVal *lastInUseTime;
26.141
26.142 - gboolean hasAirDate;
26.143 + gboolean hasAirDate;
26.144
26.145 - gint spread;
26.146 - gint startCol;
26.147 + gint spread;
26.148 + gint startCol;
26.149
26.150 - gint recpriority2;
26.151 - gint reactivate;
26.152 + gint recpriority2;
26.153 + gint reactivate;
26.154
26.155 - gint recordid;
26.156 - gint parentid;
26.157 + gint recordid;
26.158 + gint parentid;
26.159
26.160 /** The backend video source id associated to this program.*/
26.161 - gint sourceid;
26.162 + gint sourceid;
26.163 /** the backend input id associated to this program.*/
26.164 - gint inputid;
26.165 + gint inputid;
26.166 /** The backend card id associated to this program.*/
26.167 - gint cardid;
26.168 - gboolean shareable;
26.169 - gboolean duplicate;
26.170 + gint cardid;
26.171 + gboolean shareable;
26.172 + gboolean duplicate;
26.173
26.174 - GString *schedulerid;
26.175 - gint findid;
26.176 + GString *schedulerid;
26.177 + gint findid;
26.178
26.179 - gint programflags;
26.180 - gint transcoder;
26.181 + gint programflags;
26.182 + gint transcoder;
26.183
26.184 - GString *recgroup;
26.185 - GString *playgroup;
26.186 - gint recpriority;
26.187 + GString *recgroup;
26.188 + GString *playgroup;
26.189 + gint recpriority;
26.190
26.191 - /** The file size of the recorded program.*/
26.192 - gint64 filesize;
26.193 + /** The file size of the recorded program.*/
26.194 + gint64 filesize;
26.195
26.196 /** The file name of the recorded program.*/
26.197 - GString *pathname;
26.198 - GString *hostname;
26.199 -};
26.200 + GString *pathname;
26.201 + GString *hostname;
26.202 + };
26.203
26.204 -GType gmyth_program_info_type (void);
26.205 +GType gmyth_program_info_type ( void );
26.206
26.207 -GMythProgramInfo *gmyth_program_info_new (void);
26.208 +GMythProgramInfo *gmyth_program_info_new ( void );
26.209
26.210 -GMythStringList *gmyth_program_info_to_string_list (GMythProgramInfo * prog,
26.211 - GMythStringList * slist);
26.212 +GMythStringList *gmyth_program_info_to_string_list ( GMythProgramInfo * prog,
26.213 + GMythStringList * slist );
26.214
26.215 -GMythProgramInfo *gmyth_program_info_from_string_list_from_pos (GMythStringList
26.216 - * slist, guint pos);
26.217 +GMythProgramInfo *gmyth_program_info_from_string_list_from_pos ( GMythStringList
26.218 + * slist,
26.219 + guint pos );
26.220
26.221 -GMythProgramInfo *gmyth_program_info_from_string_list (GMythStringList * slist);
26.222 +GMythProgramInfo *gmyth_program_info_from_string_list ( GMythStringList *
26.223 + slist );
26.224
26.225 GMythProgramInfo
26.226 - * gmyth_program_info_from_string_list_next_prog (GMythStringList * slist);
26.227 + * gmyth_program_info_from_string_list_next_prog ( GMythStringList * slist );
26.228
26.229 -const gchar *gmyth_program_info_to_string (const GMythProgramInfo * prog);
26.230 +const gchar *gmyth_program_info_to_string ( const GMythProgramInfo * prog );
26.231
26.232 -gboolean gmyth_program_info_is_equals (const GMythProgramInfo * prog1,
26.233 - const GMythProgramInfo * prog2);
26.234 +gboolean gmyth_program_info_is_equals ( const GMythProgramInfo * prog1,
26.235 + const GMythProgramInfo * prog2 );
26.236
26.237 G_END_DECLS
26.238 #endif /*_GMYTH_PROGRAMINFO_H*/
27.1 --- a/gmyth/src/gmyth_query.c Wed May 23 19:21:26 2007 +0100
27.2 +++ b/gmyth/src/gmyth_query.c Wed May 23 19:50:41 2007 +0100
27.3 @@ -9,22 +9,21 @@
27.4 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
27.5 * @author Leonardo Sobral Cunha <leonardo.cunha@indt.org.br>
27.6 *
27.7 - *//*
27.8 - *
27.9 - * This program is free software; you can redistribute it and/or modify
27.10 - * it under the terms of the GNU Lesser General Public License as published by
27.11 - * the Free Software Foundation; either version 2 of the License, or
27.12 - * (at your option) any later version.
27.13 - *
27.14 - * This program is distributed in the hope that it will be useful,
27.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
27.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27.17 - * GNU General Public License for more details.
27.18 - *
27.19 - * You should have received a copy of the GNU Lesser General Public License
27.20 - * along with this program; if not, write to the Free Software
27.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27.22 - */
27.23 + *
27.24 + * This program is free software; you can redistribute it and/or modify
27.25 + * it under the terms of the GNU Lesser General Public License as published by
27.26 + * the Free Software Foundation; either version 2 of the License, or
27.27 + * (at your option) any later version.
27.28 + *
27.29 + * This program is distributed in the hope that it will be useful,
27.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
27.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27.32 + * GNU General Public License for more details.
27.33 + *
27.34 + * You should have received a copy of the GNU Lesser General Public License
27.35 + * along with this program; if not, write to the Free Software
27.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27.37 + */
27.38
27.39 #ifdef HAVE_CONFIG_H
27.40 #include "config.h"
27.41 @@ -37,60 +36,62 @@
27.42 #include "gmyth_query.h"
27.43 #include "gmyth_debug.h"
27.44
27.45 -static void gmyth_query_class_init (GMythQueryClass * klass);
27.46 -static void gmyth_query_init (GMythQuery * object);
27.47 +static void gmyth_query_class_init ( GMythQueryClass * klass );
27.48 +static void gmyth_query_init ( GMythQuery * object );
27.49
27.50 -static void gmyth_query_dispose (GObject * object);
27.51 -static void gmyth_query_finalize (GObject * object);
27.52 +static void gmyth_query_dispose ( GObject * object );
27.53 +static void gmyth_query_finalize ( GObject * object );
27.54
27.55 -static void gmyth_query_print_error (MYSQL * conn, char *message);
27.56 +static void gmyth_query_print_error ( MYSQL * conn, char *message );
27.57
27.58 -G_DEFINE_TYPE (GMythQuery, gmyth_query, G_TYPE_OBJECT)
27.59 - static void gmyth_query_class_init (GMythQueryClass * klass)
27.60 +G_DEFINE_TYPE ( GMythQuery, gmyth_query, G_TYPE_OBJECT )
27.61 + static void gmyth_query_class_init ( GMythQueryClass * klass )
27.62 {
27.63 GObjectClass *gobject_class;
27.64
27.65 - gobject_class = (GObjectClass *) klass;
27.66 + gobject_class = ( GObjectClass * ) klass;
27.67
27.68 gobject_class->dispose = gmyth_query_dispose;
27.69 gobject_class->finalize = gmyth_query_finalize;
27.70 }
27.71
27.72 static void
27.73 -gmyth_query_init (GMythQuery * gmyth_query)
27.74 +gmyth_query_init ( GMythQuery * gmyth_query )
27.75 {
27.76 gmyth_query->backend_info = NULL;
27.77
27.78 /* initialize connection handler */
27.79 - gmyth_query->conn = mysql_init (NULL);
27.80 + gmyth_query->conn = mysql_init ( NULL );
27.81
27.82 - if (!(gmyth_query->conn))
27.83 - g_warning ("[%s] MSQL structure not initialized", __FUNCTION__);
27.84 + if ( !( gmyth_query->conn ) )
27.85 + g_warning ( "[%s] MSQL structure not initialized", __FUNCTION__ );
27.86 }
27.87
27.88 static void
27.89 -gmyth_query_dispose (GObject * object)
27.90 +gmyth_query_dispose ( GObject * object )
27.91 {
27.92 - GMythQuery *gmyth_query = GMYTH_QUERY (object);
27.93 + GMythQuery *gmyth_query = GMYTH_QUERY ( object );
27.94
27.95 - if (gmyth_query->conn != NULL) {
27.96 - gmyth_query_disconnect (gmyth_query);
27.97 + if ( gmyth_query->conn != NULL )
27.98 + {
27.99 + gmyth_query_disconnect ( gmyth_query );
27.100 }
27.101
27.102 - if (gmyth_query->backend_info) {
27.103 - g_object_unref (gmyth_query->backend_info);
27.104 + if ( gmyth_query->backend_info )
27.105 + {
27.106 + g_object_unref ( gmyth_query->backend_info );
27.107 gmyth_query->backend_info = NULL;
27.108 }
27.109
27.110 - G_OBJECT_CLASS (gmyth_query_parent_class)->dispose (object);
27.111 + G_OBJECT_CLASS ( gmyth_query_parent_class )->dispose ( object );
27.112 }
27.113
27.114 static void
27.115 -gmyth_query_finalize (GObject * object)
27.116 +gmyth_query_finalize ( GObject * object )
27.117 {
27.118 - g_signal_handlers_destroy (object);
27.119 + g_signal_handlers_destroy ( object );
27.120
27.121 - G_OBJECT_CLASS (gmyth_query_parent_class)->finalize (object);
27.122 + G_OBJECT_CLASS ( gmyth_query_parent_class )->finalize ( object );
27.123 }
27.124
27.125 /** Creates a new instance of GMythQuery.
27.126 @@ -98,30 +99,34 @@
27.127 * @return a new instance of GMythQuery.
27.128 */
27.129 GMythQuery *
27.130 -gmyth_query_new ()
27.131 +gmyth_query_new ( )
27.132 {
27.133 - GMythQuery *sql_query = GMYTH_QUERY (g_object_new (GMYTH_QUERY_TYPE, NULL));
27.134 + GMythQuery *sql_query =
27.135 + GMYTH_QUERY ( g_object_new ( GMYTH_QUERY_TYPE, NULL ) );
27.136
27.137 return sql_query;
27.138 }
27.139
27.140 gboolean
27.141 -gmyth_query_connect_with_timeout (GMythQuery * gmyth_query,
27.142 - GMythBackendInfo * backend_info, guint timeout)
27.143 +gmyth_query_connect_with_timeout ( GMythQuery * gmyth_query,
27.144 + GMythBackendInfo * backend_info,
27.145 + guint timeout )
27.146 {
27.147 - assert (gmyth_query);
27.148 + assert ( gmyth_query );
27.149
27.150 - if (gmyth_query->conn == NULL) {
27.151 - gmyth_query->conn = mysql_init (NULL);
27.152 + if ( gmyth_query->conn == NULL )
27.153 + {
27.154 + gmyth_query->conn = mysql_init ( NULL );
27.155 }
27.156
27.157 - if (timeout != 0) {
27.158 + if ( timeout != 0 )
27.159 + {
27.160 /* sets connection timeout */
27.161 - mysql_options (gmyth_query->conn, MYSQL_OPT_CONNECT_TIMEOUT,
27.162 - (gchar *) & timeout);
27.163 + mysql_options ( gmyth_query->conn, MYSQL_OPT_CONNECT_TIMEOUT,
27.164 + ( gchar * ) & timeout );
27.165 }
27.166
27.167 - return gmyth_query_connect (gmyth_query, backend_info);
27.168 + return gmyth_query_connect ( gmyth_query, backend_info );
27.169 }
27.170
27.171 /** Connects to the Mysql database in the backend. The backend address
27.172 @@ -131,42 +136,47 @@
27.173 * @return true if connection was success, false if failed.
27.174 */
27.175 gboolean
27.176 -gmyth_query_connect (GMythQuery * gmyth_query, GMythBackendInfo * backend_info)
27.177 +gmyth_query_connect ( GMythQuery * gmyth_query,
27.178 + GMythBackendInfo * backend_info )
27.179 {
27.180 - assert (gmyth_query);
27.181 - g_return_val_if_fail (backend_info != NULL, FALSE);
27.182 - g_return_val_if_fail (backend_info->hostname != NULL, FALSE);
27.183 - g_return_val_if_fail (backend_info->username != NULL, FALSE);
27.184 - g_return_val_if_fail (backend_info->password != NULL, FALSE);
27.185 - g_return_val_if_fail (backend_info->db_name != NULL, FALSE);
27.186 + assert ( gmyth_query );
27.187 + g_return_val_if_fail ( backend_info != NULL, FALSE );
27.188 + g_return_val_if_fail ( backend_info->hostname != NULL, FALSE );
27.189 + g_return_val_if_fail ( backend_info->username != NULL, FALSE );
27.190 + g_return_val_if_fail ( backend_info->password != NULL, FALSE );
27.191 + g_return_val_if_fail ( backend_info->db_name != NULL, FALSE );
27.192
27.193 - if (gmyth_query->backend_info != NULL) {
27.194 - g_object_unref (gmyth_query->backend_info);
27.195 + if ( gmyth_query->backend_info != NULL )
27.196 + {
27.197 + g_object_unref ( gmyth_query->backend_info );
27.198 }
27.199 - gmyth_query->backend_info = g_object_ref (backend_info);
27.200 + gmyth_query->backend_info = g_object_ref ( backend_info );
27.201
27.202 - if (gmyth_query->conn == NULL) {
27.203 - gmyth_query->conn = mysql_init (NULL);
27.204 + if ( gmyth_query->conn == NULL )
27.205 + {
27.206 + gmyth_query->conn = mysql_init ( NULL );
27.207 }
27.208
27.209 /* connect to server */
27.210 - if (mysql_real_connect (gmyth_query->conn,
27.211 - gmyth_query->backend_info->hostname,
27.212 - gmyth_query->backend_info->username,
27.213 - gmyth_query->backend_info->password,
27.214 - gmyth_query->backend_info->db_name, 0, NULL, 0) == NULL) {
27.215 - gmyth_query_print_error (gmyth_query->conn,
27.216 - "mysql_real_connect() failed");
27.217 + if ( mysql_real_connect ( gmyth_query->conn,
27.218 + gmyth_query->backend_info->hostname,
27.219 + gmyth_query->backend_info->username,
27.220 + gmyth_query->backend_info->password,
27.221 + gmyth_query->backend_info->db_name, 0, NULL,
27.222 + 0 ) == NULL )
27.223 + {
27.224 + gmyth_query_print_error ( gmyth_query->conn,
27.225 + "mysql_real_connect() failed" );
27.226 return FALSE;
27.227 }
27.228
27.229 gmyth_debug
27.230 - ("[%s] Connection to Mysql server succeeded! (host = %s, user = %s, "
27.231 - "password = %s, db name = %s)", __FUNCTION__,
27.232 - gmyth_query->backend_info->hostname,
27.233 - gmyth_query->backend_info->username,
27.234 - gmyth_query->backend_info->password,
27.235 - gmyth_query->backend_info->db_name);
27.236 + ( "[%s] Connection to Mysql server succeeded! (host = %s, user = %s, "
27.237 + "password = %s, db name = %s)", __FUNCTION__,
27.238 + gmyth_query->backend_info->hostname,
27.239 + gmyth_query->backend_info->username,
27.240 + gmyth_query->backend_info->password,
27.241 + gmyth_query->backend_info->db_name );
27.242
27.243 return TRUE;
27.244 }
27.245 @@ -177,31 +187,34 @@
27.246 * @return true if disconnection was success, false if failed.
27.247 */
27.248 gboolean
27.249 -gmyth_query_disconnect (GMythQuery * gmyth_query)
27.250 +gmyth_query_disconnect ( GMythQuery * gmyth_query )
27.251 {
27.252 - g_return_val_if_fail (gmyth_query != NULL, FALSE);
27.253 - g_return_val_if_fail (gmyth_query->conn != NULL, FALSE);
27.254 + g_return_val_if_fail ( gmyth_query != NULL, FALSE );
27.255 + g_return_val_if_fail ( gmyth_query->conn != NULL, FALSE );
27.256
27.257 /* TODO: Check how to return error */
27.258 - gmyth_debug ("[%s] Closing gmyth_query->conn", __FUNCTION__);
27.259 + gmyth_debug ( "[%s] Closing gmyth_query->conn", __FUNCTION__ );
27.260
27.261 - mysql_close (gmyth_query->conn);
27.262 + mysql_close ( gmyth_query->conn );
27.263 gmyth_query->conn = NULL;
27.264
27.265 return TRUE;
27.266 }
27.267
27.268 static void
27.269 -gmyth_query_print_error (MYSQL * conn, char *message)
27.270 +gmyth_query_print_error ( MYSQL * conn, char *message )
27.271 {
27.272 - gmyth_debug ("%s", message);
27.273 + gmyth_debug ( "%s", message );
27.274
27.275 - if (conn != NULL) {
27.276 + if ( conn != NULL )
27.277 + {
27.278 #if MYSQL_VERSION_ID >= 40101
27.279 - gmyth_debug ("Error %u (%s): %s\n",
27.280 - mysql_errno (conn), mysql_sqlstate (conn), mysql_error (conn));
27.281 + gmyth_debug ( "Error %u (%s): %s\n",
27.282 + mysql_errno ( conn ), mysql_sqlstate ( conn ),
27.283 + mysql_error ( conn ) );
27.284 #else
27.285 - gmyth_debug ("Error %u: %s\n", mysql_errno (conn), mysql_error (conn));
27.286 + gmyth_debug ( "Error %u: %s\n", mysql_errno ( conn ),
27.287 + mysql_error ( conn ) );
27.288 #endif
27.289 }
27.290 }
27.291 @@ -217,46 +230,48 @@
27.292 * @return the MYSQL_RES result pointer or NULL if any error happens.
27.293 */
27.294 MYSQL_RES *
27.295 -gmyth_query_process_statement (GMythQuery * gmyth_query, char *stmt_str)
27.296 +gmyth_query_process_statement ( GMythQuery * gmyth_query, char *stmt_str )
27.297 {
27.298 - assert (gmyth_query);
27.299 + assert ( gmyth_query );
27.300
27.301 - gmyth_debug ("[%s] Running mysql query %s", __FUNCTION__, stmt_str);
27.302 + gmyth_debug ( "[%s] Running mysql query %s", __FUNCTION__, stmt_str );
27.303
27.304 - if (gmyth_query == NULL)
27.305 + if ( gmyth_query == NULL )
27.306 return NULL;
27.307
27.308 /* the statement failed */
27.309 - if (mysql_query (gmyth_query->conn, stmt_str) != 0) {
27.310 - gmyth_query_print_error (gmyth_query->conn,
27.311 - "Could not execute statement");
27.312 + if ( mysql_query ( gmyth_query->conn, stmt_str ) != 0 )
27.313 + {
27.314 + gmyth_query_print_error ( gmyth_query->conn,
27.315 + "Could not execute statement" );
27.316 return NULL;
27.317 }
27.318
27.319 /* the statement succeeded; determine whether it returned data */
27.320 - return mysql_store_result (gmyth_query->conn);
27.321 + return mysql_store_result ( gmyth_query->conn );
27.322 }
27.323
27.324 MYSQL_RES *
27.325 -gmyth_query_process_statement_with_increment (GMythQuery * gmyth_query,
27.326 - char *stmt_str, gulong * id)
27.327 +gmyth_query_process_statement_with_increment ( GMythQuery * gmyth_query,
27.328 + char *stmt_str, gulong * id )
27.329 {
27.330 - assert (gmyth_query);
27.331 + assert ( gmyth_query );
27.332
27.333 - gmyth_debug ("[%s] Running mysql query %s", __FUNCTION__, stmt_str);
27.334 + gmyth_debug ( "[%s] Running mysql query %s", __FUNCTION__, stmt_str );
27.335
27.336 - if (gmyth_query == NULL)
27.337 + if ( gmyth_query == NULL )
27.338 return NULL;
27.339
27.340 /* the statement failed */
27.341 - if (mysql_query (gmyth_query->conn, stmt_str) != 0) {
27.342 - gmyth_query_print_error (gmyth_query->conn,
27.343 - "Could not execute statement");
27.344 + if ( mysql_query ( gmyth_query->conn, stmt_str ) != 0 )
27.345 + {
27.346 + gmyth_query_print_error ( gmyth_query->conn,
27.347 + "Could not execute statement" );
27.348 return NULL;
27.349 }
27.350
27.351 - *id = (my_ulonglong) mysql_insert_id (gmyth_query->conn);
27.352 + *id = ( my_ulonglong ) mysql_insert_id ( gmyth_query->conn );
27.353
27.354 /* the statement succeeded; determine whether it returned data */
27.355 - return mysql_store_result (gmyth_query->conn);
27.356 + return mysql_store_result ( gmyth_query->conn );
27.357 }
28.1 --- a/gmyth/src/gmyth_query.h Wed May 23 19:21:26 2007 +0100
28.2 +++ b/gmyth/src/gmyth_query.h Wed May 23 19:50:41 2007 +0100
28.3 @@ -9,22 +9,21 @@
28.4 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
28.5 * @author Leonardo Sobral Cunha <leonardo.cunha@indt.org.br>
28.6 *
28.7 - *//*
28.8 - *
28.9 - * This program is free software; you can redistribute it and/or modify
28.10 - * it under the terms of the GNU Lesser General Public License as published by
28.11 - * the Free Software Foundation; either version 2 of the License, or
28.12 - * (at your option) any later version.
28.13 - *
28.14 - * This program is distributed in the hope that it will be useful,
28.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
28.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28.17 - * GNU General Public License for more details.
28.18 - *
28.19 - * You should have received a copy of the GNU Lesser General Public License
28.20 - * along with this program; if not, write to the Free Software
28.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28.22 - */
28.23 + *
28.24 + * This program is free software; you can redistribute it and/or modify
28.25 + * it under the terms of the GNU Lesser General Public License as published by
28.26 + * the Free Software Foundation; either version 2 of the License, or
28.27 + * (at your option) any later version.
28.28 + *
28.29 + * This program is distributed in the hope that it will be useful,
28.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
28.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28.32 + * GNU General Public License for more details.
28.33 + *
28.34 + * You should have received a copy of the GNU Lesser General Public License
28.35 + * along with this program; if not, write to the Free Software
28.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28.37 + */
28.38
28.39 #ifndef __GMYTH_QUERY_H__
28.40 #define __GMYTH_QUERY_H__
28.41 @@ -47,37 +46,40 @@
28.42 typedef struct _GMythQueryClass GMythQueryClass;
28.43
28.44 struct _GMythQueryClass
28.45 -{
28.46 - GObjectClass parent_class;
28.47 + {
28.48 + GObjectClass parent_class;
28.49
28.50 - /* callbacks */
28.51 - /* no one for now */
28.52 -};
28.53 + /* callbacks */
28.54 + /* no one for now */
28.55 + };
28.56
28.57 struct _GMythQuery
28.58 -{
28.59 - GObject parent;
28.60 + {
28.61 + GObject parent;
28.62
28.63 - GMythBackendInfo *backend_info;
28.64 + GMythBackendInfo *backend_info;
28.65
28.66 - /* pointer to connection handler */
28.67 - MYSQL *conn;
28.68 -};
28.69 + /* pointer to connection handler */
28.70 + MYSQL *conn;
28.71 + };
28.72
28.73
28.74 -GType gmyth_query_get_type (void);
28.75 +GType gmyth_query_get_type ( void );
28.76
28.77 -GMythQuery *gmyth_query_new (void);
28.78 -MYSQL_RES *gmyth_query_process_statement (GMythQuery * gmyth_query,
28.79 - gchar * stmt_str);
28.80 -MYSQL_RES *gmyth_query_process_statement_with_increment (GMythQuery *
28.81 - gmyth_query, char *stmt_str, gulong * id);
28.82 +GMythQuery *gmyth_query_new ( void );
28.83 +MYSQL_RES *gmyth_query_process_statement ( GMythQuery * gmyth_query,
28.84 + gchar * stmt_str );
28.85 +MYSQL_RES *gmyth_query_process_statement_with_increment ( GMythQuery *
28.86 + gmyth_query,
28.87 + char *stmt_str,
28.88 + gulong * id );
28.89
28.90 -gboolean gmyth_query_connect (GMythQuery * gmyth_query,
28.91 - GMythBackendInfo * backend_info);
28.92 -gboolean gmyth_query_connect_with_timeout (GMythQuery * gmyth_query,
28.93 - GMythBackendInfo * backend_info, guint timeout);
28.94 -gboolean gmyth_query_disconnect (GMythQuery * gmyth_query);
28.95 +gboolean gmyth_query_connect ( GMythQuery * gmyth_query,
28.96 + GMythBackendInfo * backend_info );
28.97 +gboolean gmyth_query_connect_with_timeout ( GMythQuery * gmyth_query,
28.98 + GMythBackendInfo * backend_info,
28.99 + guint timeout );
28.100 +gboolean gmyth_query_disconnect ( GMythQuery * gmyth_query );
28.101
28.102 G_END_DECLS
28.103 #endif /* __GMYTH_QUERY_H__ */
29.1 --- a/gmyth/src/gmyth_recorder.c Wed May 23 19:21:26 2007 +0100
29.2 +++ b/gmyth/src/gmyth_recorder.c Wed May 23 19:50:41 2007 +0100
29.3 @@ -11,22 +11,21 @@
29.4 * @author Hallyson Luiz de Morais Melo <hallyson.melo@indt.org.br>
29.5 * @author Rosfran Borges <rosfran.borges@indt.org.br>
29.6 *
29.7 - *//*
29.8 - *
29.9 - * This program is free software; you can redistribute it and/or modify
29.10 - * it under the terms of the GNU Lesser General Public License as published by
29.11 - * the Free Software Foundation; either version 2 of the License, or
29.12 - * (at your option) any later version.
29.13 - *
29.14 - * This program is distributed in the hope that it will be useful,
29.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
29.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29.17 - * GNU General Public License for more details.
29.18 - *
29.19 - * You should have received a copy of the GNU Lesser General Public License
29.20 - * along with this program; if not, write to the Free Software
29.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29.22 - */
29.23 + *
29.24 + * This program is free software; you can redistribute it and/or modify
29.25 + * it under the terms of the GNU Lesser General Public License as published by
29.26 + * the Free Software Foundation; either version 2 of the License, or
29.27 + * (at your option) any later version.
29.28 + *
29.29 + * This program is distributed in the hope that it will be useful,
29.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
29.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29.32 + * GNU General Public License for more details.
29.33 + *
29.34 + * You should have received a copy of the GNU Lesser General Public License
29.35 + * along with this program; if not, write to the Free Software
29.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29.37 + */
29.38
29.39 #ifdef HAVE_CONFIG_H
29.40 #include "config.h"
29.41 @@ -43,74 +42,77 @@
29.42
29.43 #define GMYTHTV_RECORDER_HEADER "QUERY_RECORDER"
29.44
29.45 -static void gmyth_recorder_class_init (GMythRecorderClass * klass);
29.46 -static void gmyth_recorder_init (GMythRecorder * object);
29.47 +static void gmyth_recorder_class_init ( GMythRecorderClass * klass );
29.48 +static void gmyth_recorder_init ( GMythRecorder * object );
29.49
29.50 -static void gmyth_recorder_dispose (GObject * object);
29.51 -static void gmyth_recorder_finalize (GObject * object);
29.52 +static void gmyth_recorder_dispose ( GObject * object );
29.53 +static void gmyth_recorder_finalize ( GObject * object );
29.54
29.55 -G_DEFINE_TYPE (GMythRecorder, gmyth_recorder, G_TYPE_OBJECT)
29.56 - static void gmyth_recorder_class_init (GMythRecorderClass * klass)
29.57 +G_DEFINE_TYPE ( GMythRecorder, gmyth_recorder, G_TYPE_OBJECT )
29.58 + static void gmyth_recorder_class_init ( GMythRecorderClass * klass )
29.59 {
29.60 GObjectClass *gobject_class;
29.61
29.62 - gobject_class = (GObjectClass *) klass;
29.63 + gobject_class = ( GObjectClass * ) klass;
29.64
29.65 gobject_class->dispose = gmyth_recorder_dispose;
29.66 gobject_class->finalize = gmyth_recorder_finalize;
29.67 }
29.68
29.69 static void
29.70 -gmyth_recorder_init (GMythRecorder * gmyth_remote_encoder)
29.71 +gmyth_recorder_init ( GMythRecorder * gmyth_remote_encoder )
29.72 {
29.73 }
29.74
29.75 static void
29.76 -gmyth_recorder_dispose (GObject * object)
29.77 +gmyth_recorder_dispose ( GObject * object )
29.78 {
29.79 - GMythRecorder *recorder = GMYTH_RECORDER (object);
29.80 + GMythRecorder *recorder = GMYTH_RECORDER ( object );
29.81
29.82 - gmyth_recorder_close (recorder);
29.83 + gmyth_recorder_close ( recorder );
29.84
29.85 - if (recorder->mutex != NULL) {
29.86 - g_mutex_free (recorder->mutex);
29.87 + if ( recorder->mutex != NULL )
29.88 + {
29.89 + g_mutex_free ( recorder->mutex );
29.90 recorder->mutex = NULL;
29.91 }
29.92
29.93 - if (recorder->myth_socket != NULL) {
29.94 - g_object_unref (recorder->myth_socket);
29.95 + if ( recorder->myth_socket != NULL )
29.96 + {
29.97 + g_object_unref ( recorder->myth_socket );
29.98 recorder->myth_socket = NULL;
29.99 }
29.100
29.101 - if (recorder->progs_info_list != NULL)
29.102 - gmyth_free_program_list (recorder->progs_info_list);
29.103 + if ( recorder->progs_info_list != NULL )
29.104 + gmyth_free_program_list ( recorder->progs_info_list );
29.105
29.106 - if (recorder->hostname != NULL)
29.107 - g_string_free (recorder->hostname, TRUE);
29.108 + if ( recorder->hostname != NULL )
29.109 + g_string_free ( recorder->hostname, TRUE );
29.110
29.111 - G_OBJECT_CLASS (gmyth_recorder_parent_class)->dispose (object);
29.112 + G_OBJECT_CLASS ( gmyth_recorder_parent_class )->dispose ( object );
29.113 }
29.114
29.115 static void
29.116 -gmyth_recorder_finalize (GObject * object)
29.117 +gmyth_recorder_finalize ( GObject * object )
29.118 {
29.119 - g_signal_handlers_destroy (object);
29.120 + g_signal_handlers_destroy ( object );
29.121
29.122 - G_OBJECT_CLASS (gmyth_recorder_parent_class)->finalize (object);
29.123 + G_OBJECT_CLASS ( gmyth_recorder_parent_class )->finalize ( object );
29.124 }
29.125
29.126 void
29.127 -gmyth_recorder_close (GMythRecorder * recorder)
29.128 +gmyth_recorder_close ( GMythRecorder * recorder )
29.129 {
29.130 - if (recorder != NULL && recorder->recorder_num != -1) {
29.131 - g_mutex_lock (recorder->mutex);
29.132 + if ( recorder != NULL && recorder->recorder_num != -1 )
29.133 + {
29.134 + g_mutex_lock ( recorder->mutex );
29.135
29.136 - gmyth_recorder_stop_playing (recorder);
29.137 - gmyth_recorder_stop_livetv (recorder);
29.138 - gmyth_recorder_finish_recording (recorder);
29.139 - gmyth_recorder_free_tuner (recorder);
29.140 + gmyth_recorder_stop_playing ( recorder );
29.141 + gmyth_recorder_stop_livetv ( recorder );
29.142 + gmyth_recorder_finish_recording ( recorder );
29.143 + gmyth_recorder_free_tuner ( recorder );
29.144
29.145 - g_mutex_unlock (recorder->mutex);
29.146 + g_mutex_unlock ( recorder->mutex );
29.147 }
29.148 }
29.149
29.150 @@ -119,16 +121,16 @@
29.151 * @return a new instance of GMythRecorder.
29.152 */
29.153 GMythRecorder *
29.154 -gmyth_recorder_new (int num, GString * hostname, gshort port)
29.155 +gmyth_recorder_new ( int num, GString * hostname, gshort port )
29.156 {
29.157 GMythRecorder *encoder =
29.158 - GMYTH_RECORDER (g_object_new (GMYTH_RECORDER_TYPE, FALSE));
29.159 + GMYTH_RECORDER ( g_object_new ( GMYTH_RECORDER_TYPE, FALSE ) );
29.160
29.161 encoder->recorder_num = num;
29.162 - encoder->hostname = g_string_new (hostname->str);
29.163 + encoder->hostname = g_string_new ( hostname->str );
29.164 encoder->port = port;
29.165
29.166 - encoder->mutex = g_mutex_new ();
29.167 + encoder->mutex = g_mutex_new ( );
29.168
29.169 encoder->progs_info_list = NULL;
29.170
29.171 @@ -142,22 +144,27 @@
29.172 * @return TRUE if successfull, FALSE if any error happens.
29.173 */
29.174 gboolean
29.175 -gmyth_recorder_setup (GMythRecorder * recorder)
29.176 +gmyth_recorder_setup ( GMythRecorder * recorder )
29.177 {
29.178 - assert (recorder);
29.179 - gmyth_debug ("[%s] Creating socket and connecting to backend",
29.180 - __FUNCTION__);
29.181 + assert ( recorder );
29.182 + gmyth_debug ( "[%s] Creating socket and connecting to backend",
29.183 + __FUNCTION__ );
29.184
29.185 - if (recorder->myth_socket == NULL) {
29.186 - recorder->myth_socket = gmyth_socket_new ();
29.187 + if ( recorder->myth_socket == NULL )
29.188 + {
29.189 + recorder->myth_socket = gmyth_socket_new ( );
29.190
29.191 - if (!gmyth_socket_connect_to_backend (recorder->myth_socket,
29.192 - recorder->hostname->str, recorder->port, TRUE)) {
29.193 - gmyth_debug ("GMythRemoteEncoder: Connection to backend failed");
29.194 + if ( !gmyth_socket_connect_to_backend ( recorder->myth_socket,
29.195 + recorder->hostname->str,
29.196 + recorder->port, TRUE ) )
29.197 + {
29.198 + gmyth_debug ( "GMythRemoteEncoder: Connection to backend failed" );
29.199 return FALSE;
29.200 }
29.201 - } else {
29.202 - gmyth_debug ("Remote encoder socket already created\n");
29.203 + }
29.204 + else
29.205 + {
29.206 + gmyth_debug ( "Remote encoder socket already created\n" );
29.207 }
29.208
29.209 return TRUE;
29.210 @@ -171,52 +178,54 @@
29.211 * @return true if success, false if any error happens.
29.212 */
29.213 gboolean
29.214 -gmyth_recorder_spawntv (GMythRecorder * recorder, GString * tvchain_id)
29.215 +gmyth_recorder_spawntv ( GMythRecorder * recorder, GString * tvchain_id )
29.216 {
29.217 GMythStringList *str_list;
29.218 - GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER);
29.219 + GString *tmp_str = g_string_new ( GMYTHTV_RECORDER_HEADER );
29.220 gboolean ret = TRUE;
29.221
29.222 - gmyth_debug ("[%s] Spawntv with tvchain_id = %s", __FUNCTION__,
29.223 - tvchain_id->str);
29.224 + gmyth_debug ( "[%s] Spawntv with tvchain_id = %s", __FUNCTION__,
29.225 + tvchain_id->str );
29.226
29.227 - str_list = gmyth_string_list_new ();
29.228 + str_list = gmyth_string_list_new ( );
29.229
29.230 - g_mutex_lock (recorder->mutex);
29.231 + g_mutex_lock ( recorder->mutex );
29.232
29.233 - g_string_append_printf (tmp_str, " %d", recorder->recorder_num);
29.234 + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
29.235
29.236 - gmyth_string_list_append_string (str_list, tmp_str);
29.237 - g_string_free (tmp_str, TRUE);
29.238 + gmyth_string_list_append_string ( str_list, tmp_str );
29.239 + g_string_free ( tmp_str, TRUE );
29.240
29.241 - gmyth_string_list_append_char_array (str_list, "SPAWN_LIVETV");
29.242 + gmyth_string_list_append_char_array ( str_list, "SPAWN_LIVETV" );
29.243
29.244 - gmyth_string_list_append_string (str_list, tvchain_id);
29.245 - gmyth_string_list_append_int (str_list, 0); // PIP = FALSE (0)
29.246 + gmyth_string_list_append_string ( str_list, tvchain_id );
29.247 + gmyth_string_list_append_int ( str_list, 0 ); // PIP = FALSE (0)
29.248
29.249 - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
29.250 + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list );
29.251
29.252 - tmp_str = gmyth_string_list_get_string (str_list, 0);
29.253 + tmp_str = gmyth_string_list_get_string ( str_list, 0 );
29.254
29.255 - if (tmp_str == NULL) {
29.256 - gmyth_debug ("[%s] Spawntv request returned %s", __FUNCTION__,
29.257 - tmp_str->str);
29.258 + if ( tmp_str == NULL )
29.259 + {
29.260 + gmyth_debug ( "[%s] Spawntv request returned %s", __FUNCTION__,
29.261 + tmp_str->str );
29.262 ret = FALSE;
29.263 goto cleanup;
29.264 }
29.265
29.266 - if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) {
29.267 - gmyth_debug ("[%s] Spawntv request returned %s", __FUNCTION__,
29.268 - tmp_str->str);
29.269 + if ( g_ascii_strncasecmp ( tmp_str->str, "ok", 2 ) )
29.270 + {
29.271 + gmyth_debug ( "[%s] Spawntv request returned %s", __FUNCTION__,
29.272 + tmp_str->str );
29.273 ret = FALSE;
29.274 goto cleanup;
29.275 }
29.276
29.277 cleanup:
29.278 - g_mutex_unlock (recorder->mutex);
29.279 + g_mutex_unlock ( recorder->mutex );
29.280
29.281 - g_string_free (tmp_str, TRUE);
29.282 - g_object_unref (str_list);
29.283 + g_string_free ( tmp_str, TRUE );
29.284 + g_object_unref ( str_list );
29.285
29.286 return ret;
29.287 }
29.288 @@ -230,48 +239,50 @@
29.289 * @return true if success, false if any error happens.
29.290 */
29.291 gboolean
29.292 -gmyth_recorder_spawntv_no_tvchain (GMythRecorder * recorder)
29.293 +gmyth_recorder_spawntv_no_tvchain ( GMythRecorder * recorder )
29.294 {
29.295 GMythStringList *str_list;
29.296 - GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER);
29.297 + GString *tmp_str = g_string_new ( GMYTHTV_RECORDER_HEADER );
29.298 gboolean ret = TRUE;
29.299
29.300 - gmyth_debug ("[%s] Spawntv, no TV chain!", __FUNCTION__);
29.301 + gmyth_debug ( "[%s] Spawntv, no TV chain!", __FUNCTION__ );
29.302
29.303 - str_list = gmyth_string_list_new ();
29.304 + str_list = gmyth_string_list_new ( );
29.305
29.306 - g_mutex_lock (recorder->mutex);
29.307 + g_mutex_lock ( recorder->mutex );
29.308
29.309 - g_string_append_printf (tmp_str, " %d", recorder->recorder_num);
29.310 + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
29.311
29.312 - gmyth_string_list_append_string (str_list, tmp_str);
29.313 - g_string_free (tmp_str, TRUE);
29.314 + gmyth_string_list_append_string ( str_list, tmp_str );
29.315 + g_string_free ( tmp_str, TRUE );
29.316
29.317 - gmyth_string_list_append_char_array (str_list, "SPAWN_LIVETV");
29.318 + gmyth_string_list_append_char_array ( str_list, "SPAWN_LIVETV" );
29.319
29.320 - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
29.321 + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list );
29.322
29.323 - tmp_str = gmyth_string_list_get_string (str_list, 0);
29.324 + tmp_str = gmyth_string_list_get_string ( str_list, 0 );
29.325
29.326 - if (tmp_str == NULL) {
29.327 - gmyth_debug ("[%s] Spawntv request returned %s", __FUNCTION__,
29.328 - tmp_str->str);
29.329 + if ( tmp_str == NULL )
29.330 + {
29.331 + gmyth_debug ( "[%s] Spawntv request returned %s", __FUNCTION__,
29.332 + tmp_str->str );
29.333 ret = FALSE;
29.334 goto cleanup;
29.335 }
29.336
29.337 - if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) {
29.338 - gmyth_debug ("[%s] Spawntv request returned %s", __FUNCTION__,
29.339 - tmp_str->str);
29.340 + if ( g_ascii_strncasecmp ( tmp_str->str, "ok", 2 ) )
29.341 + {
29.342 + gmyth_debug ( "[%s] Spawntv request returned %s", __FUNCTION__,
29.343 + tmp_str->str );
29.344 ret = FALSE;
29.345 goto cleanup;
29.346 }
29.347
29.348 cleanup:
29.349 - g_mutex_unlock (recorder->mutex);
29.350 + g_mutex_unlock ( recorder->mutex );
29.351
29.352 - g_string_free (tmp_str, TRUE);
29.353 - g_object_unref (str_list);
29.354 + g_string_free ( tmp_str, TRUE );
29.355 + g_object_unref ( str_list );
29.356
29.357 return ret;
29.358 }
29.359 @@ -282,37 +293,38 @@
29.360 * @return true if success, false if any error happens.
29.361 */
29.362 gboolean
29.363 -gmyth_recorder_stop_livetv (GMythRecorder * recorder)
29.364 +gmyth_recorder_stop_livetv ( GMythRecorder * recorder )
29.365 {
29.366 GMythStringList *str_list;
29.367 - GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER);
29.368 + GString *tmp_str = g_string_new ( GMYTHTV_RECORDER_HEADER );
29.369 gboolean ret = TRUE;
29.370
29.371 - gmyth_debug ("[%s]", __FUNCTION__);
29.372 + gmyth_debug ( "[%s]", __FUNCTION__ );
29.373
29.374 - str_list = gmyth_string_list_new ();
29.375 + str_list = gmyth_string_list_new ( );
29.376
29.377 - g_string_append_printf (tmp_str, " %d", recorder->recorder_num);
29.378 + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
29.379
29.380 - gmyth_string_list_append_string (str_list, tmp_str);
29.381 - g_string_free (tmp_str, TRUE);
29.382 + gmyth_string_list_append_string ( str_list, tmp_str );
29.383 + g_string_free ( tmp_str, TRUE );
29.384
29.385 - gmyth_string_list_append_char_array (str_list, "STOP_LIVETV");
29.386 + gmyth_string_list_append_char_array ( str_list, "STOP_LIVETV" );
29.387
29.388 - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
29.389 + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list );
29.390
29.391 - tmp_str = gmyth_string_list_get_string (str_list, 0);
29.392 + tmp_str = gmyth_string_list_get_string ( str_list, 0 );
29.393
29.394 - if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) {
29.395 - gmyth_debug ("[%s] Stop livetv request returned %s", __FUNCTION__,
29.396 - tmp_str->str);
29.397 + if ( g_ascii_strncasecmp ( tmp_str->str, "ok", 2 ) )
29.398 + {
29.399 + gmyth_debug ( "[%s] Stop livetv request returned %s", __FUNCTION__,
29.400 + tmp_str->str );
29.401 ret = FALSE;
29.402 goto cleanup;
29.403 }
29.404
29.405 cleanup:
29.406 - g_string_free (tmp_str, TRUE);
29.407 - g_object_unref (str_list);
29.408 + g_string_free ( tmp_str, TRUE );
29.409 + g_object_unref ( str_list );
29.410
29.411 return ret;
29.412 }
29.413 @@ -324,49 +336,51 @@
29.414 * @return TRUE if success, FALSE if any error happens.
29.415 */
29.416 gboolean
29.417 -gmyth_recorder_send_frontend_ready_command (GMythRecorder * recorder)
29.418 +gmyth_recorder_send_frontend_ready_command ( GMythRecorder * recorder )
29.419 {
29.420 GMythStringList *str_list;
29.421 - GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER);
29.422 + GString *tmp_str = g_string_new ( GMYTHTV_RECORDER_HEADER );
29.423 gboolean ret = TRUE;
29.424
29.425 - gmyth_debug ("[%s] FRONTEND_READY with recorder id = %d", __FUNCTION__,
29.426 - recorder->recorder_num);
29.427 + gmyth_debug ( "[%s] FRONTEND_READY with recorder id = %d", __FUNCTION__,
29.428 + recorder->recorder_num );
29.429
29.430 - str_list = gmyth_string_list_new ();
29.431 + str_list = gmyth_string_list_new ( );
29.432
29.433 - g_mutex_lock (recorder->mutex);
29.434 + g_mutex_lock ( recorder->mutex );
29.435
29.436 - g_string_append_printf (tmp_str, " %d", recorder->recorder_num);
29.437 + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
29.438
29.439 - gmyth_string_list_append_string (str_list, tmp_str);
29.440 - g_string_free (tmp_str, TRUE);
29.441 + gmyth_string_list_append_string ( str_list, tmp_str );
29.442 + g_string_free ( tmp_str, TRUE );
29.443
29.444 - gmyth_string_list_append_char_array (str_list, "FRONTEND_READY");
29.445 + gmyth_string_list_append_char_array ( str_list, "FRONTEND_READY" );
29.446
29.447 - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
29.448 + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list );
29.449
29.450 - tmp_str = gmyth_string_list_get_string (str_list, 0);
29.451 + tmp_str = gmyth_string_list_get_string ( str_list, 0 );
29.452
29.453 - if (tmp_str == NULL) {
29.454 + if ( tmp_str == NULL )
29.455 + {
29.456 gmyth_debug
29.457 - ("[%s] FRONTEND_READY command request couldn't returns, reason: %s",
29.458 - __FUNCTION__, tmp_str->str);
29.459 + ( "[%s] FRONTEND_READY command request couldn't returns, reason: %s",
29.460 + __FUNCTION__, tmp_str->str );
29.461 ret = FALSE;
29.462 goto cleanup;
29.463 }
29.464
29.465 - if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) {
29.466 - gmyth_debug ("[%s] FRONTEND_READY request returned %s", __FUNCTION__,
29.467 - tmp_str->str);
29.468 + if ( g_ascii_strncasecmp ( tmp_str->str, "ok", 2 ) )
29.469 + {
29.470 + gmyth_debug ( "[%s] FRONTEND_READY request returned %s", __FUNCTION__,
29.471 + tmp_str->str );
29.472 ret = FALSE;
29.473 goto cleanup;
29.474 }
29.475
29.476 cleanup:
29.477 - g_mutex_unlock (recorder->mutex);
29.478 - g_string_free (tmp_str, TRUE);
29.479 - g_object_unref (str_list);
29.480 + g_mutex_unlock ( recorder->mutex );
29.481 + g_string_free ( tmp_str, TRUE );
29.482 + g_object_unref ( str_list );
29.483
29.484 return ret;
29.485 }
29.486 @@ -379,50 +393,53 @@
29.487 * @return true if success, false if any error happens.
29.488 */
29.489 gboolean
29.490 -gmyth_recorder_check_channel_name (GMythRecorder * recorder, gchar * channel)
29.491 +gmyth_recorder_check_channel_name ( GMythRecorder * recorder, gchar * channel )
29.492 {
29.493 GMythStringList *str_list;
29.494 - GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER);
29.495 + GString *tmp_str = g_string_new ( GMYTHTV_RECORDER_HEADER );
29.496 gboolean ret = TRUE;
29.497
29.498 - gmyth_debug ("[%s] CHECK_CHANNEL with channel = %s", __FUNCTION__, channel);
29.499 + gmyth_debug ( "[%s] CHECK_CHANNEL with channel = %s", __FUNCTION__,
29.500 + channel );
29.501
29.502 - str_list = gmyth_string_list_new ();
29.503 + str_list = gmyth_string_list_new ( );
29.504
29.505 - g_mutex_lock (recorder->mutex);
29.506 + g_mutex_lock ( recorder->mutex );
29.507
29.508 - g_string_append_printf (tmp_str, " %d", recorder->recorder_num);
29.509 + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
29.510
29.511 - gmyth_string_list_append_string (str_list, tmp_str);
29.512 - g_string_free (tmp_str, TRUE);
29.513 + gmyth_string_list_append_string ( str_list, tmp_str );
29.514 + g_string_free ( tmp_str, TRUE );
29.515
29.516 - gmyth_string_list_append_char_array (str_list, "CHECK_CHANNEL");
29.517 + gmyth_string_list_append_char_array ( str_list, "CHECK_CHANNEL" );
29.518
29.519 - gmyth_string_list_append_char_array (str_list, channel);
29.520 + gmyth_string_list_append_char_array ( str_list, channel );
29.521
29.522 - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
29.523 + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list );
29.524
29.525 - tmp_str = gmyth_string_list_get_string (str_list, 0);
29.526 + tmp_str = gmyth_string_list_get_string ( str_list, 0 );
29.527
29.528 - if (tmp_str == NULL) {
29.529 - gmyth_debug ("[%s] CHECK_CHANNEL request returned %s", __FUNCTION__,
29.530 - tmp_str->str);
29.531 + if ( tmp_str == NULL )
29.532 + {
29.533 + gmyth_debug ( "[%s] CHECK_CHANNEL request returned %s", __FUNCTION__,
29.534 + tmp_str->str );
29.535 ret = FALSE;
29.536 goto cleanup;
29.537 }
29.538
29.539 - if (g_ascii_strncasecmp (tmp_str->str, "ok", 2) == 0
29.540 - || g_ascii_strncasecmp (tmp_str->str, "0", 1) == 0) {
29.541 - gmyth_debug ("[%s] CHECK_CHANNEL request returned %s", __FUNCTION__,
29.542 - tmp_str->str);
29.543 + if ( g_ascii_strncasecmp ( tmp_str->str, "ok", 2 ) == 0
29.544 + || g_ascii_strncasecmp ( tmp_str->str, "0", 1 ) == 0 )
29.545 + {
29.546 + gmyth_debug ( "[%s] CHECK_CHANNEL request returned %s", __FUNCTION__,
29.547 + tmp_str->str );
29.548 ret = FALSE;
29.549 goto cleanup;
29.550 }
29.551
29.552 cleanup:
29.553 - g_mutex_unlock (recorder->mutex);
29.554 - g_string_free (tmp_str, TRUE);
29.555 - g_object_unref (str_list);
29.556 + g_mutex_unlock ( recorder->mutex );
29.557 + g_string_free ( tmp_str, TRUE );
29.558 + g_object_unref ( str_list );
29.559
29.560 return ret;
29.561 }
29.562 @@ -435,10 +452,10 @@
29.563 * @return true if success, false if any error happens.
29.564 */
29.565 gboolean
29.566 -gmyth_recorder_check_channel (GMythRecorder * recorder, gint channel)
29.567 +gmyth_recorder_check_channel ( GMythRecorder * recorder, gint channel )
29.568 {
29.569 - return gmyth_recorder_check_channel_name (recorder, g_strdup_printf ("%d",
29.570 - channel));
29.571 + return gmyth_recorder_check_channel_name ( recorder, g_strdup_printf ( "%d",
29.572 + channel ) );
29.573 }
29.574
29.575 /** Send a SET_CHANNEL command request to the backend, to start streaming on another
29.576 @@ -449,49 +466,51 @@
29.577 * @return true if success, false if any error happens.
29.578 */
29.579 gboolean
29.580 -gmyth_recorder_set_channel (GMythRecorder * recorder, gint channel)
29.581 +gmyth_recorder_set_channel ( GMythRecorder * recorder, gint channel )
29.582 {
29.583 GMythStringList *str_list;
29.584 - GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER);
29.585 + GString *tmp_str = g_string_new ( GMYTHTV_RECORDER_HEADER );
29.586 gboolean ret = TRUE;
29.587
29.588 - gmyth_debug ("[%s] SET_CHANNEL with channel = %d", __FUNCTION__, channel);
29.589 + gmyth_debug ( "[%s] SET_CHANNEL with channel = %d", __FUNCTION__, channel );
29.590
29.591 - str_list = gmyth_string_list_new ();
29.592 + str_list = gmyth_string_list_new ( );
29.593
29.594 - g_mutex_lock (recorder->mutex);
29.595 + g_mutex_lock ( recorder->mutex );
29.596
29.597 - g_string_append_printf (tmp_str, " %d", recorder->recorder_num);
29.598 + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
29.599
29.600 - gmyth_string_list_append_string (str_list, tmp_str);
29.601 - g_string_free (tmp_str, TRUE);
29.602 + gmyth_string_list_append_string ( str_list, tmp_str );
29.603 + g_string_free ( tmp_str, TRUE );
29.604
29.605 - gmyth_string_list_append_char_array (str_list, "SET_CHANNEL");
29.606 + gmyth_string_list_append_char_array ( str_list, "SET_CHANNEL" );
29.607
29.608 - gmyth_string_list_append_int (str_list, channel);
29.609 + gmyth_string_list_append_int ( str_list, channel );
29.610
29.611 - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
29.612 + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list );
29.613
29.614 - tmp_str = gmyth_string_list_get_string (str_list, 0);
29.615 + tmp_str = gmyth_string_list_get_string ( str_list, 0 );
29.616
29.617 - if (tmp_str == NULL) {
29.618 - gmyth_debug ("[%s] SET_CHANNEL request returned %s", __FUNCTION__,
29.619 - tmp_str->str);
29.620 + if ( tmp_str == NULL )
29.621 + {
29.622 + gmyth_debug ( "[%s] SET_CHANNEL request returned %s", __FUNCTION__,
29.623 + tmp_str->str );
29.624 ret = FALSE;
29.625 goto cleanup;
29.626 }
29.627
29.628 - if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) {
29.629 - gmyth_debug ("[%s] SET_CHANNEL request returned %s", __FUNCTION__,
29.630 - tmp_str->str);
29.631 + if ( g_ascii_strncasecmp ( tmp_str->str, "ok", 2 ) )
29.632 + {
29.633 + gmyth_debug ( "[%s] SET_CHANNEL request returned %s", __FUNCTION__,
29.634 + tmp_str->str );
29.635 ret = FALSE;
29.636 goto cleanup;
29.637 }
29.638
29.639 cleanup:
29.640 - g_mutex_unlock (recorder->mutex);
29.641 - g_string_free (tmp_str, TRUE);
29.642 - g_object_unref (str_list);
29.643 + g_mutex_unlock ( recorder->mutex );
29.644 + g_string_free ( tmp_str, TRUE );
29.645 + g_object_unref ( str_list );
29.646
29.647 return ret;
29.648 }
29.649 @@ -504,52 +523,54 @@
29.650 * @return true if success, false if any error happens.
29.651 */
29.652 gboolean
29.653 -gmyth_recorder_set_channel_name (GMythRecorder * recorder,
29.654 - const gchar * channel)
29.655 +gmyth_recorder_set_channel_name ( GMythRecorder * recorder,
29.656 + const gchar * channel )
29.657 {
29.658 GMythStringList *str_list;
29.659 - GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER);
29.660 + GString *tmp_str = g_string_new ( GMYTHTV_RECORDER_HEADER );
29.661 gboolean ret = TRUE;
29.662
29.663 - gmyth_debug ("[%s] SET_CHANNEL with channel name = %s", __FUNCTION__,
29.664 - channel);
29.665 + gmyth_debug ( "[%s] SET_CHANNEL with channel name = %s", __FUNCTION__,
29.666 + channel );
29.667
29.668 - str_list = gmyth_string_list_new ();
29.669 + str_list = gmyth_string_list_new ( );
29.670
29.671 - g_mutex_lock (recorder->mutex);
29.672 + g_mutex_lock ( recorder->mutex );
29.673
29.674 - g_string_append_printf (tmp_str, " %d", recorder->recorder_num);
29.675 + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
29.676
29.677 - gmyth_string_list_append_string (str_list, tmp_str);
29.678 - g_string_free (tmp_str, TRUE);
29.679 + gmyth_string_list_append_string ( str_list, tmp_str );
29.680 + g_string_free ( tmp_str, TRUE );
29.681
29.682 - gmyth_string_list_append_char_array (str_list, "SET_CHANNEL");
29.683 - gmyth_string_list_append_char_array (str_list, channel);
29.684 + gmyth_string_list_append_char_array ( str_list, "SET_CHANNEL" );
29.685 + gmyth_string_list_append_char_array ( str_list, channel );
29.686
29.687 - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
29.688 + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list );
29.689
29.690 - tmp_str = gmyth_string_list_get_string (str_list, 0);
29.691 + tmp_str = gmyth_string_list_get_string ( str_list, 0 );
29.692
29.693 - if (tmp_str == NULL) {
29.694 - gmyth_debug ("[%s] SET_CHANNEL name request returned NULL!",
29.695 - __FUNCTION__);
29.696 + if ( tmp_str == NULL )
29.697 + {
29.698 + gmyth_debug ( "[%s] SET_CHANNEL name request returned NULL!",
29.699 + __FUNCTION__ );
29.700 ret = FALSE;
29.701 goto cleanup;
29.702 }
29.703
29.704 - if (tmp_str != NULL && g_ascii_strncasecmp (tmp_str->str, "ok", 2)
29.705 - /*|| g_ascii_strtoull( tmp_str->str, NULL, 10 ) == 0 */
29.706 - ) {
29.707 - g_warning ("[%s] SET_CHANNEL name request returned not ok",
29.708 - __FUNCTION__);
29.709 + if ( tmp_str != NULL && g_ascii_strncasecmp ( tmp_str->str, "ok", 2 )
29.710 + /*|| g_ascii_strtoull( tmp_str->str, NULL, 10 ) == 0 */
29.711 + )
29.712 + {
29.713 + g_warning ( "[%s] SET_CHANNEL name request returned not ok",
29.714 + __FUNCTION__ );
29.715 ret = FALSE;
29.716 goto cleanup;
29.717 }
29.718
29.719 cleanup:
29.720 - g_mutex_unlock (recorder->mutex);
29.721 - g_string_free (tmp_str, TRUE);
29.722 - g_object_unref (str_list);
29.723 + g_mutex_unlock ( recorder->mutex );
29.724 + g_string_free ( tmp_str, TRUE );
29.725 + g_object_unref ( str_list );
29.726
29.727 return ret;
29.728 }
29.729 @@ -570,51 +591,54 @@
29.730 * @return true if success, false if any error happens.
29.731 */
29.732 gboolean
29.733 -gmyth_recorder_change_channel (GMythRecorder * recorder,
29.734 - const GMythRecorderChannelChangeDirection direction)
29.735 +gmyth_recorder_change_channel ( GMythRecorder * recorder,
29.736 + const GMythRecorderChannelChangeDirection
29.737 + direction )
29.738 {
29.739 GMythStringList *str_list;
29.740 - GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER);
29.741 + GString *tmp_str = g_string_new ( GMYTHTV_RECORDER_HEADER );
29.742 gboolean ret = TRUE;
29.743
29.744 - gmyth_debug ("[%s] CHANGE_CHANNEL to the channel direction = %u",
29.745 - __FUNCTION__, direction);
29.746 + gmyth_debug ( "[%s] CHANGE_CHANNEL to the channel direction = %u",
29.747 + __FUNCTION__, direction );
29.748
29.749 - str_list = gmyth_string_list_new ();
29.750 + str_list = gmyth_string_list_new ( );
29.751
29.752 - g_mutex_lock (recorder->mutex);
29.753 + g_mutex_lock ( recorder->mutex );
29.754
29.755 - g_string_append_printf (tmp_str, " %d", recorder->recorder_num);
29.756 + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
29.757
29.758 - gmyth_string_list_append_string (str_list, tmp_str);
29.759 - g_string_free (tmp_str, TRUE);
29.760 + gmyth_string_list_append_string ( str_list, tmp_str );
29.761 + g_string_free ( tmp_str, TRUE );
29.762
29.763 - gmyth_string_list_append_char_array (str_list, "CHANGE_CHANNEL");
29.764 - gmyth_string_list_append_int (str_list, direction);
29.765 + gmyth_string_list_append_char_array ( str_list, "CHANGE_CHANNEL" );
29.766 + gmyth_string_list_append_int ( str_list, direction );
29.767
29.768 - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
29.769 + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list );
29.770
29.771 - tmp_str = gmyth_string_list_get_string (str_list, 0);
29.772 + tmp_str = gmyth_string_list_get_string ( str_list, 0 );
29.773
29.774 - if (tmp_str == NULL) {
29.775 - gmyth_debug ("[%s] CHANGE_CHANNEL name request returned %s",
29.776 - __FUNCTION__, tmp_str->str);
29.777 + if ( tmp_str == NULL )
29.778 + {
29.779 + gmyth_debug ( "[%s] CHANGE_CHANNEL name request returned %s",
29.780 + __FUNCTION__, tmp_str->str );
29.781 ret = FALSE;
29.782 goto cleanup;
29.783 }
29.784
29.785 - if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)
29.786 - || g_ascii_strtoull (tmp_str->str, NULL, 10) == 0) {
29.787 - gmyth_debug ("[%s] CHANGE_CHANNEL name request returned %s",
29.788 - __FUNCTION__, tmp_str->str);
29.789 + if ( g_ascii_strncasecmp ( tmp_str->str, "ok", 2 )
29.790 + || g_ascii_strtoull ( tmp_str->str, NULL, 10 ) == 0 )
29.791 + {
29.792 + gmyth_debug ( "[%s] CHANGE_CHANNEL name request returned %s",
29.793 + __FUNCTION__, tmp_str->str );
29.794 ret = FALSE;
29.795 goto cleanup;
29.796 }
29.797
29.798 cleanup:
29.799 - g_mutex_unlock (recorder->mutex);
29.800 - g_string_free (tmp_str, TRUE);
29.801 - g_object_unref (str_list);
29.802 + g_mutex_unlock ( recorder->mutex );
29.803 + g_string_free ( tmp_str, TRUE );
29.804 + g_object_unref ( str_list );
29.805
29.806 return ret;
29.807 }
29.808 @@ -627,23 +651,25 @@
29.809 * @return a GList* instance with all the channel names.
29.810 */
29.811 GList *
29.812 -gmyth_recorder_get_channel_list (GMythRecorder * recorder)
29.813 +gmyth_recorder_get_channel_list ( GMythRecorder * recorder )
29.814 {
29.815
29.816 GList *channel_list = NULL;
29.817 gchar *channel = NULL;
29.818 guint i;
29.819
29.820 - for (i = 0; i < 1000; i++) {
29.821 - channel = g_strdup_printf ("%u", i);
29.822 + for ( i = 0; i < 1000; i++ )
29.823 + {
29.824 + channel = g_strdup_printf ( "%u", i );
29.825
29.826 - if (gmyth_recorder_check_channel_name (recorder, channel)) {
29.827 - channel_list = g_list_append (channel_list, g_strdup (channel));
29.828 + if ( gmyth_recorder_check_channel_name ( recorder, channel ) )
29.829 + {
29.830 + channel_list = g_list_append ( channel_list, g_strdup ( channel ) );
29.831 }
29.832
29.833 } /* for - channel list */
29.834
29.835 - g_free (channel);
29.836 + g_free ( channel );
29.837
29.838 return channel_list;
29.839
29.840 @@ -656,65 +682,70 @@
29.841 * @return true if success, false if any error happens.
29.842 */
29.843 gboolean
29.844 -gmyth_recorder_pause_recording (GMythRecorder * recorder)
29.845 +gmyth_recorder_pause_recording ( GMythRecorder * recorder )
29.846 {
29.847 GMythStringList *str_list;
29.848 - GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER);
29.849 + GString *tmp_str = g_string_new ( GMYTHTV_RECORDER_HEADER );
29.850 gboolean ret = TRUE;
29.851
29.852 - gmyth_debug ("[%s] PAUSE", __FUNCTION__);
29.853 + gmyth_debug ( "[%s] PAUSE", __FUNCTION__ );
29.854
29.855 - str_list = gmyth_string_list_new ();
29.856 + str_list = gmyth_string_list_new ( );
29.857
29.858 - g_mutex_lock (recorder->mutex);
29.859 + g_mutex_lock ( recorder->mutex );
29.860
29.861 - g_string_append_printf (tmp_str, " %d", recorder->recorder_num);
29.862 + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
29.863
29.864 - gmyth_string_list_append_string (str_list, tmp_str);
29.865 - g_string_free (tmp_str, TRUE);
29.866 + gmyth_string_list_append_string ( str_list, tmp_str );
29.867 + g_string_free ( tmp_str, TRUE );
29.868
29.869 - gmyth_string_list_append_char_array (str_list, "PAUSE");
29.870 + gmyth_string_list_append_char_array ( str_list, "PAUSE" );
29.871
29.872 - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
29.873 + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list );
29.874
29.875 - tmp_str = gmyth_string_list_get_string (str_list, 0);
29.876 + tmp_str = gmyth_string_list_get_string ( str_list, 0 );
29.877
29.878 - if (tmp_str == NULL) {
29.879 - gmyth_debug ("[%s] PAUSE name request returned %s", __FUNCTION__,
29.880 - tmp_str->str);
29.881 + if ( tmp_str == NULL )
29.882 + {
29.883 + gmyth_debug ( "[%s] PAUSE name request returned %s", __FUNCTION__,
29.884 + tmp_str->str );
29.885 ret = FALSE;
29.886 goto cleanup;
29.887 }
29.888
29.889 - if (g_ascii_strncasecmp (tmp_str->str, "ok", 2)) {
29.890 - gmyth_debug ("[%s] PAUSE name request returned %s", __FUNCTION__,
29.891 - tmp_str->str);
29.892 + if ( g_ascii_strncasecmp ( tmp_str->str, "ok", 2 ) )
29.893 + {
29.894 + gmyth_debug ( "[%s] PAUSE name request returned %s", __FUNCTION__,
29.895 + tmp_str->str );
29.896 ret = FALSE;
29.897 goto cleanup;
29.898 }
29.899
29.900 cleanup:
29.901 - g_mutex_unlock (recorder->mutex);
29.902 - g_string_free (tmp_str, TRUE);
29.903 - g_object_unref (str_list);
29.904 + g_mutex_unlock ( recorder->mutex );
29.905 + g_string_free ( tmp_str, TRUE );
29.906 + g_object_unref ( str_list );
29.907
29.908 return ret;
29.909 }
29.910
29.911 static gboolean
29.912 -gmyth_recorder_find_if_program_exists (GMythRecorder * recorder,
29.913 - GMythProgramInfo * prog)
29.914 +gmyth_recorder_find_if_program_exists ( GMythRecorder * recorder,
29.915 + GMythProgramInfo * prog )
29.916 {
29.917 GList *lst = NULL;
29.918
29.919 - g_return_val_if_fail (recorder != NULL
29.920 - && recorder->progs_info_list != NULL, FALSE);
29.921 + g_return_val_if_fail ( recorder != NULL
29.922 + && recorder->progs_info_list != NULL, FALSE );
29.923
29.924 - for (lst = recorder->progs_info_list; lst != NULL; lst = g_list_next (lst)) {
29.925 - gmyth_debug ("Got program info from list = [%s]",
29.926 - gmyth_program_info_to_string ((GMythProgramInfo *)
29.927 - lst->data));
29.928 - if (gmyth_program_info_is_equals (prog, (GMythProgramInfo *) lst->data))
29.929 + for ( lst = recorder->progs_info_list; lst != NULL;
29.930 + lst = g_list_next ( lst ) )
29.931 + {
29.932 + gmyth_debug ( "Got program info from list = [%s]",
29.933 + gmyth_program_info_to_string ( ( GMythProgramInfo * )
29.934 + lst->data ) );
29.935 + if ( gmyth_program_info_is_equals
29.936 + ( prog, ( GMythProgramInfo * ) lst->data ) )
29.937 return TRUE;
29.938 }
29.939
29.940 @@ -728,56 +759,60 @@
29.941 * @return The actual program info.
29.942 */
29.943 GMythProgramInfo *
29.944 -gmyth_recorder_get_current_program_info (GMythRecorder * recorder)
29.945 +gmyth_recorder_get_current_program_info ( GMythRecorder * recorder )
29.946 {
29.947 GMythStringList *str_list = NULL;
29.948 GMythProgramInfo *program_info = NULL;
29.949 - GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER);
29.950 + GString *tmp_str = g_string_new ( GMYTHTV_RECORDER_HEADER );
29.951
29.952 - str_list = gmyth_string_list_new ();
29.953 + str_list = gmyth_string_list_new ( );
29.954
29.955 - g_mutex_lock (recorder->mutex);
29.956 + g_mutex_lock ( recorder->mutex );
29.957
29.958 - g_string_append_printf (tmp_str, " %d", recorder->recorder_num);
29.959 + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
29.960
29.961 - gmyth_string_list_append_string (str_list, tmp_str);
29.962 + gmyth_string_list_append_string ( str_list, tmp_str );
29.963
29.964 - if (recorder->myth_socket->mythtv_version >= 26)
29.965 - gmyth_string_list_append_char_array (str_list, "GET_CURRENT_RECORDING");
29.966 + if ( recorder->myth_socket->mythtv_version >= 26 )
29.967 + gmyth_string_list_append_char_array ( str_list,
29.968 + "GET_CURRENT_RECORDING" );
29.969 else
29.970 - gmyth_string_list_append_char_array (str_list, "GET_PROGRAM_INFO");
29.971 + gmyth_string_list_append_char_array ( str_list, "GET_PROGRAM_INFO" );
29.972
29.973 - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
29.974 + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list );
29.975
29.976 - if (str_list == NULL) {
29.977 + if ( str_list == NULL )
29.978 + {
29.979 gmyth_debug
29.980 - ("[%s] GET_PROGRAM_INFO request returned. Error getting program info, string list equals to NULL!",
29.981 - __FUNCTION__);
29.982 + ( "[%s] GET_PROGRAM_INFO request returned. Error getting program info, string list equals to NULL!",
29.983 + __FUNCTION__ );
29.984 goto cleanup;
29.985 }
29.986
29.987 - program_info = gmyth_program_info_from_string_list (str_list);
29.988 + program_info = gmyth_program_info_from_string_list ( str_list );
29.989
29.990 - if (NULL == program_info || NULL == program_info->pathname
29.991 - || program_info->pathname->len <= 0) {
29.992 + if ( NULL == program_info || NULL == program_info->pathname
29.993 + || program_info->pathname->len <= 0 )
29.994 + {
29.995 gmyth_debug
29.996 - ("GET_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!");
29.997 + ( "GET_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!" );
29.998
29.999 - if (program_info)
29.1000 - g_object_unref (program_info);
29.1001 + if ( program_info )
29.1002 + g_object_unref ( program_info );
29.1003
29.1004 program_info = NULL;
29.1005
29.1006 goto cleanup;
29.1007 }
29.1008
29.1009 - if (!gmyth_recorder_find_if_program_exists (recorder, program_info))
29.1010 - recorder->progs_info_list = g_list_append (recorder->progs_info_list,
29.1011 - g_object_ref (program_info));
29.1012 + if ( !gmyth_recorder_find_if_program_exists ( recorder, program_info ) )
29.1013 + recorder->progs_info_list = g_list_append ( recorder->progs_info_list,
29.1014 + g_object_ref
29.1015 + ( program_info ) );
29.1016 cleanup:
29.1017 - g_mutex_unlock (recorder->mutex);
29.1018 - g_string_free (tmp_str, TRUE);
29.1019 - g_object_unref (str_list);
29.1020 + g_mutex_unlock ( recorder->mutex );
29.1021 + g_string_free ( tmp_str, TRUE );
29.1022 + g_object_unref ( str_list );
29.1023
29.1024 return program_info;
29.1025 }
29.1026 @@ -789,73 +824,82 @@
29.1027 * @return The GMythRecorder instance.
29.1028 */
29.1029 GMythRecorder *
29.1030 -gmyth_recorder_get_recorder_from_num (gint rec_id)
29.1031 +gmyth_recorder_get_recorder_from_num ( gint rec_id )
29.1032 {
29.1033 GMythRecorder *recorder = NULL;
29.1034 GMythStringList *str_list;
29.1035 - GString *tmp_str = g_string_new ("GET_RECORDER_FROM_NUM");
29.1036 + GString *tmp_str = g_string_new ( "GET_RECORDER_FROM_NUM" );
29.1037 gint command_size = 0;
29.1038
29.1039 gchar *recorder_host = NULL;
29.1040 gint recorder_port;
29.1041
29.1042 - str_list = gmyth_string_list_new ();
29.1043 + str_list = gmyth_string_list_new ( );
29.1044
29.1045 /* g_string_append_printf ( tmp_str, " %d", recorder->recorder_num ); */
29.1046
29.1047 - g_mutex_lock (recorder->mutex);
29.1048 + g_mutex_lock ( recorder->mutex );
29.1049
29.1050 - gmyth_string_list_append_string (str_list, tmp_str);
29.1051 + gmyth_string_list_append_string ( str_list, tmp_str );
29.1052
29.1053 - gmyth_string_list_append_int (str_list, rec_id);
29.1054 + gmyth_string_list_append_int ( str_list, rec_id );
29.1055
29.1056 - command_size = gmyth_socket_sendreceive_stringlist (recorder->myth_socket,
29.1057 - str_list);
29.1058 + command_size = gmyth_socket_sendreceive_stringlist ( recorder->myth_socket,
29.1059 + str_list );
29.1060
29.1061 - if (str_list == NULL) {
29.1062 + if ( str_list == NULL )
29.1063 + {
29.1064 gmyth_debug
29.1065 - ("[%s] GET_RECORDER_FROM_NUM request returned. Error getting recorder number %d, it is equals to NULL!!!",
29.1066 - __FUNCTION__, rec_id);
29.1067 + ( "[%s] GET_RECORDER_FROM_NUM request returned. Error getting recorder number %d, it is equals to NULL!!!",
29.1068 + __FUNCTION__, rec_id );
29.1069 return NULL;
29.1070 }
29.1071
29.1072 - if (command_size > 0) {
29.1073 - recorder_host = gmyth_string_list_get_char_array (str_list, 0);
29.1074 - recorder_port = gmyth_string_list_get_int (str_list, 1);
29.1075 + if ( command_size > 0 )
29.1076 + {
29.1077 + recorder_host = gmyth_string_list_get_char_array ( str_list, 0 );
29.1078 + recorder_port = gmyth_string_list_get_int ( str_list, 1 );
29.1079
29.1080 - if (g_strstr_len (recorder_host, strlen (recorder_host), "nohost")
29.1081 - != NULL) {
29.1082 + if ( g_strstr_len ( recorder_host, strlen ( recorder_host ), "nohost" )
29.1083 + != NULL )
29.1084 + {
29.1085 gmyth_debug
29.1086 - ("No available recorder with the recorder ID number %d!",
29.1087 - rec_id);
29.1088 - } else {
29.1089 + ( "No available recorder with the recorder ID number %d!",
29.1090 + rec_id );
29.1091 + }
29.1092 + else
29.1093 + {
29.1094
29.1095 - recorder = gmyth_recorder_new (rec_id,
29.1096 - g_string_new (recorder_host), (gshort) recorder_port);
29.1097 + recorder = gmyth_recorder_new ( rec_id,
29.1098 + g_string_new ( recorder_host ),
29.1099 + ( gshort ) recorder_port );
29.1100
29.1101 - if (NULL == recorder) {
29.1102 + if ( NULL == recorder )
29.1103 + {
29.1104 gmyth_debug
29.1105 - ("[%s] GET_RECORDER_FROM_NUM request returned. Error getting recorder number %d, it is equals to NULL!!!",
29.1106 - __FUNCTION__, rec_id);
29.1107 - g_object_unref (recorder);
29.1108 + ( "[%s] GET_RECORDER_FROM_NUM request returned. Error getting recorder number %d, it is equals to NULL!!!",
29.1109 + __FUNCTION__, rec_id );
29.1110 + g_object_unref ( recorder );
29.1111 return NULL;
29.1112 }
29.1113
29.1114 }
29.1115
29.1116 - } else {
29.1117 + }
29.1118 + else
29.1119 + {
29.1120 gmyth_debug
29.1121 - ("Cannot find a valuable recorder with the recorder ID number %d, backend server error!",
29.1122 - rec_id);
29.1123 + ( "Cannot find a valuable recorder with the recorder ID number %d, backend server error!",
29.1124 + rec_id );
29.1125 }
29.1126
29.1127 - g_mutex_unlock (recorder->mutex);
29.1128 + g_mutex_unlock ( recorder->mutex );
29.1129
29.1130 - g_object_unref (str_list);
29.1131 + g_object_unref ( str_list );
29.1132
29.1133 - g_string_free (tmp_str, TRUE);
29.1134 + g_string_free ( tmp_str, TRUE );
29.1135
29.1136 - g_free (recorder_host);
29.1137 + g_free ( recorder_host );
29.1138
29.1139 return recorder;
29.1140
29.1141 @@ -871,66 +915,75 @@
29.1142 * @return The GMythProgramInfo next program info instance.
29.1143 */
29.1144 GMythProgramInfo *
29.1145 -gmyth_recorder_get_next_program_info (GMythRecorder * recorder,
29.1146 - const GMythRecorderBrowseDirection direction)
29.1147 +gmyth_recorder_get_next_program_info ( GMythRecorder * recorder,
29.1148 + const GMythRecorderBrowseDirection
29.1149 + direction )
29.1150 {
29.1151 GMythProgramInfo *actual_proginfo = NULL;
29.1152 GMythProgramInfo *program_info = NULL;
29.1153 GMythStringList *str_list;
29.1154 - GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER);
29.1155 + GString *tmp_str = g_string_new ( GMYTHTV_RECORDER_HEADER );
29.1156
29.1157 gchar *date = NULL;
29.1158 struct tm *tm = NULL;
29.1159 time_t t;
29.1160
29.1161 - actual_proginfo = gmyth_recorder_get_current_program_info (recorder);
29.1162 + actual_proginfo = gmyth_recorder_get_current_program_info ( recorder );
29.1163
29.1164 - str_list = gmyth_string_list_new ();
29.1165 + str_list = gmyth_string_list_new ( );
29.1166
29.1167 - g_mutex_lock (recorder->mutex);
29.1168 + g_mutex_lock ( recorder->mutex );
29.1169
29.1170 - g_string_append_printf (tmp_str, " %d", recorder->recorder_num);
29.1171 + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
29.1172
29.1173 - t = time (NULL);
29.1174 - tm = localtime (&t);
29.1175 - date = g_strdup_printf ("%.4d%.2d%.2d%.2d%.2d%.2d", tm->tm_year + 1900,
29.1176 - tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
29.1177 + t = time ( NULL );
29.1178 + tm = localtime ( &t );
29.1179 + date = g_strdup_printf ( "%.4d%.2d%.2d%.2d%.2d%.2d", tm->tm_year + 1900,
29.1180 + tm->tm_mon + 1, tm->tm_mday, tm->tm_hour,
29.1181 + tm->tm_min, tm->tm_sec );
29.1182
29.1183 - gmyth_string_list_append_string (str_list, tmp_str);
29.1184 - gmyth_string_list_append_char_array (str_list, "GET_NEXT_PROGRAM_INFO");
29.1185 - gmyth_string_list_append_string (str_list, actual_proginfo->channame);
29.1186 - gmyth_string_list_append_string (str_list, actual_proginfo->chanid);
29.1187 - gmyth_string_list_append_int (str_list, direction);
29.1188 - gmyth_string_list_append_char_array (str_list, date);
29.1189 + gmyth_string_list_append_string ( str_list, tmp_str );
29.1190 + gmyth_string_list_append_char_array ( str_list, "GET_NEXT_PROGRAM_INFO" );
29.1191 + gmyth_string_list_append_string ( str_list, actual_proginfo->channame );
29.1192 + gmyth_string_list_append_string ( str_list, actual_proginfo->chanid );
29.1193 + gmyth_string_list_append_int ( str_list, direction );
29.1194 + gmyth_string_list_append_char_array ( str_list, date );
29.1195
29.1196 - if (gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list)
29.1197 - > 0) {
29.1198 + if ( gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list )
29.1199 + > 0 )
29.1200 + {
29.1201
29.1202 - if (str_list == NULL) {
29.1203 + if ( str_list == NULL )
29.1204 + {
29.1205 gmyth_debug
29.1206 - ("[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!",
29.1207 - __FUNCTION__);
29.1208 + ( "[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!",
29.1209 + __FUNCTION__ );
29.1210 goto done;
29.1211 }
29.1212 - program_info = gmyth_program_info_from_string_list_next_prog (str_list);
29.1213 + program_info =
29.1214 + gmyth_program_info_from_string_list_next_prog ( str_list );
29.1215
29.1216 - if (NULL == program_info) {
29.1217 + if ( NULL == program_info )
29.1218 + {
29.1219 gmyth_debug
29.1220 - ("[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!",
29.1221 - __FUNCTION__);
29.1222 - g_object_unref (program_info);
29.1223 + ( "[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!",
29.1224 + __FUNCTION__ );
29.1225 + g_object_unref ( program_info );
29.1226 goto done;
29.1227 }
29.1228
29.1229 if ( /*( program_info->chanid != NULL && strlen( program_info->chanid->str ) > 0 ) && */
29.1230 - (program_info->chansign != NULL
29.1231 - && strlen (program_info->chansign->str) > 0)) {
29.1232 - gmyth_debug ("OK!!! Got the next program info... [%s].",
29.1233 - program_info->chansign->str);
29.1234 - } else {
29.1235 + ( program_info->chansign != NULL
29.1236 + && strlen ( program_info->chansign->str ) > 0 ) )
29.1237 + {
29.1238 + gmyth_debug ( "OK!!! Got the next program info... [%s].",
29.1239 + program_info->chansign->str );
29.1240 + }
29.1241 + else
29.1242 + {
29.1243 gmyth_debug
29.1244 - ("GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!");
29.1245 - g_object_unref (program_info);
29.1246 + ( "GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!" );
29.1247 + g_object_unref ( program_info );
29.1248 program_info = NULL;
29.1249 }
29.1250
29.1251 @@ -938,19 +991,19 @@
29.1252 /* if */
29.1253 done:
29.1254
29.1255 - g_mutex_unlock (recorder->mutex);
29.1256 + g_mutex_unlock ( recorder->mutex );
29.1257
29.1258 - if (actual_proginfo != NULL)
29.1259 - g_object_unref (actual_proginfo);
29.1260 + if ( actual_proginfo != NULL )
29.1261 + g_object_unref ( actual_proginfo );
29.1262
29.1263 - if (str_list != NULL)
29.1264 - g_object_unref (str_list);
29.1265 + if ( str_list != NULL )
29.1266 + g_object_unref ( str_list );
29.1267
29.1268 - if (tmp_str != NULL)
29.1269 - g_string_free (tmp_str, TRUE);
29.1270 + if ( tmp_str != NULL )
29.1271 + g_string_free ( tmp_str, TRUE );
29.1272
29.1273 - if (date != NULL)
29.1274 - g_free (date);
29.1275 + if ( date != NULL )
29.1276 + g_free ( date );
29.1277 //if ( tm != NULL)
29.1278 // g_free (tm);
29.1279
29.1280 @@ -965,13 +1018,13 @@
29.1281 * @return The GMythProgramInfo next program info instance.
29.1282 */
29.1283 GMythProgramInfo *
29.1284 -gmyth_recorder_get_program_info_from_channel_name (GMythRecorder * recorder,
29.1285 - const gchar * channel)
29.1286 +gmyth_recorder_get_program_info_from_channel_name ( GMythRecorder * recorder,
29.1287 + const gchar * channel )
29.1288 {
29.1289 //GMythProgramInfo* actual_proginfo= NULL;
29.1290 GMythProgramInfo *program_info = NULL;
29.1291 GMythStringList *str_list;
29.1292 - GString *tmp_str = g_string_new (GMYTHTV_RECORDER_HEADER);
29.1293 + GString *tmp_str = g_string_new ( GMYTHTV_RECORDER_HEADER );
29.1294
29.1295 /*
29.1296 gchar *date = NULL;
29.1297 @@ -981,11 +1034,11 @@
29.1298 actual_proginfo = gmyth_recorder_get_current_program_info(recorder);
29.1299 */
29.1300
29.1301 - str_list = gmyth_string_list_new ();
29.1302 + str_list = gmyth_string_list_new ( );
29.1303
29.1304 - g_mutex_lock (recorder->mutex);
29.1305 + g_mutex_lock ( recorder->mutex );
29.1306
29.1307 - g_string_append_printf (tmp_str, " %d", recorder->recorder_num);
29.1308 + g_string_append_printf ( tmp_str, " %d", recorder->recorder_num );
29.1309
29.1310 /*
29.1311 t = time(NULL);
29.1312 @@ -994,63 +1047,70 @@
29.1313 tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
29.1314 */
29.1315
29.1316 - gmyth_string_list_append_string (str_list, tmp_str);
29.1317 - gmyth_string_list_append_char_array (str_list, "GET_NEXT_PROGRAM_INFO");
29.1318 - gmyth_string_list_append_char_array (str_list, channel);
29.1319 - gmyth_string_list_append_char_array (str_list, "0");
29.1320 - gmyth_string_list_append_int (str_list, BROWSE_DIRECTION_UP);
29.1321 - gmyth_string_list_append_char_array (str_list, "0");
29.1322 + gmyth_string_list_append_string ( str_list, tmp_str );
29.1323 + gmyth_string_list_append_char_array ( str_list, "GET_NEXT_PROGRAM_INFO" );
29.1324 + gmyth_string_list_append_char_array ( str_list, channel );
29.1325 + gmyth_string_list_append_char_array ( str_list, "0" );
29.1326 + gmyth_string_list_append_int ( str_list, BROWSE_DIRECTION_UP );
29.1327 + gmyth_string_list_append_char_array ( str_list, "0" );
29.1328
29.1329 - do {
29.1330 + do
29.1331 + {
29.1332
29.1333 - if (str_list != NULL &&
29.1334 - gmyth_socket_sendreceive_stringlist (recorder->myth_socket,
29.1335 - str_list) > 0) {
29.1336 + if ( str_list != NULL &&
29.1337 + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket,
29.1338 + str_list ) > 0 )
29.1339 + {
29.1340
29.1341 - if (str_list == NULL) {
29.1342 + if ( str_list == NULL )
29.1343 + {
29.1344 gmyth_debug
29.1345 - ("[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!",
29.1346 - __FUNCTION__);
29.1347 + ( "[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting program info, it is equals to NULL!!!",
29.1348 + __FUNCTION__ );
29.1349 goto done;
29.1350 }
29.1351 program_info =
29.1352 - gmyth_program_info_from_string_list_next_prog (str_list);
29.1353 + gmyth_program_info_from_string_list_next_prog ( str_list );
29.1354
29.1355 - if (NULL == program_info) {
29.1356 + if ( NULL == program_info )
29.1357 + {
29.1358 gmyth_debug
29.1359 - ("[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!",
29.1360 - __FUNCTION__);
29.1361 - g_object_unref (program_info);
29.1362 + ( "[%s] GET_NEXT_PROGRAM_INFO request returned. Error getting next program info, it is equals to NULL!!!",
29.1363 + __FUNCTION__ );
29.1364 + g_object_unref ( program_info );
29.1365 goto done;
29.1366 }
29.1367
29.1368 if ( /*( program_info->chanid != NULL && strlen( program_info->chanid->str ) > 0 ) && */
29.1369 - (program_info->chansign != NULL
29.1370 - && strlen (program_info->chansign->str) > 0)) {
29.1371 - gmyth_debug ("OK!!! Got the next program info... [%s].",
29.1372 - program_info->chansign->str);
29.1373 - } else {
29.1374 + ( program_info->chansign != NULL
29.1375 + && strlen ( program_info->chansign->str ) > 0 ) )
29.1376 + {
29.1377 + gmyth_debug ( "OK!!! Got the next program info... [%s].",
29.1378 + program_info->chansign->str );
29.1379 + }
29.1380 + else
29.1381 + {
29.1382 gmyth_debug
29.1383 - ("GET_NEXT_PROGRAM_INFO request returned. Error getting "
29.1384 - "next program info, it is equals to NULL!!!");
29.1385 - g_object_unref (program_info);
29.1386 + ( "GET_NEXT_PROGRAM_INFO request returned. Error getting "
29.1387 + "next program info, it is equals to NULL!!!" );
29.1388 + g_object_unref ( program_info );
29.1389 program_info = NULL;
29.1390 }
29.1391
29.1392 }
29.1393 /* if */
29.1394 }
29.1395 - while (str_list != NULL);
29.1396 + while ( str_list != NULL );
29.1397
29.1398 done:
29.1399
29.1400 - g_mutex_unlock (recorder->mutex);
29.1401 + g_mutex_unlock ( recorder->mutex );
29.1402
29.1403 - if (str_list != NULL)
29.1404 - g_object_unref (str_list);
29.1405 + if ( str_list != NULL )
29.1406 + g_object_unref ( str_list );
29.1407
29.1408 - if (tmp_str != NULL)
29.1409 - g_string_free (tmp_str, TRUE);
29.1410 + if ( tmp_str != NULL )
29.1411 + g_string_free ( tmp_str, TRUE );
29.1412
29.1413 return program_info;
29.1414 }
29.1415 @@ -1063,40 +1123,41 @@
29.1416 * @return The position, in bytes, of the offset to the read header.
29.1417 */
29.1418 gint64
29.1419 -gmyth_recorder_get_file_position (GMythRecorder * recorder)
29.1420 +gmyth_recorder_get_file_position ( GMythRecorder * recorder )
29.1421 {
29.1422 gint64 pos = 0;
29.1423 - GString *query = g_string_new (GMYTHTV_RECORDER_HEADER);
29.1424 + GString *query = g_string_new ( GMYTHTV_RECORDER_HEADER );
29.1425
29.1426 - GMythStringList *str_list = gmyth_string_list_new ();
29.1427 + GMythStringList *str_list = gmyth_string_list_new ( );
29.1428
29.1429 - g_mutex_lock (recorder->mutex);
29.1430 + g_mutex_lock ( recorder->mutex );
29.1431
29.1432 - g_string_append_printf (query, " %d", recorder->recorder_num);
29.1433 + g_string_append_printf ( query, " %d", recorder->recorder_num );
29.1434
29.1435 - gmyth_string_list_append_string (str_list, query);
29.1436 - gmyth_string_list_append_char_array (str_list, "GET_FILE_POSITION");
29.1437 + gmyth_string_list_append_string ( str_list, query );
29.1438 + gmyth_string_list_append_char_array ( str_list, "GET_FILE_POSITION" );
29.1439
29.1440 - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
29.1441 + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list );
29.1442
29.1443 - if (str_list != NULL && gmyth_string_list_length (str_list) > 0) {
29.1444 + if ( str_list != NULL && gmyth_string_list_length ( str_list ) > 0 )
29.1445 + {
29.1446 GString *str = NULL;
29.1447
29.1448 - if ((str = gmyth_string_list_get_string (str_list, 0)) != NULL
29.1449 - && strstr (str->str, "bad") == NULL)
29.1450 - pos = gmyth_string_list_get_int64 (str_list, 0);
29.1451 - g_string_free (str, TRUE);
29.1452 + if ( ( str = gmyth_string_list_get_string ( str_list, 0 ) ) != NULL
29.1453 + && strstr ( str->str, "bad" ) == NULL )
29.1454 + pos = gmyth_string_list_get_int64 ( str_list, 0 );
29.1455 + g_string_free ( str, TRUE );
29.1456 }
29.1457 #ifndef GMYTHTV_ENABLE_DEBUG
29.1458 - gmyth_debug ("[%s] Got file position = %lld\n", __FUNCTION__, pos);
29.1459 + gmyth_debug ( "[%s] Got file position = %lld\n", __FUNCTION__, pos );
29.1460 #endif
29.1461
29.1462 - g_mutex_unlock (recorder->mutex);
29.1463 + g_mutex_unlock ( recorder->mutex );
29.1464
29.1465 - if (str_list != NULL)
29.1466 - g_object_unref (str_list);
29.1467 + if ( str_list != NULL )
29.1468 + g_object_unref ( str_list );
29.1469
29.1470 - g_string_free (query, TRUE);
29.1471 + g_string_free ( query, TRUE );
29.1472
29.1473 return pos;
29.1474 }
29.1475 @@ -1109,49 +1170,51 @@
29.1476 * @return <code>true</code>, if the actual remote file is bein recorded.
29.1477 */
29.1478 gboolean
29.1479 -gmyth_recorder_is_recording (GMythRecorder * recorder)
29.1480 +gmyth_recorder_is_recording ( GMythRecorder * recorder )
29.1481 {
29.1482 gboolean ret = TRUE;
29.1483
29.1484 - g_return_val_if_fail (recorder != NULL, FALSE);
29.1485 + g_return_val_if_fail ( recorder != NULL, FALSE );
29.1486
29.1487 - GMythStringList *str_list = gmyth_string_list_new ();
29.1488 - GString *message = g_string_new ("");
29.1489 + GMythStringList *str_list = gmyth_string_list_new ( );
29.1490 + GString *message = g_string_new ( "" );
29.1491
29.1492 - g_mutex_lock (recorder->mutex);
29.1493 + g_mutex_lock ( recorder->mutex );
29.1494
29.1495 - g_string_printf (message, "%s %d", GMYTHTV_RECORDER_HEADER,
29.1496 - recorder->recorder_num);
29.1497 - gmyth_string_list_append_string (str_list, message);
29.1498 - gmyth_string_list_append_char_array (str_list, "IS_RECORDING");
29.1499 + g_string_printf ( message, "%s %d", GMYTHTV_RECORDER_HEADER,
29.1500 + recorder->recorder_num );
29.1501 + gmyth_string_list_append_string ( str_list, message );
29.1502 + gmyth_string_list_append_char_array ( str_list, "IS_RECORDING" );
29.1503
29.1504 - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
29.1505 + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list );
29.1506
29.1507 - if (str_list != NULL && gmyth_string_list_length (str_list) > 0) {
29.1508 + if ( str_list != NULL && gmyth_string_list_length ( str_list ) > 0 )
29.1509 + {
29.1510 GString *str = NULL;
29.1511
29.1512 - if ((str = gmyth_string_list_get_string (str_list, 0)) != NULL
29.1513 - && strcmp (str->str, "bad") != 0) {
29.1514 - gint is_rec = gmyth_string_list_get_int (str_list, 0);
29.1515 + if ( ( str = gmyth_string_list_get_string ( str_list, 0 ) ) != NULL
29.1516 + && strcmp ( str->str, "bad" ) != 0 )
29.1517 + {
29.1518 + gint is_rec = gmyth_string_list_get_int ( str_list, 0 );
29.1519
29.1520 - if (is_rec != 0)
29.1521 + if ( is_rec != 0 )
29.1522 ret = TRUE;
29.1523 else
29.1524 ret = FALSE;
29.1525 }
29.1526 - g_string_free (str, TRUE);
29.1527 + g_string_free ( str, TRUE );
29.1528 }
29.1529
29.1530 - gmyth_debug ("%s, stream is %s being recorded!\n", ret ? "YES" : "NO",
29.1531 - ret ? "" : "NOT");
29.1532 + gmyth_debug ( "%s, stream is %s being recorded!\n", ret ? "YES" : "NO",
29.1533 + ret ? "" : "NOT" );
29.1534 //g_static_mutex_unlock (&mutex);
29.1535
29.1536 - g_mutex_unlock (recorder->mutex);
29.1537 + g_mutex_unlock ( recorder->mutex );
29.1538
29.1539 - if (str_list != NULL)
29.1540 - g_object_unref (str_list);
29.1541 + if ( str_list != NULL )
29.1542 + g_object_unref ( str_list );
29.1543
29.1544 - g_string_free (message, TRUE);
29.1545 + g_string_free ( message, TRUE );
29.1546
29.1547 return ret;
29.1548
29.1549 @@ -1165,45 +1228,47 @@
29.1550 * @return <code>true</code>, if the recording had been actually closed.
29.1551 */
29.1552 gboolean
29.1553 -gmyth_recorder_finish_recording (GMythRecorder * recorder)
29.1554 +gmyth_recorder_finish_recording ( GMythRecorder * recorder )
29.1555 {
29.1556 gboolean ret = TRUE;
29.1557
29.1558 - g_return_val_if_fail (recorder != NULL, FALSE);
29.1559 + g_return_val_if_fail ( recorder != NULL, FALSE );
29.1560
29.1561 - GMythStringList *str_list = gmyth_string_list_new ();
29.1562 - GString *message = g_string_new ("");
29.1563 + GMythStringList *str_list = gmyth_string_list_new ( );
29.1564 + GString *message = g_string_new ( "" );
29.1565
29.1566 - g_string_printf (message, "%s %d", GMYTHTV_RECORDER_HEADER,
29.1567 - recorder->recorder_num);
29.1568 - gmyth_string_list_append_string (str_list, message);
29.1569 - gmyth_string_list_append_char_array (str_list, "FINISH_RECORDING");
29.1570 + g_string_printf ( message, "%s %d", GMYTHTV_RECORDER_HEADER,
29.1571 + recorder->recorder_num );
29.1572 + gmyth_string_list_append_string ( str_list, message );
29.1573 + gmyth_string_list_append_char_array ( str_list, "FINISH_RECORDING" );
29.1574
29.1575 - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
29.1576 + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list );
29.1577
29.1578 - if (str_list != NULL && gmyth_string_list_length (str_list) > 0) {
29.1579 + if ( str_list != NULL && gmyth_string_list_length ( str_list ) > 0 )
29.1580 + {
29.1581 GString *str = NULL;
29.1582
29.1583 - if ((str = gmyth_string_list_get_string (str_list, 0)) != NULL &&
29.1584 - strcmp (str->str, "ok") != 0) {
29.1585 - gint is_rec = gmyth_string_list_get_int (str_list, 0);
29.1586 + if ( ( str = gmyth_string_list_get_string ( str_list, 0 ) ) != NULL &&
29.1587 + strcmp ( str->str, "ok" ) != 0 )
29.1588 + {
29.1589 + gint is_rec = gmyth_string_list_get_int ( str_list, 0 );
29.1590
29.1591 - if (is_rec != 0)
29.1592 + if ( is_rec != 0 )
29.1593 ret = TRUE;
29.1594 else
29.1595 ret = FALSE;
29.1596 }
29.1597 - g_string_free (str, TRUE);
29.1598 + g_string_free ( str, TRUE );
29.1599 }
29.1600
29.1601 - gmyth_debug ("%s, stream is %s finished!\n", ret ? "YES" : "NO",
29.1602 - ret ? "" : "NOT");
29.1603 + gmyth_debug ( "%s, stream is %s finished!\n", ret ? "YES" : "NO",
29.1604 + ret ? "" : "NOT" );
29.1605 //g_static_mutex_unlock (&mutex);
29.1606
29.1607 - if (str_list != NULL)
29.1608 - g_object_unref (str_list);
29.1609 + if ( str_list != NULL )
29.1610 + g_object_unref ( str_list );
29.1611
29.1612 - g_string_free (message, TRUE);
29.1613 + g_string_free ( message, TRUE );
29.1614
29.1615 return ret;
29.1616 }
29.1617 @@ -1217,44 +1282,46 @@
29.1618 * @return <code>true</code>, if the recording had been actually stopped.
29.1619 */
29.1620 gboolean
29.1621 -gmyth_recorder_stop_playing (GMythRecorder * recorder)
29.1622 +gmyth_recorder_stop_playing ( GMythRecorder * recorder )
29.1623 {
29.1624 gboolean ret = TRUE;
29.1625
29.1626 - g_return_val_if_fail (recorder != NULL, FALSE);
29.1627 + g_return_val_if_fail ( recorder != NULL, FALSE );
29.1628
29.1629 - GMythStringList *str_list = gmyth_string_list_new ();
29.1630 - GString *message = g_string_new ("");
29.1631 + GMythStringList *str_list = gmyth_string_list_new ( );
29.1632 + GString *message = g_string_new ( "" );
29.1633
29.1634 - g_string_printf (message, "%s %d", GMYTHTV_RECORDER_HEADER,
29.1635 - recorder->recorder_num);
29.1636 - gmyth_string_list_append_string (str_list, message);
29.1637 - gmyth_string_list_append_char_array (str_list, "STOP_PLAYING");
29.1638 + g_string_printf ( message, "%s %d", GMYTHTV_RECORDER_HEADER,
29.1639 + recorder->recorder_num );
29.1640 + gmyth_string_list_append_string ( str_list, message );
29.1641 + gmyth_string_list_append_char_array ( str_list, "STOP_PLAYING" );
29.1642
29.1643 - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
29.1644 + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list );
29.1645
29.1646 - if (str_list != NULL && gmyth_string_list_length (str_list) > 0) {
29.1647 + if ( str_list != NULL && gmyth_string_list_length ( str_list ) > 0 )
29.1648 + {
29.1649 GString *str = NULL;
29.1650
29.1651 - if ((str = gmyth_string_list_get_string (str_list, 0)) != NULL &&
29.1652 - strcmp (str->str, "ok") != 0) {
29.1653 - gint is_rec = gmyth_string_list_get_int (str_list, 0);
29.1654 + if ( ( str = gmyth_string_list_get_string ( str_list, 0 ) ) != NULL &&
29.1655 + strcmp ( str->str, "ok" ) != 0 )
29.1656 + {
29.1657 + gint is_rec = gmyth_string_list_get_int ( str_list, 0 );
29.1658
29.1659 - if (is_rec != 0)
29.1660 + if ( is_rec != 0 )
29.1661 ret = TRUE;
29.1662 else
29.1663 ret = FALSE;
29.1664 }
29.1665 - g_string_free (str, TRUE);
29.1666 + g_string_free ( str, TRUE );
29.1667 }
29.1668
29.1669 - gmyth_debug ("%s, stream is %s stopped!\n", ret ? "YES" : "NO",
29.1670 - ret ? "" : "NOT");
29.1671 + gmyth_debug ( "%s, stream is %s stopped!\n", ret ? "YES" : "NO",
29.1672 + ret ? "" : "NOT" );
29.1673
29.1674 - if (str_list != NULL)
29.1675 - g_object_unref (str_list);
29.1676 + if ( str_list != NULL )
29.1677 + g_object_unref ( str_list );
29.1678
29.1679 - g_string_free (message, TRUE);
29.1680 + g_string_free ( message, TRUE );
29.1681
29.1682 return ret;
29.1683 }
29.1684 @@ -1267,42 +1334,44 @@
29.1685 * @return <code>true</code>, if the tuner had been freed.
29.1686 */
29.1687 gboolean
29.1688 -gmyth_recorder_free_tuner (GMythRecorder * recorder)
29.1689 +gmyth_recorder_free_tuner ( GMythRecorder * recorder )
29.1690 {
29.1691 gboolean ret = TRUE;
29.1692
29.1693 - g_return_val_if_fail (recorder != NULL, FALSE);
29.1694 + g_return_val_if_fail ( recorder != NULL, FALSE );
29.1695
29.1696 - GMythStringList *str_list = gmyth_string_list_new ();
29.1697 - GString *message = g_string_new ("");
29.1698 + GMythStringList *str_list = gmyth_string_list_new ( );
29.1699 + GString *message = g_string_new ( "" );
29.1700
29.1701 - g_string_printf (message, "%s %d", "FREE_TUNER", recorder->recorder_num);
29.1702 - gmyth_string_list_append_string (str_list, message);
29.1703 + g_string_printf ( message, "%s %d", "FREE_TUNER", recorder->recorder_num );
29.1704 + gmyth_string_list_append_string ( str_list, message );
29.1705
29.1706 - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
29.1707 + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list );
29.1708
29.1709 - if (str_list != NULL && gmyth_string_list_length (str_list) > 0) {
29.1710 + if ( str_list != NULL && gmyth_string_list_length ( str_list ) > 0 )
29.1711 + {
29.1712 GString *str = NULL;
29.1713
29.1714 - if ((str = gmyth_string_list_get_string (str_list, 0)) != NULL &&
29.1715 - g_ascii_strncasecmp (str->str, "ok", 2) != 0) {
29.1716 - gint is_rec = gmyth_string_list_get_int (str_list, 0);
29.1717 + if ( ( str = gmyth_string_list_get_string ( str_list, 0 ) ) != NULL &&
29.1718 + g_ascii_strncasecmp ( str->str, "ok", 2 ) != 0 )
29.1719 + {
29.1720 + gint is_rec = gmyth_string_list_get_int ( str_list, 0 );
29.1721
29.1722 - if (is_rec != 0)
29.1723 + if ( is_rec != 0 )
29.1724 ret = TRUE;
29.1725 else
29.1726 ret = FALSE;
29.1727 }
29.1728 - g_string_free (str, TRUE);
29.1729 + g_string_free ( str, TRUE );
29.1730 }
29.1731
29.1732 - gmyth_debug ("%s, tuner is %s freed!\n", ret ? "YES" : "NO",
29.1733 - ret ? "" : "NOT");
29.1734 + gmyth_debug ( "%s, tuner is %s freed!\n", ret ? "YES" : "NO",
29.1735 + ret ? "" : "NOT" );
29.1736
29.1737 - if (str_list != NULL)
29.1738 - g_object_unref (str_list);
29.1739 + if ( str_list != NULL )
29.1740 + g_object_unref ( str_list );
29.1741
29.1742 - g_string_free (message, TRUE);
29.1743 + g_string_free ( message, TRUE );
29.1744
29.1745 return ret;
29.1746 }
29.1747 @@ -1316,41 +1385,42 @@
29.1748 * @return The framerate (double value) of the current video.
29.1749 */
29.1750 gdouble
29.1751 -gmyth_recorder_get_framerate (GMythRecorder * recorder)
29.1752 +gmyth_recorder_get_framerate ( GMythRecorder * recorder )
29.1753 {
29.1754 gdouble fr = 0.0f;
29.1755 - GString *query = g_string_new (GMYTHTV_RECORDER_HEADER);
29.1756 + GString *query = g_string_new ( GMYTHTV_RECORDER_HEADER );
29.1757
29.1758 - GMythStringList *str_list = gmyth_string_list_new ();
29.1759 + GMythStringList *str_list = gmyth_string_list_new ( );
29.1760
29.1761 - g_mutex_lock (recorder->mutex);
29.1762 + g_mutex_lock ( recorder->mutex );
29.1763
29.1764 - g_string_append_printf (query, " %d", recorder->recorder_num);
29.1765 + g_string_append_printf ( query, " %d", recorder->recorder_num );
29.1766
29.1767 - gmyth_string_list_append_string (str_list, query);
29.1768 - gmyth_string_list_append_char_array (str_list, "GET_FRAMERATE");
29.1769 + gmyth_string_list_append_string ( str_list, query );
29.1770 + gmyth_string_list_append_char_array ( str_list, "GET_FRAMERATE" );
29.1771
29.1772 - gmyth_socket_sendreceive_stringlist (recorder->myth_socket, str_list);
29.1773 + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list );
29.1774
29.1775 - if (str_list != NULL && gmyth_string_list_length (str_list) > 0) {
29.1776 + if ( str_list != NULL && gmyth_string_list_length ( str_list ) > 0 )
29.1777 + {
29.1778 GString *str = NULL;
29.1779
29.1780 - if ((str = gmyth_string_list_get_string (str_list, 0)) != NULL
29.1781 - && strstr (str->str, "bad") == NULL)
29.1782 - fr = g_ascii_strtod (str->str, NULL);
29.1783 + if ( ( str = gmyth_string_list_get_string ( str_list, 0 ) ) != NULL
29.1784 + && strstr ( str->str, "bad" ) == NULL )
29.1785 + fr = g_ascii_strtod ( str->str, NULL );
29.1786
29.1787 - g_string_free (str, TRUE);
29.1788 + g_string_free ( str, TRUE );
29.1789 }
29.1790 #ifndef GMYTHTV_ENABLE_DEBUG
29.1791 - gmyth_debug ("[%s] Got file position = %f\n", __FUNCTION__, fr);
29.1792 + gmyth_debug ( "[%s] Got file position = %f\n", __FUNCTION__, fr );
29.1793 #endif
29.1794
29.1795 - g_mutex_unlock (recorder->mutex);
29.1796 + g_mutex_unlock ( recorder->mutex );
29.1797
29.1798 - if (str_list != NULL)
29.1799 - g_object_unref (str_list);
29.1800 + if ( str_list != NULL )
29.1801 + g_object_unref ( str_list );
29.1802
29.1803 - g_string_free (query, TRUE);
29.1804 + g_string_free ( query, TRUE );
29.1805
29.1806 return fr;
29.1807
30.1 --- a/gmyth/src/gmyth_recorder.h Wed May 23 19:21:26 2007 +0100
30.2 +++ b/gmyth/src/gmyth_recorder.h Wed May 23 19:50:41 2007 +0100
30.3 @@ -11,22 +11,21 @@
30.4 * @author Hallyson Luiz de Morais Melo <hallyson.melo@indt.org.br>
30.5 * @author Rosfran Borges <rosfran.borges@indt.org.br>
30.6 *
30.7 - *//*
30.8 - *
30.9 - * This program is free software; you can redistribute it and/or modify
30.10 - * it under the terms of the GNU Lesser General Public License as published by
30.11 - * the Free Software Foundation; either version 2 of the License, or
30.12 - * (at your option) any later version.
30.13 - *
30.14 - * This program is distributed in the hope that it will be useful,
30.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
30.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30.17 - * GNU General Public License for more details.
30.18 - *
30.19 - * You should have received a copy of the GNU Lesser General Public License
30.20 - * along with this program; if not, write to the Free Software
30.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30.22 - */
30.23 + *
30.24 + * This program is free software; you can redistribute it and/or modify
30.25 + * it under the terms of the GNU Lesser General Public License as published by
30.26 + * the Free Software Foundation; either version 2 of the License, or
30.27 + * (at your option) any later version.
30.28 + *
30.29 + * This program is distributed in the hope that it will be useful,
30.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
30.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30.32 + * GNU General Public License for more details.
30.33 + *
30.34 + * You should have received a copy of the GNU Lesser General Public License
30.35 + * along with this program; if not, write to the Free Software
30.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30.37 + */
30.38
30.39 #ifndef __GMYTH_RECORDER_H__
30.40 #define __GMYTH_RECORDER_H__
30.41 @@ -54,99 +53,106 @@
30.42 typedef struct _GMythRecorderClass GMythRecorderClass;
30.43
30.44 struct _GMythRecorderClass
30.45 -{
30.46 - GObjectClass parent_class;
30.47 + {
30.48 + GObjectClass parent_class;
30.49
30.50 - /* callbacks */
30.51 - /* no one for now */
30.52 -};
30.53 + /* callbacks */
30.54 + /* no one for now */
30.55 + };
30.56
30.57 struct _GMythRecorder
30.58 -{
30.59 - GObject parent;
30.60 + {
30.61 + GObject parent;
30.62
30.63 - /* socket descriptor */
30.64 - GMythSocket *myth_socket;
30.65 + /* socket descriptor */
30.66 + GMythSocket *myth_socket;
30.67
30.68 - gint recorder_num;
30.69 - GString *hostname;
30.70 - gint port;
30.71 + gint recorder_num;
30.72 + GString *hostname;
30.73 + gint port;
30.74
30.75 - GList *progs_info_list;
30.76 + GList *progs_info_list;
30.77
30.78 - GMutex *mutex;
30.79 -};
30.80 + GMutex *mutex;
30.81 + };
30.82
30.83 typedef enum _GMythRecorderChannelChangeDirection
30.84 -{
30.85 - CHANNEL_DIRECTION_UP = 0,
30.86 - CHANNEL_DIRECTION_DOWN,
30.87 - CHANNEL_DIRECTION_FAVORITE,
30.88 - CHANNEL_DIRECTION_SAME
30.89 -} GMythRecorderChannelChangeDirection;
30.90 + {
30.91 + CHANNEL_DIRECTION_UP = 0,
30.92 + CHANNEL_DIRECTION_DOWN,
30.93 + CHANNEL_DIRECTION_FAVORITE,
30.94 + CHANNEL_DIRECTION_SAME
30.95 + } GMythRecorderChannelChangeDirection;
30.96
30.97 typedef enum _GMythRecorderBrowseDirection
30.98 -{
30.99 - BROWSE_DIRECTION_SAME = 0, /* Stay in the same place */
30.100 - BROWSE_DIRECTION_UP, /* Move up one slot (down one channel) */
30.101 - BROWSE_DIRECTION_DOWN, /* Move down one slot (up one channel) */
30.102 - BROWSE_DIRECTION_LEFT, /* Move left one slot (down one time slot) */
30.103 - BROWSE_DIRECTION_RIGHT, /* Move right one slot (up one time slot) */
30.104 - BROWSE_DIRECTION_FAVORITE /* Move to the next favorite slot */
30.105 -} GMythRecorderBrowseDirection;
30.106 + {
30.107 + BROWSE_DIRECTION_SAME = 0, /* Stay in the same place */
30.108 + BROWSE_DIRECTION_UP, /* Move up one slot (down one channel) */
30.109 + BROWSE_DIRECTION_DOWN, /* Move down one slot (up one channel) */
30.110 + BROWSE_DIRECTION_LEFT, /* Move left one slot (down one time slot) */
30.111 + BROWSE_DIRECTION_RIGHT, /* Move right one slot (up one time slot) */
30.112 + BROWSE_DIRECTION_FAVORITE /* Move to the next favorite slot */
30.113 + } GMythRecorderBrowseDirection;
30.114
30.115 -GType gmyth_recorder_get_type (void);
30.116 +GType gmyth_recorder_get_type ( void );
30.117
30.118 -GMythRecorder *gmyth_recorder_new (int num, GString * hostname, gshort port);
30.119 +GMythRecorder *gmyth_recorder_new ( int num, GString * hostname, gshort port );
30.120
30.121 -void gmyth_recorder_close (GMythRecorder * recorder);
30.122 +void gmyth_recorder_close ( GMythRecorder * recorder );
30.123
30.124 -gboolean gmyth_recorder_setup (GMythRecorder * recorder);
30.125 -gboolean gmyth_recorder_spawntv (GMythRecorder * recorder,
30.126 - GString * tvchain_id);
30.127 +gboolean gmyth_recorder_setup ( GMythRecorder * recorder );
30.128 +gboolean gmyth_recorder_spawntv ( GMythRecorder * recorder,
30.129 + GString * tvchain_id );
30.130
30.131 -gboolean gmyth_recorder_spawntv_no_tvchain (GMythRecorder * recorder);
30.132 +gboolean gmyth_recorder_spawntv_no_tvchain ( GMythRecorder * recorder );
30.133
30.134 -gboolean gmyth_recorder_stop_livetv (GMythRecorder * recorder);
30.135 +gboolean gmyth_recorder_stop_livetv ( GMythRecorder * recorder );
30.136
30.137 -gboolean gmyth_recorder_send_frontend_ready_command (GMythRecorder * recorder);
30.138 +gboolean gmyth_recorder_send_frontend_ready_command ( GMythRecorder *
30.139 + recorder );
30.140
30.141 -gboolean gmyth_recorder_check_channel (GMythRecorder * recorder, gint channel);
30.142 +gboolean gmyth_recorder_check_channel ( GMythRecorder * recorder,
30.143 + gint channel );
30.144
30.145 -gboolean gmyth_recorder_check_channel_name (GMythRecorder * recorder,
30.146 - gchar * channel);
30.147 +gboolean gmyth_recorder_check_channel_name ( GMythRecorder * recorder,
30.148 + gchar * channel );
30.149
30.150 -gboolean gmyth_recorder_set_channel (GMythRecorder * recorder, gint channel);
30.151 +gboolean gmyth_recorder_set_channel ( GMythRecorder * recorder, gint channel );
30.152
30.153 -gboolean gmyth_recorder_set_channel_name (GMythRecorder * recorder,
30.154 - const gchar * channel);
30.155 +gboolean gmyth_recorder_set_channel_name ( GMythRecorder * recorder,
30.156 + const gchar * channel );
30.157
30.158 -gboolean gmyth_recorder_change_channel (GMythRecorder * recorder,
30.159 - const GMythRecorderChannelChangeDirection direction);
30.160 +gboolean gmyth_recorder_change_channel ( GMythRecorder * recorder,
30.161 + const
30.162 + GMythRecorderChannelChangeDirection
30.163 + direction );
30.164
30.165 -GList *gmyth_recorder_get_channel_list (GMythRecorder * recorder);
30.166 +GList *gmyth_recorder_get_channel_list ( GMythRecorder * recorder );
30.167
30.168 -gboolean gmyth_recorder_pause_recording (GMythRecorder * recorder);
30.169 +gboolean gmyth_recorder_pause_recording ( GMythRecorder * recorder );
30.170
30.171 -GMythProgramInfo *gmyth_recorder_get_current_program_info (GMythRecorder *
30.172 - recorder);
30.173 +GMythProgramInfo *gmyth_recorder_get_current_program_info ( GMythRecorder *
30.174 + recorder );
30.175
30.176 -GMythProgramInfo *gmyth_recorder_get_next_program_info (GMythRecorder *
30.177 - recorder, const GMythRecorderBrowseDirection direction);
30.178 +GMythProgramInfo *gmyth_recorder_get_next_program_info ( GMythRecorder *
30.179 + recorder,
30.180 + const
30.181 + GMythRecorderBrowseDirection
30.182 + direction );
30.183
30.184 -GMythRecorder *gmyth_recorder_get_recorder_from_num (gint rec_id);
30.185 +GMythRecorder *gmyth_recorder_get_recorder_from_num ( gint rec_id );
30.186
30.187 -gint64 gmyth_recorder_get_file_position (GMythRecorder * recorder);
30.188 +gint64 gmyth_recorder_get_file_position ( GMythRecorder * recorder );
30.189
30.190 -gboolean gmyth_recorder_is_recording (GMythRecorder * recorder);
30.191 +gboolean gmyth_recorder_is_recording ( GMythRecorder * recorder );
30.192
30.193 -gboolean gmyth_recorder_finish_recording (GMythRecorder * recorder);
30.194 +gboolean gmyth_recorder_finish_recording ( GMythRecorder * recorder );
30.195
30.196 -gboolean gmyth_recorder_stop_playing (GMythRecorder * recorder);
30.197 +gboolean gmyth_recorder_stop_playing ( GMythRecorder * recorder );
30.198
30.199 -gboolean gmyth_recorder_free_tuner (GMythRecorder * recorder);
30.200 +gboolean gmyth_recorder_free_tuner ( GMythRecorder * recorder );
30.201
30.202 -gdouble gmyth_recorder_get_framerate (GMythRecorder * recorder);
30.203 +gdouble gmyth_recorder_get_framerate ( GMythRecorder * recorder );
30.204
30.205 G_END_DECLS
30.206 #endif /* __GMYTH_REMOTE_ENCODER_H__ */
31.1 --- a/gmyth/src/gmyth_recprofile.c Wed May 23 19:21:26 2007 +0100
31.2 +++ b/gmyth/src/gmyth_recprofile.c Wed May 23 19:50:41 2007 +0100
31.3 @@ -8,9 +8,6 @@
31.4 * Copyright (C) 2007 INdT - Instituto Nokia de Tecnologia.
31.5 * @author Artur Duque de Souza <artur.souza@indt.org.br>
31.6 *
31.7 - */
31.8 -/*
31.9 - *
31.10 * This program is free software; you can redistribute it and/or modify
31.11 * it under the terms of the GNU Lesser General Public License as published by
31.12 * the Free Software Foundation; either version 2 of the License, or
31.13 @@ -40,54 +37,54 @@
31.14 #include "gmyth_debug.h"
31.15 #include "gmyth_http.h"
31.16
31.17 -static void gmyth_recprofile_class_init (GMythRecProfileClass * klass);
31.18 -static void gmyth_recprofile_init (GMythRecProfile * object);
31.19 +static void gmyth_recprofile_class_init ( GMythRecProfileClass * klass );
31.20 +static void gmyth_recprofile_init ( GMythRecProfile * object );
31.21
31.22 -static void gmyth_recprofile_dispose (GObject * object);
31.23 -static void gmyth_recprofile_finalize (GObject * object);
31.24 +static void gmyth_recprofile_dispose ( GObject * object );
31.25 +static void gmyth_recprofile_finalize ( GObject * object );
31.26
31.27 -G_DEFINE_TYPE (GMythRecProfile, gmyth_recprofile, G_TYPE_OBJECT)
31.28 - static void gmyth_recprofile_class_init (GMythRecProfileClass * klass)
31.29 +G_DEFINE_TYPE ( GMythRecProfile, gmyth_recprofile, G_TYPE_OBJECT )
31.30 + static void gmyth_recprofile_class_init ( GMythRecProfileClass * klass )
31.31 {
31.32 - GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
31.33 + GObjectClass *gobject_class = G_OBJECT_CLASS ( klass );
31.34
31.35 gobject_class->dispose = gmyth_recprofile_dispose;
31.36 gobject_class->finalize = gmyth_recprofile_finalize;
31.37 }
31.38
31.39 static void
31.40 -gmyth_recprofile_init (GMythRecProfile * recprofile)
31.41 +gmyth_recprofile_init ( GMythRecProfile * recprofile )
31.42 {
31.43 }
31.44
31.45 static void
31.46 -gmyth_recprofile_dispose (GObject * object)
31.47 +gmyth_recprofile_dispose ( GObject * object )
31.48 {
31.49 - GMythRecProfile *recprofile = GMYTH_RECPROFILE (object);
31.50 + GMythRecProfile *recprofile = GMYTH_RECPROFILE ( object );
31.51
31.52 - if (recprofile->name)
31.53 - g_free (recprofile->name);
31.54 + if ( recprofile->name )
31.55 + g_free ( recprofile->name );
31.56
31.57 - if (recprofile->group)
31.58 - g_free (recprofile->group);
31.59 + if ( recprofile->group )
31.60 + g_free ( recprofile->group );
31.61
31.62 - if (recprofile->vcodec)
31.63 - g_free (recprofile->vcodec);
31.64 + if ( recprofile->vcodec )
31.65 + g_free ( recprofile->vcodec );
31.66
31.67 - if (recprofile->acodec)
31.68 - g_free (recprofile->acodec);
31.69 + if ( recprofile->acodec )
31.70 + g_free ( recprofile->acodec );
31.71
31.72 - if (recprofile->options)
31.73 - g_free (recprofile->options);
31.74 + if ( recprofile->options )
31.75 + g_free ( recprofile->options );
31.76
31.77 - G_OBJECT_CLASS (gmyth_recprofile_parent_class)->dispose (object);
31.78 + G_OBJECT_CLASS ( gmyth_recprofile_parent_class )->dispose ( object );
31.79 }
31.80
31.81 static void
31.82 -gmyth_recprofile_finalize (GObject * object)
31.83 +gmyth_recprofile_finalize ( GObject * object )
31.84 {
31.85 - g_signal_handlers_destroy (object);
31.86 - G_OBJECT_CLASS (gmyth_recprofile_parent_class)->finalize (object);
31.87 + g_signal_handlers_destroy ( object );
31.88 + G_OBJECT_CLASS ( gmyth_recprofile_parent_class )->finalize ( object );
31.89 }
31.90
31.91 /**
31.92 @@ -96,10 +93,10 @@
31.93 * @return a new instance of GMythRecProfile.
31.94 **/
31.95 GMythRecProfile *
31.96 -gmyth_recprofile_new (void)
31.97 +gmyth_recprofile_new ( void )
31.98 {
31.99 GMythRecProfile *recprofile = GMYTH_RECPROFILE
31.100 - (g_object_new (GMYTH_RECPROFILE_TYPE, NULL));
31.101 + ( g_object_new ( GMYTH_RECPROFILE_TYPE, NULL ) );
31.102
31.103 recprofile->id = 0;
31.104 recprofile->name = NULL;
31.105 @@ -121,9 +118,9 @@
31.106 *
31.107 **/
31.108 GSList *
31.109 -gmyth_recprofile_get_profile_list (GMythBackendInfo * backend_info)
31.110 +gmyth_recprofile_get_profile_list ( GMythBackendInfo * backend_info )
31.111 {
31.112 - return gmyth_http_retrieve_rec_profiles (backend_info, "Transcoders");
31.113 + return gmyth_http_retrieve_rec_profiles ( backend_info, "Transcoders" );
31.114 }
31.115
31.116 /**
31.117 @@ -136,10 +133,10 @@
31.118 *
31.119 **/
31.120 gint
31.121 -gmyth_recprofile_create_profile (GMythBackendInfo * backend_info,
31.122 - GMythRecProfile * profile)
31.123 +gmyth_recprofile_create_profile ( GMythBackendInfo * backend_info,
31.124 + GMythRecProfile * profile )
31.125 {
31.126 - return gmyth_http_create_rec_profile (backend_info, profile);
31.127 + return gmyth_http_create_rec_profile ( backend_info, profile );
31.128 }
31.129
31.130 /**
31.131 @@ -152,9 +149,9 @@
31.132 *
31.133 **/
31.134 gint
31.135 -gmyth_recprofile_del_profile_list (GMythBackendInfo * backend_info, gint id)
31.136 +gmyth_recprofile_del_profile_list ( GMythBackendInfo * backend_info, gint id )
31.137 {
31.138 - return gmyth_http_del_rec_profile (backend_info, id);
31.139 + return gmyth_http_del_rec_profile ( backend_info, id );
31.140 }
31.141
31.142 /**
31.143 @@ -167,7 +164,7 @@
31.144 *
31.145 **/
31.146 gint
31.147 -gmyth_recprofile_set_id (GMythRecProfile * rec, gint id)
31.148 +gmyth_recprofile_set_id ( GMythRecProfile * rec, gint id )
31.149 {
31.150 rec->id = id;
31.151 return 0;
31.152 @@ -184,22 +181,24 @@
31.153 *
31.154 **/
31.155 gint
31.156 -gmyth_recprofile_set (GMythRecProfile * rec, gchar * member, gchar * value)
31.157 +gmyth_recprofile_set ( GMythRecProfile * rec, gchar * member, gchar * value )
31.158 {
31.159 int ret = 0;
31.160
31.161 - if (value != NULL) {
31.162 - if (g_ascii_strcasecmp (member, "name") == 0)
31.163 - rec->name = g_strndup (value, strlen (value));
31.164 - else if (g_ascii_strcasecmp (member, "group") == 0)
31.165 - rec->group = g_strndup (value, strlen (value));
31.166 - else if (g_ascii_strcasecmp (member, "vcodec") == 0)
31.167 - rec->vcodec = g_strndup (value, strlen (value));
31.168 - else if (g_ascii_strcasecmp (member, "acodec") == 0)
31.169 - rec->acodec = g_strndup (value, strlen (value));
31.170 + if ( value != NULL )
31.171 + {
31.172 + if ( g_ascii_strcasecmp ( member, "name" ) == 0 )
31.173 + rec->name = g_strndup ( value, strlen ( value ) );
31.174 + else if ( g_ascii_strcasecmp ( member, "group" ) == 0 )
31.175 + rec->group = g_strndup ( value, strlen ( value ) );
31.176 + else if ( g_ascii_strcasecmp ( member, "vcodec" ) == 0 )
31.177 + rec->vcodec = g_strndup ( value, strlen ( value ) );
31.178 + else if ( g_ascii_strcasecmp ( member, "acodec" ) == 0 )
31.179 + rec->acodec = g_strndup ( value, strlen ( value ) );
31.180 else
31.181 ret = -1;
31.182 - } else
31.183 + }
31.184 + else
31.185 ret = -1;
31.186
31.187 return ret;
31.188 @@ -215,9 +214,9 @@
31.189 *
31.190 **/
31.191 gint
31.192 -gmyth_recprofile_set_name (GMythRecProfile * rec, gchar * name)
31.193 +gmyth_recprofile_set_name ( GMythRecProfile * rec, gchar * name )
31.194 {
31.195 - return gmyth_recprofile_set (rec, "name", name);
31.196 + return gmyth_recprofile_set ( rec, "name", name );
31.197 }
31.198
31.199 /**
31.200 @@ -230,9 +229,9 @@
31.201 *
31.202 **/
31.203 gint
31.204 -gmyth_recprofile_set_group (GMythRecProfile * rec, gchar * group)
31.205 +gmyth_recprofile_set_group ( GMythRecProfile * rec, gchar * group )
31.206 {
31.207 - return gmyth_recprofile_set (rec, "group", group);
31.208 + return gmyth_recprofile_set ( rec, "group", group );
31.209 }
31.210
31.211 /**
31.212 @@ -245,9 +244,9 @@
31.213 *
31.214 **/
31.215 gint
31.216 -gmyth_recprofile_set_vcodec (GMythRecProfile * rec, gchar * vcodec)
31.217 +gmyth_recprofile_set_vcodec ( GMythRecProfile * rec, gchar * vcodec )
31.218 {
31.219 - return gmyth_recprofile_set (rec, "vcodec", vcodec);
31.220 + return gmyth_recprofile_set ( rec, "vcodec", vcodec );
31.221 }
31.222
31.223 /**
31.224 @@ -260,7 +259,7 @@
31.225 *
31.226 **/
31.227 gint
31.228 -gmyth_recprofile_set_acodec (GMythRecProfile * rec, gchar * acodec)
31.229 +gmyth_recprofile_set_acodec ( GMythRecProfile * rec, gchar * acodec )
31.230 {
31.231 - return gmyth_recprofile_set (rec, "acodec", acodec);
31.232 + return gmyth_recprofile_set ( rec, "acodec", acodec );
31.233 }
32.1 --- a/gmyth/src/gmyth_recprofile.h Wed May 23 19:21:26 2007 +0100
32.2 +++ b/gmyth/src/gmyth_recprofile.h Wed May 23 19:50:41 2007 +0100
32.3 @@ -8,8 +8,6 @@
32.4 * Copyright (C) 2007 INdT - Instituto Nokia de Tecnologia.
32.5 * @author Artur Duque de Souza <artur.souza@indt.org.br>
32.6 *
32.7 - */
32.8 -/*
32.9 *
32.10 * This program is free software; you can redistribute it and/or modify
32.11 * it under the terms of the GNU Lesser General Public License as published by
32.12 @@ -48,73 +46,73 @@
32.13 typedef struct _GMythRecProfileClass GMythRecProfileClass;
32.14
32.15 struct _GMythRecProfileClass
32.16 -{
32.17 - GObjectClass parent_class;
32.18 - gint teste;
32.19 - /* callbacks */
32.20 -};
32.21 + {
32.22 + GObjectClass parent_class;
32.23 + gint teste;
32.24 + /* callbacks */
32.25 + };
32.26
32.27 struct _GMythRecProfile
32.28 -{
32.29 - gint id;
32.30 - gchar *name;
32.31 - gchar *group;
32.32 - gchar *vcodec;
32.33 - gchar *acodec;
32.34 - Options *options;
32.35 -};
32.36 + {
32.37 + gint id;
32.38 + gchar *name;
32.39 + gchar *group;
32.40 + gchar *vcodec;
32.41 + gchar *acodec;
32.42 + Options *options;
32.43 + };
32.44
32.45 struct _Options
32.46 -{
32.47 - gint transcodelossless;
32.48 - gint transcoderesize;
32.49 - gint width;
32.50 - gint height;
32.51 - gint rtjpegquality;
32.52 - gint rtjpeglumafilter;
32.53 - gint rtjpegchromafilter;
32.54 - gint mpeg4bitrate;
32.55 - gint mpeg4maxquality;
32.56 - gint mpeg4minquality;
32.57 - gint mpeg4qualdiff;
32.58 - gint mpeg4scalebitrate;
32.59 - gint mpeg4optionvhq;
32.60 - gint mpeg4option4mv;
32.61 - gint mpeg4optionidct;
32.62 - gint mpeg4optionime;
32.63 - gint hardwaremjpegquality;
32.64 - gint hardwaremjpeghdecimation;
32.65 - gint hardwaremjpegvdecimation;
32.66 - gchar *mpeg2streamtype;
32.67 - gchar *mpeg2aspectratio;
32.68 - gint mpeg2bitrate;
32.69 - gint mpeg2maxbitrate;
32.70 - gint samplerate;
32.71 - gint mp3quality;
32.72 - gint volume;
32.73 - gchar *mpeg2audtype;
32.74 - gint mpeg2audbitratel1;
32.75 - gint mpeg2audbitratel2;
32.76 - gint mpeg2audvolume;
32.77 -};
32.78 + {
32.79 + gint transcodelossless;
32.80 + gint transcoderesize;
32.81 + gint width;
32.82 + gint height;
32.83 + gint rtjpegquality;
32.84 + gint rtjpeglumafilter;
32.85 + gint rtjpegchromafilter;
32.86 + gint mpeg4bitrate;
32.87 + gint mpeg4maxquality;
32.88 + gint mpeg4minquality;
32.89 + gint mpeg4qualdiff;
32.90 + gint mpeg4scalebitrate;
32.91 + gint mpeg4optionvhq;
32.92 + gint mpeg4option4mv;
32.93 + gint mpeg4optionidct;
32.94 + gint mpeg4optionime;
32.95 + gint hardwaremjpegquality;
32.96 + gint hardwaremjpeghdecimation;
32.97 + gint hardwaremjpegvdecimation;
32.98 + gchar *mpeg2streamtype;
32.99 + gchar *mpeg2aspectratio;
32.100 + gint mpeg2bitrate;
32.101 + gint mpeg2maxbitrate;
32.102 + gint samplerate;
32.103 + gint mp3quality;
32.104 + gint volume;
32.105 + gchar *mpeg2audtype;
32.106 + gint mpeg2audbitratel1;
32.107 + gint mpeg2audbitratel2;
32.108 + gint mpeg2audvolume;
32.109 + };
32.110
32.111 -GType gmyth_recprofile_type (void);
32.112 +GType gmyth_recprofile_type ( void );
32.113
32.114 -GMythRecProfile *gmyth_recprofile_new (void);
32.115 +GMythRecProfile *gmyth_recprofile_new ( void );
32.116
32.117 -GSList *gmyth_recprofile_get_profile_list (GMythBackendInfo * backend_info);
32.118 +GSList *gmyth_recprofile_get_profile_list ( GMythBackendInfo * backend_info );
32.119
32.120 -gint gmyth_recprofile_create_profile (GMythBackendInfo * backend_info,
32.121 - GMythRecProfile * profile);
32.122 +gint gmyth_recprofile_create_profile ( GMythBackendInfo * backend_info,
32.123 + GMythRecProfile * profile );
32.124
32.125 -gint gmyth_recprofile_del_profile_list (GMythBackendInfo * backend_info,
32.126 - gint id);
32.127 +gint gmyth_recprofile_del_profile_list ( GMythBackendInfo * backend_info,
32.128 + gint id );
32.129
32.130 -gint gmyth_recprofile_set_acodec (GMythRecProfile * rec, gchar * acodec);
32.131 -gint gmyth_recprofile_set_vcodec (GMythRecProfile * rec, gchar * vcodec);
32.132 -gint gmyth_recprofile_set_group (GMythRecProfile * rec, gchar * group);
32.133 -gint gmyth_recprofile_set_name (GMythRecProfile * rec, gchar * name);
32.134 -gint gmyth_recprofile_set_id (GMythRecProfile * rec, gint id);
32.135 +gint gmyth_recprofile_set_acodec ( GMythRecProfile * rec, gchar * acodec );
32.136 +gint gmyth_recprofile_set_vcodec ( GMythRecProfile * rec, gchar * vcodec );
32.137 +gint gmyth_recprofile_set_group ( GMythRecProfile * rec, gchar * group );
32.138 +gint gmyth_recprofile_set_name ( GMythRecProfile * rec, gchar * name );
32.139 +gint gmyth_recprofile_set_id ( GMythRecProfile * rec, gint id );
32.140
32.141 G_END_DECLS
32.142 #endif /*_GMYTH_RECPROFILE_H*/
33.1 --- a/gmyth/src/gmyth_remote_util.c Wed May 23 19:21:26 2007 +0100
33.2 +++ b/gmyth/src/gmyth_remote_util.c Wed May 23 19:50:41 2007 +0100
33.3 @@ -9,22 +9,21 @@
33.4 * @author Hallyson Luiz de Morais Melo <hallyson.melo@indt.org.br>
33.5 * @author Rosfran Borges <rosfran.borges@indt.org.br>
33.6 *
33.7 - *//*
33.8 - *
33.9 - * This program is free software; you can redistribute it and/or modify
33.10 - * it under the terms of the GNU Lesser General Public License as published by
33.11 - * the Free Software Foundation; either version 2 of the License, or
33.12 - * (at your option) any later version.
33.13 - *
33.14 - * This program is distributed in the hope that it will be useful,
33.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
33.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33.17 - * GNU General Public License for more details.
33.18 - *
33.19 - * You should have received a copy of the GNU Lesser General Public License
33.20 - * along with this program; if not, write to the Free Software
33.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33.22 - */
33.23 + *
33.24 + * This program is free software; you can redistribute it and/or modify
33.25 + * it under the terms of the GNU Lesser General Public License as published by
33.26 + * the Free Software Foundation; either version 2 of the License, or
33.27 + * (at your option) any later version.
33.28 + *
33.29 + * This program is distributed in the hope that it will be useful,
33.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
33.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33.32 + * GNU General Public License for more details.
33.33 + *
33.34 + * You should have received a copy of the GNU Lesser General Public License
33.35 + * along with this program; if not, write to the Free Software
33.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33.37 + */
33.38
33.39 #ifdef HAVE_CONFIG_H
33.40 #include "config.h"
33.41 @@ -45,42 +44,43 @@
33.42 * @return the remote encoder instance available, or NULL if any error happens.
33.43 */
33.44 GMythRecorder *
33.45 -remote_request_next_free_recorder (GMythSocket * socket, gint curr)
33.46 +remote_request_next_free_recorder ( GMythSocket * socket, gint curr )
33.47 {
33.48 GMythRecorder *recorder = NULL;
33.49 GString *hostname;
33.50 gint num, port;
33.51
33.52 - GMythStringList *strlist = gmyth_string_list_new ();
33.53 + GMythStringList *strlist = gmyth_string_list_new ( );
33.54
33.55 - gmyth_debug ("[%s] Request next free recorder in the backend",
33.56 - __FUNCTION__);
33.57 + gmyth_debug ( "[%s] Request next free recorder in the backend",
33.58 + __FUNCTION__ );
33.59
33.60 - gmyth_string_list_append_char_array (strlist, "GET_NEXT_FREE_RECORDER");
33.61 - gmyth_string_list_append_int (strlist, curr);
33.62 + gmyth_string_list_append_char_array ( strlist, "GET_NEXT_FREE_RECORDER" );
33.63 + gmyth_string_list_append_int ( strlist, curr );
33.64
33.65 - if (!gmyth_socket_sendreceive_stringlist (socket, strlist)) {
33.66 - g_warning ("GET_NEXT_FREE_RECORDER request error!\n");
33.67 + if ( !gmyth_socket_sendreceive_stringlist ( socket, strlist ) )
33.68 + {
33.69 + g_warning ( "GET_NEXT_FREE_RECORDER request error!\n" );
33.70 return NULL;
33.71 }
33.72
33.73 - num = gmyth_string_list_get_int (strlist, 0);
33.74 - hostname = gmyth_string_list_get_string (strlist, 1);
33.75 - port = gmyth_string_list_get_int (strlist, 2);
33.76 + num = gmyth_string_list_get_int ( strlist, 0 );
33.77 + hostname = gmyth_string_list_get_string ( strlist, 1 );
33.78 + port = gmyth_string_list_get_int ( strlist, 2 );
33.79
33.80 - if (num < 0 || port < 0)
33.81 + if ( num < 0 || port < 0 )
33.82 goto clean_up;
33.83
33.84 gmyth_debug
33.85 - ("[%s] Free recorder info received: num: %d, hostname: %s, port: %d",
33.86 - __FUNCTION__, num, hostname->str, port);
33.87 + ( "[%s] Free recorder info received: num: %d, hostname: %s, port: %d",
33.88 + __FUNCTION__, num, hostname->str, port );
33.89
33.90 - recorder = gmyth_recorder_new (num, hostname, port);
33.91 + recorder = gmyth_recorder_new ( num, hostname, port );
33.92
33.93 clean_up:
33.94
33.95 - g_string_free (hostname, TRUE);
33.96 - g_object_unref (strlist);
33.97 + g_string_free ( hostname, TRUE );
33.98 + g_object_unref ( strlist );
33.99
33.100 return recorder;
33.101 }
33.102 @@ -93,33 +93,34 @@
33.103 * @return the number of remote encoders instance available, or 0 if no one is actually free..
33.104 */
33.105 gint
33.106 -gmyth_remote_util_get_free_recorder_count (GMythSocket * socket)
33.107 +gmyth_remote_util_get_free_recorder_count ( GMythSocket * socket )
33.108 {
33.109 gint num_recs = 0;
33.110
33.111 - GMythStringList *strlist = gmyth_string_list_new ();
33.112 + GMythStringList *strlist = gmyth_string_list_new ( );
33.113
33.114 - gmyth_debug ("[%s] Request next free recorder in the backend",
33.115 - __FUNCTION__);
33.116 + gmyth_debug ( "[%s] Request next free recorder in the backend",
33.117 + __FUNCTION__ );
33.118
33.119 - gmyth_string_list_append_char_array (strlist, "GET_FREE_RECORDER_COUNT");
33.120 + gmyth_string_list_append_char_array ( strlist, "GET_FREE_RECORDER_COUNT" );
33.121
33.122 - if (!gmyth_socket_sendreceive_stringlist (socket, strlist)) {
33.123 - gmyth_debug ("GET_FREE_RECORDER_COUNT request error!");
33.124 + if ( !gmyth_socket_sendreceive_stringlist ( socket, strlist ) )
33.125 + {
33.126 + gmyth_debug ( "GET_FREE_RECORDER_COUNT request error!" );
33.127 return 0;
33.128 }
33.129
33.130 - num_recs = gmyth_string_list_get_int (strlist, 0);
33.131 + num_recs = gmyth_string_list_get_int ( strlist, 0 );
33.132
33.133 - if (num_recs < 0)
33.134 + if ( num_recs < 0 )
33.135 goto clean_up;
33.136
33.137 - gmyth_debug ("[%s] Free recorder info received: num recorders: %d",
33.138 - __FUNCTION__, num_recs);
33.139 + gmyth_debug ( "[%s] Free recorder info received: num recorders: %d",
33.140 + __FUNCTION__, num_recs );
33.141
33.142 clean_up:
33.143
33.144 - g_object_unref (strlist);
33.145 + g_object_unref ( strlist );
33.146
33.147 return num_recs;
33.148 }
34.1 --- a/gmyth/src/gmyth_remote_util.h Wed May 23 19:21:26 2007 +0100
34.2 +++ b/gmyth/src/gmyth_remote_util.h Wed May 23 19:50:41 2007 +0100
34.3 @@ -8,22 +8,21 @@
34.4 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
34.5 * @author Hallyson Luiz de Morais Melo <hallyson.melo@indt.org.br>
34.6 *
34.7 - *//*
34.8 - *
34.9 - * This program is free software; you can redistribute it and/or modify
34.10 - * it under the terms of the GNU Lesser General Public License as published by
34.11 - * the Free Software Foundation; either version 2 of the License, or
34.12 - * (at your option) any later version.
34.13 - *
34.14 - * This program is distributed in the hope that it will be useful,
34.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
34.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34.17 - * GNU General Public License for more details.
34.18 - *
34.19 - * You should have received a copy of the GNU Lesser General Public License
34.20 - * along with this program; if not, write to the Free Software
34.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34.22 - */
34.23 + *
34.24 + * This program is free software; you can redistribute it and/or modify
34.25 + * it under the terms of the GNU Lesser General Public License as published by
34.26 + * the Free Software Foundation; either version 2 of the License, or
34.27 + * (at your option) any later version.
34.28 + *
34.29 + * This program is distributed in the hope that it will be useful,
34.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
34.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34.32 + * GNU General Public License for more details.
34.33 + *
34.34 + * You should have received a copy of the GNU Lesser General Public License
34.35 + * along with this program; if not, write to the Free Software
34.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34.37 + */
34.38
34.39 #ifndef __REMOTE_UTIL_H__
34.40 #define __REMOTE_UTIL_H__
34.41 @@ -33,9 +32,9 @@
34.42 #include "gmyth_socket.h"
34.43
34.44 G_BEGIN_DECLS
34.45 - GMythRecorder * remote_request_next_free_recorder (GMythSocket * socket,
34.46 - gint curr);
34.47 -gint gmyth_remote_util_get_free_recorder_count (GMythSocket * socket);
34.48 + GMythRecorder * remote_request_next_free_recorder ( GMythSocket * socket,
34.49 + gint curr );
34.50 +gint gmyth_remote_util_get_free_recorder_count ( GMythSocket * socket );
34.51
34.52 G_END_DECLS
34.53 #endif
35.1 --- a/gmyth/src/gmyth_scheduler.c Wed May 23 19:21:26 2007 +0100
35.2 +++ b/gmyth/src/gmyth_scheduler.c Wed May 23 19:50:41 2007 +0100
35.3 @@ -9,22 +9,21 @@
35.4 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
35.5 * @author Alexsandro Jose Virginio dos Santos <alexsandro.santos@indt.org.br>
35.6 *
35.7 - *//*
35.8 - *
35.9 - * This program is free software; you can redistribute it and/or modify
35.10 - * it under the terms of the GNU Lesser General Public License as published by
35.11 - * the Free Software Foundation; either version 2 of the License, or
35.12 - * (at your option) any later version.
35.13 - *
35.14 - * This program is distributed in the hope that it will be useful,
35.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
35.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35.17 - * GNU General Public License for more details.
35.18 - *
35.19 - * You should have received a copy of the GNU Lesser General Public License
35.20 - * along with this program; if not, write to the Free Software
35.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35.22 - */
35.23 + *
35.24 + * This program is free software; you can redistribute it and/or modify
35.25 + * it under the terms of the GNU Lesser General Public License as published by
35.26 + * the Free Software Foundation; either version 2 of the License, or
35.27 + * (at your option) any later version.
35.28 + *
35.29 + * This program is distributed in the hope that it will be useful,
35.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
35.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35.32 + * GNU General Public License for more details.
35.33 + *
35.34 + * You should have received a copy of the GNU Lesser General Public License
35.35 + * along with this program; if not, write to the Free Software
35.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35.37 + */
35.38
35.39 #ifdef HAVE_CONFIG_H
35.40 #include "config.h"
35.41 @@ -40,33 +39,33 @@
35.42 #include "gmyth_socket.h"
35.43 #include "gmyth_debug.h"
35.44
35.45 -static void gmyth_scheduler_class_init (GMythSchedulerClass * klass);
35.46 -static void gmyth_scheduler_init (GMythScheduler * object);
35.47 +static void gmyth_scheduler_class_init ( GMythSchedulerClass * klass );
35.48 +static void gmyth_scheduler_init ( GMythScheduler * object );
35.49
35.50 -static void gmyth_scheduler_dispose (GObject * object);
35.51 -static void gmyth_scheduler_finalize (GObject * object);
35.52 +static void gmyth_scheduler_dispose ( GObject * object );
35.53 +static void gmyth_scheduler_finalize ( GObject * object );
35.54
35.55 -static gint get_record_id_from_database (GMythScheduler * scheduler);
35.56 -static gboolean update_backend (GMythScheduler * scheduler, gint record_id);
35.57 +static gint get_record_id_from_database ( GMythScheduler * scheduler );
35.58 +static gboolean update_backend ( GMythScheduler * scheduler, gint record_id );
35.59
35.60 -G_DEFINE_TYPE (GMythScheduler, gmyth_scheduler, G_TYPE_OBJECT)
35.61 - static void gmyth_scheduler_class_init (GMythSchedulerClass * klass)
35.62 +G_DEFINE_TYPE ( GMythScheduler, gmyth_scheduler, G_TYPE_OBJECT )
35.63 + static void gmyth_scheduler_class_init ( GMythSchedulerClass * klass )
35.64 {
35.65 GObjectClass *gobject_class;
35.66
35.67 - gobject_class = (GObjectClass *) klass;
35.68 + gobject_class = ( GObjectClass * ) klass;
35.69
35.70 gobject_class->dispose = gmyth_scheduler_dispose;
35.71 gobject_class->finalize = gmyth_scheduler_finalize;
35.72 }
35.73
35.74 static void
35.75 -gmyth_scheduler_init (GMythScheduler * sched)
35.76 +gmyth_scheduler_init ( GMythScheduler * sched )
35.77 {
35.78 sched->recordid = 0;
35.79 sched->type = 0;
35.80 sched->search = 0;
35.81 - sched->profile = g_string_new ("");
35.82 + sched->profile = g_string_new ( "" );
35.83
35.84 sched->dupin = 0;
35.85 sched->dupmethod = 0;
35.86 @@ -86,48 +85,50 @@
35.87 sched->maxnewest = 0;
35.88
35.89 sched->recpriority = 0;
35.90 - sched->recgroup = g_string_new ("");
35.91 - sched->playgroup = g_string_new ("");
35.92 + sched->recgroup = g_string_new ( "" );
35.93 + sched->playgroup = g_string_new ( "" );
35.94
35.95 sched->prefinput = 0;
35.96 sched->inactive = 0;
35.97
35.98 - sched->search_type = g_string_new ("");
35.99 - sched->search_what = g_string_new ("");
35.100 + sched->search_type = g_string_new ( "" );
35.101 + sched->search_what = g_string_new ( "" );
35.102
35.103 - sched->msqlquery = gmyth_query_new ();
35.104 + sched->msqlquery = gmyth_query_new ( );
35.105 }
35.106
35.107 static void
35.108 -gmyth_scheduler_dispose (GObject * object)
35.109 +gmyth_scheduler_dispose ( GObject * object )
35.110 {
35.111 - GMythScheduler *scheduler = GMYTH_SCHEDULER (object);
35.112 + GMythScheduler *scheduler = GMYTH_SCHEDULER ( object );
35.113
35.114 - if (scheduler->backend_info) {
35.115 - g_object_unref (scheduler->backend_info);
35.116 + if ( scheduler->backend_info )
35.117 + {
35.118 + g_object_unref ( scheduler->backend_info );
35.119 scheduler->backend_info = NULL;
35.120 }
35.121
35.122 - if (scheduler->msqlquery) {
35.123 - g_object_unref (scheduler->msqlquery);
35.124 + if ( scheduler->msqlquery )
35.125 + {
35.126 + g_object_unref ( scheduler->msqlquery );
35.127 scheduler->msqlquery = NULL;
35.128 }
35.129
35.130 - g_string_free (scheduler->profile, TRUE);
35.131 - g_string_free (scheduler->recgroup, TRUE);
35.132 - g_string_free (scheduler->playgroup, TRUE);
35.133 - g_string_free (scheduler->search_type, TRUE);
35.134 - g_string_free (scheduler->search_what, TRUE);
35.135 + g_string_free ( scheduler->profile, TRUE );
35.136 + g_string_free ( scheduler->recgroup, TRUE );
35.137 + g_string_free ( scheduler->playgroup, TRUE );
35.138 + g_string_free ( scheduler->search_type, TRUE );
35.139 + g_string_free ( scheduler->search_what, TRUE );
35.140
35.141 - G_OBJECT_CLASS (gmyth_scheduler_parent_class)->dispose (object);
35.142 + G_OBJECT_CLASS ( gmyth_scheduler_parent_class )->dispose ( object );
35.143 }
35.144
35.145 static void
35.146 -gmyth_scheduler_finalize (GObject * object)
35.147 +gmyth_scheduler_finalize ( GObject * object )
35.148 {
35.149 - g_signal_handlers_destroy (object);
35.150 + g_signal_handlers_destroy ( object );
35.151
35.152 - G_OBJECT_CLASS (gmyth_scheduler_parent_class)->finalize (object);
35.153 + G_OBJECT_CLASS ( gmyth_scheduler_parent_class )->finalize ( object );
35.154 }
35.155
35.156 /** Creates a new instance of GMythScheduler.
35.157 @@ -135,19 +136,19 @@
35.158 * @return a new instance of GMythScheduler.
35.159 */
35.160 GMythScheduler *
35.161 -gmyth_scheduler_new ()
35.162 +gmyth_scheduler_new ( )
35.163 {
35.164 GMythScheduler *scheduler =
35.165 - GMYTH_SCHEDULER (g_object_new (GMYTH_SCHEDULER_TYPE, NULL));
35.166 + GMYTH_SCHEDULER ( g_object_new ( GMYTH_SCHEDULER_TYPE, NULL ) );
35.167
35.168 return scheduler;
35.169 }
35.170
35.171 gboolean
35.172 -gmyth_scheduler_connect (GMythScheduler * scheduler,
35.173 - GMythBackendInfo * backend_info)
35.174 +gmyth_scheduler_connect ( GMythScheduler * scheduler,
35.175 + GMythBackendInfo * backend_info )
35.176 {
35.177 - return gmyth_scheduler_connect_with_timeout (scheduler, backend_info, 0);
35.178 + return gmyth_scheduler_connect_with_timeout ( scheduler, backend_info, 0 );
35.179 }
35.180
35.181 /** Connects to the Mysql database in the backend. The backend address
35.182 @@ -157,25 +158,29 @@
35.183 * @return true if connection was success, false if failed.
35.184 */
35.185 gboolean
35.186 -gmyth_scheduler_connect_with_timeout (GMythScheduler * scheduler,
35.187 - GMythBackendInfo * backend_info, guint timeout)
35.188 +gmyth_scheduler_connect_with_timeout ( GMythScheduler * scheduler,
35.189 + GMythBackendInfo * backend_info,
35.190 + guint timeout )
35.191 {
35.192 - assert (scheduler);
35.193 - g_return_val_if_fail (backend_info != NULL, FALSE);
35.194 + assert ( scheduler );
35.195 + g_return_val_if_fail ( backend_info != NULL, FALSE );
35.196
35.197 - if (scheduler->backend_info)
35.198 - g_object_unref (scheduler->backend_info);
35.199 + if ( scheduler->backend_info )
35.200 + g_object_unref ( scheduler->backend_info );
35.201
35.202 - scheduler->backend_info = g_object_ref (backend_info);
35.203 + scheduler->backend_info = g_object_ref ( backend_info );
35.204
35.205 - if (scheduler->msqlquery == NULL) {
35.206 - g_warning ("[%s] GMythScheduler db initializing", __FUNCTION__);
35.207 - scheduler->msqlquery = gmyth_query_new ();
35.208 + if ( scheduler->msqlquery == NULL )
35.209 + {
35.210 + g_warning ( "[%s] GMythScheduler db initializing", __FUNCTION__ );
35.211 + scheduler->msqlquery = gmyth_query_new ( );
35.212 }
35.213
35.214 - if (!gmyth_query_connect_with_timeout (scheduler->msqlquery,
35.215 - scheduler->backend_info, timeout)) {
35.216 - g_warning ("[%s] Error while connecting to db", __FUNCTION__);
35.217 + if ( !gmyth_query_connect_with_timeout ( scheduler->msqlquery,
35.218 + scheduler->backend_info,
35.219 + timeout ) )
35.220 + {
35.221 + g_warning ( "[%s] Error while connecting to db", __FUNCTION__ );
35.222 return FALSE;
35.223 }
35.224
35.225 @@ -188,12 +193,13 @@
35.226 * @return true if disconnection was success, false if failed.
35.227 */
35.228 gboolean
35.229 -gmyth_scheduler_disconnect (GMythScheduler * scheduler)
35.230 +gmyth_scheduler_disconnect ( GMythScheduler * scheduler )
35.231 {
35.232 - assert (scheduler);
35.233 + assert ( scheduler );
35.234
35.235 - if (scheduler->msqlquery != NULL) {
35.236 - gmyth_query_disconnect (scheduler->msqlquery);
35.237 + if ( scheduler->msqlquery != NULL )
35.238 + {
35.239 + gmyth_query_disconnect ( scheduler->msqlquery );
35.240 }
35.241
35.242 return TRUE;
35.243 @@ -206,66 +212,74 @@
35.244 * @return The amount of schedules retrieved from database, or -1 if error.
35.245 */
35.246 gint
35.247 -gmyth_scheduler_get_schedule_list (GMythScheduler * scheduler,
35.248 - GList ** schedule_list)
35.249 +gmyth_scheduler_get_schedule_list ( GMythScheduler * scheduler,
35.250 + GList ** schedule_list )
35.251 {
35.252 ScheduleInfo *schedule;
35.253 MYSQL_RES *msql_res;
35.254 - GString *query_str = g_string_new ("");
35.255 + GString *query_str = g_string_new ( "" );
35.256 gchar *date_time = NULL;
35.257
35.258 - assert (scheduler);
35.259 + assert ( scheduler );
35.260
35.261 - g_string_printf (query_str,
35.262 - "SELECT recordid,programid,chanid,starttime,startdate,"
35.263 - "endtime,enddate,title,subtitle,description,category FROM record;");
35.264 + g_string_printf ( query_str,
35.265 + "SELECT recordid,programid,chanid,starttime,startdate,"
35.266 + "endtime,enddate,title,subtitle,description,category FROM record;" );
35.267
35.268 - if (scheduler->msqlquery == NULL) {
35.269 - g_warning ("[%s] Scheduler db connection not initialized",
35.270 - __FUNCTION__);
35.271 + if ( scheduler->msqlquery == NULL )
35.272 + {
35.273 + g_warning ( "[%s] Scheduler db connection not initialized",
35.274 + __FUNCTION__ );
35.275 return -1;
35.276 }
35.277 msql_res =
35.278 - gmyth_query_process_statement (scheduler->msqlquery, query_str->str);
35.279 + gmyth_query_process_statement ( scheduler->msqlquery, query_str->str );
35.280
35.281 - if (msql_res == NULL) {
35.282 - g_warning ("DB retrieval of schedule list failed");
35.283 + if ( msql_res == NULL )
35.284 + {
35.285 + g_warning ( "DB retrieval of schedule list failed" );
35.286 return -1;
35.287 - } else {
35.288 + }
35.289 + else
35.290 + {
35.291 MYSQL_ROW row;
35.292
35.293 *schedule_list = NULL;
35.294
35.295 - while ((row = mysql_fetch_row (msql_res)) != NULL) {
35.296 - schedule = g_new0 (ScheduleInfo, 1);
35.297 + while ( ( row = mysql_fetch_row ( msql_res ) ) != NULL )
35.298 + {
35.299 + schedule = g_new0 ( ScheduleInfo, 1 );
35.300
35.301 - schedule->schedule_id = (guint) g_ascii_strtoull (row[0], NULL, 10);
35.302 - schedule->program_id = (guint) g_ascii_strtoull (row[1], NULL, 10);
35.303 - schedule->channel_id = (guint) g_ascii_strtoull (row[2], NULL, 10);
35.304 + schedule->schedule_id =
35.305 + ( guint ) g_ascii_strtoull ( row[0], NULL, 10 );
35.306 + schedule->program_id =
35.307 + ( guint ) g_ascii_strtoull ( row[1], NULL, 10 );
35.308 + schedule->channel_id =
35.309 + ( guint ) g_ascii_strtoull ( row[2], NULL, 10 );
35.310
35.311 /* generate a time_t from a time and a date db field */
35.312 - date_time = g_strdup_printf ("%sT%s", row[4], row[3]);
35.313 - schedule->start_time = gmyth_util_string_to_time_val (date_time);
35.314 - g_free (date_time);
35.315 + date_time = g_strdup_printf ( "%sT%s", row[4], row[3] );
35.316 + schedule->start_time = gmyth_util_string_to_time_val ( date_time );
35.317 + g_free ( date_time );
35.318
35.319 /* generate a time_t from a time and a date db field */
35.320 - date_time = g_strdup_printf ("%sT%s", row[6], row[5]);
35.321 - schedule->end_time = gmyth_util_string_to_time_val (date_time);
35.322 - g_free (date_time);
35.323 + date_time = g_strdup_printf ( "%sT%s", row[6], row[5] );
35.324 + schedule->end_time = gmyth_util_string_to_time_val ( date_time );
35.325 + g_free ( date_time );
35.326
35.327 - schedule->title = g_string_new (row[7]);
35.328 - schedule->subtitle = g_string_new (row[8]);
35.329 - schedule->description = g_string_new (row[9]);
35.330 - schedule->category = g_string_new (row[10]);
35.331 + schedule->title = g_string_new ( row[7] );
35.332 + schedule->subtitle = g_string_new ( row[8] );
35.333 + schedule->description = g_string_new ( row[9] );
35.334 + schedule->category = g_string_new ( row[10] );
35.335
35.336 - (*schedule_list) = g_list_append (*(schedule_list), schedule);
35.337 + ( *schedule_list ) = g_list_append ( *( schedule_list ), schedule );
35.338 }
35.339 }
35.340
35.341 - mysql_free_result (msql_res);
35.342 - g_string_free (query_str, TRUE);
35.343 + mysql_free_result ( msql_res );
35.344 + g_string_free ( query_str, TRUE );
35.345
35.346 - return (*schedule_list == NULL) ? 0 : g_list_length (*schedule_list);
35.347 + return ( *schedule_list == NULL ) ? 0 : g_list_length ( *schedule_list );
35.348 }
35.349
35.350 /** Retrieves from the backend Mysql database the list of recorded programs.
35.351 @@ -275,83 +289,90 @@
35.352 * @return The amount of recorded retrieved from database, or -1 if error.
35.353 */
35.354 gint
35.355 -gmyth_scheduler_get_recorded_list (GMythScheduler * scheduler,
35.356 - GList ** recorded_list)
35.357 +gmyth_scheduler_get_recorded_list ( GMythScheduler * scheduler,
35.358 + GList ** recorded_list )
35.359 {
35.360 RecordedInfo *record;
35.361 MYSQL_RES *msql_res;
35.362 - GString *query_str = g_string_new ("");
35.363 + GString *query_str = g_string_new ( "" );
35.364
35.365 - assert (scheduler);
35.366 + assert ( scheduler );
35.367
35.368 - g_string_printf (query_str,
35.369 - "SELECT recordid,programid,chanid,starttime,progstart,"
35.370 - "endtime,progend,title,subtitle,description,category,"
35.371 - "filesize,basename FROM recorded WHERE recgroup != 'LiveTV'");
35.372 + g_string_printf ( query_str,
35.373 + "SELECT recordid,programid,chanid,starttime,progstart,"
35.374 + "endtime,progend,title,subtitle,description,category,"
35.375 + "filesize,basename FROM recorded WHERE recgroup != 'LiveTV'" );
35.376
35.377 - if (scheduler->msqlquery == NULL) {
35.378 - g_warning ("[%s] Scheduler db connection not initialized",
35.379 - __FUNCTION__);
35.380 + if ( scheduler->msqlquery == NULL )
35.381 + {
35.382 + g_warning ( "[%s] Scheduler db connection not initialized",
35.383 + __FUNCTION__ );
35.384 return -1;
35.385 }
35.386
35.387 msql_res =
35.388 - gmyth_query_process_statement (scheduler->msqlquery, query_str->str);
35.389 + gmyth_query_process_statement ( scheduler->msqlquery, query_str->str );
35.390
35.391 - if (msql_res == NULL) {
35.392 - g_warning ("DB retrieval of recording list failed");
35.393 + if ( msql_res == NULL )
35.394 + {
35.395 + g_warning ( "DB retrieval of recording list failed" );
35.396 return -1;
35.397 - } else {
35.398 + }
35.399 + else
35.400 + {
35.401 MYSQL_ROW row;
35.402
35.403 - (*recorded_list) = NULL;
35.404 + ( *recorded_list ) = NULL;
35.405
35.406 - while ((row = mysql_fetch_row (msql_res)) != NULL) {
35.407 - record = g_new0 (RecordedInfo, 1);
35.408 + while ( ( row = mysql_fetch_row ( msql_res ) ) != NULL )
35.409 + {
35.410 + record = g_new0 ( RecordedInfo, 1 );
35.411
35.412 - record->record_id = (guint) g_ascii_strtoull (row[0], NULL, 10);
35.413 - record->program_id = (guint) g_ascii_strtoull (row[1], NULL, 10);
35.414 - record->channel_id = (guint) g_ascii_strtoull (row[2], NULL, 10);
35.415 + record->record_id = ( guint ) g_ascii_strtoull ( row[0], NULL, 10 );
35.416 + record->program_id =
35.417 + ( guint ) g_ascii_strtoull ( row[1], NULL, 10 );
35.418 + record->channel_id =
35.419 + ( guint ) g_ascii_strtoull ( row[2], NULL, 10 );
35.420
35.421 - record->start_time = gmyth_util_string_to_time_val (row[3]);
35.422 - record->end_time = gmyth_util_string_to_time_val (row[5]);
35.423 + record->start_time = gmyth_util_string_to_time_val ( row[3] );
35.424 + record->end_time = gmyth_util_string_to_time_val ( row[5] );
35.425
35.426 - record->title = g_string_new (row[7]);
35.427 - record->subtitle = g_string_new (row[8]);
35.428 - record->description = g_string_new (row[9]);
35.429 - record->category = g_string_new (row[10]);
35.430 - record->filesize = g_ascii_strtoull (row[11], NULL, 10);
35.431 - record->basename = g_string_new (row[12]);
35.432 + record->title = g_string_new ( row[7] );
35.433 + record->subtitle = g_string_new ( row[8] );
35.434 + record->description = g_string_new ( row[9] );
35.435 + record->category = g_string_new ( row[10] );
35.436 + record->filesize = g_ascii_strtoull ( row[11], NULL, 10 );
35.437 + record->basename = g_string_new ( row[12] );
35.438
35.439 - (*recorded_list) = g_list_append ((*recorded_list), record);
35.440 + ( *recorded_list ) = g_list_append ( ( *recorded_list ), record );
35.441 }
35.442 }
35.443
35.444 - mysql_free_result (msql_res);
35.445 - g_string_free (query_str, TRUE);
35.446 + mysql_free_result ( msql_res );
35.447 + g_string_free ( query_str, TRUE );
35.448
35.449 - return (*recorded_list == NULL) ? 0 : g_list_length (*recorded_list);
35.450 + return ( *recorded_list == NULL ) ? 0 : g_list_length ( *recorded_list );
35.451 }
35.452
35.453 static void
35.454 -_set_value (GMythQuery * myth_query, char *field, gchar * value, gint rec_id)
35.455 +_set_value ( GMythQuery * myth_query, char *field, gchar * value, gint rec_id )
35.456 {
35.457 gchar *query =
35.458 g_strdup_printf
35.459 - ("UPDATE record SET recordid = %d, %s = \"%s\" WHERE recordid = %d;",
35.460 - rec_id, field, value, rec_id);
35.461 + ( "UPDATE record SET recordid = %d, %s = \"%s\" WHERE recordid = %d;",
35.462 + rec_id, field, value, rec_id );
35.463
35.464 - gmyth_query_process_statement (myth_query, query);
35.465 - g_free (query);
35.466 + gmyth_query_process_statement ( myth_query, query );
35.467 + g_free ( query );
35.468 }
35.469
35.470 static void
35.471 -_set_int_value (GMythQuery * myth_query, char *field, gint value, gint rec_id)
35.472 +_set_int_value ( GMythQuery * myth_query, char *field, gint value, gint rec_id )
35.473 {
35.474 - gchar *str_value = g_strdup_printf ("%d", value);
35.475 + gchar *str_value = g_strdup_printf ( "%d", value );
35.476
35.477 - _set_value (myth_query, field, str_value, rec_id);
35.478 - g_free (str_value);
35.479 + _set_value ( myth_query, field, str_value, rec_id );
35.480 + g_free ( str_value );
35.481 }
35.482
35.483 /** Requests the Mysql database in the backend to add a new schedule.
35.484 @@ -363,97 +384,105 @@
35.485 * @return gboolean returns FALSE if some error occurs, TRUE otherwise
35.486 */
35.487 gboolean
35.488 -gmyth_scheduler_add_schedule (GMythScheduler * scheduler,
35.489 - ScheduleInfo * schedule_info)
35.490 +gmyth_scheduler_add_schedule ( GMythScheduler * scheduler,
35.491 + ScheduleInfo * schedule_info )
35.492 {
35.493 MYSQL_RES *msql_res;
35.494 gchar *query_str = "INSERT record (recordid) VALUE (0);";
35.495 gchar *station = NULL;
35.496 gulong rec_id;
35.497
35.498 - assert (scheduler);
35.499 + assert ( scheduler );
35.500
35.501 - if (scheduler->msqlquery == NULL) {
35.502 - g_warning ("[%s] Scheduler db connection not initialized",
35.503 - __FUNCTION__);
35.504 + if ( scheduler->msqlquery == NULL )
35.505 + {
35.506 + g_warning ( "[%s] Scheduler db connection not initialized",
35.507 + __FUNCTION__ );
35.508 return FALSE;
35.509 }
35.510
35.511 msql_res =
35.512 - gmyth_query_process_statement_with_increment (scheduler->msqlquery,
35.513 - query_str, &rec_id);
35.514 - mysql_free_result (msql_res);
35.515 + gmyth_query_process_statement_with_increment ( scheduler->msqlquery,
35.516 + query_str, &rec_id );
35.517 + mysql_free_result ( msql_res );
35.518
35.519 // Retrieves the station info
35.520 query_str =
35.521 - g_strdup_printf ("SELECT callsign FROM channel WHERE chanid = \"%d\";",
35.522 - schedule_info->channel_id);
35.523 - msql_res = gmyth_query_process_statement (scheduler->msqlquery, query_str);
35.524 - if (msql_res == NULL) {
35.525 - g_warning ("[%s] msql query returned NULL MYSQL_RES", __FUNCTION__);
35.526 + g_strdup_printf ( "SELECT callsign FROM channel WHERE chanid = \"%d\";",
35.527 + schedule_info->channel_id );
35.528 + msql_res =
35.529 + gmyth_query_process_statement ( scheduler->msqlquery, query_str );
35.530 + if ( msql_res == NULL )
35.531 + {
35.532 + g_warning ( "[%s] msql query returned NULL MYSQL_RES", __FUNCTION__ );
35.533 return FALSE;
35.534 - } else {
35.535 + }
35.536 + else
35.537 + {
35.538 MYSQL_ROW row;
35.539
35.540 - if ((row = mysql_fetch_row (msql_res)) != NULL) {
35.541 - station = g_strdup (row[0]);
35.542 + if ( ( row = mysql_fetch_row ( msql_res ) ) != NULL )
35.543 + {
35.544 + station = g_strdup ( row[0] );
35.545 }
35.546 }
35.547 - mysql_free_result (msql_res);
35.548 - g_free (query_str);
35.549 + mysql_free_result ( msql_res );
35.550 + g_free ( query_str );
35.551
35.552 // _set_value (field, value, id);
35.553 - _set_int_value (scheduler->msqlquery, "chanid", schedule_info->channel_id,
35.554 - rec_id);
35.555 - _set_value (scheduler->msqlquery, "station", station, rec_id);
35.556 - _set_value (scheduler->msqlquery, "title", schedule_info->title->str,
35.557 - rec_id);
35.558 + _set_int_value ( scheduler->msqlquery, "chanid", schedule_info->channel_id,
35.559 + rec_id );
35.560 + _set_value ( scheduler->msqlquery, "station", station, rec_id );
35.561 + _set_value ( scheduler->msqlquery, "title", schedule_info->title->str,
35.562 + rec_id );
35.563 /// subtitle, description
35.564 - _set_value (scheduler->msqlquery, "starttime",
35.565 - gmyth_util_time_to_string_only_time (schedule_info->
35.566 - start_time), rec_id);
35.567 - _set_value (scheduler->msqlquery, "startdate",
35.568 - gmyth_util_time_to_string_only_date (schedule_info->
35.569 - start_time), rec_id);
35.570 - _set_value (scheduler->msqlquery, "endtime",
35.571 - gmyth_util_time_to_string_only_time (schedule_info->end_time), rec_id);
35.572 - _set_value (scheduler->msqlquery, "enddate",
35.573 - gmyth_util_time_to_string_only_date (schedule_info->end_time), rec_id);
35.574 + _set_value ( scheduler->msqlquery, "starttime",
35.575 + gmyth_util_time_to_string_only_time ( schedule_info->
35.576 + start_time ), rec_id );
35.577 + _set_value ( scheduler->msqlquery, "startdate",
35.578 + gmyth_util_time_to_string_only_date ( schedule_info->
35.579 + start_time ), rec_id );
35.580 + _set_value ( scheduler->msqlquery, "endtime",
35.581 + gmyth_util_time_to_string_only_time ( schedule_info->
35.582 + end_time ), rec_id );
35.583 + _set_value ( scheduler->msqlquery, "enddate",
35.584 + gmyth_util_time_to_string_only_date ( schedule_info->
35.585 + end_time ), rec_id );
35.586 /// category, series id, program id
35.587 //_set_value (scheduler->msqlquery, "findday", (gmyth_util_time_val_to_date( schedule_info->start_time ))->tm_wday, rec_id);
35.588 //_set_value (scheduler->msqlquery, "findtime", gmyth_util_time_to_string_only_time( schedule_info->start_time), rec_id);
35.589 //_set_int_value (scheduler->msqlquery, "findid", (gint)(schedule_info->start_time->tv_sec/60/60/24 + 719528), rec_id);
35.590 - _set_value (scheduler->msqlquery, "parentid", "0", rec_id);
35.591 - _set_value (scheduler->msqlquery, "search", "0", rec_id);
35.592 - _set_value (scheduler->msqlquery, "type", "1", rec_id);
35.593 - _set_value (scheduler->msqlquery, "recpriority", "0", rec_id);
35.594 - _set_value (scheduler->msqlquery, "startoffset", "0", rec_id);
35.595 - _set_value (scheduler->msqlquery, "endoffset", "0", rec_id);
35.596 - _set_value (scheduler->msqlquery, "dupmethod", "6", rec_id); // ?
35.597 - _set_value (scheduler->msqlquery, "dupin", "15", rec_id); // ?
35.598 + _set_value ( scheduler->msqlquery, "parentid", "0", rec_id );
35.599 + _set_value ( scheduler->msqlquery, "search", "0", rec_id );
35.600 + _set_value ( scheduler->msqlquery, "type", "1", rec_id );
35.601 + _set_value ( scheduler->msqlquery, "recpriority", "0", rec_id );
35.602 + _set_value ( scheduler->msqlquery, "startoffset", "0", rec_id );
35.603 + _set_value ( scheduler->msqlquery, "endoffset", "0", rec_id );
35.604 + _set_value ( scheduler->msqlquery, "dupmethod", "6", rec_id ); // ?
35.605 + _set_value ( scheduler->msqlquery, "dupin", "15", rec_id ); // ?
35.606
35.607 - _set_value (scheduler->msqlquery, "prefinput", "0", rec_id);
35.608 - _set_value (scheduler->msqlquery, "inactive", "0", rec_id);
35.609 - _set_value (scheduler->msqlquery, "profile", "Default", rec_id);
35.610 - _set_value (scheduler->msqlquery, "recgroup", "Default", rec_id);
35.611 - _set_value (scheduler->msqlquery, "storagegroup", "Default", rec_id);
35.612 - _set_value (scheduler->msqlquery, "playgroup", "Default", rec_id);
35.613 - _set_value (scheduler->msqlquery, "autoexpire", "1", rec_id);
35.614 - _set_value (scheduler->msqlquery, "maxepisodes", "0", rec_id);
35.615 - _set_value (scheduler->msqlquery, "maxnewest", "0", rec_id);
35.616 - _set_value (scheduler->msqlquery, "autocommflag", "1", rec_id);
35.617 - _set_value (scheduler->msqlquery, "autotranscode", "0", rec_id);
35.618 - _set_value (scheduler->msqlquery, "transcoder", "0", rec_id);
35.619 + _set_value ( scheduler->msqlquery, "prefinput", "0", rec_id );
35.620 + _set_value ( scheduler->msqlquery, "inactive", "0", rec_id );
35.621 + _set_value ( scheduler->msqlquery, "profile", "Default", rec_id );
35.622 + _set_value ( scheduler->msqlquery, "recgroup", "Default", rec_id );
35.623 + _set_value ( scheduler->msqlquery, "storagegroup", "Default", rec_id );
35.624 + _set_value ( scheduler->msqlquery, "playgroup", "Default", rec_id );
35.625 + _set_value ( scheduler->msqlquery, "autoexpire", "1", rec_id );
35.626 + _set_value ( scheduler->msqlquery, "maxepisodes", "0", rec_id );
35.627 + _set_value ( scheduler->msqlquery, "maxnewest", "0", rec_id );
35.628 + _set_value ( scheduler->msqlquery, "autocommflag", "1", rec_id );
35.629 + _set_value ( scheduler->msqlquery, "autotranscode", "0", rec_id );
35.630 + _set_value ( scheduler->msqlquery, "transcoder", "0", rec_id );
35.631
35.632 - _set_value (scheduler->msqlquery, "autouserjob1", "0", rec_id);
35.633 - _set_value (scheduler->msqlquery, "autouserjob2", "0", rec_id);
35.634 - _set_value (scheduler->msqlquery, "autouserjob3", "0", rec_id);
35.635 - _set_value (scheduler->msqlquery, "autouserjob4", "0", rec_id);
35.636 + _set_value ( scheduler->msqlquery, "autouserjob1", "0", rec_id );
35.637 + _set_value ( scheduler->msqlquery, "autouserjob2", "0", rec_id );
35.638 + _set_value ( scheduler->msqlquery, "autouserjob3", "0", rec_id );
35.639 + _set_value ( scheduler->msqlquery, "autouserjob4", "0", rec_id );
35.640
35.641 schedule_info->schedule_id = rec_id;
35.642
35.643 /* Notify the backend of changes */
35.644 - return update_backend (scheduler, rec_id);
35.645 + return update_backend ( scheduler, rec_id );
35.646 }
35.647
35.648 /** Requests the Mysql database in the backend to remove an existing schedule.
35.649 @@ -463,32 +492,33 @@
35.650 * @return gboolean TRUE if success, FALSE if error
35.651 */
35.652 gboolean
35.653 -gmyth_scheduler_delete_schedule (GMythScheduler * scheduler, gint record_id)
35.654 +gmyth_scheduler_delete_schedule ( GMythScheduler * scheduler, gint record_id )
35.655 {
35.656
35.657 MYSQL_RES *msql_res;
35.658 - GString *query_str = g_string_new ("");
35.659 + GString *query_str = g_string_new ( "" );
35.660
35.661 - assert (scheduler);
35.662 + assert ( scheduler );
35.663
35.664 - if (scheduler->msqlquery == NULL) {
35.665 - g_warning ("[%s] Scheduler db connection not initialized",
35.666 - __FUNCTION__);
35.667 + if ( scheduler->msqlquery == NULL )
35.668 + {
35.669 + g_warning ( "[%s] Scheduler db connection not initialized",
35.670 + __FUNCTION__ );
35.671 return FALSE;
35.672 }
35.673 //========================================
35.674 - g_string_printf (query_str,
35.675 - "DELETE FROM record WHERE recordid=%d", record_id);
35.676 + g_string_printf ( query_str,
35.677 + "DELETE FROM record WHERE recordid=%d", record_id );
35.678
35.679 msql_res =
35.680 - gmyth_query_process_statement (scheduler->msqlquery, query_str->str);
35.681 + gmyth_query_process_statement ( scheduler->msqlquery, query_str->str );
35.682
35.683
35.684 - mysql_free_result (msql_res);
35.685 - g_string_free (query_str, TRUE);
35.686 + mysql_free_result ( msql_res );
35.687 + g_string_free ( query_str, TRUE );
35.688
35.689 // Notify the backend of the changes
35.690 - return update_backend (scheduler, record_id);
35.691 + return update_backend ( scheduler, record_id );
35.692 }
35.693
35.694 /** Requests the Mysql database in the backend to remove an existing recorded item.
35.695 @@ -498,34 +528,35 @@
35.696 * @return gboolean TRUE if success, FALSE if error
35.697 */
35.698 gboolean
35.699 -gmyth_scheduler_delete_recorded (GMythScheduler * scheduler, gint record_id)
35.700 +gmyth_scheduler_delete_recorded ( GMythScheduler * scheduler, gint record_id )
35.701 {
35.702
35.703 MYSQL_RES *msql_res;
35.704
35.705 - GString *query_str = g_string_new ("");
35.706 + GString *query_str = g_string_new ( "" );
35.707
35.708 - assert (scheduler);
35.709 + assert ( scheduler );
35.710
35.711 - if (scheduler->msqlquery == NULL) {
35.712 - g_warning ("[%s] Scheduler db connection not initialized",
35.713 - __FUNCTION__);
35.714 + if ( scheduler->msqlquery == NULL )
35.715 + {
35.716 + g_warning ( "[%s] Scheduler db connection not initialized",
35.717 + __FUNCTION__ );
35.718 return FALSE;
35.719 }
35.720 //========================================
35.721 - g_string_printf (query_str,
35.722 - "DELETE FROM recorded WHERE recordid=%d", record_id);
35.723 + g_string_printf ( query_str,
35.724 + "DELETE FROM recorded WHERE recordid=%d", record_id );
35.725
35.726 // FIXME: Mythtv implementation runs also: DELETE FROM oldfind WHERE recordid = x
35.727
35.728 msql_res =
35.729 - gmyth_query_process_statement (scheduler->msqlquery, query_str->str);
35.730 + gmyth_query_process_statement ( scheduler->msqlquery, query_str->str );
35.731
35.732 - mysql_free_result (msql_res);
35.733 - g_string_free (query_str, TRUE);
35.734 + mysql_free_result ( msql_res );
35.735 + g_string_free ( query_str, TRUE );
35.736
35.737 // Notify the backend of the changes
35.738 - return update_backend (scheduler, record_id);
35.739 + return update_backend ( scheduler, record_id );
35.740 }
35.741
35.742 /** Retrieves an existing recorded item information from database. The information
35.743 @@ -538,101 +569,109 @@
35.744 * information, or NULL if error.
35.745 */
35.746 GMythProgramInfo *
35.747 -gmyth_scheduler_get_recorded (GMythScheduler * scheduler,
35.748 - GString * channel, GTimeVal * starttime)
35.749 +gmyth_scheduler_get_recorded ( GMythScheduler * scheduler,
35.750 + GString * channel, GTimeVal * starttime )
35.751 {
35.752 MYSQL_RES *msql_res;
35.753 GMythProgramInfo *proginfo = NULL;
35.754 - GString *query_str = g_string_new ("");
35.755 - gchar *time_str = gmyth_util_time_to_string_from_time_val (starttime);
35.756 + GString *query_str = g_string_new ( "" );
35.757 + gchar *time_str = gmyth_util_time_to_string_from_time_val ( starttime );
35.758
35.759 - assert (scheduler);
35.760 + assert ( scheduler );
35.761
35.762 - gmyth_debug ("[%s] channel: %s", __FUNCTION__, channel->str);
35.763 + gmyth_debug ( "[%s] channel: %s", __FUNCTION__, channel->str );
35.764
35.765 - if (scheduler->msqlquery == NULL) {
35.766 - g_warning ("[%s] Scheduler db connection not initialized",
35.767 - __FUNCTION__);
35.768 + if ( scheduler->msqlquery == NULL )
35.769 + {
35.770 + g_warning ( "[%s] Scheduler db connection not initialized",
35.771 + __FUNCTION__ );
35.772 return NULL;
35.773 }
35.774
35.775 - g_string_printf (query_str,
35.776 - "SELECT recorded.chanid,starttime,endtime,title, "
35.777 - "subtitle,description,channel.channum, "
35.778 - "channel.callsign,channel.name,channel.commfree, "
35.779 - "channel.outputfilters,seriesid,programid,filesize, "
35.780 - "lastmodified,stars,previouslyshown,originalairdate, "
35.781 - "hostname,recordid,transcoder,playgroup, "
35.782 - "recorded.recpriority,progstart,progend,basename,recgroup "
35.783 - "FROM recorded " "LEFT JOIN channel "
35.784 - "ON recorded.chanid = channel.chanid "
35.785 - "WHERE recorded.chanid = \"%s\" "
35.786 - "AND starttime = \"%s\" ;", channel->str, time_str);
35.787 + g_string_printf ( query_str,
35.788 + "SELECT recorded.chanid,starttime,endtime,title, "
35.789 + "subtitle,description,channel.channum, "
35.790 + "channel.callsign,channel.name,channel.commfree, "
35.791 + "channel.outputfilters,seriesid,programid,filesize, "
35.792 + "lastmodified,stars,previouslyshown,originalairdate, "
35.793 + "hostname,recordid,transcoder,playgroup, "
35.794 + "recorded.recpriority,progstart,progend,basename,recgroup "
35.795 + "FROM recorded " "LEFT JOIN channel "
35.796 + "ON recorded.chanid = channel.chanid "
35.797 + "WHERE recorded.chanid = \"%s\" "
35.798 + "AND starttime = \"%s\" ;", channel->str, time_str );
35.799
35.800 msql_res =
35.801 - gmyth_query_process_statement (scheduler->msqlquery, query_str->str);
35.802 + gmyth_query_process_statement ( scheduler->msqlquery, query_str->str );
35.803
35.804 - if (msql_res /*&& query.size() > 0 */ ) {
35.805 - MYSQL_ROW msql_row = mysql_fetch_row (msql_res);
35.806 + if ( msql_res /*&& query.size() > 0 */ )
35.807 + {
35.808 + MYSQL_ROW msql_row = mysql_fetch_row ( msql_res );
35.809
35.810 - if (msql_row) {
35.811 - proginfo = gmyth_program_info_new ();
35.812 + if ( msql_row )
35.813 + {
35.814 + proginfo = gmyth_program_info_new ( );
35.815
35.816 - proginfo->chanid = g_string_new (msql_row[0]);
35.817 - proginfo->startts = gmyth_util_string_to_time_val (msql_row[23]);
35.818 - proginfo->endts = gmyth_util_string_to_time_val (msql_row[24]);
35.819 - proginfo->recstartts = gmyth_util_string_to_time_val (msql_row[1]);
35.820 - proginfo->recendts = gmyth_util_string_to_time_val (msql_row[2]);
35.821 - proginfo->title = g_string_new (msql_row[3]);
35.822 - proginfo->subtitle = g_string_new (msql_row[4]);
35.823 - proginfo->description = g_string_new (msql_row[5]);
35.824 + proginfo->chanid = g_string_new ( msql_row[0] );
35.825 + proginfo->startts = gmyth_util_string_to_time_val ( msql_row[23] );
35.826 + proginfo->endts = gmyth_util_string_to_time_val ( msql_row[24] );
35.827 + proginfo->recstartts =
35.828 + gmyth_util_string_to_time_val ( msql_row[1] );
35.829 + proginfo->recendts = gmyth_util_string_to_time_val ( msql_row[2] );
35.830 + proginfo->title = g_string_new ( msql_row[3] );
35.831 + proginfo->subtitle = g_string_new ( msql_row[4] );
35.832 + proginfo->description = g_string_new ( msql_row[5] );
35.833
35.834 - proginfo->chanstr = g_string_new (msql_row[6]);
35.835 - proginfo->chansign = g_string_new (msql_row[7]);
35.836 - proginfo->channame = g_string_new (msql_row[0]);
35.837 + proginfo->chanstr = g_string_new ( msql_row[6] );
35.838 + proginfo->chansign = g_string_new ( msql_row[7] );
35.839 + proginfo->channame = g_string_new ( msql_row[0] );
35.840 proginfo->chancommfree =
35.841 - (gint) g_ascii_strtoull (msql_row[9], NULL, 10);
35.842 - proginfo->chanOutputFilters = g_string_new (msql_row[10]);
35.843 - proginfo->seriesid = g_string_new (msql_row[11]);
35.844 - proginfo->programid = g_string_new (msql_row[12]);
35.845 - proginfo->filesize = g_ascii_strtoull (msql_row[13], NULL, 10);
35.846 + ( gint ) g_ascii_strtoull ( msql_row[9], NULL, 10 );
35.847 + proginfo->chanOutputFilters = g_string_new ( msql_row[10] );
35.848 + proginfo->seriesid = g_string_new ( msql_row[11] );
35.849 + proginfo->programid = g_string_new ( msql_row[12] );
35.850 + proginfo->filesize = g_ascii_strtoull ( msql_row[13], NULL, 10 );
35.851
35.852 proginfo->lastmodified =
35.853 - gmyth_util_string_to_time_val (msql_row[14]);
35.854 - proginfo->stars = g_ascii_strtod (msql_row[15], NULL);
35.855 - proginfo->repeat = (gint) g_ascii_strtoull (msql_row[16], NULL, 10);
35.856 + gmyth_util_string_to_time_val ( msql_row[14] );
35.857 + proginfo->stars = g_ascii_strtod ( msql_row[15], NULL );
35.858 + proginfo->repeat =
35.859 + ( gint ) g_ascii_strtoull ( msql_row[16], NULL, 10 );
35.860
35.861 - if (msql_row[17] == NULL) {
35.862 + if ( msql_row[17] == NULL )
35.863 + {
35.864 proginfo->originalAirDate = 0;
35.865 proginfo->hasAirDate = FALSE;
35.866 - } else {
35.867 + }
35.868 + else
35.869 + {
35.870 proginfo->originalAirDate =
35.871 - gmyth_util_string_to_time_val (msql_row[17]);
35.872 + gmyth_util_string_to_time_val ( msql_row[17] );
35.873 proginfo->hasAirDate = TRUE;
35.874 }
35.875
35.876 - proginfo->hostname = g_string_new (msql_row[18]);
35.877 + proginfo->hostname = g_string_new ( msql_row[18] );
35.878 proginfo->recordid =
35.879 - (gint) g_ascii_strtoull (msql_row[19], NULL, 10);
35.880 + ( gint ) g_ascii_strtoull ( msql_row[19], NULL, 10 );
35.881 proginfo->transcoder =
35.882 - (gint) g_ascii_strtoull (msql_row[20], NULL, 10);
35.883 + ( gint ) g_ascii_strtoull ( msql_row[20], NULL, 10 );
35.884 //proginfo->spread = -1;
35.885 //proginfo->programflags = proginfo->getProgramFlags();
35.886
35.887 - proginfo->recgroup = g_string_new (msql_row[26]);
35.888 - proginfo->playgroup = g_string_new (msql_row[21]);
35.889 + proginfo->recgroup = g_string_new ( msql_row[26] );
35.890 + proginfo->playgroup = g_string_new ( msql_row[21] );
35.891 proginfo->recpriority =
35.892 - (gint) g_ascii_strtoull (msql_row[22], NULL, 10);
35.893 + ( gint ) g_ascii_strtoull ( msql_row[22], NULL, 10 );
35.894
35.895 - proginfo->pathname = g_string_new (g_strdup (msql_row[25]));
35.896 + proginfo->pathname = g_string_new ( g_strdup ( msql_row[25] ) );
35.897
35.898 - gmyth_debug ("One program info loaded from mysql database\n");
35.899 + gmyth_debug ( "One program info loaded from mysql database\n" );
35.900 }
35.901 }
35.902
35.903 - mysql_free_result (msql_res);
35.904 - g_string_free (query_str, TRUE);
35.905 - g_free (time_str);
35.906 + mysql_free_result ( msql_res );
35.907 + g_string_free ( query_str, TRUE );
35.908 + g_free ( time_str );
35.909
35.910 return proginfo;
35.911 }
35.912 @@ -643,19 +682,20 @@
35.913 * @return gint record_id if success, -1 otherwise
35.914 */
35.915 static gint
35.916 -get_record_id_from_database (GMythScheduler * scheduler)
35.917 +get_record_id_from_database ( GMythScheduler * scheduler )
35.918 {
35.919 gint record_id;
35.920
35.921 - assert (scheduler);
35.922 + assert ( scheduler );
35.923
35.924 - if (scheduler->msqlquery == NULL) {
35.925 - g_warning ("[%s] Scheduler db connection not initialized",
35.926 - __FUNCTION__);
35.927 + if ( scheduler->msqlquery == NULL )
35.928 + {
35.929 + g_warning ( "[%s] Scheduler db connection not initialized",
35.930 + __FUNCTION__ );
35.931 return 0;
35.932 }
35.933
35.934 - record_id = mysql_insert_id (scheduler->msqlquery->conn);
35.935 + record_id = mysql_insert_id ( scheduler->msqlquery->conn );
35.936
35.937 return record_id;
35.938 }
35.939 @@ -665,121 +705,124 @@
35.940 * @param record_id the id of the modified recording.
35.941 */
35.942 static gboolean
35.943 -update_backend (GMythScheduler * scheduler, gint record_id) //fixme: put void and discovery record_id inside
35.944 +update_backend ( GMythScheduler * scheduler, gint record_id ) //fixme: put void and discovery record_id inside
35.945 {
35.946 GMythSocket *socket;
35.947 - GMythStringList *strlist = gmyth_string_list_new ();
35.948 - GString *datastr = g_string_new ("RESCHEDULE_RECORDINGS ");
35.949 + GMythStringList *strlist = gmyth_string_list_new ( );
35.950 + GString *datastr = g_string_new ( "RESCHEDULE_RECORDINGS " );
35.951 gboolean ret = FALSE;
35.952
35.953 - g_string_append_printf (datastr, "%d", record_id);
35.954 - gmyth_string_list_append_string (strlist, datastr);
35.955 + g_string_append_printf ( datastr, "%d", record_id );
35.956 + gmyth_string_list_append_string ( strlist, datastr );
35.957
35.958 - socket = gmyth_socket_new ();
35.959 - if (gmyth_socket_connect_to_backend
35.960 - (socket, scheduler->backend_info->hostname,
35.961 - scheduler->backend_info->port, TRUE)) {
35.962 - ret = (gmyth_socket_sendreceive_stringlist (socket, strlist) > 0);
35.963 - } else {
35.964 - g_warning ("[%s] Connection to backend failed!", __FUNCTION__);
35.965 + socket = gmyth_socket_new ( );
35.966 + if ( gmyth_socket_connect_to_backend
35.967 + ( socket, scheduler->backend_info->hostname,
35.968 + scheduler->backend_info->port, TRUE ) )
35.969 + {
35.970 + ret = ( gmyth_socket_sendreceive_stringlist ( socket, strlist ) > 0 );
35.971 + }
35.972 + else
35.973 + {
35.974 + g_warning ( "[%s] Connection to backend failed!", __FUNCTION__ );
35.975 }
35.976
35.977 - g_string_free (datastr, TRUE);
35.978 - g_object_unref (strlist);
35.979 + g_string_free ( datastr, TRUE );
35.980 + g_object_unref ( strlist );
35.981
35.982 return ret;
35.983 }
35.984
35.985 void
35.986 -gmyth_scheduler_recorded_info_get_preview (RecordedInfo * info,
35.987 - GByteArray * data)
35.988 +gmyth_scheduler_recorded_info_get_preview ( RecordedInfo * info,
35.989 + GByteArray * data )
35.990 {
35.991 }
35.992
35.993 void
35.994 -gmyth_recorded_info_free (RecordedInfo * info)
35.995 +gmyth_recorded_info_free ( RecordedInfo * info )
35.996 {
35.997 - if (info->title != NULL)
35.998 - g_string_free (info->title, TRUE);
35.999 + if ( info->title != NULL )
35.1000 + g_string_free ( info->title, TRUE );
35.1001
35.1002 - if (info->subtitle != NULL)
35.1003 - g_string_free (info->subtitle, TRUE);
35.1004 + if ( info->subtitle != NULL )
35.1005 + g_string_free ( info->subtitle, TRUE );
35.1006
35.1007 - if (info->description != NULL)
35.1008 - g_string_free (info->description, TRUE);
35.1009 + if ( info->description != NULL )
35.1010 + g_string_free ( info->description, TRUE );
35.1011
35.1012 - if (info->category != NULL)
35.1013 - g_string_free (info->category, TRUE);
35.1014 + if ( info->category != NULL )
35.1015 + g_string_free ( info->category, TRUE );
35.1016
35.1017 - if (info->basename != NULL)
35.1018 - g_string_free (info->basename, TRUE);
35.1019 + if ( info->basename != NULL )
35.1020 + g_string_free ( info->basename, TRUE );
35.1021
35.1022 - if (info != NULL)
35.1023 - g_free (info->start_time);
35.1024 + if ( info != NULL )
35.1025 + g_free ( info->start_time );
35.1026
35.1027 - if (info != NULL)
35.1028 - g_free (info->end_time);
35.1029 + if ( info != NULL )
35.1030 + g_free ( info->end_time );
35.1031
35.1032 - g_free (info);
35.1033 + g_free ( info );
35.1034 }
35.1035
35.1036 static void
35.1037 -free_recorded_info_item (gpointer data, gpointer user_data)
35.1038 +free_recorded_info_item ( gpointer data, gpointer user_data )
35.1039 {
35.1040 - RecordedInfo *info = (RecordedInfo *) data;
35.1041 + RecordedInfo *info = ( RecordedInfo * ) data;
35.1042
35.1043 - gmyth_recorded_info_free (info);
35.1044 + gmyth_recorded_info_free ( info );
35.1045 }
35.1046
35.1047 void
35.1048 -gmyth_recorded_info_list_free (GList * list)
35.1049 +gmyth_recorded_info_list_free ( GList * list )
35.1050 {
35.1051 - g_return_if_fail (list != NULL);
35.1052 + g_return_if_fail ( list != NULL );
35.1053
35.1054 - g_list_foreach (list, free_recorded_info_item, NULL);
35.1055 - g_list_free (list);
35.1056 + g_list_foreach ( list, free_recorded_info_item, NULL );
35.1057 + g_list_free ( list );
35.1058 }
35.1059
35.1060 void
35.1061 -gmyth_schedule_info_free (ScheduleInfo * info)
35.1062 +gmyth_schedule_info_free ( ScheduleInfo * info )
35.1063 {
35.1064
35.1065 - g_return_if_fail (info != NULL);
35.1066 + g_return_if_fail ( info != NULL );
35.1067
35.1068 - if (info->title != NULL)
35.1069 - g_string_free (info->title, TRUE);
35.1070 + if ( info->title != NULL )
35.1071 + g_string_free ( info->title, TRUE );
35.1072
35.1073 - if (info->subtitle != NULL)
35.1074 - g_string_free (info->subtitle, TRUE);
35.1075 + if ( info->subtitle != NULL )
35.1076 + g_string_free ( info->subtitle, TRUE );
35.1077
35.1078 - if (info->description != NULL)
35.1079 - g_string_free (info->description, TRUE);
35.1080 + if ( info->description != NULL )
35.1081 + g_string_free ( info->description, TRUE );
35.1082
35.1083 - if (info->category != NULL)
35.1084 - g_string_free (info->category, TRUE);
35.1085 + if ( info->category != NULL )
35.1086 + g_string_free ( info->category, TRUE );
35.1087
35.1088 - if (info != NULL)
35.1089 - g_free (info->start_time);
35.1090 + if ( info != NULL )
35.1091 + g_free ( info->start_time );
35.1092
35.1093 - if (info != NULL)
35.1094 - g_free (info->end_time);
35.1095 + if ( info != NULL )
35.1096 + g_free ( info->end_time );
35.1097
35.1098 - g_free (info);
35.1099 + g_free ( info );
35.1100 }
35.1101
35.1102 static void
35.1103 -free_schedule_info_item (gpointer data, gpointer user_data)
35.1104 +free_schedule_info_item ( gpointer data, gpointer user_data )
35.1105 {
35.1106 - ScheduleInfo *info = (ScheduleInfo *) data;
35.1107 + ScheduleInfo *info = ( ScheduleInfo * ) data;
35.1108
35.1109 - gmyth_schedule_info_free (info);
35.1110 + gmyth_schedule_info_free ( info );
35.1111 }
35.1112
35.1113 void
35.1114 -gmyth_schedule_info_list_free (GList * list)
35.1115 +gmyth_schedule_info_list_free ( GList * list )
35.1116 {
35.1117 - g_return_if_fail (list != NULL);
35.1118 + g_return_if_fail ( list != NULL );
35.1119
35.1120 - g_list_foreach (list, free_schedule_info_item, NULL);
35.1121 - g_list_free (list);
35.1122 + g_list_foreach ( list, free_schedule_info_item, NULL );
35.1123 + g_list_free ( list );
35.1124 }
36.1 --- a/gmyth/src/gmyth_scheduler.h Wed May 23 19:21:26 2007 +0100
36.2 +++ b/gmyth/src/gmyth_scheduler.h Wed May 23 19:50:41 2007 +0100
36.3 @@ -9,22 +9,21 @@
36.4 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
36.5 * @author Alexsandro Jose Virginio dos Santos <alexsandro.santos@indt.org.br>
36.6 *
36.7 - *//*
36.8 - *
36.9 - * This program is free software; you can redistribute it and/or modify
36.10 - * it under the terms of the GNU Lesser General Public License as published by
36.11 - * the Free Software Foundation; either version 2 of the License, or
36.12 - * (at your option) any later version.
36.13 - *
36.14 - * This program is distributed in the hope that it will be useful,
36.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
36.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36.17 - * GNU General Public License for more details.
36.18 - *
36.19 - * You should have received a copy of the GNU Lesser General Public License
36.20 - * along with this program; if not, write to the Free Software
36.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
36.22 - */
36.23 + *
36.24 + * This program is free software; you can redistribute it and/or modify
36.25 + * it under the terms of the GNU Lesser General Public License as published by
36.26 + * the Free Software Foundation; either version 2 of the License, or
36.27 + * (at your option) any later version.
36.28 + *
36.29 + * This program is distributed in the hope that it will be useful,
36.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
36.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36.32 + * GNU General Public License for more details.
36.33 + *
36.34 + * You should have received a copy of the GNU Lesser General Public License
36.35 + * along with this program; if not, write to the Free Software
36.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
36.37 + */
36.38
36.39 #ifndef __GMYTH_SCHEDULER_H__
36.40 #define __GMYTH_SCHEDULER_H__
36.41 @@ -47,123 +46,125 @@
36.42 typedef struct _GMythSchedulerClass GMythSchedulerClass;
36.43
36.44 struct _GMythSchedulerClass
36.45 -{
36.46 - GObjectClass parent_class;
36.47 + {
36.48 + GObjectClass parent_class;
36.49
36.50 - /* callbacks */
36.51 - /* no one for now */
36.52 -};
36.53 + /* callbacks */
36.54 + /* no one for now */
36.55 + };
36.56
36.57 struct _GMythScheduler
36.58 -{
36.59 - GObject parent;
36.60 + {
36.61 + GObject parent;
36.62
36.63 - unsigned long recordid;
36.64 - unsigned long type;
36.65 - unsigned long search;
36.66 - GString *profile;
36.67 + unsigned long recordid;
36.68 + unsigned long type;
36.69 + unsigned long search;
36.70 + GString *profile;
36.71
36.72 - long dupin;
36.73 - long dupmethod;
36.74 - long autoexpire;
36.75 - short int autotranscode;
36.76 - long transcoder;
36.77 + long dupin;
36.78 + long dupmethod;
36.79 + long autoexpire;
36.80 + short int autotranscode;
36.81 + long transcoder;
36.82
36.83 - short int autocommflag;
36.84 - short int autouserjob1;
36.85 - short int autouserjob2;
36.86 - short int autouserjob3;
36.87 - short int autouserjob4;
36.88 + short int autocommflag;
36.89 + short int autouserjob1;
36.90 + short int autouserjob2;
36.91 + short int autouserjob3;
36.92 + short int autouserjob4;
36.93
36.94 - long startoffset;
36.95 - long endoffset;
36.96 - long maxepisodes;
36.97 - long maxnewest;
36.98 + long startoffset;
36.99 + long endoffset;
36.100 + long maxepisodes;
36.101 + long maxnewest;
36.102
36.103 - long recpriority;
36.104 - GString *recgroup;
36.105 - GString *playgroup;
36.106 + long recpriority;
36.107 + GString *recgroup;
36.108 + GString *playgroup;
36.109
36.110 - long prefinput;
36.111 - short int inactive;
36.112 + long prefinput;
36.113 + short int inactive;
36.114
36.115 - GString *search_type;
36.116 - GString *search_what;
36.117 + GString *search_type;
36.118 + GString *search_what;
36.119
36.120 - GMythQuery *msqlquery;
36.121 - GMythBackendInfo *backend_info;
36.122 -};
36.123 + GMythQuery *msqlquery;
36.124 + GMythBackendInfo *backend_info;
36.125 + };
36.126
36.127 typedef struct
36.128 -{
36.129 - guint schedule_id;
36.130 - guint program_id;
36.131 - guint channel_id;
36.132 + {
36.133 + guint schedule_id;
36.134 + guint program_id;
36.135 + guint channel_id;
36.136
36.137 - GTimeVal *start_time;
36.138 - GTimeVal *end_time;
36.139 + GTimeVal *start_time;
36.140 + GTimeVal *end_time;
36.141
36.142 - GString *title;
36.143 - GString *subtitle;
36.144 - GString *description;
36.145 - GString *category;
36.146 + GString *title;
36.147 + GString *subtitle;
36.148 + GString *description;
36.149 + GString *category;
36.150
36.151 -} ScheduleInfo;
36.152 + } ScheduleInfo;
36.153
36.154 typedef struct
36.155 -{
36.156 - guint record_id;
36.157 - guint program_id;
36.158 - guint channel_id;
36.159 + {
36.160 + guint record_id;
36.161 + guint program_id;
36.162 + guint channel_id;
36.163
36.164 - GTimeVal *start_time;
36.165 - GTimeVal *end_time;
36.166 + GTimeVal *start_time;
36.167 + GTimeVal *end_time;
36.168
36.169 - GString *title;
36.170 - GString *subtitle;
36.171 - GString *description;
36.172 - GString *category;
36.173 + GString *title;
36.174 + GString *subtitle;
36.175 + GString *description;
36.176 + GString *category;
36.177
36.178 - GString *basename;
36.179 + GString *basename;
36.180
36.181 - guint64 filesize;
36.182 + guint64 filesize;
36.183
36.184 -} RecordedInfo;
36.185 + } RecordedInfo;
36.186
36.187
36.188 -GType gmyth_scheduler_get_type (void);
36.189 +GType gmyth_scheduler_get_type ( void );
36.190
36.191 -GMythScheduler *gmyth_scheduler_new ();
36.192 -gboolean gmyth_scheduler_connect (GMythScheduler * scheduler,
36.193 - GMythBackendInfo * backend_info);
36.194 -gboolean gmyth_scheduler_connect_with_timeout (GMythScheduler * scheduler,
36.195 - GMythBackendInfo * backend_info, guint timeout);
36.196 -gboolean gmyth_scheduler_disconnect (GMythScheduler * scheduler);
36.197 +GMythScheduler *gmyth_scheduler_new ( );
36.198 +gboolean gmyth_scheduler_connect ( GMythScheduler * scheduler,
36.199 + GMythBackendInfo * backend_info );
36.200 +gboolean gmyth_scheduler_connect_with_timeout ( GMythScheduler * scheduler,
36.201 + GMythBackendInfo * backend_info,
36.202 + guint timeout );
36.203 +gboolean gmyth_scheduler_disconnect ( GMythScheduler * scheduler );
36.204
36.205 -gint gmyth_scheduler_get_schedule_list (GMythScheduler * scheduler,
36.206 - GList ** sched_list);
36.207 -gint gmyth_scheduler_get_recorded_list (GMythScheduler * scheduler,
36.208 - GList ** rec_list);
36.209 +gint gmyth_scheduler_get_schedule_list ( GMythScheduler * scheduler,
36.210 + GList ** sched_list );
36.211 +gint gmyth_scheduler_get_recorded_list ( GMythScheduler * scheduler,
36.212 + GList ** rec_list );
36.213
36.214 -GMythProgramInfo *gmyth_scheduler_get_recorded (GMythScheduler * scheduler,
36.215 - GString * channel, GTimeVal * starttime);
36.216 +GMythProgramInfo *gmyth_scheduler_get_recorded ( GMythScheduler * scheduler,
36.217 + GString * channel,
36.218 + GTimeVal * starttime );
36.219
36.220 -gint gmyth_scheduler_add_schedule (GMythScheduler * scheduler,
36.221 - ScheduleInfo * schedule_info);
36.222 +gint gmyth_scheduler_add_schedule ( GMythScheduler * scheduler,
36.223 + ScheduleInfo * schedule_info );
36.224
36.225 -gint gmyth_scheduler_delete_schedule (GMythScheduler * scheduler,
36.226 - gint record_id);
36.227 -gint gmyth_scheduler_delete_recorded (GMythScheduler * scheduler,
36.228 - gint record_id);
36.229 +gint gmyth_scheduler_delete_schedule ( GMythScheduler * scheduler,
36.230 + gint record_id );
36.231 +gint gmyth_scheduler_delete_recorded ( GMythScheduler * scheduler,
36.232 + gint record_id );
36.233
36.234 -void gmyth_scheduler_recorded_info_get_preview (RecordedInfo * info,
36.235 - GByteArray * data);
36.236 +void gmyth_scheduler_recorded_info_get_preview ( RecordedInfo * info,
36.237 + GByteArray * data );
36.238
36.239 -void gmyth_recorded_info_free (RecordedInfo * info);
36.240 -void gmyth_schedule_info_free (ScheduleInfo * info);
36.241 +void gmyth_recorded_info_free ( RecordedInfo * info );
36.242 +void gmyth_schedule_info_free ( ScheduleInfo * info );
36.243
36.244 -void gmyth_recorded_info_list_free (GList * list);
36.245 -void gmyth_schedule_info_list_free (GList * list);
36.246 +void gmyth_recorded_info_list_free ( GList * list );
36.247 +void gmyth_schedule_info_list_free ( GList * list );
36.248
36.249 G_END_DECLS
36.250 #endif /* __GMYTH_SCHEDULER_H__ */
37.1 --- a/gmyth/src/gmyth_socket.c Wed May 23 19:21:26 2007 +0100
37.2 +++ b/gmyth/src/gmyth_socket.c Wed May 23 19:50:41 2007 +0100
37.3 @@ -13,22 +13,21 @@
37.4 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
37.5 * @author Rosfran Lins Borges <rosfran.borges@indt.org.br>
37.6 *
37.7 - *//*
37.8 - *
37.9 - * This program is free software; you can redistribute it and/or modify
37.10 - * it under the terms of the GNU Lesser General Public License as published by
37.11 - * the Free Software Foundation; either version 2 of the License, or
37.12 - * (at your option) any later version.
37.13 - *
37.14 - * This program is distributed in the hope that it will be useful,
37.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
37.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37.17 - * GNU General Public License for more details.
37.18 - *
37.19 - * You should have received a copy of the GNU Lesser General Public License
37.20 - * along with this program; if not, write to the Free Software
37.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
37.22 - */
37.23 + *
37.24 + * This program is free software; you can redistribute it and/or modify
37.25 + * it under the terms of the GNU Lesser General Public License as published by
37.26 + * the Free Software Foundation; either version 2 of the License, or
37.27 + * (at your option) any later version.
37.28 + *
37.29 + * This program is distributed in the hope that it will be useful,
37.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
37.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37.32 + * GNU General Public License for more details.
37.33 + *
37.34 + * You should have received a copy of the GNU Lesser General Public License
37.35 + * along with this program; if not, write to the Free Software
37.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
37.37 + */
37.38
37.39 #ifdef HAVE_CONFIG_H
37.40 #include "config.h"
37.41 @@ -76,25 +75,25 @@
37.42
37.43 static gchar *local_hostname = NULL;
37.44
37.45 -static void gmyth_socket_class_init (GMythSocketClass * klass);
37.46 -static void gmyth_socket_init (GMythSocket * object);
37.47 +static void gmyth_socket_class_init ( GMythSocketClass * klass );
37.48 +static void gmyth_socket_init ( GMythSocket * object );
37.49
37.50 -static void gmyth_socket_dispose (GObject * object);
37.51 -static void gmyth_socket_finalize (GObject * object);
37.52 +static void gmyth_socket_dispose ( GObject * object );
37.53 +static void gmyth_socket_finalize ( GObject * object );
37.54
37.55 -G_DEFINE_TYPE (GMythSocket, gmyth_socket, G_TYPE_OBJECT)
37.56 - static void gmyth_socket_class_init (GMythSocketClass * klass)
37.57 +G_DEFINE_TYPE ( GMythSocket, gmyth_socket, G_TYPE_OBJECT )
37.58 + static void gmyth_socket_class_init ( GMythSocketClass * klass )
37.59 {
37.60 GObjectClass *gobject_class;
37.61
37.62 - gobject_class = (GObjectClass *) klass;
37.63 + gobject_class = ( GObjectClass * ) klass;
37.64
37.65 gobject_class->dispose = gmyth_socket_dispose;
37.66 gobject_class->finalize = gmyth_socket_finalize;
37.67 }
37.68
37.69 static void
37.70 -gmyth_socket_init (GMythSocket * gmyth_socket)
37.71 +gmyth_socket_init ( GMythSocket * gmyth_socket )
37.72 {
37.73
37.74 /* gmyth_socket->local_hostname = NULL; */
37.75 @@ -107,47 +106,48 @@
37.76 * @return gint that represents the error number from getaddrinfo().
37.77 */
37.78 static gint
37.79 -gmyth_socket_toaddrinfo (const gchar * addr, gint port,
37.80 - struct addrinfo **addrInfo)
37.81 +gmyth_socket_toaddrinfo ( const gchar * addr, gint port,
37.82 + struct addrinfo **addrInfo )
37.83 {
37.84 struct addrinfo hints;
37.85 gchar *portStr = NULL;
37.86 gint errorn = EADDRNOTAVAIL;
37.87
37.88 - g_return_val_if_fail (addr != NULL, -1);
37.89 + g_return_val_if_fail ( addr != NULL, -1 );
37.90
37.91 - memset (&hints, 0, sizeof (struct addrinfo));
37.92 + memset ( &hints, 0, sizeof ( struct addrinfo ) );
37.93 hints.ai_family = AF_INET;
37.94 hints.ai_socktype = SOCK_STREAM;
37.95 /* hints.ai_flags = AI_NUMERICHOST; */
37.96
37.97 - if (port != -1)
37.98 - portStr = g_strdup_printf ("%d", port);
37.99 + if ( port != -1 )
37.100 + portStr = g_strdup_printf ( "%d", port );
37.101 else
37.102 portStr = NULL;
37.103
37.104 - gmyth_debug ("Getting name resolution for: %s, %d\n", addr, port);
37.105 + gmyth_debug ( "Getting name resolution for: %s, %d\n", addr, port );
37.106
37.107 - if ((errorn = getaddrinfo (addr, portStr, &hints, addrInfo)) != 0) {
37.108 - gmyth_debug ("[%s] Socket ERROR: %s\n", __FUNCTION__,
37.109 - gai_strerror (errorn));
37.110 + if ( ( errorn = getaddrinfo ( addr, portStr, &hints, addrInfo ) ) != 0 )
37.111 + {
37.112 + gmyth_debug ( "[%s] Socket ERROR: %s\n", __FUNCTION__,
37.113 + gai_strerror ( errorn ) );
37.114 }
37.115
37.116 - g_free (portStr);
37.117 + g_free ( portStr );
37.118
37.119 return errorn;
37.120 }
37.121
37.122 /*
37.123 -static gint
37.124 -gmyth_socket_find_match_address_uri( GMythURI* uri, gchar *address )
37.125 -{
37.126 - if ( g_ascii_strcasecmp( gmyth_uri_get_host( uri ), address ) == 0 ) {
37.127 - //gmyth_debug( "Found URI: %s !!!\n", rui_uri_getvalue(uri) );
37.128 - return 0;
37.129 - } else {
37.130 - return -1;
37.131 - }
37.132 + static gint
37.133 + gmyth_socket_find_match_address_uri( GMythURI* uri, gchar *address )
37.134 + {
37.135 + if ( g_ascii_strcasecmp( gmyth_uri_get_host( uri ), address ) == 0 ) {
37.136 +//gmyth_debug( "Found URI: %s !!!\n", rui_uri_getvalue(uri) );
37.137 +return 0;
37.138 +} else {
37.139 +return -1;
37.140 +}
37.141 }
37.142 */
37.143
37.144 @@ -160,7 +160,7 @@
37.145 * @return List with all the local net interfaces.
37.146 */
37.147 GList *
37.148 -gmyth_socket_get_local_addrs (GList * current_connections)
37.149 +gmyth_socket_get_local_addrs ( GList * current_connections )
37.150 {
37.151
37.152 GList *local_addrs = NULL;
37.153 @@ -171,44 +171,45 @@
37.154 gchar *ifname;
37.155 gchar *sep;
37.156
37.157 - s = socket (AF_INET, SOCK_DGRAM, 0);
37.158 - if (s < 0)
37.159 + s = socket ( AF_INET, SOCK_DGRAM, 0 );
37.160 + if ( s < 0 )
37.161 return 0;
37.162 - fd = fopen (PATH_PROC_NET_DEV, "r");
37.163 - fgets (buffer, sizeof (buffer) - 1, fd);
37.164 - fgets (buffer, sizeof (buffer) - 1, fd);
37.165 - while (!feof (fd)) {
37.166 + fd = fopen ( PATH_PROC_NET_DEV, "r" );
37.167 + fgets ( buffer, sizeof ( buffer ) - 1, fd );
37.168 + fgets ( buffer, sizeof ( buffer ) - 1, fd );
37.169 + while ( !feof ( fd ) )
37.170 + {
37.171 ifname = buffer;
37.172
37.173 - if (fgets (buffer, sizeof (buffer) - 1, fd) == NULL)
37.174 + if ( fgets ( buffer, sizeof ( buffer ) - 1, fd ) == NULL )
37.175 break;
37.176 - sep = strrchr (buffer, ':');
37.177 - if (sep)
37.178 + sep = strrchr ( buffer, ':' );
37.179 + if ( sep )
37.180 *sep = 0;
37.181 - while (*ifname == ' ')
37.182 + while ( *ifname == ' ' )
37.183 ifname++;
37.184 struct ifreq req;
37.185
37.186 - strcpy (req.ifr_name, ifname);
37.187 - if (ioctl (s, SIOCGIFFLAGS, &req) < 0)
37.188 + strcpy ( req.ifr_name, ifname );
37.189 + if ( ioctl ( s, SIOCGIFFLAGS, &req ) < 0 )
37.190 continue;
37.191 - if (!(req.ifr_flags & IFF_UP))
37.192 + if ( !( req.ifr_flags & IFF_UP ) )
37.193 continue;
37.194 - if (req.ifr_flags & IFF_LOOPBACK)
37.195 + if ( req.ifr_flags & IFF_LOOPBACK )
37.196 continue;
37.197 - if (ioctl (s, SIOCGIFADDR, &req) < 0)
37.198 + if ( ioctl ( s, SIOCGIFADDR, &req ) < 0 )
37.199 continue;
37.200 - g_strlcpy (ifaddr,
37.201 - inet_ntoa (((struct sockaddr_in *) &req.ifr_addr)->
37.202 - sin_addr), sizeof (struct ifaddr) - 1);
37.203 - local_addrs = g_list_append (local_addrs, g_strdup (ifaddr));
37.204 + g_strlcpy ( ifaddr,
37.205 + inet_ntoa ( ( ( struct sockaddr_in * ) &req.ifr_addr )->
37.206 + sin_addr ), sizeof ( struct ifaddr ) - 1 );
37.207 + local_addrs = g_list_append ( local_addrs, g_strdup ( ifaddr ) );
37.208
37.209 gmyth_debug
37.210 - ("( from the /proc/net/dev) Interface name: %s, address: %s\n",
37.211 - ifname, ifaddr);
37.212 + ( "( from the /proc/net/dev) Interface name: %s, address: %s\n",
37.213 + ifname, ifaddr );
37.214 }
37.215 - fclose (fd);
37.216 - close (s);
37.217 + fclose ( fd );
37.218 + close ( s );
37.219 return local_addrs;
37.220 }
37.221
37.222 @@ -216,25 +217,26 @@
37.223 * Get only the local addresses from the primary interface
37.224 */
37.225 gchar *
37.226 -gmyth_socket_get_primary_addr (void)
37.227 +gmyth_socket_get_primary_addr ( void )
37.228 {
37.229 - gchar *if_eth0 = g_new0 (gchar, sizeof (struct ifaddr) - 1);
37.230 + gchar *if_eth0 = g_new0 ( gchar, sizeof ( struct ifaddr ) - 1 );
37.231 GList *if_tmp = NULL;
37.232
37.233 - GList *interfs = gmyth_socket_get_local_addrs (NULL);
37.234 + GList *interfs = gmyth_socket_get_local_addrs ( NULL );
37.235
37.236 - if (interfs != NULL && (g_list_length (interfs) > 0)) {
37.237 + if ( interfs != NULL && ( g_list_length ( interfs ) > 0 ) )
37.238 + {
37.239 // get the first occurrence (primary interface)
37.240 - if_tmp = g_list_first (interfs);
37.241 + if_tmp = g_list_first ( interfs );
37.242
37.243 - if (if_tmp != NULL)
37.244 - g_strlcpy (if_eth0, (gchar *) if_tmp->data,
37.245 - sizeof (struct ifaddr) - 1);
37.246 + if ( if_tmp != NULL )
37.247 + g_strlcpy ( if_eth0, ( gchar * ) if_tmp->data,
37.248 + sizeof ( struct ifaddr ) - 1 );
37.249
37.250 }
37.251
37.252 - if (interfs != NULL)
37.253 - g_list_free (interfs);
37.254 + if ( interfs != NULL )
37.255 + g_list_free ( interfs );
37.256
37.257 return if_eth0;
37.258 }
37.259 @@ -245,23 +247,24 @@
37.260 * @return GString* get local hostname.
37.261 */
37.262 GString *
37.263 -gmyth_socket_get_local_hostname (void)
37.264 +gmyth_socket_get_local_hostname ( void )
37.265 {
37.266 char hname[50];
37.267 - gint res = gethostname (hname, 50);
37.268 + gint res = gethostname ( hname, 50 );
37.269
37.270 - if (res == -1) {
37.271 - gmyth_debug ("Error while getting hostname");
37.272 - return g_string_new ("default");
37.273 + if ( res == -1 )
37.274 + {
37.275 + gmyth_debug ( "Error while getting hostname" );
37.276 + return g_string_new ( "default" );
37.277 }
37.278
37.279 - return g_string_new (hname);
37.280 + return g_string_new ( hname );
37.281
37.282 #if 0
37.283 GString *str = NULL;
37.284
37.285 - if (local_hostname != NULL && strlen (local_hostname) > 0)
37.286 - return g_string_new (local_hostname);
37.287 + if ( local_hostname != NULL && strlen ( local_hostname ) > 0 )
37.288 + return g_string_new ( local_hostname );
37.289
37.290 gchar *localaddr = NULL;
37.291 gboolean found_addr = FALSE;
37.292 @@ -270,99 +273,108 @@
37.293 gchar localhostname[MAXHOSTNAMELEN];
37.294
37.295
37.296 - if (gethostname (localhostname, MAXHOSTNAMELEN) != 0) {
37.297 - gmyth_debug ("Error on gethostname");
37.298 + if ( gethostname ( localhostname, MAXHOSTNAMELEN ) != 0 )
37.299 + {
37.300 + gmyth_debug ( "Error on gethostname" );
37.301 }
37.302 localhostname[MAXHOSTNAMELEN - 1] = 0;
37.303
37.304 - gint err = gmyth_socket_toaddrinfo (localhostname, -1, &addr_info_data);
37.305 + gint err = gmyth_socket_toaddrinfo ( localhostname, -1, &addr_info_data );
37.306
37.307 - if (err == EADDRNOTAVAIL) {
37.308 - gmyth_debug ("[%s] Address (%s) not available. (reason = %d)\n",
37.309 - __FUNCTION__, localhostname, err);
37.310 + if ( err == EADDRNOTAVAIL )
37.311 + {
37.312 + gmyth_debug ( "[%s] Address (%s) not available. (reason = %d)\n",
37.313 + __FUNCTION__, localhostname, err );
37.314 return str;
37.315 }
37.316
37.317 - g_mutex_lock (gmyth_socket->mutex);
37.318 + g_mutex_lock ( gmyth_socket->mutex );
37.319
37.320 addr_info0 = addr_info_data;
37.321
37.322 - while (addr_info0 != NULL && addr_info0->ai_addr != NULL &&
37.323 - (sa = (struct sockaddr_in *) addr_info0->ai_addr) != NULL
37.324 - && !found_addr) {
37.325 - localaddr = inet_ntoa (sa->sin_addr);
37.326 + while ( addr_info0 != NULL && addr_info0->ai_addr != NULL &&
37.327 + ( sa = ( struct sockaddr_in * ) addr_info0->ai_addr ) != NULL
37.328 + && !found_addr )
37.329 + {
37.330 + localaddr = inet_ntoa ( sa->sin_addr );
37.331
37.332 - if (localaddr != NULL && (g_strrstr (localaddr, "127") == NULL)) {
37.333 - str = g_string_new (localaddr);
37.334 + if ( localaddr != NULL && ( g_strrstr ( localaddr, "127" ) == NULL ) )
37.335 + {
37.336 + str = g_string_new ( localaddr );
37.337 found_addr = TRUE;
37.338 - g_free (localaddr);
37.339 + g_free ( localaddr );
37.340 break;
37.341 }
37.342 -/*
37.343 - if (localaddr != NULL) {
37.344 - g_free (localaddr);
37.345 - localaddr = NULL;
37.346 - }
37.347 - */
37.348 + /*
37.349 + if (localaddr != NULL) {
37.350 + g_free (localaddr);
37.351 + localaddr = NULL;
37.352 + }
37.353 + */
37.354
37.355 addr_info0 = addr_info0->ai_next;
37.356 };
37.357
37.358 - freeaddrinfo (addr_info_data);
37.359 + freeaddrinfo ( addr_info_data );
37.360 addr_info_data = NULL;
37.361
37.362 - if (found_addr == FALSE) {
37.363 - gchar *prim_addr = gmyth_socket_get_primary_addr ();
37.364 + if ( found_addr == FALSE )
37.365 + {
37.366 + gchar *prim_addr = gmyth_socket_get_primary_addr ( );
37.367
37.368 - if (prim_addr != NULL) {
37.369 + if ( prim_addr != NULL )
37.370 + {
37.371 gmyth_debug
37.372 - ("[%s] Could not determine the local alphanumerical hostname. Setting to %s\n",
37.373 - __FUNCTION__, prim_addr);
37.374 + ( "[%s] Could not determine the local alphanumerical hostname. Setting to %s\n",
37.375 + __FUNCTION__, prim_addr );
37.376
37.377 - str = g_string_new (prim_addr);
37.378 - g_free (prim_addr);
37.379 - } else {
37.380 - str = g_string_new (localhostname);
37.381 + str = g_string_new ( prim_addr );
37.382 + g_free ( prim_addr );
37.383 + }
37.384 + else
37.385 + {
37.386 + str = g_string_new ( localhostname );
37.387 }
37.388 }
37.389
37.390 - g_mutex_unlock (gmyth_socket->mutex);
37.391 + g_mutex_unlock ( gmyth_socket->mutex );
37.392
37.393 - if (str != NULL && str->str != NULL)
37.394 - local_hostname = g_strdup (str->str);
37.395 + if ( str != NULL && str->str != NULL )
37.396 + local_hostname = g_strdup ( str->str );
37.397
37.398 return str;
37.399 #endif
37.400 }
37.401
37.402 static void
37.403 -gmyth_socket_dispose (GObject * object)
37.404 +gmyth_socket_dispose ( GObject * object )
37.405 {
37.406 - GMythSocket *gmyth_socket = GMYTH_SOCKET (object);
37.407 + GMythSocket *gmyth_socket = GMYTH_SOCKET ( object );
37.408
37.409 /* disconnect socket */
37.410 - gmyth_socket_close_connection (gmyth_socket);
37.411 + gmyth_socket_close_connection ( gmyth_socket );
37.412
37.413 - g_free (gmyth_socket->hostname);
37.414 + g_free ( gmyth_socket->hostname );
37.415
37.416 - g_free (local_hostname);
37.417 + g_free ( local_hostname );
37.418
37.419 local_hostname = NULL;
37.420
37.421 - if (gmyth_socket->mutex != NULL) {
37.422 - g_mutex_free (gmyth_socket->mutex);
37.423 + if ( gmyth_socket->mutex != NULL )
37.424 + {
37.425 + g_mutex_free ( gmyth_socket->mutex );
37.426 gmyth_socket->mutex = NULL;
37.427 }
37.428
37.429 - G_OBJECT_CLASS (gmyth_socket_parent_class)->dispose (object);
37.430 + G_OBJECT_CLASS ( gmyth_socket_parent_class )->dispose ( object );
37.431 }
37.432
37.433 static void
37.434 -gmyth_socket_finalize (GObject * object)
37.435 +gmyth_socket_finalize ( GObject * object )
37.436 {
37.437 - g_signal_handlers_destroy (object);
37.438 + g_signal_handlers_destroy ( object );
37.439
37.440 - G_OBJECT_CLASS (gmyth_socket_parent_class)->finalize (object);
37.441 + G_OBJECT_CLASS ( gmyth_socket_parent_class )->finalize ( object );
37.442 }
37.443
37.444 /** Creates a new instance of GMythSocket.
37.445 @@ -370,14 +382,14 @@
37.446 * @return a new instance of GMythSocket.
37.447 */
37.448 GMythSocket *
37.449 -gmyth_socket_new ()
37.450 +gmyth_socket_new ( )
37.451 {
37.452 GMythSocket *gmyth_socket =
37.453 - GMYTH_SOCKET (g_object_new (GMYTH_SOCKET_TYPE, NULL));
37.454 + GMYTH_SOCKET ( g_object_new ( GMYTH_SOCKET_TYPE, NULL ) );
37.455
37.456 gmyth_socket->mythtv_version = MYTHTV_VERSION_DEFAULT;
37.457
37.458 - gmyth_socket->mutex = g_mutex_new ();
37.459 + gmyth_socket->mutex = g_mutex_new ( );
37.460
37.461 return gmyth_socket;
37.462 }
37.463 @@ -392,89 +404,97 @@
37.464 * @return Any numerical value below 0, if an error had been found.
37.465 */
37.466 static gint
37.467 -gmyth_socket_try_connect (gint fd, struct sockaddr *remote, gint len,
37.468 - struct timeval *timeout, gint * err)
37.469 +gmyth_socket_try_connect ( gint fd, struct sockaddr *remote, gint len,
37.470 + struct timeval *timeout, gint * err )
37.471 {
37.472 /*g_return_val_if_fail( timeout != NULL, 0 ); */
37.473 gint saveflags, ret, back_err;
37.474
37.475 fd_set fd_w;
37.476
37.477 - saveflags = fcntl (fd, F_GETFL, 0);
37.478 - if (saveflags < 0) {
37.479 - gmyth_debug ("[%s] Problems when getting socket flags on fcntl.\n",
37.480 - __FUNCTION__);
37.481 + saveflags = fcntl ( fd, F_GETFL, 0 );
37.482 + if ( saveflags < 0 )
37.483 + {
37.484 + gmyth_debug ( "[%s] Problems when getting socket flags on fcntl.\n",
37.485 + __FUNCTION__ );
37.486 *err = errno;
37.487 return -1;
37.488 }
37.489
37.490 /* Set non blocking */
37.491 - if (fcntl (fd, F_SETFL, saveflags | O_NONBLOCK) < 0) {
37.492 - gmyth_debug ("[%s] Problems when setting non-blocking using fcntl.\n",
37.493 - __FUNCTION__);
37.494 + if ( fcntl ( fd, F_SETFL, saveflags | O_NONBLOCK ) < 0 )
37.495 + {
37.496 + gmyth_debug ( "[%s] Problems when setting non-blocking using fcntl.\n",
37.497 + __FUNCTION__ );
37.498 *err = errno;
37.499 return -1;
37.500 }
37.501
37.502 /* This will return immediately */
37.503 - *err = connect (fd, remote, len);
37.504 + *err = connect ( fd, remote, len );
37.505 back_err = errno;
37.506
37.507 /* restore flags */
37.508 - if (fcntl (fd, F_SETFL, saveflags) < 0) {
37.509 + if ( fcntl ( fd, F_SETFL, saveflags ) < 0 )
37.510 + {
37.511 gmyth_debug
37.512 - ("[%s] Problems when trying to restore flags with fcntl.\n",
37.513 - __FUNCTION__);
37.514 + ( "[%s] Problems when trying to restore flags with fcntl.\n",
37.515 + __FUNCTION__ );
37.516 *err = errno;
37.517 return -1;
37.518 }
37.519
37.520 /* return unless the connection was successful or the connect is
37.521 still in progress. */
37.522 - if (*err < 0 && back_err != EINPROGRESS) {
37.523 + if ( *err < 0 && back_err != EINPROGRESS )
37.524 + {
37.525 gmyth_debug
37.526 - ("[%s] Connection unsucessfully (it is not in progress).\n",
37.527 - __FUNCTION__);
37.528 + ( "[%s] Connection unsucessfully (it is not in progress).\n",
37.529 + __FUNCTION__ );
37.530 *err = errno;
37.531 return -1;
37.532 }
37.533
37.534 - FD_ZERO (&fd_w);
37.535 - FD_SET (fd, &fd_w);
37.536 + FD_ZERO ( &fd_w );
37.537 + FD_SET ( fd, &fd_w );
37.538
37.539 - *err = select (FD_SETSIZE, NULL, &fd_w, NULL, timeout);
37.540 - if (*err < 0) {
37.541 - gmyth_debug ("[%s] Connection unsucessfull (timed out).\n",
37.542 - __FUNCTION__);
37.543 + *err = select ( FD_SETSIZE, NULL, &fd_w, NULL, timeout );
37.544 + if ( *err < 0 )
37.545 + {
37.546 + gmyth_debug ( "[%s] Connection unsucessfull (timed out).\n",
37.547 + __FUNCTION__ );
37.548 *err = errno;
37.549 return -1;
37.550 }
37.551
37.552 /* 0 means it timeout out & no fds changed */
37.553 - if (*err == 0) {
37.554 + if ( *err == 0 )
37.555 + {
37.556 gmyth_debug
37.557 - ("[%s] Connection unsucessfull [%d] - 0 means it timeout out & no fds changed\n",
37.558 - __FUNCTION__, *err);
37.559 - close (fd);
37.560 + ( "[%s] Connection unsucessfull [%d] - 0 means it timeout out & no fds changed\n",
37.561 + __FUNCTION__, *err );
37.562 + close ( fd );
37.563 *err = ETIMEDOUT;
37.564 return -1;
37.565 }
37.566
37.567 /* Get the return code from the connect */
37.568 - len = sizeof (ret);
37.569 - *err = getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, (socklen_t *) & len);
37.570 + len = sizeof ( ret );
37.571 + *err = getsockopt ( fd, SOL_SOCKET, SO_ERROR, &ret, ( socklen_t * ) & len );
37.572
37.573 - if (*err < 0) {
37.574 - gmyth_debug ("[%s] Connection unsucessfull.\n", __FUNCTION__);
37.575 + if ( *err < 0 )
37.576 + {
37.577 + gmyth_debug ( "[%s] Connection unsucessfull.\n", __FUNCTION__ );
37.578 *err = errno;
37.579 return -1;
37.580 }
37.581
37.582 /* ret=0 means success, otherwise it contains the errno */
37.583 - if (ret) {
37.584 + if ( ret )
37.585 + {
37.586 gmyth_debug
37.587 - ("[%s] Connection unsucessfull - Couldn't connect to remote host!!!\n",
37.588 - __FUNCTION__);
37.589 + ( "[%s] Connection unsucessfull - Couldn't connect to remote host!!!\n",
37.590 + __FUNCTION__ );
37.591 *err = ret;
37.592 return -1;
37.593 }
37.594 @@ -493,15 +513,17 @@
37.595
37.596
37.597 gboolean
37.598 -gmyth_socket_connect (GMythSocket * gmyth_socket,
37.599 - const gchar * hostname, gint port)
37.600 +gmyth_socket_connect ( GMythSocket * gmyth_socket,
37.601 + const gchar * hostname, gint port )
37.602 {
37.603 - return gmyth_socket_connect_with_timeout (gmyth_socket, hostname, port, 0);
37.604 + return gmyth_socket_connect_with_timeout ( gmyth_socket, hostname, port,
37.605 + 0 );
37.606 }
37.607
37.608 gboolean
37.609 -gmyth_socket_connect_with_timeout (GMythSocket * gmyth_socket,
37.610 - const gchar * hostname, gint port, guint timeout)
37.611 +gmyth_socket_connect_with_timeout ( GMythSocket * gmyth_socket,
37.612 + const gchar * hostname, gint port,
37.613 + guint timeout )
37.614 {
37.615 struct addrinfo *addr_info_data = NULL, *addr_info0 = NULL;
37.616 struct linger ling;
37.617 @@ -513,109 +535,117 @@
37.618 gint errno;
37.619 gboolean ret = TRUE;
37.620
37.621 - gmyth_debug ("CONNECTING %s:%d", hostname, port);
37.622 + gmyth_debug ( "CONNECTING %s:%d", hostname, port );
37.623
37.624 - if (hostname == NULL)
37.625 - gmyth_debug ("Invalid hostname parameter!\n");
37.626 + if ( hostname == NULL )
37.627 + gmyth_debug ( "Invalid hostname parameter!\n" );
37.628
37.629 /* store hostname and port number */
37.630 - gmyth_debug ("CONNECTING %s:%d", hostname, port);
37.631 + gmyth_debug ( "CONNECTING %s:%d", hostname, port );
37.632
37.633 - errno = gmyth_socket_toaddrinfo (hostname, port, &addr_info_data);
37.634 + errno = gmyth_socket_toaddrinfo ( hostname, port, &addr_info_data );
37.635
37.636 - g_return_val_if_fail (addr_info_data != NULL && hostname != NULL, FALSE);
37.637 + g_return_val_if_fail ( addr_info_data != NULL && hostname != NULL, FALSE );
37.638
37.639 /* hack to avoid deleting the hostname when
37.640 * gmyth_socket->hostname == hostname */
37.641 tmp_str = gmyth_socket->hostname;
37.642
37.643 - gmyth_socket->hostname = g_strdup (hostname);
37.644 + gmyth_socket->hostname = g_strdup ( hostname );
37.645 gmyth_socket->port = port;
37.646
37.647 - g_free (tmp_str);
37.648 + g_free ( tmp_str );
37.649
37.650 - for (addr_info0 = addr_info_data; addr_info0;
37.651 - addr_info0 = addr_info_data->ai_next) {
37.652 + for ( addr_info0 = addr_info_data; addr_info0;
37.653 + addr_info0 = addr_info_data->ai_next )
37.654 + {
37.655 /* init socket descriptor */
37.656 gmyth_socket->sd =
37.657 - socket (addr_info0->ai_family, addr_info0->ai_socktype,
37.658 - addr_info0->ai_protocol);
37.659 + socket ( addr_info0->ai_family, addr_info0->ai_socktype,
37.660 + addr_info0->ai_protocol );
37.661
37.662 - if (gmyth_socket->sd < 0)
37.663 + if ( gmyth_socket->sd < 0 )
37.664 continue;
37.665
37.666 - struct timeval *timeout_val = g_new0 (struct timeval, 1);
37.667 + struct timeval *timeout_val = g_new0 ( struct timeval, 1 );
37.668
37.669 - if (timeout != 0) {
37.670 + if ( timeout != 0 )
37.671 + {
37.672 timeout_val->tv_sec = timeout;
37.673 timeout_val->tv_usec = 0;
37.674 - } else {
37.675 + }
37.676 + else
37.677 + {
37.678 timeout_val->tv_sec = 5;
37.679 timeout_val->tv_usec = 100;
37.680 }
37.681
37.682 - if (gmyth_socket_try_connect
37.683 - (gmyth_socket->sd, (struct sockaddr *) addr_info0->ai_addr,
37.684 - addr_info0->ai_addrlen, timeout_val, &ret_code) < 0) {
37.685 - gmyth_debug ("[%s] Error connecting to backend!\n", __FUNCTION__);
37.686 - if (ret_code == ETIMEDOUT)
37.687 - gmyth_debug ("[%s]\tBackend host unreachable!\n", __FUNCTION__);
37.688 + if ( gmyth_socket_try_connect
37.689 + ( gmyth_socket->sd, ( struct sockaddr * ) addr_info0->ai_addr,
37.690 + addr_info0->ai_addrlen, timeout_val, &ret_code ) < 0 )
37.691 + {
37.692 + gmyth_debug ( "[%s] Error connecting to backend!\n", __FUNCTION__ );
37.693 + if ( ret_code == ETIMEDOUT )
37.694 + gmyth_debug ( "[%s]\tBackend host unreachable!\n",
37.695 + __FUNCTION__ );
37.696
37.697 - close (gmyth_socket->sd);
37.698 + close ( gmyth_socket->sd );
37.699 gmyth_socket->sd = -1;
37.700 - gmyth_debug ("ERROR: %s\n", gai_strerror (ret_code));
37.701 - g_free (timeout_val);
37.702 + gmyth_debug ( "ERROR: %s\n", gai_strerror ( ret_code ) );
37.703 + g_free ( timeout_val );
37.704 continue;
37.705 }
37.706
37.707 - g_free (timeout_val);
37.708 + g_free ( timeout_val );
37.709
37.710 /* only will be reached if none of the error above occurred */
37.711 break;
37.712 }
37.713
37.714 - freeaddrinfo (addr_info_data);
37.715 + freeaddrinfo ( addr_info_data );
37.716 addr_info_data = NULL;
37.717
37.718 - if (gmyth_socket->sd_io_ch != NULL) {
37.719 - g_io_channel_unref (gmyth_socket->sd_io_ch);
37.720 + if ( gmyth_socket->sd_io_ch != NULL )
37.721 + {
37.722 + g_io_channel_unref ( gmyth_socket->sd_io_ch );
37.723 gmyth_socket->sd_io_ch = NULL;
37.724 }
37.725
37.726
37.727 - memset (&ling, 0, sizeof (struct linger));
37.728 + memset ( &ling, 0, sizeof ( struct linger ) );
37.729 ling.l_onoff = TRUE;
37.730 ling.l_linger = 1;
37.731
37.732 err =
37.733 - setsockopt (gmyth_socket->sd, SOL_SOCKET, SO_LINGER, &ling,
37.734 - sizeof (struct linger));
37.735 + setsockopt ( gmyth_socket->sd, SOL_SOCKET, SO_LINGER, &ling,
37.736 + sizeof ( struct linger ) );
37.737
37.738 - if (err < 0) {
37.739 - gmyth_debug ("[%s] Setting connection unsucessfull.\n", __FUNCTION__);
37.740 + if ( err < 0 )
37.741 + {
37.742 + gmyth_debug ( "[%s] Setting connection unsucessfull.\n", __FUNCTION__ );
37.743 err = errno;
37.744 ret = FALSE;
37.745 goto cleanup;
37.746 }
37.747
37.748 - gmyth_socket->sd_io_ch = g_io_channel_unix_new (gmyth_socket->sd);
37.749 + gmyth_socket->sd_io_ch = g_io_channel_unix_new ( gmyth_socket->sd );
37.750
37.751 - g_io_channel_set_close_on_unref (gmyth_socket->sd_io_ch, TRUE);
37.752 + g_io_channel_set_close_on_unref ( gmyth_socket->sd_io_ch, TRUE );
37.753 //g_io_channel_set_encoding (gmyth_socket->sd_io_ch, NULL, NULL );
37.754
37.755 - GIOFlags flags = g_io_channel_get_flags (gmyth_socket->sd_io_ch);
37.756 + GIOFlags flags = g_io_channel_get_flags ( gmyth_socket->sd_io_ch );
37.757
37.758 /* unset the nonblock flag */
37.759 flags &= ~G_IO_FLAG_NONBLOCK;
37.760 /* unset the nonblocking stuff for some time, because GNUTLS doesn't like
37.761 * that */
37.762 - g_io_channel_set_flags (gmyth_socket->sd_io_ch, flags, NULL);
37.763 + g_io_channel_set_flags ( gmyth_socket->sd_io_ch, flags, NULL );
37.764
37.765 - ret = (ret_code == 0) ? TRUE : FALSE;
37.766 + ret = ( ret_code == 0 ) ? TRUE : FALSE;
37.767
37.768 cleanup:
37.769 - if (!ret)
37.770 - gmyth_debug ("GMythSocket error - return code error!");
37.771 + if ( !ret )
37.772 + gmyth_debug ( "GMythSocket error - return code error!" );
37.773
37.774 return ret;
37.775 }
37.776 @@ -625,9 +655,9 @@
37.777 * @param gmyth_socket The GMythSocket instance.
37.778 */
37.779 GIOChannel *
37.780 -gmyth_socket_get_io_channel (GMythSocket * gmyth_socket)
37.781 +gmyth_socket_get_io_channel ( GMythSocket * gmyth_socket )
37.782 {
37.783 - g_return_val_if_fail (gmyth_socket != NULL, NULL);
37.784 + g_return_val_if_fail ( gmyth_socket != NULL, NULL );
37.785
37.786 return gmyth_socket->sd_io_ch;
37.787 }
37.788 @@ -638,17 +668,18 @@
37.789 * @return TRUE if the socket is able to read, FALSE if not.
37.790 */
37.791 gboolean
37.792 -gmyth_socket_is_able_to_read (GMythSocket * gmyth_socket)
37.793 +gmyth_socket_is_able_to_read ( GMythSocket * gmyth_socket )
37.794 {
37.795 gboolean ret = TRUE;
37.796
37.797 /* verify if the input (read) buffer is ready to receive data */
37.798 GIOCondition io_cond =
37.799 - g_io_channel_get_buffer_condition (gmyth_socket->sd_io_ch);
37.800 + g_io_channel_get_buffer_condition ( gmyth_socket->sd_io_ch );
37.801
37.802 - if ((io_cond & G_IO_IN) == 0) {
37.803 - gmyth_debug ("[%s] IO channel is not able to send data!\n",
37.804 - __FUNCTION__);
37.805 + if ( ( io_cond & G_IO_IN ) == 0 )
37.806 + {
37.807 + gmyth_debug ( "[%s] IO channel is not able to send data!\n",
37.808 + __FUNCTION__ );
37.809 ret = FALSE;
37.810 }
37.811
37.812 @@ -662,17 +693,18 @@
37.813 * @return TRUE if the socket is able to write, FALSE if not.
37.814 */
37.815 gboolean
37.816 -gmyth_socket_is_able_to_write (GMythSocket * gmyth_socket)
37.817 +gmyth_socket_is_able_to_write ( GMythSocket * gmyth_socket )
37.818 {
37.819 gboolean ret = TRUE;
37.820
37.821 /* verify if the input (read) buffer is ready to receive data */
37.822 GIOCondition io_cond =
37.823 - g_io_channel_get_buffer_condition (gmyth_socket->sd_io_ch);
37.824 + g_io_channel_get_buffer_condition ( gmyth_socket->sd_io_ch );
37.825
37.826 - if (((io_cond & G_IO_OUT) == 0) || ((io_cond & G_IO_HUP) == 0)) {
37.827 - gmyth_debug ("[%s] IO channel is not able to send data!\n",
37.828 - __FUNCTION__);
37.829 + if ( ( ( io_cond & G_IO_OUT ) == 0 ) || ( ( io_cond & G_IO_HUP ) == 0 ) )
37.830 + {
37.831 + gmyth_debug ( "[%s] IO channel is not able to send data!\n",
37.832 + __FUNCTION__ );
37.833 ret = FALSE;
37.834 }
37.835
37.836 @@ -686,7 +718,7 @@
37.837 * @param command The string command to be sent.
37.838 */
37.839 gboolean
37.840 -gmyth_socket_send_command (GMythSocket * gmyth_socket, GString * command)
37.841 +gmyth_socket_send_command ( GMythSocket * gmyth_socket, GString * command )
37.842 {
37.843 gboolean ret = TRUE;
37.844
37.845 @@ -699,58 +731,65 @@
37.846
37.847 gsize bytes_written = 0;
37.848
37.849 - g_return_val_if_fail (gmyth_socket->sd_io_ch != NULL, FALSE);
37.850 + g_return_val_if_fail ( gmyth_socket->sd_io_ch != NULL, FALSE );
37.851
37.852 - if (command == NULL || (command->len <= 0) || command->str == NULL) {
37.853 - gmyth_debug ("[%s] Invalid NULL command parameter!\n", __FUNCTION__);
37.854 + if ( command == NULL || ( command->len <= 0 ) || command->str == NULL )
37.855 + {
37.856 + gmyth_debug ( "[%s] Invalid NULL command parameter!\n", __FUNCTION__ );
37.857 ret = FALSE;
37.858 goto done;
37.859 }
37.860
37.861 - g_mutex_lock (gmyth_socket->mutex);
37.862 - gmyth_debug ("Sending command to backend: %s\n", command->str);
37.863 + g_mutex_lock ( gmyth_socket->mutex );
37.864 + gmyth_debug ( "Sending command to backend: %s\n", command->str );
37.865
37.866 - buffer = g_strnfill (BUFLEN, ' ');
37.867 - g_snprintf (buffer, MYTH_PROTOCOL_FIELD_SIZE + 1, "%-8d", command->len);
37.868 + buffer = g_strnfill ( BUFLEN, ' ' );
37.869 + g_snprintf ( buffer, MYTH_PROTOCOL_FIELD_SIZE + 1, "%-8d", command->len );
37.870
37.871 - command = g_string_prepend (command, buffer);
37.872 + command = g_string_prepend ( command, buffer );
37.873
37.874 /* write bytes to socket */
37.875 - io_status = g_io_channel_write_chars (gmyth_socket->sd_io_ch, command->str,
37.876 - command->len, &bytes_written, &error);
37.877 + io_status = g_io_channel_write_chars ( gmyth_socket->sd_io_ch, command->str,
37.878 + command->len, &bytes_written,
37.879 + &error );
37.880
37.881
37.882 - if ((io_status == G_IO_STATUS_ERROR) || (bytes_written <= 0)) {
37.883 - gmyth_debug ("[%s] Error while writing to socket", __FUNCTION__);
37.884 + if ( ( io_status == G_IO_STATUS_ERROR ) || ( bytes_written <= 0 ) )
37.885 + {
37.886 + gmyth_debug ( "[%s] Error while writing to socket", __FUNCTION__ );
37.887 ret = FALSE;
37.888 - } else if (bytes_written < command->len) {
37.889 - gmyth_debug ("[%s] Not all data was written socket", __FUNCTION__);
37.890 + }
37.891 + else if ( bytes_written < command->len )
37.892 + {
37.893 + gmyth_debug ( "[%s] Not all data was written socket", __FUNCTION__ );
37.894 ret = FALSE;
37.895 }
37.896
37.897 - io_status = g_io_channel_flush (gmyth_socket->sd_io_ch, &error);
37.898 + io_status = g_io_channel_flush ( gmyth_socket->sd_io_ch, &error );
37.899
37.900 - if ((bytes_written != command->len)
37.901 - || (io_status == G_IO_STATUS_ERROR)) {
37.902 + if ( ( bytes_written != command->len )
37.903 + || ( io_status == G_IO_STATUS_ERROR ) )
37.904 + {
37.905 gmyth_debug
37.906 - ("[%s] Some problem occurred when sending data to the socket\n",
37.907 - __FUNCTION__);
37.908 + ( "[%s] Some problem occurred when sending data to the socket\n",
37.909 + __FUNCTION__ );
37.910
37.911 ret = TRUE;
37.912 }
37.913
37.914 - g_mutex_unlock (gmyth_socket->mutex);
37.915 + g_mutex_unlock ( gmyth_socket->mutex );
37.916 done:
37.917 - if (error != NULL) {
37.918 + if ( error != NULL )
37.919 + {
37.920 gmyth_debug
37.921 - ("[%s] Error found reading data from IO channel: (%d, %s)\n",
37.922 - __FUNCTION__, error->code, error->message);
37.923 + ( "[%s] Error found reading data from IO channel: (%d, %s)\n",
37.924 + __FUNCTION__, error->code, error->message );
37.925 ret = FALSE;
37.926 - g_error_free (error);
37.927 + g_error_free ( error );
37.928 }
37.929
37.930 - if (buffer != NULL)
37.931 - g_free (buffer);
37.932 + if ( buffer != NULL )
37.933 + g_free ( buffer );
37.934
37.935 return ret;
37.936 }
37.937 @@ -766,46 +805,54 @@
37.938 * backend connection.
37.939 */
37.940 static gboolean
37.941 -gmyth_socket_connect_to_backend_and_events (GMythSocket * gmyth_socket,
37.942 - const gchar * hostname_backend,
37.943 - gint port, gboolean blocking_client, gboolean with_events)
37.944 +gmyth_socket_connect_to_backend_and_events ( GMythSocket * gmyth_socket,
37.945 + const gchar * hostname_backend,
37.946 + gint port,
37.947 + gboolean blocking_client,
37.948 + gboolean with_events )
37.949 {
37.950 - if (!gmyth_socket_connect (gmyth_socket, hostname_backend, port)) {
37.951 - gmyth_debug ("[%s] Could not open socket to backend machine [%s]\n",
37.952 - __FUNCTION__, hostname_backend);
37.953 + if ( !gmyth_socket_connect ( gmyth_socket, hostname_backend, port ) )
37.954 + {
37.955 + gmyth_debug ( "[%s] Could not open socket to backend machine [%s]\n",
37.956 + __FUNCTION__, hostname_backend );
37.957 return FALSE;
37.958 }
37.959
37.960 - if (gmyth_socket_check_protocol_version (gmyth_socket)) {
37.961 + if ( gmyth_socket_check_protocol_version ( gmyth_socket ) )
37.962 + {
37.963 GString *result;
37.964 - GString *base_str = g_string_new ("");
37.965 + GString *base_str = g_string_new ( "" );
37.966 GString *hostname = NULL;
37.967
37.968 - hostname = gmyth_socket_get_local_hostname ();
37.969 - if (hostname == NULL) {
37.970 - gmyth_debug ("Hostname not available, setting to n800frontend\n");
37.971 - hostname = g_string_new ("n800frontend");
37.972 + hostname = gmyth_socket_get_local_hostname ( );
37.973 + if ( hostname == NULL )
37.974 + {
37.975 + gmyth_debug ( "Hostname not available, setting to n800frontend\n" );
37.976 + hostname = g_string_new ( "n800frontend" );
37.977 }
37.978
37.979 - g_string_printf (base_str, "ANN %s %s %u",
37.980 - (blocking_client ? "Playback" : "Monitor"),
37.981 - hostname->str, with_events);
37.982 + g_string_printf ( base_str, "ANN %s %s %u",
37.983 + ( blocking_client ? "Playback" : "Monitor" ),
37.984 + hostname->str, with_events );
37.985
37.986 - gmyth_socket_send_command (gmyth_socket, base_str);
37.987 - result = gmyth_socket_receive_response (gmyth_socket);
37.988 + gmyth_socket_send_command ( gmyth_socket, base_str );
37.989 + result = gmyth_socket_receive_response ( gmyth_socket );
37.990
37.991 - if (result != NULL) {
37.992 - gmyth_debug ("Response received from backend: %s", result->str);
37.993 - g_string_free (result, TRUE);
37.994 + if ( result != NULL )
37.995 + {
37.996 + gmyth_debug ( "Response received from backend: %s", result->str );
37.997 + g_string_free ( result, TRUE );
37.998 }
37.999
37.1000 - g_string_free (hostname, TRUE);
37.1001 - g_string_free (base_str, TRUE);
37.1002 + g_string_free ( hostname, TRUE );
37.1003 + g_string_free ( base_str, TRUE );
37.1004
37.1005 return TRUE;
37.1006 - } else {
37.1007 - gmyth_debug ("[%s] GMythSocket could not connect to the backend",
37.1008 - __FUNCTION__);
37.1009 + }
37.1010 + else
37.1011 + {
37.1012 + gmyth_debug ( "[%s] GMythSocket could not connect to the backend",
37.1013 + __FUNCTION__ );
37.1014 return FALSE;
37.1015 }
37.1016 }
37.1017 @@ -819,13 +866,15 @@
37.1018 * @param blocking_client A flag to choose between blocking and non-blocking
37.1019 */
37.1020 gboolean
37.1021 -gmyth_socket_connect_to_backend (GMythSocket * gmyth_socket,
37.1022 - const gchar * hostname_backend, gint port, gboolean blocking_client)
37.1023 +gmyth_socket_connect_to_backend ( GMythSocket * gmyth_socket,
37.1024 + const gchar * hostname_backend, gint port,
37.1025 + gboolean blocking_client )
37.1026 {
37.1027 - if (!gmyth_socket_connect_to_backend_and_events
37.1028 - (gmyth_socket, hostname_backend, port, blocking_client, FALSE)) {
37.1029 - gmyth_debug ("Could not open socket to backend machine [%s]\n",
37.1030 - hostname_backend);
37.1031 + if ( !gmyth_socket_connect_to_backend_and_events
37.1032 + ( gmyth_socket, hostname_backend, port, blocking_client, FALSE ) )
37.1033 + {
37.1034 + gmyth_debug ( "Could not open socket to backend machine [%s]\n",
37.1035 + hostname_backend );
37.1036 return FALSE;
37.1037 }
37.1038
37.1039 @@ -842,14 +891,16 @@
37.1040 * @param blocking_client A flag to choose between blocking and non-blocking
37.1041 */
37.1042 gboolean
37.1043 -gmyth_socket_connect_to_backend_events (GMythSocket * gmyth_socket,
37.1044 - const gchar * hostname_backend, gint port, gboolean blocking_client)
37.1045 +gmyth_socket_connect_to_backend_events ( GMythSocket * gmyth_socket,
37.1046 + const gchar * hostname_backend,
37.1047 + gint port, gboolean blocking_client )
37.1048 {
37.1049 - if (!gmyth_socket_connect_to_backend_and_events
37.1050 - (gmyth_socket, hostname_backend, port, blocking_client, TRUE)) {
37.1051 + if ( !gmyth_socket_connect_to_backend_and_events
37.1052 + ( gmyth_socket, hostname_backend, port, blocking_client, TRUE ) )
37.1053 + {
37.1054 gmyth_debug
37.1055 - ("Could not open socket to backend machine in order to receive events [%s]\n",
37.1056 - hostname_backend);
37.1057 + ( "Could not open socket to backend machine in order to receive events [%s]\n",
37.1058 + hostname_backend );
37.1059 return FALSE;
37.1060 }
37.1061
37.1062 @@ -861,7 +912,7 @@
37.1063 * @param gmyth_socket The GMythSocket instance.
37.1064 */
37.1065 void
37.1066 -gmyth_socket_close_connection (GMythSocket * gmyth_socket)
37.1067 +gmyth_socket_close_connection ( GMythSocket * gmyth_socket )
37.1068 {
37.1069 /*
37.1070 if ( gmyth_socket->sd != -1 ) {
37.1071 @@ -870,9 +921,10 @@
37.1072 }
37.1073 */
37.1074
37.1075 - if (gmyth_socket->sd_io_ch != NULL) {
37.1076 - g_io_channel_shutdown (gmyth_socket->sd_io_ch, TRUE, NULL);
37.1077 - g_io_channel_unref (gmyth_socket->sd_io_ch);
37.1078 + if ( gmyth_socket->sd_io_ch != NULL )
37.1079 + {
37.1080 + g_io_channel_shutdown ( gmyth_socket->sd_io_ch, TRUE, NULL );
37.1081 + g_io_channel_unref ( gmyth_socket->sd_io_ch );
37.1082 gmyth_socket->sd_io_ch = NULL;
37.1083 gmyth_socket->sd = -1;
37.1084 }
37.1085 @@ -890,8 +942,8 @@
37.1086 * @return The actual MythTV the client is connected to.
37.1087 */
37.1088 gint
37.1089 -gmyth_socket_check_protocol_version_number (GMythSocket * gmyth_socket,
37.1090 - gint mythtv_version)
37.1091 +gmyth_socket_check_protocol_version_number ( GMythSocket * gmyth_socket,
37.1092 + gint mythtv_version )
37.1093 {
37.1094 GString *response = NULL;
37.1095 GString *payload = NULL;
37.1096 @@ -899,47 +951,54 @@
37.1097 gint mythtv_new_version = MYTHTV_CANNOT_NEGOTIATE_VERSION;
37.1098 guint max_iterations = MYTHTV_MAX_VERSION_CHECKS;
37.1099
37.1100 - assert (gmyth_socket);
37.1101 + assert ( gmyth_socket );
37.1102
37.1103 try_new_version:
37.1104 - payload = g_string_new ("MYTH_PROTO_VERSION");
37.1105 - g_string_append_printf (payload, " %d", mythtv_version);
37.1106 + payload = g_string_new ( "MYTH_PROTO_VERSION" );
37.1107 + g_string_append_printf ( payload, " %d", mythtv_version );
37.1108
37.1109 - gmyth_socket_send_command (gmyth_socket, payload);
37.1110 - response = gmyth_socket_receive_response (gmyth_socket);
37.1111 + gmyth_socket_send_command ( gmyth_socket, payload );
37.1112 + response = gmyth_socket_receive_response ( gmyth_socket );
37.1113
37.1114 - if (response == NULL) {
37.1115 - gmyth_debug ("[%s] Check protocol version error! Not answered!",
37.1116 - __FUNCTION__);
37.1117 + if ( response == NULL )
37.1118 + {
37.1119 + gmyth_debug ( "[%s] Check protocol version error! Not answered!",
37.1120 + __FUNCTION__ );
37.1121 res = FALSE;
37.1122 goto done;
37.1123 }
37.1124
37.1125 - res = g_str_has_prefix (response->str, "ACCEPT");
37.1126 - if (!res) {
37.1127 - gmyth_debug ("[%s] Protocol version request error: %s", __FUNCTION__,
37.1128 - response->str);
37.1129 + res = g_str_has_prefix ( response->str, "ACCEPT" );
37.1130 + if ( !res )
37.1131 + {
37.1132 + gmyth_debug ( "[%s] Protocol version request error: %s", __FUNCTION__,
37.1133 + response->str );
37.1134 /* get the version number returned by the REJECT message */
37.1135 - if ((res = g_str_has_prefix (response->str, "REJECT")) == TRUE) {
37.1136 + if ( ( res = g_str_has_prefix ( response->str, "REJECT" ) ) == TRUE )
37.1137 + {
37.1138 gchar *new_version = NULL;
37.1139
37.1140 - new_version = g_strrstr (response->str, "]");
37.1141 - if (new_version != NULL) {
37.1142 + new_version = g_strrstr ( response->str, "]" );
37.1143 + if ( new_version != NULL )
37.1144 + {
37.1145 ++new_version; /* skip ']' character */
37.1146 - if (new_version != NULL) {
37.1147 - gmyth_debug ("[%s] got MythTV version = %s.\n",
37.1148 - __FUNCTION__, new_version);
37.1149 + if ( new_version != NULL )
37.1150 + {
37.1151 + gmyth_debug ( "[%s] got MythTV version = %s.\n",
37.1152 + __FUNCTION__, new_version );
37.1153 mythtv_version =
37.1154 - (gint) g_ascii_strtoull (new_version, NULL, 10);
37.1155 + ( gint ) g_ascii_strtoull ( new_version, NULL, 10 );
37.1156 /* do reconnection to the socket (socket is closed if the MythTV version was wrong) */
37.1157 - gmyth_socket_connect (gmyth_socket, gmyth_socket->hostname,
37.1158 - gmyth_socket->port);
37.1159 + gmyth_socket_connect ( gmyth_socket, gmyth_socket->hostname,
37.1160 + gmyth_socket->port );
37.1161 new_version = NULL;
37.1162 - if (--max_iterations > 0) {
37.1163 - g_string_free (payload, TRUE);
37.1164 - g_string_free (response, TRUE);
37.1165 + if ( --max_iterations > 0 )
37.1166 + {
37.1167 + g_string_free ( payload, TRUE );
37.1168 + g_string_free ( response, TRUE );
37.1169 goto try_new_version;
37.1170 - } else
37.1171 + }
37.1172 + else
37.1173 goto done;
37.1174 }
37.1175 }
37.1176 @@ -947,14 +1006,15 @@
37.1177 }
37.1178
37.1179 /* change the return value to a valid one */
37.1180 - if (res) {
37.1181 + if ( res )
37.1182 + {
37.1183 mythtv_new_version = mythtv_version;
37.1184 gmyth_socket->mythtv_version = mythtv_new_version;
37.1185 }
37.1186
37.1187 done:
37.1188 - g_string_free (payload, TRUE);
37.1189 - g_string_free (response, TRUE);
37.1190 + g_string_free ( payload, TRUE );
37.1191 + g_string_free ( response, TRUE );
37.1192
37.1193 return mythtv_new_version;
37.1194 }
37.1195 @@ -965,12 +1025,12 @@
37.1196 * @return TRUE if supports, FALSE if not.
37.1197 */
37.1198 gboolean
37.1199 -gmyth_socket_check_protocol_version (GMythSocket * gmyth_socket)
37.1200 +gmyth_socket_check_protocol_version ( GMythSocket * gmyth_socket )
37.1201 {
37.1202 - return ((gmyth_socket->mythtv_version =
37.1203 - gmyth_socket_check_protocol_version_number (gmyth_socket,
37.1204 - MYTHTV_VERSION_DEFAULT))
37.1205 - != MYTHTV_CANNOT_NEGOTIATE_VERSION);
37.1206 + return ( ( gmyth_socket->mythtv_version =
37.1207 + gmyth_socket_check_protocol_version_number ( gmyth_socket,
37.1208 + MYTHTV_VERSION_DEFAULT ) )
37.1209 + != MYTHTV_CANNOT_NEGOTIATE_VERSION );
37.1210 }
37.1211
37.1212 /** Returns the Mythtv backend supported version.
37.1213 @@ -979,7 +1039,7 @@
37.1214 * @return The actual MythTV version number.
37.1215 */
37.1216 gint
37.1217 -gmyth_socket_get_protocol_version (GMythSocket * gmyth_socket)
37.1218 +gmyth_socket_get_protocol_version ( GMythSocket * gmyth_socket )
37.1219 {
37.1220 return gmyth_socket->mythtv_version;
37.1221 }
37.1222 @@ -990,7 +1050,7 @@
37.1223 * @return The response received, or NULL if error or nothing was received.
37.1224 */
37.1225 GString *
37.1226 -gmyth_socket_receive_response (GMythSocket * gmyth_socket)
37.1227 +gmyth_socket_receive_response ( GMythSocket * gmyth_socket )
37.1228 {
37.1229 GIOStatus io_status = G_IO_STATUS_NORMAL;
37.1230 GError *error = NULL;
37.1231 @@ -1001,48 +1061,53 @@
37.1232 gsize bytes_read = 0;
37.1233 gint len = 0;
37.1234
37.1235 - if (gmyth_socket == NULL)
37.1236 + if ( gmyth_socket == NULL )
37.1237 return NULL;
37.1238
37.1239 GIOCondition io_cond;
37.1240
37.1241 /* verify if the input (read) buffer is ready to receive data */
37.1242 - g_mutex_lock (gmyth_socket->mutex);
37.1243 + g_mutex_lock ( gmyth_socket->mutex );
37.1244
37.1245 - buffer = g_strnfill (MYTH_PROTOCOL_FIELD_SIZE, ' ');
37.1246 - if (NULL == gmyth_socket->sd_io_ch) {
37.1247 - gmyth_socket_connect (gmyth_socket, gmyth_socket->hostname,
37.1248 - gmyth_socket->port);
37.1249 + buffer = g_strnfill ( MYTH_PROTOCOL_FIELD_SIZE, ' ' );
37.1250 + if ( NULL == gmyth_socket->sd_io_ch )
37.1251 + {
37.1252 + gmyth_socket_connect ( gmyth_socket, gmyth_socket->hostname,
37.1253 + gmyth_socket->port );
37.1254 }
37.1255
37.1256 - io_cond = g_io_channel_get_buffer_condition (gmyth_socket->sd_io_ch);
37.1257 + io_cond = g_io_channel_get_buffer_condition ( gmyth_socket->sd_io_ch );
37.1258 /*
37.1259 if ( NULL == gmyth_socket->sd_io_ch->read_buf || ( NULL == gmyth_socket->sd_io_ch->read_buf->str ) )
37.1260 gmyth_socket->sd_io_ch = g_io_channel_unix_new( gmyth_socket->sd );
37.1261 */
37.1262
37.1263 - if (gmyth_socket->sd_io_ch->
37.1264 - is_readable /*&& !( ( io_cond & G_IO_IN ) == 0 ) */ )
37.1265 + if ( gmyth_socket->sd_io_ch->
37.1266 + is_readable /*&& !( ( io_cond & G_IO_IN ) == 0 ) */ )
37.1267 io_status =
37.1268 - g_io_channel_read_chars (gmyth_socket->sd_io_ch, buffer,
37.1269 - MYTH_PROTOCOL_FIELD_SIZE, &bytes_read, &error);
37.1270 + g_io_channel_read_chars ( gmyth_socket->sd_io_ch, buffer,
37.1271 + MYTH_PROTOCOL_FIELD_SIZE, &bytes_read,
37.1272 + &error );
37.1273 else
37.1274 - return g_string_new ("");
37.1275 + return g_string_new ( "" );
37.1276
37.1277 /* verify if the input (read) buffer is ready to receive data */
37.1278 - io_cond = g_io_channel_get_buffer_condition (gmyth_socket->sd_io_ch);
37.1279 + io_cond = g_io_channel_get_buffer_condition ( gmyth_socket->sd_io_ch );
37.1280
37.1281 //if ( ( io_cond & G_IO_IN ) == 0 )
37.1282 // return NULL;
37.1283
37.1284 - gmyth_debug ("[%s] Bytes read = %d\n", __FUNCTION__, bytes_read);
37.1285 + gmyth_debug ( "[%s] Bytes read = %d\n", __FUNCTION__, bytes_read );
37.1286
37.1287 - if ((io_status == G_IO_STATUS_ERROR) || (bytes_read <= 0)) {
37.1288 - gmyth_debug ("[%s] Error in mythprotocol response from backend\n",
37.1289 - __FUNCTION__);
37.1290 + if ( ( io_status == G_IO_STATUS_ERROR ) || ( bytes_read <= 0 ) )
37.1291 + {
37.1292 + gmyth_debug ( "[%s] Error in mythprotocol response from backend\n",
37.1293 + __FUNCTION__ );
37.1294 str = NULL;
37.1295 //return NULL;
37.1296 - } else if (buffer != NULL && strlen (buffer) > 0) {
37.1297 + }
37.1298 + else if ( buffer != NULL && strlen ( buffer ) > 0 )
37.1299 + {
37.1300
37.1301 //io_status = g_io_channel_flush( gmyth_socket->sd_io_ch, &error );
37.1302 /* verify if the input (read) buffer is ready to receive data */
37.1303 @@ -1053,9 +1118,9 @@
37.1304
37.1305 /* removes trailing whitespace */
37.1306 //buffer_aux = g_strstrip (buffer);
37.1307 - len = (gint) g_ascii_strtoull (g_strstrip (buffer), NULL, 10);
37.1308 + len = ( gint ) g_ascii_strtoull ( g_strstrip ( buffer ), NULL, 10 );
37.1309
37.1310 - g_free (buffer);
37.1311 + g_free ( buffer );
37.1312
37.1313 /*
37.1314 if (buffer_aux != NULL) {
37.1315 @@ -1064,41 +1129,42 @@
37.1316 }
37.1317 */
37.1318
37.1319 - buffer = g_new0 (gchar, len + 1);
37.1320 + buffer = g_new0 ( gchar, len + 1 );
37.1321
37.1322 bytes_read = 0;
37.1323 - if (!(gmyth_socket != NULL && gmyth_socket->sd_io_ch != NULL))
37.1324 + if ( !( gmyth_socket != NULL && gmyth_socket->sd_io_ch != NULL ) )
37.1325 return NULL;
37.1326
37.1327 - if (gmyth_socket->sd_io_ch->is_readable)
37.1328 + if ( gmyth_socket->sd_io_ch->is_readable )
37.1329 io_status =
37.1330 - g_io_channel_read_chars (gmyth_socket->sd_io_ch, buffer, len,
37.1331 - &bytes_read, &error);
37.1332 + g_io_channel_read_chars ( gmyth_socket->sd_io_ch, buffer, len,
37.1333 + &bytes_read, &error );
37.1334 else
37.1335 - return g_string_new ("");
37.1336 + return g_string_new ( "" );
37.1337
37.1338 buffer[bytes_read] = '\0';
37.1339 //}
37.1340 }
37.1341
37.1342 - g_mutex_unlock (gmyth_socket->mutex);
37.1343 + g_mutex_unlock ( gmyth_socket->mutex );
37.1344 //g_static_rw_lock_reader_unlock (&rwlock);
37.1345
37.1346 - gmyth_debug ("Response received from backend: ----- {%s}\n", buffer);
37.1347 - if ((bytes_read != len) || (io_status == G_IO_STATUS_ERROR))
37.1348 + gmyth_debug ( "Response received from backend: ----- {%s}\n", buffer );
37.1349 + if ( ( bytes_read != len ) || ( io_status == G_IO_STATUS_ERROR ) )
37.1350 str = NULL;
37.1351 else
37.1352 - str = g_string_new (buffer);
37.1353 + str = g_string_new ( buffer );
37.1354
37.1355 - if (error != NULL) {
37.1356 + if ( error != NULL )
37.1357 + {
37.1358 gmyth_debug
37.1359 - ("[%s] Error found receiving response from the IO channel: (%d, %s)\n",
37.1360 - __FUNCTION__, error->code, error->message);
37.1361 + ( "[%s] Error found receiving response from the IO channel: (%d, %s)\n",
37.1362 + __FUNCTION__, error->code, error->message );
37.1363 str = NULL;
37.1364 - g_error_free (error);
37.1365 + g_error_free ( error );
37.1366 }
37.1367
37.1368 - g_free (buffer);
37.1369 + g_free ( buffer );
37.1370 return str;
37.1371 }
37.1372
37.1373 @@ -1109,49 +1175,56 @@
37.1374 * @return TRUE if command was sent, FALSE if any error happens.
37.1375 */
37.1376 gboolean
37.1377 -gmyth_socket_write_stringlist (GMythSocket * gmyth_socket,
37.1378 - GMythStringList * str_list)
37.1379 +gmyth_socket_write_stringlist ( GMythSocket * gmyth_socket,
37.1380 + GMythStringList * str_list )
37.1381 {
37.1382
37.1383 GList *tmp_list = NULL;
37.1384 GPtrArray *ptr_array = NULL;
37.1385 gchar *str_array = NULL;
37.1386
37.1387 - g_mutex_lock (gmyth_socket->mutex);
37.1388 + g_mutex_lock ( gmyth_socket->mutex );
37.1389 //g_static_rw_lock_writer_lock (&rwlock);
37.1390
37.1391 - ptr_array = g_ptr_array_sized_new (g_list_length (str_list->glist));
37.1392 + ptr_array = g_ptr_array_sized_new ( g_list_length ( str_list->glist ) );
37.1393
37.1394 // FIXME: change this implementation!
37.1395 tmp_list = str_list->glist;
37.1396 - for (; tmp_list; tmp_list = tmp_list->next) {
37.1397 - if (tmp_list->data != NULL) {
37.1398 - g_ptr_array_add (ptr_array, ((GString *) tmp_list->data)->str);
37.1399 - } else {
37.1400 - g_ptr_array_add (ptr_array, "");
37.1401 + for ( ; tmp_list; tmp_list = tmp_list->next )
37.1402 + {
37.1403 + if ( tmp_list->data != NULL )
37.1404 + {
37.1405 + g_ptr_array_add ( ptr_array,
37.1406 + ( ( GString * ) tmp_list->data )->str );
37.1407 + }
37.1408 + else
37.1409 + {
37.1410 + g_ptr_array_add ( ptr_array, "" );
37.1411 }
37.1412 }
37.1413 - g_ptr_array_add (ptr_array, NULL); // g_str_joinv() needs a NULL terminated string
37.1414 + g_ptr_array_add ( ptr_array, NULL ); // g_str_joinv() needs a NULL terminated string
37.1415
37.1416 - str_array = g_strjoinv (MYTH_SEPARATOR, (gchar **) (ptr_array->pdata));
37.1417 + str_array =
37.1418 + g_strjoinv ( MYTH_SEPARATOR, ( gchar ** ) ( ptr_array->pdata ) );
37.1419
37.1420 - g_mutex_unlock (gmyth_socket->mutex);
37.1421 + g_mutex_unlock ( gmyth_socket->mutex );
37.1422 //g_static_rw_lock_writer_unlock (&rwlock);
37.1423
37.1424 - gmyth_debug ("[%s] Sending socket request: %s\n", __FUNCTION__, str_array);
37.1425 + gmyth_debug ( "[%s] Sending socket request: %s\n", __FUNCTION__,
37.1426 + str_array );
37.1427
37.1428 // Sends message to backend
37.1429 // TODO: implement looping to send remaining data, and add timeout testing!
37.1430 - GString *command = g_string_new (str_array);
37.1431 + GString *command = g_string_new ( str_array );
37.1432
37.1433 - gmyth_socket_send_command (gmyth_socket, command);
37.1434 + gmyth_socket_send_command ( gmyth_socket, command );
37.1435
37.1436 - g_string_free (command, TRUE);
37.1437 + g_string_free ( command, TRUE );
37.1438
37.1439 - g_free (str_array);
37.1440 + g_free ( str_array );
37.1441
37.1442 /* ptr_array is pointing to data inside str_list->glist */
37.1443 - g_ptr_array_free (ptr_array, TRUE);
37.1444 + g_ptr_array_free ( ptr_array, TRUE );
37.1445
37.1446 return TRUE;
37.1447 }
37.1448 @@ -1163,34 +1236,36 @@
37.1449 * @return The number of received strings.
37.1450 */
37.1451 gint
37.1452 -gmyth_socket_read_stringlist (GMythSocket * gmyth_socket,
37.1453 - GMythStringList * str_list)
37.1454 +gmyth_socket_read_stringlist ( GMythSocket * gmyth_socket,
37.1455 + GMythStringList * str_list )
37.1456 {
37.1457 GString *response;
37.1458 gint i;
37.1459
37.1460 - gmyth_string_list_clear_all (str_list);
37.1461 + gmyth_string_list_clear_all ( str_list );
37.1462
37.1463 - response = gmyth_socket_receive_response (gmyth_socket);
37.1464 - if (response != NULL && response->str != NULL && response->len > 0) {
37.1465 + response = gmyth_socket_receive_response ( gmyth_socket );
37.1466 + if ( response != NULL && response->str != NULL && response->len > 0 )
37.1467 + {
37.1468 gchar **str_array;
37.1469
37.1470 - g_mutex_lock (gmyth_socket->mutex);
37.1471 + g_mutex_lock ( gmyth_socket->mutex );
37.1472
37.1473 - str_array = g_strsplit (response->str, MYTH_SEPARATOR, -1);
37.1474 + str_array = g_strsplit ( response->str, MYTH_SEPARATOR, -1 );
37.1475
37.1476 - for (i = 0; i < g_strv_length (str_array); i++) {
37.1477 + for ( i = 0; i < g_strv_length ( str_array ); i++ )
37.1478 + {
37.1479 //if ( str_array[i] != NULL && strlen( str_array[i] ) > 0 )
37.1480 - gmyth_string_list_append_char_array (str_list, str_array[i]);
37.1481 + gmyth_string_list_append_char_array ( str_list, str_array[i] );
37.1482 }
37.1483
37.1484 - g_mutex_unlock (gmyth_socket->mutex);
37.1485 - g_strfreev (str_array);
37.1486 + g_mutex_unlock ( gmyth_socket->mutex );
37.1487 + g_strfreev ( str_array );
37.1488 }
37.1489
37.1490 - g_string_free (response, TRUE);
37.1491 + g_string_free ( response, TRUE );
37.1492
37.1493 - return gmyth_string_list_length (str_list);
37.1494 + return gmyth_string_list_length ( str_list );
37.1495 }
37.1496
37.1497 /** Formats a Mythtv protocol command based on str_list and sends it to
37.1498 @@ -1203,10 +1278,10 @@
37.1499 * error happens.
37.1500 */
37.1501 gint
37.1502 -gmyth_socket_sendreceive_stringlist (GMythSocket * gmyth_socket,
37.1503 - GMythStringList * str_list)
37.1504 +gmyth_socket_sendreceive_stringlist ( GMythSocket * gmyth_socket,
37.1505 + GMythStringList * str_list )
37.1506 {
37.1507 - gmyth_socket_write_stringlist (gmyth_socket, str_list);
37.1508 + gmyth_socket_write_stringlist ( gmyth_socket, str_list );
37.1509
37.1510 - return gmyth_socket_read_stringlist (gmyth_socket, str_list);
37.1511 + return gmyth_socket_read_stringlist ( gmyth_socket, str_list );
37.1512 }
38.1 --- a/gmyth/src/gmyth_socket.h Wed May 23 19:21:26 2007 +0100
38.2 +++ b/gmyth/src/gmyth_socket.h Wed May 23 19:50:41 2007 +0100
38.3 @@ -13,22 +13,21 @@
38.4 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
38.5 * @author Rosfran Lins Borges <rosfran.borges@indt.org.br>
38.6 *
38.7 - *//*
38.8 - *
38.9 - * This program is free software; you can redistribute it and/or modify
38.10 - * it under the terms of the GNU Lesser General Public License as published by
38.11 - * the Free Software Foundation; either version 2 of the License, or
38.12 - * (at your option) any later version.
38.13 - *
38.14 - * This program is distributed in the hope that it will be useful,
38.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
38.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38.17 - * GNU General Public License for more details.
38.18 - *
38.19 - * You should have received a copy of the GNU Lesser General Public License
38.20 - * along with this program; if not, write to the Free Software
38.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
38.22 - */
38.23 + *
38.24 + * This program is free software; you can redistribute it and/or modify
38.25 + * it under the terms of the GNU Lesser General Public License as published by
38.26 + * the Free Software Foundation; either version 2 of the License, or
38.27 + * (at your option) any later version.
38.28 + *
38.29 + * This program is distributed in the hope that it will be useful,
38.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
38.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38.32 + * GNU General Public License for more details.
38.33 + *
38.34 + * You should have received a copy of the GNU Lesser General Public License
38.35 + * along with this program; if not, write to the Free Software
38.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
38.37 + */
38.38
38.39 #ifndef __GMYTH_SOCKET_H__
38.40 #define __GMYTH_SOCKET_H__
38.41 @@ -54,72 +53,77 @@
38.42 typedef struct _GMythSocketClass GMythSocketClass;
38.43
38.44 struct _GMythSocketClass
38.45 -{
38.46 - GObjectClass parent_class;
38.47 + {
38.48 + GObjectClass parent_class;
38.49
38.50 - /* callbacks */
38.51 - /* no one for now */
38.52 -};
38.53 + /* callbacks */
38.54 + /* no one for now */
38.55 + };
38.56
38.57 struct _GMythSocket
38.58 -{
38.59 - GObject parent;
38.60 + {
38.61 + GObject parent;
38.62
38.63 - GMutex *mutex;
38.64 + GMutex *mutex;
38.65
38.66 - /* socket descriptor */
38.67 - gint sd;
38.68 - GIOChannel *sd_io_ch;
38.69 + /* socket descriptor */
38.70 + gint sd;
38.71 + GIOChannel *sd_io_ch;
38.72
38.73 - gchar *hostname;
38.74 - gint port;
38.75 - gint mythtv_version;
38.76 -};
38.77 + gchar *hostname;
38.78 + gint port;
38.79 + gint mythtv_version;
38.80 + };
38.81
38.82 /* used when no protocol version number was negotiated */
38.83 #define MYTHTV_CANNOT_NEGOTIATE_VERSION 0
38.84
38.85 -GType gmyth_socket_get_type (void);
38.86 +GType gmyth_socket_get_type ( void );
38.87
38.88 -GMythSocket *gmyth_socket_new ();
38.89 +GMythSocket *gmyth_socket_new ( );
38.90
38.91 -GIOChannel *gmyth_socket_get_io_channel (GMythSocket * gmyth_socket);
38.92 +GIOChannel *gmyth_socket_get_io_channel ( GMythSocket * gmyth_socket );
38.93
38.94 -gboolean gmyth_socket_is_able_to_read (GMythSocket * gmyth_socket);
38.95 -gboolean gmyth_socket_is_able_to_write (GMythSocket * gmyth_socket);
38.96 +gboolean gmyth_socket_is_able_to_read ( GMythSocket * gmyth_socket );
38.97 +gboolean gmyth_socket_is_able_to_write ( GMythSocket * gmyth_socket );
38.98
38.99 -gboolean gmyth_socket_send_command (GMythSocket * gmyth_socket,
38.100 - GString * command);
38.101 -GString *gmyth_socket_receive_response (GMythSocket * gmyth_socket);
38.102 -gint gmyth_socket_sendreceive_stringlist (GMythSocket * gmyth_socket,
38.103 - GMythStringList * str_list);
38.104 +gboolean gmyth_socket_send_command ( GMythSocket * gmyth_socket,
38.105 + GString * command );
38.106 +GString *gmyth_socket_receive_response ( GMythSocket * gmyth_socket );
38.107 +gint gmyth_socket_sendreceive_stringlist ( GMythSocket * gmyth_socket,
38.108 + GMythStringList * str_list );
38.109
38.110 -gboolean gmyth_socket_connect (GMythSocket * gmyth_socket,
38.111 - const gchar * hostname, gint port);
38.112 -gboolean gmyth_socket_connect_with_timeout (GMythSocket * gmyth_socket,
38.113 - const gchar * hostname, gint port, guint timeout);
38.114 +gboolean gmyth_socket_connect ( GMythSocket * gmyth_socket,
38.115 + const gchar * hostname, gint port );
38.116 +gboolean gmyth_socket_connect_with_timeout ( GMythSocket * gmyth_socket,
38.117 + const gchar * hostname, gint port,
38.118 + guint timeout );
38.119
38.120 -gboolean gmyth_socket_connect_to_backend (GMythSocket * gmyth_socket,
38.121 - const gchar * hostname_backend, gint port, gboolean blocking_client);
38.122 +gboolean gmyth_socket_connect_to_backend ( GMythSocket * gmyth_socket,
38.123 + const gchar * hostname_backend,
38.124 + gint port,
38.125 + gboolean blocking_client );
38.126
38.127 -gboolean gmyth_socket_connect_to_backend_events (GMythSocket * gmyth_socket,
38.128 - const gchar * hostname_backend, gint port, gboolean blocking_client);
38.129 +gboolean gmyth_socket_connect_to_backend_events ( GMythSocket * gmyth_socket,
38.130 + const gchar *
38.131 + hostname_backend, gint port,
38.132 + gboolean blocking_client );
38.133
38.134 -gchar *gmyth_socket_get_primary_addr (void);
38.135 +gchar *gmyth_socket_get_primary_addr ( void );
38.136
38.137 -GString *gmyth_socket_get_local_hostname (void);
38.138 +GString *gmyth_socket_get_local_hostname ( void );
38.139
38.140 -void gmyth_socket_close_connection (GMythSocket * gmyth_socket);
38.141 +void gmyth_socket_close_connection ( GMythSocket * gmyth_socket );
38.142
38.143 -gboolean gmyth_socket_check_protocol_version (GMythSocket * gmyth_socket);
38.144 -gint gmyth_socket_check_protocol_version_number (GMythSocket * gmyth_socket,
38.145 - gint mythtv_version);
38.146 +gboolean gmyth_socket_check_protocol_version ( GMythSocket * gmyth_socket );
38.147 +gint gmyth_socket_check_protocol_version_number ( GMythSocket * gmyth_socket,
38.148 + gint mythtv_version );
38.149
38.150 -gint gmyth_socket_get_protocol_version (GMythSocket * gmyth_socket);
38.151 +gint gmyth_socket_get_protocol_version ( GMythSocket * gmyth_socket );
38.152
38.153 -gboolean gmyth_socket_write_stringlist (GMythSocket * gmyth_socket,
38.154 - GMythStringList * str_list);
38.155 -gint gmyth_socket_read_stringlist (GMythSocket * gmyth_socket,
38.156 - GMythStringList * str_list);
38.157 +gboolean gmyth_socket_write_stringlist ( GMythSocket * gmyth_socket,
38.158 + GMythStringList * str_list );
38.159 +gint gmyth_socket_read_stringlist ( GMythSocket * gmyth_socket,
38.160 + GMythStringList * str_list );
38.161 G_END_DECLS
38.162 #endif /* __GMYTH_SOCKET_H__ */
39.1 --- a/gmyth/src/gmyth_stringlist.c Wed May 23 19:21:26 2007 +0100
39.2 +++ b/gmyth/src/gmyth_stringlist.c Wed May 23 19:50:41 2007 +0100
39.3 @@ -9,22 +9,21 @@
39.4 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
39.5 * @author Hallyson Luiz de Morais Melo <hallyson.melo@indt.org.br>
39.6 *
39.7 - *//*
39.8 - *
39.9 - * This program is free software; you can redistribute it and/or modify
39.10 - * it under the terms of the GNU Lesser General Public License as published by
39.11 - * the Free Software Foundation; either version 2 of the License, or
39.12 - * (at your option) any later version.
39.13 - *
39.14 - * This program is distributed in the hope that it will be useful,
39.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
39.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39.17 - * GNU General Public License for more details.
39.18 - *
39.19 - * You should have received a copy of the GNU Lesser General Public License
39.20 - * along with this program; if not, write to the Free Software
39.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
39.22 - */
39.23 + *
39.24 + * This program is free software; you can redistribute it and/or modify
39.25 + * it under the terms of the GNU Lesser General Public License as published by
39.26 + * the Free Software Foundation; either version 2 of the License, or
39.27 + * (at your option) any later version.
39.28 + *
39.29 + * This program is distributed in the hope that it will be useful,
39.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
39.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39.32 + * GNU General Public License for more details.
39.33 + *
39.34 + * You should have received a copy of the GNU Lesser General Public License
39.35 + * along with this program; if not, write to the Free Software
39.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
39.37 + */
39.38
39.39 #ifdef HAVE_CONFIG_H
39.40 #include "config.h"
39.41 @@ -34,47 +33,47 @@
39.42
39.43 #include "gmyth_debug.h"
39.44
39.45 -static void gmyth_string_list_class_init (GMythStringListClass * klass);
39.46 -static void gmyth_string_list_init (GMythStringList * object);
39.47 +static void gmyth_string_list_class_init ( GMythStringListClass * klass );
39.48 +static void gmyth_string_list_init ( GMythStringList * object );
39.49
39.50 -static void gmyth_string_list_dispose (GObject * object);
39.51 -static void gmyth_string_list_finalize (GObject * object);
39.52 +static void gmyth_string_list_dispose ( GObject * object );
39.53 +static void gmyth_string_list_finalize ( GObject * object );
39.54
39.55 -G_DEFINE_TYPE (GMythStringList, gmyth_string_list, G_TYPE_OBJECT)
39.56 - static void gmyth_string_list_class_init (GMythStringListClass * klass)
39.57 +G_DEFINE_TYPE ( GMythStringList, gmyth_string_list, G_TYPE_OBJECT )
39.58 + static void gmyth_string_list_class_init ( GMythStringListClass * klass )
39.59 {
39.60 GObjectClass *gobject_class;
39.61
39.62 - gobject_class = (GObjectClass *) klass;
39.63 + gobject_class = ( GObjectClass * ) klass;
39.64
39.65 gobject_class->dispose = gmyth_string_list_dispose;
39.66 gobject_class->finalize = gmyth_string_list_finalize;
39.67 }
39.68
39.69 static void
39.70 -gmyth_string_list_init (GMythStringList * gmyth_string_list)
39.71 +gmyth_string_list_init ( GMythStringList * gmyth_string_list )
39.72 {
39.73 gmyth_string_list->glist = NULL;
39.74 }
39.75
39.76 static void
39.77 -gmyth_string_list_dispose (GObject * object)
39.78 +gmyth_string_list_dispose ( GObject * object )
39.79 {
39.80 - GMythStringList *gmyth_string_list = GMYTH_STRING_LIST (object);
39.81 + GMythStringList *gmyth_string_list = GMYTH_STRING_LIST ( object );
39.82
39.83 - gmyth_string_list_clear_all (gmyth_string_list);
39.84 + gmyth_string_list_clear_all ( gmyth_string_list );
39.85
39.86 - G_OBJECT_CLASS (gmyth_string_list_parent_class)->dispose (object);
39.87 + G_OBJECT_CLASS ( gmyth_string_list_parent_class )->dispose ( object );
39.88 }
39.89
39.90 static void
39.91 -gmyth_string_list_finalize (GObject * object)
39.92 +gmyth_string_list_finalize ( GObject * object )
39.93 {
39.94 //GMythStringList *gmyth_string_list = GMYTH_STRING_LIST(object);
39.95
39.96 - g_signal_handlers_destroy (object);
39.97 + g_signal_handlers_destroy ( object );
39.98
39.99 - G_OBJECT_CLASS (gmyth_string_list_parent_class)->finalize (object);
39.100 + G_OBJECT_CLASS ( gmyth_string_list_parent_class )->finalize ( object );
39.101 }
39.102
39.103 /** Creates a new instance of GStringList.
39.104 @@ -82,10 +81,10 @@
39.105 * @return a new instance of GStringList.
39.106 */
39.107 GMythStringList *
39.108 -gmyth_string_list_new ()
39.109 +gmyth_string_list_new ( )
39.110 {
39.111 GMythStringList *gmyth_string_list =
39.112 - GMYTH_STRING_LIST (g_object_new (GMYTH_STRING_LIST_TYPE, NULL));
39.113 + GMYTH_STRING_LIST ( g_object_new ( GMYTH_STRING_LIST_TYPE, NULL ) );
39.114
39.115 return gmyth_string_list;
39.116 }
39.117 @@ -98,13 +97,13 @@
39.118 * @return The appended guint64 converted to a GString object.
39.119 */
39.120 GString *
39.121 -gmyth_string_list_append_int (GMythStringList * strlist, const gint value)
39.122 +gmyth_string_list_append_int ( GMythStringList * strlist, const gint value )
39.123 {
39.124 - GString *value_str = g_string_new ("");
39.125 + GString *value_str = g_string_new ( "" );
39.126
39.127 - g_string_printf (value_str, "%d", value);
39.128 + g_string_printf ( value_str, "%d", value );
39.129
39.130 - strlist->glist = g_list_append (strlist->glist, value_str);
39.131 + strlist->glist = g_list_append ( strlist->glist, value_str );
39.132
39.133 return value_str;
39.134 }
39.135 @@ -117,29 +116,30 @@
39.136 * @return The appended guint64 converted to a GString object.
39.137 */
39.138 GString *
39.139 -gmyth_string_list_append_uint64 (GMythStringList * strlist, const guint64 value)
39.140 +gmyth_string_list_append_uint64 ( GMythStringList * strlist,
39.141 + const guint64 value )
39.142 {
39.143 - GString *tmp_str1 = g_string_new ("");
39.144 - GString *tmp_str2 = g_string_new ("");
39.145 + GString *tmp_str1 = g_string_new ( "" );
39.146 + GString *tmp_str2 = g_string_new ( "" );
39.147
39.148 - gmyth_debug ("value = %llu.\n", value);
39.149 + gmyth_debug ( "value = %llu.\n", value );
39.150
39.151 - gulong l2 = ((guint64) value & 0xffffffff);
39.152 - gulong l1 = ((guint64) value >> 32);
39.153 + gulong l2 = ( ( guint64 ) value & 0xffffffff );
39.154 + gulong l1 = ( ( guint64 ) value >> 32 );
39.155
39.156 /* high order part of guint64 value */
39.157 - g_string_printf (tmp_str1, "%lu", l1);
39.158 + g_string_printf ( tmp_str1, "%lu", l1 );
39.159
39.160 - gmyth_debug ("[%s] uint64 (high) = %s\n", __FUNCTION__, tmp_str1->str);
39.161 + gmyth_debug ( "[%s] uint64 (high) = %s\n", __FUNCTION__, tmp_str1->str );
39.162
39.163 - strlist->glist = g_list_append (strlist->glist, tmp_str1);
39.164 + strlist->glist = g_list_append ( strlist->glist, tmp_str1 );
39.165
39.166 /* low order part of guint64 value */
39.167 - g_string_printf (tmp_str2, "%lu", l2);
39.168 + g_string_printf ( tmp_str2, "%lu", l2 );
39.169
39.170 - gmyth_debug ("[%s] uint64 (low) = %s\n", __FUNCTION__, tmp_str2->str);
39.171 + gmyth_debug ( "[%s] uint64 (low) = %s\n", __FUNCTION__, tmp_str2->str );
39.172
39.173 - strlist->glist = g_list_append (strlist->glist, tmp_str2);
39.174 + strlist->glist = g_list_append ( strlist->glist, tmp_str2 );
39.175
39.176 return tmp_str2;
39.177 }
39.178 @@ -152,29 +152,29 @@
39.179 * @return The appended gint64 converted to a GString object.
39.180 */
39.181 GString *
39.182 -gmyth_string_list_append_int64 (GMythStringList * strlist, const gint64 value)
39.183 +gmyth_string_list_append_int64 ( GMythStringList * strlist, const gint64 value )
39.184 {
39.185 - GString *tmp_str1 = g_string_new ("");
39.186 - GString *tmp_str2 = g_string_new ("");
39.187 + GString *tmp_str1 = g_string_new ( "" );
39.188 + GString *tmp_str2 = g_string_new ( "" );
39.189
39.190 - gmyth_debug ("value = %lld.\n", value);
39.191 + gmyth_debug ( "value = %lld.\n", value );
39.192
39.193 - glong l2 = ((gint64) value & 0xffffffff);
39.194 - glong l1 = ((gint64) value >> 32);
39.195 + glong l2 = ( ( gint64 ) value & 0xffffffff );
39.196 + glong l1 = ( ( gint64 ) value >> 32 );
39.197
39.198 /* high order part of gint64 value */
39.199 - g_string_printf (tmp_str1, "%ld", l1);
39.200 + g_string_printf ( tmp_str1, "%ld", l1 );
39.201
39.202 - gmyth_debug ("[%s] int64 (high) = %s\n", __FUNCTION__, tmp_str1->str);
39.203 + gmyth_debug ( "[%s] int64 (high) = %s\n", __FUNCTION__, tmp_str1->str );
39.204
39.205 - strlist->glist = g_list_append (strlist->glist, tmp_str1);
39.206 + strlist->glist = g_list_append ( strlist->glist, tmp_str1 );
39.207
39.208 /* low order part of gint64 value */
39.209 - g_string_printf (tmp_str2, "%ld", l2);
39.210 + g_string_printf ( tmp_str2, "%ld", l2 );
39.211
39.212 - gmyth_debug ("[%s] int64 (low) = %s\n", __FUNCTION__, tmp_str2->str);
39.213 + gmyth_debug ( "[%s] int64 (low) = %s\n", __FUNCTION__, tmp_str2->str );
39.214
39.215 - strlist->glist = g_list_append (strlist->glist, tmp_str2);
39.216 + strlist->glist = g_list_append ( strlist->glist, tmp_str2 );
39.217
39.218 return tmp_str2;
39.219 }
39.220 @@ -187,16 +187,16 @@
39.221 * @return The appended char array converted to a GString object.
39.222 */
39.223 GString *
39.224 -gmyth_string_list_append_char_array (GMythStringList * strlist,
39.225 - const gchar * value)
39.226 +gmyth_string_list_append_char_array ( GMythStringList * strlist,
39.227 + const gchar * value )
39.228 {
39.229 GString *tmp_str = NULL;
39.230
39.231 - g_return_val_if_fail (strlist != NULL, NULL);
39.232 + g_return_val_if_fail ( strlist != NULL, NULL );
39.233
39.234 - tmp_str = g_string_new (value);
39.235 + tmp_str = g_string_new ( value );
39.236
39.237 - strlist->glist = g_list_append (strlist->glist, tmp_str);
39.238 + strlist->glist = g_list_append ( strlist->glist, tmp_str );
39.239
39.240 return tmp_str;
39.241 }
39.242 @@ -209,15 +209,18 @@
39.243 * @return The appended string itself.
39.244 */
39.245 GString *
39.246 -gmyth_string_list_append_string (GMythStringList * strlist, GString * value)
39.247 +gmyth_string_list_append_string ( GMythStringList * strlist, GString * value )
39.248 {
39.249 - g_return_val_if_fail (strlist != NULL, NULL);
39.250 + g_return_val_if_fail ( strlist != NULL, NULL );
39.251
39.252 - if (value != NULL) {
39.253 + if ( value != NULL )
39.254 + {
39.255 strlist->glist =
39.256 - g_list_append (strlist->glist, g_string_new (value->str));
39.257 - } else {
39.258 - strlist->glist = g_list_append (strlist->glist, NULL);
39.259 + g_list_append ( strlist->glist, g_string_new ( value->str ) );
39.260 + }
39.261 + else
39.262 + {
39.263 + strlist->glist = g_list_append ( strlist->glist, NULL );
39.264 }
39.265
39.266 return value;
39.267 @@ -230,20 +233,21 @@
39.268 * @return The integer value.
39.269 */
39.270 gint
39.271 -gmyth_string_list_get_int (GMythStringList * strlist, const gint index)
39.272 +gmyth_string_list_get_int ( GMythStringList * strlist, const gint index )
39.273 {
39.274 //TODO: Create static method check_index()
39.275 GString *tmp_str = NULL;
39.276
39.277 - g_return_val_if_fail (strlist != NULL, 0);
39.278 + g_return_val_if_fail ( strlist != NULL, 0 );
39.279
39.280 - tmp_str = (GString *) g_list_nth_data (strlist->glist, index);
39.281 + tmp_str = ( GString * ) g_list_nth_data ( strlist->glist, index );
39.282
39.283 - if (NULL == tmp_str || NULL == tmp_str->str || strlen (tmp_str->str) <= 0)
39.284 + if ( NULL == tmp_str || NULL == tmp_str->str
39.285 + || strlen ( tmp_str->str ) <= 0 )
39.286 return 0;
39.287
39.288 - return (gint) ( /* 0x00000000ffffffffL & (gint64) */
39.289 - g_ascii_strtoull (tmp_str->str, NULL, 10));
39.290 + return ( gint ) ( /* 0x00000000ffffffffL & (gint64) */
39.291 + g_ascii_strtoull ( tmp_str->str, NULL, 10 ) );
39.292 }
39.293
39.294 /** Gets a guint64 value from the string list at the given position.
39.295 @@ -256,45 +260,54 @@
39.296 * @return The guint64 value.
39.297 */
39.298 guint64
39.299 -gmyth_string_list_get_uint64 (GMythStringList * strlist, const gint index)
39.300 +gmyth_string_list_get_uint64 ( GMythStringList * strlist, const gint index )
39.301 {
39.302 //TODO: Create static method check_index()
39.303 guint64 ret_value = 0;
39.304 guint64 l2 = 0;
39.305
39.306 - g_return_val_if_fail (strlist != NULL, 0);
39.307 + g_return_val_if_fail ( strlist != NULL, 0 );
39.308
39.309 const GString *tmp_str1 =
39.310 - (GString *) g_list_nth_data (strlist->glist, index);
39.311 + ( GString * ) g_list_nth_data ( strlist->glist, index );
39.312 const GString *tmp_str2 =
39.313 - (GString *) g_list_nth_data (strlist->glist, index + 1);
39.314 + ( GString * ) g_list_nth_data ( strlist->glist, index + 1 );
39.315
39.316 - if (tmp_str1 != NULL)
39.317 - gmyth_debug ("[%s] seek high bytes = %s\n", __FUNCTION__,
39.318 - tmp_str1->str);
39.319 - if (tmp_str2 == NULL || strlen (tmp_str2->str) > 0) {
39.320 - } else {
39.321 - gmyth_debug ("[%s] seek low bytes = %s\n", __FUNCTION__, tmp_str2->str);
39.322 + if ( tmp_str1 != NULL )
39.323 + gmyth_debug ( "[%s] seek high bytes = %s\n", __FUNCTION__,
39.324 + tmp_str1->str );
39.325 + if ( tmp_str2 == NULL || strlen ( tmp_str2->str ) > 0 )
39.326 + {
39.327 + }
39.328 + else
39.329 + {
39.330 + gmyth_debug ( "[%s] seek low bytes = %s\n", __FUNCTION__,
39.331 + tmp_str2->str );
39.332 }
39.333
39.334 - guint64 l1 = ((guint64) g_ascii_strtoull (tmp_str1->str, NULL, 10) /*& 0xffffffff */
39.335 - );
39.336 + guint64 l1 = ( ( guint64 ) g_ascii_strtoull ( tmp_str1->str, NULL, 10 ) /*& 0xffffffff */
39.337 + );
39.338
39.339 - if (tmp_str2 != NULL && tmp_str2->str != NULL && strlen (tmp_str2->str) > 0) {
39.340 - l2 = ((guint64) g_ascii_strtoull (tmp_str2->str, NULL, 10)
39.341 - /*& 0xffffffff */
39.342 - );
39.343 - } else {
39.344 + if ( tmp_str2 != NULL && tmp_str2->str != NULL
39.345 + && strlen ( tmp_str2->str ) > 0 )
39.346 + {
39.347 + l2 = ( ( guint64 ) g_ascii_strtoull ( tmp_str2->str, NULL, 10 )
39.348 + /*& 0xffffffff */
39.349 + );
39.350 + }
39.351 + else
39.352 + {
39.353 l2 = l1;
39.354 l1 = 0;
39.355 }
39.356
39.357 - gmyth_debug ("[%s]\t[l1 == %llu, l2 == %llu]\n", __FUNCTION__, l1, l2);
39.358 + gmyth_debug ( "[%s]\t[l1 == %llu, l2 == %llu]\n", __FUNCTION__, l1, l2 );
39.359
39.360 - ret_value = ((guint64) (l2) /*& 0xffffffff */ ) | ((guint64) l1 << 32);
39.361 + ret_value =
39.362 + ( ( guint64 ) ( l2 ) /*& 0xffffffff */ ) | ( ( guint64 ) l1 << 32 );
39.363
39.364 - gmyth_debug ("[%s] returning uint64 value = %llu\n", __FUNCTION__,
39.365 - ret_value);
39.366 + gmyth_debug ( "[%s] returning uint64 value = %llu\n", __FUNCTION__,
39.367 + ret_value );
39.368
39.369 return ret_value;
39.370 }
39.371 @@ -309,45 +322,54 @@
39.372 * @return The gint64 value.
39.373 */
39.374 gint64
39.375 -gmyth_string_list_get_int64 (GMythStringList * strlist, const gint index)
39.376 +gmyth_string_list_get_int64 ( GMythStringList * strlist, const gint index )
39.377 {
39.378 //TODO: Create static method check_index()
39.379 gint64 ret_value = 0;
39.380 gint64 l2 = 0;
39.381
39.382 - g_return_val_if_fail (strlist != NULL, 0);
39.383 + g_return_val_if_fail ( strlist != NULL, 0 );
39.384
39.385 const GString *tmp_str1 =
39.386 - (GString *) g_list_nth_data (strlist->glist, index);
39.387 + ( GString * ) g_list_nth_data ( strlist->glist, index );
39.388 const GString *tmp_str2 =
39.389 - (GString *) g_list_nth_data (strlist->glist, index + 1);
39.390 + ( GString * ) g_list_nth_data ( strlist->glist, index + 1 );
39.391
39.392 - if (tmp_str1 != NULL)
39.393 - gmyth_debug ("[%s] seek high bytes = %s\n", __FUNCTION__,
39.394 - tmp_str1->str);
39.395 - if (tmp_str2 == NULL || strlen (tmp_str2->str) > 0) {
39.396 - } else {
39.397 - gmyth_debug ("[%s] seek low bytes = %s\n", __FUNCTION__, tmp_str2->str);
39.398 + if ( tmp_str1 != NULL )
39.399 + gmyth_debug ( "[%s] seek high bytes = %s\n", __FUNCTION__,
39.400 + tmp_str1->str );
39.401 + if ( tmp_str2 == NULL || strlen ( tmp_str2->str ) > 0 )
39.402 + {
39.403 + }
39.404 + else
39.405 + {
39.406 + gmyth_debug ( "[%s] seek low bytes = %s\n", __FUNCTION__,
39.407 + tmp_str2->str );
39.408 }
39.409
39.410 - gint64 l1 = ((guint64) g_ascii_strtoull (tmp_str1->str, NULL, 10) /*& 0xffffffff */
39.411 - );
39.412 + gint64 l1 = ( ( guint64 ) g_ascii_strtoull ( tmp_str1->str, NULL, 10 ) /*& 0xffffffff */
39.413 + );
39.414
39.415 - if (tmp_str2 != NULL && tmp_str2->str != NULL && strlen (tmp_str2->str) > 0) {
39.416 - l2 = ((gint64) g_ascii_strtoull (tmp_str2->str, NULL, 10)
39.417 - /*& 0xffffffff */
39.418 - );
39.419 - } else {
39.420 + if ( tmp_str2 != NULL && tmp_str2->str != NULL
39.421 + && strlen ( tmp_str2->str ) > 0 )
39.422 + {
39.423 + l2 = ( ( gint64 ) g_ascii_strtoull ( tmp_str2->str, NULL, 10 )
39.424 + /*& 0xffffffff */
39.425 + );
39.426 + }
39.427 + else
39.428 + {
39.429 l2 = l1;
39.430 l1 = 0;
39.431 }
39.432
39.433 - gmyth_debug ("[%s]\t[l1 == %lld, l2 == %lld]\n", __FUNCTION__, l1, l2);
39.434 + gmyth_debug ( "[%s]\t[l1 == %lld, l2 == %lld]\n", __FUNCTION__, l1, l2 );
39.435
39.436 - ret_value = ((gint64) (l2) /*& 0xffffffff */ ) | ((gint64) l1 << 32);
39.437 + ret_value =
39.438 + ( ( gint64 ) ( l2 ) /*& 0xffffffff */ ) | ( ( gint64 ) l1 << 32 );
39.439
39.440 - gmyth_debug ("[%s] returning int64 value = %lld\n", __FUNCTION__,
39.441 - ret_value);
39.442 + gmyth_debug ( "[%s] returning int64 value = %lld\n", __FUNCTION__,
39.443 + ret_value );
39.444
39.445 return ret_value;
39.446 }
39.447 @@ -360,26 +382,27 @@
39.448 * @return A pointer to the string data.
39.449 */
39.450 GString *
39.451 -gmyth_string_list_get_string (GMythStringList * strlist, const gint index)
39.452 +gmyth_string_list_get_string ( GMythStringList * strlist, const gint index )
39.453 {
39.454 GString *ret;
39.455
39.456 - if (!strlist || !(strlist->glist)) {
39.457 - gmyth_debug ("%s received Null arguments", __FUNCTION__);
39.458 + if ( !strlist || !( strlist->glist ) )
39.459 + {
39.460 + gmyth_debug ( "%s received Null arguments", __FUNCTION__ );
39.461 return NULL;
39.462 }
39.463
39.464 - ret = (GString *) g_list_nth_data (strlist->glist, index);
39.465 + ret = ( GString * ) g_list_nth_data ( strlist->glist, index );
39.466
39.467 - return g_string_new (ret->str);
39.468 + return g_string_new ( ret->str );
39.469 }
39.470
39.471
39.472 static void
39.473 -gmyth_string_list_clear_element (GString * str_elem, void *data_aux)
39.474 +gmyth_string_list_clear_element ( GString * str_elem, void *data_aux )
39.475 {
39.476 - if (str_elem != NULL)
39.477 - g_string_free (str_elem, TRUE);
39.478 + if ( str_elem != NULL )
39.479 + g_string_free ( str_elem, TRUE );
39.480 }
39.481
39.482 /** Removes all strings from the string list.
39.483 @@ -387,12 +410,13 @@
39.484 * @param strlist The GMythStringList instance.
39.485 */
39.486 void
39.487 -gmyth_string_list_clear_all (GMythStringList * strlist)
39.488 +gmyth_string_list_clear_all ( GMythStringList * strlist )
39.489 {
39.490 - if (strlist != NULL && strlist->glist) {
39.491 - g_list_foreach (strlist->glist,
39.492 - (GFunc) gmyth_string_list_clear_element, NULL);
39.493 - g_list_free (strlist->glist);
39.494 + if ( strlist != NULL && strlist->glist )
39.495 + {
39.496 + g_list_foreach ( strlist->glist,
39.497 + ( GFunc ) gmyth_string_list_clear_element, NULL );
39.498 + g_list_free ( strlist->glist );
39.499 strlist->glist = NULL;
39.500 }
39.501 }
39.502 @@ -403,10 +427,10 @@
39.503 * @return the string list length.
39.504 */
39.505 gint
39.506 -gmyth_string_list_length (GMythStringList * strlist)
39.507 +gmyth_string_list_length ( GMythStringList * strlist )
39.508 {
39.509 - if (!(strlist != NULL && strlist->glist != NULL))
39.510 + if ( !( strlist != NULL && strlist->glist != NULL ) )
39.511 return 0;
39.512
39.513 - return g_list_length (strlist->glist);
39.514 + return g_list_length ( strlist->glist );
39.515 }
40.1 --- a/gmyth/src/gmyth_stringlist.h Wed May 23 19:21:26 2007 +0100
40.2 +++ b/gmyth/src/gmyth_stringlist.h Wed May 23 19:50:41 2007 +0100
40.3 @@ -9,22 +9,21 @@
40.4 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
40.5 * @author Hallyson Luiz de Morais Melo <hallyson.melo@indt.org.br>
40.6 *
40.7 - *//*
40.8 - *
40.9 - * This program is free software; you can redistribute it and/or modify
40.10 - * it under the terms of the GNU Lesser General Public License as published by
40.11 - * the Free Software Foundation; either version 2 of the License, or
40.12 - * (at your option) any later version.
40.13 - *
40.14 - * This program is distributed in the hope that it will be useful,
40.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
40.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40.17 - * GNU General Public License for more details.
40.18 - *
40.19 - * You should have received a copy of the GNU Lesser General Public License
40.20 - * along with this program; if not, write to the Free Software
40.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
40.22 - */
40.23 + *
40.24 + * This program is free software; you can redistribute it and/or modify
40.25 + * it under the terms of the GNU Lesser General Public License as published by
40.26 + * the Free Software Foundation; either version 2 of the License, or
40.27 + * (at your option) any later version.
40.28 + *
40.29 + * This program is distributed in the hope that it will be useful,
40.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
40.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40.32 + * GNU General Public License for more details.
40.33 + *
40.34 + * You should have received a copy of the GNU Lesser General Public License
40.35 + * along with this program; if not, write to the Free Software
40.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
40.37 + */
40.38
40.39 #ifndef GMYTH_STRING_LIST_H_
40.40 #define GMYTH_STRING_LIST_H_
40.41 @@ -49,52 +48,52 @@
40.42 typedef struct _GMythStringListClass GMythStringListClass;
40.43
40.44 struct _GMythStringListClass
40.45 -{
40.46 - GObjectClass parent_class;
40.47 + {
40.48 + GObjectClass parent_class;
40.49
40.50 - /* callbacks */
40.51 - /* no one for now */
40.52 -};
40.53 + /* callbacks */
40.54 + /* no one for now */
40.55 + };
40.56
40.57 struct _GMythStringList
40.58 -{
40.59 - GObject parent;
40.60 + {
40.61 + GObject parent;
40.62
40.63 - /* string list */
40.64 - GList *glist;
40.65 -};
40.66 + /* string list */
40.67 + GList *glist;
40.68 + };
40.69
40.70
40.71 -GType gmyth_string_list_get_type (void);
40.72 +GType gmyth_string_list_get_type ( void );
40.73
40.74 -GMythStringList *gmyth_string_list_new (void);
40.75 +GMythStringList *gmyth_string_list_new ( void );
40.76
40.77 -void gmyth_string_list_clear_all (GMythStringList * strlist);
40.78 -int gmyth_string_list_length (GMythStringList * strlist);
40.79 +void gmyth_string_list_clear_all ( GMythStringList * strlist );
40.80 +int gmyth_string_list_length ( GMythStringList * strlist );
40.81
40.82 -GString *gmyth_string_list_append_int (GMythStringList * strlist,
40.83 - const gint value);
40.84 -GString *gmyth_string_list_append_uint64 (GMythStringList * strlist,
40.85 - const guint64 value);
40.86 +GString *gmyth_string_list_append_int ( GMythStringList * strlist,
40.87 + const gint value );
40.88 +GString *gmyth_string_list_append_uint64 ( GMythStringList * strlist,
40.89 + const guint64 value );
40.90
40.91 -GString *gmyth_string_list_append_int64 (GMythStringList * strlist,
40.92 - const gint64 value);
40.93 +GString *gmyth_string_list_append_int64 ( GMythStringList * strlist,
40.94 + const gint64 value );
40.95
40.96 -GString *gmyth_string_list_append_char_array (GMythStringList * strlist,
40.97 - const char *value);
40.98 -GString *gmyth_string_list_append_string (GMythStringList * strlist,
40.99 - GString * value);
40.100 +GString *gmyth_string_list_append_char_array ( GMythStringList * strlist,
40.101 + const char *value );
40.102 +GString *gmyth_string_list_append_string ( GMythStringList * strlist,
40.103 + GString * value );
40.104
40.105 -int gmyth_string_list_get_int (GMythStringList * strlist, const gint index);
40.106 -guint64 gmyth_string_list_get_uint64 (GMythStringList * strlist,
40.107 - const gint index);
40.108 -gint64 gmyth_string_list_get_int64 (GMythStringList * strlist,
40.109 - const gint index);
40.110 -GString *gmyth_string_list_get_string (GMythStringList * strlist,
40.111 - const gint index);
40.112 +int gmyth_string_list_get_int ( GMythStringList * strlist, const gint index );
40.113 +guint64 gmyth_string_list_get_uint64 ( GMythStringList * strlist,
40.114 + const gint index );
40.115 +gint64 gmyth_string_list_get_int64 ( GMythStringList * strlist,
40.116 + const gint index );
40.117 +GString *gmyth_string_list_get_string ( GMythStringList * strlist,
40.118 + const gint index );
40.119
40.120 #define gmyth_string_list_get_char_array(strlist, index) \
40.121 - (gmyth_string_list_get_string(strlist, index))->str
40.122 + (gmyth_string_list_get_string(strlist, index))->str
40.123
40.124 G_END_DECLS
40.125 #endif /*GMYTH_STRING_LIST_H_ */
41.1 --- a/gmyth/src/gmyth_transcoder.c Wed May 23 19:21:26 2007 +0100
41.2 +++ b/gmyth/src/gmyth_transcoder.c Wed May 23 19:50:41 2007 +0100
41.3 @@ -8,8 +8,6 @@
41.4 * Copyright (C) 2007 INdT - Instituto Nokia de Tecnologia.
41.5 * @author Artur Duque de Souza <artur.souza@indt.org.br>
41.6 *
41.7 - */
41.8 -/*
41.9 *
41.10 * This program is free software; you can redistribute it and/or modify
41.11 * it under the terms of the GNU Lesser General Public License as published by
41.12 @@ -41,48 +39,48 @@
41.13 #include "gmyth_jobqueue.h"
41.14 #include "gmyth_transcoder.h"
41.15
41.16 -static void gmyth_transcoder_class_init (GMythTranscoderClass * klass);
41.17 -static void gmyth_transcoder_init (GMythTranscoder * object);
41.18 +static void gmyth_transcoder_class_init ( GMythTranscoderClass * klass );
41.19 +static void gmyth_transcoder_init ( GMythTranscoder * object );
41.20
41.21 -static void gmyth_transcoder_dispose (GObject * object);
41.22 -static void gmyth_transcoder_finalize (GObject * object);
41.23 +static void gmyth_transcoder_dispose ( GObject * object );
41.24 +static void gmyth_transcoder_finalize ( GObject * object );
41.25
41.26 -G_DEFINE_TYPE (GMythTranscoder, gmyth_transcoder, G_TYPE_OBJECT)
41.27 - static void gmyth_transcoder_class_init (GMythTranscoderClass * klass)
41.28 +G_DEFINE_TYPE ( GMythTranscoder, gmyth_transcoder, G_TYPE_OBJECT )
41.29 + static void gmyth_transcoder_class_init ( GMythTranscoderClass * klass )
41.30 {
41.31 - GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
41.32 + GObjectClass *gobject_class = G_OBJECT_CLASS ( klass );
41.33
41.34 gobject_class->dispose = gmyth_transcoder_dispose;
41.35 gobject_class->finalize = gmyth_transcoder_finalize;
41.36 }
41.37
41.38 static void
41.39 -gmyth_transcoder_init (GMythTranscoder * transcoder)
41.40 +gmyth_transcoder_init ( GMythTranscoder * transcoder )
41.41 {
41.42 transcoder->started = FALSE;
41.43 }
41.44
41.45 static void
41.46 -gmyth_transcoder_dispose (GObject * object)
41.47 +gmyth_transcoder_dispose ( GObject * object )
41.48 {
41.49 - GMythTranscoder *transcoder = GMYTH_TRANSCODER (object);
41.50 + GMythTranscoder *transcoder = GMYTH_TRANSCODER ( object );
41.51
41.52 - g_free (transcoder->output_filename);
41.53 - g_free (transcoder->filename);
41.54 - g_free (transcoder->profile);
41.55 - g_free (transcoder->starttime);
41.56 + g_free ( transcoder->output_filename );
41.57 + g_free ( transcoder->filename );
41.58 + g_free ( transcoder->profile );
41.59 + g_free ( transcoder->starttime );
41.60
41.61 - if (transcoder->backend_info)
41.62 - g_object_unref (transcoder->backend_info);
41.63 + if ( transcoder->backend_info )
41.64 + g_object_unref ( transcoder->backend_info );
41.65
41.66 - G_OBJECT_CLASS (gmyth_transcoder_parent_class)->dispose (object);
41.67 + G_OBJECT_CLASS ( gmyth_transcoder_parent_class )->dispose ( object );
41.68 }
41.69
41.70 static void
41.71 -gmyth_transcoder_finalize (GObject * object)
41.72 +gmyth_transcoder_finalize ( GObject * object )
41.73 {
41.74 - g_signal_handlers_destroy (object);
41.75 - G_OBJECT_CLASS (gmyth_transcoder_parent_class)->finalize (object);
41.76 + g_signal_handlers_destroy ( object );
41.77 + G_OBJECT_CLASS ( gmyth_transcoder_parent_class )->finalize ( object );
41.78 }
41.79
41.80 /**
41.81 @@ -91,13 +89,14 @@
41.82 * @return a new instance of GMythTranscoder.
41.83 **/
41.84 GMythTranscoder *
41.85 -gmyth_transcoder_new (GMythBackendInfo * backend_info)
41.86 +gmyth_transcoder_new ( GMythBackendInfo * backend_info )
41.87 {
41.88 GMythTranscoder *transcoder = GMYTH_TRANSCODER
41.89 - (g_object_new (GMYTH_TRANSCODER_TYPE, NULL));
41.90 + ( g_object_new ( GMYTH_TRANSCODER_TYPE, NULL ) );
41.91
41.92 - if (backend_info != NULL) {
41.93 - g_object_ref (backend_info);
41.94 + if ( backend_info != NULL )
41.95 + {
41.96 + g_object_ref ( backend_info );
41.97 transcoder->backend_info = backend_info;
41.98 }
41.99
41.100 @@ -113,37 +112,42 @@
41.101 *
41.102 **/
41.103 static gchar *
41.104 -gmyth_transcoder_date_change_format (gchar * date_s, int format)
41.105 +gmyth_transcoder_date_change_format ( gchar * date_s, int format )
41.106 {
41.107 - if (date_s != NULL) {
41.108 - gint length = strlen (date_s);
41.109 + if ( date_s != NULL )
41.110 + {
41.111 + gint length = strlen ( date_s );
41.112
41.113 //create the right date format
41.114 - gchar *src = (gchar *) g_malloc0 (sizeof (gchar) * length);
41.115 + gchar *src = ( gchar * ) g_malloc0 ( sizeof ( gchar ) * length );
41.116
41.117 - strncpy (src, date_s, length);
41.118 + strncpy ( src, date_s, length );
41.119
41.120 gchar *dst;
41.121
41.122 - if (format == DATE_FILE) {
41.123 - dst = (gchar *) g_malloc0 (sizeof (gchar) * 16);
41.124 - snprintf (dst, 16, "%.4s%.2s%.2s%.2s%.2s%.2s", src, src + 5,
41.125 - src + 7, src + 9, src + 11, src + 13);
41.126 + if ( format == DATE_FILE )
41.127 + {
41.128 + dst = ( gchar * ) g_malloc0 ( sizeof ( gchar ) * 16 );
41.129 + snprintf ( dst, 16, "%.4s%.2s%.2s%.2s%.2s%.2s", src, src + 5,
41.130 + src + 7, src + 9, src + 11, src + 13 );
41.131 dst[15] = '\0';
41.132 - } else if (format == DATE_ISO) {
41.133 - dst = (gchar *) g_malloc0 (sizeof (gchar) * 20);
41.134 - snprintf (dst, 20, "%.4s-%.2s-%.2sT%.2s:%.2s:%.2s", src, src + 4,
41.135 - src + 6, src + 8, src + 10, src + 12);
41.136 + }
41.137 + else if ( format == DATE_ISO )
41.138 + {
41.139 + dst = ( gchar * ) g_malloc0 ( sizeof ( gchar ) * 20 );
41.140 + snprintf ( dst, 20, "%.4s-%.2s-%.2sT%.2s:%.2s:%.2s", src, src + 4,
41.141 + src + 6, src + 8, src + 10, src + 12 );
41.142 dst[19] = '\0';
41.143 }
41.144
41.145 - gchar *ret = g_strdup (dst);
41.146 + gchar *ret = g_strdup ( dst );
41.147
41.148 - g_free (src);
41.149 - g_free (dst);
41.150 + g_free ( src );
41.151 + g_free ( dst );
41.152
41.153 return ret;
41.154 - } else
41.155 + }
41.156 + else
41.157 return NULL;
41.158 }
41.159
41.160 @@ -156,11 +160,11 @@
41.161 *
41.162 **/
41.163 void
41.164 -gmyth_transcoder_set_output (GMythTranscoder * transcoder,
41.165 - gboolean value, const gchar * outputfile)
41.166 +gmyth_transcoder_set_output ( GMythTranscoder * transcoder,
41.167 + gboolean value, const gchar * outputfile )
41.168 {
41.169 transcoder->output = value;
41.170 - transcoder->output_filename = g_strdup (outputfile);
41.171 + transcoder->output_filename = g_strdup ( outputfile );
41.172 }
41.173
41.174 /**
41.175 @@ -171,23 +175,25 @@
41.176 *
41.177 **/
41.178 void
41.179 -gmyth_transcoder_set_filename (GMythTranscoder * transcoder, const gchar * file)
41.180 +gmyth_transcoder_set_filename ( GMythTranscoder * transcoder,
41.181 + const gchar * file )
41.182 {
41.183 // fixme: if this method is called twice, memory will not be dealocated
41.184 // one transcoder can be used only for one file request?
41.185 - if (file != NULL) {
41.186 - gchar **splited = g_strsplit (file, "_", 2);
41.187 + if ( file != NULL )
41.188 + {
41.189 + gchar **splited = g_strsplit ( file, "_", 2 );
41.190
41.191 // Get chanid
41.192 - sscanf (splited[0], "%d", &(transcoder->chanid));
41.193 + sscanf ( splited[0], "%d", &( transcoder->chanid ) );
41.194
41.195 // Get starttime
41.196 - gchar **date = g_strsplit (splited[1], ".", 2);
41.197 + gchar **date = g_strsplit ( splited[1], ".", 2 );
41.198
41.199 transcoder->starttime =
41.200 - gmyth_transcoder_date_change_format (date[0], DATE_ISO);
41.201 + gmyth_transcoder_date_change_format ( date[0], DATE_ISO );
41.202
41.203 - transcoder->filename = g_strdup (file);
41.204 + transcoder->filename = g_strdup ( file );
41.205 }
41.206 }
41.207
41.208 @@ -202,70 +208,74 @@
41.209 *
41.210 **/
41.211 gint
41.212 -gmyth_transcoder_set_profile (GMythTranscoder * trans, const gchar * value)
41.213 +gmyth_transcoder_set_profile ( GMythTranscoder * trans, const gchar * value )
41.214 {
41.215 - g_return_val_if_fail (value != NULL, -1);
41.216 + g_return_val_if_fail ( value != NULL, -1 );
41.217
41.218 - trans->profile = g_strndup (value, strlen (value));
41.219 + trans->profile = g_strndup ( value, strlen ( value ) );
41.220
41.221 return 0;
41.222 }
41.223
41.224 gboolean
41.225 -gmyth_transcoder_start (GMythTranscoder * trans)
41.226 +gmyth_transcoder_start ( GMythTranscoder * trans )
41.227 {
41.228 - g_return_val_if_fail (trans != NULL, FALSE);
41.229 - g_return_val_if_fail (trans->backend_info != NULL, FALSE);
41.230 - g_return_val_if_fail (trans->filename != NULL, FALSE);
41.231 + g_return_val_if_fail ( trans != NULL, FALSE );
41.232 + g_return_val_if_fail ( trans->backend_info != NULL, FALSE );
41.233 + g_return_val_if_fail ( trans->filename != NULL, FALSE );
41.234
41.235 - if (trans->started == FALSE) { // not started yet
41.236 - if (!gmyth_util_file_exists (trans->backend_info, trans->filename)) {
41.237 - gmyth_debug ("File %s does not exist", trans->filename);
41.238 + if ( trans->started == FALSE )
41.239 + { // not started yet
41.240 + if ( !gmyth_util_file_exists ( trans->backend_info, trans->filename ) )
41.241 + {
41.242 + gmyth_debug ( "File %s does not exist", trans->filename );
41.243 }
41.244 - trans->started = gmyth_jobqueue_add_job (trans, "JOB_TRANSCODE");
41.245 - if (trans->started == FALSE)
41.246 - gmyth_debug ("Error while starting GMythTranscoder to file: %s",
41.247 - trans->output_filename);
41.248 - } else {
41.249 - gmyth_debug ("GMythTransfer already started!");
41.250 + trans->started = gmyth_jobqueue_add_job ( trans, "JOB_TRANSCODE" );
41.251 + if ( trans->started == FALSE )
41.252 + gmyth_debug ( "Error while starting GMythTranscoder to file: %s",
41.253 + trans->output_filename );
41.254 + }
41.255 + else
41.256 + {
41.257 + gmyth_debug ( "GMythTransfer already started!" );
41.258 }
41.259
41.260 return trans->started;
41.261 }
41.262
41.263 gboolean
41.264 -gmyth_transcoder_pause (GMythTranscoder * trans)
41.265 +gmyth_transcoder_pause ( GMythTranscoder * trans )
41.266 {
41.267 - g_return_val_if_fail (trans != NULL, FALSE);
41.268 - g_return_val_if_fail (trans->started == TRUE, FALSE);
41.269 + g_return_val_if_fail ( trans != NULL, FALSE );
41.270 + g_return_val_if_fail ( trans->started == TRUE, FALSE );
41.271
41.272 - return gmyth_jobqueue_change_cmd (trans, "PAUSE", "JOB_TRANSCODE");
41.273 + return gmyth_jobqueue_change_cmd ( trans, "PAUSE", "JOB_TRANSCODE" );
41.274 }
41.275
41.276 gboolean
41.277 -gmyth_transcoder_resume (GMythTranscoder * trans)
41.278 +gmyth_transcoder_resume ( GMythTranscoder * trans )
41.279 {
41.280 - g_return_val_if_fail (trans != NULL, FALSE);
41.281 + g_return_val_if_fail ( trans != NULL, FALSE );
41.282
41.283 - return gmyth_jobqueue_change_cmd (trans, "RESUME", "JOB_TRANSCODE");
41.284 + return gmyth_jobqueue_change_cmd ( trans, "RESUME", "JOB_TRANSCODE" );
41.285 }
41.286
41.287 gboolean
41.288 -gmyth_transcoder_cancel (GMythTranscoder * trans)
41.289 +gmyth_transcoder_cancel ( GMythTranscoder * trans )
41.290 {
41.291 - g_return_val_if_fail (trans != NULL, FALSE);
41.292 - g_return_val_if_fail (trans->started == TRUE, FALSE);
41.293 + g_return_val_if_fail ( trans != NULL, FALSE );
41.294 + g_return_val_if_fail ( trans->started == TRUE, FALSE );
41.295
41.296 trans->started = FALSE;
41.297
41.298 - return gmyth_jobqueue_change_cmd (trans, "STOP", "JOB_TRANSCODE");
41.299 + return gmyth_jobqueue_change_cmd ( trans, "STOP", "JOB_TRANSCODE" );
41.300 }
41.301
41.302 //fixme: implement this method
41.303 gint
41.304 -gmyth_transcoder_get_progress (GMythTranscoder * trans)
41.305 +gmyth_transcoder_get_progress ( GMythTranscoder * trans )
41.306 {
41.307 static int fixme = 0;
41.308
41.309 - return (fixme++) % 101;
41.310 + return ( fixme++ ) % 101;
41.311 }
42.1 --- a/gmyth/src/gmyth_transcoder.h Wed May 23 19:21:26 2007 +0100
42.2 +++ b/gmyth/src/gmyth_transcoder.h Wed May 23 19:50:41 2007 +0100
42.3 @@ -7,9 +7,6 @@
42.4 *
42.5 * Copyright (C) 2007 INdT - Instituto Nokia de Tecnologia.
42.6 * @author Artur Duque de Souza <artur.souza@indt.org.br>
42.7 - *
42.8 - */
42.9 -/*
42.10 *
42.11 * This program is free software; you can redistribute it and/or modify
42.12 * it under the terms of the GNU Lesser General Public License as published by
42.13 @@ -51,51 +48,51 @@
42.14 typedef struct _GMythTranscoderClass GMythTranscoderClass;
42.15
42.16 struct _GMythTranscoderClass
42.17 -{
42.18 - GObjectClass parent_class;
42.19 + {
42.20 + GObjectClass parent_class;
42.21
42.22 - /* callbacks */
42.23 -};
42.24 + /* callbacks */
42.25 + };
42.26
42.27 /**
42.28 * The GMythTranscoder structure is a class to implement functions
42.29 * related to transcoding.
42.30 */
42.31 struct _GMythTranscoder
42.32 -{
42.33 - GObject parent;
42.34 + {
42.35 + GObject parent;
42.36
42.37 - gboolean cutlist;
42.38 - gboolean output;
42.39 - gboolean started;
42.40 + gboolean cutlist;
42.41 + gboolean output;
42.42 + gboolean started;
42.43
42.44 - /* private begin */
42.45 - gchar *output_filename;
42.46 - gchar *filename;
42.47 - gchar *profile;
42.48 - /* private end */
42.49 + /* private begin */
42.50 + gchar *output_filename;
42.51 + gchar *filename;
42.52 + gchar *profile;
42.53 + /* private end */
42.54
42.55 - gchar *starttime;
42.56 + gchar *starttime;
42.57
42.58 - gint chanid;
42.59 + gint chanid;
42.60
42.61 - GMythBackendInfo *backend_info;
42.62 -};
42.63 + GMythBackendInfo *backend_info;
42.64 + };
42.65
42.66 -GType gmyth_transcoder_type (void);
42.67 +GType gmyth_transcoder_type ( void );
42.68
42.69 -GMythTranscoder *gmyth_transcoder_new (GMythBackendInfo * backend_info);
42.70 -void gmyth_transcoder_set_output (GMythTranscoder * transcode,
42.71 - gboolean value, const gchar * outputfile);
42.72 -void gmyth_transcoder_set_filename (GMythTranscoder * transcode,
42.73 - const gchar * file);
42.74 -gint gmyth_transcoder_set_profile (GMythTranscoder * trans,
42.75 - const gchar * value);
42.76 -gboolean gmyth_transcoder_start (GMythTranscoder * trans);
42.77 -gboolean gmyth_transcoder_pause (GMythTranscoder * trans);
42.78 -gboolean gmyth_transcoder_resume (GMythTranscoder * trans);
42.79 -gboolean gmyth_transcoder_cancel (GMythTranscoder * trans);
42.80 -gint gmyth_transcoder_get_progress (GMythTranscoder * trans);
42.81 +GMythTranscoder *gmyth_transcoder_new ( GMythBackendInfo * backend_info );
42.82 +void gmyth_transcoder_set_output ( GMythTranscoder * transcode,
42.83 + gboolean value, const gchar * outputfile );
42.84 +void gmyth_transcoder_set_filename ( GMythTranscoder * transcode,
42.85 + const gchar * file );
42.86 +gint gmyth_transcoder_set_profile ( GMythTranscoder * trans,
42.87 + const gchar * value );
42.88 +gboolean gmyth_transcoder_start ( GMythTranscoder * trans );
42.89 +gboolean gmyth_transcoder_pause ( GMythTranscoder * trans );
42.90 +gboolean gmyth_transcoder_resume ( GMythTranscoder * trans );
42.91 +gboolean gmyth_transcoder_cancel ( GMythTranscoder * trans );
42.92 +gint gmyth_transcoder_get_progress ( GMythTranscoder * trans );
42.93
42.94
42.95 G_END_DECLS
43.1 --- a/gmyth/src/gmyth_tvchain.c Wed May 23 19:21:26 2007 +0100
43.2 +++ b/gmyth/src/gmyth_tvchain.c Wed May 23 19:50:41 2007 +0100
43.3 @@ -9,22 +9,21 @@
43.4 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
43.5 * @author Hallyson Luiz de Morais Melo <hallyson.melo@indt.org.br>
43.6 *
43.7 - *//*
43.8 - *
43.9 - * This program is free software; you can redistribute it and/or modify
43.10 - * it under the terms of the GNU Lesser General Public License as published by
43.11 - * the Free Software Foundation; either version 2 of the License, or
43.12 - * (at your option) any later version.
43.13 - *
43.14 - * This program is distributed in the hope that it will be useful,
43.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
43.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43.17 - * GNU General Public License for more details.
43.18 - *
43.19 - * You should have received a copy of the GNU Lesser General Public License
43.20 - * along with this program; if not, write to the Free Software
43.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
43.22 - */
43.23 + *
43.24 + * This program is free software; you can redistribute it and/or modify
43.25 + * it under the terms of the GNU Lesser General Public License as published by
43.26 + * the Free Software Foundation; either version 2 of the License, or
43.27 + * (at your option) any later version.
43.28 + *
43.29 + * This program is distributed in the hope that it will be useful,
43.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
43.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43.32 + * GNU General Public License for more details.
43.33 + *
43.34 + * You should have received a copy of the GNU Lesser General Public License
43.35 + * along with this program; if not, write to the Free Software
43.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
43.37 + */
43.38
43.39 #ifdef HAVE_CONFIG_H
43.40 #include "config.h"
43.41 @@ -44,85 +43,90 @@
43.42 #include "gmyth_scheduler.h"
43.43 #include "gmyth_debug.h"
43.44
43.45 -static void gmyth_tvchain_class_init (GMythTVChainClass * klass);
43.46 -static void gmyth_tvchain_init (GMythTVChain * object);
43.47 +static void gmyth_tvchain_class_init ( GMythTVChainClass * klass );
43.48 +static void gmyth_tvchain_init ( GMythTVChain * object );
43.49
43.50 -static void gmyth_tvchain_dispose (GObject * object);
43.51 -static void gmyth_tvchain_finalize (GObject * object);
43.52 +static void gmyth_tvchain_dispose ( GObject * object );
43.53 +static void gmyth_tvchain_finalize ( GObject * object );
43.54
43.55 -static void free_tvchain_entry (gpointer data, gpointer user_data);
43.56 +static void free_tvchain_entry ( gpointer data, gpointer user_data );
43.57
43.58 -G_DEFINE_TYPE (GMythTVChain, gmyth_tvchain, G_TYPE_OBJECT)
43.59 - static void gmyth_tvchain_class_init (GMythTVChainClass * klass)
43.60 +G_DEFINE_TYPE ( GMythTVChain, gmyth_tvchain, G_TYPE_OBJECT )
43.61 + static void gmyth_tvchain_class_init ( GMythTVChainClass * klass )
43.62 {
43.63 GObjectClass *gobject_class;
43.64
43.65 - gobject_class = (GObjectClass *) klass;
43.66 + gobject_class = ( GObjectClass * ) klass;
43.67
43.68 gobject_class->dispose = gmyth_tvchain_dispose;
43.69 gobject_class->finalize = gmyth_tvchain_finalize;
43.70 }
43.71
43.72 static void
43.73 -gmyth_tvchain_init (GMythTVChain * tvchain)
43.74 +gmyth_tvchain_init ( GMythTVChain * tvchain )
43.75 {
43.76 tvchain->tvchain_id = NULL;
43.77
43.78 - tvchain->cur_chanid = g_string_new ("");
43.79 + tvchain->cur_chanid = g_string_new ( "" );
43.80 tvchain->cur_startts = NULL;
43.81
43.82 - tvchain->mutex = g_mutex_new ();
43.83 + tvchain->mutex = g_mutex_new ( );
43.84 }
43.85
43.86 GMythTVChain *
43.87 -gmyth_tvchain_new ()
43.88 +gmyth_tvchain_new ( )
43.89 {
43.90 GMythTVChain *tvchain =
43.91 - GMYTH_TVCHAIN (g_object_new (GMYTH_TVCHAIN_TYPE, NULL));
43.92 + GMYTH_TVCHAIN ( g_object_new ( GMYTH_TVCHAIN_TYPE, NULL ) );
43.93
43.94 return tvchain;
43.95 }
43.96
43.97 static void
43.98 -gmyth_tvchain_dispose (GObject * object)
43.99 +gmyth_tvchain_dispose ( GObject * object )
43.100 {
43.101 - GMythTVChain *tvchain = GMYTH_TVCHAIN (object);
43.102 + GMythTVChain *tvchain = GMYTH_TVCHAIN ( object );
43.103
43.104 - if (tvchain->tvchain_id != NULL) {
43.105 - g_string_free (tvchain->tvchain_id, TRUE);
43.106 + if ( tvchain->tvchain_id != NULL )
43.107 + {
43.108 + g_string_free ( tvchain->tvchain_id, TRUE );
43.109 tvchain->tvchain_id = NULL;
43.110 }
43.111
43.112 - if (tvchain->mutex != NULL) {
43.113 - g_mutex_free (tvchain->mutex);
43.114 + if ( tvchain->mutex != NULL )
43.115 + {
43.116 + g_mutex_free ( tvchain->mutex );
43.117 tvchain->mutex = NULL;
43.118 }
43.119
43.120 - if (tvchain->tvchain_list != NULL) {
43.121 - g_list_foreach (tvchain->tvchain_list, free_tvchain_entry, NULL);
43.122 - g_list_free (tvchain->tvchain_list);
43.123 + if ( tvchain->tvchain_list != NULL )
43.124 + {
43.125 + g_list_foreach ( tvchain->tvchain_list, free_tvchain_entry, NULL );
43.126 + g_list_free ( tvchain->tvchain_list );
43.127 }
43.128
43.129 - if (tvchain->cur_chanid != NULL) {
43.130 - g_string_free (tvchain->cur_chanid, TRUE);
43.131 + if ( tvchain->cur_chanid != NULL )
43.132 + {
43.133 + g_string_free ( tvchain->cur_chanid, TRUE );
43.134 tvchain->cur_chanid = NULL;
43.135 }
43.136
43.137 - if (tvchain->backend_info) {
43.138 - g_object_unref (tvchain->backend_info);
43.139 + if ( tvchain->backend_info )
43.140 + {
43.141 + g_object_unref ( tvchain->backend_info );
43.142 tvchain->backend_info = NULL;
43.143 }
43.144
43.145
43.146 - G_OBJECT_CLASS (gmyth_tvchain_parent_class)->dispose (object);
43.147 + G_OBJECT_CLASS ( gmyth_tvchain_parent_class )->dispose ( object );
43.148 }
43.149
43.150 static void
43.151 -gmyth_tvchain_finalize (GObject * object)
43.152 +gmyth_tvchain_finalize ( GObject * object )
43.153 {
43.154 - g_signal_handlers_destroy (object);
43.155 + g_signal_handlers_destroy ( object );
43.156
43.157 - G_OBJECT_CLASS (gmyth_tvchain_parent_class)->finalize (object);
43.158 + G_OBJECT_CLASS ( gmyth_tvchain_parent_class )->finalize ( object );
43.159 }
43.160
43.161 /** Initializes the tvchain and generates the tvchain id.
43.162 @@ -131,41 +135,45 @@
43.163 * @param hostname The local hostname used to generate the tvchain id.
43.164 */
43.165 gboolean
43.166 -gmyth_tvchain_initialize (GMythTVChain * tvchain,
43.167 - GMythBackendInfo * backend_info)
43.168 +gmyth_tvchain_initialize ( GMythTVChain * tvchain,
43.169 + GMythBackendInfo * backend_info )
43.170 {
43.171 const char *hostname;
43.172
43.173 - assert (tvchain);
43.174 - g_return_val_if_fail (backend_info != NULL, FALSE);
43.175 + assert ( tvchain );
43.176 + g_return_val_if_fail ( backend_info != NULL, FALSE );
43.177
43.178 - g_object_ref (backend_info);
43.179 + g_object_ref ( backend_info );
43.180 tvchain->backend_info = backend_info;
43.181
43.182 - hostname = gmyth_backend_info_get_hostname (backend_info);
43.183 + hostname = gmyth_backend_info_get_hostname ( backend_info );
43.184
43.185 - if (tvchain->tvchain_id == NULL) {
43.186 + if ( tvchain->tvchain_id == NULL )
43.187 + {
43.188 gchar *isodate = NULL;
43.189 - GTimeVal *cur_time = g_new0 (GTimeVal, 1);
43.190 + GTimeVal *cur_time = g_new0 ( GTimeVal, 1 );
43.191
43.192 //struct tm* gmyth_util_time_val_to_date ( const GTimeVal* time )
43.193
43.194 - g_get_current_time (cur_time);
43.195 + g_get_current_time ( cur_time );
43.196 isodate =
43.197 gmyth_util_time_to_isoformat_from_time_val_fmt
43.198 - ("%Y-%m-%dT%H:%M:%S", cur_time);
43.199 + ( "%Y-%m-%dT%H:%M:%S", cur_time );
43.200
43.201 tvchain->tvchain_id =
43.202 - g_string_sized_new (7 + strlen (hostname) + strlen (isodate));
43.203 - g_string_printf (tvchain->tvchain_id, "live-%s-%s", hostname, isodate);
43.204 + g_string_sized_new ( 7 + strlen ( hostname ) + strlen ( isodate ) );
43.205 + g_string_printf ( tvchain->tvchain_id, "live-%s-%s", hostname,
43.206 + isodate );
43.207
43.208 - gmyth_debug ("[%s] tv_chain_id: %s", __FUNCTION__,
43.209 - tvchain->tvchain_id->str);
43.210 + gmyth_debug ( "[%s] tv_chain_id: %s", __FUNCTION__,
43.211 + tvchain->tvchain_id->str );
43.212
43.213 - g_free (isodate);
43.214 - g_free (cur_time);
43.215 - } else {
43.216 - gmyth_debug ("[%s] TVchain already initialized", __FUNCTION__);
43.217 + g_free ( isodate );
43.218 + g_free ( cur_time );
43.219 + }
43.220 + else
43.221 + {
43.222 + gmyth_debug ( "[%s] TVchain already initialized", __FUNCTION__ );
43.223 }
43.224
43.225 return TRUE;
43.226 @@ -177,9 +185,10 @@
43.227 * @return The tvchain id.
43.228 */
43.229 GString *
43.230 -gmyth_tvchain_get_id (GMythTVChain * tvchain)
43.231 +gmyth_tvchain_get_id ( GMythTVChain * tvchain )
43.232 {
43.233 - g_return_val_if_fail (tvchain != NULL && tvchain->tvchain_id != NULL, NULL);
43.234 + g_return_val_if_fail ( tvchain != NULL
43.235 + && tvchain->tvchain_id != NULL, NULL );
43.236
43.237 return tvchain->tvchain_id;
43.238 }
43.239 @@ -190,7 +199,7 @@
43.240 * @return TRUE if success, or FALSE if error.
43.241 */
43.242 gboolean
43.243 -gmyth_tvchain_reload_all (GMythTVChain * tvchain)
43.244 +gmyth_tvchain_reload_all ( GMythTVChain * tvchain )
43.245 {
43.246 MYSQL_ROW msql_row;
43.247 MYSQL_RES *msql_res = NULL;
43.248 @@ -198,100 +207,108 @@
43.249 gboolean ret = TRUE;
43.250 GString *stmt_str = NULL;
43.251
43.252 - g_mutex_lock (tvchain->mutex);
43.253 + g_mutex_lock ( tvchain->mutex );
43.254
43.255 /* gets the initial size of the TVChain entries list */
43.256 - guint prev_size = g_list_length (tvchain->tvchain_list);
43.257 + guint prev_size = g_list_length ( tvchain->tvchain_list );
43.258
43.259 - gmyth_debug ("[%s] chainid: %s", __FUNCTION__, tvchain->tvchain_id->str);
43.260 + gmyth_debug ( "[%s] chainid: %s", __FUNCTION__, tvchain->tvchain_id->str );
43.261
43.262 - if (tvchain != NULL && tvchain->tvchain_list != NULL) {
43.263 - g_list_free (tvchain->tvchain_list);
43.264 + if ( tvchain != NULL && tvchain->tvchain_list != NULL )
43.265 + {
43.266 + g_list_free ( tvchain->tvchain_list );
43.267 tvchain->tvchain_list = NULL;
43.268 }
43.269
43.270 /* TODO: Reuse gmyth_query already connected from context */
43.271 - gmyth_query = gmyth_query_new ();
43.272 - if (!gmyth_query_connect (gmyth_query, tvchain->backend_info)) {
43.273 - gmyth_debug ("[%s] Could not connect to db", __FUNCTION__);
43.274 - g_mutex_unlock (tvchain->mutex);
43.275 + gmyth_query = gmyth_query_new ( );
43.276 + if ( !gmyth_query_connect ( gmyth_query, tvchain->backend_info ) )
43.277 + {
43.278 + gmyth_debug ( "[%s] Could not connect to db", __FUNCTION__ );
43.279 + g_mutex_unlock ( tvchain->mutex );
43.280 ret = FALSE;
43.281 goto done;
43.282 }
43.283
43.284 - stmt_str = g_string_new ("");
43.285 - g_string_printf (stmt_str,
43.286 - "SELECT chanid, starttime, endtime, discontinuity, "
43.287 - "chainpos, hostprefix, cardtype, channame, input "
43.288 - "FROM tvchain "
43.289 - "WHERE chainid = \"%s\" ORDER BY chainpos;", tvchain->tvchain_id->str);
43.290 + stmt_str = g_string_new ( "" );
43.291 + g_string_printf ( stmt_str,
43.292 + "SELECT chanid, starttime, endtime, discontinuity, "
43.293 + "chainpos, hostprefix, cardtype, channame, input "
43.294 + "FROM tvchain "
43.295 + "WHERE chainid = \"%s\" ORDER BY chainpos;",
43.296 + tvchain->tvchain_id->str );
43.297
43.298 - msql_res = gmyth_query_process_statement (gmyth_query, stmt_str->str);
43.299 - if (msql_res != NULL) {
43.300 + msql_res = gmyth_query_process_statement ( gmyth_query, stmt_str->str );
43.301 + if ( msql_res != NULL )
43.302 + {
43.303
43.304 - while ((msql_row = mysql_fetch_row (msql_res)) != NULL) {
43.305 + while ( ( msql_row = mysql_fetch_row ( msql_res ) ) != NULL )
43.306 + {
43.307 struct LiveTVChainEntry *entry =
43.308 - g_new0 (struct LiveTVChainEntry, 1);
43.309 - entry->chanid = g_string_new (msql_row[0]);
43.310 + g_new0 ( struct LiveTVChainEntry, 1 );
43.311 + entry->chanid = g_string_new ( msql_row[0] );
43.312 entry->starttime =
43.313 - gmyth_util_string_to_time_val ((const gchar *) msql_row[1]);
43.314 + gmyth_util_string_to_time_val ( ( const gchar * ) msql_row[1] );
43.315 entry->endtime =
43.316 - gmyth_util_string_to_time_val ((const gchar *) msql_row[2]);
43.317 + gmyth_util_string_to_time_val ( ( const gchar * ) msql_row[2] );
43.318 entry->discontinuity =
43.319 - g_ascii_strtoull (msql_row[3], NULL, 10) != 0;
43.320 - entry->hostprefix = g_string_new (msql_row[5]);
43.321 - entry->cardtype = g_string_new (msql_row[6]);
43.322 - entry->channum = g_string_new (msql_row[7]);
43.323 - entry->inputname = g_string_new (msql_row[8]);
43.324 + g_ascii_strtoull ( msql_row[3], NULL, 10 ) != 0;
43.325 + entry->hostprefix = g_string_new ( msql_row[5] );
43.326 + entry->cardtype = g_string_new ( msql_row[6] );
43.327 + entry->channum = g_string_new ( msql_row[7] );
43.328 + entry->inputname = g_string_new ( msql_row[8] );
43.329
43.330 //m_maxpos = query.value(4).toInt() + 1;
43.331 gmyth_debug
43.332 - ("[%s] Reading TV chain entry (channel %s): [%s, %s, %s]\n",
43.333 - __FUNCTION__, entry->channum->str, entry->chanid->str,
43.334 - (gchar *) msql_row[1], (gchar *) msql_row[2]);
43.335 + ( "[%s] Reading TV chain entry (channel %s): [%s, %s, %s]\n",
43.336 + __FUNCTION__, entry->channum->str, entry->chanid->str,
43.337 + ( gchar * ) msql_row[1], ( gchar * ) msql_row[2] );
43.338
43.339 /* add this to get the actual start timestamp of the last recording */
43.340 - if (tvchain->cur_startts < entry->starttime)
43.341 + if ( tvchain->cur_startts < entry->starttime )
43.342 tvchain->cur_startts = entry->starttime;
43.343
43.344 tvchain->tvchain_list =
43.345 - g_list_append (tvchain->tvchain_list, entry);
43.346 + g_list_append ( tvchain->tvchain_list, entry );
43.347 }
43.348 - } else {
43.349 - gmyth_debug ("gmyth_tvchain_reload_all query error!\n");
43.350 - g_mutex_unlock (tvchain->mutex);
43.351 + }
43.352 + else
43.353 + {
43.354 + gmyth_debug ( "gmyth_tvchain_reload_all query error!\n" );
43.355 + g_mutex_unlock ( tvchain->mutex );
43.356
43.357 ret = FALSE;
43.358 goto done;
43.359 }
43.360
43.361 - g_mutex_unlock (tvchain->mutex);
43.362 + g_mutex_unlock ( tvchain->mutex );
43.363
43.364 tvchain->cur_pos =
43.365 - gmyth_tvchain_program_is_at (tvchain, tvchain->cur_chanid,
43.366 - tvchain->cur_startts);
43.367 - gmyth_debug ("[%s] TVChain current position = %d.\n", __FUNCTION__,
43.368 - tvchain->cur_pos);
43.369 + gmyth_tvchain_program_is_at ( tvchain, tvchain->cur_chanid,
43.370 + tvchain->cur_startts );
43.371 + gmyth_debug ( "[%s] TVChain current position = %d.\n", __FUNCTION__,
43.372 + tvchain->cur_pos );
43.373
43.374 - if (tvchain->cur_pos < 0)
43.375 + if ( tvchain->cur_pos < 0 )
43.376 tvchain->cur_pos = 0;
43.377
43.378 // if (m_switchid >= 0)
43.379 // m_switchid = ProgramIsAt(m_switchentry.chanid,m_switchentry.starttime);
43.380
43.381 - if (prev_size != g_list_length (tvchain->tvchain_list)) {
43.382 - gmyth_debug ("[%s] Added new recording", __FUNCTION__);
43.383 + if ( prev_size != g_list_length ( tvchain->tvchain_list ) )
43.384 + {
43.385 + gmyth_debug ( "[%s] Added new recording", __FUNCTION__ );
43.386 }
43.387
43.388 done:
43.389 - if (stmt_str != NULL)
43.390 - g_string_free (stmt_str, TRUE);
43.391 + if ( stmt_str != NULL )
43.392 + g_string_free ( stmt_str, TRUE );
43.393
43.394 - if (msql_res != NULL)
43.395 - mysql_free_result (msql_res);
43.396 + if ( msql_res != NULL )
43.397 + mysql_free_result ( msql_res );
43.398
43.399 - if (gmyth_query != NULL)
43.400 - g_object_unref (gmyth_query);
43.401 + if ( gmyth_query != NULL )
43.402 + g_object_unref ( gmyth_query );
43.403
43.404 return ret;
43.405 }
43.406 @@ -304,7 +321,7 @@
43.407 * @return A program info listage.
43.408 */
43.409 GList *
43.410 -gmyth_tvchain_get_program_info_list (GMythTVChain * tvchain)
43.411 +gmyth_tvchain_get_program_info_list ( GMythTVChain * tvchain )
43.412 {
43.413 GList *prog_list = NULL;
43.414 MYSQL_ROW msql_row;
43.415 @@ -312,51 +329,57 @@
43.416 GMythQuery *gmyth_query = NULL;
43.417 GString *stmt_str = NULL;
43.418
43.419 - g_mutex_lock (tvchain->mutex);
43.420 + g_mutex_lock ( tvchain->mutex );
43.421
43.422 - gmyth_query = gmyth_query_new ();
43.423 - if (!gmyth_query_connect (gmyth_query, tvchain->backend_info)) {
43.424 - gmyth_debug ("Could not connect to db.");
43.425 + gmyth_query = gmyth_query_new ( );
43.426 + if ( !gmyth_query_connect ( gmyth_query, tvchain->backend_info ) )
43.427 + {
43.428 + gmyth_debug ( "Could not connect to db." );
43.429 goto done;
43.430 }
43.431
43.432 - stmt_str = g_string_new ("");
43.433 - g_string_printf (stmt_str,
43.434 - "SELECT channum, icon " "FROM channel " "ORDER BY channum;");
43.435 + stmt_str = g_string_new ( "" );
43.436 + g_string_printf ( stmt_str,
43.437 + "SELECT channum, icon " "FROM channel "
43.438 + "ORDER BY channum;" );
43.439
43.440 - msql_res = gmyth_query_process_statement (gmyth_query, stmt_str->str);
43.441 - if (msql_res != NULL) {
43.442 + msql_res = gmyth_query_process_statement ( gmyth_query, stmt_str->str );
43.443 + if ( msql_res != NULL )
43.444 + {
43.445
43.446 - while ((msql_row = mysql_fetch_row (msql_res)) != NULL) {
43.447 - GMythProgramInfo *entry = gmyth_program_info_new ();
43.448 + while ( ( msql_row = mysql_fetch_row ( msql_res ) ) != NULL )
43.449 + {
43.450 + GMythProgramInfo *entry = gmyth_program_info_new ( );
43.451
43.452 - entry->channame = g_string_new (msql_row[0]);
43.453 - entry->chansign = g_string_new (msql_row[1]);
43.454 + entry->channame = g_string_new ( msql_row[0] );
43.455 + entry->chansign = g_string_new ( msql_row[1] );
43.456
43.457 gmyth_debug
43.458 - ("Reading TV program info entry (channel %s): [%s - {%s, %s}]\n",
43.459 - entry->channame->str, entry->chansign->str,
43.460 - (gchar *) msql_row[0], (gchar *) msql_row[1]);
43.461 + ( "Reading TV program info entry (channel %s): [%s - {%s, %s}]\n",
43.462 + entry->channame->str, entry->chansign->str,
43.463 + ( gchar * ) msql_row[0], ( gchar * ) msql_row[1] );
43.464
43.465 - prog_list = g_list_append (prog_list, entry);
43.466 + prog_list = g_list_append ( prog_list, entry );
43.467 }
43.468 - } else {
43.469 + }
43.470 + else
43.471 + {
43.472 gmyth_debug
43.473 - ("Query error when trying to get the channel list from database!\n");
43.474 + ( "Query error when trying to get the channel list from database!\n" );
43.475 goto done;
43.476 }
43.477
43.478 done:
43.479 - g_mutex_unlock (tvchain->mutex);
43.480 + g_mutex_unlock ( tvchain->mutex );
43.481
43.482 - if (stmt_str != NULL)
43.483 - g_string_free (stmt_str, TRUE);
43.484 + if ( stmt_str != NULL )
43.485 + g_string_free ( stmt_str, TRUE );
43.486
43.487 - if (msql_res != NULL)
43.488 - mysql_free_result (msql_res);
43.489 + if ( msql_res != NULL )
43.490 + mysql_free_result ( msql_res );
43.491
43.492 - if (gmyth_query != NULL)
43.493 - g_object_unref (gmyth_query);
43.494 + if ( gmyth_query != NULL )
43.495 + g_object_unref ( gmyth_query );
43.496
43.497 return prog_list;
43.498 }
43.499 @@ -370,8 +393,8 @@
43.500 * @return A program info listage, based on a given channel name.
43.501 */
43.502 GList *
43.503 -gmyth_tvchain_get_program_info_from_channel (GMythTVChain * tvchain,
43.504 - const gchar * channel)
43.505 +gmyth_tvchain_get_program_info_from_channel ( GMythTVChain * tvchain,
43.506 + const gchar * channel )
43.507 {
43.508 GList *prog_list = NULL;
43.509 MYSQL_ROW msql_row;
43.510 @@ -379,52 +402,58 @@
43.511 GMythQuery *gmyth_query = NULL;
43.512 GString *stmt_str = NULL;
43.513
43.514 - g_mutex_lock (tvchain->mutex);
43.515 + g_mutex_lock ( tvchain->mutex );
43.516
43.517 - gmyth_query = gmyth_query_new ();
43.518 - if (!gmyth_query_connect (gmyth_query, tvchain->backend_info)) {
43.519 - gmyth_debug ("Could not connect to db.");
43.520 + gmyth_query = gmyth_query_new ( );
43.521 + if ( !gmyth_query_connect ( gmyth_query, tvchain->backend_info ) )
43.522 + {
43.523 + gmyth_debug ( "Could not connect to db." );
43.524 goto done;
43.525 }
43.526
43.527 - stmt_str = g_string_new ("");
43.528 - g_string_printf (stmt_str,
43.529 - "SELECT channum, icon "
43.530 - "FROM channel " "WHERE channum = \"%s\" ORDER BY channum;", channel);
43.531 + stmt_str = g_string_new ( "" );
43.532 + g_string_printf ( stmt_str,
43.533 + "SELECT channum, icon "
43.534 + "FROM channel "
43.535 + "WHERE channum = \"%s\" ORDER BY channum;", channel );
43.536
43.537 - msql_res = gmyth_query_process_statement (gmyth_query, stmt_str->str);
43.538 - if (msql_res != NULL) {
43.539 + msql_res = gmyth_query_process_statement ( gmyth_query, stmt_str->str );
43.540 + if ( msql_res != NULL )
43.541 + {
43.542
43.543 - while ((msql_row = mysql_fetch_row (msql_res)) != NULL) {
43.544 - GMythProgramInfo *entry = gmyth_program_info_new ();
43.545 + while ( ( msql_row = mysql_fetch_row ( msql_res ) ) != NULL )
43.546 + {
43.547 + GMythProgramInfo *entry = gmyth_program_info_new ( );
43.548
43.549 - entry->channame = g_string_new (msql_row[0]);
43.550 - entry->chansign = g_string_new (msql_row[1]);
43.551 + entry->channame = g_string_new ( msql_row[0] );
43.552 + entry->chansign = g_string_new ( msql_row[1] );
43.553
43.554 gmyth_debug
43.555 - ("Reading TV program info entry (channel %s): [%s - {%s, %s}]\n",
43.556 - entry->channame->str, entry->chansign->str,
43.557 - (gchar *) msql_row[0], (gchar *) msql_row[1]);
43.558 + ( "Reading TV program info entry (channel %s): [%s - {%s, %s}]\n",
43.559 + entry->channame->str, entry->chansign->str,
43.560 + ( gchar * ) msql_row[0], ( gchar * ) msql_row[1] );
43.561
43.562 - prog_list = g_list_append (prog_list, entry);
43.563 + prog_list = g_list_append ( prog_list, entry );
43.564 }
43.565 - } else {
43.566 + }
43.567 + else
43.568 + {
43.569 gmyth_debug
43.570 - ("Query error when trying to get the channel list from database!\n");
43.571 + ( "Query error when trying to get the channel list from database!\n" );
43.572 goto done;
43.573 }
43.574
43.575 done:
43.576 - g_mutex_unlock (tvchain->mutex);
43.577 + g_mutex_unlock ( tvchain->mutex );
43.578
43.579 - if (stmt_str != NULL)
43.580 - g_string_free (stmt_str, TRUE);
43.581 + if ( stmt_str != NULL )
43.582 + g_string_free ( stmt_str, TRUE );
43.583
43.584 - if (msql_res != NULL)
43.585 - mysql_free_result (msql_res);
43.586 + if ( msql_res != NULL )
43.587 + mysql_free_result ( msql_res );
43.588
43.589 - if (gmyth_query != NULL)
43.590 - g_object_unref (gmyth_query);
43.591 + if ( gmyth_query != NULL )
43.592 + g_object_unref ( gmyth_query );
43.593
43.594 return prog_list;
43.595 }
43.596 @@ -440,26 +469,28 @@
43.597 * @return The position of the related program info in the TV chain.
43.598 */
43.599 gint
43.600 -gmyth_tvchain_program_is_at (GMythTVChain * tvchain, GString * chanid,
43.601 - GTimeVal * startts)
43.602 +gmyth_tvchain_program_is_at ( GMythTVChain * tvchain, GString * chanid,
43.603 + GTimeVal * startts )
43.604 {
43.605 gint count = 0;
43.606 struct LiveTVChainEntry *entry;
43.607 GList *tmp_list = tvchain->tvchain_list;
43.608 - guint list_size = g_list_length (tvchain->tvchain_list);
43.609 + guint list_size = g_list_length ( tvchain->tvchain_list );
43.610
43.611 - g_mutex_lock (tvchain->mutex);
43.612 + g_mutex_lock ( tvchain->mutex );
43.613
43.614 - for (; tmp_list && (count < list_size);
43.615 - tmp_list = tvchain->tvchain_list->next, count++) {
43.616 - entry = (struct LiveTVChainEntry *) tmp_list->data;
43.617 - if (!g_strncasecmp (entry->chanid->str, chanid->str, chanid->len)
43.618 - && entry->starttime == startts) {
43.619 - g_mutex_unlock (tvchain->mutex);
43.620 + for ( ; tmp_list && ( count < list_size );
43.621 + tmp_list = tvchain->tvchain_list->next, count++ )
43.622 + {
43.623 + entry = ( struct LiveTVChainEntry * ) tmp_list->data;
43.624 + if ( !g_strncasecmp ( entry->chanid->str, chanid->str, chanid->len )
43.625 + && entry->starttime == startts )
43.626 + {
43.627 + g_mutex_unlock ( tvchain->mutex );
43.628 return count;
43.629 }
43.630 }
43.631 - g_mutex_unlock (tvchain->mutex);
43.632 + g_mutex_unlock ( tvchain->mutex );
43.633
43.634 return -1;
43.635 }
43.636 @@ -472,14 +503,14 @@
43.637 * @return The program info structure.
43.638 */
43.639 GMythProgramInfo *
43.640 -gmyth_tvchain_get_program_at (GMythTVChain * tvchain, gint index)
43.641 +gmyth_tvchain_get_program_at ( GMythTVChain * tvchain, gint index )
43.642 {
43.643 struct LiveTVChainEntry *entry;
43.644
43.645 - entry = gmyth_tvchain_get_entry_at (tvchain, index);
43.646 + entry = gmyth_tvchain_get_entry_at ( tvchain, index );
43.647
43.648 - if (entry)
43.649 - return gmyth_tvchain_entry_to_program (tvchain, entry);
43.650 + if ( entry )
43.651 + return gmyth_tvchain_entry_to_program ( tvchain, entry );
43.652
43.653 return NULL;
43.654 }
43.655 @@ -491,32 +522,36 @@
43.656 * @return The LiveTVchainEntry structure.
43.657 */
43.658 struct LiveTVChainEntry *
43.659 -gmyth_tvchain_get_entry_at (GMythTVChain * tvchain, gint index)
43.660 +gmyth_tvchain_get_entry_at ( GMythTVChain * tvchain, gint index )
43.661 {
43.662 struct LiveTVChainEntry *chain_entry = NULL;
43.663
43.664 - g_return_val_if_fail (tvchain != NULL
43.665 - && tvchain->tvchain_list != NULL, NULL);
43.666 + g_return_val_if_fail ( tvchain != NULL
43.667 + && tvchain->tvchain_list != NULL, NULL );
43.668
43.669 - g_mutex_lock (tvchain->mutex);
43.670 + g_mutex_lock ( tvchain->mutex );
43.671
43.672 - gint size = g_list_length (tvchain->tvchain_list);
43.673 - gint new_index = (index < 0 || index >= size) ? size - 1 : index;
43.674 + gint size = g_list_length ( tvchain->tvchain_list );
43.675 + gint new_index = ( index < 0 || index >= size ) ? size - 1 : index;
43.676
43.677 - if (new_index >= 0)
43.678 + if ( new_index >= 0 )
43.679 chain_entry =
43.680 - (struct LiveTVChainEntry *) g_list_nth_data (tvchain->
43.681 - tvchain_list, new_index);
43.682 + ( struct LiveTVChainEntry * ) g_list_nth_data ( tvchain->
43.683 + tvchain_list,
43.684 + new_index );
43.685
43.686 - g_mutex_unlock (tvchain->mutex);
43.687 + g_mutex_unlock ( tvchain->mutex );
43.688
43.689 - if (chain_entry != NULL) {
43.690 - gmyth_debug ("[%s] Got TV Chain entry at %d.\n", __FUNCTION__,
43.691 - new_index);
43.692 + if ( chain_entry != NULL )
43.693 + {
43.694 + gmyth_debug ( "[%s] Got TV Chain entry at %d.\n", __FUNCTION__,
43.695 + new_index );
43.696
43.697 - } else {
43.698 - gmyth_debug ("[%s] failed to get entry at index %d", __FUNCTION__,
43.699 - index);
43.700 + }
43.701 + else
43.702 + {
43.703 + gmyth_debug ( "[%s] failed to get entry at index %d", __FUNCTION__,
43.704 + index );
43.705 }
43.706
43.707 return chain_entry;
43.708 @@ -531,73 +566,85 @@
43.709 * @return The program info.
43.710 */
43.711 GMythProgramInfo *
43.712 -gmyth_tvchain_entry_to_program (GMythTVChain * tvchain,
43.713 - struct LiveTVChainEntry * entry)
43.714 +gmyth_tvchain_entry_to_program ( GMythTVChain * tvchain,
43.715 + struct LiveTVChainEntry * entry )
43.716 {
43.717 GMythProgramInfo *proginfo = NULL;
43.718
43.719 - g_return_val_if_fail (tvchain != NULL, NULL);
43.720 + g_return_val_if_fail ( tvchain != NULL, NULL );
43.721
43.722 - if (!entry || !tvchain) {
43.723 - gmyth_debug ("gmyth_tvchain_entry_to_program() received NULL argument");
43.724 + if ( !entry || !tvchain )
43.725 + {
43.726 + gmyth_debug
43.727 + ( "gmyth_tvchain_entry_to_program() received NULL argument" );
43.728 return NULL;
43.729 }
43.730
43.731 - GMythScheduler *scheduler = gmyth_scheduler_new ();
43.732 + GMythScheduler *scheduler = gmyth_scheduler_new ( );
43.733
43.734 - gmyth_scheduler_connect (scheduler, tvchain->backend_info);
43.735 - proginfo = gmyth_scheduler_get_recorded (scheduler,
43.736 - entry->chanid, entry->starttime);
43.737 - gmyth_scheduler_disconnect (scheduler);
43.738 + gmyth_scheduler_connect ( scheduler, tvchain->backend_info );
43.739 + proginfo = gmyth_scheduler_get_recorded ( scheduler,
43.740 + entry->chanid, entry->starttime );
43.741 + gmyth_scheduler_disconnect ( scheduler );
43.742
43.743 - if (proginfo) {
43.744 + if ( proginfo )
43.745 + {
43.746 proginfo->pathname =
43.747 - g_string_prepend (proginfo->pathname, entry->hostprefix->str);
43.748 - } else {
43.749 + g_string_prepend ( proginfo->pathname, entry->hostprefix->str );
43.750 + }
43.751 + else
43.752 + {
43.753 gmyth_debug
43.754 - ("tvchain_entry_to_program( chan id = %s, starttime = %ld) failed!",
43.755 - entry->chanid->str, entry->starttime->tv_sec);
43.756 + ( "tvchain_entry_to_program( chan id = %s, starttime = %ld) failed!",
43.757 + entry->chanid->str, entry->starttime->tv_sec );
43.758 }
43.759
43.760 return proginfo;
43.761 }
43.762
43.763 static void
43.764 -free_tvchain_entry (gpointer data, gpointer user_data)
43.765 +free_tvchain_entry ( gpointer data, gpointer user_data )
43.766 {
43.767 struct LiveTVChainEntry *entry;
43.768
43.769 - g_return_if_fail (data != NULL);
43.770 + g_return_if_fail ( data != NULL );
43.771
43.772 - entry = (struct LiveTVChainEntry *) data;
43.773 + entry = ( struct LiveTVChainEntry * ) data;
43.774
43.775 - if (entry->chanid != NULL) {
43.776 - g_string_free (entry->chanid, TRUE);
43.777 + if ( entry->chanid != NULL )
43.778 + {
43.779 + g_string_free ( entry->chanid, TRUE );
43.780 }
43.781
43.782 - if (entry->starttime != NULL) {
43.783 - g_free (entry->starttime);
43.784 + if ( entry->starttime != NULL )
43.785 + {
43.786 + g_free ( entry->starttime );
43.787 }
43.788
43.789 - if (entry->endtime != NULL) {
43.790 - g_free (entry->endtime);
43.791 + if ( entry->endtime != NULL )
43.792 + {
43.793 + g_free ( entry->endtime );
43.794 }
43.795
43.796 - if (entry->hostprefix) {
43.797 - g_string_free (entry->hostprefix, TRUE);
43.798 + if ( entry->hostprefix )
43.799 + {
43.800 + g_string_free ( entry->hostprefix, TRUE );
43.801 }
43.802
43.803 - if (entry->cardtype) {
43.804 - g_string_free (entry->cardtype, TRUE);
43.805 + if ( entry->cardtype )
43.806 + {
43.807 + g_string_free ( entry->cardtype, TRUE );
43.808 }
43.809
43.810 - if (entry->channum) {
43.811 - g_string_free (entry->channum, TRUE);
43.812 + if ( entry->channum )
43.813 + {
43.814 + g_string_free ( entry->channum, TRUE );
43.815 }
43.816
43.817 - if (entry->inputname) {
43.818 - g_string_free (entry->inputname, TRUE);
43.819 + if ( entry->inputname )
43.820 + {
43.821 + g_string_free ( entry->inputname, TRUE );
43.822 }
43.823
43.824 - g_free (entry);
43.825 + g_free ( entry );
43.826 }
44.1 --- a/gmyth/src/gmyth_tvchain.h Wed May 23 19:21:26 2007 +0100
44.2 +++ b/gmyth/src/gmyth_tvchain.h Wed May 23 19:50:41 2007 +0100
44.3 @@ -9,22 +9,21 @@
44.4 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
44.5 * @author Hallyson Luiz de Morais Melo <hallyson.melo@indt.org.br>
44.6 *
44.7 - *//*
44.8 - *
44.9 - * This program is free software; you can redistribute it and/or modify
44.10 - * it under the terms of the GNU Lesser General Public License as published by
44.11 - * the Free Software Foundation; either version 2 of the License, or
44.12 - * (at your option) any later version.
44.13 - *
44.14 - * This program is distributed in the hope that it will be useful,
44.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
44.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
44.17 - * GNU General Public License for more details.
44.18 - *
44.19 - * You should have received a copy of the GNU Lesser General Public License
44.20 - * along with this program; if not, write to the Free Software
44.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
44.22 - */
44.23 + *
44.24 + * This program is free software; you can redistribute it and/or modify
44.25 + * it under the terms of the GNU Lesser General Public License as published by
44.26 + * the Free Software Foundation; either version 2 of the License, or
44.27 + * (at your option) any later version.
44.28 + *
44.29 + * This program is distributed in the hope that it will be useful,
44.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
44.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
44.32 + * GNU General Public License for more details.
44.33 + *
44.34 + * You should have received a copy of the GNU Lesser General Public License
44.35 + * along with this program; if not, write to the Free Software
44.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
44.37 + */
44.38
44.39 #ifndef LIVETVCHAIN_H_
44.40 #define LIVETVCHAIN_H_
44.41 @@ -47,67 +46,68 @@
44.42
44.43
44.44 struct LiveTVChainEntry
44.45 -{
44.46 - GString *chanid;
44.47 + {
44.48 + GString *chanid;
44.49
44.50 - GTimeVal *starttime;
44.51 - GTimeVal *endtime;
44.52 + GTimeVal *starttime;
44.53 + GTimeVal *endtime;
44.54
44.55 - gboolean discontinuity; // if true, can't play smooth from last entry
44.56 - GString *hostprefix;
44.57 - GString *cardtype;
44.58 - GString *channum;
44.59 - GString *inputname;
44.60 -};
44.61 + gboolean discontinuity; // if true, can't play smooth from last entry
44.62 + GString *hostprefix;
44.63 + GString *cardtype;
44.64 + GString *channum;
44.65 + GString *inputname;
44.66 + };
44.67
44.68
44.69 struct _GMythTVChainClass
44.70 -{
44.71 - GObjectClass parent_class;
44.72 + {
44.73 + GObjectClass parent_class;
44.74
44.75 - /* callbacks */
44.76 - /* no one for now */
44.77 -};
44.78 + /* callbacks */
44.79 + /* no one for now */
44.80 + };
44.81
44.82 struct _GMythTVChain
44.83 -{
44.84 - GObject parent;
44.85 + {
44.86 + GObject parent;
44.87
44.88 - GString *tvchain_id;
44.89 - GList *tvchain_list;
44.90 + GString *tvchain_id;
44.91 + GList *tvchain_list;
44.92
44.93 - GTimeVal *cur_startts;
44.94 - GString *cur_chanid;
44.95 - gint cur_pos;
44.96 + GTimeVal *cur_startts;
44.97 + GString *cur_chanid;
44.98 + gint cur_pos;
44.99
44.100 - GMythBackendInfo *backend_info;
44.101 + GMythBackendInfo *backend_info;
44.102
44.103 - GMutex *mutex;
44.104 -};
44.105 + GMutex *mutex;
44.106 + };
44.107
44.108 -GType gmyth_tvchain_get_type (void);
44.109 +GType gmyth_tvchain_get_type ( void );
44.110
44.111 -GMythTVChain *gmyth_tvchain_new ();
44.112 +GMythTVChain *gmyth_tvchain_new ( );
44.113
44.114 -gboolean gmyth_tvchain_initialize (GMythTVChain * tvchain,
44.115 - GMythBackendInfo * backend_info);
44.116 -gboolean gmyth_tvchain_reload_all (GMythTVChain * tvchain);
44.117 -GString *gmyth_tvchain_get_id (GMythTVChain * tvchain);
44.118 -gint gmyth_tvchain_program_is_at (GMythTVChain * tvchain,
44.119 - GString * chanid, GTimeVal * startts);
44.120 +gboolean gmyth_tvchain_initialize ( GMythTVChain * tvchain,
44.121 + GMythBackendInfo * backend_info );
44.122 +gboolean gmyth_tvchain_reload_all ( GMythTVChain * tvchain );
44.123 +GString *gmyth_tvchain_get_id ( GMythTVChain * tvchain );
44.124 +gint gmyth_tvchain_program_is_at ( GMythTVChain * tvchain,
44.125 + GString * chanid, GTimeVal * startts );
44.126
44.127 -struct LiveTVChainEntry *gmyth_tvchain_get_entry_at (GMythTVChain * tvchain,
44.128 - gint index);
44.129 +struct LiveTVChainEntry *gmyth_tvchain_get_entry_at ( GMythTVChain * tvchain,
44.130 + gint index );
44.131
44.132 -GMythProgramInfo *gmyth_tvchain_entry_to_program (GMythTVChain * tvchain,
44.133 - struct LiveTVChainEntry *entry);
44.134 -GMythProgramInfo *gmyth_tvchain_get_program_at (GMythTVChain * tvchain,
44.135 - gint index);
44.136 +GMythProgramInfo *gmyth_tvchain_entry_to_program ( GMythTVChain * tvchain,
44.137 + struct LiveTVChainEntry
44.138 + *entry );
44.139 +GMythProgramInfo *gmyth_tvchain_get_program_at ( GMythTVChain * tvchain,
44.140 + gint index );
44.141
44.142 -GList *gmyth_tvchain_get_program_info_from_channel (GMythTVChain * tvchain,
44.143 - const gchar * channel);
44.144 +GList *gmyth_tvchain_get_program_info_from_channel ( GMythTVChain * tvchain,
44.145 + const gchar * channel );
44.146
44.147 -GList *gmyth_tvchain_get_program_info_list (GMythTVChain * tvchain);
44.148 +GList *gmyth_tvchain_get_program_info_list ( GMythTVChain * tvchain );
44.149
44.150 G_END_DECLS
44.151 #endif /*LIVETVCHAIN_H_ */
45.1 --- a/gmyth/src/gmyth_uri.c Wed May 23 19:21:26 2007 +0100
45.2 +++ b/gmyth/src/gmyth_uri.c Wed May 23 19:50:41 2007 +0100
45.3 @@ -10,22 +10,21 @@
45.4 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
45.5 * @author Rosfran Borges <rosfran.borges@indt.org.br>
45.6 *
45.7 - *//*
45.8 - *
45.9 - * This program is free software; you can redistribute it and/or modify
45.10 - * it under the terms of the GNU Lesser General Public License as published by
45.11 - * the Free Software Foundation; either version 2 of the License, or
45.12 - * (at your option) any later version.
45.13 - *
45.14 - * This program is distributed in the hope that it will be useful,
45.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
45.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45.17 - * GNU General Public License for more details.
45.18 - *
45.19 - * You should have received a copy of the GNU Lesser General Public License
45.20 - * along with this program; if not, write to the Free Software
45.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
45.22 - */
45.23 + *
45.24 + * This program is free software; you can redistribute it and/or modify
45.25 + * it under the terms of the GNU Lesser General Public License as published by
45.26 + * the Free Software Foundation; either version 2 of the License, or
45.27 + * (at your option) any later version.
45.28 + *
45.29 + * This program is distributed in the hope that it will be useful,
45.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
45.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45.32 + * GNU General Public License for more details.
45.33 + *
45.34 + * You should have received a copy of the GNU Lesser General Public License
45.35 + * along with this program; if not, write to the Free Software
45.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
45.37 + */
45.38
45.39 #ifdef HAVE_CONFIG_H
45.40 #include "config.h"
45.41 @@ -40,89 +39,97 @@
45.42
45.43 #include "gmyth_debug.h"
45.44
45.45 -static void gmyth_uri_class_init (GMythURIClass * klass);
45.46 -static void gmyth_uri_init (GMythURI * object);
45.47 +static void gmyth_uri_class_init ( GMythURIClass * klass );
45.48 +static void gmyth_uri_init ( GMythURI * object );
45.49
45.50 -static void gmyth_uri_dispose (GObject * object);
45.51 -static void gmyth_uri_finalize (GObject * object);
45.52 +static void gmyth_uri_dispose ( GObject * object );
45.53 +static void gmyth_uri_finalize ( GObject * object );
45.54
45.55 -static void gmyth_uri_parser_setup_and_new (GMythURI * uri,
45.56 - const gchar * value);
45.57 -static gchar *gmyth_uri_print_field (const GString * field);
45.58 +static void gmyth_uri_parser_setup_and_new ( GMythURI * uri,
45.59 + const gchar * value );
45.60 +static gchar *gmyth_uri_print_field ( const GString * field );
45.61
45.62 -G_DEFINE_TYPE (GMythURI, gmyth_uri, G_TYPE_OBJECT)
45.63 - static void gmyth_uri_class_init (GMythURIClass * klass)
45.64 +G_DEFINE_TYPE ( GMythURI, gmyth_uri, G_TYPE_OBJECT )
45.65 + static void gmyth_uri_class_init ( GMythURIClass * klass )
45.66 {
45.67 GObjectClass *gobject_class;
45.68
45.69 - gobject_class = (GObjectClass *) klass;
45.70 + gobject_class = ( GObjectClass * ) klass;
45.71
45.72 gobject_class->dispose = gmyth_uri_dispose;
45.73 gobject_class->finalize = gmyth_uri_finalize;
45.74 }
45.75
45.76 static void
45.77 -gmyth_uri_init (GMythURI * gmyth_uri)
45.78 +gmyth_uri_init ( GMythURI * gmyth_uri )
45.79 {
45.80 }
45.81
45.82 static void
45.83 -gmyth_uri_dispose (GObject * object)
45.84 +gmyth_uri_dispose ( GObject * object )
45.85 {
45.86 - GMythURI *gmyth_uri = GMYTH_URI (object);
45.87 + GMythURI *gmyth_uri = GMYTH_URI ( object );
45.88
45.89 - if (gmyth_uri->host != NULL) {
45.90 - g_string_free (gmyth_uri->host, TRUE);
45.91 + if ( gmyth_uri->host != NULL )
45.92 + {
45.93 + g_string_free ( gmyth_uri->host, TRUE );
45.94 gmyth_uri->host = NULL;
45.95 }
45.96
45.97 - if (gmyth_uri->protocol != NULL) {
45.98 - g_string_free (gmyth_uri->protocol, TRUE);
45.99 + if ( gmyth_uri->protocol != NULL )
45.100 + {
45.101 + g_string_free ( gmyth_uri->protocol, TRUE );
45.102 gmyth_uri->protocol = NULL;
45.103 }
45.104
45.105 - if (gmyth_uri->path != NULL) {
45.106 - g_string_free (gmyth_uri->path, TRUE);
45.107 + if ( gmyth_uri->path != NULL )
45.108 + {
45.109 + g_string_free ( gmyth_uri->path, TRUE );
45.110 gmyth_uri->path = NULL;
45.111 }
45.112
45.113 - if (gmyth_uri->fragment != NULL) {
45.114 - g_string_free (gmyth_uri->fragment, TRUE);
45.115 + if ( gmyth_uri->fragment != NULL )
45.116 + {
45.117 + g_string_free ( gmyth_uri->fragment, TRUE );
45.118 gmyth_uri->fragment = NULL;
45.119 }
45.120
45.121 - if (gmyth_uri->user != NULL) {
45.122 - g_string_free (gmyth_uri->user, TRUE);
45.123 + if ( gmyth_uri->user != NULL )
45.124 + {
45.125 + g_string_free ( gmyth_uri->user, TRUE );
45.126 gmyth_uri->user = NULL;
45.127 }
45.128
45.129 - if (gmyth_uri->password != NULL) {
45.130 - g_string_free (gmyth_uri->password, TRUE);
45.131 + if ( gmyth_uri->password != NULL )
45.132 + {
45.133 + g_string_free ( gmyth_uri->password, TRUE );
45.134 gmyth_uri->password = NULL;
45.135 }
45.136
45.137 - if (gmyth_uri->query != NULL) {
45.138 - g_string_free (gmyth_uri->query, TRUE);
45.139 + if ( gmyth_uri->query != NULL )
45.140 + {
45.141 + g_string_free ( gmyth_uri->query, TRUE );
45.142 gmyth_uri->query = NULL;
45.143 }
45.144
45.145 - if (gmyth_uri->uri != NULL) {
45.146 - g_string_free (gmyth_uri->uri, TRUE);
45.147 + if ( gmyth_uri->uri != NULL )
45.148 + {
45.149 + g_string_free ( gmyth_uri->uri, TRUE );
45.150 gmyth_uri->uri = NULL;
45.151 }
45.152
45.153
45.154 - G_OBJECT_CLASS (gmyth_uri_parent_class)->dispose (object);
45.155 + G_OBJECT_CLASS ( gmyth_uri_parent_class )->dispose ( object );
45.156 }
45.157
45.158 static void
45.159 -gmyth_uri_finalize (GObject * object)
45.160 +gmyth_uri_finalize ( GObject * object )
45.161 {
45.162 //GMythURI *gmyth_uri = GMYTH_URI(object);
45.163
45.164 - g_signal_handlers_destroy (object);
45.165 + g_signal_handlers_destroy ( object );
45.166
45.167 - G_OBJECT_CLASS (gmyth_uri_parent_class)->finalize (object);
45.168 + G_OBJECT_CLASS ( gmyth_uri_parent_class )->finalize ( object );
45.169 }
45.170
45.171 /**
45.172 @@ -131,9 +138,9 @@
45.173 * @return a new instance of GMythURI.
45.174 */
45.175 GMythURI *
45.176 -gmyth_uri_new (void)
45.177 +gmyth_uri_new ( void )
45.178 {
45.179 - GMythURI *gmyth_uri = GMYTH_URI (g_object_new (GMYTH_URI_TYPE, NULL));
45.180 + GMythURI *gmyth_uri = GMYTH_URI ( g_object_new ( GMYTH_URI_TYPE, NULL ) );
45.181
45.182 return gmyth_uri;
45.183 }
45.184 @@ -146,11 +153,11 @@
45.185 * @return a new instance of GMythURI.
45.186 */
45.187 GMythURI *
45.188 -gmyth_uri_new_with_value (const gchar * uri_str)
45.189 +gmyth_uri_new_with_value ( const gchar * uri_str )
45.190 {
45.191 - GMythURI *gmyth_uri = GMYTH_URI (g_object_new (GMYTH_URI_TYPE, NULL));
45.192 + GMythURI *gmyth_uri = GMYTH_URI ( g_object_new ( GMYTH_URI_TYPE, NULL ) );
45.193
45.194 - gmyth_uri_parser_setup_and_new (gmyth_uri, uri_str);
45.195 + gmyth_uri_parser_setup_and_new ( gmyth_uri, uri_str );
45.196
45.197 return gmyth_uri;
45.198 }
45.199 @@ -165,18 +172,18 @@
45.200 * haystack function parameter doesn't contains the needle string argument.
45.201 */
45.202 static gint
45.203 -gmyth_strstr (const gchar * haystack, const gchar * needle)
45.204 +gmyth_strstr ( const gchar * haystack, const gchar * needle )
45.205 {
45.206
45.207 gchar *strPos;
45.208
45.209 - if (haystack == NULL || needle == NULL)
45.210 + if ( haystack == NULL || needle == NULL )
45.211 return -1;
45.212 - strPos = strstr (haystack, needle);
45.213 - if (strPos == NULL)
45.214 + strPos = strstr ( haystack, needle );
45.215 + if ( strPos == NULL )
45.216 return -1;
45.217
45.218 - return (strPos - haystack);
45.219 + return ( strPos - haystack );
45.220
45.221 }
45.222
45.223 @@ -188,15 +195,15 @@
45.224 * @return <code>true</code>, if the URI is absolute.
45.225 */
45.226 static gboolean
45.227 -gmyth_uri_isabsolute (const GMythURI * uri)
45.228 +gmyth_uri_isabsolute ( const GMythURI * uri )
45.229 {
45.230 gboolean ret = FALSE;
45.231
45.232 - g_return_val_if_fail (uri != NULL && uri->uri != NULL
45.233 - && uri->protocol != NULL, FALSE);
45.234 + g_return_val_if_fail ( uri != NULL && uri->uri != NULL
45.235 + && uri->protocol != NULL, FALSE );
45.236
45.237 - if (gmyth_strstr (uri->uri->str, GMYTH_URI_PROTOCOL_DELIM) == 0
45.238 - || strlen (uri->protocol->str) > 0)
45.239 + if ( gmyth_strstr ( uri->uri->str, GMYTH_URI_PROTOCOL_DELIM ) == 0
45.240 + || strlen ( uri->protocol->str ) > 0 )
45.241 ret = TRUE;
45.242
45.243 return ret;
45.244 @@ -216,19 +223,21 @@
45.245 * or <code>-1</code> if the no character of the list could be found.
45.246 */
45.247 static gint
45.248 -gmyth_strrchr (const gchar * str, const gchar * chars, const gint nchars)
45.249 +gmyth_strrchr ( const gchar * str, const gchar * chars, const gint nchars )
45.250 {
45.251
45.252 gint strLen;
45.253 gint i, j;
45.254
45.255 - if (str == NULL || chars == NULL)
45.256 + if ( str == NULL || chars == NULL )
45.257 return -1;
45.258
45.259 - strLen = strlen (str);
45.260 - for (i = (strLen - 1); 0 <= i; i--) {
45.261 - for (j = 0; j < nchars; j++) {
45.262 - if (str[i] == chars[j])
45.263 + strLen = strlen ( str );
45.264 + for ( i = ( strLen - 1 ); 0 <= i; i-- )
45.265 + {
45.266 + for ( j = 0; j < nchars; j++ )
45.267 + {
45.268 + if ( str[i] == chars[j] )
45.269 return i;
45.270 }
45.271 }
45.272 @@ -238,9 +247,9 @@
45.273 }
45.274
45.275 static gchar *
45.276 -gmyth_uri_print_field (const GString * field)
45.277 +gmyth_uri_print_field ( const GString * field )
45.278 {
45.279 - if (field != NULL && field->str != NULL && strlen (field->str) > 0)
45.280 + if ( field != NULL && field->str != NULL && strlen ( field->str ) > 0 )
45.281 return field->str;
45.282 else
45.283 return "";
45.284 @@ -254,7 +263,7 @@
45.285 *
45.286 */
45.287 static void
45.288 -gmyth_uri_parser_setup_and_new (GMythURI * uri, const gchar * value)
45.289 +gmyth_uri_parser_setup_and_new ( GMythURI * uri, const gchar * value )
45.290 {
45.291
45.292 gint uriLen;
45.293 @@ -274,126 +283,143 @@
45.294 gint queryLen;
45.295 */
45.296
45.297 - uriLen = strlen (value);
45.298 - uri->uri = g_string_new (value);
45.299 + uriLen = strlen ( value );
45.300 + uri->uri = g_string_new ( value );
45.301
45.302 currIdx = 0;
45.303
45.304 - /*** Protocol ****/
45.305 - protoIdx = gmyth_strstr (value, GMYTH_URI_PROTOCOL_DELIM);
45.306 - if (0 < protoIdx) {
45.307 - uri->protocol = g_string_new_len (value, protoIdx);
45.308 - currIdx += protoIdx + strlen (GMYTH_URI_PROTOCOL_DELIM);
45.309 + /*** Protocol ****/
45.310 + protoIdx = gmyth_strstr ( value, GMYTH_URI_PROTOCOL_DELIM );
45.311 + if ( 0 < protoIdx )
45.312 + {
45.313 + uri->protocol = g_string_new_len ( value, protoIdx );
45.314 + currIdx += protoIdx + strlen ( GMYTH_URI_PROTOCOL_DELIM );
45.315 }
45.316
45.317 - /*** User (Password) ****/
45.318 - atIdx = gmyth_strstr (value + currIdx, GMYTH_URI_USER_DELIM);
45.319 - if (0 < atIdx) {
45.320 - colonIdx = gmyth_strstr (value + currIdx, GMYTH_URI_COLON_DELIM);
45.321 + /*** User (Password) ****/
45.322 + atIdx = gmyth_strstr ( value + currIdx, GMYTH_URI_USER_DELIM );
45.323 + if ( 0 < atIdx )
45.324 + {
45.325 + colonIdx = gmyth_strstr ( value + currIdx, GMYTH_URI_COLON_DELIM );
45.326
45.327 - if (0 < colonIdx && colonIdx < atIdx) {
45.328 - uri->user = g_string_new_len (value + currIdx, colonIdx);
45.329 + if ( 0 < colonIdx && colonIdx < atIdx )
45.330 + {
45.331 + uri->user = g_string_new_len ( value + currIdx, colonIdx );
45.332 uri->password =
45.333 - g_string_new_len (value + currIdx + colonIdx + 1,
45.334 - atIdx - (colonIdx + 1));
45.335 - } else
45.336 - uri->user = g_string_new_len (value + currIdx, atIdx - currIdx);
45.337 + g_string_new_len ( value + currIdx + colonIdx + 1,
45.338 + atIdx - ( colonIdx + 1 ) );
45.339 + }
45.340 + else
45.341 + uri->user = g_string_new_len ( value + currIdx, atIdx - currIdx );
45.342 currIdx += atIdx + 1;
45.343 }
45.344
45.345 - /*** Host (Port) ****/
45.346 - shashIdx = gmyth_strstr (value + currIdx, GMYTH_URI_SLASH_DELIM);
45.347 - if (0 < shashIdx)
45.348 - uri->host = g_string_new_len (value + currIdx, shashIdx);
45.349 - else if (gmyth_uri_isabsolute (uri) == TRUE)
45.350 + /*** Host (Port) ****/
45.351 + shashIdx = gmyth_strstr ( value + currIdx, GMYTH_URI_SLASH_DELIM );
45.352 + if ( 0 < shashIdx )
45.353 + uri->host = g_string_new_len ( value + currIdx, shashIdx );
45.354 + else if ( gmyth_uri_isabsolute ( uri ) == TRUE )
45.355 uri->host =
45.356 - g_string_new_len (value + currIdx, strlen (value) - currIdx);
45.357 + g_string_new_len ( value + currIdx, strlen ( value ) - currIdx );
45.358
45.359 - host = gmyth_uri_get_host (uri);
45.360 - colonIdx = gmyth_strrchr (host, GMYTH_URI_COLON_DELIM, 1);
45.361 - eblacketIdx = gmyth_strrchr (host, GMYTH_URI_EBLACET_DELIM, 1);
45.362 - if ((0 < colonIdx) && (eblacketIdx < colonIdx)) {
45.363 + host = gmyth_uri_get_host ( uri );
45.364 + colonIdx = gmyth_strrchr ( host, GMYTH_URI_COLON_DELIM, 1 );
45.365 + eblacketIdx = gmyth_strrchr ( host, GMYTH_URI_EBLACET_DELIM, 1 );
45.366 + if ( ( 0 < colonIdx ) && ( eblacketIdx < colonIdx ) )
45.367 + {
45.368 GString *portStr = NULL;
45.369 - GString *hostStr = g_string_new (host != NULL ? host : "");
45.370 + GString *hostStr = g_string_new ( host != NULL ? host : "" );
45.371
45.372 hostLen = hostStr->len;
45.373 - /**** host ****/
45.374 - uri->host = g_string_erase (uri->host, 0, hostLen);
45.375 - uri->host = g_string_insert_len (uri->host, 0, hostStr->str, colonIdx);
45.376 - if (0 < hostLen) {
45.377 - if (host[0] == '[' && host[hostLen - 1] == ']')
45.378 - uri->host = g_string_new_len (hostStr->str + 1, colonIdx - 2);
45.379 + /**** host ****/
45.380 + uri->host = g_string_erase ( uri->host, 0, hostLen );
45.381 + uri->host =
45.382 + g_string_insert_len ( uri->host, 0, hostStr->str, colonIdx );
45.383 + if ( 0 < hostLen )
45.384 + {
45.385 + if ( host[0] == '[' && host[hostLen - 1] == ']' )
45.386 + uri->host = g_string_new_len ( hostStr->str + 1, colonIdx - 2 );
45.387 }
45.388 - /**** port ****/
45.389 + /**** port ****/
45.390 portStr =
45.391 - g_string_new_len (hostStr->str + colonIdx + 1,
45.392 - hostLen - colonIdx - 1);
45.393 - uri->port = (gint) g_ascii_strtoull (portStr->str, NULL, 10);
45.394 - g_string_free (portStr, TRUE);
45.395 - g_string_free (hostStr, TRUE);
45.396 - } else {
45.397 - const gchar *protocol = gmyth_uri_get_protocol (uri);
45.398 + g_string_new_len ( hostStr->str + colonIdx + 1,
45.399 + hostLen - colonIdx - 1 );
45.400 + uri->port = ( gint ) g_ascii_strtoull ( portStr->str, NULL, 10 );
45.401 + g_string_free ( portStr, TRUE );
45.402 + g_string_free ( hostStr, TRUE );
45.403 + }
45.404 + else
45.405 + {
45.406 + const gchar *protocol = gmyth_uri_get_protocol ( uri );
45.407
45.408 uri->port = GMYTH_URI_KNKOWN_PORT;
45.409 - if (strcmp (protocol, GMYTH_URI_PROTOCOL_HTTP) == 0)
45.410 + if ( strcmp ( protocol, GMYTH_URI_PROTOCOL_HTTP ) == 0 )
45.411 uri->port = GMYTH_URI_DEFAULT_HTTP_PORT;
45.412 - if (strcmp (protocol, GMYTH_URI_PROTOCOL_FTP) == 0)
45.413 + if ( strcmp ( protocol, GMYTH_URI_PROTOCOL_FTP ) == 0 )
45.414 uri->port = GMYTH_URI_DEFAULT_FTP_PORT;
45.415 }
45.416
45.417 - if (shashIdx > 0)
45.418 + if ( shashIdx > 0 )
45.419 currIdx += shashIdx;
45.420
45.421 /*
45.422 Handle relative URL
45.423 */
45.424 - if (gmyth_uri_isabsolute (uri) == FALSE) {
45.425 + if ( gmyth_uri_isabsolute ( uri ) == FALSE )
45.426 + {
45.427
45.428 - if (shashIdx != 0) {
45.429 + if ( shashIdx != 0 )
45.430 + {
45.431 /* Add slash delimiter at the beginning of the URL,
45.432 if it doesn't exist
45.433 */
45.434 - uri->path = g_string_new (GMYTH_URI_SLASH_DELIM);
45.435 + uri->path = g_string_new ( GMYTH_URI_SLASH_DELIM );
45.436 }
45.437 - uri->path = g_string_append (uri->path, value);
45.438 + uri->path = g_string_append ( uri->path, value );
45.439
45.440 - } else {
45.441 + }
45.442 + else
45.443 + {
45.444 /* First set path simply to the rest of URI */
45.445 - uri->path = g_string_new_len (value + currIdx, uriLen - currIdx);
45.446 + uri->path = g_string_new_len ( value + currIdx, uriLen - currIdx );
45.447 }
45.448
45.449 //gmyth_debug( "uri value: %s", value );
45.450 uri->query =
45.451 - g_string_new (g_strstr_len
45.452 - (value, strlen (value), GMYTH_URI_QUESTION_DELIM));
45.453 + g_string_new ( g_strstr_len
45.454 + ( value, strlen ( value ), GMYTH_URI_QUESTION_DELIM ) );
45.455
45.456 - eIdx = gmyth_strstr (value + currIdx, GMYTH_URI_QUESTION_DELIM);
45.457 + eIdx = gmyth_strstr ( value + currIdx, GMYTH_URI_QUESTION_DELIM );
45.458
45.459 - if (0 < eIdx) {
45.460 + if ( 0 < eIdx )
45.461 + {
45.462 uri->query =
45.463 - g_string_new (g_strstr_len
45.464 - (value, strlen (value), GMYTH_URI_QUESTION_DELIM));
45.465 - gmyth_debug ("query = %s", uri->query->str);
45.466 + g_string_new ( g_strstr_len
45.467 + ( value, strlen ( value ),
45.468 + GMYTH_URI_QUESTION_DELIM ) );
45.469 + gmyth_debug ( "query = %s", uri->query->str );
45.470 }
45.471
45.472 - /**** Path (Query/Fragment) ****/
45.473 - sharpIdx = gmyth_strstr (value + currIdx, GMYTH_URI_E_DELIM);
45.474 - if (0 < sharpIdx) {
45.475 - uri->path = g_string_append_len (uri->path, value + currIdx, sharpIdx);
45.476 + /**** Path (Query/Fragment) ****/
45.477 + sharpIdx = gmyth_strstr ( value + currIdx, GMYTH_URI_E_DELIM );
45.478 + if ( 0 < sharpIdx )
45.479 + {
45.480 + uri->path =
45.481 + g_string_append_len ( uri->path, value + currIdx, sharpIdx );
45.482 uri->fragment =
45.483 - g_string_new_len (value + currIdx + sharpIdx + 1,
45.484 - uriLen - (currIdx + sharpIdx + 1));
45.485 + g_string_new_len ( value + currIdx + sharpIdx + 1,
45.486 + uriLen - ( currIdx + sharpIdx + 1 ) );
45.487 }
45.488
45.489 gmyth_debug
45.490 - ("[%s] GMythURI: host = %s, port = %d, path = %s, query = %s, fragment = %s, "
45.491 - "user = %s, password = %s.\n", __FUNCTION__,
45.492 - gmyth_uri_print_field (uri->host), uri->port,
45.493 - gmyth_uri_print_field (uri->path),
45.494 - gmyth_uri_print_field (uri->query),
45.495 - gmyth_uri_print_field (uri->fragment),
45.496 - gmyth_uri_print_field (uri->user),
45.497 - gmyth_uri_print_field (uri->password));
45.498 + ( "[%s] GMythURI: host = %s, port = %d, path = %s, query = %s, fragment = %s, "
45.499 + "user = %s, password = %s.\n", __FUNCTION__,
45.500 + gmyth_uri_print_field ( uri->host ), uri->port,
45.501 + gmyth_uri_print_field ( uri->path ),
45.502 + gmyth_uri_print_field ( uri->query ),
45.503 + gmyth_uri_print_field ( uri->fragment ),
45.504 + gmyth_uri_print_field ( uri->user ),
45.505 + gmyth_uri_print_field ( uri->password ) );
45.506
45.507 }
45.508
45.509 @@ -406,11 +432,11 @@
45.510 * @return <code>true</code>, if these two URI instances are equals.
45.511 */
45.512 gboolean
45.513 -gmyth_uri_is_equals (GMythURI * uri1, GMythURI * uri2)
45.514 +gmyth_uri_is_equals ( GMythURI * uri1, GMythURI * uri2 )
45.515 {
45.516 - return (g_ascii_strcasecmp
45.517 - (gmyth_uri_get_host (uri1), gmyth_uri_get_host (uri2)) == 0
45.518 - && gmyth_uri_get_port (uri1) == gmyth_uri_get_port (uri2));
45.519 + return ( g_ascii_strcasecmp
45.520 + ( gmyth_uri_get_host ( uri1 ), gmyth_uri_get_host ( uri2 ) ) == 0
45.521 + && gmyth_uri_get_port ( uri1 ) == gmyth_uri_get_port ( uri2 ) );
45.522 }
45.523
45.524 /**
45.525 @@ -421,22 +447,22 @@
45.526 * @return <code>true</code>, if the URI points to LiveTV content.
45.527 */
45.528 gboolean
45.529 -gmyth_uri_is_livetv (GMythURI * uri)
45.530 +gmyth_uri_is_livetv ( GMythURI * uri )
45.531 {
45.532 gboolean ret = TRUE;
45.533
45.534 - g_return_val_if_fail (uri != NULL, FALSE);
45.535 - g_return_val_if_fail (uri->uri != NULL, FALSE);
45.536 - g_return_val_if_fail (uri->uri->str != NULL, FALSE);
45.537 + g_return_val_if_fail ( uri != NULL, FALSE );
45.538 + g_return_val_if_fail ( uri->uri != NULL, FALSE );
45.539 + g_return_val_if_fail ( uri->uri->str != NULL, FALSE );
45.540
45.541 - if ((strstr (uri->uri->str, "channel") == NULL) ||
45.542 - (strstr (uri->uri->str, "livetv") == NULL))
45.543 + if ( ( strstr ( uri->uri->str, "channel" ) == NULL ) ||
45.544 + ( strstr ( uri->uri->str, "livetv" ) == NULL ) )
45.545 ret = FALSE;
45.546
45.547 - if (ret)
45.548 - gmyth_debug ("This URI is a LiveTV recording...");
45.549 + if ( ret )
45.550 + gmyth_debug ( "This URI is a LiveTV recording..." );
45.551 else
45.552 - gmyth_debug ("This URI is a stored remote recording.");
45.553 + gmyth_debug ( "This URI is a stored remote recording." );
45.554
45.555 return ret;
45.556
45.557 @@ -451,31 +477,35 @@
45.558 * of the URI string.
45.559 */
45.560 gchar *
45.561 -gmyth_uri_get_channel_name (GMythURI * uri)
45.562 +gmyth_uri_get_channel_name ( GMythURI * uri )
45.563 {
45.564 gchar *channel = NULL;
45.565
45.566 - g_return_val_if_fail (uri != NULL && uri->uri != NULL
45.567 - && uri->uri->str != NULL, FALSE);
45.568 + g_return_val_if_fail ( uri != NULL && uri->uri != NULL
45.569 + && uri->uri->str != NULL, FALSE );
45.570
45.571 - gchar *channel_query = g_strstr_len (gmyth_uri_get_query (uri),
45.572 - strlen (gmyth_uri_get_query (uri)),
45.573 - "channel");
45.574 + gchar *channel_query = g_strstr_len ( gmyth_uri_get_query ( uri ),
45.575 + strlen ( gmyth_uri_get_query
45.576 + ( uri ) ),
45.577 + "channel" );
45.578
45.579 - if (channel_query != NULL) {
45.580 - gchar **chan_key_value = g_strsplit (gmyth_uri_get_query (uri), "=", 2);
45.581 + if ( channel_query != NULL )
45.582 + {
45.583 + gchar **chan_key_value =
45.584 + g_strsplit ( gmyth_uri_get_query ( uri ), "=", 2 );
45.585
45.586 /* gmyth_debug( "Channel tuple is [ %s, %s ]", chan_key_value[0], chan_key_value[1] ); */
45.587
45.588 - if (chan_key_value[1] != NULL && strlen (chan_key_value[1]) > 0) {
45.589 - channel = g_strdup (chan_key_value[1]);
45.590 + if ( chan_key_value[1] != NULL && strlen ( chan_key_value[1] ) > 0 )
45.591 + {
45.592 + channel = g_strdup ( chan_key_value[1] );
45.593 }
45.594
45.595 - if (chan_key_value != NULL)
45.596 - g_strfreev (chan_key_value);
45.597 + if ( chan_key_value != NULL )
45.598 + g_strfreev ( chan_key_value );
45.599 }
45.600
45.601 - gmyth_debug ("Got channel decimal value from the URI: %s", channel);
45.602 + gmyth_debug ( "Got channel decimal value from the URI: %s", channel );
45.603
45.604 return channel;
45.605
45.606 @@ -490,12 +520,13 @@
45.607 * of the URI string, or <code>-1</code> it if couldn't be converted.
45.608 */
45.609 gint
45.610 -gmyth_uri_get_channel_num (GMythURI * uri)
45.611 +gmyth_uri_get_channel_num ( GMythURI * uri )
45.612 {
45.613 - gchar *channel_name = gmyth_uri_get_channel_name (uri);
45.614 + gchar *channel_name = gmyth_uri_get_channel_name ( uri );
45.615
45.616 - if (channel_name != NULL) {
45.617 - return g_ascii_strtoull (channel_name, NULL, 10);
45.618 + if ( channel_name != NULL )
45.619 + {
45.620 + return g_ascii_strtoull ( channel_name, NULL, 10 );
45.621 }
45.622
45.623 return -1;
45.624 @@ -510,37 +541,37 @@
45.625 * @return <code>true</code>, if the URI points to a local file.
45.626 */
45.627 gboolean
45.628 -gmyth_uri_is_local_file (const GMythURI * uri)
45.629 +gmyth_uri_is_local_file ( const GMythURI * uri )
45.630 {
45.631 gboolean ret = FALSE;
45.632 gint len = -1;
45.633
45.634 - GString *hostname = gmyth_socket_get_local_hostname ();
45.635 + GString *hostname = gmyth_socket_get_local_hostname ( );
45.636
45.637 - g_return_val_if_fail (uri != NULL, FALSE);
45.638 + g_return_val_if_fail ( uri != NULL, FALSE );
45.639
45.640 - len = strlen (gmyth_uri_get_host (uri));
45.641 + len = strlen ( gmyth_uri_get_host ( uri ) );
45.642
45.643 // gmyth_debug("URI: host = %s, hostname = %s.", uri->host->str, hostname != NULL ? hostname->str : "[no hostname]");
45.644
45.645 - ret = (NULL != hostname && (g_ascii_strncasecmp (uri->host->str, (hostname)->str, len) == 0) /*||
45.646 - ( g_ascii_strncasecmp( gmyth_uri_get_host(uri), gmyth_socket_get_primary_addr(), len ) == 0 ) */
45.647 - );
45.648 + ret = ( NULL != hostname && ( g_ascii_strncasecmp ( uri->host->str, ( hostname )->str, len ) == 0 ) /*||
45.649 + ( g_ascii_strncasecmp( gmyth_uri_get_host(uri), gmyth_socket_get_primary_addr(), len ) == 0 ) */
45.650 + );
45.651
45.652 - if (ret)
45.653 - gmyth_debug ("This URI is a local file...");
45.654 + if ( ret )
45.655 + gmyth_debug ( "This URI is a local file..." );
45.656 else
45.657 - gmyth_debug ("This URI is NOT a local file...");
45.658 + gmyth_debug ( "This URI is NOT a local file..." );
45.659
45.660 return ret;
45.661
45.662 }
45.663
45.664 char *
45.665 -gmyth_uri_to_string (const GMythURI * uri)
45.666 +gmyth_uri_to_string ( const GMythURI * uri )
45.667 {
45.668 - g_return_val_if_fail (uri != NULL, NULL);
45.669 - g_return_val_if_fail (uri->uri != NULL, NULL);
45.670 + g_return_val_if_fail ( uri != NULL, NULL );
45.671 + g_return_val_if_fail ( uri->uri != NULL, NULL );
45.672
45.673 - return g_strdup (uri->uri->str);
45.674 + return g_strdup ( uri->uri->str );
45.675 }
46.1 --- a/gmyth/src/gmyth_uri.h Wed May 23 19:21:26 2007 +0100
46.2 +++ b/gmyth/src/gmyth_uri.h Wed May 23 19:50:41 2007 +0100
46.3 @@ -10,22 +10,21 @@
46.4 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
46.5 * @author Rosfran Borges <rosfran.borges@indt.org.br>
46.6 *
46.7 - *//*
46.8 - *
46.9 - * This program is free software; you can redistribute it and/or modify
46.10 - * it under the terms of the GNU Lesser General Public License as published by
46.11 - * the Free Software Foundation; either version 2 of the License, or
46.12 - * (at your option) any later version.
46.13 - *
46.14 - * This program is distributed in the hope that it will be useful,
46.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
46.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
46.17 - * GNU General Public License for more details.
46.18 - *
46.19 - * You should have received a copy of the GNU Lesser General Public License
46.20 - * along with this program; if not, write to the Free Software
46.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
46.22 - */
46.23 + *
46.24 + * This program is free software; you can redistribute it and/or modify
46.25 + * it under the terms of the GNU Lesser General Public License as published by
46.26 + * the Free Software Foundation; either version 2 of the License, or
46.27 + * (at your option) any later version.
46.28 + *
46.29 + * This program is distributed in the hope that it will be useful,
46.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
46.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
46.32 + * GNU General Public License for more details.
46.33 + *
46.34 + * You should have received a copy of the GNU Lesser General Public License
46.35 + * along with this program; if not, write to the Free Software
46.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
46.37 + */
46.38
46.39 #ifndef _GMYTH_URI_H_
46.40 #define _GMYTH_URI_H_
46.41 @@ -47,9 +46,9 @@
46.42 typedef struct _GMythURI GMythURI;
46.43 typedef struct _GMythURIClass GMythURIClass;
46.44
46.45 -/****************************************
46.46 -* Define
46.47 -****************************************/
46.48 + /****************************************
46.49 + * Define
46.50 + ****************************************/
46.51
46.52 #define GMYTH_URI_KNKOWN_PORT (-1)
46.53 #define GMYTH_URI_DEFAULT_HTTP_PORT 80
46.54 @@ -72,44 +71,44 @@
46.55 #define GMYTH_URI_PROTOCOL_HTTP "http"
46.56 #define GMYTH_URI_PROTOCOL_FTP "ftp"
46.57
46.58 -/****************************************
46.59 -* Data Type
46.60 -****************************************/
46.61 + /****************************************
46.62 + * Data Type
46.63 + ****************************************/
46.64
46.65 struct _GMythURIClass
46.66 -{
46.67 - GObjectClass parent_class;
46.68 + {
46.69 + GObjectClass parent_class;
46.70
46.71 - /* callbacks */
46.72 - /* no one for now */
46.73 -};
46.74 + /* callbacks */
46.75 + /* no one for now */
46.76 + };
46.77
46.78 struct _GMythURI
46.79 -{
46.80 + {
46.81
46.82 - GObject parent;
46.83 + GObject parent;
46.84
46.85 - GString *uri;
46.86 - GString *host;
46.87 - gint port;
46.88 - GString *protocol;
46.89 - GString *path;
46.90 - GString *fragment;
46.91 - GString *user;
46.92 - GString *password;
46.93 - GString *query;
46.94 + GString *uri;
46.95 + GString *host;
46.96 + gint port;
46.97 + GString *protocol;
46.98 + GString *path;
46.99 + GString *fragment;
46.100 + GString *user;
46.101 + GString *password;
46.102 + GString *query;
46.103
46.104 -};
46.105 + };
46.106
46.107 -GType gmyth_uri_get_type (void);
46.108 -GMythURI *gmyth_uri_new (void);
46.109 -GMythURI *gmyth_uri_new_with_value (const gchar * value);
46.110 -gboolean gmyth_uri_is_equals (GMythURI * uri1, GMythURI * uri2);
46.111 -gboolean gmyth_uri_is_livetv (GMythURI * uri);
46.112 -gint gmyth_uri_get_channel_num (GMythURI * uri);
46.113 -gchar *gmyth_uri_get_channel_name (GMythURI * uri);
46.114 -char *gmyth_uri_to_string (const GMythURI * uri);
46.115 -gboolean gmyth_uri_is_local_file (const GMythURI * uri);
46.116 +GType gmyth_uri_get_type ( void );
46.117 +GMythURI *gmyth_uri_new ( void );
46.118 +GMythURI *gmyth_uri_new_with_value ( const gchar * value );
46.119 +gboolean gmyth_uri_is_equals ( GMythURI * uri1, GMythURI * uri2 );
46.120 +gboolean gmyth_uri_is_livetv ( GMythURI * uri );
46.121 +gint gmyth_uri_get_channel_num ( GMythURI * uri );
46.122 +gchar *gmyth_uri_get_channel_name ( GMythURI * uri );
46.123 +char *gmyth_uri_to_string ( const GMythURI * uri );
46.124 +gboolean gmyth_uri_is_local_file ( const GMythURI * uri );
46.125
46.126 #define gmyth_uri_get_host(urip) ( urip->host != NULL ? urip->host->str : "" )
46.127 #define gmyth_uri_get_port(urip) ( urip->port )
47.1 --- a/gmyth/src/gmyth_util.c Wed May 23 19:21:26 2007 +0100
47.2 +++ b/gmyth/src/gmyth_util.c Wed May 23 19:50:41 2007 +0100
47.3 @@ -10,22 +10,21 @@
47.4 * @author Hallyson Luiz de Morais Melo <hallyson.melo@indt.org.br>
47.5 * @author Rosfran Borges <rosfran.borges@indt.org.br>
47.6 *
47.7 - *//*
47.8 - *
47.9 - * This program is free software; you can redistribute it and/or modify
47.10 - * it under the terms of the GNU Lesser General Public License as published by
47.11 - * the Free Software Foundation; either version 2 of the License, or
47.12 - * (at your option) any later version.
47.13 - *
47.14 - * This program is distributed in the hope that it will be useful,
47.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
47.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47.17 - * GNU General Public License for more details.
47.18 - *
47.19 - * You should have received a copy of the GNU Lesser General Public License
47.20 - * along with this program; if not, write to the Free Software
47.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
47.22 - */
47.23 + *
47.24 + * This program is free software; you can redistribute it and/or modify
47.25 + * it under the terms of the GNU Lesser General Public License as published by
47.26 + * the Free Software Foundation; either version 2 of the License, or
47.27 + * (at your option) any later version.
47.28 + *
47.29 + * This program is distributed in the hope that it will be useful,
47.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
47.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47.32 + * GNU General Public License for more details.
47.33 + *
47.34 + * You should have received a copy of the GNU Lesser General Public License
47.35 + * along with this program; if not, write to the Free Software
47.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
47.37 + */
47.38
47.39 #ifdef HAVE_CONFIG_H
47.40 #include "config.h"
47.41 @@ -48,9 +47,9 @@
47.42 #include "gmyth_debug.h"
47.43
47.44 #if !GLIB_CHECK_VERSION (2, 10, 0)
47.45 -gchar *g_time_val_to_iso8601 (GTimeVal * time_);
47.46 -gboolean g_time_val_from_iso8601 (const gchar * iso_date, GTimeVal * time_);
47.47 -void g_date_set_time_val (GDate * date, GTimeVal * timeval);
47.48 +gchar *g_time_val_to_iso8601 ( GTimeVal * time_ );
47.49 +gboolean g_time_val_from_iso8601 ( const gchar * iso_date, GTimeVal * time_ );
47.50 +void g_date_set_time_val ( GDate * date, GTimeVal * timeval );
47.51
47.52 #endif
47.53
47.54 @@ -64,22 +63,24 @@
47.55 * @return GString* the converted isoformat string
47.56 */
47.57 GString *
47.58 -gmyth_util_time_to_isoformat (time_t time_value)
47.59 +gmyth_util_time_to_isoformat ( time_t time_value )
47.60 {
47.61 struct tm tm_time;
47.62 GString *result;
47.63
47.64 - if (localtime_r (&time_value, &tm_time) == NULL) {
47.65 - gmyth_debug ("gmyth_util_time_to_isoformat convertion error!\n");
47.66 + if ( localtime_r ( &time_value, &tm_time ) == NULL )
47.67 + {
47.68 + gmyth_debug ( "gmyth_util_time_to_isoformat convertion error!\n" );
47.69 return NULL;
47.70 }
47.71
47.72 - result = g_string_sized_new (20);
47.73 - g_string_printf (result, "%04d-%02d-%02dT%02d:%02d:%02d",
47.74 - tm_time.tm_year + 1900, tm_time.tm_mon + 1,
47.75 - tm_time.tm_mday, tm_time.tm_hour, tm_time.tm_min, tm_time.tm_sec);
47.76 + result = g_string_sized_new ( 20 );
47.77 + g_string_printf ( result, "%04d-%02d-%02dT%02d:%02d:%02d",
47.78 + tm_time.tm_year + 1900, tm_time.tm_mon + 1,
47.79 + tm_time.tm_mday, tm_time.tm_hour, tm_time.tm_min,
47.80 + tm_time.tm_sec );
47.81
47.82 - gmyth_debug ("Result (ISO 8601) = %s", result->str);
47.83 + gmyth_debug ( "Result (ISO 8601) = %s", result->str );
47.84
47.85 return result;
47.86 }
47.87 @@ -94,8 +95,8 @@
47.88 * @return GString* the converted isoformat string
47.89 */
47.90 gchar *
47.91 -gmyth_util_time_to_isoformat_from_time_val_fmt (const gchar * fmt_string,
47.92 - const GTimeVal * time_val)
47.93 +gmyth_util_time_to_isoformat_from_time_val_fmt ( const gchar * fmt_string,
47.94 + const GTimeVal * time_val )
47.95 {
47.96 gchar *result = NULL;
47.97 struct tm *tm_time = NULL;
47.98 @@ -103,40 +104,45 @@
47.99
47.100 gint buffer_len = 0;
47.101
47.102 - g_return_val_if_fail (fmt_string != NULL, NULL);
47.103 + g_return_val_if_fail ( fmt_string != NULL, NULL );
47.104
47.105 - g_return_val_if_fail (time_val != NULL, NULL);
47.106 + g_return_val_if_fail ( time_val != NULL, NULL );
47.107
47.108 time = time_val->tv_sec; // + (gint)( time_val->tv_usec / G_USEC_PER_SEC );
47.109
47.110 - tm_time = g_malloc0 (sizeof (struct tm));
47.111 + tm_time = g_malloc0 ( sizeof ( struct tm ) );
47.112
47.113 - if (NULL == localtime_r (&time, tm_time)) {
47.114 - gmyth_debug ("gmyth_util_time_to_isoformat convertion error!\n");
47.115 - } else {
47.116 + if ( NULL == localtime_r ( &time, tm_time ) )
47.117 + {
47.118 + gmyth_debug ( "gmyth_util_time_to_isoformat convertion error!\n" );
47.119 + }
47.120 + else
47.121 + {
47.122 /* we first check the return of strftime to allocate a buffer of the correct size */
47.123 - buffer_len = strftime (NULL, SSIZE_MAX, fmt_string, tm_time);
47.124 - if (buffer_len > 0) {
47.125 - result = g_malloc0 (buffer_len + 1);
47.126 - if (result == NULL) {
47.127 + buffer_len = strftime ( NULL, SSIZE_MAX, fmt_string, tm_time );
47.128 + if ( buffer_len > 0 )
47.129 + {
47.130 + result = g_malloc0 ( buffer_len + 1 );
47.131 + if ( result == NULL )
47.132 + {
47.133 gmyth_debug
47.134 - ("gmyth_util_time_to_isoformat convertion error!\n");
47.135 + ( "gmyth_util_time_to_isoformat convertion error!\n" );
47.136 return NULL;
47.137 }
47.138 - strftime (result, buffer_len + 1, fmt_string, tm_time);
47.139 - gmyth_debug ("Dateline (ISO result): %s", result);
47.140 + strftime ( result, buffer_len + 1, fmt_string, tm_time );
47.141 + gmyth_debug ( "Dateline (ISO result): %s", result );
47.142 }
47.143 } /* if */
47.144
47.145 - gmyth_debug ("Result (strftime) = %s", result);
47.146 + gmyth_debug ( "Result (strftime) = %s", result );
47.147
47.148 //strptime( result, "%Y-%m-%dT%H:%M:%SZ", tm_time );
47.149
47.150 //strftime( result, strlen(result), fmt_string, tm_time );
47.151
47.152 - g_free (tm_time);
47.153 + g_free ( tm_time );
47.154
47.155 - gmyth_debug ("Result (ISO 8601) = %s", result);
47.156 + gmyth_debug ( "Result (ISO 8601) = %s", result );
47.157
47.158 return result;
47.159 }
47.160 @@ -151,11 +157,11 @@
47.161 * @return GString* the converted isoformat string
47.162 */
47.163 gchar *
47.164 -gmyth_util_time_to_isoformat_from_time_val (const GTimeVal * time)
47.165 +gmyth_util_time_to_isoformat_from_time_val ( const GTimeVal * time )
47.166 {
47.167 gchar *result =
47.168 - gmyth_util_time_to_isoformat_from_time_val_fmt ("%Y-%m-%d %H:%M:%S",
47.169 - time);
47.170 + gmyth_util_time_to_isoformat_from_time_val_fmt ( "%Y-%m-%d %H:%M:%S",
47.171 + time );
47.172
47.173 //result[10] = ' ';
47.174 //result[ strlen(result) - 1] = '\0';
47.175 @@ -173,11 +179,11 @@
47.176 * @return GString* the converted isoformat string
47.177 */
47.178 gchar *
47.179 -gmyth_util_time_to_mythformat_from_time_val (const GTimeVal * time)
47.180 +gmyth_util_time_to_mythformat_from_time_val ( const GTimeVal * time )
47.181 {
47.182 gchar *result =
47.183 - gmyth_util_time_to_isoformat_from_time_val_fmt ("%Y-%m-%dT%H:%M:%S",
47.184 - time);
47.185 + gmyth_util_time_to_isoformat_from_time_val_fmt ( "%Y-%m-%dT%H:%M:%S",
47.186 + time );
47.187
47.188 return result;
47.189 }
47.190 @@ -192,10 +198,10 @@
47.191 * @return GString* the converted isoformat string
47.192 */
47.193 gchar *
47.194 -gmyth_util_time_to_string_only_date (const GTimeVal * time)
47.195 +gmyth_util_time_to_string_only_date ( const GTimeVal * time )
47.196 {
47.197 gchar *result =
47.198 - gmyth_util_time_to_isoformat_from_time_val_fmt ("%Y-%m-%d", time);
47.199 + gmyth_util_time_to_isoformat_from_time_val_fmt ( "%Y-%m-%d", time );
47.200 //result[10] = ' ';
47.201 //result[ strlen(result) - 1] = '\0';
47.202 return result;
47.203 @@ -211,10 +217,10 @@
47.204 * @return GString* the converted isoformat string
47.205 */
47.206 gchar *
47.207 -gmyth_util_time_to_string_only_time (const GTimeVal * time)
47.208 +gmyth_util_time_to_string_only_time ( const GTimeVal * time )
47.209 {
47.210 gchar *result =
47.211 - gmyth_util_time_to_isoformat_from_time_val_fmt ("%H:%M:%S", time);
47.212 + gmyth_util_time_to_isoformat_from_time_val_fmt ( "%H:%M:%S", time );
47.213 //result[10] = ' ';
47.214 //result[ strlen(result) - 1] = '\0';
47.215 return result;
47.216 @@ -230,12 +236,12 @@
47.217 * @return GString* the converted string
47.218 */
47.219 GString *
47.220 -gmyth_util_time_to_string (time_t time_value)
47.221 +gmyth_util_time_to_string ( time_t time_value )
47.222 {
47.223 - GString *result = gmyth_util_time_to_isoformat (time_value);
47.224 + GString *result = gmyth_util_time_to_isoformat ( time_value );
47.225
47.226 result->str[10] = ' ';
47.227 - result->str[strlen (result->str) - 1] = '\0';
47.228 + result->str[strlen ( result->str ) - 1] = '\0';
47.229
47.230 return result;
47.231 }
47.232 @@ -250,11 +256,11 @@
47.233 * @return GString* the converted string
47.234 */
47.235 gchar *
47.236 -gmyth_util_time_to_string_from_time_val (const GTimeVal * time_val)
47.237 +gmyth_util_time_to_string_from_time_val ( const GTimeVal * time_val )
47.238 {
47.239 gchar *result =
47.240 - gmyth_util_time_to_isoformat_from_time_val_fmt ("%Y-%m-%d %H:%M:%S",
47.241 - time_val);
47.242 + gmyth_util_time_to_isoformat_from_time_val_fmt ( "%Y-%m-%d %H:%M:%S",
47.243 + time_val );
47.244
47.245 //result[10] = ' ';
47.246
47.247 @@ -268,20 +274,21 @@
47.248 * @return time_t the time converted value
47.249 */
47.250 time_t
47.251 -gmyth_util_string_to_time (GString * time_str)
47.252 +gmyth_util_string_to_time ( GString * time_str )
47.253 {
47.254 gint year, month, day, hour, min, sec;
47.255
47.256 - gmyth_debug ("[%s] time_str = %s. [%s]", __FUNCTION__, time_str != NULL ?
47.257 - time_str->str : "[time string is NULL!]", time_str->str);
47.258 + gmyth_debug ( "[%s] time_str = %s. [%s]", __FUNCTION__, time_str != NULL ?
47.259 + time_str->str : "[time string is NULL!]", time_str->str );
47.260
47.261 - if (sscanf (time_str->str, "%04d-%02d-%02d %02d:%02d:%02d",
47.262 - &year, &month, &day, &hour, &min, &sec) < 3) {
47.263 - gmyth_debug ("GMythUtil: isoformat_to_time converter error!\n");
47.264 + if ( sscanf ( time_str->str, "%04d-%02d-%02d %02d:%02d:%02d",
47.265 + &year, &month, &day, &hour, &min, &sec ) < 3 )
47.266 + {
47.267 + gmyth_debug ( "GMythUtil: isoformat_to_time converter error!\n" );
47.268 return 0;
47.269 }
47.270
47.271 - struct tm *tm_time = g_malloc0 (sizeof (struct tm));
47.272 + struct tm *tm_time = g_malloc0 ( sizeof ( struct tm ) );
47.273
47.274 tm_time->tm_year = year - 1900;
47.275 tm_time->tm_mon = month - 1;
47.276 @@ -290,7 +297,7 @@
47.277 tm_time->tm_min = min;
47.278 tm_time->tm_sec = sec;
47.279
47.280 - return mktime (tm_time);
47.281 + return mktime ( tm_time );
47.282 }
47.283
47.284 /** Converts a GString in the following format
47.285 @@ -300,23 +307,25 @@
47.286 * @return time_t the time converted value
47.287 */
47.288 struct tm *
47.289 -gmyth_util_time_val_to_date (const GTimeVal * time)
47.290 +gmyth_util_time_val_to_date ( const GTimeVal * time )
47.291 {
47.292 - struct tm *date = g_malloc0 (sizeof (struct tm));
47.293 + struct tm *date = g_malloc0 ( sizeof ( struct tm ) );
47.294 time_t time_micros = time->tv_sec; // + (gint)( time->tv_usec / G_USEC_PER_SEC );
47.295
47.296 - if (NULL == date) {
47.297 + if ( NULL == date )
47.298 + {
47.299 gmyth_debug
47.300 - ("GMythUtil: GDate *gmyth_util_time_val_to_date (GTimeVal* time) - converter error!\n");
47.301 + ( "GMythUtil: GDate *gmyth_util_time_val_to_date (GTimeVal* time) - converter error!\n" );
47.302 return NULL;
47.303 }
47.304
47.305 - if (NULL == localtime_r (&time_micros, date)) {
47.306 - gmyth_debug ("gmyth_util_time_to_isoformat convertion error!\n");
47.307 + if ( NULL == localtime_r ( &time_micros, date ) )
47.308 + {
47.309 + gmyth_debug ( "gmyth_util_time_to_isoformat convertion error!\n" );
47.310 return NULL;
47.311 }
47.312
47.313 - gmyth_debug ("Converted from GTimeVal == %s to GDate", asctime (date));
47.314 + gmyth_debug ( "Converted from GTimeVal == %s to GDate", asctime ( date ) );
47.315
47.316 return date;
47.317 }
47.318 @@ -328,37 +337,42 @@
47.319 * @return time_t the time converted value
47.320 */
47.321 GTimeVal *
47.322 -gmyth_util_string_to_time_val_fmt (const gchar * fmt_string,
47.323 - const gchar * time_str)
47.324 +gmyth_util_string_to_time_val_fmt ( const gchar * fmt_string,
47.325 + const gchar * time_str )
47.326 {
47.327 - GTimeVal *time = g_new0 (GTimeVal, 1);
47.328 + GTimeVal *time = g_new0 ( GTimeVal, 1 );
47.329 struct tm *tm_time = NULL;
47.330 time_t time_micros;
47.331 gchar *result;
47.332
47.333 - gmyth_debug ("[%s] time_str = %s. [%s]", time_str, time_str != NULL ?
47.334 - time_str : "[time string is NULL!]", time_str);
47.335 + gmyth_debug ( "[%s] time_str = %s. [%s]", time_str, time_str != NULL ?
47.336 + time_str : "[time string is NULL!]", time_str );
47.337
47.338 - if (NULL == time_str) {
47.339 - gmyth_debug ("GMythUtil: isoformat_to_time converter error!\n");
47.340 + if ( NULL == time_str )
47.341 + {
47.342 + gmyth_debug ( "GMythUtil: isoformat_to_time converter error!\n" );
47.343 return NULL;
47.344 }
47.345
47.346 - tm_time = g_malloc0 (sizeof (struct tm));
47.347 + tm_time = g_malloc0 ( sizeof ( struct tm ) );
47.348
47.349 /* we first check the return of strftime to allocate a buffer of the correct size */
47.350 - result = strptime (time_str, "%Y-%m-%dT%H:%M:%S", tm_time);
47.351 - if (NULL == result) {
47.352 + result = strptime ( time_str, "%Y-%m-%dT%H:%M:%S", tm_time );
47.353 + if ( NULL == result )
47.354 + {
47.355 /* we first check the return of strftime to allocate a buffer of the correct size */
47.356 - result = strptime (time_str, "%Y-%m-%dT%H:%M:%SZ", tm_time);
47.357 - if (NULL == result) {
47.358 + result = strptime ( time_str, "%Y-%m-%dT%H:%M:%SZ", tm_time );
47.359 + if ( NULL == result )
47.360 + {
47.361 /* we first check the return of strftime to allocate a buffer of the correct size */
47.362 - result = strptime (time_str, "%Y-%m-%d %H:%M:%S", tm_time);
47.363 - if (NULL == result) {
47.364 - result = strptime (time_str, "%Y-%m-%dT%H:%M", tm_time);
47.365 - if (NULL == result) {
47.366 - gmyth_debug ("Dateline (ISO result): %s", result);
47.367 - g_free (tm_time);
47.368 + result = strptime ( time_str, "%Y-%m-%d %H:%M:%S", tm_time );
47.369 + if ( NULL == result )
47.370 + {
47.371 + result = strptime ( time_str, "%Y-%m-%dT%H:%M", tm_time );
47.372 + if ( NULL == result )
47.373 + {
47.374 + gmyth_debug ( "Dateline (ISO result): %s", result );
47.375 + g_free ( tm_time );
47.376 return NULL;
47.377 //goto done;
47.378 }
47.379 @@ -366,13 +380,13 @@
47.380 }
47.381 }
47.382
47.383 - time_micros = mktime (tm_time);
47.384 + time_micros = mktime ( tm_time );
47.385
47.386 time->tv_sec = time_micros; // + (gint)( time_val->tv_usec / G_USEC_PER_SEC );
47.387
47.388 - gmyth_debug ("After mktime call... = %s", asctime (tm_time));
47.389 + gmyth_debug ( "After mktime call... = %s", asctime ( tm_time ) );
47.390
47.391 - g_free (tm_time);
47.392 + g_free ( tm_time );
47.393
47.394 return time;
47.395 }
47.396 @@ -384,10 +398,10 @@
47.397 * @return time_t the time converted value
47.398 */
47.399 GTimeVal *
47.400 -gmyth_util_string_to_time_val (const gchar * time_str)
47.401 +gmyth_util_string_to_time_val ( const gchar * time_str )
47.402 {
47.403 GTimeVal *time =
47.404 - gmyth_util_string_to_time_val_fmt ("%Y-%m-%d %H:%M:%S", time_str);
47.405 + gmyth_util_string_to_time_val_fmt ( "%Y-%m-%d %H:%M:%S", time_str );
47.406
47.407 return time;
47.408 }
47.409 @@ -401,42 +415,44 @@
47.410 * @return <code>true</code>, if the remote file exists.
47.411 */
47.412 gboolean
47.413 -gmyth_util_file_exists (GMythBackendInfo * backend_info, const gchar * filename)
47.414 +gmyth_util_file_exists ( GMythBackendInfo * backend_info,
47.415 + const gchar * filename )
47.416 {
47.417 GMythSocket *socket;
47.418 gboolean res;
47.419
47.420 - gmyth_debug ("Check if file %s exists", filename);
47.421 + gmyth_debug ( "Check if file %s exists", filename );
47.422
47.423 - g_return_val_if_fail (backend_info != NULL, FALSE);
47.424 - g_return_val_if_fail (filename != NULL, FALSE);
47.425 + g_return_val_if_fail ( backend_info != NULL, FALSE );
47.426 + g_return_val_if_fail ( filename != NULL, FALSE );
47.427
47.428 - socket = gmyth_socket_new ();
47.429 - res = gmyth_socket_connect_to_backend (socket, backend_info->hostname,
47.430 - backend_info->port, TRUE);
47.431 + socket = gmyth_socket_new ( );
47.432 + res = gmyth_socket_connect_to_backend ( socket, backend_info->hostname,
47.433 + backend_info->port, TRUE );
47.434
47.435 - if (res == TRUE) {
47.436 + if ( res == TRUE )
47.437 + {
47.438 GMythStringList *slist;
47.439 GMythProgramInfo *program = NULL;
47.440
47.441 - program = gmyth_program_info_new ();
47.442 - program->pathname = g_string_new (filename);
47.443 + program = gmyth_program_info_new ( );
47.444 + program->pathname = g_string_new ( filename );
47.445
47.446 - slist = gmyth_string_list_new ();
47.447 - gmyth_string_list_append_char_array (slist, "QUERY_CHECKFILE");
47.448 + slist = gmyth_string_list_new ( );
47.449 + gmyth_string_list_append_char_array ( slist, "QUERY_CHECKFILE" );
47.450
47.451 - gmyth_program_info_to_string_list (program, slist);
47.452 + gmyth_program_info_to_string_list ( program, slist );
47.453
47.454 - gmyth_socket_sendreceive_stringlist (socket, slist);
47.455 + gmyth_socket_sendreceive_stringlist ( socket, slist );
47.456
47.457 - res = (gmyth_string_list_get_int (slist, 0) == 1);
47.458 + res = ( gmyth_string_list_get_int ( slist, 0 ) == 1 );
47.459
47.460 - g_object_unref (program);
47.461 - g_object_unref (slist);
47.462 + g_object_unref ( program );
47.463 + g_object_unref ( slist );
47.464
47.465 - gmyth_socket_close_connection (socket);
47.466 + gmyth_socket_close_connection ( socket );
47.467 }
47.468 - g_object_unref (socket);
47.469 + g_object_unref ( socket );
47.470 return res;
47.471 }
47.472
47.473 @@ -450,50 +466,52 @@
47.474 * @return <code>true</code>, if the remote file exists.
47.475 */
47.476 gboolean
47.477 -gmyth_util_file_exists_and_get_remote_dir (GMythBackendInfo * backend_info,
47.478 - const gchar * filename, gchar ** current_dir)
47.479 +gmyth_util_file_exists_and_get_remote_dir ( GMythBackendInfo * backend_info,
47.480 + const gchar * filename,
47.481 + gchar ** current_dir )
47.482 {
47.483 GMythSocket *socket;
47.484 gboolean res;
47.485
47.486 *current_dir = NULL;
47.487
47.488 - socket = gmyth_socket_new ();
47.489 - res = gmyth_socket_connect_to_backend (socket, backend_info->hostname,
47.490 - backend_info->port, TRUE);
47.491 + socket = gmyth_socket_new ( );
47.492 + res = gmyth_socket_connect_to_backend ( socket, backend_info->hostname,
47.493 + backend_info->port, TRUE );
47.494
47.495 - if (res == TRUE) {
47.496 + if ( res == TRUE )
47.497 + {
47.498 GMythStringList *slist;
47.499 GMythProgramInfo *program = NULL;
47.500
47.501 - program = gmyth_program_info_new ();
47.502 - program->pathname = g_string_new (filename);
47.503 + program = gmyth_program_info_new ( );
47.504 + program->pathname = g_string_new ( filename );
47.505
47.506 - slist = gmyth_string_list_new ();
47.507 - gmyth_string_list_append_char_array (slist, "QUERY_CHECKFILE");
47.508 + slist = gmyth_string_list_new ( );
47.509 + gmyth_string_list_append_char_array ( slist, "QUERY_CHECKFILE" );
47.510
47.511 - gmyth_program_info_to_string_list (program, slist);
47.512 + gmyth_program_info_to_string_list ( program, slist );
47.513
47.514 - gmyth_socket_sendreceive_stringlist (socket, slist);
47.515 + gmyth_socket_sendreceive_stringlist ( socket, slist );
47.516
47.517 - res = (gmyth_string_list_get_int (slist, 0) == 1);
47.518 + res = ( gmyth_string_list_get_int ( slist, 0 ) == 1 );
47.519
47.520 - if ((gmyth_string_list_length (slist) > 1) &&
47.521 - gmyth_string_list_get_char_array (slist, 1) != NULL)
47.522 + if ( ( gmyth_string_list_length ( slist ) > 1 ) &&
47.523 + gmyth_string_list_get_char_array ( slist, 1 ) != NULL )
47.524 *current_dir =
47.525 - g_strdup (gmyth_string_list_get_char_array (slist, 1));
47.526 + g_strdup ( gmyth_string_list_get_char_array ( slist, 1 ) );
47.527
47.528 - if (*current_dir != NULL)
47.529 - gmyth_debug ("Current directory = %s.", (*current_dir != NULL)
47.530 - ? *current_dir : "[directory not found]");
47.531 + if ( *current_dir != NULL )
47.532 + gmyth_debug ( "Current directory = %s.", ( *current_dir != NULL )
47.533 + ? *current_dir : "[directory not found]" );
47.534
47.535 - g_object_unref (program);
47.536 + g_object_unref ( program );
47.537
47.538 - g_object_unref (slist);
47.539 + g_object_unref ( slist );
47.540
47.541 - gmyth_socket_close_connection (socket);
47.542 + gmyth_socket_close_connection ( socket );
47.543 }
47.544 - g_object_unref (socket);
47.545 + g_object_unref ( socket );
47.546 return res;
47.547 }
47.548
47.549 @@ -507,22 +525,22 @@
47.550 * @return The string representing the file name.
47.551 */
47.552 gchar *
47.553 -gmyth_util_create_filename (const gint chan_id, const GTimeVal * start_time)
47.554 +gmyth_util_create_filename ( const gint chan_id, const GTimeVal * start_time )
47.555 {
47.556 gchar *basename = NULL;
47.557
47.558 - g_return_val_if_fail (start_time != NULL, NULL);
47.559 + g_return_val_if_fail ( start_time != NULL, NULL );
47.560
47.561 gchar *isodate =
47.562 - gmyth_util_time_to_isoformat_from_time_val_fmt ("%Y%m%d%H%M%S",
47.563 - start_time);
47.564 + gmyth_util_time_to_isoformat_from_time_val_fmt ( "%Y%m%d%H%M%S",
47.565 + start_time );
47.566
47.567 - basename = g_strdup_printf ("%d_%s", chan_id, isodate);
47.568 + basename = g_strdup_printf ( "%d_%s", chan_id, isodate );
47.569
47.570 - gmyth_debug ("Basename (from chan_id and start_time): %s", basename);
47.571 + gmyth_debug ( "Basename (from chan_id and start_time): %s", basename );
47.572
47.573 - if (isodate)
47.574 - g_free (isodate);
47.575 + if ( isodate )
47.576 + g_free ( isodate );
47.577
47.578 return basename;
47.579 }
47.580 @@ -535,55 +553,60 @@
47.581 * @return a pointer to a GList with all the channels.
47.582 */
47.583 GList *
47.584 -gmyth_util_get_channel_list (GMythBackendInfo * backend_info)
47.585 +gmyth_util_get_channel_list ( GMythBackendInfo * backend_info )
47.586 {
47.587 GMythRecorder *recorder;
47.588 GList *channel_list = NULL;
47.589 gboolean res = FALSE;
47.590
47.591 - gmyth_debug ("Gets channel list.");
47.592 + gmyth_debug ( "Gets channel list." );
47.593
47.594 - g_return_val_if_fail (backend_info != NULL, FALSE);
47.595 + g_return_val_if_fail ( backend_info != NULL, FALSE );
47.596
47.597 recorder =
47.598 - gmyth_recorder_new (1,
47.599 - g_string_new (gmyth_backend_info_get_hostname
47.600 - (backend_info)), gmyth_backend_info_get_port (backend_info));
47.601 - res = gmyth_recorder_setup (recorder);
47.602 + gmyth_recorder_new ( 1,
47.603 + g_string_new ( gmyth_backend_info_get_hostname
47.604 + ( backend_info ) ),
47.605 + gmyth_backend_info_get_port ( backend_info ) );
47.606 + res = gmyth_recorder_setup ( recorder );
47.607
47.608 - if (res == TRUE) {
47.609 + if ( res == TRUE )
47.610 + {
47.611 //GList* channel_list = gmyth_recorder_get_channel_list( recorder );
47.612 - gmyth_debug ("Yeah, got channel list!!!");
47.613 + gmyth_debug ( "Yeah, got channel list!!!" );
47.614 GList *ch = NULL;
47.615 GMythChannelInfo *channel_info = NULL;
47.616
47.617 - for (ch = gmyth_recorder_get_channel_list (recorder); ch != NULL;) {
47.618 - channel_info = g_malloc0 (sizeof (GMythChannelInfo));
47.619 + for ( ch = gmyth_recorder_get_channel_list ( recorder ); ch != NULL; )
47.620 + {
47.621 + channel_info = g_malloc0 ( sizeof ( GMythChannelInfo ) );
47.622 channel_info->channel_ID = 0;
47.623 channel_info->channel_num =
47.624 - g_string_new (g_strdup ((gchar *) ch->data));
47.625 - channel_info->channel_name = g_string_new ("");
47.626 - gmyth_debug ("Printing channel info... (%s)",
47.627 - channel_info->channel_num->str);
47.628 + g_string_new ( g_strdup ( ( gchar * ) ch->data ) );
47.629 + channel_info->channel_name = g_string_new ( "" );
47.630 + gmyth_debug ( "Printing channel info... (%s)",
47.631 + channel_info->channel_num->str );
47.632 channel_list =
47.633 - g_list_append (channel_list,
47.634 - g_memdup (channel_info, sizeof (GMythChannelInfo)));
47.635 + g_list_append ( channel_list,
47.636 + g_memdup ( channel_info,
47.637 + sizeof ( GMythChannelInfo ) ) );
47.638
47.639 - ch = g_list_next (ch);
47.640 + ch = g_list_next ( ch );
47.641
47.642 - if (channel_info != NULL)
47.643 - g_free (channel_info);
47.644 + if ( channel_info != NULL )
47.645 + g_free ( channel_info );
47.646 }
47.647
47.648 - } /* if */
47.649 - else {
47.650 - gmyth_debug ("No, couldn't get the channel list!!!");
47.651 + } /* if */
47.652 + else
47.653 + {
47.654 + gmyth_debug ( "No, couldn't get the channel list!!!" );
47.655 }
47.656
47.657 - gmyth_debug ("Got %d channels!!!", g_list_length (channel_list));
47.658 + gmyth_debug ( "Got %d channels!!!", g_list_length ( channel_list ) );
47.659
47.660
47.661 - g_object_unref (recorder);
47.662 + g_object_unref ( recorder );
47.663
47.664 return channel_list;
47.665 }
47.666 @@ -596,51 +619,56 @@
47.667 * @return The program info's listage.
47.668 */
47.669 GSList *
47.670 -gmyth_util_get_all_recordings (GMythBackendInfo * backend_info)
47.671 +gmyth_util_get_all_recordings ( GMythBackendInfo * backend_info )
47.672 {
47.673 GSList *program_list = NULL;
47.674 GMythSocket *socket;
47.675 gboolean res;
47.676
47.677 - socket = gmyth_socket_new ();
47.678 - res = gmyth_socket_connect_to_backend (socket, backend_info->hostname,
47.679 - backend_info->port, TRUE);
47.680 + socket = gmyth_socket_new ( );
47.681 + res = gmyth_socket_connect_to_backend ( socket, backend_info->hostname,
47.682 + backend_info->port, TRUE );
47.683
47.684 - if (res == TRUE) {
47.685 - GMythStringList *slist = gmyth_string_list_new ();
47.686 + if ( res == TRUE )
47.687 + {
47.688 + GMythStringList *slist = gmyth_string_list_new ( );
47.689 guint pos = 0;
47.690
47.691 - gmyth_string_list_append_char_array (slist, "QUERY_RECORDINGS Play");
47.692 + gmyth_string_list_append_char_array ( slist, "QUERY_RECORDINGS Play" );
47.693
47.694 - gmyth_socket_sendreceive_stringlist (socket, slist);
47.695 + gmyth_socket_sendreceive_stringlist ( socket, slist );
47.696
47.697 - if (slist != NULL && (gmyth_string_list_length (slist) > 0)) {
47.698 + if ( slist != NULL && ( gmyth_string_list_length ( slist ) > 0 ) )
47.699 + {
47.700 GMythProgramInfo *program = NULL;
47.701
47.702 - gmyth_debug ("OK! Got the program list [size=%d].",
47.703 - gmyth_string_list_length (slist));
47.704 + gmyth_debug ( "OK! Got the program list [size=%d].",
47.705 + gmyth_string_list_length ( slist ) );
47.706
47.707 - do {
47.708 + do
47.709 + {
47.710 program =
47.711 - gmyth_program_info_from_string_list_from_pos (slist, pos);
47.712 + gmyth_program_info_from_string_list_from_pos ( slist, pos );
47.713
47.714 - if (program != NULL) {
47.715 + if ( program != NULL )
47.716 + {
47.717 pos += 41;
47.718
47.719 - program_list = g_slist_append (program_list, program);
47.720 - } else
47.721 + program_list = g_slist_append ( program_list, program );
47.722 + }
47.723 + else
47.724 break;
47.725
47.726 }
47.727 - while (gmyth_string_list_length (slist) > pos);
47.728 + while ( gmyth_string_list_length ( slist ) > pos );
47.729
47.730 }
47.731 /* if */
47.732 - g_object_unref (slist);
47.733 + g_object_unref ( slist );
47.734
47.735 - gmyth_socket_close_connection (socket);
47.736 + gmyth_socket_close_connection ( socket );
47.737 }
47.738 - g_object_unref (socket);
47.739 + g_object_unref ( socket );
47.740
47.741 return program_list;
47.742 }
47.743 @@ -654,27 +682,31 @@
47.744 * @return The requested program info.
47.745 */
47.746 GMythProgramInfo *
47.747 -gmyth_util_get_recording_from_channel (GMythBackendInfo * backend_info,
47.748 - const gchar * channel)
47.749 +gmyth_util_get_recording_from_channel ( GMythBackendInfo * backend_info,
47.750 + const gchar * channel )
47.751 {
47.752 GSList *program_list = NULL;
47.753 GMythProgramInfo *program = NULL;
47.754
47.755 - program_list = gmyth_util_get_all_recordings (backend_info);
47.756 + program_list = gmyth_util_get_all_recordings ( backend_info );
47.757
47.758 - if (program_list != NULL && g_slist_length (program_list) > 0) {
47.759 + if ( program_list != NULL && g_slist_length ( program_list ) > 0 )
47.760 + {
47.761 GMythProgramInfo *program = NULL;
47.762 guint pos = 0;
47.763
47.764 - gmyth_debug ("OK! Got the program list [size=%d].",
47.765 - g_slist_length (program_list));
47.766 + gmyth_debug ( "OK! Got the program list [size=%d].",
47.767 + g_slist_length ( program_list ) );
47.768
47.769 - while (pos < g_slist_length (program_list)) {
47.770 - program = (GMythProgramInfo *) g_slist_nth_data (program_list, pos);
47.771 + while ( pos < g_slist_length ( program_list ) )
47.772 + {
47.773 + program =
47.774 + ( GMythProgramInfo * ) g_slist_nth_data ( program_list, pos );
47.775
47.776 - if (program != NULL && program->channame != NULL &&
47.777 - g_ascii_strncasecmp (program->channame->str, channel,
47.778 - strlen (channel)) == 0) {
47.779 + if ( program != NULL && program->channame != NULL &&
47.780 + g_ascii_strncasecmp ( program->channame->str, channel,
47.781 + strlen ( channel ) ) == 0 )
47.782 + {
47.783 break;
47.784 }
47.785
47.786 @@ -692,7 +724,7 @@
47.787 /* Hacked from glib 2.10 <gtime.c> */
47.788
47.789 static time_t
47.790 -mktime_utc (struct tm *tm)
47.791 +mktime_utc ( struct tm *tm )
47.792 {
47.793 time_t retval;
47.794
47.795 @@ -703,90 +735,98 @@
47.796 #endif
47.797
47.798 #ifndef HAVE_TIMEGM
47.799 - if (tm->tm_mon < 0 || tm->tm_mon > 11)
47.800 - return (time_t) - 1;
47.801 + if ( tm->tm_mon < 0 || tm->tm_mon > 11 )
47.802 + return ( time_t ) - 1;
47.803
47.804 - retval = (tm->tm_year - 70) * 365;
47.805 - retval += (tm->tm_year - 68) / 4;
47.806 + retval = ( tm->tm_year - 70 ) * 365;
47.807 + retval += ( tm->tm_year - 68 ) / 4;
47.808 retval += days_before[tm->tm_mon] + tm->tm_mday - 1;
47.809
47.810 - if (tm->tm_year % 4 == 0 && tm->tm_mon < 2)
47.811 + if ( tm->tm_year % 4 == 0 && tm->tm_mon < 2 )
47.812 retval -= 1;
47.813
47.814 retval =
47.815 - ((((retval * 24) + tm->tm_hour) * 60) + tm->tm_min) * 60 + tm->tm_sec;
47.816 + ( ( ( ( retval * 24 ) + tm->tm_hour ) * 60 ) + tm->tm_min ) * 60 +
47.817 + tm->tm_sec;
47.818 #else
47.819 - retval = timegm (tm);
47.820 + retval = timegm ( tm );
47.821 #endif /* !HAVE_TIMEGM */
47.822
47.823 return retval;
47.824 }
47.825
47.826 gboolean
47.827 -g_time_val_from_iso8601 (const gchar * iso_date, GTimeVal * time_)
47.828 +g_time_val_from_iso8601 ( const gchar * iso_date, GTimeVal * time_ )
47.829 {
47.830 struct tm tm;
47.831 long val;
47.832
47.833 - g_return_val_if_fail (iso_date != NULL, FALSE);
47.834 - g_return_val_if_fail (time_ != NULL, FALSE);
47.835 + g_return_val_if_fail ( iso_date != NULL, FALSE );
47.836 + g_return_val_if_fail ( time_ != NULL, FALSE );
47.837
47.838 - val = strtoul (iso_date, (char **) &iso_date, 10);
47.839 - if (*iso_date == '-') {
47.840 + val = strtoul ( iso_date, ( char ** ) &iso_date, 10 );
47.841 + if ( *iso_date == '-' )
47.842 + {
47.843 /* YYYY-MM-DD */
47.844 tm.tm_year = val - 1900;
47.845 iso_date++;
47.846 - tm.tm_mon = strtoul (iso_date, (char **) &iso_date, 10) - 1;
47.847 + tm.tm_mon = strtoul ( iso_date, ( char ** ) &iso_date, 10 ) - 1;
47.848
47.849 - if (*iso_date++ != '-')
47.850 + if ( *iso_date++ != '-' )
47.851 return FALSE;
47.852
47.853 - tm.tm_mday = strtoul (iso_date, (char **) &iso_date, 10);
47.854 - } else {
47.855 + tm.tm_mday = strtoul ( iso_date, ( char ** ) &iso_date, 10 );
47.856 + }
47.857 + else
47.858 + {
47.859 /* YYYYMMDD */
47.860 tm.tm_mday = val % 100;
47.861 - tm.tm_mon = (val % 10000) / 100 - 1;
47.862 + tm.tm_mon = ( val % 10000 ) / 100 - 1;
47.863 tm.tm_year = val / 10000 - 1900;
47.864 }
47.865
47.866 - if (*iso_date++ != 'T')
47.867 + if ( *iso_date++ != 'T' )
47.868 return FALSE;
47.869
47.870 - val = strtoul (iso_date, (char **) &iso_date, 10);
47.871 - if (*iso_date == ':') {
47.872 + val = strtoul ( iso_date, ( char ** ) &iso_date, 10 );
47.873 + if ( *iso_date == ':' )
47.874 + {
47.875 /* hh:mm:ss */
47.876 tm.tm_hour = val;
47.877 iso_date++;
47.878 - tm.tm_min = strtoul (iso_date, (char **) &iso_date, 10);
47.879 + tm.tm_min = strtoul ( iso_date, ( char ** ) &iso_date, 10 );
47.880
47.881 - if (*iso_date++ != ':')
47.882 + if ( *iso_date++ != ':' )
47.883 return FALSE;
47.884
47.885 - tm.tm_sec = strtoul (iso_date, (char **) &iso_date, 10);
47.886 - } else {
47.887 + tm.tm_sec = strtoul ( iso_date, ( char ** ) &iso_date, 10 );
47.888 + }
47.889 + else
47.890 + {
47.891 /* hhmmss */
47.892 tm.tm_sec = val % 100;
47.893 - tm.tm_min = (val % 10000) / 100;
47.894 + tm.tm_min = ( val % 10000 ) / 100;
47.895 tm.tm_hour = val / 10000;
47.896 }
47.897
47.898 - time_->tv_sec = mktime_utc (&tm);
47.899 + time_->tv_sec = mktime_utc ( &tm );
47.900 time_->tv_usec = 1;
47.901
47.902 - if (*iso_date == '.')
47.903 - time_->tv_usec = strtoul (iso_date + 1, (char **) &iso_date, 10);
47.904 + if ( *iso_date == '.' )
47.905 + time_->tv_usec = strtoul ( iso_date + 1, ( char ** ) &iso_date, 10 );
47.906
47.907 - if (*iso_date == '+' || *iso_date == '-') {
47.908 - gint sign = (*iso_date == '+') ? -1 : 1;
47.909 + if ( *iso_date == '+' || *iso_date == '-' )
47.910 + {
47.911 + gint sign = ( *iso_date == '+' ) ? -1 : 1;
47.912
47.913 - val = 60 * strtoul (iso_date + 1, (char **) &iso_date, 10);
47.914 + val = 60 * strtoul ( iso_date + 1, ( char ** ) &iso_date, 10 );
47.915
47.916 - if (*iso_date == ':')
47.917 - val = 60 * val + strtoul (iso_date + 1, NULL, 10);
47.918 + if ( *iso_date == ':' )
47.919 + val = 60 * val + strtoul ( iso_date + 1, NULL, 10 );
47.920 else
47.921 - val = 60 * (val / 100) + (val % 100);
47.922 + val = 60 * ( val / 100 ) + ( val % 100 );
47.923
47.924 - time_->tv_sec += (time_t) (val * sign);
47.925 + time_->tv_sec += ( time_t ) ( val * sign );
47.926 }
47.927
47.928 return TRUE;
47.929 @@ -794,18 +834,19 @@
47.930
47.931
47.932 gchar *
47.933 -g_time_val_to_iso8601 (GTimeVal * time_)
47.934 +g_time_val_to_iso8601 ( GTimeVal * time_ )
47.935 {
47.936 gchar *retval;
47.937
47.938 - g_return_val_if_fail (time_->tv_usec >= 0
47.939 - && time_->tv_usec < G_USEC_PER_SEC, NULL);
47.940 + g_return_val_if_fail ( time_->tv_usec >= 0
47.941 + && time_->tv_usec < G_USEC_PER_SEC, NULL );
47.942
47.943 #define ISO_8601_LEN 21
47.944 #define ISO_8601_FORMAT "%Y-%m-%dT%H:%M:%SZ"
47.945 - retval = g_new0 (gchar, ISO_8601_LEN + 1);
47.946 + retval = g_new0 ( gchar, ISO_8601_LEN + 1 );
47.947
47.948 - strftime (retval, ISO_8601_LEN, ISO_8601_FORMAT, gmtime (&(time_->tv_sec)));
47.949 + strftime ( retval, ISO_8601_LEN, ISO_8601_FORMAT,
47.950 + gmtime ( &( time_->tv_sec ) ) );
47.951
47.952 return retval;
47.953 }
47.954 @@ -814,32 +855,34 @@
47.955 /* Hacked from glib 2.10 <gdate.c> */
47.956
47.957 void
47.958 -g_date_set_time_t (GDate * date, time_t timet)
47.959 +g_date_set_time_t ( GDate * date, time_t timet )
47.960 {
47.961 struct tm tm;
47.962
47.963 - g_return_if_fail (date != NULL);
47.964 + g_return_if_fail ( date != NULL );
47.965
47.966 #ifdef HAVE_LOCALTIME_R
47.967 - localtime_r (&timet, &tm);
47.968 + localtime_r ( &timet, &tm );
47.969 #else
47.970 {
47.971 - struct tm *ptm = localtime (&timet);
47.972 + struct tm *ptm = localtime ( &timet );
47.973
47.974 - if (ptm == NULL) {
47.975 + if ( ptm == NULL )
47.976 + {
47.977 /* Happens at least in Microsoft's C library if you pass a
47.978 * negative time_t. Use 2000-01-01 as default date.
47.979 */
47.980 #ifndef G_DISABLE_CHECKS
47.981 - g_return_if_fail_warning (G_LOG_DOMAIN, "g_date_set_time",
47.982 - "ptm != NULL");
47.983 + g_return_if_fail_warning ( G_LOG_DOMAIN, "g_date_set_time",
47.984 + "ptm != NULL" );
47.985 #endif
47.986
47.987 tm.tm_mon = 0;
47.988 tm.tm_mday = 1;
47.989 tm.tm_year = 100;
47.990 - } else
47.991 - memcpy ((void *) &tm, (void *) ptm, sizeof (struct tm));
47.992 + }
47.993 + else
47.994 + memcpy ( ( void * ) &tm, ( void * ) ptm, sizeof ( struct tm ) );
47.995 }
47.996 #endif
47.997
47.998 @@ -849,16 +892,17 @@
47.999 date->day = tm.tm_mday;
47.1000 date->year = tm.tm_year + 1900;
47.1001
47.1002 - g_return_if_fail (g_date_valid_dmy (date->day, date->month, date->year));
47.1003 + g_return_if_fail ( g_date_valid_dmy
47.1004 + ( date->day, date->month, date->year ) );
47.1005
47.1006 date->dmy = TRUE;
47.1007 }
47.1008
47.1009
47.1010 void
47.1011 -g_date_set_time_val (GDate * date, GTimeVal * timeval)
47.1012 +g_date_set_time_val ( GDate * date, GTimeVal * timeval )
47.1013 {
47.1014 - g_date_set_time_t (date, (time_t) timeval->tv_sec);
47.1015 + g_date_set_time_t ( date, ( time_t ) timeval->tv_sec );
47.1016 }
47.1017
47.1018
48.1 --- a/gmyth/src/gmyth_util.h Wed May 23 19:21:26 2007 +0100
48.2 +++ b/gmyth/src/gmyth_util.h Wed May 23 19:50:41 2007 +0100
48.3 @@ -10,22 +10,21 @@
48.4 * @author Hallyson Luiz de Morais Melo <hallyson.melo@indt.org.br>
48.5 * @author Rosfran Borges <rosfran.borges@indt.org.br>
48.6 *
48.7 - *//*
48.8 - *
48.9 - * This program is free software; you can redistribute it and/or modify
48.10 - * it under the terms of the GNU Lesser General Public License as published by
48.11 - * the Free Software Foundation; either version 2 of the License, or
48.12 - * (at your option) any later version.
48.13 - *
48.14 - * This program is distributed in the hope that it will be useful,
48.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
48.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48.17 - * GNU General Public License for more details.
48.18 - *
48.19 - * You should have received a copy of the GNU Lesser General Public License
48.20 - * along with this program; if not, write to the Free Software
48.21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
48.22 - */
48.23 + *
48.24 + * This program is free software; you can redistribute it and/or modify
48.25 + * it under the terms of the GNU Lesser General Public License as published by
48.26 + * the Free Software Foundation; either version 2 of the License, or
48.27 + * (at your option) any later version.
48.28 + *
48.29 + * This program is distributed in the hope that it will be useful,
48.30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
48.31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48.32 + * GNU General Public License for more details.
48.33 + *
48.34 + * You should have received a copy of the GNU Lesser General Public License
48.35 + * along with this program; if not, write to the Free Software
48.36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
48.37 + */
48.38
48.39 #ifndef GMYTH_UTIL_H_
48.40 #define GMYTH_UTIL_H_
48.41 @@ -37,44 +36,50 @@
48.42 #include "gmyth_backendinfo.h"
48.43 #include "gmyth_programinfo.h"
48.44
48.45 -G_BEGIN_DECLS GString *gmyth_util_time_to_isoformat (time_t time_value);
48.46 -GString *gmyth_util_time_to_string (time_t time_value);
48.47 -time_t gmyth_util_string_to_time (GString * time_str);
48.48 +G_BEGIN_DECLS GString *gmyth_util_time_to_isoformat ( time_t time_value );
48.49 +GString *gmyth_util_time_to_string ( time_t time_value );
48.50 +time_t gmyth_util_string_to_time ( GString * time_str );
48.51
48.52 -gchar *gmyth_util_time_to_isoformat_from_time_val_fmt (const gchar *
48.53 - fmt_string, const GTimeVal * time_val);
48.54 +gchar *gmyth_util_time_to_isoformat_from_time_val_fmt ( const gchar *
48.55 + fmt_string,
48.56 + const GTimeVal *
48.57 + time_val );
48.58
48.59 -GTimeVal *gmyth_util_string_to_time_val_fmt (const gchar * fmt_string,
48.60 - const gchar * time_str);
48.61 +GTimeVal *gmyth_util_string_to_time_val_fmt ( const gchar * fmt_string,
48.62 + const gchar * time_str );
48.63
48.64 -GTimeVal *gmyth_util_string_to_time_val (const gchar * time_str);
48.65 +GTimeVal *gmyth_util_string_to_time_val ( const gchar * time_str );
48.66
48.67 -gchar *gmyth_util_time_to_isoformat_from_time_val (const GTimeVal * time);
48.68 -gchar *gmyth_util_time_to_mythformat_from_time_val (const GTimeVal * time);
48.69 +gchar *gmyth_util_time_to_isoformat_from_time_val ( const GTimeVal * time );
48.70 +gchar *gmyth_util_time_to_mythformat_from_time_val ( const GTimeVal * time );
48.71
48.72 -gchar *gmyth_util_time_to_string_only_date (const GTimeVal * time);
48.73 +gchar *gmyth_util_time_to_string_only_date ( const GTimeVal * time );
48.74
48.75 -gchar *gmyth_util_time_to_string_only_time (const GTimeVal * time);
48.76 +gchar *gmyth_util_time_to_string_only_time ( const GTimeVal * time );
48.77
48.78 -gchar *gmyth_util_time_to_string_from_time_val (const GTimeVal * time_val);
48.79 +gchar *gmyth_util_time_to_string_from_time_val ( const GTimeVal * time_val );
48.80
48.81 -struct tm *gmyth_util_time_val_to_date (const GTimeVal * time);
48.82 +struct tm *gmyth_util_time_val_to_date ( const GTimeVal * time );
48.83
48.84 -gboolean gmyth_util_file_exists (GMythBackendInfo * backend_info,
48.85 - const gchar * filename);
48.86 +gboolean gmyth_util_file_exists ( GMythBackendInfo * backend_info,
48.87 + const gchar * filename );
48.88
48.89 -gboolean gmyth_util_file_exists_and_get_remote_dir (GMythBackendInfo *
48.90 - backend_info, const gchar * filename, gchar ** current_dir);
48.91 +gboolean gmyth_util_file_exists_and_get_remote_dir ( GMythBackendInfo *
48.92 + backend_info,
48.93 + const gchar * filename,
48.94 + gchar ** current_dir );
48.95
48.96 -gchar *gmyth_util_create_filename (const gint chan_id,
48.97 - const GTimeVal * start_time);
48.98 +gchar *gmyth_util_create_filename ( const gint chan_id,
48.99 + const GTimeVal * start_time );
48.100
48.101 -GList *gmyth_util_get_channel_list (GMythBackendInfo * backend_info);
48.102 +GList *gmyth_util_get_channel_list ( GMythBackendInfo * backend_info );
48.103
48.104 -GSList *gmyth_util_get_all_recordings (GMythBackendInfo * backend_info);
48.105 +GSList *gmyth_util_get_all_recordings ( GMythBackendInfo * backend_info );
48.106
48.107 -GMythProgramInfo *gmyth_util_get_recording_from_channel (GMythBackendInfo *
48.108 - backend_info, const gchar * channel);
48.109 +GMythProgramInfo *gmyth_util_get_recording_from_channel ( GMythBackendInfo *
48.110 + backend_info,
48.111 + const gchar *
48.112 + channel );
48.113
48.114 G_END_DECLS
48.115 #endif /*GMYTH_UTIL_H_ */
49.1 --- a/gmyth/src/gmyth_vlc.c Wed May 23 19:21:26 2007 +0100
49.2 +++ b/gmyth/src/gmyth_vlc.c Wed May 23 19:50:41 2007 +0100
49.3 @@ -36,8 +36,8 @@
49.4 #include "gmyth_socket.h"
49.5
49.6 /* static functions */
49.7 -static int _socket_send (int socket, gchar * msg);
49.8 -static int _socket_recv (int socket, gchar * buf);
49.9 +static int _socket_send ( int socket, gchar * msg );
49.10 +static int _socket_recv ( int socket, gchar * buf );
49.11
49.12 /** Primitive function to send a message through the socket
49.13 *
49.14 @@ -46,17 +46,17 @@
49.15 * @return 0 if success
49.16 */
49.17 static int
49.18 -_socket_send (int socket, gchar * msg)
49.19 +_socket_send ( int socket, gchar * msg )
49.20 {
49.21 - size_t size = strlen (msg) + 2; // (\n + \0)
49.22 - gchar *final = (gchar *) g_malloc0 (sizeof (gchar) * size);
49.23 + size_t size = strlen ( msg ) + 2; // (\n + \0)
49.24 + gchar *final = ( gchar * ) g_malloc0 ( sizeof ( gchar ) * size );
49.25
49.26 - g_snprintf (final, size, "%s\n", msg);
49.27 + g_snprintf ( final, size, "%s\n", msg );
49.28
49.29 - if (send (socket, final, strlen (final), 0) == -1)
49.30 - perror ("GMyth_VLC: send error");
49.31 + if ( send ( socket, final, strlen ( final ), 0 ) == -1 )
49.32 + perror ( "GMyth_VLC: send error" );
49.33
49.34 - g_free (final);
49.35 + g_free ( final );
49.36 return 0;
49.37 }
49.38
49.39 @@ -68,12 +68,13 @@
49.40 * @return 0 if success
49.41 */
49.42 static int
49.43 -_socket_recv (int socket, gchar * buf)
49.44 +_socket_recv ( int socket, gchar * buf )
49.45 {
49.46 int numbytes = 0;
49.47
49.48 - if ((numbytes = recv (socket, buf, BUFFER - 1, 0)) == -1) {
49.49 - perror ("GMyth_VLC: recv error");
49.50 + if ( ( numbytes = recv ( socket, buf, BUFFER - 1, 0 ) ) == -1 )
49.51 + {
49.52 + perror ( "GMyth_VLC: recv error" );
49.53 return -1;
49.54 }
49.55
49.56 @@ -91,18 +92,19 @@
49.57 * @return 0 if success
49.58 */
49.59 int
49.60 -gmyth_vlc_setup_output (GMythVlc * vlc, int output, gchar * kind, gchar * opts)
49.61 +gmyth_vlc_setup_output ( GMythVlc * vlc, int output, gchar * kind,
49.62 + gchar * opts )
49.63 {
49.64 int ret;
49.65
49.66 - size_t size = strlen (opts) + 25;
49.67 - gchar *msg = g_malloc0 (sizeof (gchar) * size);
49.68 + size_t size = strlen ( opts ) + 25;
49.69 + gchar *msg = g_malloc0 ( sizeof ( gchar ) * size );
49.70
49.71 - g_snprintf (msg, size, "setup output%d %s %s", output, kind, opts);
49.72 + g_snprintf ( msg, size, "setup output%d %s %s", output, kind, opts );
49.73
49.74 - ret = _socket_send (vlc->sockfd, msg);
49.75 + ret = _socket_send ( vlc->sockfd, msg );
49.76
49.77 - g_free (msg);
49.78 + g_free ( msg );
49.79 return ret;
49.80 }
49.81
49.82 @@ -115,9 +117,9 @@
49.83 * @return 0 if success
49.84 */
49.85 int
49.86 -gmyth_vlc_clean_playlist (GMythVlc * vlc)
49.87 +gmyth_vlc_clean_playlist ( GMythVlc * vlc )
49.88 {
49.89 - return _socket_send (vlc->sockfd, "del all");
49.90 + return _socket_send ( vlc->sockfd, "del all" );
49.91 }
49.92
49.93
49.94 @@ -129,16 +131,16 @@
49.95 * @return 0 if success
49.96 */
49.97 int
49.98 -gmyth_vlc_control_input (GMythVlc * vlc, int output, gchar * command)
49.99 +gmyth_vlc_control_input ( GMythVlc * vlc, int output, gchar * command )
49.100 {
49.101 size_t size = 25;
49.102 - gchar *msg = g_malloc0 (sizeof (gchar) * size);
49.103 + gchar *msg = g_malloc0 ( sizeof ( gchar ) * size );
49.104
49.105 - g_snprintf (msg, size, "control output%d %s", output, command);
49.106 + g_snprintf ( msg, size, "control output%d %s", output, command );
49.107
49.108 - int ret = _socket_send (vlc->sockfd, msg);
49.109 + int ret = _socket_send ( vlc->sockfd, msg );
49.110
49.111 - g_free (msg);
49.112 + g_free ( msg );
49.113 return ret;
49.114 }
49.115
49.116 @@ -152,9 +154,9 @@
49.117 * @return 0 if success
49.118 */
49.119 int
49.120 -gmyth_vlc_create_input (GMythVlc * vlc, int output, gchar * file)
49.121 +gmyth_vlc_create_input ( GMythVlc * vlc, int output, gchar * file )
49.122 {
49.123 - return gmyth_vlc_setup_output (vlc, output, "input", file);
49.124 + return gmyth_vlc_setup_output ( vlc, output, "input", file );
49.125 }
49.126
49.127
49.128 @@ -166,43 +168,44 @@
49.129 * @return 0 if success
49.130 */
49.131 int
49.132 -gmyth_vlc_create_channel (GMythVlc * vlc, gchar * type, int port, int vcodec)
49.133 +gmyth_vlc_create_channel ( GMythVlc * vlc, gchar * type, int port, int vcodec )
49.134 {
49.135 int ret;
49.136 size_t size = 40;
49.137 - gchar *msg = (gchar *) g_malloc0 (sizeof (gchar) * size);
49.138 + gchar *msg = ( gchar * ) g_malloc0 ( sizeof ( gchar ) * size );
49.139
49.140 - g_snprintf (msg, size, "new output%d %s enabled loop",
49.141 - vlc->n_outputs, type);
49.142 + g_snprintf ( msg, size, "new output%d %s enabled loop",
49.143 + vlc->n_outputs, type );
49.144
49.145 - ret = _socket_send (vlc->sockfd, msg);
49.146 + ret = _socket_send ( vlc->sockfd, msg );
49.147
49.148 - if (ret > -1) {
49.149 - gmyth_vlc_setup_output (vlc, vlc->n_outputs, "option", "sout-keep=1");
49.150 + if ( ret > -1 )
49.151 + {
49.152 + gmyth_vlc_setup_output ( vlc, vlc->n_outputs, "option", "sout-keep=1" );
49.153
49.154 - g_free (msg);
49.155 + g_free ( msg );
49.156 size = 256;
49.157 - msg = (gchar *) g_malloc0 (sizeof (gchar) * size);
49.158 + msg = ( gchar * ) g_malloc0 ( sizeof ( gchar ) * size );
49.159
49.160 - if (vcodec == MPEG1)
49.161 + if ( vcodec == MPEG1 )
49.162 // Best transcode option for N800 (MP1V)
49.163 - g_snprintf (msg, size, "#transcode{vcodec=mp1v,vb=384,"
49.164 - "fps=25.0,scale=1,acodec=mpga,"
49.165 - "ab=64,channels=1}:duplicate{dst="
49.166 - "std{access=http,mux=mpeg1,dst=" ":%d}}", port);
49.167 + g_snprintf ( msg, size, "#transcode{vcodec=mp1v,vb=384,"
49.168 + "fps=25.0,scale=1,acodec=mpga,"
49.169 + "ab=64,channels=1}:duplicate{dst="
49.170 + "std{access=http,mux=mpeg1,dst=" ":%d}}", port );
49.171 else
49.172 // Best transcode option for N800 (THEORA)
49.173 - g_snprintf (msg, size, "#transcode{vcodec=theo,vb=384,"
49.174 - "fps=25.0,scale=1,acodec=vorb,"
49.175 - "ab=64,channels=1}:duplicate{dst="
49.176 - "std{access=http,mux=ogg,dst=" ":%d}}", port);
49.177 + g_snprintf ( msg, size, "#transcode{vcodec=theo,vb=384,"
49.178 + "fps=25.0,scale=1,acodec=vorb,"
49.179 + "ab=64,channels=1}:duplicate{dst="
49.180 + "std{access=http,mux=ogg,dst=" ":%d}}", port );
49.181
49.182 - ret = gmyth_vlc_setup_output (vlc, vlc->n_outputs, "output", msg);
49.183 + ret = gmyth_vlc_setup_output ( vlc, vlc->n_outputs, "output", msg );
49.184
49.185 vlc->n_outputs++;
49.186 }
49.187
49.188 - g_free (msg);
49.189 + g_free ( msg );
49.190
49.191 return ret;
49.192 }
49.193 @@ -216,44 +219,48 @@
49.194 * @return 0 if success
49.195 */
49.196 int
49.197 -gmyth_vlc_connect (GMythVlc * vlc, GMythBackendInfo * backend_info,
49.198 - gchar * passwd, int port)
49.199 +gmyth_vlc_connect ( GMythVlc * vlc, GMythBackendInfo * backend_info,
49.200 + gchar * passwd, int port )
49.201 {
49.202 int numbytes;
49.203
49.204 - if ((vlc->he = gethostbyname (backend_info->hostname)) == NULL) {
49.205 - herror ("GMyth_VLC: gethostbyname error");
49.206 + if ( ( vlc->he = gethostbyname ( backend_info->hostname ) ) == NULL )
49.207 + {
49.208 + herror ( "GMyth_VLC: gethostbyname error" );
49.209 return -1;
49.210 }
49.211
49.212 - if ((vlc->sockfd = socket (PF_INET, SOCK_STREAM, 0)) == -1) {
49.213 - perror ("GMyth_VLC: socket error");
49.214 + if ( ( vlc->sockfd = socket ( PF_INET, SOCK_STREAM, 0 ) ) == -1 )
49.215 + {
49.216 + perror ( "GMyth_VLC: socket error" );
49.217 return -1;
49.218 }
49.219 // Socket properties
49.220 vlc->their_addr.sin_family = AF_INET;
49.221 - vlc->their_addr.sin_port = htons (port);
49.222 - vlc->their_addr.sin_addr = *((struct in_addr *) vlc->he->h_addr);
49.223 - memset (&(vlc->their_addr.sin_zero), '\0', 8);
49.224 + vlc->their_addr.sin_port = htons ( port );
49.225 + vlc->their_addr.sin_addr = *( ( struct in_addr * ) vlc->he->h_addr );
49.226 + memset ( &( vlc->their_addr.sin_zero ), '\0', 8 );
49.227
49.228 - if (connect (vlc->sockfd, (struct sockaddr *) &(vlc->their_addr),
49.229 - sizeof (struct sockaddr)) == -1) {
49.230 - perror ("GMyth_VLC: connect error. Check VLC's telnet interface");
49.231 + if ( connect ( vlc->sockfd, ( struct sockaddr * ) &( vlc->their_addr ),
49.232 + sizeof ( struct sockaddr ) ) == -1 )
49.233 + {
49.234 + perror ( "GMyth_VLC: connect error. Check VLC's telnet interface" );
49.235 return -1;
49.236 }
49.237 // Receive the Password's Prompt
49.238 - numbytes = _socket_recv (vlc->sockfd, vlc->buf);
49.239 + numbytes = _socket_recv ( vlc->sockfd, vlc->buf );
49.240
49.241 // Send the Password. We don't have to
49.242 // care about passwords being sent in plain text
49.243 // because telnet protocol does it.
49.244 - _socket_send (vlc->sockfd, passwd);
49.245 + _socket_send ( vlc->sockfd, passwd );
49.246
49.247 // Receive the Welcome msg
49.248 - numbytes = _socket_recv (vlc->sockfd, vlc->buf);
49.249 - if (numbytes > -1)
49.250 - if (strncmp (vlc->buf, "\r\nWrong password.", 17) == 0) {
49.251 - perror ("Gmyth_VLC: passwd error. Check your passwd");
49.252 + numbytes = _socket_recv ( vlc->sockfd, vlc->buf );
49.253 + if ( numbytes > -1 )
49.254 + if ( strncmp ( vlc->buf, "\r\nWrong password.", 17 ) == 0 )
49.255 + {
49.256 + perror ( "Gmyth_VLC: passwd error. Check your passwd" );
49.257 return -2;
49.258 }
49.259
49.260 @@ -269,17 +276,18 @@
49.261 * @return 0 if success
49.262 */
49.263 int
49.264 -gmyth_vlc_disconnect (GMythVlc * vlc)
49.265 +gmyth_vlc_disconnect ( GMythVlc * vlc )
49.266 {
49.267
49.268 int ret;
49.269
49.270 - ret = gmyth_vlc_clean_playlist (vlc);
49.271 + ret = gmyth_vlc_clean_playlist ( vlc );
49.272
49.273 - if (ret > -1) {
49.274 + if ( ret > -1 )
49.275 + {
49.276 vlc->n_outputs = 0;
49.277 vlc->n_inputs = 0;
49.278 }
49.279
49.280 - return close (vlc->sockfd);
49.281 + return close ( vlc->sockfd );
49.282 }
50.1 --- a/gmyth/src/gmyth_vlc.h Wed May 23 19:21:26 2007 +0100
50.2 +++ b/gmyth/src/gmyth_vlc.h Wed May 23 19:50:41 2007 +0100
50.3 @@ -53,42 +53,42 @@
50.4 typedef struct _GMythVlc GMythVlc;
50.5
50.6 struct _GMythVlc
50.7 -{
50.8 - int sockfd;
50.9 + {
50.10 + int sockfd;
50.11
50.12 - // Number of outputs used
50.13 - int n_outputs;
50.14 + // Number of outputs used
50.15 + int n_outputs;
50.16
50.17 - // Number of inputs
50.18 - int n_inputs;
50.19 + // Number of inputs
50.20 + int n_inputs;
50.21
50.22 - // Socket vars
50.23 - struct hostent *he;
50.24 - struct sockaddr_in their_addr;
50.25 + // Socket vars
50.26 + struct hostent *he;
50.27 + struct sockaddr_in their_addr;
50.28
50.29 - char buf[BUFFER];
50.30 -};
50.31 + char buf[BUFFER];
50.32 + };
50.33
50.34
50.35
50.36 -int gmyth_vlc_setup_output (GMythVlc * vlc, int output,
50.37 - gchar * kind, gchar * opts);
50.38 +int gmyth_vlc_setup_output ( GMythVlc * vlc, int output,
50.39 + gchar * kind, gchar * opts );
50.40
50.41
50.42 -int gmyth_vlc_clean_playlist (GMythVlc * vlc);
50.43 +int gmyth_vlc_clean_playlist ( GMythVlc * vlc );
50.44
50.45
50.46 -int gmyth_vlc_control_input (GMythVlc * vlc, int output, gchar * command);
50.47 +int gmyth_vlc_control_input ( GMythVlc * vlc, int output, gchar * command );
50.48
50.49 -int gmyth_vlc_create_input (GMythVlc * vlc, int output, gchar * file);
50.50 +int gmyth_vlc_create_input ( GMythVlc * vlc, int output, gchar * file );
50.51
50.52 -int gmyth_vlc_create_channel (GMythVlc * vlc, gchar * type,
50.53 - int port, int vcodec);
50.54 +int gmyth_vlc_create_channel ( GMythVlc * vlc, gchar * type,
50.55 + int port, int vcodec );
50.56
50.57 -int gmyth_vlc_connect (GMythVlc * vlc, GMythBackendInfo * backend_info,
50.58 - gchar * passwd, int port);
50.59 +int gmyth_vlc_connect ( GMythVlc * vlc, GMythBackendInfo * backend_info,
50.60 + gchar * passwd, int port );
50.61
50.62 -int gmyth_vlc_disconnect (GMythVlc * vlc);
50.63 +int gmyth_vlc_disconnect ( GMythVlc * vlc );
50.64
50.65 G_END_DECLS
50.66 #endif /* __GMYTH_VLC_H__ */