Esempio n. 1
0
static htsmsg_t *
avt_SetAVTransportURI(http_connection_t *hc, htsmsg_t *args,
		      const char *myhost, int myport)
{
  const char *uri = htsmsg_get_str(args, "CurrentURI");
  const char *metaxml = htsmsg_get_str(args, "CurrentURIMetaData");
  char errbuf[200];
  htsmsg_t *meta;

  if(uri == NULL)
    return NULL;

  if(metaxml == NULL) {
    playqueue_play(uri, prop_create_root(NULL), 1);
    return NULL;
  }

  meta = htsmsg_xml_deserialize_cstr(metaxml, errbuf, sizeof(errbuf));
  if(meta == NULL) {
    TRACE(TRACE_ERROR, "UPNP", 
	  "SetAVTransportURI: Unable to parse metadata -- %s", errbuf);
    return NULL;
  }
  
  if(play_with_context(uri, meta)) {
    // Failed to play from context
    // TODO: Fix metadata here
    playqueue_play(uri, prop_create_root(NULL), 1);
  }
  htsmsg_release(meta);
  return NULL;
}
Esempio n. 2
0
void
connman_init(void)
{
  TAILQ_INIT(&connman_services);

  netconf_model = prop_create_root(NULL);
  prop_concat_t *pc = prop_concat_create(prop_create(netconf_model, "nodes"));

  net_state     = prop_create(netconf_model, "status");
  prop_set(netconf_model, "type", PROP_SET_STRING, "directory");

  prop_t *m = prop_create(netconf_model, "metadata");
  prop_set(m, "title", PROP_SET_RSTRING, _("Network connections"));


  // service_nodes contains list of items we receive from connman
  service_nodes = prop_create_root(NULL);
  prop_concat_add_source(pc, service_nodes, NULL);

  // settings
  connman_settings = prop_create_root(NULL);

  prop_t *delim = prop_create_root(NULL);
  prop_set_string(prop_create(delim, "type"), "separator");
  prop_concat_add_source(pc, prop_create(connman_settings, "nodes"), delim);

  settings_add_url(gconf.settings_network,
		   _p("Network connections"), NULL, NULL, NULL, MYURL,
		   SETTINGS_FIRST);

  hts_thread_create_detached("connman", connman_thread, NULL,
			     THREAD_PRIO_BGTASK);
}
Esempio n. 3
0
int
message_popup(const char *message, int flags, const char **extra)
{
  prop_t *p;
  int rval;

  p = prop_ref_inc(prop_create_root(NULL));

  TRACE(TRACE_DEBUG, "Notification", "%s", message);

  prop_set_string(prop_create(p, "type"), "message");
  prop_set_string_ex(prop_create(p, "message"), NULL, message,
		     flags & MESSAGE_POPUP_RICH_TEXT ?
		     PROP_STR_RICH : PROP_STR_UTF8);

  if(extra) {
    int cnt = 1;
    prop_t *btns = prop_create(p, "buttons");
    while(*extra) {
      prop_t *b = prop_create_root(NULL);
      prop_set_string(prop_create(b, "title"), *extra);
      char action[10];
      snprintf(action, sizeof(action), "btn%d", cnt);
      prop_set_string(prop_create(b, "action"), action);
      if(prop_set_parent(b, btns))
	abort();
      cnt++;
      extra++;
    }
  }

  if(flags & MESSAGE_POPUP_CANCEL)
    prop_set_int(prop_create(p, "cancel"), 1);
  if(flags & MESSAGE_POPUP_OK)
    prop_set_int(prop_create(p, "ok"), 1);

  event_t *e = popup_display(p);
  prop_destroy(p);
  prop_ref_dec(p);

  const event_payload_t *ep = (const event_payload_t *)e;

  if(event_is_action(e, ACTION_OK))
    rval = MESSAGE_POPUP_OK;
  else if(event_is_action(e, ACTION_CANCEL))
    rval = MESSAGE_POPUP_CANCEL;
  else if(event_is_type(e, EVENT_DYNAMIC_ACTION) &&
	  !strncmp(ep->payload, "btn", 3))
    rval = atoi(ep->payload + 3);
  else
    rval = 0;

  event_release(e);
  return rval;
}
Esempio n. 4
0
JSBool 
js_addsubprovider(JSContext *cx, JSObject *obj, uintN argc, 
		  jsval *argv, jsval *rval)
{
  js_subprovider_t *sp;
  js_plugin_t *jsp = JS_GetPrivate(cx, obj);

  if(!JS_ObjectIsFunction(cx, JSVAL_TO_OBJECT(argv[0]))) {
    JS_ReportError(cx, "Argument is not a function");
    return JS_FALSE;
  }

  sp = calloc(1, sizeof(js_subprovider_t));

  sp->super.sp_query        = js_sub_query;
  sp->super.sp_retain       = js_sub_retain;

  sp->sp_title = prop_create_root(NULL);
  prop_set_string(sp->sp_title, jsp->jsp_id);

  subtitle_provider_register(&sp->super,
                             jsp->jsp_id, sp->sp_title,
                             0, "plugin", 1, 1);

  sp->sp_jsp = jsp;
  LIST_INSERT_HEAD(&jsp->jsp_subproviders, sp, sp_plugin_link);

  sp->sp_func = argv[0];
  atomic_set(&sp->sp_refcnt, 1);
  JS_AddNamedRoot(cx, &sp->sp_func, "subprovider");

  *rval = JSVAL_VOID;
  return JS_TRUE;
}
Esempio n. 5
0
static JSBool 
js_item_addOptAction(JSContext *cx, JSObject *obj,
		     uintN argc, jsval *argv, jsval *rval)
{
  js_item_t *ji = JS_GetPrivate(cx, obj);
  const char *title;
  const char *action;

  if (!JS_ConvertArguments(cx, argc, argv, "ss", &title, &action))
    return JS_FALSE;
  
  prop_t *p = prop_create_root(NULL);
  prop_set_string(prop_create(p, "type"), "action");
  prop_set_string(prop_create(prop_create(p, "metadata"), "title"), title);
  prop_set_int(prop_create(p, "enabled"), 1);
  prop_set_string(prop_create(p, "action"), action);

  prop_t *opts = prop_create_r(ji->ji_root, "options");
  if(prop_set_parent(p, opts))
    prop_destroy(p);
  prop_ref_dec(opts);

  *rval = JSVAL_VOID;
  return JS_TRUE;
}
Esempio n. 6
0
int
search_class_create(prop_t *parent, prop_t **nodesp, prop_t **entriesp,
		    const char *title, const char *icon)
{
  prop_t *p = prop_create_root(NULL);
  prop_t *m = prop_create(p, "metadata");
  prop_t *n, *e;
  
  char url[URL_MAX];

  backend_prop_make(p, url, sizeof(url));
  prop_set_string(prop_create(p, "url"), url);

  prop_set_string(prop_create(m, "title"), title);
  if(icon != NULL)
    prop_set_string(prop_create(m, "icon"), icon);
  prop_set_string(prop_create(p, "type"), "directory");
      
  n = prop_create(p, "nodes");
  e = prop_create(p, "entries");
  prop_set_int(e, 0);

  *nodesp = prop_ref_inc(n);
  *entriesp = prop_ref_inc(e);

  if(prop_set_parent(p, parent)) {
    prop_destroy(p);
    return 1;
  }
  return 0;
}
Esempio n. 7
0
static void
trace_prop(int l, const char *pfx, const char *msg, const char *sev)
{
  trace_entry_t *te = malloc(sizeof(trace_entry_t));
  te->p = prop_create_root(NULL);

  prop_set_string(prop_create(te->p, "prefix"), pfx);
  prop_set_string(prop_create(te->p, "message"), msg);
  prop_set_string(prop_create(te->p, "severity"), sev);

  TAILQ_INSERT_TAIL(&traces, te, link);


  if(prop_set_parent(te->p, log_root))
    abort();

  entries++;

  if(entries > 50) {
    te = TAILQ_FIRST(&traces);
    TAILQ_REMOVE(&traces, te, link);
    prop_destroy(te->p);
    free(te);
    entries--;
  }
}
Esempio n. 8
0
static void
bookmark_add(const char *title, const char *url, const char *type)
{
  bookmark_t *bm = calloc(1, sizeof(bookmark_t));
  prop_t *p = prop_create_root(NULL);
  prop_t *src = prop_create(p, "model");
 
  prop_set_string(prop_create(src, "type"), "bookmark");

  bm->bm_title_sub = bookmark_add_prop(src, "title",    title,   bm, set_title);
  bm->bm_url_sub   = bookmark_add_prop(src, "url",      url,     bm, set_url);
  bm->bm_type_sub  = bookmark_add_prop(src, "svctype",  type,    bm, set_type);

  bm->bm_service = service_create(title, url, type, NULL, 1, 1);

  prop_link(service_get_status_prop(bm->bm_service),
	    prop_create(src, "status"));

  prop_link(service_get_statustxt_prop(bm->bm_service),
	    prop_create(src, "statustxt"));


  prop_subscribe(PROP_SUB_TRACK_DESTROY | PROP_SUB_NO_INITIAL_UPDATE,
		 PROP_TAG_CALLBACK, bookmark_destroyed, bm,
		 PROP_TAG_ROOT, p,
		 PROP_TAG_MUTEX, &bookmark_mutex,
		 NULL);
  if(prop_set_parent(p, prop_create(bookmarks, "nodes")))
    abort();

}
Esempio n. 9
0
static void
nav_page_setup_prop(navigator_t *nav, nav_page_t *np, const char *view)
{
  np->np_prop_root = prop_create_root("page");
  if(view != NULL) {
    np->np_view = strdup(view);
    prop_set_string(prop_create(np->np_prop_root, "requestedView"), view);
  }

  // XXX Change this into event-style subscription
  np->np_close_sub = 
    prop_subscribe(0,
		   PROP_TAG_ROOT, prop_create(np->np_prop_root, "close"),
		   PROP_TAG_CALLBACK_INT, nav_page_close_set, np,
		   PROP_TAG_COURIER, nav->nav_pc,
		   NULL);

  prop_set_string(prop_create(np->np_prop_root, "url"), np->np_url);

  np->np_direct_close_sub = 
    prop_subscribe(PROP_SUB_NO_INITIAL_UPDATE,
		   PROP_TAG_ROOT, prop_create(np->np_prop_root, "directClose"),
		   PROP_TAG_CALLBACK_INT, nav_page_direct_close_set, np,
		   PROP_TAG_COURIER, nav->nav_pc,
		   NULL);
}
Esempio n. 10
0
static nls_string_t *
nls_string_find(const char *key)
{
  nls_string_t *ns;

  unsigned int hash = mystrhash(key) % NLS_STRING_HASH_WIDTH;

  hts_mutex_lock(&nls_mutex);

  LIST_FOREACH(ns, &nls_strings[hash], ns_link)
    if(!strcmp(rstr_get(ns->ns_key), key))
      break;

  if(ns == NULL) {
    ns = calloc(1, sizeof(nls_string_t));
    ns->ns_key = rstr_alloc(key);
    ns->ns_prop = prop_create_root(NULL);
    prop_set_rstring(ns->ns_prop, ns->ns_key);

  } else {
    LIST_REMOVE(ns, ns_link);
  }
  LIST_INSERT_HEAD(&nls_strings[hash], ns, ns_link);

  hts_mutex_unlock(&nls_mutex);
  return ns;
}
Esempio n. 11
0
prop_t *
add_news(const char *message, const char *location, const char *caption)
{
  prop_t *p, *ret = NULL;

  prop_t *root = prop_create(prop_get_global(), "news");

  hts_mutex_lock(&news_mutex);

  if(dismissed_news_out != NULL) {

    if(htsmsg_get_u32_or_default(dismissed_news_in, message, 0)) {
      dismis_news(message);
    } else {
      
      p = prop_create_root(NULL);
      prop_set_string(prop_create(p, "message"), message);
      prop_set_string(prop_create(p, "location"), location);
      prop_set_string(prop_create(p, "caption"), caption);
		       
      prop_subscribe(PROP_SUB_TRACK_DESTROY,
		     PROP_TAG_CALLBACK, news_sink, prop_ref_inc(p),
		     PROP_TAG_ROOT, prop_create(p, "eventSink"),
		     PROP_TAG_MUTEX, &news_mutex,
		     NULL);
      ret = prop_ref_inc(p);
      if(prop_set_parent(p, root))
	prop_destroy(p);
    }
  }
  hts_mutex_unlock(&news_mutex);
  return ret;
}
Esempio n. 12
0
int
message_popup(const char *message, int flags)
{
  prop_t *p;
  int rval;

  p = prop_create_root(NULL);

  prop_set_string(prop_create(p, "type"), "message");
  prop_set_string_ex(prop_create(p, "message"), NULL, message,
		     flags & MESSAGE_POPUP_RICH_TEXT ?
		     PROP_STR_RICH : PROP_STR_UTF8);
  if(flags & MESSAGE_POPUP_CANCEL)
    prop_set_int(prop_create(p, "cancel"), 1);
  if(flags & MESSAGE_POPUP_OK)
    prop_set_int(prop_create(p, "ok"), 1);

  event_t *e = popup_display(p);
  prop_destroy(p);
  
  if(event_is_action(e, ACTION_OK))
    rval = MESSAGE_POPUP_OK;
  else if(event_is_action(e, ACTION_CANCEL))
    rval = MESSAGE_POPUP_CANCEL;
  else
    rval = 0;

  event_release(e);
  return rval;
}
Esempio n. 13
0
static prop_t *
add_news_locked(const char *id, const char *message,
                const char *location, const char *caption,
                const char *action)
{
  prop_t *p, *ret = NULL;
  prop_t *root = prop_create(prop_get_global(), "news");

  if(dismissed_news_out != NULL) {

    if(htsmsg_get_u32_or_default(dismissed_news_in, id, 0)) {
      dismis_news(id);
    } else {

      p = prop_create_root(id);
      prop_set(p, "message",  PROP_SET_STRING, message);
      prop_set(p, "id",       PROP_SET_STRING, id);
      prop_set(p, "location", PROP_SET_STRING, location);
      prop_set(p, "caption",  PROP_SET_STRING, caption);
      prop_set(p, "action",   PROP_SET_STRING, action);

      prop_subscribe(PROP_SUB_TRACK_DESTROY,
		     PROP_TAG_CALLBACK, news_sink, prop_ref_inc(p),
		     PROP_TAG_ROOT, prop_create(p, "eventSink"),
		     PROP_TAG_MUTEX, &news_mutex,
		     NULL);
      ret = prop_ref_inc(p);
      if(prop_set_parent(p, root))
	prop_destroy(p);
    }
  }
  return ret;
}
Esempio n. 14
0
static htsp_channel_t *
htsp_channel_get(htsp_connection_t *hc, int id, int create)
{
  htsp_channel_t *ch;
  char txt[256];
  LIST_FOREACH(ch, &hc->hc_channels, ch_link)
    if(ch->ch_id == id)
      return ch;

  if(!create)
    return NULL;

  ch = calloc(1, sizeof(htsp_channel_t));

  snprintf(txt, sizeof(txt), "%d", id);
  prop_t *p = ch->ch_root = prop_create_root(txt);
  
  snprintf(txt, sizeof(txt), "htsp://%s:%d/channel/%d",
	   hc->hc_hostname, hc->hc_port, id);
  prop_set_string(prop_create(ch->ch_root, "url"), txt);

  prop_t *m = prop_create(p, "metadata");
  ch->ch_prop_icon = prop_create(m, "icon");
  ch->ch_prop_title = prop_create(m, "title");
  ch->ch_prop_channelNumber = prop_create(m, "channelNumber");
  ch->ch_prop_events = prop_create(m, "events");

  prop_set_string(prop_create(ch->ch_root, "type"), "tvchannel");
  
  LIST_INSERT_HEAD(&hc->hc_channels, ch, ch_link);
  ch->ch_id = id;
  return ch;
}
Esempio n. 15
0
prop_t *
makesep(prop_t *title)
{
  prop_t *d = prop_create_root(NULL);
  prop_link(title, prop_create(prop_create(d, "metadata"), "title"));
  prop_set_string(prop_create(d, "type"), "separator");
  return d;

}
Esempio n. 16
0
static JSBool 
js_appendItem0(JSContext *cx, js_model_t *model, prop_t *parent,
	       const char *url, const char *type, JSObject *metaobj,
	       jsval *data, jsval *rval, int enabled,
	       const char *metabind)
{
  prop_t *item = prop_create_root(NULL);

  if(url != NULL)
    prop_set_string(prop_create(item, "url"), url);

  if(data != NULL)
    js_prop_set_from_jsval(cx, prop_create(item, "data"), *data);

  *rval = JSVAL_VOID;

  if(metabind != NULL)
    metadb_bind_url_to_prop(NULL, metabind, item);

  if(type != NULL) {
    prop_set_string(prop_create(item, "type"), type);

    if(metaobj)
      js_prop_from_object(cx, metaobj, prop_create(item, "metadata"));

  } else if(url != NULL) {

    if(backend_resolve_item(url, item)) {
      prop_destroy(item);
      return JS_TRUE;
    }
  }

  prop_set_int(prop_create(item, "enabled"), enabled);

  prop_t *p = prop_ref_inc(item);

  if(prop_set_parent(item, parent)) {
    prop_destroy(item);
    prop_ref_dec(p);
  } else {
    JSObject *robj =
      JS_NewObjectWithGivenProto(cx, &item_class,
				 JSVAL_TO_OBJECT(model->jm_item_proto), NULL);

    *rval =  OBJECT_TO_JSVAL(robj);
    js_item_t *ji = calloc(1, sizeof(js_item_t));
    ji->ji_model = model;
    ji->ji_root =  p;
    LIST_INSERT_HEAD(&model->jm_items, ji, ji_link);
    JS_SetPrivate(cx, robj, ji);
    ji->ji_enable_set_property = 1; 
  }
  return JS_TRUE;
}
Esempio n. 17
0
static void
init_dev_settings(void)
{
  htsmsg_t *store;

  if((store = htsmsg_store_load("dev")) == NULL)
    store = htsmsg_create_map();

  settings_dev = settings_add_dir(prop_create_root(NULL),
				  _p("Developer settings"), NULL, NULL,
				  _p("Settings useful for developers"),
				  "settings:dev");

  prop_t *r = setting_add(settings_dev, NULL, "info", 0);
  prop_set_string(prop_create(r, "description"),
		  "Settings for developers. If you don't know what this is, don't touch it");


  prop_t *t;
  
  t = prop_create_root(NULL);
  prop_set_string(t, "Enable binrelpace");

  settings_create_bool(settings_dev, "binreplace", t, 0,
		       store, settings_generic_set_bool,
		       &gconf.enable_bin_replace, 
		       SETTINGS_INITIAL_UPDATE, NULL,
		       settings_generic_save_settings, 
		       (void *)"dev");

  t = prop_create_root(NULL);
  prop_set_string(t, "Enable omnigrade");

  settings_create_bool(settings_dev, "omnigrade", t, 0,
		       store, settings_generic_set_bool,
		       &gconf.enable_omnigrade, 
		       SETTINGS_INITIAL_UPDATE, NULL,
		       settings_generic_save_settings, 
		       (void *)"dev");


}
Esempio n. 18
0
static int
play_with_context(const char *uri, htsmsg_t *meta)
{
  const char *parentid, *id;
  upnp_service_t *us;

  parentid =
    htsmsg_get_str_multi(meta,
			 "DIDL-Lite",
			 "item",
			 "parentID",
			 NULL);

  if(parentid == NULL)
    return 1;

  id =
    htsmsg_get_str_multi(meta,
			 "DIDL-Lite",
			 "item",
			 "id",
			 NULL);

  if(id == NULL)
    return 1;

  UPNP_TRACE("Playing %s (id: %s, parent: %s)", uri, id, parentid);

  hts_mutex_lock(&upnp_lock);

  us = upnp_service_guess(uri);

  if(us != NULL) {
    UPNP_TRACE("Using controlpoint %s", us->us_control_url);

    prop_t *model = prop_create_root(NULL);
    prop_t *nodes = prop_create(model, "nodes");
    prop_t *t = NULL;

    if(upnp_browse_children(us->us_control_url, parentid, nodes, id, &t) 
       || t == NULL) {

      prop_destroy(model);

    } else {
      playqueue_load_with_source(t, model, PQ_PAUSED);
      hts_mutex_unlock(&upnp_lock);
      return 0;
    }
  }

  hts_mutex_unlock(&upnp_lock);
  return 1;
}
Esempio n. 19
0
/**
 *  Popup an request to the user on behalf of connman
 */
static GVariant *
agent_request_input(connman_service_t *cs, GVariant *req,
		    GDBusMethodInvocation *inv)
{
  TRACE(TRACE_INFO, "CONNMAN", "Requesting credentials for %s", cs->cs_path);

  TRACE(TRACE_DEBUG, "CONNMAN", "RequestInput: %s",
	g_variant_print(req, TRUE));

  prop_t *p = prop_create_root(NULL);

  prop_set(p, "type",   PROP_SET_STRING, "auth");
  prop_set(p, "id",     PROP_SET_STRING, cs->cs_path);
  prop_set(p, "source", PROP_SET_STRING, "Network");


  GVariant *prev = g_variant_lookup_value(req, "PreviousPassphrase", NULL);

  if(prev) {
    prop_set(p, "reason", PROP_SET_STRING, "Password incorrect");
  } else {
    prop_set(p, "reason", PROP_SET_STRING, "Password needed");
  }

  GVariant *identity = g_variant_lookup_value(req, "Identity", NULL);

  cs->cs_input_req_want_identity = identity != NULL;
  prop_set(p, "disableUsername", PROP_SET_INT, !cs->cs_input_req_want_identity);

  prop_set(p, "disableDomain", PROP_SET_INT, 1);

  prop_t *r = prop_create(p, "eventSink");

  cs->cs_input_req_sub =
    prop_subscribe(0,
		   PROP_TAG_CALLBACK_EVENT, input_req_event, cs,
		   PROP_TAG_NAMED_ROOT, r, "popup",
		   PROP_TAG_COURIER, connman_courier,
		   NULL);

  cs->cs_input_req_prop = p;

  /* Will show the popup */
  if(prop_set_parent(p, prop_create(prop_get_global(), "popups"))) {
    /* popuproot is a zombie, this is an error */
    abort();
  }

  cs->cs_input_req_inv = inv;
  g_object_ref(G_OBJECT(inv));

  return NULL;
}
Esempio n. 20
0
void *
notify_add(prop_t *root, notify_type_t type, const char *icon, int delay,
	   rstr_t *fmt, ...)
{
  char msg[256];
  prop_t *p;
  const char *typestr;
  int tl;
  va_list ap, apx;

  switch(type) {
  case NOTIFY_INFO:    typestr = "info";    tl = TRACE_INFO;  break;
  case NOTIFY_WARNING: typestr = "warning"; tl = TRACE_INFO;  break;
  case NOTIFY_ERROR:   typestr = "error";   tl = TRACE_ERROR; break;
  default: return NULL;
  }
  
  va_start(ap, fmt);
  va_copy(apx, ap);

  tracev(0, tl, "notify", rstr_get(fmt), ap);

  vsnprintf(msg, sizeof(msg), rstr_get(fmt), apx);

  va_end(ap);
  va_end(apx);

  rstr_release(fmt);

  p = prop_create_root(NULL);

  prop_set_string(prop_create(p, "text"), msg);
  prop_set_string(prop_create(p, "type"), typestr);

  if(icon != NULL)
    prop_set_string(prop_create(p, "icon"), icon);

  p = prop_ref_inc(p);

  if(prop_set_parent(p, root ?: notify_prop_entries))
    prop_destroy(p);

  if(delay != 0) {
    prop_t *r = NULL;
    if(delay < 0) {
      r = prop_ref_inc(p);
      delay = -delay;
    }
    callout_arm(NULL, notify_timeout, p, delay);
    return r;
  }
  return p;
}
Esempio n. 21
0
static int
sidfile_scandir(fa_dir_t *fd, const char *url, char *errbuf, size_t errlen)
{
  void *fh = NULL;
  char *p, *fpath = mystrdupa(url);
  char buf[128];
  char name[32];
  char turl[URL_MAX];
  int tracks, i;
  fa_dir_entry_t *fde;
  rstr_t *album, *artist;
 

  if((p = strrchr(fpath, '/')) == NULL) {
    snprintf(errbuf, errlen, "Invalid filename");
    return -1;
  }

  *p = 0;
  if((fh = fa_open(fpath, errbuf, errlen)) == NULL)
    return -1;

  if(fa_read(fh, buf, 128) != 128) {
    snprintf(errbuf, errlen, "Unable to read file");
    fa_close(fh);
    return -1;
  }

  album = rstr_alloc(utf8_from_bytes((char *)buf + 0x16, 32, NULL));
  artist = rstr_alloc(utf8_from_bytes((char *)buf + 0x36, 32, NULL));

  tracks = buf[0xf];
  for(i = 0; i < tracks; i++) {

    snprintf(name, sizeof(name), "Track %02d", i + 1);
    snprintf(turl, sizeof(turl), "sidplayer:%s/%d", fpath, i + 1);
    fde = fa_dir_add(fd, turl, name, CONTENT_AUDIO);

    fde->fde_probestatus = FDE_PROBE_DEEP;

    fde->fde_metadata = prop_create_root("metadata");
    prop_set_string(prop_create(fde->fde_metadata, "title"), name);
    prop_set_rstring(prop_create(fde->fde_metadata, "album"), album);
    prop_set_rstring(prop_create(fde->fde_metadata, "artist"), artist);
  }

  rstr_release(album);
  rstr_release(artist);

  fa_close(fh);
  return 0;
}
Esempio n. 22
0
void
settings_init(void)
{
  prop_t *n, *d, *model;
  prop_t *s1;

  settings_root = prop_create(prop_get_global(), "settings");
  prop_set_string(prop_create(settings_root, "type"), "settings");
  set_title(settings_root, _p("Global settings"));




  settings_nodes = prop_create_root(NULL);
  s1 = prop_create_root(NULL);

  prop_nf_create(s1,
		 settings_nodes, NULL, "node.model.metadata.title",
		 PROP_NF_AUTODESTROY);


  settings_apps = prop_create_root(NULL);
  settings_sd = prop_create_root(NULL);

  prop_concat_t *pc;

  pc = prop_concat_create(prop_create(settings_root, "nodes"), 0);

  prop_concat_add_source(pc, s1, NULL);

  // Applications and plugins

  n = prop_create(prop_create(settings_apps, "model"), "nodes");

  d = prop_create_root(NULL);
  model = prop_create(d, "model");
  set_title(model, _p("Applications and installed plugins"));
  prop_set_string(prop_create(model, "type"), "divider");
  prop_concat_add_source(pc, n, d);


  d = prop_create_root(NULL);
  model = prop_create(d, "model");
  set_title(model, _p("Discovered media sources"));
  prop_set_string(prop_create(model, "type"), "divider");

  n = prop_create(prop_create(settings_sd, "model"), "nodes");
  prop_concat_add_source(pc, n, d);

  // General settings

  settings_general = settings_add_dir(NULL, _p("General"), NULL, NULL,
				      _p("System related settings"));
}
Esempio n. 23
0
static void
nav_open0(navigator_t *nav, const char *url, const char *view, prop_t *origin)
{
  nav_page_t *np = calloc(1, sizeof(nav_page_t));
  np->np_nav = nav;
  np->np_url = url ? strdup(url) : NULL;
  np->np_direct_close = 0;
  TAILQ_INSERT_TAIL(&nav->nav_pages, np, np_global_link);

  np->np_prop_root = prop_create_root("page");
  if(view != NULL) {
    np->np_view = strdup(view);
    prop_set_string(prop_create(np->np_prop_root, "requestedView"), view);
  }

  // XXX Change this into event-style subscription
  np->np_close_sub = 
    prop_subscribe(0,
		   PROP_TAG_ROOT, prop_create(np->np_prop_root, "close"),
		   PROP_TAG_CALLBACK_INT, nav_page_close_set, np,
		   PROP_TAG_COURIER, nav->nav_pc,
		   NULL);

  if(url != NULL)
    prop_set_string(prop_create(np->np_prop_root, "url"), url);

  np->np_url_sub = 
    prop_subscribe(PROP_SUB_NO_INITIAL_UPDATE,
		   PROP_TAG_ROOT, prop_create(np->np_prop_root, "url"),
		   PROP_TAG_CALLBACK_STRING, nav_page_url_set, np,
		   PROP_TAG_COURIER, nav->nav_pc,
		   NULL);

  np->np_direct_close_sub = 
    prop_subscribe(PROP_SUB_NO_INITIAL_UPDATE,
		   PROP_TAG_ROOT, prop_create(np->np_prop_root, "directClose"),
		   PROP_TAG_CALLBACK_INT, nav_page_direct_close_set, np,
		   PROP_TAG_COURIER, nav->nav_pc,
		   NULL);
  
  TRACE(TRACE_INFO, "navigator", "Opening %s", url);
  if(backend_open(np->np_prop_root, url))
    nav_open_errorf(np->np_prop_root, url, "No handler for URL");

  nav_insert_page(nav, np, origin);
}
Esempio n. 24
0
void
settings_init(void)
{
  prop_t *n, *d;
  prop_t *s1;

  settings_root = prop_create(prop_get_global(), "settings");
  prop_set_string(prop_create(settings_root, "type"), "settings");
  set_title2(settings_root, _p("Global settings"));

  settings_nodes = prop_create_root(NULL);
  s1 = prop_create_root(NULL);

  struct prop_nf *pnf;

  pnf = prop_nf_create(s1, settings_nodes, NULL, PROP_NF_AUTODESTROY);
  prop_nf_sort(pnf, "node.metadata.title", 0, 0, NULL, 1);

  settings_apps = prop_create_root(NULL);
  settings_sd = prop_create_root(NULL);

  prop_concat_t *pc;

  pc = prop_concat_create(prop_create(settings_root, "nodes"), 0);

  prop_concat_add_source(pc, s1, NULL);

  // Applications and plugins

  n = prop_create(settings_apps, "nodes");

  d = prop_create_root(NULL);
  set_title2(d, _p("Applications and installed plugins"));
  prop_set_string(prop_create(d, "type"), "separator");
  prop_concat_add_source(pc, n, d);

  d = prop_create_root(NULL);
  set_title2(d, _p("Discovered media sources"));
  prop_set_string(prop_create(d, "type"), "separator");

  n = prop_create(settings_sd, "nodes");
  prop_concat_add_source(pc, n, d);

  // General settings

  settings_general = settings_add_dir(NULL, _p("General"), NULL, NULL,
				      _p("System related settings"),
				      "settings:general");

  // Developer settings, only available via its URI

  init_dev_settings();
}
Esempio n. 25
0
void
settings_init(void)
{
  settings_root = prop_create(prop_get_global(), "settings");

  settings_nodes = prop_create_root("sources");

  prop_nf_create(prop_create(settings_root, "nodes"),
		 settings_nodes, NULL, "node.model.metadata.title",
		 PROP_NF_AUTODESTROY);

  prop_set_string(prop_create(settings_root, "type"), "settings");
  set_title(settings_root, "Global settings");

  settings_apps = settings_add_dir(NULL, "Plugins", "settings", NULL);
  settings_sd = settings_add_dir(NULL, "Autodiscovered services",
				 "settings", NULL);
}
Esempio n. 26
0
static plugin_t *
plugin_find(const char *id, int create)
{
  plugin_t *pl;
  LIST_FOREACH(pl, &plugins, pl_link)
    if(!strcmp(pl->pl_id, id))
      return pl;
  if(!create)
    return NULL;
  
  pl = calloc(1, sizeof(plugin_t));
  pl->pl_id = strdup(id);

  pl->pl_status = prop_create_root(NULL);

  LIST_INSERT_HEAD(&plugins, pl, pl_link);
  return pl;
}
Esempio n. 27
0
static int
file_open_file(prop_t *page, const char *url, struct fa_stat *fs)
{
  char redir[URL_MAX];
  char errbuf[200];
  int c;
  prop_t *meta;

  meta = prop_create_root("metadata");

  c = fa_probe(meta, url, redir, sizeof(redir), errbuf, sizeof(errbuf), fs, 1);

  switch(c) {
  case CONTENT_ARCHIVE:
  case CONTENT_ALBUM:
    prop_destroy(meta);
    return file_open_dir(page, redir);

  case CONTENT_AUDIO:
    if(!file_open_audio(page, url)) {
      prop_destroy(meta);
      return 0;
    }

    playqueue_play(url, meta, 0);
    return playqueue_open(page);

  case CONTENT_VIDEO:
  case CONTENT_DVD:
    prop_destroy(meta);
    return backend_open_video(page, url);

  case CONTENT_IMAGE:
    return file_open_image(page, meta);

  case CONTENT_PLUGIN:
    plugin_open_file(page, url);
    return 0;

  default:
    prop_destroy(meta);
    return nav_open_error(page, errbuf);
  }
}
Esempio n. 28
0
int
text_dialog_kbrd(const char *message, char** answer, int flags)
{
  htsmsg_t *m;
  rstr_t *r;

  prop_t *p = prop_create_root(NULL);

  prop_set_string(prop_create(p, "type"), "textDialogKbrd");
  prop_set_string_ex(prop_create(p, "message"), NULL, message,
		     flags & MESSAGE_POPUP_RICH_TEXT ?
		     PROP_STR_RICH : PROP_STR_UTF8);
  prop_t *string = prop_create(p, "input");
  if(flags & MESSAGE_POPUP_CANCEL)
    prop_set_int(prop_create(p, "cancel"), 1);
  if(flags & MESSAGE_POPUP_OK)
    prop_set_int(prop_create(p, "ok"), 1);
  
  event_t *e = popup_display_kbrd(p, string);
  if (event_is_action(e, ACTION_OK))
  {
    m = htsmsg_create_map();  
      
    r = prop_get_string(string);
    htsmsg_add_str(m, "input", r ? rstr_get(r) : "");
    rstr_release(r);
      
    htsmsg_get_str(m, "input");
    
    setstr(answer, m, "input");
  }
  
  prop_destroy(p);
  
  if(event_is_action(e, ACTION_CANCEL)){
      event_release(e);
      return -1;
  } 

  event_release(e);
  
  return 0;
}
Esempio n. 29
0
JNIEXPORT jint JNICALL
Java_com_showtimemediacenter_showtime_STCore_glwCreate(JNIEnv *env,
                                                       jobject obj,
                                                       jobject vrp)
{
  android_glw_root_t *agr = calloc(1, sizeof(android_glw_root_t));
  agr->gr.gr_prop_ui = prop_create_root("ui");
  agr->gr.gr_prop_nav = android_nav;

  if(glw_init(&agr->gr))
    return 0;

  hts_cond_init(&agr->agr_runcond, &gr->gr_mutex);

  agr->agr_vrp = (*env)->NewGlobalRef(env, vrp);

  TRACE(TRACE_DEBUG, "GLW", "GLW %p created", agr);

  glw_load_universe(&agr->gr);
  return (intptr_t)agr;
}
Esempio n. 30
0
static void
htsp_tagAddUpdate(htsp_connection_t *hc, htsmsg_t *m, int create)
{
  const char *id;
  htsmsg_t *members;
  htsmsg_field_t *f;
  prop_t *metadata, *before, *nodes;
  char txt[200];
  int num = 0, i;
  htsp_tag_t *ht, *n;
  const char *title;
  if((id = htsmsg_get_str(m, "tagId")) == NULL)
    return;
  
  title =  htsmsg_get_str(m, "tagName");

  hts_mutex_lock(&hc->hc_meta_mutex);

  if(create) {

    ht = calloc(1, sizeof(htsp_tag_t));
    ht->ht_id = strdup(id);
    ht->ht_title = strdup(title ?: "");

    LIST_INSERT_SORTED(&hc->hc_tags, ht, ht_link, tag_compar);
    n = LIST_NEXT(ht, ht_link);

    ht->ht_root = prop_create_root(id);

    snprintf(txt, sizeof(txt), "htsp://%s:%d/tag/%s",
	     hc->hc_hostname, hc->hc_port, id);
    
    prop_set_string(prop_create(ht->ht_root, "url"), txt);
    prop_set_string(prop_create(ht->ht_root, "type"), "directory");

    if(prop_set_parent_ex(ht->ht_root, hc->hc_tags_nodes,
			  n ? n->ht_root : NULL, NULL))
      abort();
    
  } else {