本文整理汇总了C++中prop_subscribe函数的典型用法代码示例。如果您正苦于以下问题:C++ prop_subscribe函数的具体用法?C++ prop_subscribe怎么用?C++ prop_subscribe使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了prop_subscribe函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: audio_mastervol_init
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);
}
示例2: nav_page_setup_prop
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);
}
示例3: nav_create
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;
}
示例4: prop_reorder_create
void
prop_reorder_create(prop_t *dst, prop_t *src, int flags, const char *id)
{
prop_reorder_t *pr = calloc(1, sizeof(prop_reorder_t));
pr->pr_order = htsmsg_store_load(id);
if(pr->pr_order == NULL)
pr->pr_order = htsmsg_create_list();
pr->pr_store = strdup(id);
pr->pr_dst = flags & PROP_REORDER_TAKE_DST_OWNERSHIP ?
dst : prop_xref_addref(dst);
hts_mutex_lock(&prop_mutex);
pr->pr_srcsub = prop_subscribe(PROP_SUB_INTERNAL | PROP_SUB_DONTLOCK |
PROP_SUB_TRACK_DESTROY,
PROP_TAG_CALLBACK, src_cb, pr,
PROP_TAG_ROOT, src,
NULL);
pr->pr_dstsub = prop_subscribe(PROP_SUB_INTERNAL | PROP_SUB_DONTLOCK |
PROP_SUB_TRACK_DESTROY,
PROP_TAG_CALLBACK, dst_cb, pr,
PROP_TAG_ROOT, dst,
NULL);
hts_mutex_unlock(&prop_mutex);
}
示例5: bookmark_add
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();
}
示例6: add_news
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;
}
示例7: add_header
static void
add_header(prop_courier_t *pc, GtkWidget *parent, prop_t *root)
{
GtkWidget *hbox, *w;
prop_sub_t *s;
hbox = gtk_hbox_new(FALSE, 1);
gtk_box_pack_start(GTK_BOX(parent), hbox, FALSE, TRUE, 0);
/* Artist name */
w = gtk_label_new("");
gtk_misc_set_alignment(GTK_MISC(w), 0, 0);
gtk_label_set_ellipsize(GTK_LABEL(w), PANGO_ELLIPSIZE_END);
gtk_box_pack_start(GTK_BOX(hbox), w, TRUE, TRUE, 0);
s = prop_subscribe(0,
PROP_TAG_NAME("self", "model", "artist_name"),
PROP_TAG_CALLBACK_STRING, gu_subscription_set_label_xl, w,
PROP_TAG_COURIER, pc,
PROP_TAG_NAMED_ROOT, root, "self",
NULL);
gu_unsubscribe_on_destroy(GTK_OBJECT(w), s);
}
示例8: add_albums
static void
add_albums(gu_tab_t *gt, GtkWidget *parent, prop_t *root)
{
GtkWidget *sbox;
albumbrowse_t *ab = calloc(1, sizeof(albumbrowse_t));
ab->gt = gt;
/* Scrolled window */
sbox = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sbox),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_box_pack_start(GTK_BOX(parent), sbox, TRUE, TRUE, 0);
/* vbox for all albums */
ab->vbox = gtk_vbox_new(FALSE, 1);
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sbox), ab->vbox);
ab->sub =
prop_subscribe(0,
PROP_TAG_NAME("self", "model", "nodes"),
PROP_TAG_CALLBACK, collection_albums, ab,
PROP_TAG_COURIER, gt->gt_gw->gw_gu->gu_pc,
PROP_TAG_NAMED_ROOT, root, "self",
NULL);
g_signal_connect(sbox, "destroy", G_CALLBACK(ab_destroy), ab);
}
示例9: js_item_onEvent
static JSBool
js_item_onEvent(JSContext *cx, JSObject *obj,
uintN argc, jsval *argv, jsval *rval)
{
js_item_t *ji = JS_GetPrivate(cx, obj);
if(!JS_ObjectIsFunction(cx, JSVAL_TO_OBJECT(argv[1]))) {
JS_ReportError(cx, "Argument is not a function");
return JS_FALSE;
}
if(ji->ji_eventsub == NULL) {
ji->ji_eventsub =
prop_subscribe(PROP_SUB_TRACK_DESTROY,
PROP_TAG_CALLBACK, js_item_eventsub, ji,
PROP_TAG_ROOT, ji->ji_root,
PROP_TAG_COURIER, ji->ji_model->jm_pc,
NULL);
ji->ji_model->jm_subs++;
ji->ji_this = OBJECT_TO_JSVAL(obj);
JS_AddNamedRoot(cx, &ji->ji_this, "item_this");
}
js_event_handler_create(cx, &ji->ji_event_handlers,
JSVAL_IS_STRING(argv[0]) ?
JS_GetStringBytes(JS_ValueToString(cx, argv[0])) :
NULL,
argv[1]);
*rval = JSVAL_VOID;
return JS_TRUE;
}
示例10: backend_prop_make
void
backend_prop_make(prop_t *model, char *url, size_t urllen)
{
proppage_t *pp;
hts_mutex_lock(&pp_mutex);
pp = malloc(sizeof(proppage_t));
pp_tally++;
snprintf(url, urllen, "prop:%d", pp_tally);
pp->pp_url = strdup(url);
pp->pp_model = prop_ref_inc(model);
pp->pp_model_sub =
prop_subscribe(PROP_SUB_TRACK_DESTROY,
PROP_TAG_CALLBACK, pp_cb, pp,
PROP_TAG_MUTEX, &pp_mutex,
PROP_TAG_ROOT, model,
NULL);
LIST_INSERT_HEAD(&proppages, pp, pp_link);
hts_mutex_unlock(&pp_mutex);
}
示例11: bookmarks_init
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);
}
示例12: add_news_locked
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;
}
示例13: be_prop_open
static int
be_prop_open(prop_t *page, const char *url)
{
proppage_t *pp;
openpage_t *op;
hts_mutex_lock(&pp_mutex);
LIST_FOREACH(pp, &proppages, pp_link)
if(!strcmp(rstr_get(pp->pp_url), url))
break;
if(pp == NULL) {
hts_mutex_unlock(&pp_mutex);
return 1;
}
op = calloc(1, sizeof(openpage_t));
LIST_INSERT_HEAD(&pp->pp_pages, op, op_link);
op->op_pp = pp;
op->op_root = prop_ref_inc(page);
op->op_page_sub =
prop_subscribe(PROP_SUB_TRACK_DESTROY,
PROP_TAG_CALLBACK, op_cb, op,
PROP_TAG_MUTEX, &pp_mutex,
PROP_TAG_ROOT, page,
NULL);
prop_link(pp->pp_model, prop_create(page, "model"));
hts_mutex_unlock(&pp_mutex);
return 0;
}
示例14: popup_display
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;
}
示例15: settings_create_bool
setting_t *
settings_create_bool(prop_t *parent, const char *id, prop_t *title,
int initial, htsmsg_t *store,
prop_callback_int_t *cb, void *opaque,
int flags, prop_courier_t *pc,
settings_saver_t *saver, void *saver_opaque)
{
setting_t *s = setting_create_leaf(parent, title, "bool", "value", flags);
prop_sub_t *sub;
s->s_id = strdup(id);
s->s_callback = cb;
s->s_opaque = opaque;
if(store != NULL)
initial = htsmsg_get_u32_or_default(store, id, initial);
prop_set_int(s->s_val, !!initial);
if(flags & SETTINGS_INITIAL_UPDATE)
settings_int_callback(s, !!initial);
sub = prop_subscribe(PROP_SUB_NO_INITIAL_UPDATE,
PROP_TAG_CALLBACK_INT, settings_int_callback, s,
PROP_TAG_ROOT, s->s_val,
PROP_TAG_COURIER, pc,
NULL);
s->s_sub = sub;
s->s_store = store;
s->s_saver = saver;
s->s_saver_opaque = saver_opaque;
return s;
}