private void CreateLocalShareRPs(bool multipleSources, bool useCurrent = false)
        {
            ResourceProviderMetadata.SystemAffinity affinity = ResourceProviderMetadata.SystemAffinity.Client;
            if (!_isAttached)
            {
                affinity |= ResourceProviderMetadata.SystemAffinity.DetachedClient;
            }

            ListItem    localSystemItem = new ListItem(Consts.KEY_NAME, Consts.RES_SHARES_CONFIG_LOCAL_SHARE);
            LocalShares proxy;

            if (useCurrent && _shareProxy is LocalShares)
            {
                proxy = (LocalShares)_shareProxy;
                proxy.SystemAffinity = ResourceProviderMetadata.SystemAffinity.Client;
            }
            else
            {
                proxy = new LocalShares {
                    SystemAffinity = affinity, MultipleSources = multipleSources
                }
            };

            proxy.UpdateResourceProvidersList();
            proxy.IsResourceProviderSelectedProperty.Attach(OnResourceProviderSelected);
            localSystemItem.AdditionalProperties[Consts.KEY_SHARES_PROXY] = proxy;
            localSystemItem.SelectedProperty.Attach(OnSystemSelectionChanged);
            _systemsList.Add(localSystemItem);
        }
 // Currently not used; the shares edit workflow is started from the shares info screen calling EditCurrentShare.
 public void EditSelectedShare()
 {
     try
     {
         Share share = GetSelectedLocalShares().FirstOrDefault();
         if (share != null)
         {
             ShareProxy = new LocalShares(share);
         }
         else
         {
             share = GetSelectedServerShares().FirstOrDefault();
             if (share == null)
             {
                 // Should never happen
                 return;
             }
             ShareProxy = new ServerShares(share);
         }
         IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>();
         workflowManager.NavigatePush(Consts.WF_STATE_ID_SHARE_EDIT_CHOOSE_RESOURCE_PROVIDER);
     }
     catch (NotConnectedException)
     {
         DisconnectedError();
     }
     catch (Exception e)
     {
         ErrorEditShare(e);
     }
 }
        protected void UpdateSharesList_NoLock(ItemsList list, List <Share> shareDescriptors, ShareOrigin origin, bool selectFirstItem)
        {
            list.Clear();
            bool selectShare = selectFirstItem;

            shareDescriptors.Sort((a, b) => a.Name.CompareTo(b.Name));
            foreach (Share share in shareDescriptors)
            {
                ListItem shareItem = new ListItem(Consts.KEY_NAME, share.Name);
                shareItem.AdditionalProperties[Consts.KEY_SHARE] = share;
                try
                {
                    string path = origin == ShareOrigin.Local ?
                                  LocalShares.GetLocalResourcePathDisplayName(share.BaseResourcePath) :
                                  ServerShares.GetServerResourcePathDisplayName(share.BaseResourcePath);
                    if (string.IsNullOrEmpty(path))
                    {
                        // Error case: The path is invalid
                        path = LocalizationHelper.Translate(Consts.RES_INVALID_PATH, share.BaseResourcePath);
                    }
                    shareItem.SetLabel(Consts.KEY_PATH, path);
                    Guid?firstResourceProviderId = SharesProxy.GetBaseResourceProviderId(share.BaseResourcePath);
                    if (firstResourceProviderId.HasValue)
                    {
                        ResourceProviderMetadata firstResourceProviderMetadata = origin == ShareOrigin.Local ?
                                                                                 LocalShares.GetLocalResourceProviderMetadata(firstResourceProviderId.Value) :
                                                                                 ServerShares.GetServerResourceProviderMetadata(firstResourceProviderId.Value);
                        shareItem.AdditionalProperties[Consts.KEY_RESOURCE_PROVIDER_METADATA] = firstResourceProviderMetadata;
                    }
                    string categories = StringUtils.Join(", ", share.MediaCategories);
                    shareItem.SetLabel(Consts.KEY_MEDIA_CATEGORIES, categories);
                    Share shareCopy = share;
                    shareItem.Command = new MethodDelegateCommand(() => ShowShareInfo(shareCopy, origin));
                }
                catch (NotConnectedException)
                {
                    throw;
                }
                catch (Exception e)
                {
                    ServiceRegistration.Get <ILogger>().Warn("Problems building share item '{0}' (path '{1}')", e, share.Name, share.BaseResourcePath);
                }
                if (selectShare)
                {
                    selectShare        = false;
                    shareItem.Selected = true;
                }
                shareItem.SelectedProperty.Attach(OnShareItemSelectionChanged);
                lock (_syncObj)
                    list.Add(shareItem);
            }
            list.FireChange();
        }
Пример #4
0
 protected internal async Task UpdateSharesLists_NoLock(bool create)
 {
     lock (_syncObj)
     {
         if (_updatingProperties)
         {
             return;
         }
         _updatingProperties = true;
         if (create)
         {
             _localSharesList = new ItemsList();
         }
         if (create)
         {
             _serverSharesList = new ItemsList();
         }
     }
     try
     {
         List <Share> localShareDescriptors  = new List <Share>(LocalShares.GetShares());
         List <Share> serverShareDescriptors = IsHomeServerConnected ?
                                               new List <Share>(await ServerShares.GetSharesAsync()) : new List <Share>(0);
         int numShares = localShareDescriptors.Count + serverShareDescriptors.Count;
         UpdateSharesList_NoLock(_localSharesList, localShareDescriptors, ShareOrigin.Local, numShares == 1);
         try
         {
             UpdateSharesList_NoLock(_serverSharesList, serverShareDescriptors, ShareOrigin.Server, numShares == 1);
         }
         catch (NotConnectedException)
         {
             _serverSharesList.Clear();
             _serverSharesList.FireChange();
             numShares = localShareDescriptors.Count;
         }
         ShowLocalShares  = !IsLocalHomeServer || _localSharesList.Count > 0;
         IsSharesSelected = numShares == 1;
         bool anySharesAvailable;
         lock (_syncObj)
             anySharesAvailable = _serverSharesList.Count > 0 || _localSharesList.Count > 0;
         AnyShareAvailable = anySharesAvailable;
     }
     catch (Exception ex)
     {
         ServiceRegistration.Get <ILogger>().Warn("Error updating shares list", ex);
     }
     finally
     {
         lock (_syncObj)
             _updatingProperties = false;
     }
 }
Пример #5
0
 protected internal void UpdateSharesLists_NoLock(bool create)
 {
     lock (_syncObj)
     {
         if (_updatingProperties)
         {
             return;
         }
         _updatingProperties = true;
         if (create)
         {
             _localSharesList = new ItemsList();
         }
         if (create)
         {
             _serverSharesList = new ItemsList();
         }
     }
     try
     {
         List <Share> localShareDescriptors  = new List <Share>(LocalShares.GetShares());
         List <Share> serverShareDescriptors = IsHomeServerConnected ?
                                               new List <Share>(ServerShares.GetShares()) : new List <Share>(0);
         int numShares = localShareDescriptors.Count + serverShareDescriptors.Count;
         UpdateSharesList_NoLock(_localSharesList, localShareDescriptors, ShareOrigin.Local, numShares == 1);
         if (IsHomeServerConnected)
         {
             // If our home server is not connected, don't try to update its list of shares
             try
             {
                 UpdateSharesList_NoLock(_serverSharesList, serverShareDescriptors, ShareOrigin.Server, numShares == 1);
             }
             catch (NotConnectedException)
             {
                 _serverSharesList.Clear();
                 _serverSharesList.FireChange();
                 numShares = localShareDescriptors.Count;
             }
         }
         ShowLocalShares  = !IsLocalHomeServer || _localSharesList.Count > 0;
         IsSharesSelected = numShares == 1;
         bool anySharesAvailable;
         lock (_syncObj)
             anySharesAvailable = _serverSharesList.Count > 0 || _localSharesList.Count > 0;
         AnyShareAvailable = anySharesAvailable;
     }
     finally
     {
         lock (_syncObj)
             _updatingProperties = false;
     }
 }
 public void RemoveSelectedSharesAndFinish()
 {
     try
     {
         LocalShares.RemoveShares(GetSelectedLocalShares());
         ServerShares.RemoveShares(GetSelectedServerShares());
         NavigateBackToOverview();
     }
     catch (NotConnectedException)
     {
         DisconnectedError();
     }
     catch (Exception e)
     {
         ErrorEditShare(e);
     }
 }
        protected void ShowShareInfo(Share share, ShareOrigin origin)
        {
            if (share == null)
            {
                return;
            }
            if (origin == ShareOrigin.Local)
            {
                ShareProxy = new LocalShares(share);
            }
            else if (origin == ShareOrigin.Server)
            {
                ShareProxy = new ServerShares(share);
            }
            IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>();

            workflowManager.NavigatePush(Consts.WF_STATE_ID_SHARE_INFO, new NavigationContextConfig {
                NavigationContextDisplayLabel = share.Name
            });
        }
Пример #8
0
 protected void ShowShareInfo(Share share, ShareOrigin origin)
 {
   if (share == null)
     return;
   if (origin == ShareOrigin.Local)
     ShareProxy = new LocalShares(share);
   else if (origin == ShareOrigin.Server)
     ShareProxy = new ServerShares(share);
   IWorkflowManager workflowManager = ServiceRegistration.Get<IWorkflowManager>();
   workflowManager.NavigatePush(Consts.WF_STATE_ID_SHARE_INFO, new NavigationContextConfig { NavigationContextDisplayLabel = share.Name });
 }
Пример #9
0
    private void CreateLocalShareRPs(bool multipleSources, bool useCurrent = false)
    {
      ResourceProviderMetadata.SystemAffinity affinity = ResourceProviderMetadata.SystemAffinity.Client;
      if (!_isAttached)
        affinity |= ResourceProviderMetadata.SystemAffinity.DetachedClient;

      ListItem localSystemItem = new ListItem(Consts.KEY_NAME, Consts.RES_SHARES_CONFIG_LOCAL_SHARE);
      LocalShares proxy;
      if (useCurrent && _shareProxy is LocalShares)
      {
        proxy = (LocalShares)_shareProxy;
        proxy.SystemAffinity = ResourceProviderMetadata.SystemAffinity.Client;
      }
      else
        proxy = new LocalShares { SystemAffinity = affinity, MultipleSources = multipleSources };

      proxy.UpdateResourceProvidersList();
      proxy.IsResourceProviderSelectedProperty.Attach(OnResourceProviderSelected);
      localSystemItem.AdditionalProperties[Consts.KEY_SHARES_PROXY] = proxy;
      localSystemItem.SelectedProperty.Attach(OnSystemSelectionChanged);
      _systemsList.Add(localSystemItem);
    }
Пример #10
0
 // Currently not used; the shares edit workflow is started from the shares info screen calling EditCurrentShare.
 public void EditSelectedShare()
 {
   try
   {
     Share share = GetSelectedLocalShares().FirstOrDefault();
     if (share != null)
       ShareProxy = new LocalShares(share);
     else
     {
       share = GetSelectedServerShares().FirstOrDefault();
       if (share == null)
         // Should never happen
         return;
       ShareProxy = new ServerShares(share);
     }
     IWorkflowManager workflowManager = ServiceRegistration.Get<IWorkflowManager>();
     workflowManager.NavigatePush(Consts.WF_STATE_ID_SHARE_EDIT_CHOOSE_RESOURCE_PROVIDER);
   }
   catch (NotConnectedException)
   {
     DisconnectedError();
   }
   catch (Exception e)
   {
     ErrorEditShare(e);
   }
 }