From kde-commits Thu Mar 24 14:11:15 2011 From: =?utf-8?b?TWloYSDEjGFuxI11bGE=?= Date: Thu, 24 Mar 2011 14:11:15 +0000 To: kde-commits Subject: =?utf-8?q?=5Bknights=5D_src=3A_Add_missing_files_for_D-Bus_inter?= Message-Id: <20110324141115.66F6EA60B4 () git ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=130097590815357 Git commit ddeb018e7d02bc1f6e3bc91c962ddd4da378adc0 by Miha Čančula. Committed on 24/03/2011 at 14:55. Pushed by mihac into branch 'master'. Add missing files for D-Bus interface. A +54 -0 src/externalcontrol.cpp [License: GPL (v3+)] A +52 -0 src/externalcontrol.h [License: GPL (v3+)] A +23 -0 src/org.kde.Knights.xml [License: UNKNOWN] * The files marked with a * at the end have a non valid license. Please read: http://techbase.kde.org/Policies/Licensing_Policy and use the headers which are listed at that page. http://commits.kde.org/knights/ddeb018e7d02bc1f6e3bc91c962ddd4da378adc0 diff --git a/src/externalcontrol.cpp b/src/externalcontrol.cpp new file mode 100644 index 0000000..946e340 --- /dev/null +++ b/src/externalcontrol.cpp @@ -0,0 +1,54 @@ +/* + + Copyright (C) 2011 Miha Čančula + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 . +*/ + + +#include "externalcontrol.h" +#include "gamemanager.h" +#include "knightsadaptor.h" +#include + +#define FORWARD_FUNCTION(name, action) void ExternalControl::name() { Manager::self()->sendOffer(Action##action, NoColor, qrand()); } + +using namespace Knights; + +ExternalControl::ExternalControl(QObject* parent) : QObject(parent) +{ + connect(Manager::self(), SIGNAL(pieceMoved(Move)), SIGNAL(moveMade(QString))); + new KnightsAdaptor(this); + kDebug() << QDBusConnection::sessionBus().registerObject(QLatin1String("/Knights"), this); + kDebug() << QDBusConnection::sessionBus().registerService(QLatin1String("org.kde.Knights")); +} + +ExternalControl::~ExternalControl() +{ + +} + +FORWARD_FUNCTION(adjourn,Adjourn) +FORWARD_FUNCTION(abort,Abort) +FORWARD_FUNCTION(pauseGame,Pause) +FORWARD_FUNCTION(resumeGame,Resume) +FORWARD_FUNCTION(undo,Undo) +FORWARD_FUNCTION(offerDraw,Draw) + +void ExternalControl::movePiece(const QString& move) +{ + Manager::self()->moveByExternalControl(move); +} + + diff --git a/src/externalcontrol.h b/src/externalcontrol.h new file mode 100644 index 0000000..855d7c6 --- /dev/null +++ b/src/externalcontrol.h @@ -0,0 +1,52 @@ +/* + + Copyright (C) 2011 Miha Čančula + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR 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 . +*/ + + +#ifndef KNIGHTS_EXTERNALCONTROL_H +#define KNIGHTS_EXTERNALCONTROL_H + +#include +#include + +namespace Knights { + +class ExternalControl : public QObject +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "org.kde.Knights") + +public: + explicit ExternalControl(QObject* parent = 0); + virtual ~ExternalControl(); + +public Q_SLOTS: + void movePiece(const QString& move); + void pauseGame(); + void resumeGame(); + void undo(); + void offerDraw(); + void adjourn(); + void abort(); + +Q_SIGNALS: + void moveMade(const QString& move); +}; + +} + +#endif // KNIGHTS_EXTERNALCONTROL_H diff --git a/src/org.kde.Knights.xml b/src/org.kde.Knights.xml new file mode 100644 index 0000000..ae7db7b --- /dev/null +++ b/src/org.kde.Knights.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + +