Proper detection whether SCTP is available. Do not update player names on configuration change if network client is running.

This commit is contained in:
lotodore
2007-06-04 16:19:11 +00:00
parent ffbe8ac924
commit b9ccba6ed4
8 changed files with 37 additions and 15 deletions
@@ -21,6 +21,7 @@
#include "session.h" #include "session.h"
#include "configfile.h" #include "configfile.h"
#include "tinyxml.h" #include "tinyxml.h"
#include <net/socket_startup.h>
using namespace std; using namespace std;
@@ -90,6 +91,8 @@ void joinNetworkGameDialogImpl::exec() {
fillServerProfileList(); fillServerProfileList();
} }
checkBox_sctp->setEnabled(socket_has_sctp());
QDialog::exec(); QDialog::exec();
} }
+1 -5
View File
@@ -511,10 +511,6 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent)
myWaitingForServerGameDialog = new waitForServerToStartGameDialogImpl(this); myWaitingForServerGameDialog = new waitForServerToStartGameDialogImpl(this);
myAboutPokerthDialog = new aboutPokerthImpl(this); myAboutPokerthDialog = new aboutPokerthImpl(this);
//dialog settings
// mySettingsDialog->checkBox_useSctp->setEnabled(mySession->hasSctp());
// myJoinNetworkGameDialog->checkBox_sctp->setEnabled(mySession->hasSctp());
// //ShortCuts // //ShortCuts
// QShortcut *quitPokerTHKeys = new QShortcut(QKeySequence(Qt::Key_Control + Qt::Key_Q), this); // QShortcut *quitPokerTHKeys = new QShortcut(QKeySequence(Qt::Key_Control + Qt::Key_Q), this);
// connect( quitPokerTHKeys, SIGNAL(activated() ), actionQuit, SLOT( trigger() ) ); // connect( quitPokerTHKeys, SIGNAL(activated() ), actionQuit, SLOT( trigger() ) );
@@ -798,7 +794,7 @@ void mainWindowImpl::callSettingsDialog() {
else { groupBox_RightToolBox->hide(); } else { groupBox_RightToolBox->hide(); }
//Falls Spielernamen geändert wurden --> neu zeichnen --> erst beim nächsten Neustart neu ausgelesen //Falls Spielernamen geändert wurden --> neu zeichnen --> erst beim nächsten Neustart neu ausgelesen
if (mySettingsDialog->getPlayerNickIsChanged() && mySession->getCurrentGame()) { if (mySettingsDialog->getPlayerNickIsChanged() && mySession->getCurrentGame() && !mySession->isNetworkClientRunning()) {
HandInterface *currentHand = mySession->getCurrentGame()->getCurrentHand(); HandInterface *currentHand = mySession->getCurrentGame()->getCurrentHand();
currentHand->getPlayerArray()[0]->setMyName(mySettingsDialog->lineEdit_HumanPlayerName->text().toUtf8().constData()); currentHand->getPlayerArray()[0]->setMyName(mySettingsDialog->lineEdit_HumanPlayerName->text().toUtf8().constData());
@@ -21,6 +21,7 @@
#include "myavatarlistitem.h" #include "myavatarlistitem.h"
#include "configfile.h" #include "configfile.h"
#include <net/socket_startup.h>
#include <iostream> #include <iostream>
@@ -136,6 +137,7 @@ void settingsDialogImpl::exec() {
spinBox_logStoreDuration->setValue(myConfig->readConfigInt("LogStoreDuration")); spinBox_logStoreDuration->setValue(myConfig->readConfigInt("LogStoreDuration"));
comboBox_logInterval->setCurrentIndex(myConfig->readConfigInt("LogInterval")); comboBox_logInterval->setCurrentIndex(myConfig->readConfigInt("LogInterval"));
checkBox_useSctp->setEnabled(socket_has_sctp());
QDialog::exec(); QDialog::exec();
+19
View File
@@ -22,6 +22,10 @@
#include <net/socket_startup.h> #include <net/socket_startup.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
bool bool
socket_startup() socket_startup()
{ {
@@ -33,3 +37,18 @@ socket_cleanup()
{ {
} }
bool
socket_has_sctp()
{
#ifdef IPPROTO_SCTP
int test = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP);
if (test == -1)
return false;
close(test);
return true;
#else
return false;
#endif
}
+3 -1
View File
@@ -16,12 +16,14 @@
* Free Software Foundation, Inc., * * Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
/* Socket startup/cleanup functions (required for Win32). */ /* Socket startup/cleanup/detection functions. */
#ifndef _SOCKET_STARTUP_H_ #ifndef _SOCKET_STARTUP_H_
#define _SOCKET_STARTUP_H_ #define _SOCKET_STARTUP_H_
bool socket_startup(); bool socket_startup();
void socket_cleanup(); void socket_cleanup();
bool socket_has_sctp();
#endif #endif
+6
View File
@@ -66,3 +66,9 @@ socket_cleanup()
WSACleanup(); WSACleanup();
} }
bool
socket_has_sctp()
{
return false; /* no SCTP on Windows */
}
+2 -1
View File
@@ -34,7 +34,7 @@
using namespace std; using namespace std;
Session::Session(GuiInterface *g, ConfigFile *c) Session::Session(GuiInterface *g, ConfigFile *c)
: currentGameID(0), myNetClient(0), myNetServer(0), myGui(g), myConfig(c), thisHasSctp(0) : currentGameID(0), myNetClient(0), myNetServer(0), myGui(g), myConfig(c)
{ {
} }
@@ -210,3 +210,4 @@ bool Session::isNetworkClientRunning() const
// TODO // TODO
return myNetClient != NULL; return myNetClient != NULL;
} }
-7
View File
@@ -63,10 +63,6 @@ public:
bool isNetworkClientRunning() const; // TODO hack bool isNetworkClientRunning() const; // TODO hack
void setHasSctp ( bool theValue ) { thisHasSctp = theValue; }
bool hasSctp() const { return thisHasSctp; }
private: private:
int currentGameID; int currentGameID;
@@ -77,9 +73,6 @@ private:
boost::shared_ptr<Game> currentGame; boost::shared_ptr<Game> currentGame;
GuiInterface *myGui; GuiInterface *myGui;
ConfigFile *myConfig; ConfigFile *myConfig;
bool thisHasSctp;
}; };