Example #1
0
        /// <summary>
        /// Helper method which simulates a user navigation under this view specification to the given <paramref name="targetPath"/>
        /// under the given <paramref name="localShare"/>.
        /// </summary>
        /// <param name="localShare">Client or server share which is located at the local system.</param>
        /// <param name="targetPath">Resource path to navigate to. This path must be located under the given <paramref name="localShare"/>'s base path.</param>
        /// <param name="navigateToViewDlgt">Callback which will be called for each view specification to navigate to to do the actual navigation.</param>
        public void Navigate(Share localShare, ResourcePath targetPath, NavigateToViewDlgt navigateToViewDlgt)
        {
            NavigateToLocalRootView(localShare, navigateToViewDlgt);
            IResourceAccessor startRA;

            if (!localShare.BaseResourcePath.TryCreateLocalResourceAccessor(out startRA))
            {
                return;
            }
            IFileSystemResourceAccessor current = startRA as IFileSystemResourceAccessor;

            if (current == null)
            {
                // Wrong path resource, cannot navigate. Should not happen if the share is based on a filesystem resource,
                // but might happen if we have found a non-standard share.
                startRA.Dispose();
                return;
            }
            while (true)
            {
                ICollection <IFileSystemResourceAccessor> children = FileSystemResourceNavigator.GetChildDirectories(current, false);
                current.Dispose();
                current = null;
                if (children != null)
                {
                    foreach (IFileSystemResourceAccessor childDirectory in children)
                    {
                        using (childDirectory)
                        {
                            if (childDirectory.CanonicalLocalResourcePath.IsSameOrParentOf(targetPath))
                            {
                                current = childDirectory;
                                break;
                            }
                        }
                    }
                }
                if (current == null)
                {
                    break;
                }
                ViewSpecification newVS = NavigateCreateViewSpecification(localShare.SystemId, current);
                if (newVS == null)
                {
                    current.Dispose();
                    return;
                }
                navigateToViewDlgt(newVS);
            }
        }
Example #2
0
        protected override void NavigateToLocalRootView(Share localShare, NavigateToViewDlgt navigateToViewDlgt)
        {
            // We need to simulate the logic from method ReLoadItemsAndSubViewSpecifications
            IServerConnectionManager serverConnectionManager = ServiceRegistration.Get <IServerConnectionManager>();

            if (!IsSingleSeat(serverConnectionManager))
            {
                string viewName;
                if (localShare.SystemId == serverConnectionManager.HomeServerSystemId)
                {
                    viewName = serverConnectionManager.LastHomeServerName;
                }
                else
                {
                    MPClientMetadata clientMetadata = ServerCommunicationHelper.GetClientMetadata(localShare.SystemId);
                    viewName = clientMetadata == null ? null : clientMetadata.LastClientName;
                }
                if (viewName != null)
                {
                    navigateToViewDlgt(new SystemSharesViewSpecification(localShare.SystemId, viewName, _necessaryMIATypeIds, _optionalMIATypeIds));
                }
            }

            IContentDirectory cd = serverConnectionManager.ContentDirectory;

            if (cd == null)
            {
                return;
            }

            Guid?           userProfile = null;
            IUserManagement userProfileDataManagement = ServiceRegistration.Get <IUserManagement>();

            if (userProfileDataManagement != null && userProfileDataManagement.IsValidUser)
            {
                userProfile = userProfileDataManagement.CurrentUser.ProfileId;
            }

            MediaItem parentDirectory = cd.LoadItemAsync(localShare.SystemId, localShare.BaseResourcePath,
                                                         SystemSharesViewSpecification.DIRECTORY_MIA_ID_ENUMERATION, SystemSharesViewSpecification.EMPTY_ID_ENUMERATION, userProfile).Result;

            if (parentDirectory == null)
            {
                return;
            }
            navigateToViewDlgt(new MediaLibraryBrowseViewSpecification(localShare.Name, parentDirectory.MediaItemId,
                                                                       localShare.SystemId, localShare.BaseResourcePath, _necessaryMIATypeIds, _optionalMIATypeIds));
        }
 /// <summary>
 /// Helper method which simulates a user navigation under this view specification to the given <paramref name="targetPath"/>
 /// under the given <paramref name="localShare"/>.
 /// </summary>
 /// <param name="localShare">Client or server share which is located at the local system.</param>
 /// <param name="targetPath">Resource path to navigate to. This path must be located under the given <paramref name="localShare"/>'s base path.</param>
 /// <param name="navigateToViewDlgt">Callback which will be called for each view specification to navigate to to do the actual navigation.</param>
 public void Navigate(Share localShare, ResourcePath targetPath, NavigateToViewDlgt navigateToViewDlgt)
 {
   NavigateToLocalRootView(localShare, navigateToViewDlgt);
   IResourceAccessor startRA;
   if (!localShare.BaseResourcePath.TryCreateLocalResourceAccessor(out startRA))
     return;
   IFileSystemResourceAccessor current = startRA as IFileSystemResourceAccessor;
   if (current == null)
   {
     // Wrong path resource, cannot navigate. Should not happen if the share is based on a filesystem resource,
     // but might happen if we have found a non-standard share.
     startRA.Dispose();
     return;
   }
   while (true)
   {
     ICollection<IFileSystemResourceAccessor> children = FileSystemResourceNavigator.GetChildDirectories(current, false);
     current.Dispose();
     current = null;
     if (children != null)
       foreach (IFileSystemResourceAccessor childDirectory in children)
         using (childDirectory)
         {
           if (childDirectory.CanonicalLocalResourcePath.IsSameOrParentOf(targetPath))
           {
             current = childDirectory;
             break;
           }
         }
     if (current == null)
       break;
     ViewSpecification newVS = NavigateCreateViewSpecification(localShare.SystemId, current);
     if (newVS == null)
     {
       current.Dispose();
       return;
     }
     navigateToViewDlgt(newVS);
   }
 }
        protected override void NavigateToLocalRootView(Share localShare, NavigateToViewDlgt navigateToViewDlgt)
        {
            // We need to simulate the logic from method ReLoadItemsAndSubViewSpecifications
            ICollection <Share> localServerShares;
            ICollection <Share> localClientShares;

            GetShares(out localServerShares, out localClientShares);
            if (localServerShares.Count > 0 && localClientShares.Count > 0)
            {
                IServerConnectionManager serverConnectionManager = ServiceRegistration.Get <IServerConnectionManager>();
                ISystemResolver          systemResolver          = ServiceRegistration.Get <ISystemResolver>();
                if (localShare.SystemId == serverConnectionManager.HomeServerSystemId)
                {
                    navigateToViewDlgt(new LocalSharesViewSpecification(localServerShares, Consts.RES_SERVER_SHARES_VIEW_NAME, _necessaryMIATypeIds, _optionalMIATypeIds));
                }
                else if (localShare.SystemId == systemResolver.LocalSystemId)
                {
                    navigateToViewDlgt(new LocalSharesViewSpecification(localClientShares, Consts.RES_CLIENT_SHARES_VIEW_NAME, _necessaryMIATypeIds, _optionalMIATypeIds));
                }
            }
            navigateToViewDlgt(new LocalDirectoryViewSpecification(localShare.Name, localShare.BaseResourcePath, _necessaryMIATypeIds, _optionalMIATypeIds));
        }
    protected override void NavigateToLocalRootView(Share localShare, NavigateToViewDlgt navigateToViewDlgt)
    {
      // We need to simulate the logic from method ReLoadItemsAndSubViewSpecifications
      IServerConnectionManager serverConnectionManager = ServiceRegistration.Get<IServerConnectionManager>();

      if (!IsSingleSeat(serverConnectionManager))
      {
        string viewName;
        if (localShare.SystemId == serverConnectionManager.HomeServerSystemId)
          viewName = serverConnectionManager.LastHomeServerName;
        else
        {
          MPClientMetadata clientMetadata = ServerCommunicationHelper.GetClientMetadata(localShare.SystemId);
          viewName = clientMetadata == null ? null : clientMetadata.LastClientName;
        }
        if (viewName != null)
          navigateToViewDlgt(new SystemSharesViewSpecification(localShare.SystemId, viewName, _necessaryMIATypeIds, _optionalMIATypeIds));
      }

      IContentDirectory cd = serverConnectionManager.ContentDirectory;
      if (cd == null)
        return;

      MediaItem parentDirectory = cd.LoadItem(localShare.SystemId, localShare.BaseResourcePath,
          SystemSharesViewSpecification.DIRECTORY_MIA_ID_ENUMERATION, SystemSharesViewSpecification.EMPTY_ID_ENUMERATION);
      if (parentDirectory == null)
        return;
      navigateToViewDlgt(new MediaLibraryBrowseViewSpecification(localShare.Name, parentDirectory.MediaItemId,
            localShare.SystemId, localShare.BaseResourcePath, _necessaryMIATypeIds, _optionalMIATypeIds));
    }
Example #6
0
 /// <summary>
 /// According to the actual class (local media/browse media), this method simulates a user navigation to the given <paramref name="localShare"/>.
 /// </summary>
 /// <param name="localShare">Client or server share which is located at the local system.</param>
 /// <param name="navigateToViewDlgt">Callback which will be called for each view specification to navigate to to do the actual navigation.</param>
 protected abstract void NavigateToLocalRootView(Share localShare, NavigateToViewDlgt navigateToViewDlgt);
 /// <summary>
 /// According to the actual class (local media/browse media), this method simulates a user navigation to the given <paramref name="localShare"/>.
 /// </summary>
 /// <param name="localShare">Client or server share which is located at the local system.</param>
 /// <param name="navigateToViewDlgt">Callback which will be called for each view specification to navigate to to do the actual navigation.</param>
 protected abstract void NavigateToLocalRootView(Share localShare, NavigateToViewDlgt navigateToViewDlgt);
 protected override void NavigateToLocalRootView(Share localShare, NavigateToViewDlgt navigateToViewDlgt)
 {
   // We need to simulate the logic from method ReLoadItemsAndSubViewSpecifications
   ICollection<Share> localServerShares;
   ICollection<Share> localClientShares;
   GetShares(out localServerShares, out localClientShares);
   if (localServerShares.Count > 0 && localClientShares.Count > 0)
   {
     IServerConnectionManager serverConnectionManager = ServiceRegistration.Get<IServerConnectionManager>();
     ISystemResolver systemResolver = ServiceRegistration.Get<ISystemResolver>();
     if (localShare.SystemId == serverConnectionManager.HomeServerSystemId)
       navigateToViewDlgt(new LocalSharesViewSpecification(localServerShares, Consts.RES_SERVER_SHARES_VIEW_NAME, _necessaryMIATypeIds, _optionalMIATypeIds));
     else if (localShare.SystemId == systemResolver.LocalSystemId)
       navigateToViewDlgt(new LocalSharesViewSpecification(localClientShares, Consts.RES_CLIENT_SHARES_VIEW_NAME, _necessaryMIATypeIds, _optionalMIATypeIds));
   }
   navigateToViewDlgt(new LocalDirectoryViewSpecification(localShare.Name, localShare.BaseResourcePath, _necessaryMIATypeIds, _optionalMIATypeIds));
 }