static void set_current_str(void *opaque, const char *str) { upnp_local_service_t *uls = &upnp_AVTransport_2; mystrset((char **)opaque, str); upnp_schedule_notify(uls); }
static void http_callback(http_req_aux_t *req, void *opaque) { char errbuf[128]; tracker_torrent_t *tt = opaque; torrent_t *to = tt->tt_torrent; htsmsg_t *msg; net_addr_t na; assert(tt->tt_http_req != NULL); tt->tt_http_req = NULL; buf_t *b = http_req_get_result(req); tt->tt_interval = MIN(3600, tt->tt_interval * 2); if(b != NULL) { msg = bencode_deserialize(buf_cstr(b), buf_cstr(b) + buf_size(b), errbuf, sizeof(errbuf), NULL, NULL); if(msg != NULL) { const char *err = htsmsg_get_str(msg, "failure reason"); if(err != NULL) { tracker_trace(tt->tt_tracker, "%s for %s", err, to->to_title); goto done; } const char *trackerid = htsmsg_get_str(msg, "trackerid"); if(trackerid != NULL) mystrset(&tt->tt_trackerid, trackerid); tt->tt_interval = htsmsg_get_u32_or_default(msg, "min interval", htsmsg_get_u32_or_default(msg, "interval", 1800)); htsmsg_t *peers = htsmsg_get_list(msg, "peers"); if(peers != NULL) { htsmsg_field_t *f; HTSMSG_FOREACH(f, peers) { htsmsg_t *sub = htsmsg_get_map_by_field(f); if(sub == NULL) continue; const char *ip = htsmsg_get_str(sub, "ip"); if(ip == NULL) continue; if(net_resolve_numeric(ip, &na)) continue; na.na_port = htsmsg_get_u32_or_default(sub, "port", 0); if(na.na_port == 0) continue; peer_add(to, &na); } }
static void htsp_channelAddUpdate(htsp_connection_t *hc, htsmsg_t *m, int create) { uint32_t id, next; int chnum; char txt[200]; const char *title, *icon; htsp_channel_t *ch; if(htsmsg_get_u32(m, "channelId", &id)) return; title = htsmsg_get_str(m, "channelName"); icon = htsmsg_get_str(m, "channelIcon"); chnum = htsmsg_get_s32_or_default(m, "channelNumber", -1); snprintf(txt, sizeof(txt), "%d", id); hts_mutex_lock(&hc->hc_meta_mutex); if(create) { ch = htsp_channel_get(hc, id, 1); if(prop_set_parent(ch->ch_root, hc->hc_channels_nodes)) abort(); } else { ch = htsp_channel_get(hc, id, 0); if(ch == NULL) { TRACE(TRACE_ERROR, "HTSP", "Got update for unknown channel %d", id); hts_mutex_unlock(&hc->hc_meta_mutex); return; } } hts_mutex_unlock(&hc->hc_meta_mutex); if(icon != NULL) prop_set_string(ch->ch_prop_icon, icon); if(title != NULL) { mystrset(&ch->ch_title, title); prop_set_string(ch->ch_prop_title, title); } if(chnum != -1) prop_set_int(ch->ch_prop_channelNumber, chnum); if(htsmsg_get_u32(m, "eventId", &id)) id = 0; if(htsmsg_get_u32(m, "nextEventId", &next)) next = 0; update_events(hc, ch->ch_prop_events, id, next); }
static prop_t * settings_multiopt_add(setting_t *s, const char *id, prop_t *o, int selected) { if(selected) { if(s->s_sub != NULL) prop_select(o); else mystrset(&s->s_initial_value, id); } if(s->s_first == NULL) s->s_first = strdup(id); return o; }
void 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); if(selected) { mystrset(&s->s_initial_value, id); prop_select_ex(o, NULL, s->s_sub); } if(s->s_first == NULL) s->s_first = strdup(id); }
void settings_multiopt_initiate(setting_t *s, prop_callback_string_t *cb, void *opaque, prop_courier_t *pc, htsmsg_t *store, settings_saver_t *saver, void *saver_opaque) { const char *str = store ? htsmsg_get_str(store, s->s_id) : NULL; prop_t *o = str ? prop_find(s->s_val, str, NULL) : NULL; if(o == NULL && s->s_initial_value != NULL) o = prop_find(s->s_val, s->s_initial_value, NULL); if(o == NULL && s->s_first != NULL) o = prop_find(s->s_val, s->s_first, NULL); if(o != NULL) { prop_select(o); rstr_t *name = prop_get_name(o); cb(opaque, rstr_get(name)); rstr_release(name); prop_ref_dec(o); } s->s_callback = cb; s->s_opaque = opaque; mystrset(&s->s_initial_value, NULL); s->s_sub = prop_subscribe(PROP_SUB_NO_INITIAL_UPDATE, PROP_TAG_CALLBACK, callback_opt, s, PROP_TAG_ROOT, s->s_val, PROP_TAG_COURIER, pc, NULL); s->s_store = store; s->s_saver = saver; s->s_saver_opaque = saver_opaque; }
static gboolean navigation_policy_decision_requested(WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequest *request, WebKitWebNavigationAction *action, WebKitWebPolicyDecision *decision, gpointer user_data) { webpopup_t *wp = user_data; const char *uri = webkit_network_request_get_uri(request); if(mystrbegins(uri, wp->wp_trap)) { TRACE(TRACE_DEBUG, "Webkit", "Opening %s -- Final URI reached", uri); mystrset(&wp->wp_wr.wr_trapped.url, uri); finalize(wp, WEBPOPUP_TRAPPED_URL); webkit_web_policy_decision_ignore(decision); } else { TRACE(TRACE_DEBUG, "Webkit", "Opening %s", uri); webkit_web_policy_decision_use(decision); } return TRUE; }
static void set_lang(void *opaque, const char *str) { char **s = opaque; mystrset(s, str); }
static void set_beta_passwords(void *opaque, const char *value) { mystrset(&plugin_beta_passwords, value); }
static JSBool js_createMultiOpt(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { js_setting_group_t *jsg = JS_GetPrivate(cx, obj); const char *id; const char *title; JSObject *func; JSObject *optlist; JSBool persistent = JS_FALSE; if(!JS_ConvertArguments(cx, argc, argv, "ssoo/b", &id, &title, &optlist, &func, &persistent)) return JS_FALSE; js_setting_t *jss = jss_create(cx, obj, id, rval, func, jsg, persistent); if(jss == NULL) return JS_FALSE; char **options = NULL; JSIdArray *opts, *opt; int i; char *defvalue = NULL; if((opts = JS_Enumerate(cx, optlist)) != NULL) { for(i = 0; i < opts->length; i++) { jsval name, value, id, title, def; if(!JS_IdToValue(cx, opts->vector[i], &name) || !JSVAL_IS_INT(name) || !JS_GetElement(cx, optlist, JSVAL_TO_INT(name), &value) || !JSVAL_IS_OBJECT(value) || (opt = JS_Enumerate(cx, JSVAL_TO_OBJECT(value))) == NULL) continue; if(opt->length >= 2 && JS_GetElement(cx, JSVAL_TO_OBJECT(value), 0, &id) && JS_GetElement(cx, JSVAL_TO_OBJECT(value), 1, &title)) { if(opt->length < 3 || !JS_GetElement(cx, JSVAL_TO_OBJECT(value), 2, &def)) def = JSVAL_FALSE; const char *k = JS_GetStringBytes(JS_ValueToString(cx, id)); if(def == JSVAL_TRUE) mystrset(&defvalue, k); strvec_addp(&options, k); strvec_addp(&options, JS_GetStringBytes(JS_ValueToString(cx, title))); } JS_DestroyIdArray(cx, opt); } JS_DestroyIdArray(cx, opts); } rstr_t *r = NULL; if(persistent && jsg->jsg_kv_url) r = kv_url_opt_get_rstr(jsg->jsg_kv_url, KVSTORE_DOMAIN_PLUGIN, id); jss->jss_s = setting_create(SETTING_MULTIOPT, jsg->jsg_root, SETTINGS_INITIAL_UPDATE | jsg->jsg_settings_flags, SETTING_TITLE_CSTR(title), SETTING_COURIER(js_global_pc), SETTING_CALLBACK(js_store_update_string, jss), SETTING_VALUE(r ? rstr_get(r) : defvalue), SETTING_OPTION_LIST(options), SETTING_HTSMSG_CUSTOM_SAVER(id, jsg->jsg_store, js_setting_group_save, jsg), NULL); strvec_free(options); rstr_release(r); jss->jss_cx = NULL; return JS_TRUE; }
static void set_id(glw_t *w, const char *str) { mystrset(&w->glw_id, str); }
void parse_opts(int argc, char **argv) { const char *argv0 = argv[0]; argv++; argc--; while(argc > 0) { if(!strcmp(argv[0], "-h") || !strcmp(argv[0], "--help")) { printf("Showtime %s\n" "Copyright (C) 2007-2012 Andreas Öman\n" "\n" "Usage: %s [options] [<url>]\n" "\n" " Options:\n" " -h, --help - This help text.\n" " -d - Enable debug output.\n" " --no-ui - Start without UI.\n" " --fullscreen - Start in fullscreen mode.\n" " --ffmpeglog - Print ffmpeg log messages.\n" " --with-standby - Enable system standby.\n" " --with-poweroff - Enable system power-off.\n" " -s <path> - Non-default Showtime settings path.\n" " --ui <ui> - Use specified user interface.\n" " -L <ip:host> - Send log messages to remote <ip:host>.\n" " --syslog - Send log messages to syslog.\n" #if ENABLE_STDIN " --stdin - Listen on stdin for events.\n" #endif " -v <view> - Use specific view for <url>.\n" " --cache <path> - Set path for cache [%s].\n" #if ENABLE_SERDEV " --serdev - Probe service ports for devices.\n" #endif #if ENABLE_HTTPSERVER " --disable-upnp - Disable UPNP/DLNA stack.\n" #endif " --disable-sd - Disable service discovery (mDNS, etc).\n" " -p - Path to plugin directory to load\n" " Intended for plugin development\n" " --plugin-repo - URL to plugin repository\n" " Intended for plugin development\n" " -j <path> Load javascript file\n" " --ui <ui> Select user interface\n" " --skin <skin> Select skin (for GLW ui)\n" "\n" " URL is any URL-type supported by Showtime, " "e.g., \"file:///...\"\n" "\n", htsversion_full, argv0, gconf.cache_path); exit(0); argc--; argv++; } else if(!strcmp(argv[0], "-d")) { gconf.trace_level = TRACE_DEBUG; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--ffmpeglog")) { gconf.ffmpeglog = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--no-ui")) { gconf.noui = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--fullscreen")) { gconf.fullscreen = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--syslog")) { gconf.trace_to_syslog = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--stdin")) { gconf.listen_on_stdin = 1; argc -= 1; argv += 1; continue; #if ENABLE_SERDEV } else if(!strcmp(argv[0], "--serdev")) { gconf.enable_serdev = 1; argc -= 1; argv += 1; continue; #endif #if ENABLE_HTTPSERVER } else if(!strcmp(argv[0], "--disable-upnp")) { gconf.disable_upnp = 1; argc -= 1; argv += 1; continue; #endif } else if(!strcmp(argv[0], "--disable-sd")) { gconf.disable_sd = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--with-standby")) { gconf.can_standby = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--with-poweroff")) { gconf.can_poweroff = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--with-logout")) { gconf.can_logout = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--with-openshell")) { gconf.can_open_shell = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--without-exit")) { gconf.can_not_exit = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--with-restart")) { gconf.can_restart = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "-p") && argc > 1) { gconf.devplugin = argv[1]; argc -= 2; argv += 2; continue; } else if(!strcmp(argv[0], "--plugin-repo") && argc > 1) { gconf.plugin_repo = argv[1]; argc -= 2; argv += 2; continue; } else if(!strcmp(argv[0], "-j") && argc > 1) { gconf.load_jsfile = argv[1]; argc -= 2; argv += 2; continue; } else if (!strcmp(argv[0], "-v") && argc > 1) { gconf.initial_view = argv[1]; argc -= 2; argv += 2; } else if (!strcmp(argv[0], "--cache") && argc > 1) { mystrset(&gconf.cache_path, argv[1]); argc -= 2; argv += 2; } else if (!strcmp(argv[0], "--ui") && argc > 1) { mystrset(&gconf.ui, argv[1]); argc -= 2; argv += 2; } else if (!strcmp(argv[0], "--skin") && argc > 1) { mystrset(&gconf.skin, argv[1]); argc -= 2; argv += 2; #ifdef __APPLE__ /* ignore -psn argument, process serial number */ } else if(!strncmp(argv[0], "-psn", 4)) { argc -= 1; argv += 1; continue; #endif } else break; } if(argc > 0) gconf.initial_url = argv[0]; }
void parse_opts(int argc, char **argv) { const char *argv0 = argv[0]; argv++; argc--; gconf.showtime_shell_fd = -1; while(argc > 0) { if(!strcmp(argv[0], "-h") || !strcmp(argv[0], "--help")) { printf(APPNAMEUSER" %s\n" "Copyright (C) 2007-2015 Lonelycoder AB\n" "\n" "Usage: %s [options] [<url>]\n" "\n" " Options:\n" " -h, --help - This help text.\n" " -d - Enable debug output.\n" " --no-ui - Start without UI.\n" " --fullscreen - Start in fullscreen mode.\n" " --libav-log - Print libav log messages.\n" " --with-standby - Enable system standby.\n" " --with-poweroff - Enable system power-off.\n" " -s <path> - Non-default settings path.\n" " --ui <ui> - Use specified user interface.\n" " -L <ip:host> - Send log messages to remote <ip:host>.\n" " --syslog - Send log messages to syslog.\n" #if ENABLE_STDIN " --stdin - Listen on stdin for events.\n" #endif " -v <view> - Use specific view for <url>.\n" " --cache <path> - Set path for cache [%s].\n" " --persistent <path> - Set path for persistent stuff [%s].\n" #if ENABLE_HTTPSERVER " --disable-upnp - Disable UPNP/DLNA stack.\n" #endif " --disable-sd - Disable service discovery (mDNS, etc).\n" " -p - Path to plugin directory to load\n" " Intended for plugin development\n" " --plugin-repo - URL to plugin repository\n" " Intended for plugin development\n" " -j <path> Load javascript file\n" " --skin <skin> Select skin (for GLW ui)\n" "\n" " URL is any URL-type supported, " "e.g., \"file:///...\"\n" "\n", htsversion_full, argv0, gconf.cache_path, gconf.persistent_path); exit(0); argc--; argv++; } else if(!strcmp(argv[0], "-d")) { gconf.trace_level = TRACE_DEBUG; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--libav-log")) { gconf.libavlog = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--debug-glw")) { gconf.debug_glw = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--show-usage-events")) { gconf.show_usage_events = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--no-ui")) { gconf.noui = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--fullscreen")) { gconf.fullscreen = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--syslog")) { gconf.trace_to_syslog = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--stdin")) { gconf.listen_on_stdin = 1; argc -= 1; argv += 1; continue; #if ENABLE_HTTPSERVER } else if(!strcmp(argv[0], "--disable-upnp")) { gconf.disable_upnp = 1; argc -= 1; argv += 1; continue; #endif } else if(!strcmp(argv[0], "--disable-sd")) { gconf.disable_sd = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--disable-upgrades")) { gconf.disable_upgrades = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--with-standby")) { gconf.can_standby = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--with-poweroff")) { gconf.can_poweroff = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--with-logout")) { gconf.can_logout = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--with-openshell")) { gconf.can_open_shell = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--without-exit")) { gconf.can_not_exit = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--with-restart")) { gconf.can_restart = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "-p") && argc > 1) { strvec_addp(&gconf.devplugins,argv[1]); argc -= 2; argv += 2; continue; } else if(!strcmp(argv[0], "--plugin-repo") && argc > 1) { gconf.plugin_repo = argv[1]; argc -= 2; argv += 2; continue; } else if(!strcmp(argv[0], "--bypass-ecmascript-acl")) { gconf.bypass_ecmascript_acl = 1; argc -= 1; argv += 1; } else if(!strcmp(argv[0], "--ecmascript") && argc > 1) { gconf.load_ecmascript = argv[1]; argc -= 2; argv += 2; continue; } else if (!strcmp(argv[0], "-v") && argc > 1) { gconf.initial_view = argv[1]; argc -= 2; argv += 2; } else if (!strcmp(argv[0], "--cache") && argc > 1) { mystrset(&gconf.cache_path, argv[1]); argc -= 2; argv += 2; } else if (!strcmp(argv[0], "--persistent") && argc > 1) { mystrset(&gconf.persistent_path, argv[1]); argc -= 2; argv += 2; } else if (!strcmp(argv[0], "--ui") && argc > 1) { mystrset(&gconf.ui, argv[1]); argc -= 2; argv += 2; } else if (!strcmp(argv[0], "--skin") && argc > 1) { mystrset(&gconf.skin, argv[1]); argc -= 2; argv += 2; } else if (!strcmp(argv[0], "--upgrade-path") && argc > 1) { mystrset(&gconf.upgrade_path, argv[1]); argc -= 2; argv += 2; } else if (!strcmp(argv[0], "--showtime-shell-fd") && argc > 1) { gconf.showtime_shell_fd = atoi(argv[1]); argc -= 2; argv += 2; } else if (!strcmp(argv[0], "--proxy") && argc > 1) { char *x = mystrdupa(argv[1]); char *pstr = strchr(x, ':'); if(pstr != NULL) { *pstr++ = 0; gconf.proxy_port = atoi(pstr); } else { gconf.proxy_port = 1080; } snprintf(gconf.proxy_host, sizeof(gconf.proxy_host), "%s", x); printf("Proxy set to %s:%d\n", gconf.proxy_host, gconf.proxy_port); argc -= 2; argv += 2; #ifdef __APPLE__ /* ignore -psn argument, process serial number */ } else if(!strncmp(argv[0], "-psn", 4)) { argc -= 1; argv += 1; continue; #endif } else break; } if(argc > 0) gconf.initial_url = argv[0]; }
static connman_service_t * update_service(GVariant *v, const char *path, connman_service_t *after) { connman_service_t *cs = connman_service_find(path); if(cs == NULL) { GError *err = NULL; GDBusProxy *proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START , NULL, "net.connman", path, "net.connman.Service", NULL, &err); if(proxy == NULL) { TRACE(TRACE_ERROR, "CONNMAN", "Unable to connect to service %s -- %s", path, err->message); g_error_free(err); return NULL; } cs = calloc(1, sizeof(connman_service_t)); cs->cs_refcount = 1; cs->cs_proxy = proxy; if(after == NULL) { TAILQ_INSERT_HEAD(&connman_services, cs, cs_link); } else { TAILQ_INSERT_AFTER(&connman_services, after, cs, cs_link); } connman_service_t *next = TAILQ_NEXT(cs, cs_link); cs->cs_prop = prop_create_root(path); cs->cs_path = strdup(path); cs->cs_sub = prop_subscribe(0, PROP_TAG_CALLBACK_EVENT, connman_service_event, cs, PROP_TAG_ROOT, cs->cs_prop, PROP_TAG_COURIER, connman_courier, NULL); g_signal_connect(G_OBJECT(cs->cs_proxy), "g-signal", G_CALLBACK(connman_svc_signal), cs); // Insert at correct position if(prop_set_parent_ex(cs->cs_prop, service_nodes, next ? next->cs_prop : NULL, NULL)) abort(); prop_t *m = prop_create(cs->cs_prop, "metadata"); prop_link(prop_create(m, "name"), prop_create(m, "title")); prop_set(cs->cs_prop, "type", PROP_SET_STRING, "network"); } else { // Possibly move TAILQ_REMOVE(&connman_services, cs, cs_link); if(after == NULL) { TAILQ_INSERT_HEAD(&connman_services, cs, cs_link); } else { TAILQ_INSERT_AFTER(&connman_services, after, cs, cs_link); } connman_service_t *next = TAILQ_NEXT(cs, cs_link); prop_move(cs->cs_prop, next ? next->cs_prop : NULL); } // Update metadata prop_set_from_vardict(v, prop_create(cs->cs_prop, "metadata")); GVariant *name = g_variant_lookup_value(v, "Name", NULL); const gchar *val = name ? g_variant_get_string(name, NULL) : NULL; if(val) mystrset(&cs->cs_name, val); return cs; }
static void htsp_channelAddUpdate(htsp_connection_t *hc, htsmsg_t *m, int create) { uint32_t id, next; int chnum; prop_t *p; char txt[200]; const char *title, *icon; htsp_channel_t *ch, *n; if(htsmsg_get_u32(m, "channelId", &id)) return; title = htsmsg_get_str(m, "channelName"); icon = htsmsg_get_str(m, "channelIcon"); chnum = htsmsg_get_s32_or_default(m, "channelNumber", -1); if(chnum == 0) chnum = INT32_MAX; snprintf(txt, sizeof(txt), "%d", id); hts_mutex_lock(&hc->hc_meta_mutex); if(create) { ch = calloc(1, sizeof(htsp_channel_t)); p = ch->ch_root = prop_create_root(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"); ch->ch_id = id; snprintf(txt, sizeof(txt), "htsp://%s:%d/channel/%d", hc->hc_hostname, hc->hc_port, id); prop_set_string(prop_create(p, "url"), txt); prop_set_string(prop_create(p, "type"), "tvchannel"); ch->ch_channel_num = chnum; mystrset(&ch->ch_title, title); TAILQ_INSERT_SORTED(&hc->hc_channels, ch, ch_link, channel_compar); n = TAILQ_NEXT(ch, ch_link); if(prop_set_parent_ex(p, hc->hc_channels_nodes, n ? n->ch_root : NULL, NULL)) abort(); } else { int move = 0; ch = htsp_channel_get(hc, id); if(ch == NULL) { TRACE(TRACE_ERROR, "HTSP", "Got update for unknown channel %d", id); hts_mutex_unlock(&hc->hc_meta_mutex); return; } p = ch->ch_root; if(title != NULL) { move = 1; mystrset(&ch->ch_title, title); } if(chnum != -1) { move = 1; ch->ch_channel_num = chnum; } if(move) { TAILQ_REMOVE(&hc->hc_channels, ch, ch_link); TAILQ_INSERT_SORTED(&hc->hc_channels, ch, ch_link, channel_compar); n = TAILQ_NEXT(ch, ch_link); prop_move(p, n ? n->ch_root : NULL); } } hts_mutex_unlock(&hc->hc_meta_mutex); if(icon != NULL) prop_set_string(ch->ch_prop_icon, icon); if(title != NULL) prop_set_string(ch->ch_prop_title, title); if(chnum != -1) prop_set_int(ch->ch_prop_channelNumber, chnum); if(htsmsg_get_u32(m, "eventId", &id)) id = 0; if(htsmsg_get_u32(m, "nextEventId", &next)) next = 0; update_events(hc, ch->ch_prop_events, id, next); }
/** * Showtime main */ int main(int argc, char **argv) { struct timeval tv; const char *settingspath = NULL; const char *uiargs[16]; const char *argv0 = argc > 0 ? argv[0] : "showtime"; const char *forceview = NULL; int nuiargs = 0; int can_standby = 0; int can_poweroff = 0; int r; trace_level = TRACE_INFO; gettimeofday(&tv, NULL); srand(tv.tv_usec); arch_set_default_paths(argc, argv); /* We read options ourselfs since getopt() is broken on some (nintento wii) targets */ argv++; argc--; while(argc > 0) { if(!strcmp(argv[0], "-h") || !strcmp(argv[0], "--help")) { printf("HTS Showtime %s\n" "Copyright (C) 2007-2010 Andreas Öman\n" "\n" "Usage: %s [options] [<url>]\n" "\n" " Options:\n" " -h, --help - This help text.\n" " -d - Enable debug output.\n" " --ffmpeglog - Print ffmpeg log messages.\n" " --with-standby - Enable system standby.\n" " --with-poweroff - Enable system power-off.\n" " -s <path> - Non-default Showtime settings path.\n" " --ui <ui> - Use specified user interface.\n" " -L <ip:host> - Send log messages to remote <ip:host>.\n" " --syslog - Send log messages to syslog.\n" #if ENABLE_STDIN " --stdin - Listen on stdin for events.\n" #endif " -v <view> - Use specific view for <url>.\n" " --cache <path> - Set path for cache [%s].\n" #if ENABLE_SERDEV " --serdev - Probe service ports for devices.\n" #endif "\n" " URL is any URL-type supported by Showtime, " "e.g., \"file:///...\"\n" "\n", htsversion_full, argv0, showtime_cache_path); exit(0); argc--; argv++; } else if(!strcmp(argv[0], "-d")) { trace_level++; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--ffmpeglog")) { ffmpeglog = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--syslog")) { trace_to_syslog = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--stdin")) { listen_on_stdin = 1; argc -= 1; argv += 1; continue; #if ENABLE_SERDEV } else if(!strcmp(argv[0], "--serdev")) { enable_serdev = 1; argc -= 1; argv += 1; continue; #endif } else if(!strcmp(argv[0], "--with-standby")) { can_standby = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "--with-poweroff")) { can_poweroff = 1; argc -= 1; argv += 1; continue; } else if(!strcmp(argv[0], "-s") && argc > 1) { settingspath = argv[1]; argc -= 2; argv += 2; continue; } else if(!strcmp(argv[0], "--ui") && argc > 1) { if(nuiargs < 16) uiargs[nuiargs++] = argv[1]; argc -= 2; argv += 2; continue; } else if(!strcmp(argv[0], "-L") && argc > 1) { showtime_logtarget = argv[1]; argc -= 2; argv += 2; continue; } else if (!strcmp(argv[0], "-v") && argc > 1) { forceview = argv[1]; argc -= 2; argv += 2; } else if (!strcmp(argv[0], "--cache") && argc > 1) { mystrset(&showtime_cache_path, argv[1]); argc -= 2; argv += 2; #ifdef __APPLE__ /* ignore -psn argument, process serial number */ } else if(!strncmp(argv[0], "-psn", 4)) { argc -= 1; argv += 1; continue; #endif } else break; } unicode_init(); /* Initialize property tree */ prop_init(); init_global_info(); /* Initiailize logging */ trace_init(); /* Callout framework */ callout_init(); /* Notification framework */ notifications_init(); /* Architecture specific init */ arch_init(); htsmsg_store_init(); /* Try to create cache path */ if(showtime_cache_path != NULL && (r = makedirs(showtime_cache_path)) != 0) { TRACE(TRACE_ERROR, "cache", "Unable to create cache path %s -- %s", showtime_cache_path, strerror(r)); showtime_cache_path = NULL; } /* Initializte blob cache */ blobcache_init(); /* Try to create settings path */ if(showtime_settings_path != NULL && (r = makedirs(showtime_settings_path)) != 0) { TRACE(TRACE_ERROR, "settings", "Unable to create settings path %s -- %s", showtime_settings_path, strerror(r)); showtime_settings_path = NULL; } /* Initialize keyring */ keyring_init(); /* Initialize settings */ settings_init(); /* Initialize libavcodec & libavformat */ av_lockmgr_register(fflockmgr); av_log_set_callback(fflog); av_register_all(); /* Freetype keymapper */ #if ENABLE_LIBFREETYPE freetype_init(); #endif /* Global keymapper */ keymapper_init(); /* Initialize media subsystem */ media_init(); /* Service handling */ service_init(); /* Initialize backend content handlers */ backend_init(); /* Initialize navigator */ nav_init(); /* Initialize audio subsystem */ audio_init(); /* Initialize bookmarks */ bookmarks_init(); /* Initialize plugin manager and load plugins */ plugins_init(); /* Internationalization */ i18n_init(); nav_open(NAV_HOME, NULL); /* Open initial page */ if(argc > 0) nav_open(argv[0], forceview); /* Various interprocess communication stuff (D-Bus on Linux, etc) */ ipc_init(); /* Service discovery. Must be after ipc_init() (d-bus and threads, etc) */ sd_init(); /* Initialize various external APIs */ api_init(); /* HTTP server and UPNP */ #if ENABLE_HTTPSERVER http_server_init(); upnp_init(); #endif /* */ runcontrol_init(can_standby, can_poweroff); TRACE(TRACE_DEBUG, "core", "Starting UI"); /* Initialize user interfaces */ ui_start(nuiargs, uiargs, argv0); finalize(); }
static void set_alt_repo_url(void *opaque, const char *value) { mystrset(&plugin_alt_repo_url, value); }