示例#1
0
 public virtual void AddChannel(ChannelList list, ChannelInfo channel)
 {
     if (list == null)
       {
     warnings.AppendFormat("No list found to add channel '{0}'\r\n", channel);
     return;
       }
       string warning = list.AddChannel(channel);
       if (warning != null)
     this.Warnings.AppendLine(warning);
 }
示例#2
0
    internal static SatChannel CreateFromProxy(ChannelInfo proxy, DataRoot dataRoot, DataMapping mapping, int rawSize)
    {
      if (proxy.Transponder == null || proxy.Transponder.Satellite == null || proxy.Transponder.Satellite.LnbConfig == null)
        return null;

      byte[] rawData = mapping.Settings.GetBytes("newRecordTemplate");
      if (rawData == null)
        return null;

      mapping.SetDataPtr(rawData, 0);
      mapping.SetWord(_SatConfigIndex, proxy.Transponder.Satellite.LnbConfig.Id);
      mapping.SetWord(_TransponderIndex, proxy.Transponder.Id);
      mapping.SetWord(_ServiceId, proxy.ServiceId);
      var channel = new SatChannel(0, proxy.NewProgramNr, mapping, dataRoot);
      channel.Name = proxy.Name;
      return channel;
    }   
示例#3
0
    public string AddChannel(ChannelInfo ci)
    {
      IList<ChannelInfo> others;
      if (this.channelByUid.TryGetValue(ci.Uid, out others))
        ++duplicateUidCount;
      else
      {
        others = new List<ChannelInfo>();
        this.channelByUid.Add(ci.Uid, others);
      }
      others.Add(ci);

      string warning2 = null;
      bool isDupeProgNr = false;
      if (ci.OldProgramNr != -1)
      {
        ChannelInfo other;
        this.channelByProgNr.TryGetValue(ci.OldProgramNr, out other);
        if (other != null)
        {
          warning2 = string.Format(Resources.ChannelList_ProgramNrAssignedToMultipleChannels,
                                  this.ShortCaption, ci.OldProgramNr, other.RecordIndex, other.Name, ci.RecordIndex, ci.Name);
          ++duplicateProgNrCount;
          isDupeProgNr = true;
        }
      }

      if (!isDupeProgNr)
        this.channelByProgNr[ci.OldProgramNr] = ci;

      var lowerName = (ci.Name ?? "").ToLower().Trim();
      var byNameList = this.channelByName.TryGet(lowerName);
      if (byNameList == null)
      {
        byNameList = new List<ChannelInfo>();
        this.channelByName[lowerName] = byNameList;
      }
      byNameList.Add(ci);

      if (ci.ProgramNrPreset != 0)
        ++this.PresetProgramNrCount;

      this.Channels.Add(ci);
      
      return warning2;
    }
示例#4
0
 /// <summary>
 /// Set the number inside the favorites list to the same number as Pr#
 /// </summary>
 /// <param name="tvChannel"></param>
 private void ApplyPrNrToFavLists(ChannelInfo tvChannel)
 {
     var supMask = (int)this.DataRoot.SupportedFavorites;
       var refMask = (int)tvChannel.Favorites;
       for (int i = 0; supMask != 0; i++)
       {
     tvChannel.FavIndex[i] = (refMask & 0x01) == 0 ? -1 : tvChannel.OldProgramNr;
     supMask >>= 1;
     refMask >>= 1;
       }
 }
示例#5
0
 private void NavigateToChannel(ChannelInfo channel, GridView view)
 {
     if (channel == null) return;
       int rowHandle = view.GetRowHandle(this.currentChannelList.Channels.IndexOf(channel));
       if (view.IsValidRowHandle(rowHandle))
       {
     this.SelectFocusedRow(view, rowHandle);
     view.MakeRowVisible(rowHandle);
       }
 }
示例#6
0
 private void VerifyChannelNameModified(ChannelInfo info, string newName)
 {
     if (newName != info.Name)
     info.IsNameModified = true;
 }
示例#7
0
        /// <summary>
        /// Applies the ordering of a reference list to the TV list
        /// </summary>
        /// <param name="refDataRoot">object representing the whole reference list file</param>
        /// <param name="refList">the particular ChannelList to take the order from</param>
        /// <param name="tvList">the particular ChannelList to apply the order to</param>
        /// <param name="addProxyChannels">if true, a placeholder channel will be created in the tvList if there is no matching TV channel for a reference channel</param>
        /// <param name="positionOffset">can be used to shift the Pr# of the reference list so avoid conflicts with already assigned Pr# in the TV list</param>
        /// <param name="chanFilter">a function which is called for each channel in the reference list (with 2nd parameter=true) and TV list (2nd parameter=false) to determine if the channel is part of the reordering
        /// This is used to filter for analog/digital, radio/TV, antenna/cable/sat/ip
        /// </param>
        /// <param name="overwrite">controls whether Pr# will be reassigned to the reference channel when they are already in-use in the TV list</param>
        /// <param name="consecutive">when true, consecutive numbers will be used instead of the Pr# in the reference list when applying the order</param>
        public void ApplyReferenceList(DataRoot refDataRoot, ChannelList refList, ChannelList tvList, bool addProxyChannels = true, int positionOffset = 0, Func <ChannelInfo, bool, bool> chanFilter = null, bool overwrite = true, bool consecutive = false)
        {
            // create Hashtable for exact channel lookup
            // the UID of a TV channel list contains a source-indicator (Analog, Cable, Sat), which may be undefined in the reference list)
            var onidTsidSid = new Dictionary <long, List <ChannelInfo> >();

            foreach (var channel in tvList.Channels)
            {
                var key  = DvbKey(channel.OriginalNetworkId, channel.TransportStreamId, channel.ServiceId);
                var list = onidTsidSid.TryGet(key);
                if (list == null)
                {
                    list = new List <ChannelInfo>();
                    onidTsidSid.Add(key, list);
                }
                list.Add(channel);
            }

            var incNr = 1 + positionOffset;

            foreach (var refChannel in refList.Channels.OrderBy(ch => ch.OldProgramNr))
            {
                if (!(chanFilter?.Invoke(refChannel, true) ?? true))
                {
                    continue;
                }

                var tvChannels = tvList.GetChannelByUid(refChannel.Uid);

                // try to find matching channels based on ONID+TSID+SID
                if (tvChannels.Count == 0)
                {
                    var key = DvbKey(refChannel.OriginalNetworkId, refChannel.TransportStreamId, refChannel.ServiceId);
                    List <ChannelInfo> candidates;
                    if (key != 0 && onidTsidSid.TryGetValue(key, out candidates))
                    {
                        tvChannels = candidates;

                        // narrow the list down further when a transponder is also provided (i.e. the same TV channel can be received on multiple DVB-T frequencies)
                        if (tvChannels.Count > 1 && !string.IsNullOrEmpty(refChannel.ChannelOrTransponder))
                        {
                            candidates = tvChannels.Where(ch => ch.ChannelOrTransponder == refChannel.ChannelOrTransponder).ToList();
                            if (candidates.Count > 0)
                            {
                                tvChannels = candidates;
                            }
                        }
                    }
                }

                // try to find matching channels by name
                if (tvChannels.Count == 0 && !string.IsNullOrWhiteSpace(refChannel.Name))
                {
                    tvChannels = tvList.GetChannelByName(refChannel.Name).ToList();
                }

                // get the first unassigned channel from the candidates (e.g. when matching by non-unique names), or fall back to the first matching channel (e.g. by unique ID)
                ChannelInfo tvChannel = tvChannels.FirstOrDefault(c => c.GetPosition(0) == -1);
                if (tvChannel == null && tvChannels.Count > 0)
                {
                    tvChannel = tvChannels[0];
                }

                if (tvChannel != null)
                {
                    if (!(chanFilter?.Invoke(tvChannel, false) ?? true))
                    {
                        continue;
                    }

                    var newNr = consecutive ? incNr++ : refChannel.OldProgramNr + positionOffset;

                    // handle conflicts when the number is already in-use
                    var curChans = tvList.GetChannelByNewProgNr(newNr);
                    if (!overwrite && curChans.Any())
                    {
                        continue;
                    }
                    foreach (var chan in curChans)
                    {
                        chan.NewProgramNr = -1;
                    }

                    tvChannel.SetPosition(0, newNr);
                    if (refDataRoot.CanSkip && this.DataRoot.CanSkip)
                    {
                        tvChannel.Skip = refChannel.Skip;
                    }
                    if (refDataRoot.CanLock && this.DataRoot.CanLock)
                    {
                        tvChannel.Lock = refChannel.Lock;
                    }
                    if (refDataRoot.CanHide && this.DataRoot.CanHide)
                    {
                        tvChannel.Hidden = refChannel.Hidden;
                    }

                    //tvChannel.IsDeleted = refChannel.IsDeleted;
                    if ((tvChannel.SignalSource & SignalSource.Analog) != 0 && !string.IsNullOrEmpty(refChannel.Name))
                    {
                        tvChannel.Name           = refChannel.Name;
                        tvChannel.IsNameModified = true;
                    }

                    ApplyFavorites(refDataRoot, refChannel, tvChannel);
                }
                else if (addProxyChannels)
                {
                    tvChannel = new ChannelInfo(refChannel.SignalSource, refChannel.Uid, refChannel.OldProgramNr, refChannel.Name);
                    tvList.AddChannel(tvChannel);
                }
            }
        }
示例#8
0
 private int PhysicalChannelOrder(ChannelInfo channel)
 {
     return (channel.Transponder.Id << 16) + channel.ServiceId;
 }
示例#9
0
        private void ParseChannelInfoNodes(XmlNode itemNode, ChannelInfo ch, bool onlyNames = false)
        {
            bool hasHexName = false;
              int mapType = 0;
              foreach (XmlNode info in itemNode.ChildNodes)
              {
            if (onlyNames && info.LocalName != "vchName" && info.LocalName != "hexVchName")
              continue;

            switch (info.LocalName)
            {
            // common to ATV and DTV
              case "prNum":
            ch.OldProgramNr = int.Parse(info.InnerText) & 0x3FFF;
            break;
              case "vchName":
            // In old file format versions, this field contains binary data stuffed into UTF8 envelopes. that data is correct
            // In newer file formats, this field contains plain text but fails to hold localized characters. The hexVchName field, if present, contains the correct data then.
            if (!hasHexName)
              ch.Name = ParseName(info.InnerText);
            break;
              case "sourceIndex":
            var source = int.Parse(info.InnerText);
            if (source == 2)
              ch.SignalSource |= SignalSource.Cable;
            else if (source == 7)
              ch.SignalSource |= SignalSource.Sat;
            else
              ch.SignalSource |= SignalSource.Antenna;
            break;
              case "mapType":
            mapType = int.Parse(info.InnerText);
            break;
              case "mapAttr":
            if (mapType == 1)
              ch.Favorites = (Favorites) int.Parse(info.InnerText);
            break;
              case "isBlocked":
            ch.Lock = int.Parse(info.InnerText) == 1;
            break;
              case "isSkipped":
            ch.Skip = int.Parse(info.InnerText) == 1;
            break;

            // ATV
              case "pllData":
            ch.FreqInMhz = (decimal) int.Parse(info.InnerText)/20;
            break;

            // DTV
              case "original_network_id":
            ch.OriginalNetworkId = int.Parse(info.InnerText);
            break;
              case "transport_id":
            ch.TransportStreamId = int.Parse(info.InnerText);
            break;
              case "service_id":
            ch.ServiceId = int.Parse(info.InnerText);
            break;
              case "serviceType":
            ch.ServiceType = int.Parse(info.InnerText);
            ch.SignalSource |= LookupData.Instance.IsRadioOrTv(ch.ServiceType);
            break;
              case "frequency":
            ch.FreqInMhz = int.Parse(info.InnerText);
            if ((ch.SignalSource & SignalSource.Sat) == 0)
              ch.FreqInMhz /= 1000;
            break;
              case "isInvisable": // that spelling error is part of the XML
            ch.Hidden = int.Parse(info.InnerText) == 1;
            break;
              case "isNumUnSel":
            // ?
            break;
              case "isDisabled":
            ch.IsDeleted = int.Parse(info.InnerText) != 0;
            break;
              case "usSatelliteHandle":
            int satIndex = int.Parse(info.InnerText);
            string satPos = this.satPositionByIndex.TryGet(satIndex);
            ch.SatPosition = satPos ?? satIndex.ToString(); // fallback to ensure unique UIDs
            ch.Satellite = satPos;
            break;

            // not present in all XML files. if present, the <vchName> might be empty or corrupted
              case "hexVchName":
            var bytes = Tools.HexDecode(info.InnerText);
            string longName, shortName;
            dvbStringDecoder.GetChannelNames(bytes, 0, bytes.Length, out longName, out shortName);
            ch.Name = longName;
            ch.ShortName = shortName;
            hasHexName = true;
            break;
            }
              }
        }
示例#10
0
 public void RemoveChannel(ChannelInfo channel)
 {
     this.channels.Remove(channel);
       var list = this.channelByUid.TryGet(channel.Uid);
       if (list != null && list.Contains(channel))
     list.Remove(channel);
       list = this.channelByName.TryGet(channel.Name);
       if (list != null && list.Contains(channel))
     list.Remove(channel);
       var chan = this.channelByProgNr.TryGet(channel.OldProgramNr);
       if (ReferenceEquals(chan, channel))
     this.channelByProgNr.Remove(channel.OldProgramNr);
 }
示例#11
0
 private int ChannelComparerForSortingByName(ChannelInfo channel1, ChannelInfo channel2)
 {
     return channel1.Name.CompareTo(channel2.Name);
 }
示例#12
0
 private int GetNewPogramNr(ChannelInfo appChannel, ref int maxPrNr)
 {
     int prNr = appChannel.NewProgramNr;
       if (prNr > maxPrNr)
     maxPrNr = prNr;
       if (prNr == -1)
       {
     if (appChannel.OldProgramNr != -1 && this.unsortedChannelMode != UnsortedChannelMode.MarkDeleted)
       prNr = ++maxPrNr;
       }
       return prNr;
 }
示例#13
0
    private void LoadSvlData(SQLiteCommand cmd, int tableNr, string joinTable, string joinFields, Action<ChannelInfo, SQLiteDataReader, int> enhanceChannelInfo)
    {
      if (!this.tableNames.Contains(joinTable.Replace("#", tableNr.ToString())))
        return;

      cmd.CommandText = $"select svl_#.svl_rec_id, channel_id, svl_#.tsl_rec_id, e_serv_type, ac_name, nw_mask, prog_id, `t_desc.e_bcst_medium` {joinFields}"
        + $" from svl_# inner join {joinTable} on {joinTable}.svl_rec_id=svl_#.svl_rec_id inner join tsl_# on tsl_#.tsl_rec_id=svl_#.tsl_rec_id";
      cmd.CommandText = cmd.CommandText.Replace("#", tableNr.ToString());
      using (var r = cmd.ExecuteReader())
      {
        while (r.Read())
        {
          var id = ((long)tableNr << 32) | (uint)r.GetInt32(0);
          var prNr = (int)((uint)r.GetInt32(1)) >> 18;
          var trans = this.DataRoot.Transponder.TryGet(r.GetInt32(2));
          var stype = (ServiceType) r.GetInt32(3);
          var name = r.GetString(4);
          var nwMask = (NwMask)r.GetInt32(5);
          var sid = r.GetInt32(6);
          var bmedium = (BroadcastMedium)r.GetInt32(7);

          var ssource = DetermineSignalSource(bmedium, stype);
          var ci = new ChannelInfo(ssource, id, prNr, name);
          if (trans != null)
          {
            ci.Transponder = trans;
            ci.OriginalNetworkId = trans.OriginalNetworkId;
            ci.TransportStreamId = trans.TransportStreamId;
            ci.SymbolRate = trans.SymbolRate;
            ci.FreqInMhz = trans.FrequencyInMhz;
            ci.Satellite = trans.Satellite?.ToString();
          }

          ci.ServiceId = sid;

          //ci.Skip = (nwMask & NwMask.Active) == 0;
          ci.Lock = (nwMask & NwMask.Lock) != 0;
          ci.Hidden = (nwMask & NwMask.Visible) == 0;
          ci.Favorites |= (Favorites) ((int)(nwMask & (NwMask.Fav1 | NwMask.Fav2 | NwMask.Fav3 | NwMask.Fav4)) >> 4);

          if (stype == ServiceType.Radio)
            ci.ServiceTypeName = "Radio";
          else if (stype == ServiceType.Tv)
            ci.ServiceTypeName = "TV";
          else if (stype == ServiceType.App)
            ci.ServiceTypeName = "Data";

          enhanceChannelInfo(ci, r, 8);

          var list = this.channelLists[tableNr - 1];
          this.DataRoot.AddChannel(list, ci);
        }
      }
    }
示例#14
0
        private ChannelInfo ReadChannel(SignalSource source, int index, int nameLength)
        {
            ChannelInfo ci = new ChannelInfo(source, index, 0, "");
              //ci.RecordIndex = svlMapping.GetWord("RecordId");
              ci.OldProgramNr = svlMapping.GetWord("ChannelId") >> 2;

              var nwMask = svlMapping.GetDword("NwMask");
              ci.Skip = (nwMask & svlMapping.Settings.GetInt("NwMask_Skip")) != 0;
              ci.Lock = (nwMask & svlMapping.Settings.GetInt("NwMask_Lock")) != 0;
              ci.Hidden = (nwMask & svlMapping.Settings.GetInt("NwMask_Hide")) != 0;
              for (int i = 0; i < 3; i++)
              {
            bool isFav = (nwMask & svlMapping.Settings.GetInt("NwMask_Fav" + (i + 1))) != 0;
            if (isFav)
              ci.Favorites |= (Favorites) (1 << i);
              }

              var fieldMask = svlMapping.GetDword("HashcodeFieldMask");

              if ((fieldMask & svlMapping.Settings.GetInt("HashcodeFieldMask_Name")) != 0)
              {
            ci.Name = svlMapping.GetString("Name", nameLength);
            int term = ci.Name.IndexOf('\0');
            if (term >= 0)
              ci.Name = ci.Name.Substring(0, term);
              }

              var serviceType = svlMapping.GetByte("ServiceType");
              if (serviceType == 1)
              {
            ci.SignalSource |= SignalSource.Tv;
            ci.ServiceTypeName = "TV";
              }
              else if (serviceType == 2)
              {
            ci.SignalSource |= SignalSource.Radio;
            ci.ServiceTypeName = "Radio";
              }
              else
              {
            ci.ServiceTypeName = "Data";
              }

              if ((fieldMask & svlMapping.Settings.GetInt("HashcodeFieldMask_TslRecId")) != 0)
              {
            int transpTableId = svlMapping.GetByte("TslTableId");
            int transpRecordId = svlMapping.GetByte("TslRecordId");
            var transpId = (transpTableId << 16) + transpRecordId;
            var transp = this.transponder.TryGet(transpId);
            if (transp != null)
            {
              ci.Transponder = transp;
              ci.FreqInMhz = transp.FrequencyInMhz;
              ci.SymbolRate = transp.SymbolRate;
            }
              }

              if ((fieldMask & svlMapping.Settings.GetInt("HashcodeFieldMask_BroadcastType")) != 0)
              {
            var bcastType = svlMapping.GetByte("BroadcastType");
            if (bcastType == 1)
              ReadAnalogData(ci);
            else if (bcastType == 2)
              ReadDvbData(ci);
              }

              ci.Encrypted = (fieldMask & svlMapping.Settings.GetInt("HashcodeFieldMask_Encrypted")) != 0;

              //ci.AddDebug("u1=");
              //ci.AddDebug(svlMapping.Data, svlMapping.BaseOffset + 2, 2);
              //ci.AddDebug("u2=");
              //ci.AddDebug(svlMapping.Data, svlMapping.BaseOffset + 4, 2);
              //ci.AddDebug(", hash=");
              //ci.AddDebug(svlMapping.Data, svlMapping.BaseOffset + 8, 2);
              //ci.AddDebug(", nw=");
              //ci.AddDebug(svlMapping.Data, svlMapping.BaseOffset + 12, 4);
              //ci.AddDebug(", o1=");
              //ci.AddDebug(svlMapping.Data, svlMapping.BaseOffset + 16, 4);
              ci.AddDebug(", o2=");
              ci.AddDebug(svlMapping.Data, svlMapping.BaseOffset + 20, 4);
              ci.AddDebug("progId=");
              ci.AddDebug(svlMapping.Data, svlMapping.BaseOffset + 24, 4);

              return ci;
        }
示例#15
0
 private void ReadAnalogData(ChannelInfo ci)
 {
 }
示例#16
0
        private void ReadDvbData(ChannelInfo ci)
        {
            var mask = dvbMapping.GetDword("LinkageMask");
              var tsFlag = dvbMapping.Settings.GetInt("LinkageMask_Ts");

              if ((mask & tsFlag) != 0)
              {
            ci.OriginalNetworkId = dvbMapping.GetWord("Onid");
            ci.TransportStreamId = dvbMapping.GetWord("Tsid");
            ci.ServiceId = dvbMapping.GetWord("Ssid");
              }
              //ci.Encrypted = dvbMapping.GetByte("Encrypted") != 0;

              if ((ci.SignalSource & SignalSource.DvbT) == SignalSource.DvbT)
            ci.ChannelOrTransponder = LookupData.Instance.GetDvbtTransponder(ci.FreqInMhz).ToString();

              ci.ShortName = dvbMapping.GetString("ShortName", dvbMapping.Settings.GetInt("ShortName_Size"));
        }
示例#17
0
    private void UpdateChannel(SQLiteCommand cmd, ChannelInfo ci)
    {
      int x = (int)((ulong)ci.RecordIndex >> 32);   // the table number is kept in the higher 32 bits
      int id = (int)(ci.RecordIndex & 0xFFFFFFFF);  // the record id is kept in the lower 32 bits

      var resetFlags = NwMask.Fav1 | NwMask.Fav2 | NwMask.Fav3 | NwMask.Fav4 | NwMask.Lock | NwMask.Visible;
      var setFlags = (NwMask)(((int)ci.Favorites & 0x0F) << 4);
      if (ci.Lock) setFlags |= NwMask.Lock;
      if (!ci.Hidden) setFlags |= NwMask.Visible;

      //if (ci.NewProgramNr >= 0)
      {
        cmd.CommandText = $"update svl_{x} set channel_id=(channel_id&{0xFFFC})|@chnr, name=cast(@name as varchar), " + 
          $"option_mask=option_mask|{(int)(OptionMask.ChNumEdited|OptionMask.NameEdited)}, nw_mask=(nw_mask&@resetFlags)|@setFlags where svl_rec_id=@id";
        cmd.Parameters.Clear();
        cmd.Parameters.Add("@id", DbType.Int32);
        cmd.Parameters.Add("@chnr", DbType.Int32);
        cmd.Parameters.Add("@name", DbType.Binary);
        cmd.Parameters.Add("@resetFlags", DbType.Int32);
        cmd.Parameters.Add("@setFlags", DbType.Int32);
        cmd.Parameters["@id"].Value = id;
        cmd.Parameters["@chnr"].Value = ci.NewProgramNr << 18;
        cmd.Parameters["@name"].Value = Encoding.BigEndianUnicode.GetBytes(ci.Name);
        cmd.Parameters["@resetFlags"].Value = ~(int)resetFlags;
        cmd.Parameters["@setFlags"].Value = (int)setFlags;
        cmd.ExecuteNonQuery();
      }
      //else
      //{
      //  cmd.CommandText = $"update svl_{x} set nw_mask=nw_mask | " + ((int)OptionMask.DeletedByUser) + " where svl_rec_id=@id";
      //  cmd.Parameters.Clear();
      //  cmd.Parameters.Add("@id", DbType.Int32);
      //  cmd.Parameters.Add("@fav", DbType.Int32);
      //  cmd.Parameters["@id"].Value = id;
      //  cmd.Parameters["@fav"].Value = ((int)ci.Favorites & 0x0F) << 4;
      //  cmd.ExecuteNonQuery();
      //}
    }
示例#18
0
        private string ChanSortCriteria(ChannelInfo channel)
        {
            // explicitly sorted
              if (channel.GetPosition(this.SubListIndex) != -1)
            return channel.GetPosition(this.SubListIndex).ToString("d4");

              // eventually hide unsorted channels
              if (this.unsortedChannelMode == UnsortedChannelMode.MarkDeleted)
            return "Z";

              // eventually append in old order
              if (this.unsortedChannelMode == UnsortedChannelMode.AppendInOrder)
            return "B" + channel.OldProgramNr.ToString("d4");

              // sort alphabetically, with "." and "" on the bottom
              if (channel.Name == ".")
            return "B";
              if (channel.Name == "")
            return "C";
              return "A" + channel.Name;
        }
示例#19
0
    private void ApplyFlags(ChannelInfo channel, string flags)
    {
      channel.Lock = false;
      channel.Skip = false;
      channel.Hidden = false;

      foreach (char c in flags)
      {
        switch (c)
        {
          case '1': channel.Favorites |= Favorites.A; break;
          case '2': channel.Favorites |= Favorites.B; break;
          case '3': channel.Favorites |= Favorites.C; break;
          case '4': channel.Favorites |= Favorites.D; break;
          case '5': channel.Favorites |= Favorites.E; break;
          case 'L': channel.Lock = true; break;
          case 'S': channel.Skip = true; break;
          case 'H': channel.Hidden = true; break;
          case 'D': channel.IsDeleted = true; break;
        }
      }
    }
示例#20
0
        public void ApplyReferenceList(DataRoot refDataRoot)
        {
            foreach (var channelList in this.DataRoot.ChannelLists)
              {
            foreach (var channel in channelList.Channels)
              channel.SetPosition(this.SubListIndex, -1);
              }

              StringBuilder log = new StringBuilder();
              foreach (var refList in refDataRoot.ChannelLists)
              {
            var tvList = this.DataRoot.GetChannelList(refList.SignalSource);
            if (tvList == null)
            {
              log.AppendFormat("Skipped reference list {0}\r\n", refList.ShortCaption);
              continue;
            }
            foreach (var refChannel in refList.Channels)
            {
              var tvChannels = tvList.GetChannelByUid(refChannel.Uid);
              ChannelInfo tvChannel = tvChannels.FirstOrDefault(c => c.GetPosition(this.SubListIndex) == -1);
              if (tvChannel != null)
              {
            tvChannel.SetPosition(this.SubListIndex, refChannel.OldProgramNr);
            tvChannel.Favorites = refChannel.Favorites & DataRoot.SupportedFavorites;
            tvChannel.Skip = refChannel.Skip;
            tvChannel.Lock = refChannel.Lock;
            tvChannel.Hidden = refChannel.Hidden;
            tvChannel.IsDeleted = refChannel.IsDeleted;
            if ((tvChannel.SignalSource & SignalSource.Analog) != 0)
            {
              tvChannel.Name = refChannel.Name;
              tvChannel.IsNameModified = true;
            }
            if (this.DataRoot.SortedFavorites)
            {
              if (refDataRoot.SortedFavorites)
              {
                var c = Math.Min(refChannel.FavIndex.Count, tvChannel.FavIndex.Count);
                for (int i = 0; i < c; i++)
                  tvChannel.FavIndex[i] = refChannel.FavIndex[i];
              }
              else
              {
                this.ApplyPrNrToFavLists(tvChannel);
              }
            }
              }
              else
              {
            tvChannel = new ChannelInfo(refChannel.SignalSource, refChannel.Uid, refChannel.OldProgramNr,
                                        refChannel.Name);
            tvList.AddChannel(tvChannel);
              }
            }
              }
        }
示例#21
0
 private string EncodeFavoritesAndFlags(ChannelInfo channel)
 {
   StringBuilder sb = new StringBuilder();
   if ((channel.Favorites & Favorites.A) != 0) sb.Append('1');
   if ((channel.Favorites & Favorites.B) != 0) sb.Append('2');
   if ((channel.Favorites & Favorites.C) != 0) sb.Append('3');
   if ((channel.Favorites & Favorites.D) != 0) sb.Append('4');
   if ((channel.Favorites & Favorites.E) != 0) sb.Append('5');
   if (channel.Lock) sb.Append('L');
   if (channel.Skip) sb.Append('S');
   if (channel.Hidden) sb.Append('H');
   if (channel.IsDeleted) sb.Append('D');
   return sb.ToString();
 }
示例#22
0
    private void ReadChannel(string line)
    {
      var parts = CsvFile.Parse(line, ',');
      if (parts.Count < 5) return;
      int programNr;
      if (!int.TryParse(parts[1], out programNr)) return;
      string uid = parts[3];
      if (uid.StartsWith("S")) // remove satellite orbital position from UID ... not all TV models provide this information
        uid = "S" + uid.Substring(uid.IndexOf('-'));
      SignalSource signalSource = GetSignalSource(ref programNr, uid, parts);
      if (signalSource == 0)
        return;

      string name = parts[4];
      ChannelList channelList = this.GetInitiallyClearedChannelList(signalSource);
      if (channelList == null)
        return;

      IEnumerable<ChannelInfo> channels = FindChannels(channelList, name, uid);
      var channel = channels == null ? null : channels.FirstOrDefault(c => c.NewProgramNr == -1);
      if (channel != null)
      {
        if (!this.addChannels)
        {
          channel.NewProgramNr = programNr;
          if ((channel.SignalSource & SignalSource.Analog) != 0)
          {
            channel.Name = name;
            channel.IsNameModified = true;
          }
          if (parts.Count >= 7)
            ApplyFlags(channel, parts[6]);
        }
      }
      else if (parts.Count >= 6) // create proxy channel when using the new ref-list format
      {        
        channel = new ChannelInfo(signalSource, uid, programNr, name);
        if (addChannels)
        {
          channel.NewProgramNr = -1;
          channel.OldProgramNr = programNr;
        }
        channelList.AddChannel(channel);
      }
    }
示例#23
0
 private ChannelInfo CreateChannelFromProxy(ChannelInfo proxy)
 {
     if ((proxy.SignalSource & SignalSource.Sat) != 0)
       {
     var mapping = this.GetDvbsChannelMapping();
     var channel = SatChannel.CreateFromProxy(proxy, this.DataRoot, mapping, this.satConfig.dvbsChannelLength);
     if (channel != null)
       this.mustReorganizeDvbs = true;
     return channel;
       }
       return null;
 }
示例#24
0
 private IComparable SortCriteria(ChannelInfo a)
 {
   return this.orderByName ? (IComparable) a.Name : a.GetPosition(this.subListIndex);
 }
示例#25
0
 private int ChannelComparerForSortingByName(ChannelInfo channel1, ChannelInfo channel2)
 {
     return(channel1.Name.CompareTo(channel2.Name));
 }