Ejemplo n.º 1
0
/**
 * The end of all things
 */
void
main_fini(void)
{
  prop_destroy_by_name(prop_get_global(), "popups");
  fini_group(INIT_GROUP_API);
  TRACE(TRACE_DEBUG, "core", "API group finished");
  fini_group(INIT_GROUP_IPC);
  TRACE(TRACE_DEBUG, "core", "IPC group finished");
#if ENABLE_PLAYQUEUE
  playqueue_fini();
  TRACE(TRACE_DEBUG, "core", "Playqueue finished");
#endif
  audio_fini();
  TRACE(TRACE_DEBUG, "core", "Audio finished");
  nav_fini();
  TRACE(TRACE_DEBUG, "core", "Navigator finished");
  backend_fini();
  TRACE(TRACE_DEBUG, "core", "Backend finished");
  shutdown_hook_run(0);
  TRACE(TRACE_DEBUG, "core", "Slow shutdown hooks finished");
  blobcache_fini();
  TRACE(TRACE_DEBUG, "core", "Blobcache finished");
#if ENABLE_METADATA
  metadb_fini();
  TRACE(TRACE_DEBUG, "core", "Metadb finished");
#endif
  kvstore_fini();
  notifications_fini();
  htsmsg_store_flush();
  TRACE(TRACE_DEBUG, "core", APPNAMEUSER" terminated normally");
  trace_fini();
}
Ejemplo n.º 2
0
static void *
do_shutdown(void *aux)
{
  shutdown_hook_run(2);

  event_dispatch(event_create_action(ACTION_STOP));
  prop_destroy_by_name(prop_get_global(), "popups");

  app_flush_caches();

  TRACE(TRACE_DEBUG, "core", "Caches flushed");

  int r = arch_stop_req();

  TRACE(TRACE_DEBUG, "core", "arch stop=%d", r);

  if(!r) {
    // If arch_stop_req() returns -1 it will not actually
    // exit showtime but rather suspend the UI and turn off HDMI ,etc
    // Typically used on some targets where we want to enter a 
    // semi-standby state.
    // So only do shutdown hooks if we are about to exit for real.

    // Run early shutdown hooks (those must be fast since this
    // function may be called from UI thread)
    shutdown_hook_run(1);
  }
  return NULL;
}
Ejemplo n.º 3
0
static void
dismis_news(const char *id)
{
  htsmsg_add_u32(dismissed_news_out, id, 1);
  htsmsg_store_save(dismissed_news_out, "dismissed_news");
  prop_t *root = prop_create(prop_get_global(), "news");
  prop_destroy_by_name(root, id);
}
Ejemplo n.º 4
0
static JSBool
pb_delProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
  const char *name = name_by_id(id);

  if(name)
    prop_destroy_by_name(JS_GetPrivate(cx, obj), name);

  return JS_TRUE;
}
Ejemplo n.º 5
0
int
js_prop_from_object(JSContext *cx, JSObject *obj, prop_t *p)
{
  JSIdArray *ida;
  int i, r = 0;
  const char *n;
  int array_zapped = 0;

  if((ida = JS_Enumerate(cx, obj)) == NULL)
    return -1;
  
  for(i = 0; i < ida->length; i++) {
    jsval name, value;

    if(!JS_IdToValue(cx, ida->vector[i], &name))
      continue;

    if(JSVAL_IS_STRING(name)) {
      n = JS_GetStringBytes(JSVAL_TO_STRING(name));
      if(!JS_GetProperty(cx, obj, n, &value))
	continue;
    } else if(JSVAL_IS_INT(name)) {
      if(!JS_GetElement(cx, obj, JSVAL_TO_INT(name), &value) ||
	 JSVAL_IS_VOID(value))
	continue;
      if(!array_zapped) {
	array_zapped = 1;
	prop_destroy_by_name(p, NULL);
      }
      n = NULL;
    } else {
      continue;
    }

    if(JSVAL_TO_OBJECT(value) == obj)
      continue;

    js_prop_set_from_jsval(cx, prop_create(p, n), value);
  }
  JS_DestroyIdArray(cx, ida);
  return r;
}
Ejemplo n.º 6
0
static void
update_events(htsp_connection_t *hc, prop_t *metadata, int id, int next)
{
  int i;
  htsmsg_t *m;
  prop_t *events        = prop_create(metadata, "list");
  prop_t *current_event = prop_create(metadata, "current");
  prop_t *next_event    = prop_create(metadata, "next");
  int linkstate = 0;
  htsmsg_field_t *f;

  if(id == 0) {

    if(next == 0) {
      // No events at all
      prop_destroy_childs(events);
      return;
    }
    
    id = next;
    linkstate = 1;
  }

  m = htsmsg_create_map();
  htsmsg_add_str(m, "method", "getEvents");
  htsmsg_add_u32(m, "eventId", id);
  htsmsg_add_u32(m, "numFollowing", EPG_TAIL);

  if((m = htsp_reqreply(hc, m)) != NULL) {

    htsmsg_t *events = htsmsg_get_list(m, "events");
    f = events ? TAILQ_FIRST(&events->hm_fields) : NULL;

  } else {
    f = NULL;
  }


  for(i = 0; i < EPG_TAIL; i++) {
    char buf[10];
    uint32_t u32;
    snprintf(buf, sizeof(buf), "%d", i);

    if(f != NULL && f->hmf_type != HMF_MAP)
      f = NULL;

    if(f != NULL) {

      m = htsmsg_get_map_by_field(f);

      prop_t *e = prop_create(events, buf);
      prop_set_string(prop_create(e, "title"), htsmsg_get_str(m, "title"));
      prop_set_string(prop_create(e, "description"),
		      htsmsg_get_str(m, "description"));
      if(!htsmsg_get_u32(m, "start", &u32))
	prop_set_int(prop_create(e, "start"), u32);
      
      if(!htsmsg_get_u32(m, "stop", &u32))
	prop_set_int(prop_create(e, "stop"), u32);
      
      switch(linkstate) {
      case 0:
	prop_link(e, current_event);
	break;
      case 1:
	prop_link(e, next_event);
	break;
      }
      linkstate++;

      f = TAILQ_NEXT(f, hmf_link);
      continue;
    }
    prop_destroy_by_name(events, buf);

    switch(linkstate) {
    case 0:
      prop_unlink(current_event);
      break;
    case 1:
      prop_unlink(next_event);
      break;
    }
    linkstate++;
  }
}
Ejemplo n.º 7
0
static void
update_events(htsp_connection_t *hc, prop_t *metadata, int id, int next)
{
  int i;
  htsmsg_t *m;
  prop_t *events        = prop_create(metadata, "list");
  prop_t *current_event = prop_create(metadata, "current");
  prop_t *next_event    = prop_create(metadata, "next");
  char buf[10];
  uint32_t u32;
  int linkstate = 0;

  if(id == 0) {

    if(next == 0) {
      // No events at all
      prop_destroy_childs(events);
      return;
    }
    
    id = next;
    linkstate = 1;
  }

  for(i = 0; i < EPG_TAIL; i++) {
    snprintf(buf, sizeof(buf), "id%d", i);

    if(id != 0) {
      m = htsmsg_create_map();
      htsmsg_add_str(m, "method", "getEvent");
      htsmsg_add_u32(m, "eventId", id);
    
      if((m = htsp_reqreply(hc, m)) != NULL) {

	prop_t *e = prop_create(events, buf);
	prop_set_string(prop_create(e, "title"), htsmsg_get_str(m, "title"));
	prop_set_string(prop_create(e, "description"),
			htsmsg_get_str(m, "description"));
	if(!htsmsg_get_u32(m, "start", &u32))
	  prop_set_int(prop_create(e, "start"), u32);
	
	if(!htsmsg_get_u32(m, "stop", &u32))
	  prop_set_int(prop_create(e, "stop"), u32);

	switch(linkstate) {
	case 0:
	  prop_link(e, current_event);
	  break;
	case 1:
	  prop_link(e, next_event);
	  break;
	}
	linkstate++;
	id = htsmsg_get_u32_or_default(m, "nextEventId", 0);
	continue;
      } else {
	id = 0;
      }
    }
    prop_destroy_by_name(events, buf);

    switch(linkstate) {
    case 0:
      prop_unlink(current_event);
      break;
    case 1:
      prop_unlink(next_event);
      break;
    }
    linkstate++;
  }
}