Commit a92f22bb authored by Gaël de Chalendar's avatar Gaël de Chalendar
Browse files

First working draft of KsirK able to use Jabber to propose/find network games....

First working draft of KsirK able to use Jabber to propose/find network games. It uses a 'natural language' protocol to indicate/read in a standard MUC room what are the running games and where to connect to them

svn path=/branches/work/ksirk.jabber/; revision=857189
parent aefeeb78
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt (revision 855877)
+++ CMakeLists.txt (working copy)
@@ -1,3 +1,4 @@
+add_definitions(-DQT3_SUPPORT -DQT3_SUPPORT_WARNINGS)
#add_subdirectory( cutestuff )
#add_subdirectory( iris )
@@ -4,6 +5,9 @@
FIND_PACKAGE(ZLIB REQUIRED)
+FIND_PACKAGE(QCA2 REQUIRED)
+macro_log_feature(QCA2_FOUND "QCA2" "Qt Cryptographic Architecture" "http://delta.affinix.com/qca" FALSE "2.0.0" "Needed to build Kopete's GroupWise and Jabberprotocols.")
+
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/cutestuff/
${CMAKE_CURRENT_SOURCE_DIR}/cutestuff/legacy/
@@ -66,7 +70,7 @@
${iris_SRCS}
)
-kde4_moc_headers(iris_kopete
+kde4_moc_headers(iris_ksirk
# cutestuff/legacy/ndns.h
# cutestuff/legacy/safedelete.h
# cutestuff/legacy/servsock.h
@@ -98,23 +102,23 @@
# iris/xmpp-im/xmpp_discoinfotask.h
)
-kde4_add_library(iris_kopete SHARED ${libiris_SRCS})
+kde4_add_library(iris_ksirk SHARED ${libiris_SRCS})
-set(iris_kopete_libs ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QT3SUPPORT_LIBRARY} ${QT_QTNETWORK_LIBRARY} ${QT_QTXML_LIBRARY}
- ${IDN_LIBRARY} ${QCA2_LIBRARIES} ${ZLIB_LIBRARIES})
+set(iris_ksirk_libs ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QT3SUPPORT_LIBRARY} ${QT_QTNETWORK_LIBRARY} ${QT_QTXML_LIBRARY}
+ ${IDN_LIBRARY} ${QCA2_LIBRARIES} ${ZLIB_LIBRARIES} -lidn)
if(WIN32)
- set(iris_kopete_libs ${iris_kopete_libs} ws2_32)
+ set(iris_ksirk_libs ${iris_ksirk_libs} ws2_32)
endif(WIN32)
if(HAVE_NSL_LIBRARY)
# This is probably Solaris, and libiris needs to link
# to libnsl for gethostbyname
- set(iris_kopete_libs ${iris_kopete_libs} nsl)
+ set(iris_ksirk_libs ${iris_ksirk_libs} nsl)
endif(HAVE_NSL_LIBRARY)
-target_link_libraries(iris_kopete ${iris_kopete_libs})
+target_link_libraries(iris_ksirk ${iris_ksirk_libs})
-set_target_properties(iris_kopete PROPERTIES VERSION 1.0.0 SOVERSION 1 )
-install(TARGETS iris_kopete ${INSTALL_TARGETS_DEFAULT_ARGS})
+set_target_properties(iris_ksirk PROPERTIES VERSION 1.0.0 SOVERSION 1 )
+install(TARGETS iris_ksirk ${INSTALL_TARGETS_DEFAULT_ARGS})
########### install files ###############
add_definitions(-DQT3_SUPPORT -DQT3_SUPPORT_WARNINGS)
add_subdirectory( skins )
add_subdirectory( libiris )
FIND_PACKAGE(QCA2 REQUIRED)
macro_log_feature(QCA2_FOUND "QCA2" "Qt Cryptographic Architecture" "http://delta.affinix.com/qca" FALSE "2.0.0" "Needed to build Kopete's GroupWise and Jabberprotocols.")
include_directories(
${CMAKE_BINARY_DIR}/ksirk
......@@ -10,7 +16,18 @@ include_directories(
./Sprites
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
${CMAKE_CURRENT_SOURCE_DIR}/libiris/iris/include/
${CMAKE_CURRENT_SOURCE_DIR}/libiris/iris/jabber/
${CMAKE_CURRENT_SOURCE_DIR}/libiris/iris/xmpp-core/
${CMAKE_CURRENT_SOURCE_DIR}/libiris/iris/xmpp-im/
${CMAKE_CURRENT_SOURCE_DIR}/libiris/cutestuff/util/
${CMAKE_CURRENT_SOURCE_DIR}/libiris/cutestuff/network/
${CMAKE_CURRENT_SOURCE_DIR}/libiris/cutestuff/
${CMAKE_CURRENT_SOURCE_DIR}/libiris/iris/
${QCA2_INCLUDE_DIR}
)
link_directories( ${CMAKE_CURRENT_BINARY_DIR}/libiris/ )
########### next target ###############
......@@ -47,6 +64,7 @@ set(ksirk_SRCS
Dialogs/newGameDialogImpl.cpp
Dialogs/kwaitedplayersetupdialog.cpp
Dialogs/restartOrExitDialogImpl.cpp
Dialogs/joingame.cpp
main.cpp
decoratedgameframe.cpp
gestionSprites.cpp
......@@ -57,6 +75,13 @@ set(ksirk_SRCS
fightArena.cpp
mainMenu.cpp
krightdialog.cpp
# Jabber/jabberaccount.cpp
Jabber/jabberbytestream.cpp
Jabber/jabberclient.cpp
Jabber/jabberconnector.cpp
Jabber/privacylist.cpp
Jabber/privacylistitem.cpp
Jabber/privacymanager.cpp
)
set(ksirk_UI
......@@ -64,6 +89,8 @@ set(ksirk_UI
Dialogs/newGameDialog.ui
Dialogs/qwaitedplayersetupdialog.ui
Dialogs/restartOrExitDialog.ui
Dialogs/jabberconnect.ui
Dialogs/joingame.ui
preferences.ui
)
......@@ -84,6 +111,7 @@ target_link_libraries(ksirk
kdegames
${CRYPT_LIBS}
${KDEGAMES_LIBRARY}
iris_ksirk
)
install( TARGETS ksirk ${INSTALL_TARGETS_DEFAULT_ARGS})
......
/* This file is part of KsirK.
Copyright (C) 2008 Gael de Chalendar <kleag@free.fr>
KsirK 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, version 2.
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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA
*/
#ifndef JABBERCONNECTDIALOG_H
#define JABBERCONNECTDIALOG_H
#include "ui_jabberconnect.h"
#include <QDialog>
class JabberConnectDialog : public QDialog, public Ui::JabberConnectDialog
{
public:
JabberConnectDialog(QWidget* parent) : QDialog(parent)
{
setupUi(this);
}
};
#endif
<ui version="4.0" >
<class>JabberConnectDialog</class>
<widget class="QDialog" name="JabberConnectDialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>284</height>
</rect>
</property>
<property name="windowTitle" >
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<layout class="QFormLayout" name="formLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Jabber ID:</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="KLineEdit" name="jabberid" />
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Password:</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="KLineEdit" name="password" >
<property name="text" >
<string/>
</property>
<property name="echoMode" >
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout_2" >
<item row="0" column="0" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>Room JID:</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="KLineEdit" name="roomjid" />
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_4" >
<property name="text" >
<string>Nickname:</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="KLineEdit" name="nickname" />
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>Room Password:</string>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="KLineEdit" name="roompassword" >
<property name="echoMode" >
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KLineEdit</class>
<extends>QLineEdit</extends>
<header>klineedit.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>JabberConnectDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel" >
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>JabberConnectDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel" >
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
/***************************************************************************
kdialogsetupjoueur.cpp - description
-------------------
begin : Thu Jul 19 2001
copyright : (C) 2001 by Gaël de Chalendar
email : Gael.de.Chalendar@free.fr
***************************************************************************/
/***************************************************************************
* *
* 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 2 of the License, or *
* (at your option) any later version. *
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
***************************************************************************/
#define KDE_NO_COMPAT
#include "joingame.h"
#include "GameLogic/gameautomaton.h"
#include "GameLogic/player.h"
#include "GameLogic/nationality.h"
#include "GameLogic/onu.h"
#include "Sprites/skinSpritesData.h"
#include "Sprites/flagsprite.h"
#include <QString>
#include <QLabel>
#include <QLineEdit>
#include <QCheckBox>
#include <QComboBox>
#include <QPixmap>
#include <QPainter>
#include <klocale.h>
#include <kdebug.h>
#include <kstandarddirs.h>
#include <kpassworddialog.h>
#include <kmessagebox.h>
#define _XOPEN_SOURCE_
// #include <unistd.h>
namespace Ksirk
{
JoinGameDialog::JoinGameDialog(GameLogic::GameAutomaton* automaton,
QString& host,
int& port,
QWidget *parent) :
QDialog(parent), Ui::JoinGameDialog(),
m_automaton(automaton), m_host(host),
m_port(port)
{
kDebug();
setupUi(this);
hostEdit-> setText(m_host);
portEdit-> setText(QString::number(m_port));
QObject::connect(m_automaton, SIGNAL(clicked()), this, SLOT(slotOK()) );
connect(automaton,SIGNAL(newJabberGame(const QString&, const QString&, int, const QString&)), this,SLOT(slotNewJabberGame(const QString&, const QString&, int, const QString&)));
connect(jabberTable, SIGNAL(cellClicked(int,int)), this, SLOT(slotCellClicked(int,int)));
hostEdit->setFocus();
QStringList headers;
headers.push_back("Nickname");
headers.push_back("Host");
headers.push_back("Port");
headers.push_back("Skin");
jabberTable->setHorizontalHeaderLabels(headers);
}
JoinGameDialog::~JoinGameDialog(){
hide();
}
void JoinGameDialog::slotNewJabberGame(const QString& nick,
const QString& host,
int port,
const QString& skin
)
{
kDebug() << nick << host << port << skin;
jabberTable->setSortingEnabled(false);
jabberTable->setRowCount(jabberTable->rowCount()+1);
QTableWidgetItem *newItem = new QTableWidgetItem(nick);
jabberTable->setItem(jabberTable->rowCount()-1,0,newItem);
newItem = new QTableWidgetItem(host);
jabberTable->setItem(jabberTable->rowCount()-1,1,newItem);
newItem = new QTableWidgetItem(QString::number(port));
jabberTable->setItem(jabberTable->rowCount()-1,2,newItem);
newItem = new QTableWidgetItem(skin);
jabberTable->setItem(jabberTable->rowCount()-1,3,newItem);
jabberTable->setSortingEnabled(false);
}
void JoinGameDialog::accept()
{
kDebug();
m_host = hostEdit->text();
m_port = hostEdit->text().toInt();
QDialog::accept();
}
void JoinGameDialog::reject() {
// kDebug() << "I not allow to close the dialog!" << endl;
QDialog::reject();
}
void JoinGameDialog::slotCellClicked(int row, int column)
{
Q_UNUSED(column);
kDebug() << row;
m_host = jabberTable->item(row,1)->text();
m_port = jabberTable->item(row,2)->text().toInt();
kDebug() << m_host << m_port;
hostEdit->setText(m_host);
portEdit->setText(QString::number(m_port));
}
}
#include "joingame.moc"
/***************************************************************************
kdialogsetupjoueur.h - description
-------------------
begin : Thu Jul 19 2001
copyright : (C) 2001 by Gaël de Chalendar
email : Gael.de.Chalendar@free.fr
***************************************************************************/
/***************************************************************************
* *
* 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 2 of the License, or *
* (at your option) any later version. *
* *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
***************************************************************************/
#define KDE_NO_COMPAT
#ifndef JOINGAMEDIALOG_H
#define JOINGAMEDIALOG_H
#include "ui_joingame.h"
#include <QDialog>
#include <QMap>
class KPlayer;
namespace Ksirk
{
namespace GameLogic
{
class ONU;
class GameAutomaton;
}
/**
* This is the implementation of the player configuration dialog made with
* QT Designer
* @author Gael de Chalendar
*/
class JoinGameDialog : public QDialog, public Ui::JoinGameDialog
{
Q_OBJECT
public:
JoinGameDialog(GameLogic::GameAutomaton* automaton,
QString& host,
int& port,
QWidget *parent=0);
virtual ~JoinGameDialog();
protected:
void accept();
void reject();
public Q_SLOTS:
void slotNewJabberGame(const QString& nick,
const QString& host,
int port,
const QString& skin
);
private Q_SLOTS:
void slotCellClicked(int row, int column);
private:
GameLogic::GameAutomaton* m_automaton;
QString &m_host;
int& m_port;
};
}
#endif // KPLAYERSETUPDIALOG_H
<ui version="4.0" >
<class>JoinGameDialog</class>
<widget class="QDialog" name="JoinGameDialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>525</width>
<height>372</height>
</rect>
</property>
<property name="windowTitle" >
<string>Join network game configuration</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<widget class="QGroupBox" name="groupBox" >
<property name="title" >
<string>Network configuration</string>
</property>
<layout class="QFormLayout" name="formLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Host:</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="KLineEdit" name="hostEdit" />
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Port:</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="KLineEdit" name="portEdit" />
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2" >
<property name="title" >
<string>Jabber Games</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" >
<item>
<widget class="QTableWidget" name="jabberTable" >
<property name="selectionMode" >
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior" >
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="rowCount" >
<number>0</number>
</property>
<property name="columnCount" >
<number>4</number>
</property>
<column/>
<column/>
<column/>
<column/>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KLineEdit</class>
<extends>QLineEdit</extends>
<header>klineedit.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>JoinGameDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel" >
<x>157</x>
<y>274</y>
</hint>
</hints>