static void startup()
{	
	location_init();
	loc = location_new(LOCATION_METHOD_GPS);

	loop = g_main_loop_new(NULL,FALSE);		
	g_main_loop_run (loop);

	tet_printf("\n TC startup");	
}
int
main (int argc, char *argv[])
{
	LocationObject *loc = NULL;
	
	location_init ();

	loop = g_main_loop_new (NULL, TRUE);

	loc  = location_new (LOCATION_METHOD_GPS);
	if (!loc) {
		g_debug("location_new failed");
		return -1;
	}

	LocationPosition *rb = location_position_new(0, 37.258, 127.056, 0, LOCATION_STATUS_2D_FIX);
	LocationPosition *lt = location_position_new(0, 37.260, 127.054, 0, LOCATION_STATUS_2D_FIX);
	LocationBoundary *bound = location_boundary_new_for_rect(lt, rb);
	location_position_free (rb);
	location_position_free (lt);
	if (bound) {
		g_object_set(loc, "boundary", bound, NULL);
		location_boundary_free(bound);
	} else g_warning("failed to location_boundary_new_for_rect()");	
	g_object_get(loc, "boundary", &bound, NULL);
	if (bound) {
		g_debug("Set property>> boundary> type: %d, (%f,%f),(%f,%f)", 
			bound->type,
			bound->rect.right_bottom->latitude, bound->rect.right_bottom->longitude,
			bound->rect.left_top->latitude, bound->rect.left_top->longitude);
		location_boundary_free (bound);
	} else 	g_warning("failed to set property> boundary");

	g_signal_connect (loc, "service-enabled", G_CALLBACK(cb_service_enabled), loc);
	g_signal_connect (loc, "service-disabled", G_CALLBACK(cb_service_disabled), loc);
	g_signal_connect (loc, "zone-in", G_CALLBACK(cb_zone_in), loc);
	g_signal_connect (loc, "zone-out", G_CALLBACK(cb_zone_out), loc);
	
	if( LOCATION_ERROR_NONE != location_start (loc) ){
		g_debug("location_start failed");
		return -1;
	}

	g_timeout_add_seconds (60, exit_program, NULL);
	g_main_loop_run (loop);

	location_stop (loc);
	location_free (loc);

	return 0;
}
static void startup()
{
	location_init();
	loc = location_new(LOCATION_METHOD_GPS);
	tet_printf("\n TC startup");
}
Пример #4
0
int main( int argc, char *arvg[] ) {
	int quit = 0;
	int config_status = 0;
	int event;

#ifdef __WIN32__
	freopen( "cabrio.out", "w", stdout );
	freopen( "cabrio.err", "w", stderr );
#endif

	config_status = config_open( NULL );
	if( config_status == -1 )
		return -1;

	if( sdl_init() != 0 )
		bail();

	if( ogl_init() != 0 )
		bail();
	
	/* Clear the screen as soon as we can. This avoids graphics
	 * glitches which can occur with some SDL implementations. */
	ogl_clear();
	sdl_swap();

	if( event_init() != 0 )
		bail();

	if( font_init() != 0 )
		bail();

	if( config_status == 1 ) {
		/* Config file didn't exist, so run the setup utility */
		if( setup() != 0 )
			return -1;
		config_update();
		if( config_create() != 0 )
			return -1;
	}

	location_init();

	/* If config or location results in a new font, it'll be loaded here. */
	font_free();
	font_init();

	/* Large game lists take a while to initialise,
	 * so show the background while we wait... */
	bg_init();
	bg_clear();
	bg_draw();
	sdl_swap();

	if( platform_init() != 0 )
		bail();

	if( category_init() != 0 )
		bail();

	if( game_sel_init() != 0 )
		bail();

	if( hint_init() != 0 )
		bail();

	if( snap_init() != 0 )
		bail();
	
	if( game_list_create() != 0 )
		bail();

	if( menu_init() != 0 )
		bail();

	if( submenu_init() != 0 )
		bail();

	sound_init();
	video_init();
	
	event_flush();

	if( !config_get()->iface.theme.menu.auto_hide )
		menu_show();
		
	focus_set( FOCUS_GAMESEL );

	while( !quit ) {
		ogl_clear();
		bg_draw();
		snap_draw();
		if (!config_get()->iface.hide_buttons)
			hint_draw();
		menu_draw();
		submenu_draw();
		game_sel_draw();
		sdl_swap();
		if (Mix_PlayingMusic() != 1 && config_get()->iface.theme_sound && reader_running == 0) 
			playmusic();
		if (( event = event_poll() )) {
			if( supress_wait == 0 ) {
				if( event == EVENT_QUIT ) {
					quit = 1;
				}
				else {
					supress();
					event_process( event );
				}
			}
		}
		if( supress_wait > 0 )
			supress_wait--;
		
		sdl_frame_delay();
	}
	clean_up();
	return 0;
}
Пример #5
0
/*
  This method returns:
  -2 if plugin consider this request should be totally discarded!
  -1 on error
  0  nothing has been done
  1  things has been done on psp_req element
*/
int
cb_ls_localdb_search_user_location (psp_request_t * psp_req)
{
  osip_route_t *route;
  ppl_uinfo_t *uinfo;
  int i;
  int numlocs = 0 /* DAB */ ;
  osip_message_t *request;
  request = psp_request_get_request(psp_req);

  /* default OUTPUT */
  if (ISSET_R_ROUTE_MODE (ls_localdb_context->flag))
    psp_request_set_property (psp_req, PSP_STAY_ON_PATH);
  else
    psp_request_set_property (psp_req, 0);

  /* mode */
  if (ISSET_FORKING_MODE (ls_localdb_context->flag))
    psp_request_set_mode (psp_req, PSP_FORK_MODE);
  else if (ISSET_SEQUENTIAL_MODE (ls_localdb_context->flag))
    psp_request_set_mode (psp_req, PSP_SEQ_MODE);
  else if (ISSET_REDIRECT_MODE (ls_localdb_context->flag))
    {
      psp_request_set_uas_status (psp_req, 302);
      psp_request_set_mode (psp_req, PSP_UAS_MODE);
    }
  else
    psp_request_set_mode (psp_req, PSP_FORK_MODE);

  psp_request_set_state (psp_req, PSP_MANDATE);

  /* THIS IS MANDATORY FOR ALL PLUGINS TO CHECK THAT!
     this is rarely used as a previous plugin 'ls_localdb' should have
     checked for it. In case you remove it. */
  osip_message_get_route (request, 1, &route);
  if (route != NULL)
    {
      if (ISSET_SEQUENTIAL_MODE (ls_localdb_context->flag))
	psp_request_set_mode (psp_req, PSP_SEQ_MODE);
      else
	psp_request_set_mode (psp_req, PSP_FORK_MODE);
      psp_request_set_state (psp_req, PSP_MANDATE);
      return 0;			/* do nothing.. */
    }

  if (request->req_uri->username == NULL)
    {
      /* Propose 484, but let's keep searching if another plugin can find
	 the destination. */
      psp_request_set_uas_status (psp_req, 484);
      psp_request_set_state (psp_req, PSP_CONTINUE);
      psp_request_set_mode (psp_req, PSP_UAS_MODE);
      return 0;
    }

  /* look for this URI in our list of users */
  uinfo = ppl_uinfo_find_by_aor (request->req_uri);
  if (uinfo != NULL)
    {
      /* add all locations to the psp_req element */
      binding_t *bind;
      binding_t *bindnext;
      location_t *loc;
      osip_uri_t *url;

      bind = uinfo->bindings;
      bindnext = uinfo->bindings;
      for (; bind != NULL; bind = bindnext)
	{
	  bindnext = bind->next;
	  i = ppl_uinfo_check_binding (bind);
	  if (i != 0)
	    {			/* binding is expired */
	      ppl_uinfo_remove_binding (uinfo, bind);
	    }
	}
      bind = uinfo->bindings;
      if (bind == NULL)
	{			/* user is not around... */
	  OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL,
				  "ls_localdb plugin: User Exist but has no valid registration!\n"));
	  psp_request_set_uas_status (psp_req, 480);
	  psp_request_set_mode (psp_req, PSP_UAS_MODE);
	  psp_request_set_state (psp_req, PSP_MANDATE);
	  return 0;
	}

      bindnext = uinfo->bindings;	/* DAB */
      for (; bind != NULL; bind = bindnext)	/* DAB */
	{			/* DAB */
	  /* If this is an INVITE Request,  collect all locations  DAB */
#ifdef EXPERIMENTAL_FORK
	  if (MSG_IS_INVITE (request))
	    bindnext = bind->next;	/* DAB */
	  else
	    bindnext = NULL;	/* DAB */
#else
	  /* always accept only ONE location even for INVITE */
	  /* this is a limitation for stability reason as the forking mode
	     is unfinished (calculation of the best response is not compliant
	     to the rfc3261.txt behavior. */
	  bindnext = NULL;	/* loop will be execute onece only */
#endif

	  i = osip_uri_clone (bind->contact->url, &url);
	  if (i != 0)
	    {
	      OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL,
				      "ls_localdb plugin: Could not clone contact info!\n"));
	      psp_request_set_uas_status (psp_req, 400);
	      psp_request_set_mode (psp_req, PSP_UAS_MODE);
	      psp_request_set_state (psp_req, PSP_MANDATE);
	      return -1;
	    }
	  i = location_init (&loc, url, 3600);
	  if (i != 0)
	    {
	      osip_uri_free (url);
	      OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_BUG, NULL,
				      "ls_localdb plugin: Could not create location info!\n"));
	      psp_request_set_uas_status (psp_req, 400);
	      psp_request_set_mode (psp_req, PSP_UAS_MODE);
	      psp_request_set_state (psp_req, PSP_MANDATE);
	      return -1;
	    }

	  /* new support for rfc3327.txt and Path header */
	  if (bind->path!=NULL)
	    location_set_path(loc, osip_strdup(bind->path));

	  ADD_ELEMENT (psp_req->locations, loc);
	  numlocs++;		/* DAB */
	}			/* DAB */

      OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO1, NULL,
			      "ls_localdb plugin: %d locations found!\n",
			      numlocs));
      return 0;
    }

  /* no user location found in local database... */
  psp_request_set_uas_status (psp_req, 404);
  psp_request_set_state (psp_req, PSP_CONTINUE);
  psp_request_set_mode (psp_req, PSP_UAS_MODE);
  OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO1, NULL,
			  "ls_localdb plugin: No location found for known user: return 404 Not found!!\n"));
  return 0;
}
Пример #6
0
/*
  This method returns:
  -2 if plugin consider this request should be totally discarded!
  -1 on error
  0  nothing has been done
  1  things has been done on psp_req element
*/
int cb_groups_search_location(psp_request_t *psp_req)
{
    location_t *loc;
    osip_route_t *route;
    int i;
    int index;
    int match;
    grp_t *grp=NULL;

    osip_uri_param_t *psp_param;
    osip_message_t *request;
    request = psp_request_get_request(psp_req);

    OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,
                          "groups plugin: entering cb_groups_search_location\n"));

    /* default OUTPUT */
    if (ISSET_R_ROUTE_MODE(groups_context->flag))
        psp_request_set_property(psp_req, PSP_STAY_ON_PATH);
    else
        psp_request_set_property(psp_req, 0);

    psp_request_set_mode(psp_req, PSP_SFULL_MODE);

    i=0;
    for (; !osip_list_eol(&request->routes, i); i++)
    {
        osip_message_get_route (request, i, &route);
        if (0 != psp_core_is_responsible_for_this_route(route->url))
        {
            psp_request_set_mode (psp_req, PSP_SFULL_MODE);
            psp_request_set_state (psp_req, PSP_MANDATE);
            OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO1, NULL,
                                    "groups plugin: mandate statefull handling for route.\n"));
            return 0;
        }
    }

    psp_request_set_state(psp_req, PSP_MANDATE);

    if (i>1)
    {
        psp_request_set_uas_status(psp_req, 482); /* loop? */
        psp_request_set_mode(psp_req, PSP_UAS_MODE);
        return 0;
    }
    if (i==1)
    {
        osip_message_get_route(request, 0, &route); /* should be the first one */
        /* if this route header contains the "psp" parameter, it means
        the element does not come from a pre-route-set header (in this
         last case, we want to execute the plugin for the initial request) */
        /* NON compliant UAs (not returning this parameter) are guilty. */
        osip_uri_uparam_get_byname (route->url, "psp", &psp_param);
        if (psp_param!=NULL)
        {
            psp_request_set_state(psp_req, PSP_MANDATE);
            psp_request_set_mode (psp_req, PSP_SFULL_MODE);
            /* got it, leave this plugin. */
            return 0;
        }
    }

    if (request->req_uri->username==NULL
            || request->req_uri->host==NULL)
    {
        OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO1, NULL,
                                "groups plugin: No username in uri.\n"));
        psp_request_set_state(psp_req, PSP_PROPOSE);
        psp_request_set_uas_status(psp_req, 404);
        psp_request_set_mode(psp_req, PSP_UAS_MODE);
        return 0;
    }

    /* search for a group */
    match=0;
    for (index=0; index<MAX_GROUPS; index++)
    {
        grp = &(groups_context->grps[index]);
        if (grp->group[0]!='\0')
        {
            if (osip_strcasecmp(grp->group, request->req_uri->username)==0)
            {
                if (grp->domain[0]=='\0')
                {
                    match=1;
                    break;
                }
                else if (osip_strcasecmp(grp->domain, request->req_uri->host)==0)
                {
                    match=1;
                    break;
                }
            }
        }
        grp=NULL;
    }

    if (match==1 && grp!=NULL)
    {
        OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO1, NULL,
                                "groups plugin: A group match this call (%s).\n",
                                grp->group));

        for (index=0; index<MAX_MEMBERS; index++)
        {
            osip_uri_t *uri;
            int i;
            char *dest;

            dest = grp->members[index];
            if (dest[0]=='\0')
                break;
            OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO3,NULL,
                                  "groups plugin: members of %s: %s\n",
                                  grp->group,
                                  dest));

            osip_uri_init(&uri);
            i = osip_uri_parse(uri, dest);

            if (i==0)
            {
                i = location_init(&loc, uri, 3600);
                if (i!=0)
                {   /* This can only happen in case we don't have enough memory */
                    osip_uri_free(uri);
                    OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_BUG,NULL,
                                          "groups plugin: Could not create location info!\n"));
                }
                else
                {
                    ADD_ELEMENT(psp_req->locations, loc);
                }
            }
        }
        return 0;
    }

    OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,
                          "groups plugin: Didn't do anything with this request?\n"));
    psp_request_set_state(psp_req, PSP_PROPOSE);
    psp_request_set_uas_status(psp_req, 404);
    psp_request_set_mode(psp_req, PSP_UAS_MODE);

    return 0;

}
int main(int argc, char** argv)
{
	char strOpt[255];
	int ret;
	char str[STR_MAX];
	GError *gerr = NULL;

	// If application is executed by AUL, this is not needed.
	g_setenv("PKG_NAME", "com.samsung.location-api-test", 1);

	g_type_init();

#if !GLIB_CHECK_VERSION (2, 31, 0)
	if( !g_thread_supported() )
	{
		g_thread_init(NULL);
	}
#endif

	GThread *g_main;
	g_main = g_thread_create(GmainThread, NULL, TRUE, &gerr);
	if (!g_main) {
		g_printf("Error create gmain thread: Err domain[%d] Err code[%d] Err msg[%s]",
			gerr->domain, gerr->code, gerr->message);
		g_error_free(gerr);
		return 0;
	}

	json_util_init(LOCATION_API_TEST_JSON_FILE);
	g_printf("--- Start LBS Test App ---\n");
	while(1)
	{
		print_menu();
		g_printf("Select option: ");
		SelectOpt(strOpt);
		g_printf("======================================================================================\n");
		if (0 == g_strcmp0 ("x", strOpt)) {

		}
		else if (0 == g_strcmp0("1",strOpt)) {
			ret = location_init();
			GetLocationError(str, ret);
			g_printf("location_init: returned value [%s]\n", str);
		} else if (0 == g_strcmp0("2",strOpt)) {
			if (location_obj) {
				g_printf("Location object already existed: [0x%x]", (unsigned int)location_obj);
				continue;
			}
			g_printf("LOCATION_METHOD_HYBRID[0] LOCATION_METHOD_GPS[1] LOCATION_METHOD_WPS[2] LOCATION_METHOD_CPS[3]\n");
			g_printf("Select Location Method: ");
			LocationMethod method = PromptInt();
			location_obj = location_new(method);
			if(location_obj) g_printf("Success\n");
			else             g_printf("Failed\n");
		} else if (0 == g_strcmp0("3",strOpt)) {
			ret = location_free (location_obj);
			location_obj = NULL;

			g_sig_enable = 0;
			g_sig_disable = 0;
			g_sig_update = 0;
			g_sig_zonein = 0;
			g_sig_zoneout = 0;
			GetLocationError(str, ret);
			g_printf("location_free: returned value [%s]\n", str);
		} else if (0 == g_strcmp0("4",strOpt)) {
			ret = location_start(location_obj);
			GetLocationError(str, ret);
			g_printf("location_start: returned value [%s]\n", str);
		} else if (0 == g_strcmp0("5",strOpt)) {
			ret = location_stop(location_obj);
			GetLocationError(str, ret);
			g_printf("location_stop: returned value [%s]\n", str);
		} else if (0 == g_strcmp0("6",strOpt)) {
			LocationPosition *pos = NULL;
			LocationAccuracy *acc = NULL;
			ret = location_get_position(location_obj, &pos, &acc);
			GetLocationError(str, ret);
			g_printf("location_get_position: returned value [%s]\n", str);
			if (ret == LOCATION_ERROR_NONE) {
				g_printf("time: [%d], latitude: [%f], longitude: [%f], altitude: [%f], status: [%d]\n", pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
				GetAccuracyLevel(str, acc->level);
				g_printf("level: [%s], horizontal_accuracy: [%f], vertical_accuracy: [%f]\n", str, acc->horizontal_accuracy, acc->vertical_accuracy);
			}
			if(pos) location_position_free(pos);
			if(acc) location_accuracy_free(acc);
		} else if (0 == g_strcmp0("6a",strOpt)) {
			LocationPosition *last_pos;
			LocationAccuracy *last_acc;
			int ret = 0;

			ret = location_get_last_position (location_obj, &last_pos, &last_acc);
			GetLocationError(str, ret);
			if (ret == LOCATION_ERROR_NONE) {
				g_printf ("SYNC>> Last position> time: %d, lat: %f, long: %f, alt: %f, status: %d",
					last_pos->timestamp, last_pos->latitude, last_pos->longitude, last_pos->altitude, last_pos->status);
				g_printf ("\tAccuracy level %d (%.0f meters %.0f meters)",
					last_acc->level, last_acc->horizontal_accuracy, last_acc->vertical_accuracy);
				location_position_free(last_pos);
				location_accuracy_free(last_acc);
			} else g_warning ("SYNC>> Last position> failed. Error[%s]",str);

		}else if(0 == g_strcmp0("7",strOpt) ){
			LocationVelocity *vel = NULL;
			LocationAccuracy *acc = NULL;
			ret = location_get_velocity(location_obj, &vel, &acc);
			g_printf("location_get_velocity: returned value [%s]\n", str);
			if (ret == LOCATION_ERROR_NONE) {
				g_printf("time: [%d], speed: [%f], direction: [%f], climb: [%f]\n", vel->timestamp, vel->speed, vel->direction, vel->climb);
				GetAccuracyLevel(str, acc->level);
				g_printf("level: [%s], horizontal_accuracy: [%f], vertical_accuracy: [%f]\n", str, acc->horizontal_accuracy, acc->vertical_accuracy);
			}
			else {
				GetLocationError(str, ret);
				g_warning ("SYNC>> velocity> failed. Error[%s]", str);
			}
			if(vel) location_velocity_free(vel);
			if(acc) location_accuracy_free(acc);
		}else if(0 == g_strcmp0("7a",strOpt) ){
			LocationVelocity *last_vel = NULL;
			LocationAccuracy *last_acc = NULL;
			ret = location_get_last_velocity (location_obj, &last_vel, &last_acc);
			GetLocationError(str, ret);
			if (ret == LOCATION_ERROR_NONE) {
				g_printf ("SYNC>> Last velocity> time: %d, speed: %f, direction:%f, climb:%f",
					last_vel->timestamp, last_vel->speed, last_vel->direction, last_vel->climb);
				g_printf ("\tAccuracy level %d (%.0f meters %.0f meters)",
					last_acc->level, last_acc->horizontal_accuracy, last_acc->vertical_accuracy);
				location_velocity_free(last_vel);
				location_accuracy_free(last_acc);
			} else g_warning ("SYNC>> Last velocity> failed. Error[%s]", str);
		}else if(0 == g_strcmp0("8",strOpt) ){
			int ret = 0, idx = 0;
			LocationSatellite *sat = NULL;
			guint prn;
			gboolean used;
			guint elevation;
			guint azimuth;
			gint snr;

			ret =  location_get_satellite (location_obj, &sat);
			GetLocationError(str, ret);
			if (ret == LOCATION_ERROR_NONE) {
				g_printf ("SYNC>> Current Sattelite> time = %d, satellite in view = %d, satellite in used = %d", sat->timestamp, sat->num_of_sat_inview, sat->num_of_sat_used);
				g_printf ("\tinview satellite information = ");
				for (idx=0; idx<sat->num_of_sat_inview; idx++) {
					location_satellite_get_satellite_details(sat, idx, &prn, &used, &elevation, &azimuth, &snr);
					g_printf ("\t\t[%02d] used: %d, prn: %d, elevation: %d, azimuth: %d, snr: %d", idx, used, prn, elevation, azimuth, snr);
				}
				location_satellite_free (sat);
			} else g_warning ("SYNC>> Current satellite> failed. Error[%s]", str);
		}else if(0 == g_strcmp0("8a",strOpt) ){
			int ret = 0, idx = 0;
			LocationSatellite *last_sat = NULL;
			guint prn;
			gboolean used;
			guint elevation;
			guint azimuth;
			gint snr;

			ret = location_get_last_satellite (location_obj, &last_sat);
			GetLocationError(str, ret);
			if (ret == LOCATION_ERROR_NONE) {
				g_printf ("SYNC>> Last Sattelite> time = %d, satellite in view = %d, satellite in used = %d", last_sat->timestamp, last_sat->num_of_sat_inview, last_sat->num_of_sat_used);
				g_printf ("\tinview satellite information = ");
				for (idx=0; idx<last_sat->num_of_sat_inview; idx++) {
					location_satellite_get_satellite_details(last_sat, idx, &prn, &used, &elevation, &azimuth, &snr);
					g_printf ("\t\t[%02d] used: %d, prn: %d, elevation: %d, azimuth: %d, snr: %d", idx, used, prn, elevation, azimuth, snr);
				}
				location_satellite_free (last_sat);
			} else g_warning ("SYNC>> Last satellite> failed. Error[%s]", str);
		}else if(0 == g_strcmp0("9",strOpt) ) {

			gulong distance;
			int ret = 0;
			char str[STR_MAX];
			LocationPosition pos1, pos2;

			pos1.latitude = 50.0663222;
			pos1.longitude = -5.71475;

			pos2.latitude = 58.6441;
			pos2.longitude = -3.070094;

			ret = location_get_distance(&pos1, &pos2, &distance);
			GetLocationError(str, ret);
			if(ret != LOCATION_ERROR_NONE) {
					g_printf("Fail to get position. Error[%s]\n", str);
			}
			else {
					g_printf("The approximate distance is [%lu]\n", distance);
					g_printf("cf.) It is approximately 969954.114 meter\n");
			}
		}else if(0 == g_strcmp0("10", strOpt)) {
			int method;
			char method_str[STR_MAX] = {0, };
			char input[8] = {0, };
			gboolean is_supported = FALSE;

			g_printf("0.Hybrid 1.GPS 2.WPS 3.CPS\n");
			g_printf("Select Method :");
			fgets(input, 8, stdin);
			method = atoi(input);
			switch(method) {
				case LOCATION_METHOD_HYBRID:
					is_supported = location_is_supported_method(LOCATION_METHOD_HYBRID);
					break;

				case LOCATION_METHOD_GPS:
					is_supported = location_is_supported_method(LOCATION_METHOD_GPS);
					break;

				case LOCATION_METHOD_WPS:
					is_supported = location_is_supported_method(LOCATION_METHOD_WPS);
					break;

				case LOCATION_METHOD_CPS:
					is_supported = location_is_supported_method(LOCATION_METHOD_CPS);
					break;

				default:
					break;

			}
			GetMethod(method_str, method);

			g_printf("Method[%s] is %s.", method_str, is_supported ? "supported" : "not supported");

		}else if(0 == g_strcmp0("11", strOpt)) {
			gboolean is_enabled = FALSE;
			is_enabled = location_is_enabled_gps(location_obj);
			if(is_enabled == TRUE) g_printf("GPS is turned on");
			else g_printf("GPS is turned off");
		}else if(0 == g_strcmp0("99", strOpt)) {
			int ret = 0;
			const *str = "command";
			ret = location_send_command(str);
			if(ret == 0)
				g_printf("Success to send command[%s]", str);
		}else if(0 == g_strcmp0("a1",strOpt)){
			if(location_obj && !g_sig_enable) {
				g_sig_enable = g_signal_connect (location_obj, "service-enabled", G_CALLBACK(cb_service_enabled), location_obj);
			}
		}else if(0 == g_strcmp0("a2",strOpt)){
			if(location_obj && !g_sig_disable){
				g_sig_disable = g_signal_connect (location_obj, "service-disabled", G_CALLBACK(cb_service_disabled), location_obj);
			}
		}else if(0 == g_strcmp0("a3",strOpt)){
			if(location_obj && !g_sig_update){
				g_sig_update = g_signal_connect (location_obj, "service-updated", G_CALLBACK(cb_service_updated), location_obj);
			}
		}else if(0 == g_strcmp0("a4",strOpt)){
			if(location_obj && !g_sig_zonein){
				g_sig_zonein = g_signal_connect (location_obj, "zone-in", G_CALLBACK(cb_zone_in), location_obj);
			}
		}else if(0 == g_strcmp0("a5",strOpt)){
			if(location_obj && !g_sig_zoneout){
				g_sig_zoneout = g_signal_connect (location_obj, "zone-out", G_CALLBACK(cb_zone_out), location_obj);
			}
		}else if(0 == g_strcmp0("b1",strOpt)){
			if(location_obj && g_sig_enable) {
				g_signal_handler_disconnect (location_obj, g_sig_enable);
				g_sig_enable = 0;
			}
		}else if(0 == g_strcmp0("b2",strOpt)){
			if(location_obj && g_sig_disable){
				g_signal_handler_disconnect (location_obj, g_sig_disable);
				g_sig_disable = 0;
			}
		}else if(0 == g_strcmp0("b3",strOpt)){
			if(location_obj && g_sig_update){
				g_signal_handler_disconnect (location_obj, g_sig_update);
				g_sig_update = 0;
			}
		}else if(0 == g_strcmp0("b4",strOpt)){
			if(location_obj && g_sig_zonein){
				g_signal_handler_disconnect (location_obj, g_sig_zonein);
				g_sig_zonein = 0;
			}
		}else if(0 == g_strcmp0("b5",strOpt)){
			if(location_obj && g_sig_zoneout){
				g_signal_handler_disconnect (location_obj, g_sig_zoneout);
				g_sig_zoneout = 0;
			}
		}else if(0 == g_strcmp0("c1",strOpt)){
			LocationBoundary* bound = NULL;
			int i = 0;
			int polygon_count = json_util_get_polygon_count();

			g_printf("[0].San jose(Rect) [1].Suwon HQ(Rect) [2].Seoul City(circle) ");
			for(i = 0; i < polygon_count; i++)
				g_printf("[%d].%s ", i + 3, json_util_get_polygon_name(i));

			g_printf("\nSelect Boundary: ");
			int opt = PromptInt();
			if (opt == 0) {
				LocationPosition* rb = location_position_new (0, 37.300, -121.86, 0, LOCATION_STATUS_2D_FIX);
				LocationPosition* lt = location_position_new (0, 37.360, -121.92, 0, LOCATION_STATUS_2D_FIX);
				bound = location_boundary_new_for_rect (lt, rb);
				location_position_free(rb);
				location_position_free(lt);

				location_boundary_add(location_obj, bound);

			} else if(opt == 1) {
				LocationPosition* rb = location_position_new (0, 37.255, 127.058, 0, LOCATION_STATUS_2D_FIX);
				LocationPosition* lt = location_position_new (0, 37.260, 127.045, 0, LOCATION_STATUS_2D_FIX);
				bound = location_boundary_new_for_rect (lt, rb);
				location_position_free(rb);
				location_position_free(lt);

				location_boundary_add(location_obj, bound);
			} else if(opt == 2) {
				LocationPosition *center = location_position_new(0, 37.566535, 126.977969, 0.0, LOCATION_STATUS_2D_FIX);
				double radius = 10.0;
				bound = location_boundary_new_for_circle(center, radius);

				location_boundary_add(location_obj, bound);
			} else if (opt > 2 && opt < 3 + polygon_count) {
				int index;
				int polygon_index = opt - 3;
				bound = json_util_get_polygon_boundary(polygon_index);
				location_boundary_add(location_obj, bound);

				LocationPosition * check_pos = NULL;
				gboolean ret = FALSE;
				int count = json_util_get_marker_position_count(polygon_index);
				for(index = 0; index < count; index++) {
					check_pos = json_util_get_marker_position(polygon_index, index);

					ret = location_boundary_if_inside(bound, check_pos);
					g_printf("[%s] is [%s] and the test result is [%s]\n", json_util_get_marker_name(polygon_index, index), json_util_result_zone_test(polygon_index, index), ret == TRUE? "inside": "outside");
					location_position_free(check_pos);
				}
			} else {
				g_printf("boundary is not set\n");
			}
			location_boundary_free(bound);

		}else if(0 == g_strcmp0("c2",strOpt)){
			g_printf("Get Boundary\n");
			location_boundary_foreach(location_obj, PrintBoundary, NULL);

		}else if(0 == g_strcmp0("c3",strOpt)){
			g_printf("Remove Boundary\n");
			LocationBoundary* bound = NULL;

			int i = 0;
			int polygon_count = json_util_get_polygon_count();

			g_printf("[0].San jose(Rect) [1].Suwon HQ(Rect) [2].Seoul City(circle) ");
			for(i = 0; i < polygon_count; i++)
				g_printf("[%d].%s ", i + 3, json_util_get_polygon_name(i));

			g_printf("\nSelect Boundary: ");
			int opt = PromptInt();
			if (opt == 0) {
				LocationPosition* rb = location_position_new (0, 37.300, -121.86, 0, LOCATION_STATUS_2D_FIX);
				LocationPosition* lt = location_position_new (0, 37.360, -121.92, 0, LOCATION_STATUS_2D_FIX);
				bound = location_boundary_new_for_rect (lt, rb);
				location_position_free(rb);
				location_position_free(lt);

			} else if(opt == 1) {
				LocationPosition* rb = location_position_new (0, 37.255, 127.058, 0, LOCATION_STATUS_2D_FIX);
				LocationPosition* lt = location_position_new (0, 37.260, 127.045, 0, LOCATION_STATUS_2D_FIX);
				bound = location_boundary_new_for_rect (lt, rb);
				location_position_free(rb);
				location_position_free(lt);

			} else if(opt == 2) {
				LocationPosition *center = location_position_new(0, 37.566535, 126.977969, 0.0, LOCATION_STATUS_2D_FIX);
				double radius = 10.0;
				bound = location_boundary_new_for_circle(center, radius);
				location_position_free(center);

			} else if (opt > 2 && opt < 3 + polygon_count) {
				int polygon_index = opt - 3;
				bound = json_util_get_polygon_boundary(polygon_index);
			} else {
				g_printf("Invalid value\n");
			}

			if(bound != NULL) location_boundary_remove(location_obj, bound);

		}else if(0 == g_strcmp0("c4",strOpt)){
			location_boundary_foreach(location_obj, RemoveBoundary, location_obj);
		}else if(0 == g_strcmp0("c5",strOpt)){
			char buf[255];
			g_printf("Input device name: ");
			fgets(buf, 255, stdin);
			buf[strlen(buf)-1]='\0';
			g_object_set(location_obj, "dev-name", buf, NULL);
		} else if (0 == g_strcmp0("c6", strOpt)) {
			guint interval = 1;
			g_printf("Input interval[1~120]:");
			scanf("%u", &interval);
			g_printf("changed interval to [%u]\n", interval);
			g_object_set(location_obj, "pos-interval", interval, NULL);
		} else if (0 == g_strcmp0("c7", strOpt)) {
			guint interval = 1;
			g_printf("Input interval[1~120]:");
			scanf("%u", &interval);
			g_printf("changed interval to [%u]\n", interval);
			g_object_set(location_obj, "vel-interval", interval, NULL);
		} else if (0 == g_strcmp0("c8", strOpt)) {
			guint interval = 1;
			g_printf("Input interval[1~120]:");
			scanf("%u", &interval);
			g_printf("changed interval to [%u]\n", interval);
			g_object_set(location_obj, "sat-interval", interval, NULL);
		}else if(0 == g_strcmp0("q",strOpt) ){
			g_main_loop_quit(g_mainloop);
			break;
		}
	}
	g_thread_join(g_main);
	g_printf("\n--- Exit LBS Test App ---\n");
	return 1;
}