Commit 5d8b0775 authored by Jean-Paul Saman's avatar Jean-Paul Saman

Telnet command options implemented:

- channel ... --add and --delete
- program ... --add and --delete
- show [broadcast|channel|program|input]

Remove unused "Program Number" from C_Program. It does not show up in "browse" and "show program" commands.
parent c5dad8f1
......@@ -2,7 +2,7 @@
* dvbinput.cpp: DVB streams
*-------------------------------------------------------------------------------
* (c)1999-2002 VideoLAN
* $Id: dvbinput.cpp,v 1.12 2002/09/22 01:38:54 nitrox Exp $
* $Id: dvbinput.cpp,v 1.13 2002/09/26 16:05:32 jpsaman Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -683,3 +683,7 @@ void C_DvbInput::OnUpdateProgram(C_String strProgram,
C_String strFileName, C_String strType)
{
}
void C_DvbInput::OnDeleteProgram(C_String strProgram)
{
}
......@@ -2,7 +2,7 @@
* dvbinput.h: DVB Input class definition
*-------------------------------------------------------------------------------
* (c)1999-2002 VideoLAN
* $Id: dvbinput.h,v 1.6 2002/09/22 01:38:54 nitrox Exp $
* $Id: dvbinput.h,v 1.7 2002/09/26 16:05:32 jpsaman Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -50,6 +50,7 @@ protected:
virtual void OnStopStreaming(C_Broadcast* pBroadcast);
virtual void OnUpdateProgram(C_String strProgram,
C_String strFileName, C_String strType);
virtual void OnDeleteProgram(C_String strProgram);
virtual C_List<C_Program> OnGetAvailablePgrms();
// Hardware specific PID selection (demux)
......
......@@ -2,7 +2,7 @@
* localinput.cpp: Local streams
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: localinput.cpp,v 1.9 2002/09/04 10:56:34 jpsaman Exp $
* $Id: localinput.cpp,v 1.10 2002/09/26 16:05:33 jpsaman Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -415,7 +415,7 @@ void C_LocalInput::OnStopStreaming(C_Broadcast* pBroadcast)
}
//------------------------------------------------------------------------------
// Rewind the reception of the given program with specified speed
//
//------------------------------------------------------------------------------
void C_LocalInput::OnUpdateProgram(C_String strProgram,
C_String strFileName, C_String strType)
......@@ -423,6 +423,12 @@ void C_LocalInput::OnUpdateProgram(C_String strProgram,
C_String strPgrmCount = m_cSettings.GetSetting("Input.ProgramCount", "0");
unsigned int uiPgrmCount = strPgrmCount.ToInt();
unsigned int uiId = m_vProgramNames.Find(strProgram) + 1;
if (uiId>0)
{
Log(m_hLog, LOG_WARN, "The program already exists in the list for this input");
}
if(uiPgrmCount)
{
uiPgrmCount++;
......@@ -443,9 +449,99 @@ void C_LocalInput::OnUpdateProgram(C_String strProgram,
}
else
{
Log(m_hLog, LOG_WARN,
throw E_Exception(GEN_ERR,
"The \"ProgramCount\" variable isn't specified in the file \"" +
m_strConfigPath + "/input.cfg\"");
}
}
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
void C_LocalInput::OnDeleteProgram(C_String strProgram)
{
// Get the type of the program
unsigned int uiId = m_vProgramNames.Find(strProgram) + 1;
if (uiId>0)
{
// Delete settings from m_cSettings
C_String strPgrmCount = m_cSettings.GetSetting("Input.ProgramCount", "0");
unsigned int uiPgrmCount = strPgrmCount.ToInt();
if(uiPgrmCount)
{
C_String strDelKey = C_String(uiId)+ ".Name";
m_cSettings.Delete(strDelKey.ToLower());
if (m_cSettings.GetSetting(C_String(uiId)+".FileName", "") != "" )
{
strDelKey = C_String(uiId)+ ".FileName";
m_cSettings.Delete(strDelKey.ToLower());
}
if (m_cSettings.GetSetting(C_String(uiId)+".Device", "") != "" )
{
strDelKey = C_String(uiId)+ ".Device";
m_cSettings.Delete(strDelKey.ToLower());
}
strDelKey = C_String(uiId)+ ".Type";
m_cSettings.Delete(strDelKey.ToLower());
// Move all other settings one item down
for(unsigned int ui = uiId; ui <= uiPgrmCount; ui++)
{
C_String strProgram = m_cSettings.GetSetting(C_String(ui+1) + ".Name",C_String("Pgrm") + ui+1);
C_String strFileName = m_cSettings.GetSetting(C_String(ui+1)+".FileName", "");
C_String strType = m_cSettings.GetSetting(C_String(ui+1) + ".Type", "Mpeg2-TS");
C_String strDevice = m_cSettings.GetSetting(C_String(ui+1)+".Device", "");
// update settings
C_String strKey = C_String(ui)+ ".Name";
m_cSettings.Update(strKey.ToLower(),strProgram);
strKey = C_String(ui)+ ".FileName";
if (strFileName != "")
{
m_cSettings.Update(strKey.ToLower(), strFileName);
}
else
m_cSettings.Update(strKey.ToLower(), "");
strKey = C_String(ui)+ ".Device";
if (strDevice != "")
{
m_cSettings.Update(strKey.ToLower(), strDevice);
}
else
m_cSettings.Update(strKey.ToLower(), "");
strKey = C_String(ui)+ ".Type";
m_cSettings.Update(strKey.ToLower(), strType);
}
// Lower program count
uiPgrmCount--;
strDelKey = C_String("Input.ProgramCount");
m_cSettings.Update(strDelKey.ToLower(), C_String(uiPgrmCount));
m_vProgramNames.Delete(uiId);
// ** DEBUG **
Log(m_hLog, LOG_NOTE, "Debugging inputs m_cSettings list.");
C_String strPgrmCount = m_cSettings.GetSetting("Input.ProgramCount", "0");
unsigned int uiPgrmCount = strPgrmCount.ToInt();
for(unsigned int ui = 1; ui <= uiPgrmCount; ui++)
{
C_String strProgram = m_cSettings.GetSetting(C_String(ui) + ".Name",C_String("Pgrm") + ui);
C_String strFileName = m_cSettings.GetSetting(C_String(ui)+".FileName", "");
C_String strDevice = m_cSettings.GetSetting(C_String(ui)+".Device", "");
C_String strType = m_cSettings.GetSetting(C_String(ui) + ".Type", "Mpeg2-TS").ToLower();
Log(m_hLog, LOG_NOTE, "Program: \"" + strProgram +"\"");
Log(m_hLog, LOG_NOTE, " FileName: \"" + strFileName+"\"");
Log(m_hLog, LOG_NOTE, " Device: \"" + strDevice+"\"");
Log(m_hLog, LOG_NOTE, " Type: \"" + strType+"\"");
}
}
else
{
throw E_Exception(GEN_ERR,"Deleting program information from input failed");
}
}
else
{
throw E_Exception(GEN_ERR, "The program is not known by this input.");
}
}
......@@ -2,7 +2,7 @@
* localinput.h: Local Input class definition
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: localinput.h,v 1.3 2002/09/04 10:56:34 jpsaman Exp $
* $Id: localinput.h,v 1.4 2002/09/26 16:05:33 jpsaman Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -56,6 +56,7 @@ protected:
virtual void OnSuspendStreaming(C_Broadcast* pBroadcast);
virtual void OnStopStreaming(C_Broadcast* pBroadcast);
virtual void OnUpdateProgram(C_String strProgram,C_String strFileName, C_String strType);
virtual void OnDeleteProgram(C_String strProgram);
virtual C_List<C_Program> OnGetAvailablePgrms();
private:
......
......@@ -2,7 +2,7 @@
* videoinput.cpp: Video4linux streams
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: videoinput.cpp,v 1.11 2002/09/16 20:24:33 asmax Exp $
* $Id: videoinput.cpp,v 1.12 2002/09/26 16:05:33 jpsaman Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
* Cyril Deguet <asmax@via.ecp.fr>
......@@ -356,3 +356,7 @@ void C_VideoInput::OnUpdateProgram(C_String strProgram,
C_String strFileName, C_String strType)
{
}
void C_VideoInput::OnDeleteProgram(C_String strProgram)
{
}
......@@ -2,7 +2,7 @@
* videoinput.h: Video Input class definition
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: videoinput.h,v 1.4 2002/09/04 10:56:34 jpsaman Exp $
* $Id: videoinput.h,v 1.5 2002/09/26 16:05:33 jpsaman Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
*
......@@ -53,6 +53,7 @@ protected:
virtual void OnStopStreaming(C_Broadcast* pBroadcast);
virtual void OnUpdateProgram(C_String strProgram,
C_String strFileName, C_String strType);
virtual void OnDeleteProgram(C_String strProgram);
virtual C_List<C_Program> OnGetAvailablePgrms();
......
......@@ -2,7 +2,7 @@
* rtp.cpp: RTP header manipulation
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: rtp.cpp,v 1.2 2002/08/13 22:13:46 massiot Exp $
* $Id: rtp.cpp,v 1.3 2002/09/26 16:05:34 jpsaman Exp $
*
* Authors: Tristan Leteurtre <tooney@via.ecp.fr>
* Jean-Paul Saman <saman@natlab.research.philips.com>
......@@ -66,8 +66,9 @@ u8 C_RtpHeader::BuildHeader(u16 iCounter)
bData[1] = 33; // Mpeg2-TS A/V at 90 kHz, as defined in RFC 1890
// Set sequence number with initial random iCounter
bData[2] = iCounter >> 8;
bData[3] = iCounter;
bData[2] = iCounter >> 8; //msb
bData[3] = iCounter; //lsb
// byte 4,5,6,7 is the PCR time stamp in our case
bData[4]=bData[5]=bData[6]=bData[7]=0xFF;
// byte 8,9,10,11 are the synchronization source (SSRC)
......
......@@ -2,7 +2,7 @@
* admin.cpp:
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: admin.cpp,v 1.13 2002/09/10 11:56:28 tooney Exp $
* $Id: admin.cpp,v 1.14 2002/09/26 16:05:34 jpsaman Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -245,6 +245,15 @@ int C_Admin::Init()
pCmdDesc->m_vOptionalArgs.Add(pStr);
pCmdDesc->BuildUsage();
m_cCmdDescriptions.Add(pCmdDesc->m_strName, pCmdDesc);
// -- show [broadcast|channel|program|input]
pCmdDesc = new C_CommandDesc("show",
"show running broadcasts, available channels, programs or inputs",
"Called with one argument, \"show\" gives information about "
" running broadcasts or available channels, programs or inputs.");
pStr = new C_String("command");
pCmdDesc->m_vMandatoryArgs.Add(pStr);
pCmdDesc->BuildUsage();
m_cCmdDescriptions.Add(pCmdDesc->m_strName, pCmdDesc);
// -- config <filename> [--load] [--save]
pCmdDesc = new C_CommandDesc("config",
"load and save configuration file.",
......@@ -349,7 +358,7 @@ int C_Admin::Init()
pCmdDesc->m_vBooleans.Add(pStr);
pCmdDesc->BuildUsage();
m_cCmdDescriptions.Add(pCmdDesc->m_strName, pCmdDesc);
// -- start <program> <channel> <input> [--loop] [--end]
// -- start <program> <channel> <input> [--loop] [--end] [--rtp]
pCmdDesc = new C_CommandDesc("start",
"launches a program.",
"\"start\" launches the specified program of the specified input"
......@@ -366,8 +375,6 @@ int C_Admin::Init()
pCmdDesc->m_vBooleans.Add(pStr);
pStr = new C_String("rtp");
pCmdDesc->m_vBooleans.Add(pStr);
pStr = new C_String("end"); // jump to end of file
pCmdDesc->m_vBooleans.Add(pStr);
pCmdDesc->m_bExtendedOptions = true;
pCmdDesc->BuildUsage();
m_cCmdDescriptions.Add(pCmdDesc->m_strName, pCmdDesc);
......
......@@ -2,7 +2,7 @@
* directory.cpp: programs definition and registration
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: directory.cpp,v 1.1 2001/10/06 21:23:37 bozo Exp $
* $Id: directory.cpp,v 1.2 2002/09/26 16:05:34 jpsaman Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -82,6 +82,14 @@ void C_PgrmInfo::AddProvider(C_Input* pInput)
}
bool C_PgrmInfo::DeleteProvider(C_Input* pInput)
{
ASSERT(pInput);
ASSERT(!m_cProviders.Find(*pInput) < 0);
//m_cProviders.Delete(pInput);
return false;
}
/*******************************************************************************
* C_PgrmDirectoryBrowser class
......@@ -160,8 +168,20 @@ int C_PgrmDirectory::Add(const C_Program& cProgram, C_Input* pInput)
int C_PgrmDirectory::Remove(const C_Program& cProgram, C_Input* pInput)
{
ASSERT(false);
return GEN_ERR;
ASSERT(pInput);
int iRc = GEN_ERR;
C_String strPgrmName = cProgram.GetName();
C_PgrmInfo* pInfo = m_cPgrmList.Find(strPgrmName);
if(pInfo)
{
//pInfo->DeleteProvider(pInput);
iRc = m_cPgrmList.Remove(strPgrmName);
}
return iRc;
}
......
......@@ -2,7 +2,7 @@
* directory.h: Program description and registration classes definition
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: directory.h,v 1.1 2001/10/06 21:23:37 bozo Exp $
* $Id: directory.h,v 1.2 2002/09/26 16:05:34 jpsaman Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -61,6 +61,7 @@ class C_PgrmInfo
const C_Vector<C_Input>& GetProviders() const;
bool IsProvider(C_Input* pInput) const;
void AddProvider(C_Input* pInput);
bool DeleteProvider(C_Input* pInput);
private:
C_Program m_cProgram;
......
......@@ -2,7 +2,7 @@
* input.cpp: Input streams
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: input.cpp,v 1.7 2002/09/04 14:38:37 jpsaman Exp $
* $Id: input.cpp,v 1.8 2002/09/26 16:05:34 jpsaman Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -325,8 +325,8 @@ C_Answer C_Input::UpdateProgram(C_String strProgram, C_String strFileName,
try
{
LogDbg(m_hLog, "Program "+strProgram+" added.");
OnUpdateProgram(strProgram, strFileName, strType);
LogDbg(m_hLog, "Program "+strProgram+" added.");
// Build the answer
cAnswer.SetStatus(NO_ERR);
......@@ -344,6 +344,33 @@ C_Answer C_Input::UpdateProgram(C_String strProgram, C_String strFileName,
}
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
C_Answer C_Input::DeleteProgram(C_String strProgram)
{
C_Answer cAnswer(GetName());
try
{
OnDeleteProgram(strProgram);
LogDbg(m_hLog, "Configuration Program "+strProgram+" removed.");
// Build the answer
cAnswer.SetStatus(NO_ERR);
cAnswer.AddMessage("Configuration Program " + strProgram + " removed.");
}
catch(E_Exception e)
{
// Build the answer
cAnswer.SetStatus(e.GetCode());
cAnswer.AddMessage("Unable to delete program "+strProgram);
cAnswer.AddMessage(e.Dump());
}
return cAnswer;
}
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
......
......@@ -2,7 +2,7 @@
* input.h: Input class definition
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: input.h,v 1.5 2002/09/04 14:38:37 jpsaman Exp $
* $Id: input.h,v 1.6 2002/09/26 16:05:34 jpsaman Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -83,6 +83,7 @@ class C_Input
C_Answer SuspendStreaming(C_Broadcast* pBroadcast);
C_Answer StopStreaming(C_Broadcast* pBroadcast);
C_Answer UpdateProgram(C_String strProgram, C_String strFileName, C_String strType);
C_Answer DeleteProgram(C_String strProgram);
// List of available programs
C_List<C_Program> GetAvailablePgrms();
......@@ -103,6 +104,7 @@ class C_Input
virtual void OnStopStreaming(C_Broadcast* pBroadcast) = 0;
virtual void OnUpdateProgram(C_String strProgram, C_String strFileName,
C_String strType) = 0;
virtual void OnDeleteProgram(C_String strProgram) = 0;
// Child program table browsing
virtual C_List<C_Program> OnGetAvailablePgrms() = 0;
// Input internal failure management
......
......@@ -2,7 +2,7 @@
* manager.cpp: Vls manager
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: manager.cpp,v 1.17 2002/09/11 07:17:55 jpsaman Exp $
* $Id: manager.cpp,v 1.18 2002/09/26 16:05:34 jpsaman Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -432,6 +432,10 @@ C_Answer C_Manager::HandleRequest(const C_Request& cRequest)
{
cAnswer = Browse(cRequest);
}
else if(strCmd == "show")
{
cAnswer = Show(cRequest);
}
else if(strCmd == "start")
{
cAnswer = Start(cRequest);
......@@ -452,10 +456,6 @@ C_Answer C_Manager::HandleRequest(const C_Request& cRequest)
{
cAnswer = Config(cRequest);
}
else if(strCmd == "config")
{
cAnswer = Config(cRequest);
}
else if(strCmd == "program")
{
cAnswer = Program(cRequest);
......@@ -629,6 +629,143 @@ C_Answer C_Manager::Browse(const C_Request& cRequest)
return cAnswer;
}
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
C_Answer C_Manager::Show(const C_Request& cRequest)
{
C_Answer cAnswer("Manager");
C_String strCommand = cRequest.GetArg("command");
ASSERT(strCommand != "");
if (strCommand.ToLower() == "broadcast")
{
cAnswer.AddMessage("Showing running broadcasts.");
// Lock Broadcast repository
m_cBroadcasts.Lock();
C_RepositoryBrowser<C_String, C_Broadcast> cIterator1 =
m_cBroadcasts.CreateBrowser();
while(cIterator1.HasNextItem())
{
C_Broadcast* pBroadcast = cIterator1.GetNextItem();
C_Answer cBroadcast(pBroadcast->GetChannel()->GetName());
cBroadcast.SetStatus(NO_ERR);
cBroadcast.AddMessage("Channel '"+pBroadcast->GetChannel()->GetName()+"'");
cBroadcast.AddMessage("Program '"+pBroadcast->GetProgram()->GetName()+"'");
cBroadcast.AddMessage("Input '"+pBroadcast->GetInput()->GetName()+"'");
cBroadcast.AddMessage("Input '"+pBroadcast->GetChannel()->GetName()+"'");
C_String strOptions = "Options used are '";
if (pBroadcast->GetOption("rtp")=="1")
strOptions += "--rtp ";
if (pBroadcast->GetOption("end")=="1")
strOptions += "--end ";
if (pBroadcast->GetOption("loop")=="1")
strOptions += "--loop ";
cBroadcast.AddMessage(strOptions+"'");
cAnswer.Add(cBroadcast);
}
// UnLock Broadcast repository
m_cBroadcasts.UnLock();
cAnswer.SetStatus(NO_ERR);
}
else if (strCommand.ToLower() == "channel")
{
cAnswer.AddMessage("Showing available channels.");
// Lock the channel repository
m_cChannelList.Lock();
// Get the names of all the channels
C_Application* pApp = C_Application::GetApp();
ASSERT(pApp);
C_Vector<C_Setting> vChannels = pApp->GetSettings("Channels");
// Create the corresponding channels
for(unsigned int i = 0; i < vChannels.Size(); i++)
{
// Get channel name and type
C_Setting cCurrentChannel = vChannels[i];
C_String strChannelName = cCurrentChannel.GetName();
C_String strChannelType = cCurrentChannel.GetValue();
C_String strKey = strChannelName + C_String(".type");
C_String strType = pApp->GetSetting(strKey, "");
// Create answer
C_Answer cChannelDescr(strChannelName);
cChannelDescr.SetStatus(NO_ERR);
cChannelDescr.AddMessage("Channel '"+strChannelName+"' of type '"+strChannelType+"'");
cChannelDescr.AddMessage("Streamtype '"+strType+"'");
cAnswer.Add(cChannelDescr);
}
cAnswer.SetStatus(NO_ERR);
// Unlock the channel repository
m_cChannelList.UnLock();
}
else if (strCommand.ToLower() == "program")
{
cAnswer.AddMessage("Showing available programs.");
cAnswer.SetStatus(NO_ERR);
m_cProgramList.Lock();
C_PgrmDirectoryBrowser cBrowser = m_cProgramList.CreateBrowser();
while(cBrowser.HasNext())
{
C_PgrmInfo* pPgrmInfo = cBrowser.GetNext();
ASSERT(pPgrmInfo);
// Build a subanswer with the pgrm description and the list of providers
const C_Program* pPgrm = pPgrmInfo->GetProgram();
C_String strPgrmName = pPgrm->GetName();
ASSERT(strPgrmName != "");
C_Answer cPgrmDescr(strPgrmName);
cPgrmDescr.SetStatus(NO_ERR);
cPgrmDescr.AddMessage(pPgrm->GetDescription());
const C_Vector<C_Input>& cProviders = pPgrmInfo->GetProviders();
C_String strProviders = "Provided by";
for(unsigned int i = 0; i < cProviders.Size(); i++)
{
strProviders += " " + cProviders[i].GetName();
}
cPgrmDescr.AddMessage(strProviders);
// Add it to the answer
cAnswer.Add(cPgrmDescr);
}
m_cProgramList.UnLock();
}
else if (strCommand.ToLower() == "input")
{
cAnswer.AddMessage("Showing available inputs.");
cAnswer.SetStatus(NO_ERR);
// Lock the input repository
m_cInputList.Lock();
C_RepositoryBrowser<C_String, C_Input> cIterator =
m_cInputList.CreateBrowser();
while(cIterator.HasNextItem())
{
C_Input* pInput = cIterator.GetNextItem();
C_Answer cInputDescr(pInput->GetName());
cInputDescr.SetStatus(NO_ERR);
cInputDescr.AddMessage("Input '"+pInput->GetName()+"'");
cAnswer.Add(cInputDescr);
}
// Unlock the input repository
m_cInputList.UnLock();
}
else
{
cAnswer.SetStatus(GEN_ERR);
cAnswer.AddMessage("What to show? Use: broadcast, channel, program or input.");
}
return cAnswer;
}
//------------------------------------------------------------------------------
//
......@@ -844,44 +981,127 @@ C_Answer C_Manager::Program(const C_Request& cRequest)
C_Input* pInput = m_cInputList.Get(strInput);
if(!pInput)
{
cAnswer.SetStatus(GEN_ERR);
cAnswer.AddMessage("input doesn't exist");
return cAnswer;
}
// optional arguments
C_String strAdd = cRequest.GetArg("add");
C_String strDelete = cRequest.GetArg("delete");
if ((strAdd == "1") && (strDelete == "1"))
{
cAnswer.SetStatus(GEN_ERR);
cAnswer.AddMessage("Channel does not allow use of --add and --delete at the same time.");
return cAnswer;
}
if (strAdd == "1") // Add Program
{
// Check if program is already present
const C_Program* pProgram = m_cProgramList.GetPgrm(strProgram);
if(pProgram)
{
cAnswer.SetStatus(GEN_ERR);
cAnswer.AddMessage("input doesn't exist");
cAnswer.AddMessage("Ignoring command program already added.");
m_cProgramList.ReleasePgrm(pProgram->GetName());
return cAnswer;
}
// Lock the input repository and the program list
m_cProgramList.Lock();
m_cInputList.Lock();
// First update C_Settings in pInput
C_Answer cInputAnswer = pInput->UpdateProgram(strProgram,strFileName,strType);
if(cInputAnswer.GetStatus())
{
cAnswer.SetStatus(cInputAnswer.GetStatus());
}
cAnswer.Add(cInputAnswer);
// Then Update m_cProgramList
C_List<C_Program> cInputPgrms = pInput->GetAvailablePgrms();
unsigned int iPgrmNumber = cInputPgrms.Size();
if (iPgrmNumber>0)
m_cProgramList.Add(cInputPgrms[iPgrmNumber-1], pInput);
else
{
cAnswer.SetStatus(GEN_ERR);
cAnswer.AddMessage("ProgramList is empty.");
}
// debug
Log(m_hLog, LOG_NOTE, "Program configuration changed.");
for(unsigned int j = 0; j < iPgrmNumber; j++)
{
Log(m_hLog, LOG_NOTE, "Program: " + cInputPgrms[j].GetName());
}
// Unlock the input repository and the program list
m_cInputList.UnLock();
m_cProgramList.UnLock();
}
else
if (strDelete == "1") // Delete Program
{
// Lock the input repository and the program list
m_cProgramList.Lock();
m_cInputList.Lock();
Log(m_hLog, LOG_NOTE, "Program being deleted.");
// Check if program is known
const C_Program* pProgram = m_cProgramList.GetPgrm(strProgram);
if(!pProgram)
{
cAnswer.SetStatus(GEN_ERR);
cAnswer.AddMessage("Cannot delete unknown program.");
return cAnswer;
}
m_cProgramList.ReleasePgrm(pProgram->GetName());
// First update C_Settigs in pInput
C_Answer cInputAnswer = pInput->UpdateProgram(strProgram,strFileName,strType);
if(cInputAnswer.GetStatus())
{
cAnswer.SetStatus(cInputAnswer.GetStatus());
}
cAnswer.Add(cInputAnswer);
// Then Update m_cProgramList
C_List<C_Program> cInputPgrms = pInput->GetAvailablePgrms();
unsigned int iPgrmNumber = cInputPgrms.Size();
if (iPgrmNumber>0)
m_cProgramList.Add(cInputPgrms[iPgrmNumber-1], pInput);
else
{
cAnswer.SetStatus(GEN_ERR);
cAnswer.AddMessage("ProgramList is empty.");
}
// debug
Log(m_hLog, LOG_NOTE, "Program configuration changed.");
for(unsigned int j = 0; j < iPgrmNumber; j++)
// Lock the input repository and the program list
m_cProgramList.Lock();
m_cInputList.Lock();
// First update C_Settings in pInput
C_Answer cInputAnswer = pInput->DeleteProgram(strProgram);
if(cInputAnswer.GetStatus())
{
cAnswer.SetStatus(cInputAnswer.GetStatus());
cAnswer.AddMessage("Error removing program from input.");
m_cProgramList.UnLock();
m_cInputList.UnLock();
return cAnswer;
}
cAnswer.Add(cInputAnswer);
// Then Delete from m_cProgramList
if(!cInputAnswer.GetStatus())
{
int iRc = m_cProgramList.Remove(*pProgram, pInput);
if(iRc == GEN_ERR)
{
Log(m_hLog, LOG_NOTE, "Program: " + cInputPgrms[j].GetName());
cAnswer.SetStatus(GEN_ERR);
cAnswer.AddMessage("Error removing program from configuration.");
m_cProgramList.UnLock();
m_cInputList.UnLock();
return cAnswer;
}
// Unlock the input repository and the program list
m_cInputList.UnLock();
m_cProgramList.UnLock();