Beispiel #1
0
bool Service::SaveConfig( ConfigBase &config )
{
  config.WriteConfig( "ServiceID",    service_id );
  config.WriteConfig( "PID",          pid );
  config.WriteConfig( "Type",         type );
  config.WriteConfig( "Name",         name );
  config.WriteConfig( "Provider",     provider );
  config.WriteConfig( "Channel",      channel ? channel->GetKey( ) : -1 );

  config.DeleteConfig( "Streams" );
  Setting &n = config.ConfigList( "Streams" );
  ConfigBase c( n );
  for( std::map<uint16_t, Stream *>::iterator it = streams.begin( ); it != streams.end( ); it++ )
  {
    Setting &n2 = c.ConfigGroup( );
    ConfigBase c2( n2 );
    it->second->SaveConfig( c2 );
  }

  config.DeleteConfig( "CA" );
  Setting &n2 = config.ConfigList( "CA" );
  ConfigBase c2( n2 );
  for( std::set<std::pair<uint16_t, uint16_t> >::iterator it = caids.begin( ); it != caids.end( ); it++ )
  {
    Setting &n3 = c2.ConfigGroup( );
    ConfigBase c3( n3 );
    c3.WriteConfig( "CA_id", it->first );
    c3.WriteConfig( "CA_pid", it->second );
  }
  return true;
}
Beispiel #2
0
bool Service::LoadConfig( ConfigBase &config )
{
  config.ReadConfig( "ServiceID", service_id );
  config.ReadConfig( "PID", pid );
  config.ReadConfig( "Type", (int &) type );
  std::string t;
  config.ReadConfig( "Name", t );
  SetName( t );
  config.ReadConfig( "Provider", provider );
  int channel_id;
  config.ReadConfig( "Channel", channel_id );
  if( channel_id != -1 )
  {
    channel = TVDaemon::Instance( )->GetChannel( channel_id );
    if( channel )
    {
      channel->AddService( this );
      transponder.HasChannels( true );
    }
    else
    {
      LogError( "Service '%s': channel %d not found", name.c_str( ), channel_id );
      channel_id == -1;
    }
  }

  Setting &n = config.ConfigList( "Streams" );
  for( int i = 0; i < n.getLength( ); i++ )
  {
    ConfigBase c2( n[i] );
    Stream *s = new Stream( *this );
    s->LoadConfig( c2 );
    streams[s->GetKey( )] = s;
  }

  Setting &n2 = config.ConfigList( "CA" );
  for( int i = 0; i < n2.getLength( ); i++ )
  {
    ConfigBase c3( n2[i] );
    uint16_t ca_id, ca_pid;
    c3.ReadConfig( "CA_id", ca_id );
    c3.ReadConfig( "CA_pid", ca_pid );
    SetCA(ca_id, ca_pid);
  }

  return true;
}