• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • libkdegames
 

libkdegames

kgameerrordialog.cpp

00001 /*
00002     This file is part of the KDE games library
00003     Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de)
00004     Copyright (C) 2001 Martin Heni (martin@heni-online.de)
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License version 2 as published by the Free Software Foundation.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018     Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include <kmessagebox.h>
00022 #include <klocale.h>
00023 #include <kdebug.h>
00024 
00025 #include "kgame.h"
00026 
00027 #include "kgameerrordialog.h"
00028 
00029 class KGameErrorDialogPrivate
00030 {
00031 public:
00032     KGameErrorDialogPrivate()
00033     {
00034         mGame = 0;
00035     }
00036 
00037     const KGame* mGame;
00038 };
00039 
00040 KGameErrorDialog::KGameErrorDialog(TQWidget* parent) : TQObject(parent)
00041 {
00042  d = new KGameErrorDialogPrivate;
00043 }
00044 
00045 KGameErrorDialog::~KGameErrorDialog()
00046 {
00047  delete d;
00048 }
00049 
00050 void KGameErrorDialog::setKGame(const KGame* g)
00051 {
00052  slotUnsetKGame();
00053  d->mGame = g;
00054 
00055  connect(d->mGame, TQT_SIGNAL(destroyed()), this, TQT_SLOT(slotUnsetKGame()));
00056 
00057 // the error signals:
00058  connect(d->mGame, TQT_SIGNAL(signalNetworkErrorMessage(int, TQString)), 
00059         this, TQT_SLOT(slotError(int, TQString)));
00060  connect(d->mGame, TQT_SIGNAL(signalConnectionBroken()), 
00061         this, TQT_SLOT(slotServerConnectionLost()));
00062  connect(d->mGame, TQT_SIGNAL(signalClientDisconnected(TQ_UINT32,bool)), 
00063         this, TQT_SLOT(slotClientConnectionLost(TQ_UINT32,bool)));
00064 }
00065 
00066 void KGameErrorDialog::slotUnsetKGame()
00067 {
00068  if (d->mGame) {
00069     disconnect(d->mGame, 0, this, 0);
00070  }
00071  d->mGame = 0;
00072 }
00073 
00074 void KGameErrorDialog::error(const TQString& errorText, TQWidget* parent)
00075 { KMessageBox::error(parent, errorText); }
00076 
00077 void KGameErrorDialog::slotServerConnectionLost()
00078 {
00079 // TODO: add IP/port of the server
00080  TQString message = i18n("Connection to the server has been lost!");
00081  error(message, (TQWidget*)parent());
00082 }
00083 
00084 void KGameErrorDialog::slotClientConnectionLost(TQ_UINT32 /*id*/,bool)
00085 {
00086 //TODO: add IP/port of the client
00087  TQString message;
00088 // if (c) {
00089 //  message = i18n("Connection to client has been lost!\nID: %1\nIP: %2").arg(c->id()).arg(c->IP());
00090 // } else {
00091 //  message = i18n("Connection to client has been lost!");
00092 // }
00093  message = i18n("Connection to client has been lost!");
00094  error(message, (TQWidget*)parent());
00095 }
00096 
00097 void KGameErrorDialog::slotError(int errorNo, TQString text)
00098 {
00099  TQString message = i18n("Received a network error!\nError number: %1\nError message: %2").arg(errorNo).arg(text);
00100  error(message, (TQWidget*)parent());
00101 }
00102 
00103 void KGameErrorDialog::connectionError(TQString s)
00104 {
00105  TQString message;
00106  if (s.isNull()) {
00107     message = i18n("No connection could be created.");
00108  } else {
00109     message = i18n("No connection could be created.\nThe error message was:\n%1").arg(s);
00110  }
00111  error(message, (TQWidget*)parent());
00112 }
00113 
00114 
00115 
00116 // should become the real dialog - currently we just use messageboxes 
00117 // -> maybe unused forever
00118 KGameErrorMessageDialog::KGameErrorMessageDialog(TQWidget* parent) 
00119         : KDialogBase(Plain, i18n("Error"), Ok, Ok, parent, 0, true, true)
00120 {
00121 }
00122 
00123 KGameErrorMessageDialog::~KGameErrorMessageDialog()
00124 {
00125 }
00126 
00127 
00128 
00129 #include "kgameerrordialog.moc"

libkdegames

Skip menu "libkdegames"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

libkdegames

Skip menu "libkdegames"
  • libkdegames
Generated for libkdegames by doxygen 1.7.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |