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 strHistoryFileName = "";
QString strCentralServer = ""; QString strCentralServer = "";
QString strServerInfo = ""; QString strServerInfo = "";
QString strWelcomeMessage = "";
// QT docu: argv()[0] is the program name, argv()[1] is the first // QT docu: argv()[0] is the program name, argv()[1] is the first
// argument and argv()[argc()-1] is the last argument. // 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 ---------------------- // Show all registered servers in the server list ----------------------
// Undocumented debugging command line argument: Show all registered // Undocumented debugging command line argument: Show all registered
// servers in the server list regardless if a ping to the server is // servers in the server list regardless if a ping to the server is
// possible or not // possible or not.
if ( GetFlagArgument ( argv, if ( GetFlagArgument ( argv,
i, i,
"--showallservers", // no short form "--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 ------------------------------------------------- // Initialization file -------------------------------------------------
if ( GetStringArgument ( tsConsole, if ( GetStringArgument ( tsConsole,
argc, argc,
@ -400,6 +416,7 @@ int main ( int argc, char** argv )
strServerName, strServerName,
strCentralServer, strCentralServer,
strServerInfo, strServerInfo,
strWelcomeMessage,
bCentServPingServerInList ); bCentServPingServerInList );
if ( bUseGUI ) if ( bUseGUI )
@ -501,6 +518,7 @@ QString UsageArguments ( char **argv )
" -p, --port local port number (server only)\n" " -p, --port local port number (server only)\n"
" -s, --server start server\n" " -s, --server start server\n"
" -u, --numchannels maximum number of channels (server only)\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" " -y, --history enable connection history and set file\n"
" name (server only)\n" " name (server only)\n"
" -z, --startminimized start minimizied (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& strServerNameForHTMLStatusFile,
const QString& strCentralServer, const QString& strCentralServer,
const QString& strServerInfo, const QString& strServerInfo,
const QString& strNewWelcomeMessage,
const bool bNCentServPingServerInList ) : const bool bNCentServPingServerInList ) :
iNumChannels ( iNewNumChan ), iNumChannels ( iNewNumChan ),
Socket ( this, iPortNumber ), Socket ( this, iPortNumber ),
@ -182,7 +183,8 @@ CServer::CServer ( const int iNewNumChan,
iNewNumChan, iNewNumChan,
bNCentServPingServerInList, bNCentServPingServerInList,
&ConnLessProtocol ), &ConnLessProtocol ),
bAutoRunMinimized ( false ) bAutoRunMinimized ( false ),
strWelcomeMessage ( strNewWelcomeMessage )
{ {
int i; 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 // since old versions of the llcon software did not implement the channel name
// request message, we have to explicitely send the channel list here // request message, we have to explicitely send the channel list here
CreateAndSendChanListForAllConChannels(); 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(); Mutex.unlock();

View File

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