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; }
JSBool js_wait_for_value(JSContext *cx, prop_t *root, const char *subname, jsval value, jsval *rval) { prop_courier_t *pc = prop_courier_create_waitable(); prop_sub_t *s; wfv_t wfv; wfv.value = value; wfv.done = 0; s = prop_subscribe(0, PROP_TAG_ROOT, root, PROP_TAG_COURIER, pc, PROP_TAG_CALLBACK, vfw_setval, &wfv, PROP_TAG_NAMESTR, subname, NULL); if(s == NULL) { JS_ReportError(cx, "Unable to subscribe to %s", subname); return JS_FALSE; } *rval = JSVAL_TRUE; while(!wfv.done) { struct prop_notify_queue exp, nor; jsrefcount s = JS_SuspendRequest(cx); prop_courier_wait(pc, &nor, &exp); JS_ResumeRequest(cx, s); prop_notify_dispatch(&exp); prop_notify_dispatch(&nor); } prop_unsubscribe(s); prop_courier_destroy(pc); return JS_TRUE; }
event_t * popup_display_kbrd(prop_t *p, prop_t *string) { 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 || (!event_is_action(e, ACTION_OK) && !event_is_action(e, ACTION_CANCEL))) { while(e == NULL) prop_courier_wait_and_dispatch(pc); if (!event_is_action(e, ACTION_OK) && !event_is_action(e, ACTION_CANCEL)) { char *tmpInput; htsmsg_t *m; rstr_t *r; 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(&tmpInput, m, "input"); if (event_is_action(e, ACTION_KBRD_A)) strcat(tmpInput, "a"); else if (event_is_action(e, ACTION_KBRD_B)) strcat(tmpInput, "b"); else if (event_is_action(e, ACTION_KBRD_C)) strcat(tmpInput, "c"); else if (event_is_action(e, ACTION_KBRD_D)) strcat(tmpInput, "d"); else if (event_is_action(e, ACTION_KBRD_E)) strcat(tmpInput, "e"); else if (event_is_action(e, ACTION_KBRD_F)) strcat(tmpInput, "f"); else if (event_is_action(e, ACTION_KBRD_G)) strcat(tmpInput, "g"); else if (event_is_action(e, ACTION_KBRD_H)) strcat(tmpInput, "h"); else if (event_is_action(e, ACTION_KBRD_I)) strcat(tmpInput, "i"); else if (event_is_action(e, ACTION_KBRD_J)) strcat(tmpInput, "j"); else if (event_is_action(e, ACTION_KBRD_K)) strcat(tmpInput, "k"); else if (event_is_action(e, ACTION_KBRD_L)) strcat(tmpInput, "l"); else if (event_is_action(e, ACTION_KBRD_M)) strcat(tmpInput, "m"); else if (event_is_action(e, ACTION_KBRD_N)) strcat(tmpInput, "n"); else if (event_is_action(e, ACTION_KBRD_O)) strcat(tmpInput, "o"); else if (event_is_action(e, ACTION_KBRD_P)) strcat(tmpInput, "p"); else if (event_is_action(e, ACTION_KBRD_Q)) strcat(tmpInput, "q"); else if (event_is_action(e, ACTION_KBRD_R)) strcat(tmpInput, "r"); else if (event_is_action(e, ACTION_KBRD_S)) strcat(tmpInput, "s"); else if (event_is_action(e, ACTION_KBRD_T)) strcat(tmpInput, "t"); else if (event_is_action(e, ACTION_KBRD_U)) strcat(tmpInput, "u"); else if (event_is_action(e, ACTION_KBRD_V)) strcat(tmpInput, "v"); else if (event_is_action(e, ACTION_KBRD_W)) strcat(tmpInput, "w"); else if (event_is_action(e, ACTION_KBRD_X)) strcat(tmpInput, "x"); else if (event_is_action(e, ACTION_KBRD_Y)) strcat(tmpInput, "y"); else if (event_is_action(e, ACTION_KBRD_Z)) strcat(tmpInput, "z"); else if (event_is_action(e, ACTION_KBRD_0)) strcat(tmpInput, "0"); else if (event_is_action(e, ACTION_KBRD_1)) strcat(tmpInput, "1"); else if (event_is_action(e, ACTION_KBRD_2)) strcat(tmpInput, "2"); else if (event_is_action(e, ACTION_KBRD_3)) strcat(tmpInput, "3"); else if (event_is_action(e, ACTION_KBRD_4)) strcat(tmpInput, "4"); else if (event_is_action(e, ACTION_KBRD_5)) strcat(tmpInput, "5"); else if (event_is_action(e, ACTION_KBRD_6)) strcat(tmpInput, "6"); else if (event_is_action(e, ACTION_KBRD_7)) strcat(tmpInput, "7"); else if (event_is_action(e, ACTION_KBRD_8)) strcat(tmpInput, "8"); else if (event_is_action(e, ACTION_KBRD_9)) strcat(tmpInput, "9"); else if (event_is_action(e, ACTION_KBRD_COMMA)) strcat(tmpInput, ","); else if (event_is_action(e, ACTION_KBRD_DOT)) strcat(tmpInput, "."); else if (event_is_action(e, ACTION_KBRD_SPACE)) strcat(tmpInput, " "); else if (event_is_action(e, ACTION_BS)) { if (strlen(tmpInput) > 0) { strncpy(tmpInput, tmpInput, strlen(tmpInput) - 1); tmpInput[strlen(tmpInput) - 1] = '\0'; } } prop_set_string(string, tmpInput); e = NULL; } } prop_unsubscribe(s); return e; }
void background_init(prop_t *ui, prop_t *nav, void (*set_image)(rstr_t *url, const char **vpaths, void *opaque), void (*set_alpha)(float alpha, void *opaque), void *opaque) { bg_helper_t *bgh = calloc(1, sizeof(bg_helper_t)); bgh->pc = prop_courier_create_waitable(); bgh->set_image = set_image; bgh->set_alpha = set_alpha; prop_subscribe(0, PROP_TAG_NAME("ui","fullwindow"), PROP_TAG_CALLBACK_INT, set_in_fullwindow, bgh, PROP_TAG_ROOT, ui, PROP_TAG_COURIER, bgh->pc, NULL); prop_subscribe(0, PROP_TAG_NAME("ui","screensaverActive"), PROP_TAG_CALLBACK_INT, set_in_screensaver, bgh, PROP_TAG_ROOT, ui, PROP_TAG_COURIER, bgh->pc, NULL); prop_subscribe(0, PROP_TAG_NAME("ui","skin", "path"), PROP_TAG_CALLBACK_RSTR, set_skin_path, bgh, PROP_TAG_ROOT, ui, PROP_TAG_COURIER, bgh->pc, NULL); prop_subscribe(0, PROP_TAG_NAME("ui","background"), PROP_TAG_CALLBACK_RSTR, set_bg2, bgh, PROP_TAG_ROOT, ui, PROP_TAG_COURIER, bgh->pc, NULL); prop_subscribe(0, PROP_TAG_NAME("nav","currentpage","glw", "background"), PROP_TAG_CALLBACK_RSTR, set_bg1, bgh, PROP_TAG_ROOT, nav, PROP_TAG_COURIER, bgh->pc, NULL); prop_subscribe(0, PROP_TAG_NAME("nav","currentpage", "model", "metadata", "background"), PROP_TAG_CALLBACK_RSTR, set_bg0, bgh, PROP_TAG_ROOT, nav, PROP_TAG_COURIER, bgh->pc, NULL); prop_subscribe(0, PROP_TAG_NAME("nav","currentpage","glw", "backgroundAlpha"), PROP_TAG_CALLBACK_FLOAT, set_alpha1, bgh, PROP_TAG_ROOT, nav, PROP_TAG_COURIER, bgh->pc, NULL); prop_subscribe(0, PROP_TAG_NAME("nav","currentpage", "model", "metadata", "backgroundAlpha"), PROP_TAG_CALLBACK_FLOAT, set_alpha0, bgh, PROP_TAG_ROOT, nav, PROP_TAG_COURIER, bgh->pc, NULL); hts_thread_create_detached("bgloader", bgloader_thread, bgh, THREAD_PRIO_UI_WORKER_LOW); }