Ejemplo n.º 1
0
static void
nav_reload_current(navigator_t *nav)
{
  nav_page_t *np;

  if((np = nav->nav_page_current) == NULL)
    return;

  plugins_reload_dev_plugin();

  TRACE(TRACE_INFO, "navigator", "Reloading %s", np->np_url);

  prop_unsubscribe(np->np_close_sub);
  prop_unsubscribe(np->np_direct_close_sub);
  prop_destroy(np->np_prop_root);
  nav_page_setup_prop(nav, np, NULL);

  if(prop_set_parent(np->np_prop_root, nav->nav_prop_pages)) {
    /* nav->nav_prop_pages is a zombie, this is an error */
    abort();
  }

  nav_select(nav, np, NULL);
    
  if(backend_open(np->np_prop_root, np->np_url))
    nav_open_errorf(np->np_prop_root, _("No handler for URL"));
}
Ejemplo n.º 2
0
static void
nav_open0(navigator_t *nav, const char *url, const char *view, prop_t *origin)
{
  nav_page_t *np = calloc(1, sizeof(nav_page_t));
  np->np_nav = nav;
  np->np_url = url ? strdup(url) : NULL;
  np->np_direct_close = 0;
  TAILQ_INSERT_TAIL(&nav->nav_pages, np, np_global_link);

  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);

  if(url != NULL)
    prop_set_string(prop_create(np->np_prop_root, "url"), url);

  np->np_url_sub = 
    prop_subscribe(PROP_SUB_NO_INITIAL_UPDATE,
		   PROP_TAG_ROOT, prop_create(np->np_prop_root, "url"),
		   PROP_TAG_CALLBACK_STRING, nav_page_url_set, np,
		   PROP_TAG_COURIER, nav->nav_pc,
		   NULL);

  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);
  
  TRACE(TRACE_INFO, "navigator", "Opening %s", url);
  if(backend_open(np->np_prop_root, url))
    nav_open_errorf(np->np_prop_root, url, "No handler for URL");

  nav_insert_page(nav, np, origin);
}
Ejemplo n.º 3
0
static void
nav_open0(navigator_t *nav, const char *url, const char *view, prop_t *origin)
{
  nav_page_t *np = calloc(1, sizeof(nav_page_t));

  TRACE(TRACE_INFO, "navigator", "Opening %s", url);

  np->np_nav = nav;
  np->np_url = strdup(url);
  np->np_direct_close = 0;
  TAILQ_INSERT_TAIL(&nav->nav_pages, np, np_global_link);

  nav_page_setup_prop(nav, np, view);

  nav_insert_page(nav, np, origin);
  if(backend_open(np->np_prop_root, url))
    nav_open_errorf(np->np_prop_root, _("No handler for URL"));
}
Ejemplo n.º 4
0
static void
file_open_dir(prop_t *page, const char *url, time_t mtime)
{
  fa_handle_t *ref = fa_reference(url);
  metadata_t *md = fa_probe_dir(url);

  switch(md->md_contenttype) {
  case CONTENT_DVD:
    backend_open_video(page, url, 0);
    break;
    
  case CONTENT_DIR:
  case CONTENT_ARCHIVE:
    file_open_browse(page, url, mtime);
    break;

  default:
    nav_open_errorf(page, _("Can't handle content type %d"),
		    md->md_contenttype);
    break;
  }
  metadata_destroy(md);
  fa_unreference(ref);
}
Ejemplo n.º 5
0
static void
file_open_file(prop_t *page, const char *url, fa_stat_t *fs)
{
  char errbuf[200];
  metadata_t *md;

  void *db = metadb_get();
  md = metadb_metadata_get(db, url, fs->fs_mtime);
  metadb_close(db);

  if(md == NULL)
    md = fa_probe_metadata(url, errbuf, sizeof(errbuf), NULL);

  if(md == NULL) {
    nav_open_errorf(page, _("Unable to open file: %s"), errbuf);
    return;
  }

  if(md->md_redirect != NULL)
    url = md->md_redirect;

  prop_t *meta = prop_create_root("metadata");

  metadata_to_proptree(md, meta, 0);

  switch(md->md_contenttype) {
  case CONTENT_ARCHIVE:
  case CONTENT_ALBUM:
    file_open_browse(page, url, fs->fs_mtime);
    break;

  case CONTENT_AUDIO:
    if(!file_open_audio(page, url)) {
      break;
    }
    playqueue_play(url, meta, 0);
    playqueue_open(page);
    meta = NULL;
    break;

  case CONTENT_VIDEO:
  case CONTENT_DVD:
    backend_open_video(page, url, 0);
    break;

  case CONTENT_IMAGE:
    file_open_image(page, meta);
    meta = NULL;
    break;

  case CONTENT_PLUGIN:
    plugin_open_file(page, url);
    break;

  default:
    nav_open_errorf(page, _("Can't handle content type %d"),
		    md->md_contenttype);
    break;
  }
  prop_destroy(meta);
  metadata_destroy(md);
}