[gnome-chess/chess-telepathy-networking-support-664946-communicate: 5/15] Export ChessPlayer objects on DBus
- From: Chandni Verma <vchandni src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-chess/chess-telepathy-networking-support-664946-communicate: 5/15] Export ChessPlayer objects on DBus
- Date: Sun, 16 Jun 2013 15:51:23 +0000 (UTC)
commit 7d05cde33ed3aca2a590ff11aeeda3ca82b5a038
Author: Chandni Verma <chandniverma2112 gmail com>
Date: Sun Dec 23 22:45:27 2012 +0530
Export ChessPlayer objects on DBus
src/Makefile.am | 3 ++-
src/chess-game.vala | 10 ++++++++++
src/gnome-chess-handler-application.vala | 16 ++++++++++++++++
3 files changed, 28 insertions(+), 1 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index a42afe1..8102394 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -94,7 +94,8 @@ gnome_chess_VALAFLAGS = \
--pkg gmodule-2.0 \
--pkg librsvg-2.0 \
--pkg posix \
- --pkg sqlite3
+ --pkg sqlite3 \
+ --pkg gio-2.0
if ENABLE_NETWORKING
gnome_chess_CFLAGS += $(FOLKS_CFLAGS)
diff --git a/src/chess-game.vala b/src/chess-game.vala
index 9946acc..4c307be 100644
--- a/src/chess-game.vala
+++ b/src/chess-game.vala
@@ -4,25 +4,34 @@ public enum Color
BLACK
}
+[DBus (name = "org.gnome.Chess.ChessPlayer")]
public class ChessPlayer : Object
{
+ [DBus (visible = false)]
public Color color;
+ [DBus (visible = false)]
public signal void start_turn ();
public signal bool do_move (string move, bool apply);
+ [DBus (visible = false)]
public signal void do_undo ();
+ [DBus (visible = false)]
public signal bool do_resign ();
+ [DBus (visible = false)]
public signal bool do_claim_draw ();
+ [DBus (visible = false)]
public ChessPlayer (Color color)
{
this.color = color;
}
+ [DBus (visible = false)]
public bool move (string move, bool apply = true)
{
return do_move (move, apply);
}
+ [DBus (visible = false)]
public bool move_with_coords (int r0, int f0, int r1, int f1,
bool apply = true, PieceType promotion_type = PieceType.QUEEN)
{
@@ -49,6 +58,7 @@ public class ChessPlayer : Object
return do_move (move, apply);
}
+ [DBus (visible = false)]
public void undo ()
{
do_undo ();
diff --git a/src/gnome-chess-handler-application.vala b/src/gnome-chess-handler-application.vala
index 7790ecd..e8a58d8 100644
--- a/src/gnome-chess-handler-application.vala
+++ b/src/gnome-chess-handler-application.vala
@@ -672,6 +672,22 @@ public class HandlerApplication : Application
Gtk.TreeIter channel_iter)
{
debug ("Registering objects over dbus connection");
+
+ ChessGame game;
+ channels get (channel_iter, ChannelsColumn.CHESS_GAME, out game);
+
+ Variant tube_params = tube.dup_parameters_vardict ();
+ bool play_as_white = (tube_params.lookup_value ("offerer-white", VariantType.BOOLEAN)).get_boolean
();
+ ChessPlayer my_player;
+ my_player = play_as_white ? game.white : game.black;
+
+ try {
+ connection.register_object<ChessPlayer>
("/org/freedesktop/Telepathy/Client/Gnome/Chess/ChessPlayer", my_player);
+ debug ("ChessPlayer registered successfully");
+ } catch (IOError e) {
+ debug ("Could not register ChessPlayer object");
+ }
+
}
private void offer_tube (TelepathyGLib.DBusTubeChannel tube,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]