From ee2acb6b059b1920fcac2e6ccff36855b3dc3460 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sat, 17 Oct 2009 16:46:56 +0000 Subject: [PATCH] *** empty log message *** --- vompclient.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++ vompclient.h | 3 +++ vompclientrrproc.c | 2 ++ 3 files changed, 59 insertions(+) diff --git a/vompclient.c b/vompclient.c index acfa62b..fd8baf5 100644 --- a/vompclient.c +++ b/vompclient.c @@ -55,6 +55,7 @@ VompClient::VompClient(Config* cfgBase, char* tconfigDir, int tsocket) incClients(); media=new MediaPlayer(); mediaprovider=new ServerMediaFile(cfgBase,media); + netLogFile = NULL; rrproc.init(); } @@ -83,6 +84,12 @@ VompClient::~VompClient() delete media; delete mediaprovider; + + if (netLogFile) + { + fclose(netLogFile); + netLogFile = NULL; + } } void VompClient::incClients() @@ -145,6 +152,31 @@ void VompClient::cleanConfig() #endif } */ +void VompClient::netLog() +{ + // Hook, called from rrproc login after client has logged in. + // See if this MVP config says to do network logging, if so open a log + // The config object will be usable now since it's set up in login + + char* doNetLogging = config.getValueString("Advanced", "Network logging"); + if (doNetLogging) + { + if (!strcasecmp(doNetLogging, "on")) + { + char* netLogFileName = config.getValueString("Advanced", "Network logging file"); + if (netLogFileName) + { + netLogFile = fopen(netLogFileName, "a"); + if (netLogFile) log->log("Client", Log::DEBUG, "Client network logging started"); + + delete[] netLogFileName; + } + } + + delete[] doNetLogging; + } +} + void VompClientStartThread(void* arg) { VompClient* m = (VompClient*)arg; @@ -182,6 +214,7 @@ void VompClient::run2() UCHAR* data; ULONG kaTimeStamp; + ULONG logStringLen; while(1) { @@ -265,6 +298,27 @@ void VompClient::run2() break; } } + else if (channelID == 4) + { + if (!tcp.readData((UCHAR*)&logStringLen, sizeof(ULONG))) break; + logStringLen = ntohl(logStringLen); + + log->log("Client", Log::DEBUG, "Received chan=%lu loglen=%lu", channelID, logStringLen); + + UCHAR buffer[logStringLen + 1]; + if (!tcp.readData((UCHAR*)&buffer, logStringLen)) break; + buffer[logStringLen] = '\0'; + +// log->log("Client", Log::INFO, "Client said: '%s'", buffer); + if (netLogFile) + { + if (fputs((const char*)buffer, netLogFile) == EOF) + { + fclose(netLogFile); + netLogFile = NULL; + } + } + } else { log->log("Client", Log::ERR, "Incoming channel number unknown"); diff --git a/vompclient.h b/vompclient.h index bd43790..a7b0bf0 100644 --- a/vompclient.h +++ b/vompclient.h @@ -95,6 +95,9 @@ class VompClient bool loggedIn; char* configDir; + void netLog(); + FILE* netLogFile; + //void cleanConfig(); #ifndef VOMPSTANDALONE diff --git a/vompclientrrproc.c b/vompclientrrproc.c index 9477d09..ce9cc11 100644 --- a/vompclientrrproc.c +++ b/vompclientrrproc.c @@ -275,6 +275,8 @@ int VompClientRRProc::processLogin() log->log("RRProc", Log::DEBUG, "written login reply len %lu", resp->getLen()); x.loggedIn = true; + x.netLog(); // safe to run here since the client won't start net logging for a while yet + return 1; } -- 2.39.2