home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kgame / kgameconnectdialog.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  4.3 KB  |  170 lines

  1. /*
  2.     This file is part of the KDE games library
  3.     Copyright (C) 2001 Martin Heni (martin@heni-online.de)
  4.     Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de)
  5.  
  6.     This library is free software; you can redistribute it and/or
  7.     modify it under the terms of the GNU Library General Public
  8.     License version 2 as published by the Free Software Foundation.
  9.  
  10.     This library is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.     Library General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU Library General Public License
  16.     along with this library; see the file COPYING.LIB.  If not, write to
  17.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18.     Boston, MA 02110-1301, USA.
  19. */
  20.  
  21. #ifndef __KGAMECONNECTDIALOG_H__
  22. #define __KGAMECONNECTDIALOG_H__
  23.  
  24. #include <kdialogbase.h>
  25.  
  26. class KGameConnectDialogPrivate;
  27. class KGameConnectWidgetPrivate;
  28.  
  29. class KGameConnectWidget : public QWidget
  30. {
  31.     Q_OBJECT
  32. public:
  33.     KGameConnectWidget(QWidget* parent);
  34.     virtual ~KGameConnectWidget();
  35.  
  36.     /**
  37.      * @param host The host to connect to by default
  38.      **/
  39.     void setHost(const QString& host);
  40.  
  41.     /**
  42.      * @return The host to connect to or QString::null if the user wants to
  43.      * be the MASTER
  44.      **/ 
  45.     QString host() const;
  46.  
  47.     /**
  48.      * @param port The port that will be shown by default
  49.      **/
  50.     void setPort(unsigned short int port);
  51.  
  52.     /**
  53.      * @return The port to connect to / to listen
  54.      **/
  55.     unsigned short int port() const;
  56.  
  57.     /**
  58.      * Specifies which state is the default (0 = server game; 1 = join game)
  59.      * @param state The default state. 0 For a server game, 1 to join a game
  60.      **/
  61.     void setDefault(int state);
  62.     
  63.     /**
  64.      * Sets DNS-SD service type, both for publishing and browsing
  65.      * @param type Service type (something like _kwin4._tcp). 
  66.      * It should be unique for application.
  67.      * @since 3.4
  68.      **/
  69.     void setType(const QString& type);
  70.     
  71.     /**
  72.      * @return service type
  73.      */
  74.     QString type() const;
  75.     
  76.     /** 
  77.      * Set game name for publishing. 
  78.      * @param name Game name. Important only for server mode. If not
  79.      * set hostname will be used. In case of name conflict -2, -3 and so on will be added to name.
  80.      */
  81.     void setName(const QString& name);
  82.     
  83.     /**
  84.      * @return game name. 
  85.      */
  86.     QString gameName() const;
  87.  
  88. protected slots:
  89.     /**
  90.      * The type has changed, ie the user switched between creating or
  91.      * joining.
  92.      **/
  93.     void slotTypeChanged(int);
  94.     void slotGamesFound();
  95.     void slotGameSelected(int);
  96.  
  97. signals:
  98.     void signalNetworkSetup();
  99.   void signalServerTypeChanged(int);
  100.  
  101. private:
  102.     void showDnssdControls();
  103.     KGameConnectWidgetPrivate* d;
  104.  
  105. };
  106.  
  107. /**
  108.  * @short Dialog to ask for host and port
  109.  *
  110.  * This Dialog is used to create a game. You call initConnection(port,
  111.  * QString::null, parent, true) to create a network game (as a server)
  112.  * or initConnection(port, host, parent) to join a network game.
  113.  *
  114.  * @author Andreas Beckermann <b_mann@gmx.de>
  115.  **/
  116. class KGameConnectDialog : public KDialogBase
  117. {
  118.     Q_OBJECT
  119. public:
  120.     KGameConnectDialog(QWidget* parent = 0,int buttonmask=Ok|Cancel);
  121.     virtual ~KGameConnectDialog();
  122.     
  123.     /**
  124.      * Shows a dialog to either connect to an existing game or to create a
  125.      * server game, depending on user's choice.
  126.      * @param port The port the user wants to connect to.
  127.      * @param host The host the user wants to connect to. Will be
  128.      * QString::null if server game is chosen
  129.      * @param parent The parent of the dialog
  130.      * @param server True to create a network game per default, false to
  131.      * join a game by default
  132.      **/
  133.     static int initConnection(unsigned short int& port, QString& host, QWidget* parent, bool server = false);
  134.  
  135.     /**
  136.      * @param host The host to connect to by default
  137.      **/
  138.     void setHost(const QString& host);
  139.  
  140.     /**
  141.      * @return The host to connect to or QString::null if the user wants to
  142.      * be the MASTER
  143.      **/ 
  144.     QString host() const;
  145.  
  146.     /**
  147.      * @param port The port that will be shown by default
  148.      **/
  149.     void setPort(unsigned short int port);
  150.  
  151.     /**
  152.      * @return The port to connect to / to listen
  153.      **/
  154.     unsigned short int port() const;
  155.  
  156.     /**
  157.      * Specifies which state is the default (0 = server game; 1 = join game)
  158.      * @param state The default state. 0 For a server game, 1 to join a game
  159.      **/
  160.     void setDefault(int state);
  161.  
  162. signals:
  163.     void signalNetworkSetup();
  164.  
  165. private:
  166.     KGameConnectDialogPrivate* d;
  167. };
  168.  
  169. #endif
  170.