static void glw_slideshow_set_roots(glw_t *w, prop_t *self, prop_t *parent, prop_t *clone) { glw_slideshow_t *s = (glw_slideshow_t *)w; s->playstatus = prop_create(prop_create(self, "slideshow"), "playstatus"); }
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--; } }
static navigator_t * nav_create(prop_t *prop) { navigator_t *nav = calloc(1, sizeof(navigator_t)); nav->nav_prop_root = prop; TAILQ_INIT(&nav->nav_pages); TAILQ_INIT(&nav->nav_history); nav->nav_prop_pages = prop_create(nav->nav_prop_root, "pages"); nav->nav_prop_curpage = prop_create(nav->nav_prop_root, "currentpage"); nav->nav_prop_can_go_back = prop_create(nav->nav_prop_root, "canGoBack"); nav->nav_prop_can_go_fwd = prop_create(nav->nav_prop_root, "canGoForward"); nav->nav_prop_can_go_home = prop_create(nav->nav_prop_root, "canGoHome"); prop_set_int(nav->nav_prop_can_go_home, 1); nav->nav_pc = prop_courier_create_thread(NULL, "navigator"); nav->nav_eventsink = prop_subscribe(0, PROP_TAG_NAME("nav", "eventsink"), PROP_TAG_CALLBACK, nav_eventsink, nav, PROP_TAG_COURIER, nav->nav_pc, PROP_TAG_ROOT, nav->nav_prop_root, NULL); nav->nav_dtor_tracker = prop_subscribe(PROP_SUB_TRACK_DESTROY, PROP_TAG_CALLBACK, nav_dtor_tracker, nav, PROP_TAG_COURIER, nav->nav_pc, PROP_TAG_ROOT, nav->nav_prop_root, NULL); return nav; }
static void audio_mastervol_init(void) { htsmsg_t *m = htsmsg_store_load("audiomixer"); int32_t i32; prop_t *pa, *mv, *mm; pa = prop_create(prop_get_global(), "audio"); mv = prop_create(pa, "mastervolume"); mm = prop_create(pa, "mastermute"); prop_set_float_clipping_range(mv, -75, 12); if(m != NULL && !htsmsg_get_s32(m, "master-volume", &i32)) prop_set_float(mv, (float)i32 / 1000); prop_set_int(mm, 0); htsmsg_release(m); prop_subscribe(PROP_SUB_NO_INITIAL_UPDATE, PROP_TAG_CALLBACK_FLOAT, save_matervol, NULL, PROP_TAG_ROOT, mv, NULL); prop_subscribe(PROP_SUB_NO_INITIAL_UPDATE, PROP_TAG_SET_INT, &audio_master_mute, PROP_TAG_ROOT, mm, NULL); }
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; }
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; }
void audio_mastervol_init(void) { htsmsg_t *m = htsmsg_store_load("audiomixer"); int32_t i32; prop_t *prop_audio; prop_audio = prop_create(prop_get_global(), "audio"); prop_mastervol = prop_create(prop_audio, "mastervolume"); prop_mastermute = prop_create(prop_audio, "mastermute"); prop_set_float_clipping_range(prop_mastervol, -75, 0); prop_set_int(prop_mastermute, 0); if(m != NULL && !htsmsg_get_s32(m, "master-volume", &i32)) prop_set_float(prop_mastervol, (float)i32 / 1000); htsmsg_destroy(m); prop_subscribe(PROP_SUB_NO_INITIAL_UPDATE, PROP_TAG_CALLBACK_FLOAT, save_matervol, NULL, PROP_TAG_ROOT, prop_mastervol, NULL); }
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; }
static int file_open_dir(prop_t *page, const char *url) { prop_t *model; int type; char parent[URL_MAX]; int r; fa_handle_t *ref; ref = fa_reference(url); type = fa_probe_dir(NULL, url); if(type == CONTENT_DVD) { r = backend_open_video(page, url); } else { model = prop_create(page, "model"); prop_set_string(prop_create(model, "type"), "directory"); /* Find a meaningful page title (last component of URL) */ set_title_from_url(prop_create(model, "metadata"), url); // Set parent if(!fa_parent(parent, sizeof(parent), url)) prop_set_string(prop_create(page, "parent"), parent); fa_scanner(url, model, NULL); r = 0; } fa_unreference(ref); return r; }
/** * Try to open the given URL with a playqueue context */ static int file_open_audio(prop_t *page, const char *url) { char parent[URL_MAX]; char parent2[URL_MAX]; struct fa_stat fs; prop_t *model; if(fa_parent(parent, sizeof(parent), url)) return 1; if(fa_stat(parent, &fs, NULL, 0)) return 1; model = prop_create(page, "model"); prop_set_string(prop_create(model, "type"), "directory"); /* Find a meaningful page title (last component of URL) */ rstr_t *title = title_from_url(parent); prop_setv(model, "metadata", "title", NULL, PROP_SET_RSTRING, title); // Set parent if(!fa_parent(parent2, sizeof(parent2), parent)) prop_set_string(prop_create(page, "parent"), parent2); fa_scanner_page(parent, fs.fs_mtime, model, url, prop_create(page, "directClose"), title); rstr_release(title); return 0; }
void darwin_init_cpu_monitor(void) { kern_return_t r; processor_info_t pinfo; mach_msg_type_number_t msg_count; p_sys = prop_create(prop_get_global(), "system"); r = host_processor_info(mach_host_self (), PROCESSOR_CPU_LOAD_INFO, &cpu_count, (processor_info_array_t *)&pinfo, &msg_count); if(r != KERN_SUCCESS) { TRACE(TRACE_ERROR, "darwin", "host_processor_info(PROCESSOR_CPU_LOAD_INFO) failed %d", r); return; } p_cpu = calloc(cpu_count, sizeof(prop_t *)); p_load = calloc(cpu_count, sizeof(prop_t *)); last_total = calloc(cpu_count, sizeof(unsigned int)); last_idle = calloc(cpu_count, sizeof(unsigned int)); prop_set_int(prop_create(prop_create(p_sys, "cpuinfo"), "available"), 1); p_cpuroot = prop_create(prop_create(p_sys, "cpuinfo"), "cpus"); vm_deallocate(mach_task_self(), (vm_address_t)pinfo, (vm_size_t)sizeof(*pinfo) * msg_count); cpu_monitor_do(); callout_arm(&timer, timercb, NULL, 1); }
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); }
void bookmarks_init(void) { htsmsg_field_t *f; htsmsg_t *m, *n, *o; hts_mutex_init(&bookmark_mutex); bookmarks = prop_create(settings_add_dir(NULL, "Bookmarks", "bookmark", NULL), "model"); prop_set_int(prop_create(bookmarks, "mayadd"), 1); prop_subscribe(0, PROP_TAG_CALLBACK, bookmarks_callback, NULL, PROP_TAG_ROOT, prop_create(bookmarks, "nodes"), PROP_TAG_MUTEX, &bookmark_mutex, NULL); if((m = htsmsg_store_load("bookmarks")) != NULL) { n = htsmsg_get_map(m, "nodes"); HTSMSG_FOREACH(f, n) { if((o = htsmsg_get_map_by_field(f)) == NULL) continue; bookmark_load(o); } htsmsg_destroy(m); }
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); }
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(); }
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; }
void linux_init_monitors(void) { p_sys = prop_create(prop_get_global(), "system"); p_cpuroot = prop_create(prop_create(p_sys, "cpuinfo"), "cpus"); timercb(NULL, NULL); }
event_t * popup_display(prop_t *p) { prop_courier_t *pc = prop_courier_create_waitable(); event_t *e = NULL; prop_t *r = prop_create(p, "eventSink"); prop_sub_t *s = prop_subscribe(0, PROP_TAG_CALLBACK, eventsink, &e, PROP_TAG_ROOT, r, PROP_TAG_COURIER, pc, NULL); /* Will show the popup */ if(prop_set_parent(p, prop_create(prop_get_global(), "popups"))) { /* popuproot is a zombie, this is an error */ abort(); } while(e == NULL) prop_courier_wait_and_dispatch(pc); prop_unsubscribe(s); return e; }
/** * Try to open the given URL with a playqueue context */ static int file_open_audio(prop_t *page, const char *url) { char parent[URL_MAX]; char parent2[URL_MAX]; struct fa_stat fs; prop_t *model; if(fa_parent(parent, sizeof(parent), url)) return 1; if(fa_stat(parent, &fs, NULL, 0)) return 1; model = prop_create(page, "model"); prop_set_string(prop_create(model, "type"), "directory"); /* Find a meaningful page title (last component of URL) */ set_title_from_url(prop_create(model, "metadata"), parent); // Set parent if(!fa_parent(parent2, sizeof(parent2), parent)) prop_set_string(prop_create(page, "parent"), parent2); fa_scanner(parent, model, url); return 0; }
prop_t * settings_multiopt_add_opt_cstr(setting_t *s, const char *id, const char *title, int selected) { prop_t *o = prop_create(s->s_val, id); prop_set_string(prop_create(o, "title"), title); return settings_multiopt_add(s, id, o, selected); }
prop_t * settings_multiopt_add_opt(setting_t *s, const char *id, prop_t *title, int selected) { prop_t *o = prop_create(s->s_val, id); prop_link(title, prop_create(o, "title")); return settings_multiopt_add(s, id, o, selected); }
static prop_t * setting_add_cstr(prop_t *parent, const char *title, const char *type, int flags) { prop_t *p = setting_get(parent, flags); prop_set_string(prop_create(prop_create(p, "metadata"), "title"), title); prop_set_string(prop_create(p, "type"), type); return p; }
void notifications_init(void) { prop_t *root = prop_create(prop_get_global(), "notifications"); notify_prop_entries = prop_create(root, "nodes"); }
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; }
void settings_create_info(prop_t *parent, const char *image, prop_t *description) { prop_t *r = setting_add(parent, NULL, "info", 0); prop_link(description, prop_create(r, "description")); if(image != NULL) prop_set_string(prop_create(r, "image"), image); }
int nav_open_error(prop_t *root, const char *msg) { prop_t *model = prop_create(root, "model"); prop_set_string(prop_create(model, "type"), "openerror"); prop_set_int(prop_create(model, "loading"), 0); prop_set_string(prop_create(model, "error"), msg); prop_set_int(prop_create(root, "directClose"), 1); return 0; }
static prop_t * setting_add(prop_t *parent, const char *title, const char *type) { prop_t *p, *model; p = prop_create(parent ? prop_create(parent, "nodes") : settings_nodes, NULL); model = prop_create(p, "model"); set_title(model, title); prop_set_string(prop_create(model, "type"), type); return p; }
static prop_t * setting_add(prop_t *parent, prop_t *title, const char *type, int flags) { prop_t *p = setting_get(parent, flags); if(title != NULL) set_title2(p, title); prop_set_string(prop_create(p, "type"), type); prop_set_int(prop_create(p, "enabled"), 1); return p; }
static setting_t * setting_create_leaf(prop_t *parent, prop_t *title, const char *type, const char *valuename) { setting_t *s = calloc(1, sizeof(setting_t)); s->s_root = setting_add(prop_create(parent, "model"), title, type); s->s_model = prop_create(s->s_root, "model"); s->s_val = prop_ref_inc(prop_create(s->s_model, valuename)); return s; }
void settings_create_info(prop_t *parent, const char *image, const char *description) { prop_t *r = prop_create(setting_add(prop_create(parent, "model"), "Info", "info"), "model"); prop_set_string(prop_create(r, "description"), description); if(image != NULL) prop_set_string(prop_create(r, "image"), image); }