private UPnPError OnSave(DvAction action, IList<object> inParams, out IList<object> outParams, CallContext context) { string settingsTypeName = (string) inParams[0]; string settings = (string) inParams[1]; Save(settingsTypeName, settings); outParams = new List<object> { }; return null; }
private UPnPError OnLoad(DvAction action, IList<object> inParams, out IList<object> outParams, CallContext context) { string settingsTypeName = (string) inParams[0]; object result = Load(settingsTypeName); string serialized = SettingsSerializer.Serialize(result); outParams = new List<object> { serialized }; return null; }
public UPnPClientControllerServiceImpl() : base( UPnPTypesAndIds.CLIENT_CONTROLLER_SERVICE_TYPE, UPnPTypesAndIds.CLIENT_CONTROLLER_SERVICE_TYPE_VERSION, UPnPTypesAndIds.CLIENT_CONTROLLER_SERVICE_ID) { // Used for a system ID string DvStateVariable A_ARG_TYPE_SystemId = new DvStateVariable("A_ARG_TYPE_SystemId", new DvStandardDataType(UPnPStandardDataType.String)) { SendEvents = false }; AddStateVariable(A_ARG_TYPE_SystemId); // Used to transport a resource path expression DvStateVariable A_ARG_TYPE_ResourcePath = new DvStateVariable("A_ARG_TYPE_ResourcePath", new DvStandardDataType(UPnPStandardDataType.String)) { SendEvents = false }; AddStateVariable(A_ARG_TYPE_ResourcePath); // CSV of media category strings DvStateVariable A_ARG_TYPE_MediaCategoryEnumeration = new DvStateVariable("A_ARG_TYPE_MediaCategoryEnumeration", new DvStandardDataType(UPnPStandardDataType.String)) { SendEvents = false }; AddStateVariable(A_ARG_TYPE_MediaCategoryEnumeration); // Used to transport the import modes "Import" and "Refresh" for the ImportLocation action DvStateVariable A_ARG_TYPE_ImportMode = new DvStateVariable("A_ARG_TYPE_ImportMode", new DvStandardDataType(UPnPStandardDataType.String)) { SendEvents = false }; AddStateVariable(A_ARG_TYPE_ImportMode); // More state variables go here DvAction getHomeServerSystemIdAction = new DvAction("GetHomeServerSystemId", OnGetHomeServerSystemId, new DvArgument[] { }, new DvArgument[] { new DvArgument("HomeServerSystemId", A_ARG_TYPE_SystemId, ArgumentDirection.Out), }); AddAction(getHomeServerSystemIdAction); DvAction importLocationAction = new DvAction("ImportLocation", OnImportLocation, new DvArgument[] { new DvArgument("Path", A_ARG_TYPE_ResourcePath, ArgumentDirection.In), new DvArgument("MediaCategories", A_ARG_TYPE_MediaCategoryEnumeration, ArgumentDirection.In), new DvArgument("ImportMode", A_ARG_TYPE_ImportMode, ArgumentDirection.In), }, new DvArgument[] { }); AddAction(importLocationAction); // More actions go here }
private UPnPError OnGetFanArt(DvAction action, IList<object> inParams, out IList<object> outParams, CallContext context) { outParams = new List<object>(); IFanArtService fanArtService = ServiceRegistration.Get<IFanArtService>(); if (fanArtService == null) return new UPnPError(500, "FanArt service not available"); FanArtConstants.FanArtMediaType fanArtMediaType = (FanArtConstants.FanArtMediaType) Enum.Parse(typeof(FanArtConstants.FanArtMediaType), inParams[0].ToString()); FanArtConstants.FanArtType fanArtType = (FanArtConstants.FanArtType) Enum.Parse(typeof(FanArtConstants.FanArtType), inParams[1].ToString()); string name = inParams[2].ToString(); int maxWidth = (int) inParams[3]; int maxHeight = (int) inParams[4]; bool singleRandom = (bool) inParams[5]; IList<FanArtImage> fanArtImages = fanArtService.GetFanArt(fanArtMediaType, fanArtType, name, maxWidth, maxHeight, singleRandom) ?? new List<FanArtImage>(); outParams = new List<object> { fanArtImages }; return null; }
public FanArtServiceImpl() : base(Consts.FANART_SERVICE_TYPE, Consts.FANART_SERVICE_TYPE_VERSION, Consts.FANART_SERVICE_ID) { DvStateVariable A_ARG_TYPE_MediaType = new DvStateVariable("A_ARG_TYPE_MediaType", new DvStandardDataType(UPnPStandardDataType.String)) { SendEvents = false }; AddStateVariable(A_ARG_TYPE_MediaType); DvStateVariable A_ARG_TYPE_FanArtType = new DvStateVariable("A_ARG_TYPE_FanArtType", new DvStandardDataType(UPnPStandardDataType.String)) { SendEvents = false }; AddStateVariable(A_ARG_TYPE_FanArtType); DvStateVariable A_ARG_TYPE_Name = new DvStateVariable("A_ARG_TYPE_Name", new DvStandardDataType(UPnPStandardDataType.String)) { SendEvents = false }; AddStateVariable(A_ARG_TYPE_Name); DvStateVariable A_ARG_TYPE_Width = new DvStateVariable("A_ARG_TYPE_Width", new DvStandardDataType(UPnPStandardDataType.Int)) { SendEvents = false }; AddStateVariable(A_ARG_TYPE_Width); DvStateVariable A_ARG_TYPE_Height = new DvStateVariable("A_ARG_TYPE_Height", new DvStandardDataType(UPnPStandardDataType.Int)) { SendEvents = false }; AddStateVariable(A_ARG_TYPE_Height); DvStateVariable A_ARG_TYPE_Bool = new DvStateVariable("A_ARG_TYPE_Bool", new DvStandardDataType(UPnPStandardDataType.Boolean)) { SendEvents = false }; AddStateVariable(A_ARG_TYPE_Bool); DvStateVariable A_ARG_TYPE_ImgCollection = new DvStateVariable("A_ARG_TYPE_ImgCollection", new DvExtendedDataType(UPnPDtImageCollection.Instance)) { SendEvents = false }; AddStateVariable(A_ARG_TYPE_ImgCollection); DvAction getFanArt = new DvAction("GetFanArt", OnGetFanArt, new[] { new DvArgument("MediaType", A_ARG_TYPE_MediaType, ArgumentDirection.In), new DvArgument("FanArtType", A_ARG_TYPE_FanArtType, ArgumentDirection.In), new DvArgument("Name", A_ARG_TYPE_Name, ArgumentDirection.In), new DvArgument("MaxWidth", A_ARG_TYPE_Width, ArgumentDirection.In), new DvArgument("MaxHeight", A_ARG_TYPE_Height, ArgumentDirection.In), new DvArgument("SingleRandom", A_ARG_TYPE_Bool, ArgumentDirection.In) }, new[] { new DvArgument("FanArts", A_ARG_TYPE_ImgCollection, ArgumentDirection.Out, true) }); AddAction(getFanArt); }
public ServerSettingsImpl() : base(Consts.SERVERSETTINGS_SERVICE_TYPE, Consts.SERVERSETTINGS_SERVICE_TYPE_VERSION, Consts.SERVERSETTINGS_SERVICE_ID) { DvStateVariable A_ARG_TYPE_SettingsType = new DvStateVariable("A_ARG_TYPE_SettingsType", new DvStandardDataType(UPnPStandardDataType.String)) { SendEvents = false }; AddStateVariable(A_ARG_TYPE_SettingsType); DvStateVariable A_ARG_TYPE_SettingsValue = new DvStateVariable("A_ARG_TYPE_SettingsValue", new DvStandardDataType(UPnPStandardDataType.String)) { SendEvents = false }; AddStateVariable(A_ARG_TYPE_SettingsValue); DvAction loadAction = new DvAction(Consts.ACTION_LOAD, OnLoad, new DvArgument[] { new DvArgument("SettingsTypeName", A_ARG_TYPE_SettingsType, ArgumentDirection.In) }, new DvArgument[] { new DvArgument("Result", A_ARG_TYPE_SettingsValue, ArgumentDirection.Out, true) }); AddAction(loadAction); DvAction saveAction = new DvAction(Consts.ACTION_SAVE, OnSave, new DvArgument[] { new DvArgument("SettingsTypeName", A_ARG_TYPE_SettingsType, ArgumentDirection.In), new DvArgument("Settings", A_ARG_TYPE_SettingsValue, ArgumentDirection.In) }, new DvArgument[] { }); AddAction(saveAction); }
public UPnPUserProfileDataManagementServiceImpl() : base( UPnPTypesAndIds.USER_PROFILE_DATA_MANAGEMENT_SERVICE_TYPE, UPnPTypesAndIds.USER_PROFILE_DATA_MANAGEMENT_SERVICE_TYPE_VERSION, UPnPTypesAndIds.USER_PROFILE_DATA_MANAGEMENT_SERVICE_ID) { // Used to transport an enumeration of user profiles DvStateVariable A_ARG_TYPE_UserProfileEnumeration = new DvStateVariable("A_ARG_TYPE_UserProfileEnumeration", new DvExtendedDataType(UPnPExtendedDataTypes.DtUserProfileEnumeration)) { SendEvents = false, }; AddStateVariable(A_ARG_TYPE_UserProfileEnumeration); DvStateVariable A_ARG_TYPE_UserProfile = new DvStateVariable("A_ARG_TYPE_UserProfile", new DvExtendedDataType(UPnPExtendedDataTypes.DtUserProfile)) { SendEvents = false, }; AddStateVariable(A_ARG_TYPE_UserProfile); // Used for boolean values DvStateVariable A_ARG_TYPE_Bool = new DvStateVariable("A_ARG_TYPE_Bool", new DvStandardDataType(UPnPStandardDataType.Boolean)) { SendEvents = false }; AddStateVariable(A_ARG_TYPE_Bool); // Used for any single GUID value DvStateVariable A_ARG_TYPE_Uuid = new DvStateVariable("A_ARG_TYPE_Id", new DvStandardDataType(UPnPStandardDataType.Uuid)) { SendEvents = false }; AddStateVariable(A_ARG_TYPE_Uuid); // Used for string values DvStateVariable A_ARG_TYPE_String = new DvStateVariable("A_ARG_TYPE_String", new DvStandardDataType(UPnPStandardDataType.String)) { SendEvents = false }; AddStateVariable(A_ARG_TYPE_String); // More state variables go here // User profiles management DvAction getProfilesAction = new DvAction("GetProfiles", OnGetProfiles, new DvArgument[] { }, new DvArgument[] { new DvArgument("Profiles", A_ARG_TYPE_UserProfileEnumeration, ArgumentDirection.Out, true) }); AddAction(getProfilesAction); DvAction getProfileAction = new DvAction("GetProfile", OnGetProfile, new DvArgument[] { new DvArgument("ProfileId", A_ARG_TYPE_Uuid, ArgumentDirection.In) }, new DvArgument[] { new DvArgument("Profile", A_ARG_TYPE_UserProfile, ArgumentDirection.Out, true) }); AddAction(getProfileAction); DvAction getProfileByNameAction = new DvAction("GetProfileByName", OnGetProfileByName, new DvArgument[] { new DvArgument("ProfileName", A_ARG_TYPE_String, ArgumentDirection.In) }, new DvArgument[] { new DvArgument("Profile", A_ARG_TYPE_UserProfile, ArgumentDirection.Out, true) }); AddAction(getProfileByNameAction); DvAction createProfileAction = new DvAction("CreateProfile", OnCreateProfile, new DvArgument[] { new DvArgument("ProfileName", A_ARG_TYPE_String, ArgumentDirection.In) }, new DvArgument[] { new DvArgument("ProfileId", A_ARG_TYPE_Uuid, ArgumentDirection.Out, true) }); AddAction(createProfileAction); DvAction renameProfileAction = new DvAction("RenameProfile", OnRenameProfile, new DvArgument[] { new DvArgument("ProfileId", A_ARG_TYPE_Uuid, ArgumentDirection.In), new DvArgument("NewName", A_ARG_TYPE_String, ArgumentDirection.In) }, new DvArgument[] { new DvArgument("Success", A_ARG_TYPE_Bool, ArgumentDirection.Out, true) }); AddAction(renameProfileAction); DvAction deleteProfileAction = new DvAction("DeleteProfile", OnDeleteProfile, new DvArgument[] { new DvArgument("ProfileId", A_ARG_TYPE_Uuid, ArgumentDirection.In) }, new DvArgument[] { new DvArgument("Success", A_ARG_TYPE_Bool, ArgumentDirection.Out, true) }); AddAction(deleteProfileAction); // User playlist data DvAction getUserPlaylistDataAction = new DvAction("GetUserPlaylistData", OnGetUserPlaylistData, new DvArgument[] { new DvArgument("ProfileId", A_ARG_TYPE_Uuid, ArgumentDirection.In), new DvArgument("PlaylistId", A_ARG_TYPE_Uuid, ArgumentDirection.In), new DvArgument("Key", A_ARG_TYPE_String, ArgumentDirection.In) }, new DvArgument[] { new DvArgument("Data", A_ARG_TYPE_String, ArgumentDirection.Out), new DvArgument("Success", A_ARG_TYPE_Bool, ArgumentDirection.Out, true) }); AddAction(getUserPlaylistDataAction); DvAction setUserPlaylistDataAction = new DvAction("SetUserPlaylistData", OnSetUserPlaylistData, new DvArgument[] { new DvArgument("ProfileId", A_ARG_TYPE_Uuid, ArgumentDirection.In), new DvArgument("PlaylistId", A_ARG_TYPE_Uuid, ArgumentDirection.In), new DvArgument("Key", A_ARG_TYPE_String, ArgumentDirection.In), new DvArgument("Data", A_ARG_TYPE_String, ArgumentDirection.In) }, new DvArgument[] { new DvArgument("Success", A_ARG_TYPE_Bool, ArgumentDirection.Out, true) }); AddAction(setUserPlaylistDataAction); // User media item data DvAction getUserMediaItemDataAction = new DvAction("GetUserMediaItemData", OnGetUserMediaItemData, new DvArgument[] { new DvArgument("ProfileId", A_ARG_TYPE_Uuid, ArgumentDirection.In), new DvArgument("MediaItemId", A_ARG_TYPE_Uuid, ArgumentDirection.In), new DvArgument("Key", A_ARG_TYPE_String, ArgumentDirection.In) }, new DvArgument[] { new DvArgument("Data", A_ARG_TYPE_String, ArgumentDirection.Out), new DvArgument("Success", A_ARG_TYPE_Bool, ArgumentDirection.Out, true) }); AddAction(getUserMediaItemDataAction); DvAction setUserMediaItemDataAction = new DvAction("SetUserMediaItemData", OnSetUserMediaItemData, new DvArgument[] { new DvArgument("ProfileId", A_ARG_TYPE_Uuid, ArgumentDirection.In), new DvArgument("MediaItemId", A_ARG_TYPE_Uuid, ArgumentDirection.In), new DvArgument("Key", A_ARG_TYPE_String, ArgumentDirection.In), new DvArgument("Data", A_ARG_TYPE_String, ArgumentDirection.In) }, new DvArgument[] { new DvArgument("Success", A_ARG_TYPE_Bool, ArgumentDirection.Out, true) }); AddAction(setUserMediaItemDataAction); // User additional data DvAction getUserAdditionalDataAction = new DvAction("GetUserAdditionalData", OnGetUserAdditionalData, new DvArgument[] { new DvArgument("ProfileId", A_ARG_TYPE_Uuid, ArgumentDirection.In), new DvArgument("Key", A_ARG_TYPE_String, ArgumentDirection.In) }, new DvArgument[] { new DvArgument("Data", A_ARG_TYPE_String, ArgumentDirection.Out), new DvArgument("Success", A_ARG_TYPE_Bool, ArgumentDirection.Out, true) }); AddAction(getUserAdditionalDataAction); DvAction setUserAdditionalDataAction = new DvAction("SetUserAdditionalData", OnSetUserAdditionalData, new DvArgument[] { new DvArgument("ProfileId", A_ARG_TYPE_Uuid, ArgumentDirection.In), new DvArgument("Key", A_ARG_TYPE_String, ArgumentDirection.In), new DvArgument("Data", A_ARG_TYPE_String, ArgumentDirection.In) }, new DvArgument[] { new DvArgument("Success", A_ARG_TYPE_Bool, ArgumentDirection.Out, true) }); AddAction(setUserAdditionalDataAction); // Cleanup user data DvAction clearAllUserDataAction = new DvAction("ClearAllUserData", OnClearAllUserData, new DvArgument[] { new DvArgument("ProfileId", A_ARG_TYPE_Uuid, ArgumentDirection.In) }, new DvArgument[] { new DvArgument("Success", A_ARG_TYPE_Bool, ArgumentDirection.Out, true) }); AddAction(clearAllUserDataAction); // More actions go here }
static UPnPError OnSetUserAdditionalData(DvAction action, IList<object> inParams, out IList<object> outParams, CallContext context) { Guid profileId = MarshallingHelper.DeserializeGuid((string) inParams[0]); string key = (string) inParams[1]; string data = (string) inParams[2]; bool success = ServiceRegistration.Get<IUserProfileDataManagement>().SetUserAdditionalData(profileId, key, data); outParams = new List<object> {success}; return null; }
static UPnPError OnCreateProfile(DvAction action, IList<object> inParams, out IList<object> outParams, CallContext context) { string profileName = (string) inParams[0]; Guid profileId = ServiceRegistration.Get<IUserProfileDataManagement>().CreateProfile(profileName); outParams = new List<object> {profileId}; return null; }
static UPnPError OnGetProfile(DvAction action, IList<object> inParams, out IList<object> outParams, CallContext context) { Guid profileId = MarshallingHelper.DeserializeGuid((string) inParams[0]); UserProfile profile; if (!ServiceRegistration.Get<IUserProfileDataManagement>().GetProfile(profileId, out profile)) profile = null; outParams = new List<object> {profile}; return null; }
static UPnPError OnGetHomeServerSystemId(DvAction action, IList<object> inParams, out IList<object> outParams, CallContext context) { outParams = new List<object> {ServiceRegistration.Get<IServerConnectionManager>().HomeServerSystemId}; return null; }
static UPnPError OnTextSearch(DvAction action, IList<object> inParams, out IList<object> outParams, CallContext context) { string searchText = (string) inParams[0]; IEnumerable<Guid> necessaryMIATypes = MarshallingHelper.ParseCsvGuidCollection((string) inParams[1]); IEnumerable<Guid> optionalMIATypes = MarshallingHelper.ParseCsvGuidCollection((string) inParams[2]); IFilter filter = (IFilter) inParams[3]; string searchModeStr = (string) inParams[4]; string onlineStateStr = (string) inParams[5]; string capitalizationMode = (string) inParams[6]; bool excludeCLOBs; bool all = false; bool caseSensitive = true; UPnPError error = ParseSearchMode("SearchMode", searchModeStr, out excludeCLOBs) ?? ParseOnlineState("OnlineState", onlineStateStr, out all) ?? ParseCapitalizationMode("CapitalizationMode", capitalizationMode, out caseSensitive); if (error != null) { outParams = null; return error; } IMediaLibrary mediaLibrary = ServiceRegistration.Get<IMediaLibrary>(); MediaItemQuery query = mediaLibrary.BuildSimpleTextSearchQuery(searchText, necessaryMIATypes, optionalMIATypes, filter, !excludeCLOBs, caseSensitive); IList<MediaItem> mediaItems = mediaLibrary.Search(query, !all); outParams = new List<object> {mediaItems}; return null; }
static UPnPError OnReImportShare(DvAction action, IList<object> inParams, out IList<object> outParams, CallContext context) { Guid shareId = MarshallingHelper.DeserializeGuid((string) inParams[0]); Share share = ServiceRegistration.Get<IMediaLibrary>().GetShare(shareId); ServiceRegistration.Get<IImporterWorker>().ScheduleRefresh(share.BaseResourcePath, share.MediaCategories, true); outParams = null; return null; }
static UPnPError OnGetShare(DvAction action, IList<object> inParams, out IList<object> outParams, CallContext context) { Guid shareId = MarshallingHelper.DeserializeGuid((string) inParams[0]); Share result = ServiceRegistration.Get<IMediaLibrary>().GetShare(shareId); outParams = new List<object> {result}; return null; }
static UPnPError OnGetShares(DvAction action, IList<object> inParams, out IList<object> outParams, CallContext context) { string systemId = (string) inParams[0]; string sharesFilterStr = (string) inParams[1]; bool all; UPnPError error = ParseOnlineState("SharesFilter", sharesFilterStr, out all); if (error != null) { outParams = null; return error; } IDictionary<Guid, Share> shares = ServiceRegistration.Get<IMediaLibrary>().GetShares(systemId); ICollection<Share> result; if (all) result = shares.Values; else { ICollection<string> connectedClientsIds = ServiceRegistration.Get<IClientManager>().ConnectedClients.Select( connection => connection.Descriptor.MPFrontendServerUUID).ToList(); result = new List<Share>(); foreach (Share share in shares.Values) if (connectedClientsIds.Contains(share.SystemId)) result.Add(share); } outParams = new List<object> {result}; return null; }
static UPnPError OnSearch(DvAction action, IList<object> inParams, out IList<object> outParams, CallContext context) { MediaItemQuery query = (MediaItemQuery) inParams[0]; string onlineStateStr = (string) inParams[1]; bool all; UPnPError error = ParseOnlineState("OnlineState", onlineStateStr, out all); if (error != null) { outParams = null; return error; } IList<MediaItem> mediaItems = ServiceRegistration.Get<IMediaLibrary>().Search(query, !all); outParams = new List<object> {mediaItems}; return null; }
static UPnPError OnSetupDefaultServerShares(DvAction action, IList<object> inParams, out IList<object> outParams, CallContext context) { ServiceRegistration.Get<IMediaLibrary>().SetupDefaultLocalShares(); outParams = null; return null; }
static UPnPError OnGetValueGroups(DvAction action, IList<object> inParams, out IList<object> outParams, CallContext context) { Guid aspectId = MarshallingHelper.DeserializeGuid((string) inParams[0]); string attributeName = (string) inParams[1]; IFilter selectAttributeFilter = (IFilter) inParams[2]; string projectionFunctionStr = (string) inParams[3]; IEnumerable<Guid> necessaryMIATypes = MarshallingHelper.ParseCsvGuidCollection((string) inParams[4]); IFilter filter = (IFilter) inParams[5]; string onlineStateStr = (string) inParams[6]; IMediaItemAspectTypeRegistration miatr = ServiceRegistration.Get<IMediaItemAspectTypeRegistration>(); MediaItemAspectMetadata miam; outParams = null; ProjectionFunction projectionFunction; bool all = true; UPnPError error = ParseProjectionFunction("ProjectionFunction", projectionFunctionStr, out projectionFunction) ?? ParseOnlineState("OnlineState", onlineStateStr, out all); if (error != null) return error; if (!miatr.LocallyKnownMediaItemAspectTypes.TryGetValue(aspectId, out miam)) return new UPnPError(600, string.Format("Media item aspect type '{0}' is unknown", aspectId)); MediaItemAspectMetadata.AttributeSpecification attributeType; if (!miam.AttributeSpecifications.TryGetValue(attributeName, out attributeType)) return new UPnPError(600, string.Format("Media item aspect type '{0}' doesn't contain an attribute of name '{1}'", aspectId, attributeName)); HomogenousMap values = ServiceRegistration.Get<IMediaLibrary>().GetValueGroups(attributeType, selectAttributeFilter, projectionFunction, necessaryMIATypes, filter, !all); outParams = new List<object> {values}; return null; }
static UPnPError OnAddMediaItemAspectStorage(DvAction action, IList<object> inParams, out IList<object> outParams, CallContext context) { MediaItemAspectMetadata miam = (MediaItemAspectMetadata) inParams[0]; ServiceRegistration.Get<IMediaLibrary>().AddMediaItemAspectStorage(miam); outParams = null; return null; }
static UPnPError OnImportLocation(DvAction action, IList<object> inParams, out IList<object> outParams, CallContext context) { outParams = null; ResourcePath path = ResourcePath.Deserialize((string) inParams[0]); string[] mediaCategories = ((string) inParams[1]).Split(','); string importJobTypeStr = (string) inParams[2]; ImportJobType importJobType; UPnPError error = ParseImportJobType("ImportJobType", importJobTypeStr, out importJobType); if (error != null) return error; if (importJobType == ImportJobType.Refresh) ServiceRegistration.Get<IImporterWorker>().ScheduleRefresh(path, mediaCategories, true); else ServiceRegistration.Get<IImporterWorker>().ScheduleImport(path, mediaCategories, true); return null; }
static UPnPError OnRemoveMediaItemAspectStorage(DvAction action, IList<object> inParams, out IList<object> outParams, CallContext context) { Guid aspectId = MarshallingHelper.DeserializeGuid((string) inParams[0]); ServiceRegistration.Get<IMediaLibrary>().RemoveMediaItemAspectStorage(aspectId); outParams = null; return null; }
// User profiles management static UPnPError OnGetProfiles(DvAction action, IList<object> inParams, out IList<object> outParams, CallContext context) { ICollection<UserProfile> profiles = ServiceRegistration.Get<IUserProfileDataManagement>().GetProfiles(); outParams = new List<object> {profiles}; return null; }
static UPnPError OnGetAllManagedMediaItemAspectTypes(DvAction action, IList<object> inParams, out IList<object> outParams, CallContext context) { ICollection<Guid> result = ServiceRegistration.Get<IMediaLibrary>().GetManagedMediaItemAspectMetadata().Keys; outParams = new List<object> {MarshallingHelper.SerializeGuidEnumerationToCsv(result)}; return null; }
static UPnPError OnGetProfileByName(DvAction action, IList<object> inParams, out IList<object> outParams, CallContext context) { string profileName = (string) inParams[0]; UserProfile profile; if (!ServiceRegistration.Get<IUserProfileDataManagement>().GetProfileByName(profileName, out profile)) profile = null; outParams = new List<object> {profile}; return null; }
static UPnPError OnGetAllManagedMediaItemAspectCreationDates(DvAction action, IList<object> inParams, out IList<object> outParams, CallContext context) { IDictionary<Guid, DateTime> result = ServiceRegistration.Get<IMediaLibrary>().GetManagedMediaItemAspectCreationDates(); outParams = new List<object> { result }; return null; }
// User media item data static UPnPError OnGetUserMediaItemData(DvAction action, IList<object> inParams, out IList<object> outParams, CallContext context) { Guid profileId = MarshallingHelper.DeserializeGuid((string) inParams[0]); Guid mediaItemId = MarshallingHelper.DeserializeGuid((string) inParams[1]); string key = (string) inParams[2]; string data; bool success; if (!(success = ServiceRegistration.Get<IUserProfileDataManagement>().GetUserMediaItemData(profileId, mediaItemId, key, out data))) data = null; outParams = new List<object> {data, success}; return null; }
static UPnPError OnGetMediaItemAspectMetadata(DvAction action, IList<object> inParams, out IList<object> outParams, CallContext context) { Guid aspectId = MarshallingHelper.DeserializeGuid((string) inParams[0]); MediaItemAspectMetadata miam = ServiceRegistration.Get<IMediaLibrary>().GetManagedMediaItemAspectMetadata(aspectId); outParams = new List<object> {miam}; return null; }
// Cleanup user data static UPnPError OnClearAllUserData(DvAction action, IList<object> inParams, out IList<object> outParams, CallContext context) { Guid profileId = MarshallingHelper.DeserializeGuid((string) inParams[0]); bool success = ServiceRegistration.Get<IUserProfileDataManagement>().ClearAllUserData(profileId); outParams = new List<object> {success}; return null; }
static UPnPError OnLoadItem(DvAction action, IList<object> inParams, out IList<object> outParams, CallContext context) { string systemId = (string) inParams[0]; ResourcePath path = ResourcePath.Deserialize((string) inParams[1]); IEnumerable<Guid> necessaryMIATypes = MarshallingHelper.ParseCsvGuidCollection((string) inParams[2]); IEnumerable<Guid> optionalMIATypes = MarshallingHelper.ParseCsvGuidCollection((string) inParams[3]); MediaItem mediaItem = ServiceRegistration.Get<IMediaLibrary>().LoadItem(systemId, path, necessaryMIATypes, optionalMIATypes); outParams = new List<object> {mediaItem}; return null; }
/// <summary> /// Adds the specified <paramref name="action"/> to this service. /// </summary> /// <remarks> /// The actions need to be added in a special order. If this service is a standard service, actions of the standard /// service type need to be added first. After that, additional actions might be added. /// </remarks> /// <param name="action">Action to be added.</param> public void AddAction(DvAction action) { _actions.Add(action.Name, action); action.ParentService = this; }
static UPnPError OnBrowse(DvAction action, IList<object> inParams, out IList<object> outParams, CallContext context) { Guid parentDirectoryId = MarshallingHelper.DeserializeGuid((string) inParams[0]); IEnumerable<Guid> necessaryMIATypes = MarshallingHelper.ParseCsvGuidCollection((string) inParams[1]); IEnumerable<Guid> optionalMIATypes = MarshallingHelper.ParseCsvGuidCollection((string) inParams[2]); ICollection<MediaItem> result = ServiceRegistration.Get<IMediaLibrary>().Browse(parentDirectoryId, necessaryMIATypes, optionalMIATypes); outParams = new List<object> {result}; return null; }