Exemple #1
0
        static UPnPError OnScheduleImports(DvAction action, IList <object> inParams, out IList <object> outParams,
                                           CallContext context)
        {
            outParams = null;
            ICollection <Guid> shareIds         = MarshallingHelper.ParseCsvGuidCollection((string)inParams[0]);
            string             importJobTypeStr = (string)inParams[1];
            ImportJobType      importJobType;
            UPnPError          error = ParseImportJobType("ImportJobType", importJobTypeStr, out importJobType);

            if (error != null)
            {
                return(error);
            }

            IDictionary <Guid, Share> allShares = MediaLibrary.GetShares(null);
            IDictionary <string, ICollection <Share> > importRequests = new Dictionary <string, ICollection <Share> >();

            foreach (Guid shareId in shareIds)
            {
                Share importShare;
                if (!allShares.TryGetValue(shareId, out importShare))
                {
                    // Share not found
                    continue;
                }
                ICollection <Share> systemShares;
                if (!importRequests.TryGetValue(importShare.SystemId, out systemShares))
                {
                    importRequests[importShare.SystemId] = new List <Share> {
                        importShare
                    }
                }
                ;
                else
                {
                    systemShares.Add(importShare);
                }
            }
            // Local imports at the server
            ISystemResolver     systemResolver = ServiceRegistration.Get <ISystemResolver>();
            ICollection <Share> shares;

            if (importRequests.TryGetValue(systemResolver.LocalSystemId, out shares))
            {
                IImporterWorker importerWorker = ServiceRegistration.Get <IImporterWorker>();
                foreach (Share share in shares)
                {
                    if (importJobType == ImportJobType.Import)
                    {
                        importerWorker.ScheduleImport(share.BaseResourcePath, share.MediaCategories, true);
                    }
                    else
                    {
                        importerWorker.ScheduleRefresh(share.BaseResourcePath, share.MediaCategories, true);
                    }
                }
            }
            ServiceRegistration.Get <IThreadPool>().Add(() => ScheduleClientImports(importRequests, importJobType));
            return(null);
        }
Exemple #2
0
        static UPnPError OnDoesResourceProviderSupportTreeListing(DvAction action, IList <object> inParams, out IList <object> outParams,
                                                                  CallContext context)
        {
            Guid              resourceProviderId = MarshallingHelper.DeserializeGuid((string)inParams[0]);
            IMediaAccessor    mediaAccessor      = ServiceRegistration.Get <IMediaAccessor>();
            IResourceProvider rp;
            bool              result = false;

            if (mediaAccessor.LocalResourceProviders.TryGetValue(resourceProviderId, out rp) && rp is IBaseResourceProvider)
            {
                IResourceAccessor rootAccessor;
                if (((IBaseResourceProvider)rp).TryCreateResourceAccessor("/", out rootAccessor))
                {
                    if (rootAccessor is IFileSystemResourceAccessor)
                    {
                        result = true;
                    }
                    rootAccessor.Dispose();
                }
            }
            outParams = new List <object> {
                result
            };
            return(null);
        }
        public int UpdateShare(Guid shareId, ResourcePath baseResourcePath, string shareName,
                               IEnumerable <string> mediaCategories, RelocationMode relocationMode)
        {
            CpAction       action       = GetAction("UpdateShare");
            IList <object> inParameters = new List <object>
            {
                MarshallingHelper.SerializeGuid(shareId),
                baseResourcePath.Serialize(),
                shareName,
                StringUtils.Join(",", mediaCategories)
            };
            string relocationModeStr;

            switch (relocationMode)
            {
            case RelocationMode.Relocate:
                relocationModeStr = "Relocate";
                break;

            case RelocationMode.ClearAndReImport:
                relocationModeStr = "ClearAndReImport";
                break;

            case RelocationMode.None:
                relocationModeStr = "None";
                break;

            default:
                throw new NotImplementedException(string.Format("RelocationMode '{0}' is not implemented", relocationMode));
            }
            inParameters.Add(relocationModeStr);
            IList <object> outParameters = action.InvokeAction(inParameters);

            return((int)outParameters[0]);
        }
 public async Task<PlaylistRawData> ExportPlaylistAsync(Guid playlistId)
 {
   CpAction action = GetAction("X_MediaPortal_ExportPlaylist");
   IList<object> inParameters = new List<object> {MarshallingHelper.SerializeGuid(playlistId)};
   IList<object> outParameters = await action.InvokeAsync(inParameters);
   return (PlaylistRawData) outParameters[0];
 }
 public async Task<MediaItemAspectMetadata> GetMediaItemAspectMetadataAsync(Guid miamId)
 {
   CpAction action = GetAction("X_MediaPortal_GetMediaItemAspectMetadata");
   IList<object> inParameters = new List<object> {MarshallingHelper.SerializeGuid(miamId)};
   IList<object> outParameters = await action.InvokeAsync(inParameters);
   return (MediaItemAspectMetadata) outParameters[0];
 }
 public async Task<IList<MediaItem>> SimpleTextSearch(string searchText, IEnumerable<Guid> necessaryMIATypes, IEnumerable<Guid> optionalMIATypes,
   IFilter filter, bool excludeCLOBs, bool onlyOnline, bool caseSensitive,
   Guid? userProfile, bool includeVirtual, uint? offset = null, uint? limit = null)
 {
   CpAction action = GetAction("X_MediaPortal_SimpleTextSearch");
   String searchModeStr = SerializeExcludeClobs(excludeCLOBs);
   String onlineStateStr = SerializeOnlineState(onlyOnline);
   String capitalizationMode = SerializeCapitalizationMode(caseSensitive);
   IList<object> inParameters = new List<object>
   {
     searchText,
     MarshallingHelper.SerializeGuidEnumerationToCsv(necessaryMIATypes),
     MarshallingHelper.SerializeGuidEnumerationToCsv(optionalMIATypes),
     filter,
     searchModeStr,
     onlineStateStr,
     capitalizationMode,
     userProfile.HasValue ? MarshallingHelper.SerializeGuid(userProfile.Value) : null,
     includeVirtual,
     offset,
     limit,
   };
   IList<object> outParameters = await action.InvokeAsync(inParameters);
   return (IList<MediaItem>)outParameters[0];
 }
Exemple #7
0
        public ICollection <Guid> GetCurrentlyImportingShares()
        {
            CpAction       action        = GetAction("X_MediaPortal_GetCurrentlyImportingShares");
            IList <object> outParameters = action.InvokeAction(null);

            return(MarshallingHelper.ParseCsvGuidCollection((string)outParameters[0]));
        }
 public async Task<Share> GetShareAsync(Guid shareId)
 {
   CpAction action = GetAction("X_MediaPortal_GetShare");
   IList<object> inParameters = new List<object> {MarshallingHelper.SerializeGuid(shareId)};
   IList<object> outParameters = await action.InvokeAsync(inParameters);
   return (Share) outParameters[0];
 }
Exemple #9
0
        public ICollection <string> GetConnectedClients()
        {
            CpAction       action    = GetAction("GetConnectedClients");
            IList <object> outParams = action.InvokeAction(null);

            return(MarshallingHelper.ParseCsvStringCollection((string)outParams[0]));
        }
 public async Task<IList<MLQueryResultGroup>> GroupValueGroupsAsync(MediaItemAspectMetadata.AttributeSpecification attributeType,
     IFilter selectAttributeFilter, ProjectionFunction projectionFunction, IEnumerable<Guid> necessaryMIATypes,
     IFilter filter, bool onlyOnline, GroupingFunction groupingFunction, bool includeVirtual)
 {
   CpAction action = GetAction("X_MediaPortal_GroupValueGroups");
   string projectionFunctionStr = SerializeProjectionFunction(projectionFunction);
   string onlineStateStr = SerializeOnlineState(onlyOnline);
   string groupingFunctionStr;
   switch (groupingFunction)
   {
     case GroupingFunction.FirstCharacter:
       groupingFunctionStr = "FirstCharacter";
       break;
     default:
       throw new NotImplementedException(string.Format("GroupingFunction '{0}' is not implemented", groupingFunction));
   }
   IList<object> inParameters = new List<object>
   {
     MarshallingHelper.SerializeGuid(attributeType.ParentMIAM.AspectId),
     attributeType.AttributeName, selectAttributeFilter,
     projectionFunctionStr,
     MarshallingHelper.SerializeGuidEnumerationToCsv(necessaryMIATypes),
     filter,
     onlineStateStr,
     groupingFunctionStr,
     includeVirtual,
   };
   IList<object> outParameters = await action.InvokeAsync(inParameters);
   return (IList<MLQueryResultGroup>) outParameters[0];
 }
 public async Task ClientCompletedShareImportAsync(Guid shareId)
 {
     CpAction       action       = GetAction("X_MediaPortal_ClientCompletedShareImport");
     IList <object> inParameters = new List <object> {
         MarshallingHelper.SerializeGuid(shareId)
     };
     await action.InvokeAsync(inParameters);
 }
 public async Task ReimportMediaItemMetadataAsync(Guid mediaItemId, IEnumerable <MediaItemAspect> matchedAspects)
 {
     CpAction       action       = GetAction("X_MediaPortal_ReimportMediaItem");
     IList <object> inParameters = new List <object> {
         MarshallingHelper.SerializeGuid(mediaItemId), matchedAspects
     };
     await action.InvokeAsync(inParameters);
 }
 public async Task RefreshMediaItemMetadataAsync(Guid mediaItemId, bool clearMetadata)
 {
     CpAction       action       = GetAction("X_MediaPortal_RefreshMediaItem");
     IList <object> inParameters = new List <object> {
         MarshallingHelper.SerializeGuid(mediaItemId), clearMetadata
     };
     await action.InvokeAsync(inParameters);
 }
 public async Task RemoveShareAsync(Guid shareId)
 {
     CpAction       action       = GetAction("X_MediaPortal_RemoveShare");
     IList <object> inParameters = new List <object> {
         MarshallingHelper.SerializeGuid(shareId)
     };
     await action.InvokeAsync(inParameters);
 }
 public async Task RemoveMediaItemAspectStorageAsync(Guid aspectId)
 {
     CpAction       action       = GetAction("X_MediaPortal_RemoveMediaItemAspectStorage");
     IList <object> inParameters = new List <object> {
         MarshallingHelper.SerializeGuid(aspectId)
     };
     await action.InvokeAsync(inParameters);
 }
        public void ClientCompletedShareImport(Guid shareId)
        {
            CpAction       action       = GetAction("ClientCompletedShareImport");
            IList <object> inParameters = new List <object> {
                MarshallingHelper.SerializeGuid(shareId)
            };

            action.InvokeAction(inParameters);
        }
        public void RemoveMediaItemAspectStorage(Guid aspectId)
        {
            CpAction       action       = GetAction("RemoveMediaItemAspectStorage");
            IList <object> inParameters = new List <object> {
                MarshallingHelper.SerializeGuid(aspectId)
            };

            action.InvokeAction(inParameters);
        }
        public void NotifyPlayback(Guid mediaItemId)
        {
            CpAction       action       = GetAction("NotifyPlayback");
            IList <object> inParameters = new List <object> {
                MarshallingHelper.SerializeGuid(mediaItemId)
            };

            action.InvokeAction(inParameters);
        }
        public void ReImportShare(Guid shareId)
        {
            CpAction       action       = GetAction("ReImportShare");
            IList <object> inParameters = new List <object> {
                MarshallingHelper.SerializeGuid(shareId)
            };

            action.InvokeAction(inParameters);
        }
        public void ScheduleImports(IEnumerable <Guid> shareIds, ImportJobType importJobType)
        {
            CpAction       action   = GetAction("ScheduleImports");
            IList <object> inParams = new List <object> {
                MarshallingHelper.SerializeGuidEnumerationToCsv(shareIds), importJobType == ImportJobType.Refresh ? "Refresh" : "Import"
            };

            action.InvokeAction(inParams);
        }
Exemple #21
0
 static UPnPError OnGetConnectedClients(DvAction action, IList <object> inParams, out IList <object> outParams,
                                        CallContext context)
 {
     outParams = new List <object> {
         MarshallingHelper.SerializeStringEnumerationToCsv(
             ServiceRegistration.Get <IClientManager>().ConnectedClients.Select(clientConnection => clientConnection.Descriptor.MPFrontendServerUUID))
     };
     return(null);
 }
Exemple #22
0
        public async Task <Guid> CreateClientProfileAsync(Guid profileId, string profileName)
        {
            CpAction       action       = GetAction("CreateClientProfile");
            IList <object> inParameters = new List <object> {
                MarshallingHelper.SerializeGuid(profileId), profileName
            };
            IList <object> outParameters = await action.InvokeAsync(inParameters);

            return(MarshallingHelper.DeserializeGuid((string)outParameters[0]));
        }
Exemple #23
0
        public async Task <bool> ClearUserAdditionalDataKeyAsync(Guid profileId, string key)
        {
            CpAction       action       = GetAction("ClearUserAdditionalDataKey");
            IList <object> inParameters = new List <object> {
                MarshallingHelper.SerializeGuid(profileId), key
            };
            IList <object> outParameters = await action.InvokeAsync(inParameters);

            return((bool)outParameters[0]);
        }
Exemple #24
0
        public async Task <bool> ClearAllUserDataAsync(Guid profileId)
        {
            CpAction       action       = GetAction("ClearAllUserData");
            IList <object> inParameters = new List <object> {
                MarshallingHelper.SerializeGuid(profileId)
            };
            IList <object> outParameters = await action.InvokeAsync(inParameters);

            return((bool)outParameters[0]);
        }
Exemple #25
0
        public async Task <bool> ChangeProfileIdAsync(Guid profileId, Guid newProfileId)
        {
            CpAction       action       = GetAction("ChangeProfileId");
            IList <object> inParameters = new List <object> {
                MarshallingHelper.SerializeGuid(profileId), MarshallingHelper.SerializeGuid(newProfileId)
            };
            IList <object> outParameters = await action.InvokeAsync(inParameters);

            return((bool)outParameters[0]);
        }
Exemple #26
0
        public async Task <bool> RenameProfileAsync(Guid profileId, string newName)
        {
            CpAction       action       = GetAction("RenameProfile");
            IList <object> inParameters = new List <object> {
                MarshallingHelper.SerializeGuid(profileId), newName
            };
            IList <object> outParameters = await action.InvokeAsync(inParameters);

            return((bool)outParameters[0]);
        }
Exemple #27
0
        public async Task <bool> SetProfileImageAsync(Guid profileId, byte[] profileImage)
        {
            CpAction       action       = GetAction("SetProfileImage");
            IList <object> inParameters = new List <object> {
                MarshallingHelper.SerializeGuid(profileId), profileImage != null && profileImage.Length > 0 ? Convert.ToBase64String(profileImage) : ""
            };
            IList <object> outParameters = await action.InvokeAsync(inParameters);

            return((bool)outParameters[0]);
        }
Exemple #28
0
        public async Task <bool> UpdateProfileAsync(Guid profileId, string profileName, UserProfileType profileType, string profilePassword)
        {
            CpAction       action       = GetAction("UpdateUserProfile");
            IList <object> inParameters = new List <object> {
                MarshallingHelper.SerializeGuid(profileId), profileName, (int)profileType, profilePassword
            };
            IList <object> outParameters = await action.InvokeAsync(inParameters);

            return((bool)outParameters[0]);
        }
Exemple #29
0
        public async Task <Guid> CreateProfileAsync(string profileName, UserProfileType profileType, string profilePassword)
        {
            CpAction       action       = GetAction("CreateUserProfile");
            IList <object> inParameters = new List <object> {
                profileName, (int)profileType, profilePassword
            };
            IList <object> outParameters = await action.InvokeAsync(inParameters);

            return(MarshallingHelper.DeserializeGuid((string)outParameters[0]));
        }
Exemple #30
0
        public bool DeleteProfile(Guid profileId)
        {
            CpAction       action       = GetAction("DeleteProfile");
            IList <object> inParameters = new List <object> {
                MarshallingHelper.SerializeGuid(profileId)
            };
            IList <object> outParameters = action.InvokeAction(inParameters);

            return((bool)outParameters[0]);
        }