support for server welcome message on connect (enabled via a command line argument)

This commit is contained in:
Volker Fischer 2013-02-11 20:24:38 +00:00
parent 3f937e80a5
commit a04438fdc5
3 changed files with 37 additions and 2 deletions

View file

@ -69,6 +69,7 @@ int main ( int argc, char** argv )
QString strHistoryFileName = "";
QString strCentralServer = "";
QString strServerInfo = "";
QString strWelcomeMessage = "";
// QT docu: argv()[0] is the program name, argv()[1] is the first
// argument and argv()[argc()-1] is the last argument.
@ -159,7 +160,7 @@ int main ( int argc, char** argv )
// Show all registered servers in the server list ----------------------
// Undocumented debugging command line argument: Show all registered
// servers in the server list regardless if a ping to the server is
// possible or not
// possible or not.
if ( GetFlagArgument ( argv,
i,
"--showallservers", // no short form
@ -276,6 +277,21 @@ int main ( int argc, char** argv )
}
// Server welcome message ----------------------------------------------
if ( GetStringArgument ( tsConsole,
argc,
argv,
i,
"-w",
"--welcomemessage",
strArgument ) )
{
strWelcomeMessage = strArgument;
tsConsole << "- welcome message: " << strWelcomeMessage << endl;
continue;
}
// Initialization file -------------------------------------------------
if ( GetStringArgument ( tsConsole,
argc,
@ -400,6 +416,7 @@ int main ( int argc, char** argv )
strServerName,
strCentralServer,
strServerInfo,
strWelcomeMessage,
bCentServPingServerInList );
if ( bUseGUI )
@ -501,6 +518,7 @@ QString UsageArguments ( char **argv )
" -p, --port local port number (server only)\n"
" -s, --server start server\n"
" -u, --numchannels maximum number of channels (server only)\n"
" -w, --welcomemessage welcome message on connect (server only)\n"
" -y, --history enable connection history and set file\n"
" name (server only)\n"
" -z, --startminimized start minimizied (server only)\n"

View file

@ -172,6 +172,7 @@ CServer::CServer ( const int iNewNumChan,
const QString& strServerNameForHTMLStatusFile,
const QString& strCentralServer,
const QString& strServerInfo,
const QString& strNewWelcomeMessage,
const bool bNCentServPingServerInList ) :
iNumChannels ( iNewNumChan ),
Socket ( this, iPortNumber ),
@ -182,7 +183,8 @@ CServer::CServer ( const int iNewNumChan,
iNewNumChan,
bNCentServPingServerInList,
&ConnLessProtocol ),
bAutoRunMinimized ( false )
bAutoRunMinimized ( false ),
strWelcomeMessage ( strNewWelcomeMessage )
{
int i;
@ -1123,6 +1125,17 @@ bool CServer::PutData ( const CVector<uint8_t>& vecbyRecBuf,
// since old versions of the llcon software did not implement the channel name
// request message, we have to explicitely send the channel list here
CreateAndSendChanListForAllConChannels();
// send welcome message (if enabled)
if ( !strWelcomeMessage.isEmpty() )
{
// create formated server welcome message and send it just to
// the client which just connected to the server
const QString strWelcomeMessageFormated =
"<b>Server Welcome Message:</b> " + strWelcomeMessage;
vecChannels[iCurChanID].CreateChatTextMes ( strWelcomeMessageFormated );
}
}
}
Mutex.unlock();

View file

@ -111,6 +111,7 @@ public:
const QString& strServerNameForHTMLStatusFile,
const QString& strCentralServer,
const QString& strServerInfo,
const QString& strNewWelcomeMessage,
const bool bNCentServPingServerInList );
void Start();
@ -234,6 +235,9 @@ protected:
// GUI settings
bool bAutoRunMinimized;
// messaging
QString strWelcomeMessage;
signals:
void Started();
void Stopped();