示例#1
0
    public void LoadSettings(string section)
    {
      Clear();
      using (Profile.Settings xmlreader = new Profile.MPSettings())
      {
        string strDefault = xmlreader.GetValueAsString(section, "default", string.Empty);
        for (int i = 0; i < MaximumShares; i++)
        {
          string strShareName = String.Format("sharename{0}", i);
          string strSharePath = String.Format("sharepath{0}", i);
          string strPincode = String.Format("pincode{0}", i);

          string shareType = String.Format("sharetype{0}", i);
          string shareServer = String.Format("shareserver{0}", i);
          string shareLogin = String.Format("sharelogin{0}", i);
          string sharePwd = String.Format("sharepassword{0}", i);
          string sharePort = String.Format("shareport{0}", i);
          string remoteFolder = String.Format("shareremotepath{0}", i);
          string shareViewPath = String.Format("shareview{0}", i);

          Share share = new Share();
          share.Name = xmlreader.GetValueAsString(section, strShareName, string.Empty);
          share.Path = xmlreader.GetValueAsString(section, strSharePath, string.Empty);
          string pinCode = Utils.DecryptPin(xmlreader.GetValueAsString(section, strPincode, string.Empty));
          if (pinCode != string.Empty)
            share.Pincode = Convert.ToInt32(pinCode);
          else
            share.Pincode = -1;

          share.IsFtpShare = xmlreader.GetValueAsBool(section, shareType, false);
          share.FtpServer = xmlreader.GetValueAsString(section, shareServer, string.Empty);
          share.FtpLoginName = xmlreader.GetValueAsString(section, shareLogin, string.Empty);
          share.FtpPassword = xmlreader.GetValueAsString(section, sharePwd, string.Empty);
          share.FtpPort = xmlreader.GetValueAsInt(section, sharePort, 21);
          share.FtpFolder = xmlreader.GetValueAsString(section, remoteFolder, "/");
          share.DefaultLayout = (Layout)xmlreader.GetValueAsInt(section, shareViewPath, (int)Layout.List);

          if (share.Name.Length > 0)
          {
            if (strDefault == share.Name)
            {
              share.Default = true;
              if (defaultshare == null)
              {
                defaultshare = share;
              }
            }
            Add(share);
          }
          else break;
        }
      }
    }
 public string GetShareRemoteURL(Share shareName)
 {
   return String.Format("remote:{0}?{1}?{2}?{3}?{4}",
                        shareName.FtpServer,
                        shareName.FtpPort,
                        shareName.FtpLoginName,
                        shareName.FtpPassword,
                        Utils.RemoveTrailingSlash(shareName.FtpFolder));
 }
 public bool IsWakeOnLanEnabled(Share shareName)
 {
   if (shareName == null) 
     return false;
   
   return shareName.ShareWakeOnLan;
 }
    public void LoadSettings(string section)
    {
      Clear();
      using (Profile.Settings xmlreader = new Profile.MPSettings())
      {
        string strDefault = xmlreader.GetValueAsString(section, "default", string.Empty);
        for (int i = 0; i < MaximumShares; i++)
        {
          string strShareName = String.Format("sharename{0}", i);
          string strSharePath = String.Format("sharepath{0}", i);
          string strPincode = String.Format("pincode{0}", i);

          string shareType = String.Format("sharetype{0}", i);
          string shareServer = String.Format("shareserver{0}", i);
          string shareLogin = String.Format("sharelogin{0}", i);
          string sharePwd = String.Format("sharepassword{0}", i);
          string sharePort = String.Format("shareport{0}", i);
          string remoteFolder = String.Format("shareremotepath{0}", i);
          string shareViewPath = String.Format("shareview{0}", i);
          string sharewakeonlan = String.Format("sharewakeonlan{0}", i);
          string sharedonotfolderjpgifpin = String.Format("sharedonotfolderjpgifpin{0}", i);
          Share share = new Share();
          share.Name = xmlreader.GetValueAsString(section, strShareName, string.Empty);
          share.Path = xmlreader.GetValueAsString(section, strSharePath, string.Empty);
          share.Pincode = Utils.DecryptPassword(xmlreader.GetValueAsString(section, strPincode, string.Empty));
          share.IsFtpShare = xmlreader.GetValueAsBool(section, shareType, false);
          share.FtpServer = xmlreader.GetValueAsString(section, shareServer, string.Empty);
          share.FtpLoginName = xmlreader.GetValueAsString(section, shareLogin, string.Empty);
          share.FtpPassword = Utils.DecryptPassword(xmlreader.GetValueAsString(section, sharePwd, string.Empty));
          share.FtpPort = xmlreader.GetValueAsInt(section, sharePort, 21);
          share.FtpFolder = xmlreader.GetValueAsString(section, remoteFolder, "/");
          share.DefaultLayout = (Layout)xmlreader.GetValueAsInt(section, shareViewPath, (int)Layout.List);
          share.ShareWakeOnLan = xmlreader.GetValueAsBool(section, sharewakeonlan, false);
          share.DonotFolderJpgIfPin = xmlreader.GetValueAsBool(section, sharedonotfolderjpgifpin, true);

          if (share.Name.Length > 0)
          {
            if (strDefault == share.Name)
            {
              share.Default = true;
              if (defaultshare == null)
              {
                defaultshare = share;
              }
            }
            Add(share);
          }
          else break;
        }

        List<string> usbHdd = Utils.GetAvailableUsbHardDisks();

        if (usbHdd.Count > 0)
        {
          foreach (string drive in usbHdd)
          {
            bool driveFound = false;
            string driveName = Utils.GetDriveName(drive);

            if (driveName.Length == 0)
            {
              driveName = String.Format("({0}:) Removable", drive.Substring(0, 1).ToUpper());
            }
            else
            {
              driveName = String.Format("({0}:) {1}", drive.Substring(0, 1).ToUpper(), driveName);
            }

            foreach (var share in m_shares)
            {
              if (share.Path.StartsWith(drive))
              {
                driveFound = true;
                break;
              }
            }

            if (driveFound == false)
            {
              Share removableShare = new Share(driveName, drive);
              removableShare.RuntimeAdded = true;
              Add(removableShare);
            }
          }
        }
      }
    }
 public void AddRemovableDrive(String path, String name)
 {
   bool driveFound = false;
   foreach (Share share in m_shares)
   {
     if (share.Path.StartsWith(path))
     {
       driveFound = true;
       break;
     }
   }
   if (!driveFound)
   {
     Share share = new Share(name, path);
     share.RuntimeAdded = true;
     m_shares.Add(share);
   }
 }
 /// <summary>
 /// Add a new share to this virtual directory
 /// </summary>
 /// <param name="share">new Share</param>
 public void Add(Share share)
 {
   if (share == null) return;
   m_shares.Add(share);
 }
    public static void SetInitialDefaultShares(bool addOptical, bool addMusic, bool addPictures, bool addVideos)
    {
      ArrayList sharesVideos = new ArrayList();
      ArrayList sharesMusic = new ArrayList();
      ArrayList sharesPhotos = new ArrayList();

      // add optical drive letters
      if (addOptical)
      {
        string[] drives = Environment.GetLogicalDrives();
        foreach (string drive in drives)
        {
          int driveType = Utils.getDriveType(drive);
          if (driveType == (int)DriveType.CDRom)
          {
            string driveName = String.Format("({0}:) CD/DVD", drive.Substring(0, 1).ToUpperInvariant());
            Share share = new Share(driveName, drive, string.Empty);
            sharesMusic.Add(share);
            sharesPhotos.Add(share);
            sharesVideos.Add(share);
          }
        }
      }

      // add user profile dirs
      string MusicProfilePath = Win32API.GetFolderPath(Win32API.CSIDL_MYMUSIC);
      if (addMusic)
      {
        Share MusicShare = new Share(GetShareNameDefault(MusicProfilePath), MusicProfilePath, string.Empty);
        sharesMusic.Add(MusicShare);
      }

      string PicturesProfilePath = Win32API.GetFolderPath(Win32API.CSIDL_MYPICTURES);
      if (addPictures)
      {
        Share PicShare = new Share(GetShareNameDefault(PicturesProfilePath), PicturesProfilePath, string.Empty);
        sharesPhotos.Add(PicShare);
      }

      string VideoProfilePath = Win32API.GetFolderPath(Win32API.CSIDL_MYVIDEO);
      if (addVideos)
      {
        Share VidShare = new Share(GetShareNameDefault(VideoProfilePath), VideoProfilePath, string.Empty);
        sharesVideos.Add(VidShare);
      }

      using (Profile.Settings xmlwriter = new Profile.MPSettings())
      {
        if (addMusic)
        {
          xmlwriter.SetValue("music", "default", MusicProfilePath);
          SaveShare(sharesMusic, "music");
        }
        if (addPictures)
        {
          xmlwriter.SetValue("pictures", "default", PicturesProfilePath);
          SaveShare(sharesPhotos, "pictures");
        }
        if (addVideos)
        {
          xmlwriter.SetValue("movies", "default", VideoProfilePath);
          SaveShare(sharesVideos, "movies");
        }
      }
    }
示例#8
0
 /// <summary>
 /// Add a new share to this virtual directory
 /// </summary>
 /// <param name="share">new Share</param>
 public void Add(Share share)
 {
   if (share == null) return;
   m_shares.Add(share);
   //See if the share contains a folder.jpg (we'll be looking for it soon)
   if (Path.IsPathRooted(share.Path))
   {
     Util.Utils.FileExistsInCache(Path.Combine(share.Path, "folder.jpg"));
   }
 }
示例#9
0
    protected override void LoadSettings()
    {
      base.LoadSettings();
      using (Profile.Settings xmlreader = new Profile.MPSettings())
      {
        MusicState.StartWindow = xmlreader.GetValueAsInt("music", "startWindow", GetID);
        MusicState.View = xmlreader.GetValueAsString("music", "startview", string.Empty);
        _createMissingFolderThumbCache = xmlreader.GetValueAsBool("thumbnails", "musicfolderondemand", true);
        _createMissingFolderThumbs = xmlreader.GetValueAsBool("musicfiles", "createMissingFolderThumbs", false);
        _useFolderThumbs = xmlreader.GetValueAsBool("musicfiles", "useFolderThumbs", true);

        _selectOption = xmlreader.GetValueAsString("musicfiles", "selectOption", "play");
        _addAllOnSelect = xmlreader.GetValueAsBool("musicfiles", "addall", true);
        _playlistIsCurrent = xmlreader.GetValueAsBool("musicfiles", "playlistIsCurrent", true);

        for (int i = 0; i < _sortModes.Length; ++i)
        {
          _sortTags1[i] = xmlreader.GetValueAsString("mymusic", _sortModes[i] + "1", _defaultSortTags1[i]);
          _sortTags2[i] = xmlreader.GetValueAsString("mymusic", _sortModes[i] + "2", _defaultSortTags2[i]);
        }

        string playListFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
        playListFolder += @"\My Playlists";

        m_strPlayListPath = xmlreader.GetValueAsString("music", "playlists", playListFolder);
        m_strPlayListPath = Util.Utils.RemoveTrailingSlash(m_strPlayListPath);

        _shareList.Clear();

        string strDefault = xmlreader.GetValueAsString("music", "default", string.Empty);
        for (int i = 0; i < VirtualDirectory.MaxSharesCount; i++)
        {
          string strShareName = String.Format("sharename{0}", i);
          string strSharePath = String.Format("sharepath{0}", i);
          string strPincode = String.Format("pincode{0}", i);

          string shareType = String.Format("sharetype{0}", i);
          string shareServer = String.Format("shareserver{0}", i);
          string shareLogin = String.Format("sharelogin{0}", i);
          string sharePwd = String.Format("sharepassword{0}", i);
          string sharePort = String.Format("shareport{0}", i);
          string remoteFolder = String.Format("shareremotepath{0}", i);
          string shareViewPath = String.Format("shareview{0}", i);

          Share share = new Share();
          share.Name = xmlreader.GetValueAsString("music", strShareName, string.Empty);
          share.Path = xmlreader.GetValueAsString("music", strSharePath, string.Empty);
          share.Pincode = xmlreader.GetValueAsInt("music", strPincode, -1);

          share.IsFtpShare = xmlreader.GetValueAsBool("music", shareType, false);
          share.FtpServer = xmlreader.GetValueAsString("music", shareServer, string.Empty);
          share.FtpLoginName = xmlreader.GetValueAsString("music", shareLogin, string.Empty);
          share.FtpPassword = xmlreader.GetValueAsString("music", sharePwd, string.Empty);
          share.FtpPort = xmlreader.GetValueAsInt("music", sharePort, 21);
          share.FtpFolder = xmlreader.GetValueAsString("music", remoteFolder, "/");
          share.DefaultLayout = (Layout)xmlreader.GetValueAsInt("music", shareViewPath, (int)Layout.List);

          if (share.Name.Length > 0)
          {
            if (strDefault == share.Name)
            {
              share.Default = true;
            }
            _shareList.Add(share);
          }
          else
          {
            break;
          }
        }
      }
    }
示例#10
0
    public override bool Init()
    {
      bool result = Load(GUIGraphicsContext.Skin + @"\mydboxmain.xml");
      Mydbox.GUILocalizeStrings.Load(GUI.Library.GUILocalizeStrings.CurrentLanguage());

      LoadSettings();

      Data dboxdata = new Data(server, username, password, boxtype);
      dboxdata.loadEPGdata(); //load epg data from file

      if (File.Exists(LogPathName)) File.Delete(LogPathName);
      ErrorLog("Init plugin");

      SelChan = new ArrayList();

      // get bouquets
      ParseXML();
      ErrorLog("XML parsed " + _TV_Bouquets.Rows.Count);

      recDirectory.AddExtension(".dat");
      recDirectory.ShowFilesWithoutExtension = false;

      Share share2 = new Share();
      share2.Name = "Recordings";
      share2.Path = RecDir;
      recDirectory.IsRootShare(RecDir);

      if (ah == null) ah = new OnActionHandler(OnAction2);

      #region get some data from box
      try
      {
        // get actual ID
        func = new DboxFunctions(server, username, password, boxtype);
        func.wakeup();
        cGlobal.currentID = func.getID();
        if (cGlobal.currentID != "")
        {
          ErrorLog("Actual ID " + cGlobal.currentID);
          func.setSPTS();
          ErrorLog("SetSPTS has been set");
          ErrorLog("Version=> " + func.getInfo());
          func.showMessage("Mediaportal%20connected");
          // looks box is working
          BoxConn = true;
        }
        else
        {
          ErrorLog("Receiver is not reachable ?");
        }
      }

      catch
      {
        ErrorLog("Receiver is not reachable ?");
      }

      // get group/channel
      ActBouquetNo = 1;
      for (int i = 0; i < _TV_Bouquets.Rows.Count; i++)
      {
        if (_TV_Bouquets.Rows[i]["ID"].ToString() == cGlobal.currentID)
        {
          ActBouquetNo = Convert.ToInt16(_TV_Bouquets.Rows[i]["BouqNo"].ToString());

          ActBouquet = _TV_Bouquets.Rows[i]["BouqName"].ToString();
          ActChannel = _TV_Bouquets.Rows[i]["Name"].ToString();

          ErrorLog("Actual group " + ActBouquet + " actual channel " + ActChannel);
        }
      }

      #endregion

      return result;
    }
示例#11
0
        /// <summary>
        /// Initialize the virtual directory
        /// </summary>
        private void InitializeVirtualDirectory()
        {
            _sharePaths = new List<string>();
              _mDirectory.SetExtensions(GetExtenstions());
              _mDirectory.AddExtension(".pls");
              _mDirectory.AddExtension(".m3u");

              _mDirectory.Clear();
              if (_useMyVideoShares)
              {
            AddSection("movies");
              }
              if (_useMyMusicShares)
              {
            AddSection("music");
              }
              XmlDocument doc = new XmlDocument();
              string path = Config.GetFile(Config.Dir.Config, "MPlayer_GUIPlugin.xml");
              doc.Load(path);
              if (doc.DocumentElement != null)
              {
            XmlNodeList listShare = doc.DocumentElement.SelectNodes("/mplayergui/Share");
            if (listShare != null)
              foreach (XmlNode nodeShare in listShare)
              {
            Share share = new Share
                            {Name = nodeShare.Attributes["name"].Value, Path = nodeShare.Attributes["path"].Value};
            if (!_sharePaths.Contains(share.Path.ToLower()))
            {
              _sharePaths.Add(share.Path.ToLower());
              _mDirectory.Add(share);
            }
              }
              }
        }
示例#12
0
        /// <summary>
        /// Adds a section of MP shares
        /// </summary>
        /// <param name="section">Name of the section</param>
        private void AddSection(String section)
        {
            Share defaultshare = null;
              using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml")))
              {
            string strDefault = xmlreader.GetValueAsString(section, "default", String.Empty);
            for (int i = 0; i < 20; i++)
            {
              string strShareName = String.Format("sharename{0}", i);
              string strSharePath = String.Format("sharepath{0}", i);
              string strPincode = String.Format("pincode{0}", i);

              string shareType = String.Format("sharetype{0}", i);
              string shareServer = String.Format("shareserver{0}", i);
              string shareLogin = String.Format("sharelogin{0}", i);
              string sharePwd = String.Format("sharepassword{0}", i);
              string sharePort = String.Format("shareport{0}", i);
              string remoteFolder = String.Format("shareremotepath{0}", i);
              string shareViewPath = String.Format("shareview{0}", i);

              Share share = new Share
                          {
                            Name = xmlreader.GetValueAsString(section, strShareName, String.Empty),
                            Path = xmlreader.GetValueAsString(section, strSharePath, String.Empty)
                          };

              share.Pincode = Utils.DecryptPin(xmlreader.GetValueAsString(section, strPincode, string.Empty));
              share.IsFtpShare = xmlreader.GetValueAsBool(section, shareType, false);
              share.FtpServer = xmlreader.GetValueAsString(section, shareServer, String.Empty);
              share.FtpLoginName = xmlreader.GetValueAsString(section, shareLogin, String.Empty);
              share.FtpPassword = xmlreader.GetValueAsString(section, sharePwd, String.Empty);
              share.FtpPort = xmlreader.GetValueAsInt(section, sharePort, 21);
              share.FtpFolder = xmlreader.GetValueAsString(section, remoteFolder, "/");
              share.DefaultLayout = (GUIFacadeControl.Layout)xmlreader.GetValueAsInt(section, shareViewPath, (int)GUIFacadeControl.Layout.List);

              if (share.Name.Length > 0)
              {

            if (strDefault == share.Name)
            {
              share.Default = true;
              if (defaultshare == null)
              {
                defaultshare = share;
              }
            }

            if (!_sharePaths.Contains(share.Path.ToLower()))
            {
              _sharePaths.Add(share.Path.ToLower());
              _mDirectory.Add(share);
            }
              }
              else
            break;
            }
              }
        }
示例#13
0
    public bool IsShareOffline(Share shareName)
    {
      if (shareName == null)
        return false;

      return shareName.ShareOffline;
    }