/* private void ProcessVideos(List<NETWORK_SHARE> shares) { MediaPortal.Util.VirtualDirectory vd = MediaPortal.Util.VirtualDirectories.Instance.Movies; long minsizemb = Convert.ToInt32(config.VideoMinFileSizeMB.Value) * 1024 * 1024; long maxsizemb = Convert.ToInt32(config.VideoMaxFileSizeMB.Value) * 1024 * 1024; ProcessShares(shares, vd, minsizemb, maxsizemb); } private void ProcessPictures(List<NETWORK_SHARE> shares) { MediaPortal.Util.VirtualDirectory vd = MediaPortal.Util.VirtualDirectories.Instance.Pictures; long minsizekb = Convert.ToInt32(config.PictureMinFileSizeKB.Value) * 1024; long maxsizekb = Convert.ToInt32(config.PictureMaxFileSizeKB.Value) * 1024; ProcessShares(shares, vd, minsizekb, maxsizekb); } private void ProcessMusic(List<NETWORK_SHARE> shares) { MediaPortal.Util.VirtualDirectory vd = MediaPortal.Util.VirtualDirectories.Instance.Music; long minsizekb = Convert.ToInt32(config.PictureMinFileSizeKB.Value) * 1024; long maxsizekb = Convert.ToInt32(config.PictureMaxFileSizeKB.Value) * 1024; ProcessShares(shares, vd, minsizekb, maxsizekb); } private void ProcessShares(List<NETWORK_SHARE> shares, MediaPortal.Util.VirtualDirectory vdir, long minsize, long maxsize) { foreach (NETWORK_SHARE s in shares) { if (s.shi.shi1_type == (uint)SHARE_TYPE.STYPE_DISKTREE) { string uncpath = @"\\" + s.Server + @"\" + s.shi.shi1_netname; if (HasMediaType(uncpath, vdir, 2, minsize, maxsize)) { MediaPortal.Util.Share newshare = vdir.GetShare(uncpath); bool createnewshare = false; if (newshare == null) createnewshare = true; if (newshare != null && createnewshare == false) { // GetShare treats incomplete paths equally if (newshare.Path.ToLower() != uncpath.ToLower()) createnewshare = true; } if (createnewshare == true) { string sharename = s.Server + "-" + s.shi.shi1_netname; Log.Debug("adding new share: " + sharename + " for " + uncpath); newshare = new MediaPortal.Util.Share(sharename, uncpath); vdir.Add(newshare); AddedShares.Add(newshare); knownShares.Add(new MyShares.KnownShare(vdir.ToString(), sharename, uncpath)); // todo: if active plugin is guivideofiles, refresh view to reflect changes MediaPortal.GUI.Library.GUIWindow w = MediaPortal.GUI.Library.GUIWindowManager.GetWindow(MediaPortal.GUI.Library.GUIWindowManager.ActiveWindow); MediaPortal.GUI.Video.GUIVideoFiles vf = (MediaPortal.GUI.Video.GUIVideoFiles)w; if (vf != null) { // todo: only update if we are on the root folder level where the shares are listed } if (w != null) { GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SHOW_DIRECTORY, w.GetID, MyShares.Plugin.instance.GetWindowId(), 0, 0, 0, null); MediaPortal.GUI.Library.GUIWindowManager.SendMessage(msg); } } } } } // todo: verify existence of added shares for, remove if no longer existing } */ private void ProcessShare(NETWORK_SHARE s, String mediatype, MediaPortal.Util.VirtualDirectory vdir, long minsize, long maxsize) { if (s.shi.shi1_type == (uint)SHARE_TYPE.STYPE_DISKTREE) { string uncpath = @"\\" + s.Server + @"\" + s.shi.shi1_netname; if (HasMediaType(mediatype, uncpath, recursionDepth, minsize, maxsize)) { string sharename = s.Server + ": " + s.shi.shi1_netname; AddShare(mediatype, vdir, uncpath, sharename); } } }
private void ShareCallback(NETWORK_SHARE sh) { MediaPortal.Util.VirtualDirectory vd = MediaPortal.Util.VirtualDirectories.Instance.Movies; ProcessShare(sh, MediaType.Movies, vd, Parameters[_mediaTypeMovies].minSize, Parameters[_mediaTypeMovies].maxSize); vd = MediaPortal.Util.VirtualDirectories.Instance.Pictures; ProcessShare(sh, MediaType.Pictures, vd, Parameters["Pictures"].minSize, Parameters[_mediaTypePictures].maxSize); vd = MediaPortal.Util.VirtualDirectories.Instance.Music; ProcessShare(sh, MediaType.Music, vd, Parameters[_mediaTypeMusic].minSize, Parameters[_mediaTypeMusic].maxSize); }
private List<NETWORK_SHARE> EnumerateShares2(ArrayList computers, FooCallbackType fun) { List<NETWORK_SHARE> ShareInfos = new List<NETWORK_SHARE>(); foreach (string ServerName in computers) { //string ServerName = info; // "Jedi-2"; Log.Debug("processing server " + ServerName); int entriesread = 0; int totalentries = 0; int resume_handle = 0; int nStructSize = Marshal.SizeOf(typeof(SHARE_INFO_1)); IntPtr bufPtr = IntPtr.Zero; StringBuilder server = new StringBuilder(ServerName); int ret = NetShareEnum(server, 1, ref bufPtr, MAX_PREFERRED_LENGTH, ref entriesread, ref totalentries, ref resume_handle); if (ret == NERR_Success) { IntPtr currentPtr = bufPtr; for (int i = 0; i < entriesread; i++) { NETWORK_SHARE ns = new NETWORK_SHARE(); ns.Server = ServerName; ns.shi = (SHARE_INFO_1)Marshal.PtrToStructure(currentPtr, typeof(SHARE_INFO_1)); ShareInfos.Add(ns); fun(ns); currentPtr = new IntPtr(currentPtr.ToInt32() + nStructSize); } NetApiBufferFree(bufPtr); } } Log.Debug("MyShares: done processing servers"); return ShareInfos; }