Пример #1
0
  /// <summary>
  /// saves last active module.
  /// </summary>
  private void SaveLastActiveModule()
  {
    // persist the currently selected module to XML for later use.
    Log.Debug("Main: SaveLastActiveModule - enabled {0}", _showLastActiveModule);
    bool currentmodulefullscreen = Currentmodulefullscreen();
    string currentmodulefullscreenstate = GUIPropertyManager.GetProperty("#currentmodulefullscreenstate");
    string currentmoduleid = GUIPropertyManager.GetProperty("#currentmoduleid");

    if (_showLastActiveModule && !Utils.IsGUISettingsWindow(GUIWindowManager.GetPreviousActiveWindow()))
    {
      using (Settings xmlreader = new MPSettings())
      {
        if (currentmodulefullscreen)
        {
          currentmoduleid = Convert.ToString(GUIWindowManager.GetPreviousActiveWindow());
        }
        
        if (!currentmodulefullscreen && currentmodulefullscreenstate == "True")
        {
          currentmodulefullscreen = true;
        }

        if (currentmoduleid.Length == 0)
        {
          currentmoduleid = "0";
        }

        string section;
        switch (GUIWindowManager.ActiveWindow)
        {
          case (int)GUIWindow.Window.WINDOW_PICTURES:
            section = "pictures";
            break;

          case (int)GUIWindow.Window.WINDOW_MUSIC:
            section = "music";
             break;

          case (int)GUIWindow.Window.WINDOW_VIDEOS:
            section = "movies";
            break;

          default:
            section = "";
            break;
        }

        bool rememberLastFolder = xmlreader.GetValueAsBool(section, "rememberlastfolder", false);
        string lastFolder = xmlreader.GetValueAsString(section, "lastfolder", "");

        var virtualDir = new VirtualDirectory();
        virtualDir.LoadSettings(section);

        int pincode;
        bool lastFolderPinProtected = virtualDir.IsProtectedShare(lastFolder, out pincode);
        if (rememberLastFolder && lastFolderPinProtected)
        {
          lastFolder = "root";
          xmlreader.SetValue(section, "lastfolder", lastFolder);
          Log.Debug("Main: reverting to root folder, pin protected folder was open, SaveLastFolder {0}", lastFolder);
        }

        xmlreader.SetValue("general", "lastactivemodule", currentmoduleid);
        xmlreader.SetValueAsBool("general", "lastactivemodulefullscreen", currentmodulefullscreen);
        Log.Debug("Main: SaveLastActiveModule - module {0}", currentmoduleid);
        Log.Debug("Main: SaveLastActiveModule - fullscreen {0}", currentmodulefullscreen);
      }
    }
  }
Пример #2
0
    protected override void LoadSettings()
    {
      base.LoadSettings();
      using (Profile.Settings xmlreader = new Profile.MPSettings())
      {
        currentLayout = (Layout) xmlreader.GetValueAsInt(SerializeName, "layout", (int) Layout.List);
        m_bSortAscending = xmlreader.GetValueAsBool(SerializeName, "sortasc", true);
        VideoState.StartWindow = xmlreader.GetValueAsInt("movies", "startWindow", GetID);
        VideoState.View = xmlreader.GetValueAsString("movies", "startview", "369");

        // Prevent unaccesible My Videos from corrupted config
        if (!IsVideoWindow(VideoState.StartWindow))
        {
          VideoState.StartWindow = GetID;
          VideoState.View = "369";
        }

        _addVideoFilesToDb = xmlreader.GetValueAsBool("gui", "addVideoFilesToDb", false);
        _isFuzzyMatching = xmlreader.GetValueAsBool("movies", "fuzzyMatching", false);
        _scanSkipExisting = xmlreader.GetValueAsBool("moviedatabase", "scanskipexisting", false);
        _getActors = xmlreader.GetValueAsBool("moviedatabase", "getactors", true);
        _markWatchedFiles = xmlreader.GetValueAsBool("movies", "markwatched", true);
        //_eachFolderIsMovie = xmlreader.GetValueAsBool("movies", "eachFolderIsMovie", false);
        _fileMenuEnabled = xmlreader.GetValueAsBool("filemenu", "enabled", true);
        _fileMenuPinCode = Util.Utils.DecryptPassword(xmlreader.GetValueAsString("filemenu", "pincode", string.Empty));
        _howToPlayAll = xmlreader.GetValueAsInt("movies", "playallinfolder", 3);
        _watchedPercentage = xmlreader.GetValueAsInt("movies", "playedpercentagewatched", 95);
        _videoInfoInShare = xmlreader.GetValueAsBool("moviedatabase", "movieinfoshareview", false);
        _BDInternalMenu = xmlreader.GetValueAsBool("bdplayer", "useInternalBDPlayer", true);

        _virtualDirectory = VirtualDirectories.Instance.Movies;
		    // External player
        _useInternalVideoPlayer = xmlreader.GetValueAsBool("movieplayer", "internal", true);
        _useInternalDVDVideoPlayer = xmlreader.GetValueAsBool("dvdplayer", "internal", true);
        _externalPlayerExtensions = xmlreader.GetValueAsString("movieplayer", "extensions", "");

        _wolTimeout = xmlreader.GetValueAsInt("WOL", "WolTimeout", 10);
        _wolResendTime = xmlreader.GetValueAsInt("WOL", "WolResendTime", 1);

        if (_virtualStartDirectory == string.Empty)
        {
          if (_virtualDirectory.DefaultShare != null)
          {
            if (_virtualDirectory.DefaultShare.IsFtpShare)
            {
              //remote:hostname?port?login?password?folder
              _currentFolder = _virtualDirectory.GetShareRemoteURL(_virtualDirectory.DefaultShare);
              _virtualStartDirectory = _currentFolder;
            }
            else
            {
              _currentFolder = _virtualDirectory.DefaultShare.Path;
              _virtualStartDirectory = _virtualDirectory.DefaultShare.Path;
            }
          }
        }

        _askBeforePlayingDVDImage = xmlreader.GetValueAsBool("daemon", "askbeforeplaying", false);

        if (xmlreader.GetValueAsBool("movies", "rememberlastfolder", false))
        {
          string lastFolder = xmlreader.GetValueAsString("movies", "lastfolder", _currentFolder);
          if (VirtualDirectory.IsImageFile(Path.GetExtension(lastFolder)))
          {
            lastFolder = "root";
          }
          if (lastFolder != "root")
          {
            _currentFolder = lastFolder;
          }
        }

        _switchRemovableDrives = xmlreader.GetValueAsBool("movies", "SwitchRemovableDrives", true);
        _useOnlyNfoScraper = xmlreader.GetValueAsBool("moviedatabase", "useonlynfoscraper", false);
        _doNotUseDatabase = xmlreader.GetValueAsBool("moviedatabase", "donotusedatabase", false);

      }

      if (_currentFolder.Length > 0 && _currentFolder == _virtualStartDirectory)
      {
        VirtualDirectory vDir = new VirtualDirectory();
        vDir.LoadSettings("movies");
      }
    }
Пример #3
0
    private void SetMovieIDProperty(string file, bool isFolder)
    {
      VirtualDirectory vDir = new VirtualDirectory();
      int pin = 0;
      vDir.LoadSettings("movies");

      if (isFolder && !vDir.IsProtectedShare(file, out pin))
      {
        ArrayList mList = new ArrayList();
        VideoDatabase.GetMoviesByPath(file, ref mList);
        
        if (mList.Count > 0)
        {
          Random rnd = new Random();
          int r = rnd.Next(mList.Count);
          IMDBMovie movieDetails = (IMDBMovie)mList[r];
          mList.Clear();
          VideoDatabase.GetFilesForMovie(movieDetails.ID, ref mList);

          if (mList.Count > 0 && System.IO.File.Exists(mList[0].ToString()))
          {
            GUIPropertyManager.SetProperty("#movieid", movieDetails.ID.ToString());
          }
          else
          {
            GUIPropertyManager.SetProperty("#movieid", "-1");
          }
        }
        else
        {
          GUIPropertyManager.SetProperty("#movieid", "-1");
        }
      }
      else if (isFolder && vDir.IsProtectedShare(file, out pin))
      {
        GUIPropertyManager.SetProperty("#movieid", "-1");
      }
      else
      {
        GUIPropertyManager.SetProperty("#movieid", ID.ToString());
      }
    }
Пример #4
0
    private IMDBMovie GetRandomMovie(ArrayList mList)
    {
      try
      {
        ArrayList movies = new ArrayList(mList);
        ArrayList pShares = new ArrayList();

        foreach (string p in _protectedShares)
        {
          char[] splitter = { '|' };
          string[] pin = p.Split(splitter);
          // Only add shares which are unlocked
          if (Convert.ToInt32(pin[0]) == _currentPin)
          {
            pShares.Add(pin[1]);
          }
        }

        // Do not show fanart for unlocked protected movies
        foreach (IMDBMovie m in movies)
        {
          ArrayList files = new ArrayList();
          VideoDatabase.GetFilesForMovie(m.ID, ref files);

          if (string.IsNullOrEmpty(files[0].ToString()))
          {
            continue;
          }

          string directory = Path.GetDirectoryName(files[0].ToString());

          if (string.IsNullOrEmpty(directory))
            continue;

          VirtualDirectory vDir = new VirtualDirectory();
          vDir.LoadSettings("movies");
          int pincode = 0;
          bool folderPinProtected = vDir.IsProtectedShare(directory, out pincode);

          // No PIN entered, remove all protected conetnt
          if (folderPinProtected && !_ageConfirmed)
          {
            mList.Remove(m);
            continue;
          }

          // PIN entered, check for corresponding shares
          if (folderPinProtected && _ageConfirmed)
          {
            bool found = false;

            foreach (string share in pShares)
            {
              if (directory.ToLowerInvariant().Contains(share.ToLowerInvariant()))
              {
                // Movie belongs to unlocked share
                found = true;
                break;
              }
            }
            // If movie is not from unlocked shares, don't show fanart
            if (!found)
            {
              mList.Remove(m);
            }
          }
        }

        if (mList.Count > 0)
        {
          Random rnd = new Random();
          int r = rnd.Next(mList.Count);
          IMDBMovie movieDetails = (IMDBMovie)mList[r];
          return movieDetails;
        }
        else
        {
          return null;
        }
      }
      catch (Exception)
      {
        return null;
      }
    }
Пример #5
0
    protected override void LoadDirectory(string strNewDirectory)
    {
      GUIWaitCursor.Show();
      currentFolder = strNewDirectory;
      GUIControl.ClearControl(GetID, facadeLayout.GetID);
      ArrayList itemlist = new ArrayList();
      ArrayList movies = new ArrayList();

      if (_searchMovie)
      {
        string sql = "SELECT DISTINCT " +
                     "movieinfo.idMovie," +
                     "movieinfo.idDirector," +
                     "movieinfo.strDirector," +
                     "movieinfo.strPlotOutline," +
                     "movieinfo.strPlot," +
                     "movieinfo.strTagLine," +
                     "movieinfo.strVotes," +
                     "movieinfo.fRating," +
                     "movieinfo.strCast," +
                     "movieinfo.strCredits," +
                     "movieinfo.iYear," +
                     "movieinfo.strGenre," +
                     "movieinfo.strPictureURL," +
                     "movieinfo.strTitle," +
                     "movieinfo.IMDBID," +
                     "movieinfo.mpaa," +
                     "movieinfo.runtime," +
                     "movieinfo.iswatched," +
                     "movieinfo.strUserReview," +
                     "movieinfo.strFanartURL," +
                     "movieinfo.dateAdded," +
                     "movieinfo.dateWatched," +
                     "movieinfo.studios," +
                     "movieinfo.country," +
                     "movieinfo.language," +
                     "movieinfo.lastupdate, " +
			               "movieinfo.strSortTitle " +
                     "FROM movieinfo " +
                     "INNER JOIN actorlinkmovie ON actorlinkmovie.idMovie = movieinfo.idMovie " +
                     "INNER JOIN actors ON actors.idActor = actorlinkmovie.idActor " +
                     "WHERE "+ _searchMovieDbField + " LIKE '%" + _searchMovieString + "%' " +
                     "ORDER BY movieinfo.strTitle ASC";

        VideoDatabase.GetMoviesByFilter(sql, out movies, false, true, false, false);
      }
      else if (_searchActor && handler.CurrentLevelWhere != "title")
      {
        string sql = string.Empty;
        
        if (handler.CurrentLevelWhere == "director")
        {
          sql = "SELECT idActor, strActor, imdbActorId FROM actors INNER JOIN movieinfo ON movieinfo.idDirector = actors.idActor WHERE strActor LIKE '%" 
                + _searchActorString + 
                "%' ORDER BY strActor ASC";
        }
        else
        {
          sql = "SELECT * FROM actors WHERE strActor LIKE '%" + _searchActorString + "%' ORDER BY strActor ASC";
        }
        
        VideoDatabase.GetMoviesByFilter(sql, out movies, true, false, false, false);
      }
      else
      {
        movies = ((VideoViewHandler)handler).Execute();
      }

      GUIControl.ClearControl(GetID, facadeLayout.GetID);
      SwitchLayout();

      if (handler.CurrentLevel > 0)
      {
        GUIListItem listItem = new GUIListItem("..");
        listItem.Path = string.Empty;
        listItem.IsFolder = true;
        Util.Utils.SetDefaultIcons(listItem);
        listItem.OnItemSelected += OnItemSelected;
        itemlist.Add(listItem);
        SetLabel(listItem);
        ((VideoViewHandler)handler).SetLabel(listItem.AlbumInfoTag as IMDBMovie, ref listItem);
        facadeLayout.Add(listItem);
      }

      VirtualDirectory vDir = new VirtualDirectory();
      // Get protected share paths for videos
      vDir.LoadSettings("movies");

      foreach (IMDBMovie movie in movies)
      {
        GUIListItem item = new GUIListItem();
        item.Label = movie.Title;

        if (handler.CurrentLevelWhere != "user groups")
        {
          if (handler.CurrentLevel + 1 < handler.MaxLevels)
          {
            item.IsFolder = true;
          }
          else
          {
            item.IsFolder = false;
          }
        }
        else
        {
          if (string.IsNullOrEmpty(movie.Title) && handler.CurrentLevel + 1 < handler.MaxLevels)
          {
            item.IsFolder = true;
            item.IsRemote = true;
          }
          else
          {
            item.IsFolder = false;
          }
        }

        item.Path = movie.File;

        // Protected movies validation, checks item and if it is inside protected shares.
        // If item is inside PIN protected share, checks if user validate PIN with Unlock
        // command from context menu and returns "True" if all is ok and item will be visible
        // in movie list. Non-protected item will skip check and will be always visible.
        if (!string.IsNullOrEmpty(item.Path))
        {
          if (!IsItemPinProtected(item, vDir))
            continue;
        }
        //
        item.Duration = movie.RunTime * 60;
        item.AlbumInfoTag = movie;
        item.Year = movie.Year;
        item.DVDLabel = movie.DVDLabel;
        item.Rating = movie.Rating;
        item.IsPlayed = movie.Watched > 0;

        try
        {
          if (item.Path.ToUpperInvariant().Contains(@"\VIDEO_TS"))
          {
            item.Label3 = MediaTypes.DVD.ToString() + " #" + movie.WatchedCount;;
          }
          else if (item.Path.ToUpperInvariant().Contains(@"\BDMV"))
          {
            item.Label3 = MediaTypes.BD.ToString() + " #" + movie.WatchedCount;
          }
          else if (VirtualDirectory.IsImageFile(Path.GetExtension(item.Path)))
          {
            item.Label3 = MediaTypes.ISO.ToString() + " #" + movie.WatchedCount; ;
          }
          else
          {
            item.Label3 = movie.WatchedPercent + "% #" + movie.WatchedCount;
          }
        }
        catch (Exception){}
        
        item.OnItemSelected += OnItemSelected;
        SetLabel(item);
        ((VideoViewHandler)handler).SetLabel(item.AlbumInfoTag as IMDBMovie, ref item);
        // Movie/group content list skin property will read from musictag
        item.MusicTag = SetMovieListGroupedBy(item);
        facadeLayout.Add(item);
        itemlist.Add(item);
      }

      // Sort
      facadeLayout.Sort(new VideoSort(CurrentSortMethod, CurrentSortAsc));
      int itemIndex = 0;
      string viewFolder = SetItemViewHistory();
      string selectedItemLabel = m_history.Get(viewFolder);
      
      if (string.IsNullOrEmpty(selectedItemLabel) && facadeLayout.SelectedListItem != null)
      {
        selectedItemLabel = facadeLayout.SelectedListItem.Label;
      }

      int itemCount = itemlist.Count;
      
      if (itemlist.Count > 0)
      {
        GUIListItem rootItem = (GUIListItem)itemlist[0];
        if (rootItem.Label == "..")
        {
          itemCount--;
        }
      }

      //set object count label
      GUIPropertyManager.SetProperty("#itemcount", Util.Utils.GetObjectCountLabel(itemCount));

      // Clear info for zero result
      if (itemlist.Count == 0)
      {
        GUIListItem item = new GUIListItem();
        item.Label = GUILocalizeStrings.Get(284);
        IMDBMovie movie = item.AlbumInfoTag as IMDBMovie;
        movie = new IMDBMovie();
        item.AlbumInfoTag = movie;
        movie.SetProperties(false, string.Empty);
        itemlist.Add(item);
        facadeLayout.Add(item);
      }

      bool itemSelected = false;
      
      if (handler.CurrentLevel < handler.MaxLevels)
      {
        for (int i = 0; i < facadeLayout.Count; ++i)
        {
          GUIListItem item = facadeLayout[itemIndex];
          
          if (item.Label == selectedItemLabel)
          {
            currentSelectedItem = itemIndex;
            itemSelected = true;
            break;
          }

          itemIndex++;
        }
        
        switch (handler.CurrentLevelWhere.ToLowerInvariant())
        {
          case "genre":
            SetGenreThumbs(itemlist);
            break;

          case "user groups":
            SetUserGroupsThumbs(itemlist);
            break;

          case "actor":
          case "director":
            SetActorThumbs(itemlist);
            break;

          case "year":
            SetYearThumbs(itemlist);
            break;

          case "actorindex":
          case "directorindex":
          case "titleindex":
            foreach (GUIListItem itemAbc in itemlist)
            {
              itemAbc.IconImageBig = @"alpha\" + itemAbc.Label + ".png";
              itemAbc.IconImage = @"alpha\" + itemAbc.Label + ".png";
              itemAbc.ThumbnailImage = @"alpha\" + itemAbc.Label + ".png";
            }
            break;

          default:
            // Assign thumbnails also for the custom views. Bugfix for Mantis 0001471: 
            // Cover image thumbs missing in My Videos when view Selection is by "watched"
            SetIMDBThumbs(itemlist);
            break;
        }
      }
      else
      {
        SetIMDBThumbs(itemlist);
      }

      if (itemSelected)
      {
        GUIControl.SelectItemControl(GetID, facadeLayout.GetID, currentSelectedItem);
      }
      else
      {
        SelectCurrentItem();
      }

      UpdateButtonStates();
      GUIWaitCursor.Hide();
    }
Пример #6
0
    protected override void LoadSettings()
    {
      base.LoadSettings();
      using (Profile.Settings xmlreader = new Profile.MPSettings())
      {
        currentLayout = (Layout)xmlreader.GetValueAsInt(SerializeName, "layout", (int)Layout.List);
        m_bSortAscending = xmlreader.GetValueAsBool(SerializeName, "sortasc", true);
        VideoState.StartWindow = xmlreader.GetValueAsInt("movies", "startWindow", GetID);
        VideoState.View = xmlreader.GetValueAsString("movies", "startview", "369");

        // Prevent unaccesible My Videos from corrupted config
        if (!IsVideoWindow(VideoState.StartWindow))
        {
          VideoState.StartWindow = GetID;
          VideoState.View = "369";
        }

        _isFuzzyMatching = xmlreader.GetValueAsBool("movies", "fuzzyMatching", false);
        _scanSkipExisting = xmlreader.GetValueAsBool("moviedatabase", "scanskipexisting", false);
        _getActors = xmlreader.GetValueAsBool("moviedatabase", "getactors", true);
        _markWatchedFiles = xmlreader.GetValueAsBool("movies", "markwatched", true);
        _eachFolderIsMovie = xmlreader.GetValueAsBool("movies", "eachFolderIsMovie", false);
        _fileMenuEnabled = xmlreader.GetValueAsBool("filemenu", "enabled", true);
        _fileMenuPinCode = Util.Utils.DecryptPin(xmlreader.GetValueAsString("filemenu", "pincode", string.Empty));
        _howToPlayAll = xmlreader.GetValueAsInt("movies", "playallinfolder", 3);

        _virtualDirectory = VirtualDirectories.Instance.Movies;

        if (_virtualStartDirectory == string.Empty)
        {
          if (_virtualDirectory.DefaultShare != null)
          {
            if (_virtualDirectory.DefaultShare.IsFtpShare)
            {
              //remote:hostname?port?login?password?folder
              _currentFolder = _virtualDirectory.GetShareRemoteURL(_virtualDirectory.DefaultShare);
              _virtualStartDirectory = _currentFolder;
            }
            else
            {
              _currentFolder = _virtualDirectory.DefaultShare.Path;
              _virtualStartDirectory = _virtualDirectory.DefaultShare.Path;
            }
          }
        }

        _askBeforePlayingDVDImage = xmlreader.GetValueAsBool("daemon", "askbeforeplaying", false);

        if (xmlreader.GetValueAsBool("movies", "rememberlastfolder", false))
        {
          string lastFolder = xmlreader.GetValueAsString("movies", "lastfolder", _currentFolder);
          if (VirtualDirectory.IsImageFile(Path.GetExtension(lastFolder)))
          {
            lastFolder = "root";
          }
          if (lastFolder != "root")
          {
            _currentFolder = lastFolder;
          }
        }
        _switchRemovableDrives = xmlreader.GetValueAsBool("movies", "SwitchRemovableDrives", true);
      }

      if (_currentFolder.Length > 0 && _currentFolder == _virtualStartDirectory)
      {
        VirtualDirectory vDir = new VirtualDirectory();
        vDir.LoadSettings("movies");
        int pincode = 0;
        bool FolderPinProtected = vDir.IsProtectedShare(_currentFolder, out pincode);
        if (FolderPinProtected)
        {
          _currentFolder = string.Empty;
        }
      }

      if (_currentFolder.Length > 0 && !_virtualDirectory.IsRemote(_currentFolder))
      {
        DirectoryInfo dirInfo = new DirectoryInfo(_currentFolder);

        while (dirInfo.Parent != null)
        {
          string dirName = dirInfo.Name;
          dirInfo = dirInfo.Parent;
          string currentParentFolder = @dirInfo.FullName;
          _history.Set(dirName, currentParentFolder);
        }
      }
    }
Пример #7
0
  /// <summary>
  /// saves last active module.
  /// </summary>
  private void SaveLastActiveModule()
  {
    // persist the currently selected module to XML for later use.
    Log.Debug("Main: SaveLastActiveModule - enabled {0}", showLastActiveModule);
    bool currentmodulefullscreen = Currentmodulefullscreen();
    string currentmodulefullscreenstate = GUIPropertyManager.GetProperty("#currentmodulefullscreenstate");
    string currentmoduleid = GUIPropertyManager.GetProperty("#currentmoduleid");
    if (showLastActiveModule && !Utils.IsGUISettingsWindow(GUIWindowManager.GetPreviousActiveWindow()))
    {
      using (Settings xmlreader = new MPSettings())
      {
        // if MP was closed/hibernated by the use of remote control, we have to retrieve the fullscreen state in an alternative manner.

        //if currentmoduleid is TV fullscreen, then set currentmoduleid to tvhome.
        /*switch GUIWindowManager.ActiveWindow
        {
          case (int) WINDOW_FULLSCREEN_VIDEO:
            currentmoduleid = Convert.ToString( (int) GUIWindow.Window.WINDOW_TV);
            break;

          case (int) WINDOW_FULLSCREEN_VIDEO:
            currentmoduleid = Convert.ToString( (int) GUIWindow.Window.WINDOW_TV);
            break;
        }        
        */

        if (currentmodulefullscreen)
        {
          currentmoduleid = Convert.ToString(GUIWindowManager.GetPreviousActiveWindow());
        }


        if (!currentmodulefullscreen && currentmodulefullscreenstate == "True")
        {
          currentmodulefullscreen = true;
        }
        if (currentmoduleid.Length == 0)
        {
          currentmoduleid = "0";
        }

        string section;
        switch (GUIWindowManager.ActiveWindow)
        {
          case (int)GUIWindow.Window.WINDOW_PICTURES:
            {
              section = "pictures";
              break;
            }
          case (int)GUIWindow.Window.WINDOW_MUSIC:
            {
              section = "music";
              break;
            }
          case (int)GUIWindow.Window.WINDOW_VIDEOS:
            {
              section = "movies";
              break;
            }
          default:
            {
              section = "";
              break;
            }
        }

        bool rememberLastFolder = xmlreader.GetValueAsBool(section, "rememberlastfolder", false);
        string lastFolder = xmlreader.GetValueAsString(section, "lastfolder", "");

        VirtualDirectory VDir = new VirtualDirectory();
        VDir.LoadSettings(section);
        int pincode = 0;
        bool lastFolderPinProtected = VDir.IsProtectedShare(lastFolder, out pincode);
        if (rememberLastFolder && lastFolderPinProtected)
        {
          lastFolder = "root";
          xmlreader.SetValue(section, "lastfolder", lastFolder);
          Log.Debug("Main: reverting to root folder, pin protected folder was open, SaveLastFolder {0}", lastFolder);
        }

        xmlreader.SetValue("general", "lastactivemodule", currentmoduleid);
        xmlreader.SetValueAsBool("general", "lastactivemodulefullscreen", currentmodulefullscreen);
        Log.Debug("Main: SaveLastActiveModule - module {0}", currentmoduleid);
        Log.Debug("Main: SaveLastActiveModule - fullscreen {0}", currentmodulefullscreen);
      }
    }
  }
Пример #8
0
    /// <summary>
    /// Use only in share view
    /// </summary>
    /// <param name="item"></param>
    public static void SetMovieData(GUIListItem item)
    {
      IMDBMovie info = new IMDBMovie();

      if (item == null)
      {
        return;
      }
      
      try
      {
        string path = string.Empty;
        string fileName = string.Empty;

        if (Util.Utils.IsVideo(item.Path))
        {
          Util.Utils.Split(item.Path, out path, out fileName);
        }
        else
        {
          path = item.Path;
        }

        if (item.Path != ".." && System.IO.File.Exists(item.Path + @"\VIDEO_TS\VIDEO_TS.IFO"))
        {
          fileName = item.Path + @"\VIDEO_TS\VIDEO_TS.IFO";
        }
        else if (item.Path != ".." && System.IO.File.Exists(item.Path + @"\BDMV\index.bdmv"))
        {
          fileName = item.Path + @"\BDMV\index.bdmv";
        }
        else
        {
          fileName = item.Path;
        }

        // Set
        VideoFilesMediaInfo mInfo = new VideoFilesMediaInfo();

        if (path == ".." || string.IsNullOrEmpty(path) || (!Directory.Exists(path) && !Util.Utils.IsVideo(fileName)))
        {
          info.MediaInfo = mInfo;
          item.AlbumInfoTag = info;
          return;
        }

        if (Directory.Exists(path) && !Util.Utils.IsVideo(fileName))
        {
          int rndMovieId = -1;

          VirtualDirectory vDir = new VirtualDirectory();
          string pin = string.Empty;
          vDir.LoadSettings("movies");

          if (!vDir.IsProtectedShare(path, out pin))
          {
            ArrayList mList = new ArrayList();
            VideoDatabase.GetRandomMoviesByPath(path, ref mList, 1);

            if (mList.Count > 0)
            {
              IMDBMovie movieDetails = (IMDBMovie)mList[0];
              mList.Clear();
              rndMovieId = movieDetails.ID;
              if (Util.Utils.IsFolderDedicatedMovieFolder(path))
              {
                VideoDatabase.GetMovieInfoById(rndMovieId,ref info);
                int percent = 0;
                int watchedCount = 0;
                VideoDatabase.GetmovieWatchedStatus(rndMovieId, out percent, out watchedCount);
                info.WatchedPercent = percent;
                info.WatchedCount = watchedCount;
                ArrayList fList = new ArrayList();
                VideoDatabase.GetFilesForMovie(rndMovieId,ref fList);
                if (fList.Count > 0)
                {
                  VideoDatabase.GetVideoFilesMediaInfo((string)fList[0], ref mInfo, false);
                  info.VideoFileName = (string)fList[0];
                }
              }
            }
            else
            {
              // User fanart (only for videos which do not have movie info in db -> not scanned)
              try
              {
                GetUserFanart(item, ref info);
              }
              catch (Exception ex)
              {
                Log.Error("IMDBMovie Set user fanart file property error: {0}", ex.Message);
              }
            }
          }

          info.ID = rndMovieId;
          info.MediaInfo = mInfo;
          item.AlbumInfoTag = info;
          return;
        }

        try
        {
          VideoDatabase.GetMovieInfo(fileName, ref info);

          // Get recording/nfo xml
          if (info.IsEmpty)
          {
            FetchMatroskaInfo(fileName, false, ref info);

            if (info.IsEmpty)
            {
              FetchMovieNfo(path, fileName, ref info);
            }
          }

          VideoDatabase.GetVideoFilesMediaInfo(fileName, ref mInfo, false);
          info.VideoFileName = fileName;

          if (string.IsNullOrEmpty(info.VideoFilePath) || info.VideoFilePath == Strings.Unknown)
          {
            string tmpFile = string.Empty;
            Util.Utils.Split(fileName, out path, out tmpFile);
            info.VideoFilePath = path;
          }

          info.Path = path;
          info.MediaInfo = mInfo;

          if (info.ID > 0)
          {
            info.Duration = VideoDatabase.GetMovieDuration(info.ID);
          }
          else
          {
            ArrayList files = new ArrayList();
            VideoDatabase.GetFilesForMovie(VideoDatabase.GetMovieId(info.VideoFileName), ref files);

            foreach (string file in files)
            {
              info.Duration += VideoDatabase.GetVideoDuration(VideoDatabase.GetFileId(file));
            }
          }

          int percent = 0;
          int watchedCount = 0;
          VideoDatabase.GetmovieWatchedStatus(VideoDatabase.GetMovieId(fileName), out percent, out watchedCount);
          info.WatchedPercent = percent;
          info.WatchedCount = watchedCount;

          // User fanart (only for videos which do not have movie info in db -> not scanned)
          try
          {
            if (info.ID < 1)
            {
              GetUserFanart(item, ref info);
            }
          }
          catch (ThreadAbortException) 
          {
            Log.Debug("IMDBMovie.ThreadAbortException SetMovieData (GetMovieInfo) error.");
          }
          catch (Exception ex)
          {
            Log.Error("IMDBMovie Set user fanart file property error: {0}", ex.Message);
          }

          item.AlbumInfoTag = info;
        }
        catch (ThreadAbortException) 
        {
          Log.Debug("IMDBMovie.ThreadAbortException SetMovieData (GetMovieInfo) error.");
        }
        catch (Exception ex)
        {
          Log.Error("IMDBMovie SetMovieData (GetMovieInfo) error: {0}", ex.Message);
          item.AlbumInfoTag = info;
        }
      }
      catch (ThreadAbortException)
      {
        Log.Debug("IMDBMovie.ThreadAbortException SetMovieData error.");
      }
      catch (Exception ex)
      {
        Log.Error("IMDBMovie SetMovieData error: {0}", ex.Message);
        item.AlbumInfoTag = info;
      }
    }
    // Check if item is pin protected and if it exists within unlocked shares
    // Returns true if item is valid or if item is not within protected shares
    private bool CheckItem(GUIListItem item)
    {
      string directory = Path.GetDirectoryName(item.Path); // item path

      if (directory != null)
      {
        VirtualDirectory vDir = new VirtualDirectory();
        // Get protected share paths for videos
        vDir.LoadSettings("movies");

        // Check if item belongs to protected shares
        int pincode = 0;
        bool folderPinProtected = vDir.IsProtectedShare(directory, out pincode);

        bool success = false;

        // User unlocked share/shares with PIN and item is within protected shares
        if (folderPinProtected && _ageConfirmed)
        {
          // Iterate unlocked shares against current item path
          foreach (string share in _currentProtectedShare)
          {
          if (!directory.ToUpperInvariant().Contains(share.ToUpperInvariant()))
            {
              continue;
            }
            success = true;
            break;
          }
          // current item is not within unlocked shares, 
          // don't show item and go to the next item
          if (!success)
          {
            return false;
          }
          return true;
        }
        // Nothing unlocked and item belongs to protected shares,
        // don't show item and go to the next item
        if (folderPinProtected && !_ageConfirmed)
        {
          return false;
        }
      }
      // Item is not inside protected shares, show it
      return true;
    }
Пример #10
0
    /// <summary>
    /// Use only in share view
    /// </summary>
    /// <param name="item"></param>
    public static void SetMovieData(GUIListItem item)
    {
      IMDBMovie info = new IMDBMovie();

      if (item == null)
      {
        return;
      }
      
      try
      {
        string path = string.Empty;
        string fileName = string.Empty;

        if (Util.Utils.IsVideo(item.Path))
        {
          Util.Utils.Split(item.Path, out path, out fileName);
        }
        else
        {
          path = item.Path;
        }

        if (item.Path != ".." && System.IO.File.Exists(item.Path + @"\VIDEO_TS\VIDEO_TS.IFO"))
        {
          fileName = item.Path + @"\VIDEO_TS\VIDEO_TS.IFO";
        }
        else if (item.Path != ".." && System.IO.File.Exists(item.Path + @"\BDMV\index.bdmv"))
        {
          fileName = item.Path + @"\BDMV\index.bdmv";
        }
        else
        {
          fileName = item.Path;
        }

        // Set
        VideoFilesMediaInfo mInfo = new VideoFilesMediaInfo();

        if (path == ".." || string.IsNullOrEmpty(path) || (!Directory.Exists(path) && !Util.Utils.IsVideo(fileName)))
        {
          info.MediaInfo = mInfo;
          item.AlbumInfoTag = info;
          return;
        }

        if (Directory.Exists(path) && !Util.Utils.IsVideo(fileName))
        {
          int rndMovieId = -1;

          VirtualDirectory vDir = new VirtualDirectory();
          int pin = 0;
          vDir.LoadSettings("movies");

          if (!vDir.IsProtectedShare(path, out pin))
          {
            ArrayList mList = new ArrayList();
            VideoDatabase.GetRandomMoviesByPath(path, ref mList, 1);

            if (mList.Count > 0)
            {
              IMDBMovie movieDetails = (IMDBMovie)mList[0];
              mList.Clear();
              rndMovieId = movieDetails.ID;
            }
          }

          info.ID = rndMovieId;
          info.MediaInfo = mInfo;
          item.AlbumInfoTag = info;
          return;
        }

        try
        {
          VideoDatabase.GetMovieInfo(fileName, ref info);

          // Get recording/nfo xml
          if (info.IsEmpty)
          {
            FetchMatroskaInfo(fileName, false, ref info);

            if (info.IsEmpty)
            {
              FetchMovieNfo(path, fileName, ref info);
            }
          }

          VideoDatabase.GetVideoFilesMediaInfo(fileName, ref mInfo, false);
          info.VideoFileName = fileName;

          if (string.IsNullOrEmpty(info.VideoFilePath) || info.VideoFilePath == Strings.Unknown)
          {
            string tmpFile = string.Empty;
            Util.Utils.Split(fileName, out path, out tmpFile);
            info.VideoFilePath = path;
          }

          info.Path = path;
          info.MediaInfo = mInfo;
          info.Duration = VideoDatabase.GetMovieDuration(info.ID);
          int percent = 0;
          int watchedCount = 0;
          VideoDatabase.GetmovieWatchedStatus(VideoDatabase.GetMovieId(fileName), out percent, out watchedCount);
          info.WatchedPercent = percent;
          info.WatchedCount = watchedCount;
          item.AlbumInfoTag = info;
        }
        catch (Exception ex)
        {
          Log.Error("IMDBMovie SetMovieData (GetMovieInfo) error: {0}", ex.Message);
          item.AlbumInfoTag = info;
        }
      }
      catch (Exception ex)
      {
        Log.Error("IMDBMovie SetMovieData error: {0}", ex.Message);
        item.AlbumInfoTag = info;
      }
    }