diff --git a/profiles/audio/media.c b/profiles/audio/media.c
index ce674d0..eb5ea81 100644
--- a/profiles/audio/media.c
+++ b/profiles/audio/media.c
uint32_t duration;
uint8_t volume;
GTimer *timer;
+ bool play;
+ bool pause;
+ bool next;
+ bool previous;
+ bool control;
};
static GSList *adapters = NULL;
DBG("");
+ if (!mp->play || !mp->control)
+ return false;
+
return media_player_send(mp, "Play");
}
DBG("");
+ if (!mp->control)
+ return false;
+
return media_player_send(mp, "Stop");
}
DBG("");
+ if (!mp->pause || !mp->control)
+ return false;
+
return media_player_send(mp, "Pause");
}
DBG("");
+ if (!mp->next || !mp->control)
+ return false;
+
return media_player_send(mp, "Next");
}
DBG("");
+ if (!mp->previous || !mp->control)
+ return false;
+
return media_player_send(mp, "Previous");
}
return set_property(mp, "Repeat", value);
}
+static gboolean set_flag(struct media_player *mp, DBusMessageIter *iter,
+ bool *var)
+{
+ dbus_bool_t value;
+
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_BOOLEAN)
+ return FALSE;
+
+ dbus_message_iter_get_basic(iter, &value);
+
+ *var = value;
+
+ return TRUE;
+}
+
static gboolean set_player_property(struct media_player *mp, const char *key,
DBusMessageIter *entry)
{
if (strcasecmp(key, "LoopStatus") == 0)
return set_repeat(mp, &var);
+ if (strcasecmp(key, "CanPlay") == 0)
+ return set_flag(mp, &var, &mp->play);
+
+ if (strcasecmp(key, "CanPause") == 0)
+ return set_flag(mp, &var, &mp->pause);
+
+ if (strcasecmp(key, "CanGoNext") == 0)
+ return set_flag(mp, &var, &mp->next);
+
+ if (strcasecmp(key, "CanGoPrevious") == 0)
+ return set_flag(mp, &var, &mp->previous);
+
+ if (strcasecmp(key, "CanControl") == 0)
+ return set_flag(mp, &var, &mp->control);
+
DBG("%s not supported, ignoring", key);
return TRUE;