Exemple #1
0
/**
 * Run all pending updates.
 *
 * Returns true on success, false on failure.
 */
bool
Control::run_pending_updates()
{
	/* MPD has new current song */
	if (idle_events & MPD_IDLE_PLAYER) {
		if (!get_current_song()) {
			return false;
		}
		/* MPD_IDLE_PLAYER will be subtracted below */
	}

	/* MPD has new status information */
	if (idle_events & (MPD_IDLE_PLAYER | MPD_IDLE_MIXER | MPD_IDLE_OPTIONS | MPD_IDLE_QUEUE)) {
		if (!get_status()) {
			return false;
		}
		set_update_done(MPD_IDLE_PLAYER);
		set_update_done(MPD_IDLE_MIXER);
		set_update_done(MPD_IDLE_OPTIONS);
		/* MPD_IDLE_QUEUE will be subtracted below */
	}

	/* MPD has updates to queue */
	if (idle_events & MPD_IDLE_QUEUE) {
		if (!update_queue()) {
			return false;
		}
		set_update_done(MPD_IDLE_QUEUE);
	}

	/* MPD has updates to a stored playlist */
	if (idle_events & MPD_IDLE_STORED_PLAYLIST) {
		if (!update_playlist_index()) {
			return false;
		}
		if (!update_playlists()) {
			return false;
		}
		set_update_done(MPD_IDLE_STORED_PLAYLIST);
	}

	/* MPD has new song database */
	if (idle_events & MPD_IDLE_DATABASE) {
		if (!update_library()) {
			return false;
		}
		set_update_done(MPD_IDLE_DATABASE);
	}

	/* Hack to make has_pending_updates() work smoothly without too much
	 * effort. We don't care about the rest of the events, so we just
	 * pretend they never happened. */
	idle_events = 0;

	return true;
}
const char *tizgmusic::get_prev_url ()
{
  current_url_.clear ();
  try
    {
      const char *p_prev_url
          = bp::extract< char const * >(py_gm_proxy_.attr ("prev_url")());
      if (p_prev_url && !get_current_song ())
        {
          current_url_.assign (p_prev_url);
        }
    }
  catch (bp::error_already_set &e)
    {
      PyErr_PrintEx (0);
    }
  catch (...)
    {
    }
  return current_url_.empty () ? NULL : current_url_.c_str ();
}