static gboolean
ol_player_listen_get_music_info (OlMusicInfo *info)
{
  /* ol_log_func (); */
  ol_assert (info != NULL);
  if (connection == NULL || proxy == NULL)
    if (!ol_player_listen_init_dbus ())
    {
      ol_debug ("Initialize dbus proxy failed\n");
      return FALSE;
    }
  gchar *buf;
  enum OlPlayerStatus status = ol_player_listen_get_status ();
  ol_debugf ("  status: %d\n", (int)status);
  if (status == OL_PLAYER_PLAYING)
  {
    ol_music_info_clear (info);
    /* gets the title of current music */
    if (!ol_dbus_get_string (proxy,
                             get_title,
                             &info->title))
    {
      ol_error ("  Get title failed");
    }
    /* gets the artist of current music */
    if (!ol_dbus_get_string (proxy,
                             get_artist,
                             &info->artist))
    {
      ol_error ("  Get artist failed");
    }
    /* gets the album of current music */
    if (!ol_dbus_get_string (proxy,
                             get_album,
                             &info->album))
    {
      ol_error ("  Get album failed");
    }
    /* gets the location of the file */
    if (!ol_dbus_get_string (proxy,
                             get_uri,
                             &info->uri))
    {
      ol_error ("  Get track number failed");
    }
    return TRUE;
  }
  else if (status == OL_PLAYER_STOPPED)
  {
    return TRUE;
  }
  else
  {
    ol_errorf ("  unknown status\n");
    return FALSE;
  }
}
static gboolean
ol_player_exaile02_get_music_info (OlMusicInfo *info)
{
  if (info == NULL)
    return FALSE;
  if (connection == NULL || proxy == NULL)
    if (!ol_player_exaile02_init_dbus ())
      return FALSE;
  /* gets the title of current music */
  if (info->title)
  {
    g_free (info->title);
    info->title = NULL;
  }
  if (!ol_dbus_get_string (proxy,
                           get_title,
                           &info->title))
  {
    return FALSE;
  }
  /* gets the artist of current music */
  if (info->artist)
  {
    g_free (info->artist);
    info->artist = NULL;
  }
  if (!ol_dbus_get_string (proxy,
                           get_artist,
                           &info->artist))
  {
    return FALSE;
  }
  /* gets the album of current music */
  if (info->album)
  {
    g_free (info->album);
    info->album = NULL;
  }
  if (!ol_dbus_get_string (proxy,
                           get_album,
                           &info->album))
  {
    return FALSE;
  }
  ol_debugf ("%s\n"
             "  title:%s\n"
             "  artist:%s\n",
             __FUNCTION__,
             info->title,
             info->artist);
  return TRUE;
}
static gboolean
_get_music_info_and_length (OlMusicInfo *info, int *len)
{
    ol_log_func ();
    if (!_ensure_connection ())
        return FALSE;
    char *infostr = NULL;
    if (!ol_dbus_get_string (proxy, GET_CURRENT_SONG, &infostr))
        return FALSE;
    if (info != NULL)
        ol_music_info_clear (info);
    char *current, *next;
    current = infostr;
    while (current != NULL)
    {
        char *key, *value;
        next = ol_split_a_line (current);
        key = current;
        value = strchr (current, ':');
        *value = '\0';
        value++;
        key = ol_trim_string (key);
        value = ol_trim_string (value);
        if (strcmp (key, PROP_TITLE) == 0)
        {
            if (info != NULL) ol_music_info_set_title (info, value);
        }
        else if (strcmp (key, PROP_ARTIST) == 0)
        {
            if (info != NULL) ol_music_info_set_artist (info, value);
        }
        else if (strcmp (key, PROP_ALBUM) == 0)
        {
            if (info != NULL) ol_music_info_set_album (info, value);
        }
        else if (strcmp (key, PROP_URI) == 0)
        {
            if (info != NULL) ol_music_info_set_uri (info, value);
        }
        else if (strcmp (key, PROP_TRACK_NUMBER) == 0)
        {
            if (info != NULL) ol_music_info_set_track_number (info, atoi (value));
        }
        else if (strcmp (key, PROP_DURATION) == 0)
        {
            if (len != NULL)
                *len = atoi (value) * 1000;
        }
        current = next;
    }
    return TRUE;
}
static gboolean
ol_player_listen_get_activated ()
{
  /* ol_log_func (); */
  if (connection == NULL || proxy == NULL)
    if (!ol_player_listen_init_dbus ())
      return FALSE;
  gchar *buf = NULL;
  if (ol_dbus_get_string (proxy, query, &buf))
  {
    return TRUE;
  }
  else
  {
    return FALSE;
  }
}
static enum OlPlayerStatus
ol_player_exaile02_get_status ()
{
  if (connection == NULL || proxy == NULL)
    if (!ol_player_exaile02_init_dbus ())
      return FALSE;
  char *status = NULL;
  enum OlPlayerStatus ret = OL_PLAYER_UNKNOWN;
  ol_dbus_get_string (proxy, get_status, &status);
  if (status != NULL)
  {
    if (strcmp (status, "playing") == 0)
      ret = OL_PLAYER_PLAYING;
    else if (strcmp (status, "paused") == 0)
      ret = OL_PLAYER_PAUSED;
    else if (strcmp (status, "stoped") == 0)
      ret = OL_PLAYER_STOPPED;
    g_free (status);
  }
  return ret;
}
static gboolean
ol_player_exaile02_get_music_length (int *len)
{
  if (len == NULL)
    return FALSE;
  if (connection == NULL || proxy == NULL)
    if (!ol_player_exaile02_init_dbus ())
      return FALSE;
  gchar *buf = NULL;
  if (!ol_dbus_get_string (proxy, duration, &buf))
  {
    return FALSE;
  }
  int min, sec;
  if (sscanf (buf, "%d:%d", &min, &sec) == 2)
  {
    *len = (min * 60 + sec) * 1000;
  }
  g_free (buf);
  return TRUE;
}