/// <summary> /// Determines whether the specified user is owner of this card /// </summary> /// <param name="user">The user.</param> /// <returns> /// <c>true</c> if the specified user is owner; otherwise, <c>false</c>. /// </returns> public bool IsOwner(IUser user) { if (_cardHandler.IsLocal == false) { try { RemoteControl.HostName = _cardHandler.DataBaseCard.ReferencedServer().HostName; return(RemoteControl.Instance.IsOwner(_cardHandler.DataBaseCard.IdCard, user)); } catch (Exception) { Log.Error("card: unable to connect to slave controller at:{0}", _cardHandler.DataBaseCard.ReferencedServer().HostName); return(false); } } ITvCardContext context = _cardHandler.Card.Context as ITvCardContext; return(context.IsOwner(user)); }
private bool BeforeTune(IChannel channel, ref IUser user, out TvResult result) { result = TvResult.UnknownError; //@FIX this fails for back-2-back recordings //if (CurrentDbChannel(ref user) == idChannel && idChannel >= 0) //{ // return true; //} Log.Debug("card: user: {0}:{1}:{2} tune {3}", user.Name, user.CardId, user.SubChannel, channel.ToString()); _cardHandler.Card.CamType = (CamType)_cardHandler.DataBaseCard.CamType; _cardHandler.SetParameters(); //check if transponder differs ITvCardContext context = _cardHandler.Card.Context as ITvCardContext; if (_cardHandler.Card.SubChannels.Length > 0) { if (IsTunedToTransponder(channel) == false) { if (context.IsOwner(user) || user.IsAdmin) { Log.Debug("card: to different transponder"); //remove all subchannels, except for this user... IUser[] users = context.Users; for (int i = 0; i < users.Length; ++i) { if (users[i].Name != user.Name) { Log.Debug(" stop subchannel: {0} user: {1}", i, users[i].Name); //fix for b2b mantis; http://mantis.team-mediaportal.com/view.php?id=1112 if (users[i].IsAdmin) // if we are stopping an on-going recording/schedule (=admin), we have to make sure that we remove the schedule also. { Log.Debug("user is scheduler: {0}", users[i].Name); int recScheduleId = RemoteControl.Instance.GetRecordingSchedule(users[i].CardId, users[i].IdChannel); if (recScheduleId > 0) { Schedule schedule = Schedule.Retrieve(recScheduleId); Log.Info("removing schedule with id: {0}", schedule.IdSchedule); RemoteControl.Instance.StopRecordingSchedule(schedule.IdSchedule); schedule.Delete(); } } else { _cardHandler.Card.FreeSubChannel(users[i].SubChannel); context.Remove(users[i]); } } } } else { Log.Debug("card: user: {0} is not the card owner. Cannot switch transponder", user.Name); result = TvResult.NotTheOwner; return(false); } } else // same transponder, free previous subchannel before tuning.. { _cardHandler.Card.FreeSubChannel(user.SubChannel); } } if (OnBeforeTuneEvent != null) { OnBeforeTuneEvent(_cardHandler); } TvCardBase card = _cardHandler.Card as TvCardBase; if (card != null) { card.AfterTuneEvent -= new TvCardBase.OnAfterTuneDelegate(Card_OnAfterTuneEvent); card.AfterTuneEvent += new TvCardBase.OnAfterTuneDelegate(Card_OnAfterTuneEvent); } else { HybridCard hybridCard = _cardHandler.Card as HybridCard; if (hybridCard != null) { hybridCard.AfterTuneEvent = new TvCardBase.OnAfterTuneDelegate(Card_OnAfterTuneEvent); } } result = TvResult.Succeeded; return(true); }