diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-09-05 10:42:17 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-09-05 10:42:17 -0400 |
| commit | 7b6bf545dad2f9db1ea9f9cb9fdcd4bac57a18a2 (patch) | |
| tree | 9993032ec7db835314238f85535848dbd362d644 | |
| parent | 6e1ed10a065ee5c4ee6a9078d8fea1e71fddc6d3 (diff) | |
removed network option from directory picker due to unreliability
| -rw-r--r-- | MediaBrowser.Api/EnvironmentService.cs | 35 | ||||
| -rw-r--r-- | MediaBrowser.Common.Implementations/NetworkManagement/NetworkManager.cs | 62 | ||||
| -rw-r--r-- | MediaBrowser.Common/Net/INetworkManager.cs | 6 | ||||
| -rw-r--r-- | MediaBrowser.Controller/IO/NativeMethods.cs | 118 | ||||
| -rw-r--r-- | MediaBrowser.WebDashboard/ApiClient.js | 14 | ||||
| -rw-r--r-- | MediaBrowser.WebDashboard/packages.config | 2 |
6 files changed, 1 insertions, 236 deletions
diff --git a/MediaBrowser.Api/EnvironmentService.cs b/MediaBrowser.Api/EnvironmentService.cs index d88d85594..985e3c89b 100644 --- a/MediaBrowser.Api/EnvironmentService.cs +++ b/MediaBrowser.Api/EnvironmentService.cs @@ -56,15 +56,6 @@ namespace MediaBrowser.Api } /// <summary> - /// Class GetNetworkComputers - /// </summary> - [Route("/Environment/NetworkDevices", "GET")] - [Api(Description = "Gets a list of devices on the network")] - public class GetNetworkDevices : IReturn<List<FileSystemEntryInfo>> - { - } - - /// <summary> /// Class EnvironmentService /// </summary> public class EnvironmentService : BaseApiService @@ -132,18 +123,6 @@ namespace MediaBrowser.Api } /// <summary> - /// Gets the specified request. - /// </summary> - /// <param name="request">The request.</param> - /// <returns>System.Object.</returns> - public object Get(GetNetworkDevices request) - { - var result = GetNetworkDevices().OrderBy(i => i.Path).ToList(); - - return ToOptimizedResult(result); - } - - /// <summary> /// Gets the list that is returned when an empty path is supplied /// </summary> /// <returns>IEnumerable{FileSystemEntryInfo}.</returns> @@ -160,20 +139,6 @@ namespace MediaBrowser.Api } /// <summary> - /// Gets the network computers. - /// </summary> - /// <returns>IEnumerable{FileSystemEntryInfo}.</returns> - private IEnumerable<FileSystemEntryInfo> GetNetworkDevices() - { - return _networkManager.GetNetworkDevices().Select(c => new FileSystemEntryInfo - { - Name = c, - Path = NetworkPrefix + c, - Type = FileSystemEntryType.NetworkComputer - }); - } - - /// <summary> /// Gets the name. /// </summary> /// <param name="drive">The drive.</param> diff --git a/MediaBrowser.Common.Implementations/NetworkManagement/NetworkManager.cs b/MediaBrowser.Common.Implementations/NetworkManagement/NetworkManager.cs index 6d35d5f86..71e2ec85a 100644 --- a/MediaBrowser.Common.Implementations/NetworkManagement/NetworkManager.cs +++ b/MediaBrowser.Common.Implementations/NetworkManagement/NetworkManager.cs @@ -58,68 +58,6 @@ namespace MediaBrowser.Common.Implementations.NetworkManagement } /// <summary> - /// Uses the DllImport : NetServerEnum with all its required parameters - /// (see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netmgmt/netmgmt/netserverenum.asp - /// for full details or method signature) to retrieve a list of domain SV_TYPE_WORKSTATION - /// and SV_TYPE_SERVER PC's - /// </summary> - /// <returns>Arraylist that represents all the SV_TYPE_WORKSTATION and SV_TYPE_SERVER - /// PC's in the Domain</returns> - public IEnumerable<string> GetNetworkDevices() - { - //local fields - const int MAX_PREFERRED_LENGTH = -1; - var SV_TYPE_WORKSTATION = 1; - var SV_TYPE_SERVER = 2; - var buffer = IntPtr.Zero; - var tmpBuffer = IntPtr.Zero; - var entriesRead = 0; - var totalEntries = 0; - var resHandle = 0; - var sizeofINFO = Marshal.SizeOf(typeof(_SERVER_INFO_100)); - - try - { - //call the DllImport : NetServerEnum with all its required parameters - //see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netmgmt/netmgmt/netserverenum.asp - //for full details of method signature - var ret = NativeMethods.NetServerEnum(null, 100, ref buffer, MAX_PREFERRED_LENGTH, out entriesRead, out totalEntries, SV_TYPE_WORKSTATION | SV_TYPE_SERVER, null, out resHandle); - - //if the returned with a NERR_Success (C++ term), =0 for C# - if (ret == 0) - { - //loop through all SV_TYPE_WORKSTATION and SV_TYPE_SERVER PC's - for (var i = 0; i < totalEntries; i++) - { - //get pointer to, Pointer to the buffer that received the data from - //the call to NetServerEnum. Must ensure to use correct size of - //STRUCTURE to ensure correct location in memory is pointed to - tmpBuffer = new IntPtr((int)buffer + (i * sizeofINFO)); - //Have now got a pointer to the list of SV_TYPE_WORKSTATION and - //SV_TYPE_SERVER PC's, which is unmanaged memory - //Needs to Marshal data from an unmanaged block of memory to a - //managed object, again using STRUCTURE to ensure the correct data - //is marshalled - var svrInfo = (_SERVER_INFO_100)Marshal.PtrToStructure(tmpBuffer, typeof(_SERVER_INFO_100)); - - //add the PC names to the ArrayList - if (!string.IsNullOrEmpty(svrInfo.sv100_name)) - { - yield return svrInfo.sv100_name; - } - } - } - } - finally - { - //The NetApiBufferFree function frees - //the memory that the NetApiBufferAllocate function allocates - NativeMethods.NetApiBufferFree(buffer); - } - } - - - /// <summary> /// Gets the network shares. /// </summary> /// <param name="path">The path.</param> diff --git a/MediaBrowser.Common/Net/INetworkManager.cs b/MediaBrowser.Common/Net/INetworkManager.cs index 83099e1f9..6cda54606 100644 --- a/MediaBrowser.Common/Net/INetworkManager.cs +++ b/MediaBrowser.Common/Net/INetworkManager.cs @@ -24,12 +24,6 @@ namespace MediaBrowser.Common.Net string GetMacAddress(); /// <summary> - /// Gets available devices within the domain - /// </summary> - /// <returns>PC's in the Domain</returns> - IEnumerable<string> GetNetworkDevices(); - - /// <summary> /// Gets the network shares. /// </summary> /// <param name="path">The path.</param> diff --git a/MediaBrowser.Controller/IO/NativeMethods.cs b/MediaBrowser.Controller/IO/NativeMethods.cs index 5b9bf52a8..97c7dfe87 100644 --- a/MediaBrowser.Controller/IO/NativeMethods.cs +++ b/MediaBrowser.Controller/IO/NativeMethods.cs @@ -12,47 +12,6 @@ namespace MediaBrowser.Controller.IO [SuppressUnmanagedCodeSecurity] public static class NativeMethods { - //declare the Netapi32 : NetServerEnum method import - /// <summary> - /// Nets the server enum. - /// </summary> - /// <param name="ServerName">Name of the server.</param> - /// <param name="dwLevel">The dw level.</param> - /// <param name="pBuf">The p buf.</param> - /// <param name="dwPrefMaxLen">The dw pref max len.</param> - /// <param name="dwEntriesRead">The dw entries read.</param> - /// <param name="dwTotalEntries">The dw total entries.</param> - /// <param name="dwServerType">Type of the dw server.</param> - /// <param name="domain">The domain.</param> - /// <param name="dwResumeHandle">The dw resume handle.</param> - /// <returns>System.Int32.</returns> - [DllImport("Netapi32", CharSet = CharSet.Auto, SetLastError = true), - SuppressUnmanagedCodeSecurityAttribute] - - public static extern int NetServerEnum( - string ServerName, // must be null - int dwLevel, - ref IntPtr pBuf, - int dwPrefMaxLen, - out int dwEntriesRead, - out int dwTotalEntries, - int dwServerType, - string domain, // null for login domain - out int dwResumeHandle - ); - - //declare the Netapi32 : NetApiBufferFree method import - /// <summary> - /// Nets the API buffer free. - /// </summary> - /// <param name="pBuf">The p buf.</param> - /// <returns>System.Int32.</returns> - [DllImport("Netapi32", SetLastError = true), - SuppressUnmanagedCodeSecurityAttribute] - - public static extern int NetApiBufferFree( - IntPtr pBuf); - /// <summary> /// The MA x_ PATH /// </summary> @@ -71,83 +30,6 @@ namespace MediaBrowser.Controller.IO public const uint STGM_READ = 0; } - //create a _SERVER_INFO_100 STRUCTURE - /// <summary> - /// Struct _SERVER_INFO_100 - /// </summary> - [StructLayout(LayoutKind.Sequential)] - public struct _SERVER_INFO_100 - { - /// <summary> - /// The sv100_platform_id - /// </summary> - internal int sv100_platform_id; - /// <summary> - /// The sv100_name - /// </summary> - [MarshalAs(UnmanagedType.LPWStr)] - internal string sv100_name; - } - - /// <summary> - /// Class FindFirstFileExFlags - /// </summary> - public class FindFirstFileExFlags - { - /// <summary> - /// The NONE - /// </summary> - public const int NONE = 0; - - /// <summary> - /// Searches are case-sensitive.Searches are case-sensitive. - /// </summary> - public const int FIND_FIRST_EX_CASE_SENSITIVE = 1; - - /// <summary> - /// Uses a larger buffer for directory queries, which can increase performance of the find operation. - /// </summary> - public const int FIND_FIRST_EX_LARGE_FETCH = 2; - } - - /// <summary> - /// Enum FINDEX_INFO_LEVELS - /// </summary> - public enum FINDEX_INFO_LEVELS - { - /// <summary> - /// The FindFirstFileEx function retrieves a standard set of attribute information. The data is returned in a WIN32_FIND_DATA structure. - /// </summary> - FindExInfoStandard = 0, - - /// <summary> - /// The FindFirstFileEx function does not query the short file name, improving overall enumeration speed. The data is returned in a WIN32_FIND_DATA structure, and the cAlternateFileName member is always a NULL string. - /// </summary> - FindExInfoBasic = 1 - } - - /// <summary> - /// Enum FINDEX_SEARCH_OPS - /// </summary> - public enum FINDEX_SEARCH_OPS - { - /// <summary> - /// The search for a file that matches a specified file name. - /// The lpSearchFilter parameter of FindFirstFileEx must be NULL when this search operation is used. - /// </summary> - FindExSearchNameMatch = 0, - - /// <summary> - /// The find ex search limit to directories - /// </summary> - FindExSearchLimitToDirectories = 1, - - /// <summary> - /// This filtering type is not available. - /// </summary> - FindExSearchLimitToDevices = 2 - } - /// <summary> /// Struct FILETIME /// </summary> diff --git a/MediaBrowser.WebDashboard/ApiClient.js b/MediaBrowser.WebDashboard/ApiClient.js index 26aad2efb..29bfb1068 100644 --- a/MediaBrowser.WebDashboard/ApiClient.js +++ b/MediaBrowser.WebDashboard/ApiClient.js @@ -497,20 +497,6 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) { }; /** - * Gets a list of network devices from the server - */ - self.getNetworkDevices = function () { - - var url = self.getUrl("Environment/NetworkDevices"); - - return self.ajax({ - type: "GET", - url: url, - dataType: "json" - }); - }; - - /** * Cancels a package installation */ self.cancelPackageInstallation = function (installationId) { diff --git a/MediaBrowser.WebDashboard/packages.config b/MediaBrowser.WebDashboard/packages.config index 505dcab95..49180aa52 100644 --- a/MediaBrowser.WebDashboard/packages.config +++ b/MediaBrowser.WebDashboard/packages.config @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <packages> - <package id="MediaBrowser.ApiClient.Javascript" version="3.0.167" targetFramework="net45" /> + <package id="MediaBrowser.ApiClient.Javascript" version="3.0.168" targetFramework="net45" /> <package id="ServiceStack.Common" version="3.9.58" targetFramework="net45" /> <package id="ServiceStack.Text" version="3.9.58" targetFramework="net45" /> </packages>
\ No newline at end of file |
