gmyth/tests/gmyth_test_tvchain.c
branchtrunk
changeset 754 cb885ee44618
parent 750 312d6bc514f3
     1.1 --- a/gmyth/tests/gmyth_test_tvchain.c	Thu Jun 14 18:19:52 2007 +0100
     1.2 +++ b/gmyth/tests/gmyth_test_tvchain.c	Thu Jun 14 20:40:47 2007 +0100
     1.3 @@ -12,122 +12,122 @@
     1.4  
     1.5  #define URI_DEFAULT	"myth://192.168.3.165:6543/livetv?channel=9"
     1.6  
     1.7 -static gboolean
     1.8 +static          gboolean
     1.9  test_tvchain_setup(gchar * uri)
    1.10  {
    1.11 -  GMythTVChain *tvchain = NULL;
    1.12 -  gchar *channel = NULL;
    1.13 -  gboolean ret = TRUE;
    1.14 +    GMythTVChain   *tvchain = NULL;
    1.15 +    gchar          *channel = NULL;
    1.16 +    gboolean        ret = TRUE;
    1.17  
    1.18 -  if (NULL == uri)
    1.19 -	uri = g_strdup(URI_DEFAULT);
    1.20 +    if (NULL == uri)
    1.21 +        uri = g_strdup(URI_DEFAULT);
    1.22  
    1.23 -  GMythURI *gmyth_uri = gmyth_uri_new_with_value(uri);
    1.24 +    GMythURI       *gmyth_uri = gmyth_uri_new_with_value(uri);
    1.25  
    1.26 -  GMythBackendInfo *backend_info = gmyth_backend_info_new_with_uri(uri);
    1.27 +    GMythBackendInfo *backend_info = gmyth_backend_info_new_with_uri(uri);
    1.28  
    1.29 -  channel = gmyth_uri_get_channel_name(gmyth_uri);
    1.30 +    channel = gmyth_uri_get_channel_name(gmyth_uri);
    1.31  
    1.32 -  /* Creates livetv chain handler */
    1.33 -  tvchain = gmyth_tvchain_new();
    1.34 -  gmyth_tvchain_initialize(tvchain, backend_info);
    1.35 +    /*
    1.36 +     * Creates livetv chain handler 
    1.37 +     */
    1.38 +    tvchain = gmyth_tvchain_new();
    1.39 +    gmyth_tvchain_initialize(tvchain, backend_info);
    1.40  
    1.41 -  if (tvchain == NULL || tvchain->tvchain_id == NULL)
    1.42 -	{
    1.43 -	  ret = FALSE;
    1.44 -	  goto init_failed;
    1.45 -	}
    1.46 +    if (tvchain == NULL || tvchain->tvchain_id == NULL) {
    1.47 +        ret = FALSE;
    1.48 +        goto init_failed;
    1.49 +    }
    1.50  
    1.51 -  ret = (gmyth_tvchain_get_id(tvchain) != NULL);
    1.52 -  if (!ret)
    1.53 -	{
    1.54 -	  g_debug("[%s] TV Chain ID is NULL.\n", __FUNCTION__);
    1.55 -	  goto init_failed;
    1.56 -	}
    1.57 +    ret = (gmyth_tvchain_get_id(tvchain) != NULL);
    1.58 +    if (!ret) {
    1.59 +        g_debug("[%s] TV Chain ID is NULL.\n", __FUNCTION__);
    1.60 +        goto init_failed;
    1.61 +    }
    1.62  
    1.63 -  gmyth_backend_info_set_username(tvchain->backend_info, "mythtv");
    1.64 -  gmyth_backend_info_set_password(tvchain->backend_info, "mythtv");
    1.65 -  gmyth_backend_info_set_db_name(tvchain->backend_info, "mythconverg");
    1.66 -  GList *prog_list = gmyth_tvchain_get_program_info_from_channel(tvchain,
    1.67 -																 channel);
    1.68 -  GMythProgramInfo *ch_prog = NULL;
    1.69 -  if (prog_list != NULL && g_list_length(prog_list) > 0)
    1.70 -	{
    1.71 -	  ch_prog = (GMythProgramInfo *) g_list_nth_data(prog_list, 0);
    1.72 -	  g_debug("Channel program info (from a list with size = %d)!",
    1.73 -			  g_list_length(prog_list));
    1.74 -	  gmyth_program_info_print(ch_prog);
    1.75 -	}
    1.76 +    gmyth_backend_info_set_username(tvchain->backend_info, "mythtv");
    1.77 +    gmyth_backend_info_set_password(tvchain->backend_info, "mythtv");
    1.78 +    gmyth_backend_info_set_db_name(tvchain->backend_info, "mythconverg");
    1.79 +    GList          *prog_list =
    1.80 +        gmyth_tvchain_get_program_info_from_channel(tvchain,
    1.81 +                                                    channel);
    1.82 +    GMythProgramInfo *ch_prog = NULL;
    1.83 +    if (prog_list != NULL && g_list_length(prog_list) > 0) {
    1.84 +        ch_prog = (GMythProgramInfo *) g_list_nth_data(prog_list, 0);
    1.85 +        g_debug("Channel program info (from a list with size = %d)!",
    1.86 +                g_list_length(prog_list));
    1.87 +        gmyth_program_info_print(ch_prog);
    1.88 +    }
    1.89  
    1.90 -  g_debug("Program Info: %s\n", gmyth_program_info_to_string(ch_prog));
    1.91 +    g_debug("Program Info: %s\n", gmyth_program_info_to_string(ch_prog));
    1.92  
    1.93 -  /* Reload all TV chain from Mysql database. */
    1.94 -  gmyth_tvchain_reload_all(tvchain);
    1.95 +    /*
    1.96 +     * Reload all TV chain from Mysql database. 
    1.97 +     */
    1.98 +    gmyth_tvchain_reload_all(tvchain);
    1.99  
   1.100 -  if (tvchain == NULL)
   1.101 -	{
   1.102 -	  ret = FALSE;
   1.103 -	  goto init_failed;
   1.104 -	}
   1.105 +    if (tvchain == NULL) {
   1.106 +        ret = FALSE;
   1.107 +        goto init_failed;
   1.108 +    }
   1.109  
   1.110 -  /* Get program info from database using chanid and starttime */
   1.111 -  ch_prog = gmyth_tvchain_get_program_at(tvchain, 0);
   1.112 -  if (NULL == ch_prog)
   1.113 -	{
   1.114 -	  g_debug("TVChain not successfully started.\n");
   1.115 -	  ret = FALSE;
   1.116 -	  goto init_failed;
   1.117 -	}
   1.118 -  else
   1.119 -	{
   1.120 -	  ret = TRUE;
   1.121 -	  g_debug
   1.122 -		("GMythTVChain: All requests to backend to start TV were OK. [%s]\n",
   1.123 -		 ch_prog->pathname->str);
   1.124 -	}
   1.125 +    /*
   1.126 +     * Get program info from database using chanid and starttime 
   1.127 +     */
   1.128 +    ch_prog = gmyth_tvchain_get_program_at(tvchain, 0);
   1.129 +    if (NULL == ch_prog) {
   1.130 +        g_debug("TVChain not successfully started.\n");
   1.131 +        ret = FALSE;
   1.132 +        goto init_failed;
   1.133 +    } else {
   1.134 +        ret = TRUE;
   1.135 +        g_debug
   1.136 +            ("GMythTVChain: All requests to backend to start TV were OK. [%s]\n",
   1.137 +             ch_prog->pathname->str);
   1.138 +    }
   1.139  
   1.140  
   1.141 -init_failed:
   1.142 -  if (tvchain != NULL)
   1.143 -	g_object_unref(tvchain);
   1.144 +  init_failed:
   1.145 +    if (tvchain != NULL)
   1.146 +        g_object_unref(tvchain);
   1.147  
   1.148 -  if (gmyth_uri != NULL)
   1.149 -	g_object_unref(gmyth_uri);
   1.150 +    if (gmyth_uri != NULL)
   1.151 +        g_object_unref(gmyth_uri);
   1.152  
   1.153 -  if (ch_prog != NULL)
   1.154 -	g_object_unref(ch_prog);
   1.155 +    if (ch_prog != NULL)
   1.156 +        g_object_unref(ch_prog);
   1.157  
   1.158 -  if (prog_list != NULL)
   1.159 -	g_list_free(prog_list);
   1.160 +    if (prog_list != NULL)
   1.161 +        g_list_free(prog_list);
   1.162  
   1.163 -  if (backend_info != NULL)
   1.164 -	g_object_unref(backend_info);
   1.165 +    if (backend_info != NULL)
   1.166 +        g_object_unref(backend_info);
   1.167  
   1.168 -  return ret;
   1.169 +    return ret;
   1.170  
   1.171  }
   1.172  
   1.173  gint
   1.174  main(gint args, const gchar ** argv)
   1.175  {
   1.176 -  gboolean ret;
   1.177 +    gboolean        ret;
   1.178  
   1.179 -  g_type_init();
   1.180 -  g_thread_init(NULL);
   1.181 +    g_type_init();
   1.182 +    g_thread_init(NULL);
   1.183  
   1.184 -  fprintf(stdout, SYNC_STRING);
   1.185 -  fflush(NULL);
   1.186 -  getchar();
   1.187 +    fprintf(stdout, SYNC_STRING);
   1.188 +    fflush(NULL);
   1.189 +    getchar();
   1.190  
   1.191 -  if (args > 1)
   1.192 -	ret = test_tvchain_setup(argv[1]);
   1.193 -  else
   1.194 -	ret = test_tvchain_setup(NULL);
   1.195 +    if (args > 1)
   1.196 +        ret = test_tvchain_setup(argv[1]);
   1.197 +    else
   1.198 +        ret = test_tvchain_setup(NULL);
   1.199  
   1.200 -  if (!ret)
   1.201 -	g_debug("Error when running TV Chain setup test script!");
   1.202 -  else
   1.203 -	g_debug("TV Chain setup test script finished with success.");
   1.204 +    if (!ret)
   1.205 +        g_debug("Error when running TV Chain setup test script!");
   1.206 +    else
   1.207 +        g_debug("TV Chain setup test script finished with success.");
   1.208  
   1.209 -  return (0);
   1.210 +    return (0);
   1.211  }