Skip to content

Commit

Permalink
Drop the ability to run multiple UIs simultaniously and simplify thin…
Browse files Browse the repository at this point in the history
…gs a lot
  • Loading branch information
andoma committed Aug 30, 2012
1 parent c8c6fa5 commit 9b8de6c
Show file tree
Hide file tree
Showing 22 changed files with 206 additions and 643 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ SRCS += src/main.c \
src/service.c \
src/notifications.c \
src/playqueue.c \
src/ui/ui.c \
src/keymapper.c \
src/plugins.c \
src/upgrade.c \
Expand Down
5 changes: 2 additions & 3 deletions src/api/httpcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "misc/pixmap.h"
#include "misc/string.h"
#include "backend/backend.h"
#include "ui/ui.h"
#include "notifications.h"
#include "fileaccess/fileaccess.h"

Expand Down Expand Up @@ -194,7 +193,7 @@ hc_action(http_connection_t *hc, const char *remain, void *opaque,
if(remain == NULL)
return 404;

ui_primary_event(event_create_action_str(remain));
event_to_ui(event_create_action_str(remain));
return HTTP_STATUS_OK;
}

Expand Down Expand Up @@ -222,7 +221,7 @@ hc_utf8(http_connection_t *hc, const char *remain, void *opaque,
e = event_create_int(EVENT_UNICODE, c);
break;
}
ui_primary_event(e);
event_to_ui(e);
}
return HTTP_STATUS_OK;
}
Expand Down
12 changes: 12 additions & 0 deletions src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,18 @@ event_to_prop(prop_t *p, event_t *e)
}


/**
*
*/
void
event_to_ui(event_t *e)
{
event_to_prop(prop_get_by_name(PNVEC("global", "ui", "eventSink"),
1, NULL), e);
event_release(e);
}


/**
*
*/
Expand Down
4 changes: 4 additions & 0 deletions src/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ typedef enum {

EVENT_PLAYBACK_PRIORITY, // 0 = best, higher value == less important

EVENT_STOP_UI,

EVENT_DYNAMIC_ACTION,

} event_type_t;
Expand Down Expand Up @@ -313,4 +315,6 @@ void event_dispatch(event_t *e);

event_t *event_from_Fkey(unsigned int keynum, unsigned int mod);

void event_to_ui(event_t *e);

#endif /* EVENT_H */
3 changes: 1 addition & 2 deletions src/ipc/lirc.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

#include "event.h"
#include "showtime.h"
#include "ui/ui.h"
#include "ipc/ipc.h"
#include "event.h"

Expand Down Expand Up @@ -126,7 +125,7 @@ lirc_thread(void *aux)
snprintf(buf, sizeof(buf), "IR+%s", keyname);
e = event_create_str(EVENT_KEYDESC, buf);
}
ui_primary_event(e);
event_to_ui(e);
}
}
out:
Expand Down
3 changes: 1 addition & 2 deletions src/ipc/stdin.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

#include "arch/threads.h"
#include "event.h"
#include "ui/ui.h"

#include "ipc.h"

Expand Down Expand Up @@ -158,7 +157,7 @@ stdin_thread(void *aux)

if(e == NULL)
continue;
ui_primary_event(e);
event_to_ui(e);
}
return NULL;
}
Expand Down
80 changes: 43 additions & 37 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include "backend/backend.h"
#include "navigator.h"
#include "settings.h"
#include "ui/ui.h"
#include "keyring.h"
#include "notifications.h"
#include "sd/sd.h"
Expand Down Expand Up @@ -74,7 +73,6 @@ static void showtime_fini(void);
/**
*
*/
static int ffmpeglog;
static int showtime_retcode = 1;

gconf_t gconf;
Expand Down Expand Up @@ -113,7 +111,7 @@ fflog(void *ptr, int level, const char *fmt, va_list vl)
{
static char line[1024];
AVClass *avc = ptr ? *(AVClass**)ptr : NULL;
if(!ffmpeglog)
if(!gconf.ffmpeglog)
return;

if(level < AV_LOG_WARNING)
Expand Down Expand Up @@ -155,7 +153,7 @@ init_global_info(void)
*
*/
static void
showtime_init(const char *initial_url, const char *initial_view)
showtime_init(void)
{
int r;

Expand Down Expand Up @@ -251,7 +249,7 @@ showtime_init(const char *initial_url, const char *initial_view)

/* Initialize plugin manager and load plugins */
/* Once plugins are initialized it will also start the auto-upgrade system */
plugins_init(gconf.devplugin, gconf.plugin_repo, initial_url != NULL);
plugins_init(gconf.devplugin, gconf.plugin_repo, gconf.initial_url != NULL);

/* Internationalization */
i18n_init();
Expand All @@ -274,8 +272,8 @@ showtime_init(const char *initial_url, const char *initial_view)

/* Open initial page(s) */
nav_open(NAV_HOME, NULL);
if(initial_url != NULL)
nav_open(initial_url, initial_view);
if(gconf.initial_url != NULL)
nav_open(gconf.initial_url, gconf.initial_view);


/* HTTP server and UPNP */
Expand All @@ -287,30 +285,16 @@ showtime_init(const char *initial_url, const char *initial_view)


runcontrol_init();

}


/**
* Showtime main
*
*/
int
main(int argc, char **argv)
static void
parse_opts(int argc, char **argv)
{
struct timeval tv;
const char *uiargs[16];
const char *argv0 = argc > 0 ? argv[0] : "showtime";
const char *forceview = NULL;
int nuiargs = 0;

gconf.binary = argv[0];

gconf.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 */
Expand Down Expand Up @@ -368,7 +352,7 @@ main(int argc, char **argv)
argc -= 1; argv += 1;
continue;
} else if(!strcmp(argv[0], "--ffmpeglog")) {
ffmpeglog = 1;
gconf.ffmpeglog = 1;
argc -= 1; argv += 1;
continue;
} else if(!strcmp(argv[0], "--syslog")) {
Expand Down Expand Up @@ -411,11 +395,6 @@ main(int argc, char **argv)
gconf.can_open_shell = 1;
argc -= 1; argv += 1;
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], "-p") && argc > 1) {
gconf.devplugin = argv[1];
argc -= 2; argv += 2;
Expand All @@ -429,7 +408,7 @@ main(int argc, char **argv)
argc -= 2; argv += 2;
continue;
} else if (!strcmp(argv[0], "-v") && argc > 1) {
forceview = argv[1];
gconf.initial_view = argv[1];
argc -= 2; argv += 2;
} else if (!strcmp(argv[0], "--cache") && argc > 1) {
mystrset(&gconf.cache_path, argv[1]);
Expand All @@ -444,13 +423,41 @@ main(int argc, char **argv)
break;
}

showtime_init(argc > 0 ? argv[0] : NULL, forceview);
if(argc > 0)
gconf.initial_url = argv[0];
}

TRACE(TRACE_DEBUG, "core", "Starting UI");

/* Initialize user interfaces */
ui_start(nuiargs, uiargs, argv0);
/**
* Showtime main
*/
int
main(int argc, char **argv)
{
struct timeval tv;

gconf.binary = argv[0];

gconf.trace_level = TRACE_INFO;

gettimeofday(&tv, NULL);
srand(tv.tv_usec);

arch_set_default_paths(argc, argv);

parse_opts(argc, argv);

showtime_init();

TRACE(TRACE_DEBUG, "core", "Starting UI");

#if PS3
extern void glw_ps3_start(void);
glw_ps3_start();
#else
extern void glw_x11_start(void);
glw_x11_start();
#endif
showtime_fini();

arch_exit(showtime_retcode);
Expand Down Expand Up @@ -516,8 +523,7 @@ showtime_shutdown(int retcode)

htsmsg_store_flush();

if(ui_shutdown() == -1)
showtime_fini();
event_to_ui(event_create_type(EVENT_STOP_UI));
}


Expand Down
4 changes: 4 additions & 0 deletions src/showtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ typedef struct gconf {
int trace_level;
int trace_to_syslog;
int listen_on_stdin;
int ffmpeglog;

#if ENABLE_SERDEV
int enable_serdev;
Expand All @@ -209,6 +210,9 @@ typedef struct gconf {
const char *plugin_repo;
const char *load_jsfile;

const char *initial_url;
const char *initial_view;

} gconf_t;

extern gconf_t gconf;
Expand Down
Loading

0 comments on commit 9b8de6c

Please sign in to comment.