aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-08-12 20:36:14 +0100
committerConor Curran <conor.curran@canonical.com>2010-08-12 20:36:14 +0100
commit30a697a1027229c23857ced856c0fdbd15b40d14 (patch)
tree7d2a868799eb2457469e61d44cc6834774a74252
parent72ffb2c3c096cf0e7ece12c93bfeff5b651fed13 (diff)
downloadayatana-indicator-sound-30a697a1027229c23857ced856c0fdbd15b40d14.tar.gz
ayatana-indicator-sound-30a697a1027229c23857ced856c0fdbd15b40d14.tar.bz2
ayatana-indicator-sound-30a697a1027229c23857ced856c0fdbd15b40d14.zip
moving mpris2 to gdbus, the horror
-rw-r--r--configure.ac4
-rw-r--r--src/Makefile.am4
-rw-r--r--src/mpris-bridge.vala13
-rw-r--r--src/mpris2-controller.vala105
-rw-r--r--src/player-controller.vala3
5 files changed, 64 insertions, 65 deletions
diff --git a/configure.ac b/configure.ac
index 7de494a..8610d1e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -35,8 +35,9 @@ PULSE_AUDIO_REQUIRED_VERSION=0.9.19
INDICATOR_DISPLAY_OBJECTS=0.1.11
INDICATE_REQUIRED_VERSION=0.4.1
DBUSMENUGLIB_REQUIRED_VERSION=0.3.1
+GIO_2_0_REQUIRED_VERSION=2.25.13
-PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION
+PKG_CHECK_MODULES(APPLET,gtk+-2.0 >= $GTK_REQUIRED_VERSION
indicator >= $INDICATOR_REQUIRED_VERSION
dbusmenu-gtk >= $DBUSMENUGTK_REQUIRED_VERSION
libido-0.1 >= $INDICATOR_DISPLAY_OBJECTS)
@@ -52,6 +53,7 @@ AC_SUBST(PULSEAUDIO_LIBS)
PKG_CHECK_MODULES(SOUNDSERVICE, dbusmenu-glib >= $DBUSMENUGLIB_REQUIRED_VERSION
indicator >= $INDICATOR_REQUIRED_VERSION
indicate >= $INDICATE_REQUIRED_VERSION
+ gio-2.0 >= $GIO_2_0_REQUIRED_VERSION
gee-1.0)
AC_SUBST(SOUNDSERVICE_CFLAGS)
diff --git a/src/Makefile.am b/src/Makefile.am
index 5d073c7..b55b5f9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -83,7 +83,9 @@ music_bridge_VALAFLAGS = \
--pkg Dbusmenu-Glib-0.2 \
--pkg common-defs \
--pkg dbus-glib-1 \
- --pkg gio-unix-2.0
+ --pkg gio-2.0 \
+ --pkg gio-unix-2.0
+
$(MAINTAINER_VALAFLAGS)
music_bridge_APIFILES = \
diff --git a/src/mpris-bridge.vala b/src/mpris-bridge.vala
index 682069c..bb02550 100644
--- a/src/mpris-bridge.vala
+++ b/src/mpris-bridge.vala
@@ -10,17 +10,16 @@ public class MprisBridge : GLib.Object
public MprisBridge(PlayerController ctrl)
{
- this.mpris2_controller == new Mpris2Controller(ctrl);
+ this.mpris2_controller = new Mpris2Controller(ctrl);
if(this.mpris2_controller.was_successfull() == true){
- mode_in_use == mode.MPRIS_2;
- this.mpris1_controller == null;
+ this.mode_in_use = mode.MPRIS_2;
+ this.mpris1_controller = null;
this.mpris2_controller.initial_update();
}
else{
- delete this.mpris2_controller;
- this.mpris2_controller == null;
- mode_in_use == mode.MPRIS_1;
- this.mpris1_controller = new Mpris1Controller(ctrl);
+ this.mpris2_controller = null;
+ this.mode_in_use = mode.MPRIS_1;
+ this.mpris1_controller = new MprisController(ctrl);
}
}
diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala
index 6c1b71a..e8783e7 100644
--- a/src/mpris2-controller.vala
+++ b/src/mpris2-controller.vala
@@ -17,32 +17,39 @@ PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-using Gee;
-[DBus (name = "org.mpris.MediaPlayer.Player")]
+using GLib;
+using Bus;
+
+[DBus (name = Mpris2Controller.root_interface)]
+public interface MprisRoot : Object {
+ // properties
+ public abstract bool HasTracklist{owned get; set;}
+ public abstract bool CanQuit{owned get; set;}
+ public abstract bool CanRaise{owned get; set;}
+ public abstract string Identity{owned get; set;}
+ public abstract string DesktopEntry{owned get; set;}
+ // methods
+ public abstract void Quit() throws IOError;
+ public abstract void Raise() throws IOError;
+}
+
+[DBus (name = Mpris2Controller.root_interface.concat(".Player"))]
public interface MprisPlayer : Object {
- public struct Status {
- public int32 Playback_State;
- public double Playback_Rate;
- public bool Repeat_State;
- public bool Shuffle_State;
- public bool Endless_State;
- }
-
- public abstract HashTable<string, Value?> Metadata{owned get;}
- public abstract double Volume{get;}
- public abstract int32 Capabilities{get;}
- public abstract int32 Position{get;}
+ public abstract HashTable<string, Value?> Metadata{owned get; set;}
+ public abstract double Volume{owned get; set;}
+ public abstract int32 Capabilities{owned get; set;}
+ public abstract int32 Position{owned get; set;}
- public abstract void SetPosition(string prop, int32 pos) throws DBus.Error;
- public abstract void PlayPause() throws DBus.Error;
- public abstract void Pause() throws DBus.Error;
- public abstract void Next() throws DBus.Error;
- public abstract void Previous() throws DBus.Error;
-
- public abstract signal void StatusChanged(Status update);
- public abstract signal void TrackChanged(HashTable<string,Value?> Metadata);
+ public abstract void SetPosition(string prop, int32 pos) throws IOError;
+ public abstract void PlayPause() throws IOError;
+ public abstract void Pause() throws IOError;
+ public abstract void Next() throws IOError;
+ public abstract void Previous() throws IOError;
+
+ //public abstract signal void StatusChanged(Status update);
+ //public abstract signal void TrackChanged(HashTable<string,Value?> Metadata);
}
/*
@@ -51,43 +58,29 @@ public interface MprisPlayer : Object {
*/
public class Mpris2Controller : GLib.Object
{
- private DBus.Connection connection;
- public dynamic DBus.Object mpris2_root {get; construct;}
+ public static const string root_interface = "org.mpris.MediaPlayer2" ;
+ public MprisRoot mpris2_root {get; construct;}
public MprisPlayer mpris2_player {get; construct;}
public PlayerController owner {get; construct;}
public Mpris2Controller(PlayerController ctrl)
{
Object(owner: ctrl);
- this.mpris2_root = null;
- this.mpris2_player = null;
}
construct{
- try {
- debug("Going to try and create an mpris 2 controller");
- this.connection = DBus.Bus.get (DBus.BusType.SESSION);
- } catch (Error e) {
- error("Problems connecting to the session bus - %s", e.message);
- }
-
- try {
- this.mpris2_root = this.connection.get_object ("org.mpris.mediaplayers.".concat(this.owner.name.down()),
- "/org/mpris/MediaPlayer",
- "org.mpris.MediaPlayer");
- this.mpris2_player = (MprisPlayer)this.connection.get_object ("org.mpris.mediaplayers.".concat(this.owner.name.down()) ,
- "/org/mpris/MediaPlayer/Player",
- "org.mpris.MediaPlayer.Player");
- }
- catch(Error e){
- error("Problems connecting to
- }
- }
+ this.mpris2_root = Bus.get_proxy_sync (BusType.SESSION,
+ root_interface.concat(".").concat(this.owner.name.down()),
+ "/org/mpris/MediaPlayer2");
+
+ this.mpris2_player = Bus.get_proxy_sync (BusType.SESSION,
+ root_interface.concat(".").concat(this.owner.name.down()),
+ "/org/mpris/MediaPlayer2/Player");
+ }
+
public bool was_successfull(){
- if(this.mpris2_root == null ||
- this.mpris2_player == null)
- {
+ if(this.mpris2_root == null ||this.mpris2_player == null){
return false;
}
return true;
@@ -95,7 +88,7 @@ public class Mpris2Controller : GLib.Object
public void initial_update()
{
- this.mpris2_player.TrackChanged += onTrackChanged;
+ /*this.mpris2_player.TrackChanged += onTrackChanged;
this.mpris2_player.StatusChanged += onStatusChanged;
bool r = (bool)this.mpris2_player.Status.Shuffle_State;
@@ -111,11 +104,12 @@ public class Mpris2Controller : GLib.Object
ScrubMenuitem.attributes_format());
ScrubMenuitem scrub = this.owner.custom_items[PlayerController.widget_order.SCRUB] as ScrubMenuitem;
scrub.update_position(this.mpris2_player.Position);
-
+ */
}
public void transport_event(TransportMenuitem.action command)
{
+ /*
debug("transport_event input = %i", (int)command);
if(command == TransportMenuitem.action.PLAY_PAUSE){
debug("transport_event PLAY_PAUSE");
@@ -126,11 +120,13 @@ public class Mpris2Controller : GLib.Object
}
else if(command == TransportMenuitem.action.NEXT){
this.mpris2_player.Next();
- }
+ }
+ */
}
public void set_position(double position)
- {
+ {
+ /*
debug("Set position with pos (0-100) %f", position);
HashTable<string, Value?> data = this.mpris2_player.Metadata;
Value? time_value = data.lookup("time");
@@ -156,6 +152,7 @@ public class Mpris2Controller : GLib.Object
//this.mpris2_player.SetPosition((int32)(new_time_position));
ScrubMenuitem scrub = this.owner.custom_items[PlayerController.widget_order.SCRUB] as ScrubMenuitem;
scrub.update_position(this.mpris2_player.Position);
+ */
}
public bool connected()
@@ -163,7 +160,7 @@ public class Mpris2Controller : GLib.Object
return (this.mpris2_player != null);
}
- private void onStatusChanged(MprisPlayer.Status st)
+ /*private void onStatusChanged(MprisPlayer.Status st)
{
debug("onStatusChange - play state %i", st.Playback_State);
HashTable<string, Value?> ht = new HashTable<string, Value?>(str_hash, str_equal);
@@ -191,7 +188,7 @@ public class Mpris2Controller : GLib.Object
ScrubMenuitem.attributes_format());
ScrubMenuitem scrub = this.owner.custom_items[PlayerController.widget_order.SCRUB] as ScrubMenuitem;
scrub.update_position(this.mpris2_player.Position);
- }
+ }*/
}
diff --git a/src/player-controller.vala b/src/player-controller.vala
index bccf586..79b63d7 100644
--- a/src/player-controller.vala
+++ b/src/player-controller.vala
@@ -53,7 +53,6 @@ public class PlayerController : GLib.Object
public PlayerController(Dbusmenu.Menuitem root, string client_name, int offset, state initial_state)
{
- this.mpris2 = false;
this.root_menu = root;
this.name = format_client_name(client_name.strip());
this.custom_items = new ArrayList<PlayerItem>();
@@ -100,7 +99,7 @@ public class PlayerController : GLib.Object
debug("establish_mpris_connection - Not ready to connect");
return;
}
- this.mpris_bridge = new MprisBridge();
+ this.mpris_bridge = new MprisBridge(this);
this.determine_state();
}