--Boundary-00=_nBfoJnO3KVRm75E Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, (no need to cc:, I am subscribed) I am looking for some cooperation with regard to network-enabled KDE games. Would you like to see open or ongoing games for KBattleship, LSkat, KFourInLine, KSirk and others listed in a network view in Konqueror, Dolphin or a Plasma Folderview? Also be able to connect to them by clicking on them and have the corresponding game program automatically started and connected to the clicked game? Then please read on :) Currently I work on a kioslave* which lists the computers/devices and services in the network, based on DNS-SD and hopefully soon other service discovery services (build instructions below). * http://frinring.wordpress.com/2009/02/13/browse-your-network/ One example used is KBattleship**. ATM more functionailty is added to the kioslave, like connecting to the service clicked. This works nice for all protocols KDE has kioslaves for, e.g. web browsing, filesystem listing, ssh, even vnc. But it does not yet work for the KDE games. ** http://frinring.files.wordpress.com/2009/02/network-ioslave.png There are two blockers: A) None of the network-enabled KDE games has support to connect to a remote server by commandline arguments (unless I missed it). B) KIO looks for a kioslave which supports the protocol type of the link, even if the protocol name is just passed as part of a link/url in a commandline. So "kbattleship:/" does not (yet) work. For A) I quickhacked a little patch for KBattleship (see attachment) which adds the option to start the program up with the dialog to connect to a server and having it filled with the data from the link. I would be glad if it could be reviewed, improved and applied, so I have a showcase. I would be even more happy if there could be similar patches to LSkat, KFourInLine and KSirk :) To deal with B) as a temporary workaround I tricked a little by pretending that kbattleships uses http, while the code in the patch simply ignores the given protocol name. Will have to talk to the kio people how to deal with this in general. But I need running and killer usecases, that is why I am here first :) The following should do it for building the network: kioslave. You can ignore the SLP dependencies, that backend is unused currently: svn co yourprotocol://svn.kde.org/home/kde/trunk/playground/network/networkkio mkdir build cd build cmake ../networkkio make make install I hope you find this useful and we can do some work together here :) So one day you and I can browse the network and e.g. join a game by simply clicking on it. Cheers Friedrich -- Okteta - KDE 4 Hex Editor - http://utils.kde.org/projects/okteta --Boundary-00=_nBfoJnO3KVRm75E Content-Type: text/x-diff; charset="iso 8859-15"; name="connectKBattleshipToNetworkGameFromCommandLine.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="connectKBattleshipToNetworkGameFromCommandLine.patch" Index: kdegames/kbattleship/src/playfield.h =================================================================== --- kdegames/kbattleship/src/playfield.h (Revision 930293) +++ kdegames/kbattleship/src/playfield.h (Arbeitskopie) @@ -41,6 +41,7 @@ PlayField(QWidget* parent, QStatusBar*); ~PlayField(); void runGGZ(int fd); + void createClient(const KUrl& url); public slots: void highscores(); void gameOver(Sea::Player winner); Index: kdegames/kbattleship/src/playfield.cpp =================================================================== --- kdegames/kbattleship/src/playfield.cpp (Revision 930293) +++ kdegames/kbattleship/src/playfield.cpp (Arbeitskopie) @@ -340,6 +340,11 @@ createAuxMenu()->createClient(); } +void PlayField::createClient(const KUrl& url) +{ + createAuxMenu()->createClient(url); +} + void PlayField::toggleEndOfGameMessage(bool show) { m_show_endofgame_message = show; Index: kdegames/kbattleship/src/mainwindow.cpp =================================================================== --- kdegames/kbattleship/src/mainwindow.cpp (Revision 930293) +++ kdegames/kbattleship/src/mainwindow.cpp (Arbeitskopie) @@ -27,7 +27,7 @@ #include "settings.h" #include "simplemenu.h" -MainWindow::MainWindow() +MainWindow::MainWindow(const KUrl& url) : m_mod(0), m_fd(-1), m_ggzsetup(false) { m_main = new PlayField(this, statusBar()); @@ -58,6 +58,9 @@ KGameDifficulty::addStandardLevel(KGameDifficulty::Medium); KGameDifficulty::addStandardLevel(KGameDifficulty::Hard); KGameDifficulty::setLevel(KGameDifficulty::standardLevel(Settings::difficulty())); + + if(! url.isEmpty() ) + m_main->createClient(url); } void MainWindow::setupActions() Index: kdegames/kbattleship/src/networkdialog.h =================================================================== --- kdegames/kbattleship/src/networkdialog.h (Revision 930293) +++ kdegames/kbattleship/src/networkdialog.h (Arbeitskopie) @@ -45,7 +45,7 @@ protected: void slotButtonClicked(int); public: - explicit NetworkDialog(bool client, QWidget* parent = 0); + explicit NetworkDialog(bool client, QWidget* parent = 0, const KUrl* url = 0); ~NetworkDialog(); QString nickname() const; Index: kdegames/kbattleship/src/simplemenu.cpp =================================================================== --- kdegames/kbattleship/src/simplemenu.cpp (Revision 930293) +++ kdegames/kbattleship/src/simplemenu.cpp (Arbeitskopie) @@ -86,6 +86,16 @@ } } +void SimpleMenu::createClient(const KUrl& url) +{ + QWidget* parent_widget = qobject_cast(parent()); + Q_ASSERT(parent_widget); + NetworkDialog dialog(true, parent_widget,&url); + if (dialog.exec() == QDialog::Accepted) { + finalize(DONE_CLIENT, dialog.nickname(), dialog.socket()); + } +} + void SimpleMenu::createClient() { QWidget* parent_widget = qobject_cast(parent()); Index: kdegames/kbattleship/src/mainwindow.h =================================================================== --- kdegames/kbattleship/src/mainwindow.h (Revision 930293) +++ kdegames/kbattleship/src/mainwindow.h (Arbeitskopie) @@ -21,12 +21,14 @@ class Event; } +class KUrl; + class MainWindow : public KXmlGuiWindow { Q_OBJECT PlayField* m_main; public: - MainWindow(); + explicit MainWindow(const KUrl& url); protected: void setupActions(); private slots: Index: kdegames/kbattleship/src/main.cpp =================================================================== --- kdegames/kbattleship/src/main.cpp (Revision 930293) +++ kdegames/kbattleship/src/main.cpp (Arbeitskopie) @@ -13,6 +13,7 @@ #include #include #include +#include #include "mainwindow.h" #include "coord.h" @@ -47,16 +48,32 @@ KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineOptions options; + options.add("!+[URL]", ki18n("URLs to connect after startup")); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KApplication app; - KGlobal::locale()->insertCatalog("libkdegames"); - qRegisterMetaType("Coord"); - - MainWindow* window = new MainWindow(); + + KUrl url; + KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); + + if (args->count() > 0) { + for (int i = 0; i < args->count(); ++i) { + url = KUrl(args->url(i)); + + if (!url.isValid()) + continue; + + break; + } + } + args->clear(); + + MainWindow* window = new MainWindow(url); // StatsWidget* window = new StatsWidget(0, 0); window->show(); - + + KGlobal::locale()->insertCatalog("libkdegames"); + return app.exec(); } Index: kdegames/kbattleship/src/networkdialog.cpp =================================================================== --- kdegames/kbattleship/src/networkdialog.cpp (Revision 930293) +++ kdegames/kbattleship/src/networkdialog.cpp (Arbeitskopie) @@ -27,7 +27,7 @@ #include "settings.h" -NetworkDialog::NetworkDialog(bool client, QWidget* parent) +NetworkDialog::NetworkDialog(bool client, QWidget* parent, const KUrl* url) : KDialog(parent) , m_publisher(0), m_client(client) { @@ -77,10 +77,11 @@ QWidget* frame=new QWidget(main); QVBoxLayout* frameLayout = new QVBoxLayout; + const QString hostName = url? url->host() : Settings::hostname(); tmp = new QLabel(i18n("&Hostname:"), frame); m_hostname = new KLineEdit(main); m_hostname->setClearButtonShown(true); - m_hostname->setText(Settings::hostname()); + m_hostname->setText(hostName); tmp->setBuddy(m_hostname); tmpLayout = new QHBoxLayout; tmpLayout->addWidget(tmp); @@ -89,10 +90,11 @@ frameLayout->addItem(tmpLayout); // port + const int port = ( url && url->port() != -1 )? url->port(): Settings::port(); tmp = new QLabel(i18n("&Port:"), main); m_port = new QSpinBox(main); m_port->setRange(1, 99999); - m_port->setValue(Settings::port()); + m_port->setValue(port); tmp->setBuddy(m_port); tmpLayout = new QHBoxLayout; tmpLayout->addWidget(tmp); @@ -109,6 +111,9 @@ connect(sw,SIGNAL(toggled(bool)), frame, SLOT(setVisible(bool))); connect(sw,SIGNAL(toggled(bool)), m_games, SLOT(setDisabled(bool))); mainLayout->addWidget(sw); + if(url) { + sw->click(); + } } else { Index: kdegames/kbattleship/src/simplemenu.h =================================================================== --- kdegames/kbattleship/src/simplemenu.h (Revision 930293) +++ kdegames/kbattleship/src/simplemenu.h (Arbeitskopie) @@ -20,6 +20,7 @@ class QTcpSocket; class Entity; class Protocol; +class KUrl; class SimpleMenu : public QObject { @@ -51,6 +52,7 @@ void setupController(Controller* controller, Entity* old_opponent, SeaView* sea, ChatWidget* chat, bool ask = false); + void createClient(const KUrl& url); void runGGZ(int fd); Entity* player(int p) { return p == 0 ? m_player1 : m_player2; } --Boundary-00=_nBfoJnO3KVRm75E Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ kde-games-devel mailing list kde-games-devel@kde.org https://mail.kde.org/mailman/listinfo/kde-games-devel --Boundary-00=_nBfoJnO3KVRm75E--