This is an example of how to use the TV Service's Channel lock and unlock queries.
#include <glib-object.h>
#include <stdlib.h>
#include <stdio.h>
#include <glib.h>
#include <string.h>
#include <vconf.h>
#include <glib/gprintf.h>
#include "tv_service_logger.h"
#define CHANNEL_LOCK_PASSWORD_VALUE "0000"
static GMainLoop *loop = NULL;
gint service_id = 0;
static gboolean channel_unlock();
static gboolean channel_lock();
gboolean
exit_loop(gpointer user_data)
{
g_main_loop_quit(loop);
return FALSE;
}
void
{
switch(event) {
gboolean *lock_status = (gboolean*) data;
g_printf ("tv_service_callback: get tuner locked callback:%d\n", *lock_status);
}
break;
g_printf(
"tv_service_callback: set resolution width:%d,height:%d", res_data->
width,res_data->
height);
}
break;
g_printf ("tv_service_callback: get channel locked callback\n");
}
break;
g_printf ("tv_service_callback: get channel unlocked callback\n");
}
break;
default:
g_printf ("get callback_type: %d\n", event);
}
return;
}
void
signal_handle(int signum)
{
g_printf ("In signal handle!\n");
if(live_handle) {
}
g_main_loop_quit(loop);
exit(0);
return;
}
gboolean
live_channel_unlock(gpointer user_data)
{
channel_unlock();
return FALSE;
}
gboolean
live_channel_lock(gpointer user_data)
{
channel_lock();
return FALSE;
}
static
gboolean channel_unlock()
{
gint res = 0;
printf("unlock channel Success \n");
gboolean locked;
g_printf("tv_service_get_channel_locked: locked[%d]\n", locked);
} else {
g_printf("tv_service_get_channel_locked fail !!!\n");
return FALSE;
}
} else {
g_printf("unlock channel Fail !!!");
return FALSE;
}
return TRUE;
}
static
gboolean channel_lock()
{
gint res;
g_printf("lock channel Success \n");
gboolean locked;
g_printf("tv_service_get_channel_locked, locked[%d]\n", locked);
} else {
g_printf("tv_service_get_channel_locked fail !!!\n");
return FALSE;
}
} else {
g_printf("lock channel Fail !!!\n");
return FALSE;
}
return TRUE;
}
gint
static live_tune()
{
gint res;
g_printf ("In main tv_service_live_create failed!\n");
return -1;
}
g_printf ("After tv_service_live_create\n");
g_printf ("After tv_service_live_register_callback\n");
g_printf("tv_service_live_tune failed\n");
return -1;
}
g_printf ("ERROR !!! tv_service_live_set_volume fail!\n");
return -1;
}
return 0;
}
int
main(int argc, char ** argv)
{
gint res = 0;
gboolean result;
gboolean locked;
service_id = 1;
loop = g_main_loop_new (NULL, FALSE);
signal(SIGINT,signal_handle);
res = vconf_set_str("db/menu/system/change_pin", CHANNEL_LOCK_PASSWORD_VALUE);
if (res) {
g_printf("get password error, res[%d] \n", res);
return -1;
}
g_printf("tv_service_get_channel_locked fail !!! \n");
return -1;
}
g_printf("get channel lock status:[%d]\n", locked);
if (locked) {
if (TRUE == channel_unlock()) {
result = channel_lock();
} else {
return -1;
}
} else {
result = channel_lock();
}
if (result == FALSE) {
g_printf("channel lock fail\n");
return -1;
}
live_tune();
g_timeout_add_seconds (10, live_channel_unlock, NULL);
g_timeout_add_seconds (20, live_channel_lock, NULL);
g_timeout_add_seconds (30, live_channel_unlock, NULL);
g_timeout_add_seconds (40, exit_loop, NULL);
g_main_loop_run (loop);
g_printf ("exit loop ###################################\n");
if(live_handle) {
}
return 0;
}