From b9b08ab384fbffb449f048dbc440883466f81e02 Mon Sep 17 00:00:00 2001 From: Henk Kalkwater Date: Sat, 20 Mar 2021 16:29:31 +0100 Subject: [PATCH] Make model code compileable This disables some application level logic, but I'm going to rewrite that using Lager anyway. --- CMakeLists.txt | 3 + core/CMakeLists.txt | 38 ++ core/codegen/enum_header.hbs | 24 - core/codegen/enum_implementation.hbs | 25 + core/codegen/object_header.hbs | 13 - core/codegen/object_implementation.hbs | 22 +- core/include/JellyfinQt/DTO/accessschedule.h | 12 - .../include/JellyfinQt/DTO/activitylogentry.h | 12 - .../DTO/activitylogentryqueryresult.h | 12 - .../JellyfinQt/DTO/addvirtualfolderdto.h | 12 - core/include/JellyfinQt/DTO/albuminfo.h | 12 - .../DTO/albuminforemotesearchquery.h | 12 - .../JellyfinQt/DTO/allthememediaresult.h | 12 - core/include/JellyfinQt/DTO/architecture.h | 31 - core/include/JellyfinQt/DTO/artistinfo.h | 12 - .../DTO/artistinforemotesearchquery.h | 12 - .../JellyfinQt/DTO/authenticateuserbyname.h | 12 - .../JellyfinQt/DTO/authenticationinfo.h | 12 - .../DTO/authenticationinfoqueryresult.h | 12 - .../JellyfinQt/DTO/authenticationresult.h | 12 - core/include/JellyfinQt/DTO/baseitem.h | 12 - core/include/JellyfinQt/DTO/baseitemdto.h | 12 - .../JellyfinQt/DTO/baseitemdtoqueryresult.h | 12 - core/include/JellyfinQt/DTO/baseitemperson.h | 12 - core/include/JellyfinQt/DTO/bookinfo.h | 12 - .../DTO/bookinforemotesearchquery.h | 12 - core/include/JellyfinQt/DTO/boxsetinfo.h | 12 - .../DTO/boxsetinforemotesearchquery.h | 12 - core/include/JellyfinQt/DTO/brandingoptions.h | 12 - .../include/JellyfinQt/DTO/bufferrequestdto.h | 12 - core/include/JellyfinQt/DTO/channelfeatures.h | 12 - .../JellyfinQt/DTO/channelitemsortfield.h | 37 -- .../JellyfinQt/DTO/channelmappingoptionsdto.h | 12 - .../JellyfinQt/DTO/channelmediacontenttype.h | 40 -- .../include/JellyfinQt/DTO/channelmediatype.h | 25 - core/include/JellyfinQt/DTO/channeltype.h | 22 - core/include/JellyfinQt/DTO/chapterinfo.h | 12 - .../JellyfinQt/DTO/clientcapabilities.h | 12 - .../JellyfinQt/DTO/clientcapabilitiesdto.h | 12 - core/include/JellyfinQt/DTO/codecprofile.h | 12 - core/include/JellyfinQt/DTO/codectype.h | 25 - .../JellyfinQt/DTO/collectioncreationresult.h | 12 - .../JellyfinQt/DTO/configurationpageinfo.h | 12 - .../JellyfinQt/DTO/configurationpagetype.h | 22 - .../include/JellyfinQt/DTO/containerprofile.h | 12 - core/include/JellyfinQt/DTO/controlresponse.h | 12 - core/include/JellyfinQt/DTO/countryinfo.h | 12 - .../JellyfinQt/DTO/createplaylistdto.h | 12 - .../include/JellyfinQt/DTO/createuserbyname.h | 12 - core/include/JellyfinQt/DTO/culturedto.h | 12 - core/include/JellyfinQt/DTO/dayofweek.h | 37 -- core/include/JellyfinQt/DTO/daypattern.h | 25 - .../DTO/defaultdirectorybrowserinfodto.h | 12 - .../JellyfinQt/DTO/deviceidentification.h | 12 - core/include/JellyfinQt/DTO/deviceinfo.h | 12 - .../JellyfinQt/DTO/deviceinfoqueryresult.h | 12 - core/include/JellyfinQt/DTO/deviceoptions.h | 12 - core/include/JellyfinQt/DTO/deviceprofile.h | 12 - .../JellyfinQt/DTO/deviceprofileinfo.h | 12 - .../JellyfinQt/DTO/deviceprofiletype.h | 22 - .../JellyfinQt/DTO/directplayprofile.h | 12 - .../JellyfinQt/DTO/displaypreferencesdto.h | 12 - core/include/JellyfinQt/DTO/dlnaprofiletype.h | 25 - .../include/JellyfinQt/DTO/dynamicdayofweek.h | 46 -- core/include/JellyfinQt/DTO/encodingcontext.h | 22 - core/include/JellyfinQt/DTO/endpointinfo.h | 12 - core/include/JellyfinQt/DTO/externalidinfo.h | 12 - .../JellyfinQt/DTO/externalidmediatype.h | 52 -- core/include/JellyfinQt/DTO/externalurl.h | 12 - core/include/JellyfinQt/DTO/ffmpeglocation.h | 28 - .../JellyfinQt/DTO/filesystementryinfo.h | 12 - .../JellyfinQt/DTO/filesystementrytype.h | 28 - core/include/JellyfinQt/DTO/fontfile.h | 12 - .../JellyfinQt/DTO/forgotpasswordaction.h | 25 - .../JellyfinQt/DTO/forgotpassworddto.h | 12 - .../JellyfinQt/DTO/forgotpasswordresult.h | 12 - core/include/JellyfinQt/DTO/generalcommand.h | 12 - .../JellyfinQt/DTO/generalcommandtype.h | 139 ---- core/include/JellyfinQt/DTO/getprogramsdto.h | 12 - core/include/JellyfinQt/DTO/groupinfodto.h | 12 - core/include/JellyfinQt/DTO/groupqueuemode.h | 22 - core/include/JellyfinQt/DTO/grouprepeatmode.h | 25 - .../include/JellyfinQt/DTO/groupshufflemode.h | 22 - core/include/JellyfinQt/DTO/groupstatetype.h | 28 - core/include/JellyfinQt/DTO/groupupdatetype.h | 49 -- core/include/JellyfinQt/DTO/guideinfo.h | 12 - core/include/JellyfinQt/DTO/headermatchtype.h | 25 - core/include/JellyfinQt/DTO/httpheaderinfo.h | 12 - .../JellyfinQt/DTO/ignorewaitrequestdto.h | 12 - core/include/JellyfinQt/DTO/imagebynameinfo.h | 12 - core/include/JellyfinQt/DTO/imageformat.h | 31 - core/include/JellyfinQt/DTO/imageinfo.h | 12 - core/include/JellyfinQt/DTO/imageoption.h | 12 - .../include/JellyfinQt/DTO/imageorientation.h | 40 -- .../JellyfinQt/DTO/imageproviderinfo.h | 12 - .../JellyfinQt/DTO/imagesavingconvention.h | 22 - core/include/JellyfinQt/DTO/imagetype.h | 55 -- .../include/JellyfinQt/DTO/installationinfo.h | 12 - core/include/JellyfinQt/DTO/iplugin.h | 12 - core/include/JellyfinQt/DTO/isotype.h | 22 - core/include/JellyfinQt/DTO/item.h | 43 -- core/include/JellyfinQt/DTO/itemcounts.h | 12 - core/include/JellyfinQt/DTO/itemfields.h | 199 ------ core/include/JellyfinQt/DTO/itemfilter.h | 43 -- .../JellyfinQt/DTO/joingrouprequestdto.h | 12 - core/include/JellyfinQt/DTO/keepuntil.h | 28 - .../JellyfinQt/DTO/libraryoptioninfodto.h | 12 - core/include/JellyfinQt/DTO/libraryoptions.h | 12 - .../JellyfinQt/DTO/libraryoptionsresultdto.h | 12 - .../JellyfinQt/DTO/librarytypeoptionsdto.h | 12 - .../JellyfinQt/DTO/libraryupdateinfo.h | 12 - .../JellyfinQt/DTO/listingsproviderinfo.h | 12 - .../JellyfinQt/DTO/livestreamresponse.h | 12 - core/include/JellyfinQt/DTO/livetvinfo.h | 12 - .../JellyfinQt/DTO/livetvserviceinfo.h | 12 - .../JellyfinQt/DTO/livetvservicestatus.h | 22 - .../JellyfinQt/DTO/localizationoption.h | 12 - core/include/JellyfinQt/DTO/locationtype.h | 28 - core/include/JellyfinQt/DTO/logfile.h | 12 - core/include/JellyfinQt/DTO/loglevel.h | 37 -- core/include/JellyfinQt/DTO/mediaattachment.h | 12 - .../JellyfinQt/DTO/mediaencoderpathdto.h | 12 - core/include/JellyfinQt/DTO/mediapathdto.h | 12 - core/include/JellyfinQt/DTO/mediapathinfo.h | 12 - core/include/JellyfinQt/DTO/mediaprotocol.h | 37 -- core/include/JellyfinQt/DTO/mediasourceinfo.h | 12 - core/include/JellyfinQt/DTO/mediasourcetype.h | 25 - core/include/JellyfinQt/DTO/mediastream.h | 12 - core/include/JellyfinQt/DTO/mediastreamtype.h | 28 - .../JellyfinQt/DTO/mediaupdateinfodto.h | 12 - core/include/JellyfinQt/DTO/mediaurl.h | 12 - .../JellyfinQt/DTO/metadataeditorinfo.h | 12 - core/include/JellyfinQt/DTO/metadatafield.h | 43 -- core/include/JellyfinQt/DTO/metadataoptions.h | 12 - .../JellyfinQt/DTO/metadatarefreshmode.h | 28 - .../DTO/moveplaylistitemrequestdto.h | 12 - core/include/JellyfinQt/DTO/movieinfo.h | 12 - .../DTO/movieinforemotesearchquery.h | 12 - core/include/JellyfinQt/DTO/musicvideoinfo.h | 12 - .../DTO/musicvideoinforemotesearchquery.h | 12 - core/include/JellyfinQt/DTO/nameguidpair.h | 12 - core/include/JellyfinQt/DTO/nameidpair.h | 12 - core/include/JellyfinQt/DTO/namevaluepair.h | 12 - .../JellyfinQt/DTO/newgrouprequestdto.h | 12 - .../JellyfinQt/DTO/nextitemrequestdto.h | 12 - core/include/JellyfinQt/DTO/notificationdto.h | 12 - .../JellyfinQt/DTO/notificationlevel.h | 25 - .../JellyfinQt/DTO/notificationresultdto.h | 12 - .../JellyfinQt/DTO/notificationssummarydto.h | 12 - .../JellyfinQt/DTO/notificationtypeinfo.h | 12 - .../JellyfinQt/DTO/objectgroupupdate.h | 12 - .../JellyfinQt/DTO/openlivestreamdto.h | 12 - core/include/JellyfinQt/DTO/packageinfo.h | 12 - core/include/JellyfinQt/DTO/parentalrating.h | 12 - .../include/JellyfinQt/DTO/pathsubstitution.h | 12 - .../include/JellyfinQt/DTO/personlookupinfo.h | 12 - .../DTO/personlookupinforemotesearchquery.h | 12 - core/include/JellyfinQt/DTO/pingrequestdto.h | 12 - core/include/JellyfinQt/DTO/pinredeemresult.h | 12 - core/include/JellyfinQt/DTO/playaccess.h | 22 - .../JellyfinQt/DTO/playbackerrorcode.h | 25 - core/include/JellyfinQt/DTO/playbackinfodto.h | 12 - .../JellyfinQt/DTO/playbackinforesponse.h | 12 - .../JellyfinQt/DTO/playbackprogressinfo.h | 12 - .../JellyfinQt/DTO/playbackstartinfo.h | 12 - .../include/JellyfinQt/DTO/playbackstopinfo.h | 12 - core/include/JellyfinQt/DTO/playcommand.h | 31 - core/include/JellyfinQt/DTO/playerstateinfo.h | 12 - .../JellyfinQt/DTO/playlistcreationresult.h | 12 - core/include/JellyfinQt/DTO/playmethod.h | 25 - core/include/JellyfinQt/DTO/playrequest.h | 12 - core/include/JellyfinQt/DTO/playrequestdto.h | 12 - .../include/JellyfinQt/DTO/playstatecommand.h | 43 -- .../include/JellyfinQt/DTO/playstaterequest.h | 12 - core/include/JellyfinQt/DTO/plugininfo.h | 12 - .../JellyfinQt/DTO/pluginsecurityinfo.h | 12 - core/include/JellyfinQt/DTO/pluginstatus.h | 37 -- .../JellyfinQt/DTO/previousitemrequestdto.h | 12 - core/include/JellyfinQt/DTO/problemdetails.h | 12 - .../include/JellyfinQt/DTO/profilecondition.h | 12 - .../JellyfinQt/DTO/profileconditiontype.h | 31 - .../JellyfinQt/DTO/profileconditionvalue.h | 85 --- core/include/JellyfinQt/DTO/programaudio.h | 34 - .../include/JellyfinQt/DTO/publicsysteminfo.h | 12 - core/include/JellyfinQt/DTO/queryfilters.h | 12 - .../JellyfinQt/DTO/queryfilterslegacy.h | 12 - core/include/JellyfinQt/DTO/queueitem.h | 12 - core/include/JellyfinQt/DTO/queuerequestdto.h | 12 - core/include/JellyfinQt/DTO/quickconnectdto.h | 12 - .../JellyfinQt/DTO/quickconnectresult.h | 12 - .../JellyfinQt/DTO/quickconnectstate.h | 25 - core/include/JellyfinQt/DTO/ratingtype.h | 22 - core/include/JellyfinQt/DTO/readyrequestdto.h | 12 - .../JellyfinQt/DTO/recommendationdto.h | 12 - .../JellyfinQt/DTO/recommendationtype.h | 34 - core/include/JellyfinQt/DTO/recordingstatus.h | 37 -- core/include/JellyfinQt/DTO/remoteimageinfo.h | 12 - .../JellyfinQt/DTO/remoteimageresult.h | 12 - .../JellyfinQt/DTO/remotesearchresult.h | 12 - .../JellyfinQt/DTO/remotesubtitleinfo.h | 12 - .../DTO/removefromplaylistrequestdto.h | 12 - core/include/JellyfinQt/DTO/repeatmode.h | 25 - core/include/JellyfinQt/DTO/repositoryinfo.h | 12 - core/include/JellyfinQt/DTO/responseprofile.h | 12 - core/include/JellyfinQt/DTO/scrolldirection.h | 22 - core/include/JellyfinQt/DTO/searchhint.h | 12 - .../include/JellyfinQt/DTO/searchhintresult.h | 12 - core/include/JellyfinQt/DTO/seekrequestdto.h | 12 - core/include/JellyfinQt/DTO/sendcommand.h | 12 - core/include/JellyfinQt/DTO/sendcommandtype.h | 28 - core/include/JellyfinQt/DTO/seriesinfo.h | 12 - .../DTO/seriesinforemotesearchquery.h | 12 - core/include/JellyfinQt/DTO/seriesstatus.h | 22 - .../JellyfinQt/DTO/seriestimerinfodto.h | 12 - .../DTO/seriestimerinfodtoqueryresult.h | 12 - .../JellyfinQt/DTO/serverconfiguration.h | 12 - core/include/JellyfinQt/DTO/sessioninfo.h | 12 - core/include/JellyfinQt/DTO/sessionuserinfo.h | 12 - .../JellyfinQt/DTO/setchannelmappingdto.h | 12 - .../DTO/setplaylistitemrequestdto.h | 12 - .../JellyfinQt/DTO/setrepeatmoderequestdto.h | 12 - .../JellyfinQt/DTO/setshufflemoderequestdto.h | 12 - core/include/JellyfinQt/DTO/songinfo.h | 12 - core/include/JellyfinQt/DTO/sortorder.h | 22 - .../JellyfinQt/DTO/specialviewoptiondto.h | 12 - .../JellyfinQt/DTO/startupconfigurationdto.h | 12 - .../JellyfinQt/DTO/startupremoteaccessdto.h | 12 - core/include/JellyfinQt/DTO/startupuserdto.h | 12 - .../JellyfinQt/DTO/subtitledeliverymethod.h | 28 - .../JellyfinQt/DTO/subtitleplaybackmode.h | 31 - core/include/JellyfinQt/DTO/subtitleprofile.h | 12 - .../JellyfinQt/DTO/syncplayuseraccesstype.h | 25 - core/include/JellyfinQt/DTO/systeminfo.h | 12 - .../JellyfinQt/DTO/taskcompletionstatus.h | 28 - core/include/JellyfinQt/DTO/taskinfo.h | 12 - core/include/JellyfinQt/DTO/taskresult.h | 12 - core/include/JellyfinQt/DTO/taskstate.h | 25 - core/include/JellyfinQt/DTO/tasktriggerinfo.h | 12 - .../include/JellyfinQt/DTO/thememediaresult.h | 12 - core/include/JellyfinQt/DTO/timereventinfo.h | 12 - core/include/JellyfinQt/DTO/timerinfodto.h | 12 - .../JellyfinQt/DTO/timerinfodtoqueryresult.h | 12 - core/include/JellyfinQt/DTO/trailerinfo.h | 12 - .../DTO/trailerinforemotesearchquery.h | 12 - core/include/JellyfinQt/DTO/transcodereason.h | 85 --- .../JellyfinQt/DTO/transcodeseekinfo.h | 22 - core/include/JellyfinQt/DTO/transcodinginfo.h | 12 - .../JellyfinQt/DTO/transcodingprofile.h | 12 - .../JellyfinQt/DTO/transportstreamtimestamp.h | 25 - .../JellyfinQt/DTO/tunerchannelmapping.h | 12 - core/include/JellyfinQt/DTO/tunerhostinfo.h | 12 - core/include/JellyfinQt/DTO/typeoptions.h | 12 - core/include/JellyfinQt/DTO/unrateditem.h | 43 -- .../JellyfinQt/DTO/updatelibraryoptionsdto.h | 12 - .../JellyfinQt/DTO/updateusereasypassword.h | 12 - .../JellyfinQt/DTO/updateuserpassword.h | 12 - .../JellyfinQt/DTO/uploadsubtitledto.h | 12 - core/include/JellyfinQt/DTO/user.h | 43 -- .../JellyfinQt/DTO/userconfiguration.h | 12 - core/include/JellyfinQt/DTO/userdata.h | 43 -- core/include/JellyfinQt/DTO/userdto.h | 12 - core/include/JellyfinQt/DTO/useritemdatadto.h | 12 - core/include/JellyfinQt/DTO/userpolicy.h | 12 - core/include/JellyfinQt/DTO/utctimeresponse.h | 12 - core/include/JellyfinQt/DTO/validatepathdto.h | 12 - core/include/JellyfinQt/DTO/version.h | 12 - core/include/JellyfinQt/DTO/versioninfo.h | 12 - core/include/JellyfinQt/DTO/video3dformat.h | 31 - core/include/JellyfinQt/DTO/videotype.h | 28 - .../JellyfinQt/DTO/virtualfolderinfo.h | 12 - core/include/JellyfinQt/DTO/wakeonlaninfo.h | 12 - core/include/JellyfinQt/DTO/xmlattribute.h | 12 - core/include/JellyfinQt/apimodel.h | 12 +- core/include/JellyfinQt/jellyfin.h | 2 +- core/include/JellyfinQt/model/item.h | 193 ++++++ core/include/JellyfinQt/playbackmanager.h | 17 +- core/include/JellyfinQt/remotedata.h | 9 +- core/include/JellyfinQt/support/jsonconv.h | 97 +-- core/openapigenerator.d | 19 +- core/src/DTO/accessschedule.cpp | 38 +- core/src/DTO/activitylogentry.cpp | 58 +- core/src/DTO/activitylogentryqueryresult.cpp | 30 +- core/src/DTO/addvirtualfolderdto.cpp | 22 +- core/src/DTO/albuminfo.cpp | 70 +- core/src/DTO/albuminforemotesearchquery.cpp | 34 +- core/src/DTO/allthememediaresult.cpp | 30 +- core/src/DTO/architecture.cpp | 31 + core/src/DTO/artistinfo.cpp | 62 +- core/src/DTO/artistinforemotesearchquery.cpp | 34 +- core/src/DTO/authenticateuserbyname.cpp | 30 +- core/src/DTO/authenticationinfo.cpp | 66 +- .../src/DTO/authenticationinfoqueryresult.cpp | 30 +- core/src/DTO/authenticationresult.cpp | 34 +- core/src/DTO/baseitem.cpp | 62 +- core/src/DTO/baseitemdto.cpp | 622 +++++++++--------- core/src/DTO/baseitemdtoqueryresult.cpp | 30 +- core/src/DTO/baseitemperson.cpp | 42 +- core/src/DTO/bookinfo.cpp | 62 +- core/src/DTO/bookinforemotesearchquery.cpp | 34 +- core/src/DTO/boxsetinfo.cpp | 58 +- core/src/DTO/boxsetinforemotesearchquery.cpp | 34 +- core/src/DTO/brandingoptions.cpp | 26 +- core/src/DTO/bufferrequestdto.cpp | 34 +- core/src/DTO/channelfeatures.cpp | 66 +- core/src/DTO/channelitemsortfield.cpp | 37 ++ core/src/DTO/channelmappingoptionsdto.cpp | 34 +- core/src/DTO/channelmediacontenttype.cpp | 40 ++ core/src/DTO/channelmediatype.cpp | 25 + core/src/DTO/channeltype.cpp | 22 + core/src/DTO/chapterinfo.cpp | 38 +- core/src/DTO/clientcapabilities.cpp | 58 +- core/src/DTO/clientcapabilitiesdto.cpp | 58 +- core/src/DTO/codecprofile.cpp | 38 +- core/src/DTO/codectype.cpp | 25 + core/src/DTO/collectioncreationresult.cpp | 22 +- core/src/DTO/configurationpageinfo.cpp | 46 +- core/src/DTO/configurationpagetype.cpp | 22 + core/src/DTO/containerprofile.cpp | 30 +- core/src/DTO/controlresponse.cpp | 30 +- core/src/DTO/countryinfo.cpp | 34 +- core/src/DTO/createplaylistdto.cpp | 34 +- core/src/DTO/createuserbyname.cpp | 26 +- core/src/DTO/culturedto.cpp | 38 +- core/src/DTO/dayofweek.cpp | 37 ++ core/src/DTO/daypattern.cpp | 25 + .../DTO/defaultdirectorybrowserinfodto.cpp | 22 +- core/src/DTO/deviceidentification.cpp | 54 +- core/src/DTO/deviceinfo.cpp | 54 +- core/src/DTO/deviceinfoqueryresult.cpp | 30 +- core/src/DTO/deviceoptions.cpp | 22 +- core/src/DTO/deviceprofile.cpp | 174 ++--- core/src/DTO/deviceprofileinfo.cpp | 30 +- core/src/DTO/deviceprofiletype.cpp | 22 + core/src/DTO/directplayprofile.cpp | 34 +- core/src/DTO/displaypreferencesdto.cpp | 74 ++- core/src/DTO/dlnaprofiletype.cpp | 25 + core/src/DTO/dynamicdayofweek.cpp | 46 ++ core/src/DTO/encodingcontext.cpp | 22 + core/src/DTO/endpointinfo.cpp | 26 +- core/src/DTO/externalidinfo.cpp | 34 +- core/src/DTO/externalidmediatype.cpp | 52 ++ core/src/DTO/externalurl.cpp | 26 +- core/src/DTO/ffmpeglocation.cpp | 28 + core/src/DTO/filesystementryinfo.cpp | 30 +- core/src/DTO/filesystementrytype.cpp | 28 + core/src/DTO/fontfile.cpp | 34 +- core/src/DTO/forgotpasswordaction.cpp | 25 + core/src/DTO/forgotpassworddto.cpp | 22 +- core/src/DTO/forgotpasswordresult.cpp | 30 +- core/src/DTO/generalcommand.cpp | 30 +- core/src/DTO/generalcommandtype.cpp | 139 ++++ core/src/DTO/getprogramsdto.cpp | 126 ++-- core/src/DTO/groupinfodto.cpp | 38 +- core/src/DTO/groupqueuemode.cpp | 22 + core/src/DTO/grouprepeatmode.cpp | 25 + core/src/DTO/groupshufflemode.cpp | 22 + core/src/DTO/groupstatetype.cpp | 28 + core/src/DTO/groupupdatetype.cpp | 49 ++ core/src/DTO/guideinfo.cpp | 26 +- core/src/DTO/headermatchtype.cpp | 25 + core/src/DTO/httpheaderinfo.cpp | 30 +- core/src/DTO/ignorewaitrequestdto.cpp | 22 +- core/src/DTO/imagebynameinfo.cpp | 38 +- core/src/DTO/imageformat.cpp | 31 + core/src/DTO/imageinfo.cpp | 50 +- core/src/DTO/imageoption.cpp | 30 +- core/src/DTO/imageorientation.cpp | 40 ++ core/src/DTO/imageproviderinfo.cpp | 26 +- core/src/DTO/imagesavingconvention.cpp | 22 + core/src/DTO/imagetype.cpp | 55 ++ core/src/DTO/installationinfo.cpp | 42 +- core/src/DTO/iplugin.cpp | 46 +- core/src/DTO/isotype.cpp | 22 + core/src/DTO/item.cpp | 0 core/src/DTO/itemcounts.cpp | 66 +- core/src/DTO/itemfields.cpp | 199 ++++++ core/src/DTO/itemfilter.cpp | 43 ++ core/src/DTO/joingrouprequestdto.cpp | 22 +- core/src/DTO/keepuntil.cpp | 28 + core/src/DTO/libraryoptioninfodto.cpp | 26 +- core/src/DTO/libraryoptions.cpp | 118 ++-- core/src/DTO/libraryoptionsresultdto.cpp | 34 +- core/src/DTO/librarytypeoptionsdto.cpp | 38 +- core/src/DTO/libraryupdateinfo.cpp | 46 +- core/src/DTO/listingsproviderinfo.cpp | 90 +-- core/src/DTO/livestreamresponse.cpp | 22 +- core/src/DTO/livetvinfo.cpp | 30 +- core/src/DTO/livetvserviceinfo.cpp | 50 +- core/src/DTO/livetvservicestatus.cpp | 22 + core/src/DTO/localizationoption.cpp | 26 +- core/src/DTO/locationtype.cpp | 28 + core/src/DTO/logfile.cpp | 34 +- core/src/DTO/loglevel.cpp | 37 ++ core/src/DTO/mediaattachment.cpp | 46 +- core/src/DTO/mediaencoderpathdto.cpp | 26 +- core/src/DTO/mediapathdto.cpp | 30 +- core/src/DTO/mediapathinfo.cpp | 26 +- core/src/DTO/mediaprotocol.cpp | 37 ++ core/src/DTO/mediasourceinfo.cpp | 186 +++--- core/src/DTO/mediasourcetype.cpp | 25 + core/src/DTO/mediastream.cpp | 206 +++--- core/src/DTO/mediastreamtype.cpp | 28 + core/src/DTO/mediaupdateinfodto.cpp | 26 +- core/src/DTO/mediaurl.cpp | 26 +- core/src/DTO/metadataeditorinfo.cpp | 42 +- core/src/DTO/metadatafield.cpp | 43 ++ core/src/DTO/metadataoptions.cpp | 46 +- core/src/DTO/metadatarefreshmode.cpp | 28 + core/src/DTO/moveplaylistitemrequestdto.cpp | 26 +- core/src/DTO/movieinfo.cpp | 58 +- core/src/DTO/movieinforemotesearchquery.cpp | 34 +- core/src/DTO/musicvideoinfo.cpp | 62 +- .../DTO/musicvideoinforemotesearchquery.cpp | 34 +- core/src/DTO/nameguidpair.cpp | 26 +- core/src/DTO/nameidpair.cpp | 26 +- core/src/DTO/namevaluepair.cpp | 26 +- core/src/DTO/newgrouprequestdto.cpp | 22 +- core/src/DTO/nextitemrequestdto.cpp | 22 +- core/src/DTO/notificationdto.cpp | 50 +- core/src/DTO/notificationlevel.cpp | 25 + core/src/DTO/notificationresultdto.cpp | 26 +- core/src/DTO/notificationssummarydto.cpp | 26 +- core/src/DTO/notificationtypeinfo.cpp | 38 +- core/src/DTO/objectgroupupdate.cpp | 30 +- core/src/DTO/openlivestreamdto.cpp | 70 +- core/src/DTO/packageinfo.cpp | 50 +- core/src/DTO/parentalrating.cpp | 26 +- core/src/DTO/pathsubstitution.cpp | 26 +- core/src/DTO/personlookupinfo.cpp | 58 +- .../DTO/personlookupinforemotesearchquery.cpp | 34 +- core/src/DTO/pingrequestdto.cpp | 22 +- core/src/DTO/pinredeemresult.cpp | 26 +- core/src/DTO/playaccess.cpp | 22 + core/src/DTO/playbackerrorcode.cpp | 25 + core/src/DTO/playbackinfodto.cpp | 78 ++- core/src/DTO/playbackinforesponse.cpp | 30 +- core/src/DTO/playbackprogressinfo.cpp | 98 +-- core/src/DTO/playbackstartinfo.cpp | 98 +-- core/src/DTO/playbackstopinfo.cpp | 62 +- core/src/DTO/playcommand.cpp | 31 + core/src/DTO/playerstateinfo.cpp | 58 +- core/src/DTO/playlistcreationresult.cpp | 22 +- core/src/DTO/playmethod.cpp | 25 + core/src/DTO/playrequest.cpp | 50 +- core/src/DTO/playrequestdto.cpp | 30 +- core/src/DTO/playstatecommand.cpp | 43 ++ core/src/DTO/playstaterequest.cpp | 30 +- core/src/DTO/plugininfo.cpp | 50 +- core/src/DTO/pluginsecurityinfo.cpp | 26 +- core/src/DTO/pluginstatus.cpp | 37 ++ core/src/DTO/previousitemrequestdto.cpp | 22 +- core/src/DTO/problemdetails.cpp | 38 +- core/src/DTO/profilecondition.cpp | 34 +- core/src/DTO/profileconditiontype.cpp | 31 + core/src/DTO/profileconditionvalue.cpp | 85 +++ core/src/DTO/programaudio.cpp | 34 + core/src/DTO/publicsysteminfo.cpp | 46 +- core/src/DTO/queryfilters.cpp | 26 +- core/src/DTO/queryfilterslegacy.cpp | 34 +- core/src/DTO/queueitem.cpp | 26 +- core/src/DTO/queuerequestdto.cpp | 26 +- core/src/DTO/quickconnectdto.cpp | 22 +- core/src/DTO/quickconnectresult.cpp | 42 +- core/src/DTO/quickconnectstate.cpp | 25 + core/src/DTO/ratingtype.cpp | 22 + core/src/DTO/readyrequestdto.cpp | 34 +- core/src/DTO/recommendationdto.cpp | 34 +- core/src/DTO/recommendationtype.cpp | 34 + core/src/DTO/recordingstatus.cpp | 37 ++ core/src/DTO/remoteimageinfo.cpp | 58 +- core/src/DTO/remoteimageresult.cpp | 30 +- core/src/DTO/remotesearchresult.cpp | 66 +- core/src/DTO/remotesubtitleinfo.cpp | 62 +- core/src/DTO/removefromplaylistrequestdto.cpp | 22 +- core/src/DTO/repeatmode.cpp | 25 + core/src/DTO/repositoryinfo.cpp | 30 +- core/src/DTO/responseprofile.cpp | 46 +- core/src/DTO/scrolldirection.cpp | 22 + core/src/DTO/searchhint.cpp | 134 ++-- core/src/DTO/searchhintresult.cpp | 26 +- core/src/DTO/seekrequestdto.cpp | 22 +- core/src/DTO/sendcommand.cpp | 42 +- core/src/DTO/sendcommandtype.cpp | 28 + core/src/DTO/seriesinfo.cpp | 58 +- core/src/DTO/seriesinforemotesearchquery.cpp | 34 +- core/src/DTO/seriesstatus.cpp | 22 + core/src/DTO/seriestimerinfodto.cpp | 158 +++-- .../src/DTO/seriestimerinfodtoqueryresult.cpp | 30 +- core/src/DTO/serverconfiguration.cpp | 358 +++++----- core/src/DTO/sessioninfo.cpp | 130 ++-- core/src/DTO/sessionuserinfo.cpp | 26 +- core/src/DTO/setchannelmappingdto.cpp | 30 +- core/src/DTO/setplaylistitemrequestdto.cpp | 22 +- core/src/DTO/setrepeatmoderequestdto.cpp | 22 +- core/src/DTO/setshufflemoderequestdto.cpp | 22 +- core/src/DTO/songinfo.cpp | 70 +- core/src/DTO/sortorder.cpp | 22 + core/src/DTO/specialviewoptiondto.cpp | 26 +- core/src/DTO/startupconfigurationdto.cpp | 30 +- core/src/DTO/startupremoteaccessdto.cpp | 26 +- core/src/DTO/startupuserdto.cpp | 26 +- core/src/DTO/subtitledeliverymethod.cpp | 28 + core/src/DTO/subtitleplaybackmode.cpp | 31 + core/src/DTO/subtitleprofile.cpp | 38 +- core/src/DTO/syncplayuseraccesstype.cpp | 25 + core/src/DTO/systeminfo.cpp | 122 ++-- core/src/DTO/taskcompletionstatus.cpp | 28 + core/src/DTO/taskinfo.cpp | 58 +- core/src/DTO/taskresult.cpp | 50 +- core/src/DTO/taskstate.cpp | 25 + core/src/DTO/tasktriggerinfo.cpp | 38 +- core/src/DTO/thememediaresult.cpp | 34 +- core/src/DTO/timereventinfo.cpp | 26 +- core/src/DTO/timerinfodto.cpp | 130 ++-- core/src/DTO/timerinfodtoqueryresult.cpp | 30 +- core/src/DTO/trailerinfo.cpp | 58 +- core/src/DTO/trailerinforemotesearchquery.cpp | 34 +- core/src/DTO/transcodereason.cpp | 85 +++ core/src/DTO/transcodeseekinfo.cpp | 22 + core/src/DTO/transcodinginfo.cpp | 66 +- core/src/DTO/transcodingprofile.cpp | 78 ++- core/src/DTO/transportstreamtimestamp.cpp | 25 + core/src/DTO/tunerchannelmapping.cpp | 34 +- core/src/DTO/tunerhostinfo.cpp | 62 +- core/src/DTO/typeoptions.cpp | 42 +- core/src/DTO/unrateditem.cpp | 43 ++ core/src/DTO/updatelibraryoptionsdto.cpp | 26 +- core/src/DTO/updateusereasypassword.cpp | 30 +- core/src/DTO/updateuserpassword.cpp | 34 +- core/src/DTO/uploadsubtitledto.cpp | 34 +- core/src/DTO/user.cpp | 0 core/src/DTO/userconfiguration.cpp | 78 ++- core/src/DTO/userdata.cpp | 0 core/src/DTO/userdto.cpp | 74 ++- core/src/DTO/useritemdatadto.cpp | 62 +- core/src/DTO/userpolicy.cpp | 174 ++--- core/src/DTO/utctimeresponse.cpp | 26 +- core/src/DTO/validatepathdto.cpp | 30 +- core/src/DTO/version.cpp | 42 +- core/src/DTO/versioninfo.cpp | 54 +- core/src/DTO/video3dformat.cpp | 31 + core/src/DTO/videotype.cpp | 28 + core/src/DTO/virtualfolderinfo.cpp | 50 +- core/src/DTO/wakeonlaninfo.cpp | 26 +- core/src/DTO/xmlattribute.cpp | 26 +- core/src/apimodel.cpp | 8 +- core/src/model/item.cpp | 10 + core/src/playbackmanager.cpp | 72 +- core/src/remotedata.cpp | 14 +- core/src/support/jsonconv.cpp | 108 +++ core/src/websocket.cpp | 7 +- 551 files changed, 8943 insertions(+), 8809 deletions(-) create mode 100644 core/codegen/enum_implementation.hbs delete mode 100644 core/include/JellyfinQt/DTO/item.h delete mode 100644 core/include/JellyfinQt/DTO/user.h delete mode 100644 core/include/JellyfinQt/DTO/userdata.h create mode 100644 core/include/JellyfinQt/model/item.h delete mode 100644 core/src/DTO/item.cpp delete mode 100644 core/src/DTO/user.cpp delete mode 100644 core/src/DTO/userdata.cpp create mode 100644 core/src/model/item.cpp create mode 100644 core/src/support/jsonconv.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 062ecf9..4c75656 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,3 +25,6 @@ if(PLATFORM_SAILFISHOS) elseif(PLATFORM_QTQUICK) add_subdirectory(qtquick) endif() + +include(FeatureSummary) +feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 22ee062..a589af8 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -1,11 +1,47 @@ project(jellyfin-qt VERSION 0.1.0) find_package(Qt5 5.6 COMPONENTS Multimedia Network Qml WebSockets REQUIRED) include(GNUInstallDirs) +include(FetchContent) + +find_package(Boost REQUIRED) +find_package(Immer) +if(NOT Immer_FOUND) + message(STATUS "Using Immer from FetchContent") + set(immer_BUILD_TESTS OFF) + set(immer_BUILD_EXAMPLES OFF) + set(immer_BUILD_DOCS OFF) + set(immer_BUILD_EXTRAS OFF) + FetchContent_Declare(immer GIT_REPOSITORY https://github.com/arximboldi/immer GIT_TAG + 800ddb04e528a3e83e69e8021d7e872e7c34cbcd) + FetchContent_MakeAvailable(immer) +endif() + +find_package(Lager) +if(NOT Lager_FOUND) + message(STATUS "Using lager from FetchContent") + set(lager_BUILD_TESTS OFF) + set(lager_BUILD_EXAMPLES OFF) + set(lager_BUILD_DOCS OFF) + set(lager_EMBED_RESOURCES_PATH OFF) + FetchContent_Declare(lager GIT_REPOSITORY https://github.com/arximboldi/lager GIT_TAG + 71eca6b0ebbccf3e0e54324b6967f047e49ba92d) + FetchContent_MakeAvailable(lager) +endif() + +find_package(cereal) +if(NOT cereal_FOUND) + set(JUST_INSTALL_CEREAL ON) + FetchContent_Declare(cereal GIT_REPOSITORY https://github.com/USCiLab/cereal GIT_TAG v1.3.0) + FetchContent_MakeAvailable(cereal) +endif() + include(GeneratedSources.cmake) set(jellyfin-qt_SOURCES # src/DTO/dto.cpp + src/model/item.cpp + src/support/jsonconv.cpp src/support/loader.cpp src/apiclient.cpp src/apimodel.cpp @@ -22,6 +58,8 @@ list(APPEND jellyfin-qt_SOURCES ${openapi_SOURCES}) set(jellyfin-qt_HEADERS # include/JellyfinQt/DTO/dto.h + include/JellyfinQt/model/item.h + include/JellyfinQt/support/jsonconv.h include/JellyfinQt/support/loader.h include/JellyfinQt/apiclient.h include/JellyfinQt/apimodel.h diff --git a/core/codegen/enum_header.hbs b/core/codegen/enum_header.hbs index 39b3fdb..a247228 100644 --- a/core/codegen/enum_header.hbs +++ b/core/codegen/enum_header.hbs @@ -15,27 +15,3 @@ private: }; typedef {{className}}Class::Value {{className}}; - -} // NS DTO - -namespace Support { - -using {{className}} = Jellyfin::DTO::{{className}}; -using {{className}}Class = Jellyfin::DTO::{{className}}Class; - -template <> - -{{className}} fromJsonValue<{{className}}>(const QJsonValue &source) { - if (!source.isString()) return {{className}}Class::EnumNotSet; - - QString str = source.toString(); - - {{#each values as |value|}} - if (str == QStringLiteral("{{value}}")) { - return {{className}}Class::{{value}}; - } - - {{/each}} - - return {{className}}Class::EnumNotSet; -} diff --git a/core/codegen/enum_implementation.hbs b/core/codegen/enum_implementation.hbs new file mode 100644 index 0000000..cb8cc6c --- /dev/null +++ b/core/codegen/enum_implementation.hbs @@ -0,0 +1,25 @@ +{{className}}Class::{{className}}Class() {} + + +} // NS DTO + +namespace Support { + +using {{className}} = Jellyfin::DTO::{{className}}; + +template <> + +{{className}} fromJsonValue<{{className}}>(const QJsonValue &source) { + if (!source.isString()) return {{className}}::EnumNotSet; + + QString str = source.toString(); + + {{#each values as |value|}} + if (str == QStringLiteral("{{value}}")) { + return {{className}}::{{value}}; + } + + {{/each}} + + return {{className}}::EnumNotSet; +} diff --git a/core/codegen/object_header.hbs b/core/codegen/object_header.hbs index 467853a..ebabcd1 100644 --- a/core/codegen/object_header.hbs +++ b/core/codegen/object_header.hbs @@ -50,16 +50,3 @@ protected: {{/each}} }; - -} // NS DTO - -namespace Support { - -using {{className}} = Jellyfin::DTO::{{className}}; - -template <> - -{{className}} fromJsonValue<{{className}}>(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return {{className}}::fromJson(source.toObject()); -} diff --git a/core/codegen/object_implementation.hbs b/core/codegen/object_implementation.hbs index ded1c98..b789aa3 100644 --- a/core/codegen/object_implementation.hbs +++ b/core/codegen/object_implementation.hbs @@ -1,9 +1,10 @@ -{{className}}::{{className}}(QObject *parent) {} +{{className}}::{{className}}() {} {{className}} {{className}}::fromJson(QJsonObject source) { + {{className}} instance; - instance->setFromJson(source, false); + instance.setFromJson(source); return instance; } @@ -11,7 +12,7 @@ void {{className}}::setFromJson(QJsonObject source) { {{#each properties as |property|}} - {{property.memberName}} = fromJsonValue<{{property.typeNameWithQualifiers}}>(source["{{property.originalName}}"]); + {{property.memberName}} = {{supportNamespace}}::fromJsonValue<{{property.typeNameWithQualifiers}}>(source["{{property.originalName}}"]); {{/each}} @@ -21,7 +22,7 @@ QJsonObject {{className}}::toJson() { QJsonObject result; {{#each properties as |property|}} - result["{{property.originalName}}"] = toJsonValue<{{property.typeNameWithQualifiers}}>({{property.memberName}}); + result["{{property.originalName}}"] = {{supportNamespace}}::toJsonValue<{{property.typeNameWithQualifiers}}>({{property.memberName}}); {{/each}} @@ -46,3 +47,16 @@ void {{className}}::setNull() { {{property.nullableSetter}}; } {{/each}} + +} // NS DTO + +namespace Support { + +using {{className}} = Jellyfin::DTO::{{className}}; + +template <> + +{{className}} fromJsonValue<{{className}}>(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return {{className}}::fromJson(source.toObject()); +} diff --git a/core/include/JellyfinQt/DTO/accessschedule.h b/core/include/JellyfinQt/DTO/accessschedule.h index 124140b..135b014 100644 --- a/core/include/JellyfinQt/DTO/accessschedule.h +++ b/core/include/JellyfinQt/DTO/accessschedule.h @@ -95,18 +95,6 @@ protected: double m_endHour; }; -} // NS DTO - -namespace Support { - -using AccessSchedule = Jellyfin::DTO::AccessSchedule; - -template <> -AccessSchedule fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return AccessSchedule::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/activitylogentry.h b/core/include/JellyfinQt/DTO/activitylogentry.h index 262dc58..acf4a5f 100644 --- a/core/include/JellyfinQt/DTO/activitylogentry.h +++ b/core/include/JellyfinQt/DTO/activitylogentry.h @@ -142,18 +142,6 @@ protected: LogLevel m_severity; }; -} // NS DTO - -namespace Support { - -using ActivityLogEntry = Jellyfin::DTO::ActivityLogEntry; - -template <> -ActivityLogEntry fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ActivityLogEntry::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/activitylogentryqueryresult.h b/core/include/JellyfinQt/DTO/activitylogentryqueryresult.h index ab99fca..aec81a9 100644 --- a/core/include/JellyfinQt/DTO/activitylogentryqueryresult.h +++ b/core/include/JellyfinQt/DTO/activitylogentryqueryresult.h @@ -83,18 +83,6 @@ protected: qint32 m_startIndex; }; -} // NS DTO - -namespace Support { - -using ActivityLogEntryQueryResult = Jellyfin::DTO::ActivityLogEntryQueryResult; - -template <> -ActivityLogEntryQueryResult fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ActivityLogEntryQueryResult::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/addvirtualfolderdto.h b/core/include/JellyfinQt/DTO/addvirtualfolderdto.h index 39d1ff2..e2e05e2 100644 --- a/core/include/JellyfinQt/DTO/addvirtualfolderdto.h +++ b/core/include/JellyfinQt/DTO/addvirtualfolderdto.h @@ -59,18 +59,6 @@ protected: QSharedPointer m_libraryOptions = nullptr; }; -} // NS DTO - -namespace Support { - -using AddVirtualFolderDto = Jellyfin::DTO::AddVirtualFolderDto; - -template <> -AddVirtualFolderDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return AddVirtualFolderDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/albuminfo.h b/core/include/JellyfinQt/DTO/albuminfo.h index d090847..6f5a358 100644 --- a/core/include/JellyfinQt/DTO/albuminfo.h +++ b/core/include/JellyfinQt/DTO/albuminfo.h @@ -155,18 +155,6 @@ protected: QList> m_songInfos; }; -} // NS DTO - -namespace Support { - -using AlbumInfo = Jellyfin::DTO::AlbumInfo; - -template <> -AlbumInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return AlbumInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/albuminforemotesearchquery.h b/core/include/JellyfinQt/DTO/albuminforemotesearchquery.h index f337344..8964a90 100644 --- a/core/include/JellyfinQt/DTO/albuminforemotesearchquery.h +++ b/core/include/JellyfinQt/DTO/albuminforemotesearchquery.h @@ -84,18 +84,6 @@ protected: bool m_includeDisabledProviders; }; -} // NS DTO - -namespace Support { - -using AlbumInfoRemoteSearchQuery = Jellyfin::DTO::AlbumInfoRemoteSearchQuery; - -template <> -AlbumInfoRemoteSearchQuery fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return AlbumInfoRemoteSearchQuery::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/allthememediaresult.h b/core/include/JellyfinQt/DTO/allthememediaresult.h index 7591dba..f35ce1c 100644 --- a/core/include/JellyfinQt/DTO/allthememediaresult.h +++ b/core/include/JellyfinQt/DTO/allthememediaresult.h @@ -69,18 +69,6 @@ protected: QSharedPointer m_soundtrackSongsResult = nullptr; }; -} // NS DTO - -namespace Support { - -using AllThemeMediaResult = Jellyfin::DTO::AllThemeMediaResult; - -template <> -AllThemeMediaResult fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return AllThemeMediaResult::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/architecture.h b/core/include/JellyfinQt/DTO/architecture.h index 69c74ee..16a91a5 100644 --- a/core/include/JellyfinQt/DTO/architecture.h +++ b/core/include/JellyfinQt/DTO/architecture.h @@ -57,37 +57,6 @@ private: typedef ArchitectureClass::Value Architecture; -} // NS DTO - -namespace Support { - -using Architecture = Jellyfin::DTO::Architecture; -using ArchitectureClass = Jellyfin::DTO::ArchitectureClass; - -template <> -Architecture fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return ArchitectureClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("X86")) { - return ArchitectureClass::X86; - } - if (str == QStringLiteral("X64")) { - return ArchitectureClass::X64; - } - if (str == QStringLiteral("Arm")) { - return ArchitectureClass::Arm; - } - if (str == QStringLiteral("Arm64")) { - return ArchitectureClass::Arm64; - } - if (str == QStringLiteral("Wasm")) { - return ArchitectureClass::Wasm; - } - - return ArchitectureClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/artistinfo.h b/core/include/JellyfinQt/DTO/artistinfo.h index 9d9200c..f03885e 100644 --- a/core/include/JellyfinQt/DTO/artistinfo.h +++ b/core/include/JellyfinQt/DTO/artistinfo.h @@ -137,18 +137,6 @@ protected: QList> m_songInfos; }; -} // NS DTO - -namespace Support { - -using ArtistInfo = Jellyfin::DTO::ArtistInfo; - -template <> -ArtistInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ArtistInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/artistinforemotesearchquery.h b/core/include/JellyfinQt/DTO/artistinforemotesearchquery.h index aa56cf0..254422d 100644 --- a/core/include/JellyfinQt/DTO/artistinforemotesearchquery.h +++ b/core/include/JellyfinQt/DTO/artistinforemotesearchquery.h @@ -84,18 +84,6 @@ protected: bool m_includeDisabledProviders; }; -} // NS DTO - -namespace Support { - -using ArtistInfoRemoteSearchQuery = Jellyfin::DTO::ArtistInfoRemoteSearchQuery; - -template <> -ArtistInfoRemoteSearchQuery fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ArtistInfoRemoteSearchQuery::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/authenticateuserbyname.h b/core/include/JellyfinQt/DTO/authenticateuserbyname.h index f2bd5da..d24fc4d 100644 --- a/core/include/JellyfinQt/DTO/authenticateuserbyname.h +++ b/core/include/JellyfinQt/DTO/authenticateuserbyname.h @@ -80,18 +80,6 @@ protected: QString m_password; }; -} // NS DTO - -namespace Support { - -using AuthenticateUserByName = Jellyfin::DTO::AuthenticateUserByName; - -template <> -AuthenticateUserByName fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return AuthenticateUserByName::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/authenticationinfo.h b/core/include/JellyfinQt/DTO/authenticationinfo.h index 7df5cd9..9c69930 100644 --- a/core/include/JellyfinQt/DTO/authenticationinfo.h +++ b/core/include/JellyfinQt/DTO/authenticationinfo.h @@ -155,18 +155,6 @@ protected: QString m_userName; }; -} // NS DTO - -namespace Support { - -using AuthenticationInfo = Jellyfin::DTO::AuthenticationInfo; - -template <> -AuthenticationInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return AuthenticationInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/authenticationinfoqueryresult.h b/core/include/JellyfinQt/DTO/authenticationinfoqueryresult.h index 0304649..0ab6ec6 100644 --- a/core/include/JellyfinQt/DTO/authenticationinfoqueryresult.h +++ b/core/include/JellyfinQt/DTO/authenticationinfoqueryresult.h @@ -83,18 +83,6 @@ protected: qint32 m_startIndex; }; -} // NS DTO - -namespace Support { - -using AuthenticationInfoQueryResult = Jellyfin::DTO::AuthenticationInfoQueryResult; - -template <> -AuthenticationInfoQueryResult fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return AuthenticationInfoQueryResult::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/authenticationresult.h b/core/include/JellyfinQt/DTO/authenticationresult.h index 9466266..5bea7f0 100644 --- a/core/include/JellyfinQt/DTO/authenticationresult.h +++ b/core/include/JellyfinQt/DTO/authenticationresult.h @@ -76,18 +76,6 @@ protected: QString m_serverId; }; -} // NS DTO - -namespace Support { - -using AuthenticationResult = Jellyfin::DTO::AuthenticationResult; - -template <> -AuthenticationResult fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return AuthenticationResult::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/baseitem.h b/core/include/JellyfinQt/DTO/baseitem.h index 64c329d..90b6b0b 100644 --- a/core/include/JellyfinQt/DTO/baseitem.h +++ b/core/include/JellyfinQt/DTO/baseitem.h @@ -118,18 +118,6 @@ protected: bool m_supportsExternalTransfer; }; -} // NS DTO - -namespace Support { - -using BaseItem = Jellyfin::DTO::BaseItem; - -template <> -BaseItem fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return BaseItem::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/baseitemdto.h b/core/include/JellyfinQt/DTO/baseitemdto.h index 805e17b..02e10b5 100644 --- a/core/include/JellyfinQt/DTO/baseitemdto.h +++ b/core/include/JellyfinQt/DTO/baseitemdto.h @@ -1261,18 +1261,6 @@ protected: QSharedPointer m_currentProgram = nullptr; }; -} // NS DTO - -namespace Support { - -using BaseItemDto = Jellyfin::DTO::BaseItemDto; - -template <> -BaseItemDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return BaseItemDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/baseitemdtoqueryresult.h b/core/include/JellyfinQt/DTO/baseitemdtoqueryresult.h index 2a76c0c..099bcc1 100644 --- a/core/include/JellyfinQt/DTO/baseitemdtoqueryresult.h +++ b/core/include/JellyfinQt/DTO/baseitemdtoqueryresult.h @@ -83,18 +83,6 @@ protected: qint32 m_startIndex; }; -} // NS DTO - -namespace Support { - -using BaseItemDtoQueryResult = Jellyfin::DTO::BaseItemDtoQueryResult; - -template <> -BaseItemDtoQueryResult fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return BaseItemDtoQueryResult::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/baseitemperson.h b/core/include/JellyfinQt/DTO/baseitemperson.h index e13745a..f5e730f 100644 --- a/core/include/JellyfinQt/DTO/baseitemperson.h +++ b/core/include/JellyfinQt/DTO/baseitemperson.h @@ -107,18 +107,6 @@ protected: QJsonObject m_imageBlurHashes; }; -} // NS DTO - -namespace Support { - -using BaseItemPerson = Jellyfin::DTO::BaseItemPerson; - -template <> -BaseItemPerson fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return BaseItemPerson::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/bookinfo.h b/core/include/JellyfinQt/DTO/bookinfo.h index 349f2cd..6149b36 100644 --- a/core/include/JellyfinQt/DTO/bookinfo.h +++ b/core/include/JellyfinQt/DTO/bookinfo.h @@ -133,18 +133,6 @@ protected: QString m_seriesName; }; -} // NS DTO - -namespace Support { - -using BookInfo = Jellyfin::DTO::BookInfo; - -template <> -BookInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return BookInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/bookinforemotesearchquery.h b/core/include/JellyfinQt/DTO/bookinforemotesearchquery.h index 8322e7f..0a99f70 100644 --- a/core/include/JellyfinQt/DTO/bookinforemotesearchquery.h +++ b/core/include/JellyfinQt/DTO/bookinforemotesearchquery.h @@ -84,18 +84,6 @@ protected: bool m_includeDisabledProviders; }; -} // NS DTO - -namespace Support { - -using BookInfoRemoteSearchQuery = Jellyfin::DTO::BookInfoRemoteSearchQuery; - -template <> -BookInfoRemoteSearchQuery fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return BookInfoRemoteSearchQuery::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/boxsetinfo.h b/core/include/JellyfinQt/DTO/boxsetinfo.h index 3f1c02f..e49088b 100644 --- a/core/include/JellyfinQt/DTO/boxsetinfo.h +++ b/core/include/JellyfinQt/DTO/boxsetinfo.h @@ -128,18 +128,6 @@ protected: bool m_isAutomated; }; -} // NS DTO - -namespace Support { - -using BoxSetInfo = Jellyfin::DTO::BoxSetInfo; - -template <> -BoxSetInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return BoxSetInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/boxsetinforemotesearchquery.h b/core/include/JellyfinQt/DTO/boxsetinforemotesearchquery.h index 672de56..c204764 100644 --- a/core/include/JellyfinQt/DTO/boxsetinforemotesearchquery.h +++ b/core/include/JellyfinQt/DTO/boxsetinforemotesearchquery.h @@ -84,18 +84,6 @@ protected: bool m_includeDisabledProviders; }; -} // NS DTO - -namespace Support { - -using BoxSetInfoRemoteSearchQuery = Jellyfin::DTO::BoxSetInfoRemoteSearchQuery; - -template <> -BoxSetInfoRemoteSearchQuery fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return BoxSetInfoRemoteSearchQuery::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/brandingoptions.h b/core/include/JellyfinQt/DTO/brandingoptions.h index 6b6896b..e267287 100644 --- a/core/include/JellyfinQt/DTO/brandingoptions.h +++ b/core/include/JellyfinQt/DTO/brandingoptions.h @@ -71,18 +71,6 @@ protected: QString m_customCss; }; -} // NS DTO - -namespace Support { - -using BrandingOptions = Jellyfin::DTO::BrandingOptions; - -template <> -BrandingOptions fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return BrandingOptions::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/bufferrequestdto.h b/core/include/JellyfinQt/DTO/bufferrequestdto.h index 798dd47..36902fa 100644 --- a/core/include/JellyfinQt/DTO/bufferrequestdto.h +++ b/core/include/JellyfinQt/DTO/bufferrequestdto.h @@ -90,18 +90,6 @@ protected: QUuid m_playlistItemId; }; -} // NS DTO - -namespace Support { - -using BufferRequestDto = Jellyfin::DTO::BufferRequestDto; - -template <> -BufferRequestDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return BufferRequestDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/channelfeatures.h b/core/include/JellyfinQt/DTO/channelfeatures.h index 81b95bf..2b0106d 100644 --- a/core/include/JellyfinQt/DTO/channelfeatures.h +++ b/core/include/JellyfinQt/DTO/channelfeatures.h @@ -166,18 +166,6 @@ protected: bool m_supportsContentDownloading; }; -} // NS DTO - -namespace Support { - -using ChannelFeatures = Jellyfin::DTO::ChannelFeatures; - -template <> -ChannelFeatures fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ChannelFeatures::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/channelitemsortfield.h b/core/include/JellyfinQt/DTO/channelitemsortfield.h index 3139beb..7886638 100644 --- a/core/include/JellyfinQt/DTO/channelitemsortfield.h +++ b/core/include/JellyfinQt/DTO/channelitemsortfield.h @@ -59,43 +59,6 @@ private: typedef ChannelItemSortFieldClass::Value ChannelItemSortField; -} // NS DTO - -namespace Support { - -using ChannelItemSortField = Jellyfin::DTO::ChannelItemSortField; -using ChannelItemSortFieldClass = Jellyfin::DTO::ChannelItemSortFieldClass; - -template <> -ChannelItemSortField fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return ChannelItemSortFieldClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Name")) { - return ChannelItemSortFieldClass::Name; - } - if (str == QStringLiteral("CommunityRating")) { - return ChannelItemSortFieldClass::CommunityRating; - } - if (str == QStringLiteral("PremiereDate")) { - return ChannelItemSortFieldClass::PremiereDate; - } - if (str == QStringLiteral("DateCreated")) { - return ChannelItemSortFieldClass::DateCreated; - } - if (str == QStringLiteral("Runtime")) { - return ChannelItemSortFieldClass::Runtime; - } - if (str == QStringLiteral("PlayCount")) { - return ChannelItemSortFieldClass::PlayCount; - } - if (str == QStringLiteral("CommunityPlayCount")) { - return ChannelItemSortFieldClass::CommunityPlayCount; - } - - return ChannelItemSortFieldClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/channelmappingoptionsdto.h b/core/include/JellyfinQt/DTO/channelmappingoptionsdto.h index 7cbc942..cbb7db8 100644 --- a/core/include/JellyfinQt/DTO/channelmappingoptionsdto.h +++ b/core/include/JellyfinQt/DTO/channelmappingoptionsdto.h @@ -95,18 +95,6 @@ protected: QString m_providerName; }; -} // NS DTO - -namespace Support { - -using ChannelMappingOptionsDto = Jellyfin::DTO::ChannelMappingOptionsDto; - -template <> -ChannelMappingOptionsDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ChannelMappingOptionsDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/channelmediacontenttype.h b/core/include/JellyfinQt/DTO/channelmediacontenttype.h index 40ef270..c77fa66 100644 --- a/core/include/JellyfinQt/DTO/channelmediacontenttype.h +++ b/core/include/JellyfinQt/DTO/channelmediacontenttype.h @@ -60,46 +60,6 @@ private: typedef ChannelMediaContentTypeClass::Value ChannelMediaContentType; -} // NS DTO - -namespace Support { - -using ChannelMediaContentType = Jellyfin::DTO::ChannelMediaContentType; -using ChannelMediaContentTypeClass = Jellyfin::DTO::ChannelMediaContentTypeClass; - -template <> -ChannelMediaContentType fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return ChannelMediaContentTypeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Clip")) { - return ChannelMediaContentTypeClass::Clip; - } - if (str == QStringLiteral("Podcast")) { - return ChannelMediaContentTypeClass::Podcast; - } - if (str == QStringLiteral("Trailer")) { - return ChannelMediaContentTypeClass::Trailer; - } - if (str == QStringLiteral("Movie")) { - return ChannelMediaContentTypeClass::Movie; - } - if (str == QStringLiteral("Episode")) { - return ChannelMediaContentTypeClass::Episode; - } - if (str == QStringLiteral("Song")) { - return ChannelMediaContentTypeClass::Song; - } - if (str == QStringLiteral("MovieExtra")) { - return ChannelMediaContentTypeClass::MovieExtra; - } - if (str == QStringLiteral("TvExtra")) { - return ChannelMediaContentTypeClass::TvExtra; - } - - return ChannelMediaContentTypeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/channelmediatype.h b/core/include/JellyfinQt/DTO/channelmediatype.h index 268197b..00c86f9 100644 --- a/core/include/JellyfinQt/DTO/channelmediatype.h +++ b/core/include/JellyfinQt/DTO/channelmediatype.h @@ -55,31 +55,6 @@ private: typedef ChannelMediaTypeClass::Value ChannelMediaType; -} // NS DTO - -namespace Support { - -using ChannelMediaType = Jellyfin::DTO::ChannelMediaType; -using ChannelMediaTypeClass = Jellyfin::DTO::ChannelMediaTypeClass; - -template <> -ChannelMediaType fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return ChannelMediaTypeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Audio")) { - return ChannelMediaTypeClass::Audio; - } - if (str == QStringLiteral("Video")) { - return ChannelMediaTypeClass::Video; - } - if (str == QStringLiteral("Photo")) { - return ChannelMediaTypeClass::Photo; - } - - return ChannelMediaTypeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/channeltype.h b/core/include/JellyfinQt/DTO/channeltype.h index 53e7255..191f299 100644 --- a/core/include/JellyfinQt/DTO/channeltype.h +++ b/core/include/JellyfinQt/DTO/channeltype.h @@ -54,28 +54,6 @@ private: typedef ChannelTypeClass::Value ChannelType; -} // NS DTO - -namespace Support { - -using ChannelType = Jellyfin::DTO::ChannelType; -using ChannelTypeClass = Jellyfin::DTO::ChannelTypeClass; - -template <> -ChannelType fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return ChannelTypeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("TV")) { - return ChannelTypeClass::TV; - } - if (str == QStringLiteral("Radio")) { - return ChannelTypeClass::Radio; - } - - return ChannelTypeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/chapterinfo.h b/core/include/JellyfinQt/DTO/chapterinfo.h index 5ae5602..c6f49e9 100644 --- a/core/include/JellyfinQt/DTO/chapterinfo.h +++ b/core/include/JellyfinQt/DTO/chapterinfo.h @@ -91,18 +91,6 @@ protected: QString m_imageTag; }; -} // NS DTO - -namespace Support { - -using ChapterInfo = Jellyfin::DTO::ChapterInfo; - -template <> -ChapterInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ChapterInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/clientcapabilities.h b/core/include/JellyfinQt/DTO/clientcapabilities.h index 4d062ac..46b6ee1 100644 --- a/core/include/JellyfinQt/DTO/clientcapabilities.h +++ b/core/include/JellyfinQt/DTO/clientcapabilities.h @@ -108,18 +108,6 @@ protected: QString m_iconUrl; }; -} // NS DTO - -namespace Support { - -using ClientCapabilities = Jellyfin::DTO::ClientCapabilities; - -template <> -ClientCapabilities fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ClientCapabilities::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/clientcapabilitiesdto.h b/core/include/JellyfinQt/DTO/clientcapabilitiesdto.h index e086b0c..dc7a1e3 100644 --- a/core/include/JellyfinQt/DTO/clientcapabilitiesdto.h +++ b/core/include/JellyfinQt/DTO/clientcapabilitiesdto.h @@ -144,18 +144,6 @@ protected: QString m_iconUrl; }; -} // NS DTO - -namespace Support { - -using ClientCapabilitiesDto = Jellyfin::DTO::ClientCapabilitiesDto; - -template <> -ClientCapabilitiesDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ClientCapabilitiesDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/codecprofile.h b/core/include/JellyfinQt/DTO/codecprofile.h index 4d7b317..583510c 100644 --- a/core/include/JellyfinQt/DTO/codecprofile.h +++ b/core/include/JellyfinQt/DTO/codecprofile.h @@ -83,18 +83,6 @@ protected: QString m_container; }; -} // NS DTO - -namespace Support { - -using CodecProfile = Jellyfin::DTO::CodecProfile; - -template <> -CodecProfile fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return CodecProfile::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/codectype.h b/core/include/JellyfinQt/DTO/codectype.h index 2ab8e59..a6d93d2 100644 --- a/core/include/JellyfinQt/DTO/codectype.h +++ b/core/include/JellyfinQt/DTO/codectype.h @@ -55,31 +55,6 @@ private: typedef CodecTypeClass::Value CodecType; -} // NS DTO - -namespace Support { - -using CodecType = Jellyfin::DTO::CodecType; -using CodecTypeClass = Jellyfin::DTO::CodecTypeClass; - -template <> -CodecType fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return CodecTypeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Video")) { - return CodecTypeClass::Video; - } - if (str == QStringLiteral("VideoAudio")) { - return CodecTypeClass::VideoAudio; - } - if (str == QStringLiteral("Audio")) { - return CodecTypeClass::Audio; - } - - return CodecTypeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/collectioncreationresult.h b/core/include/JellyfinQt/DTO/collectioncreationresult.h index 933fe1f..cadb535 100644 --- a/core/include/JellyfinQt/DTO/collectioncreationresult.h +++ b/core/include/JellyfinQt/DTO/collectioncreationresult.h @@ -58,18 +58,6 @@ protected: QUuid m_jellyfinId; }; -} // NS DTO - -namespace Support { - -using CollectionCreationResult = Jellyfin::DTO::CollectionCreationResult; - -template <> -CollectionCreationResult fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return CollectionCreationResult::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/configurationpageinfo.h b/core/include/JellyfinQt/DTO/configurationpageinfo.h index 5363fcc..882942e 100644 --- a/core/include/JellyfinQt/DTO/configurationpageinfo.h +++ b/core/include/JellyfinQt/DTO/configurationpageinfo.h @@ -114,18 +114,6 @@ protected: QUuid m_pluginId; }; -} // NS DTO - -namespace Support { - -using ConfigurationPageInfo = Jellyfin::DTO::ConfigurationPageInfo; - -template <> -ConfigurationPageInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ConfigurationPageInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/configurationpagetype.h b/core/include/JellyfinQt/DTO/configurationpagetype.h index 3981dd7..d5d3257 100644 --- a/core/include/JellyfinQt/DTO/configurationpagetype.h +++ b/core/include/JellyfinQt/DTO/configurationpagetype.h @@ -54,28 +54,6 @@ private: typedef ConfigurationPageTypeClass::Value ConfigurationPageType; -} // NS DTO - -namespace Support { - -using ConfigurationPageType = Jellyfin::DTO::ConfigurationPageType; -using ConfigurationPageTypeClass = Jellyfin::DTO::ConfigurationPageTypeClass; - -template <> -ConfigurationPageType fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return ConfigurationPageTypeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("PluginConfiguration")) { - return ConfigurationPageTypeClass::PluginConfiguration; - } - if (str == QStringLiteral("None")) { - return ConfigurationPageTypeClass::None; - } - - return ConfigurationPageTypeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/containerprofile.h b/core/include/JellyfinQt/DTO/containerprofile.h index f7c7010..32d4681 100644 --- a/core/include/JellyfinQt/DTO/containerprofile.h +++ b/core/include/JellyfinQt/DTO/containerprofile.h @@ -73,18 +73,6 @@ protected: QString m_container; }; -} // NS DTO - -namespace Support { - -using ContainerProfile = Jellyfin::DTO::ContainerProfile; - -template <> -ContainerProfile fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ContainerProfile::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/controlresponse.h b/core/include/JellyfinQt/DTO/controlresponse.h index 259731e..97fb2b8 100644 --- a/core/include/JellyfinQt/DTO/controlresponse.h +++ b/core/include/JellyfinQt/DTO/controlresponse.h @@ -68,18 +68,6 @@ protected: bool m_isSuccessful; }; -} // NS DTO - -namespace Support { - -using ControlResponse = Jellyfin::DTO::ControlResponse; - -template <> -ControlResponse fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ControlResponse::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/countryinfo.h b/core/include/JellyfinQt/DTO/countryinfo.h index 9400207..d538a5a 100644 --- a/core/include/JellyfinQt/DTO/countryinfo.h +++ b/core/include/JellyfinQt/DTO/countryinfo.h @@ -89,18 +89,6 @@ protected: QString m_threeLetterISORegionName; }; -} // NS DTO - -namespace Support { - -using CountryInfo = Jellyfin::DTO::CountryInfo; - -template <> -CountryInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return CountryInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/createplaylistdto.h b/core/include/JellyfinQt/DTO/createplaylistdto.h index 2d530b3..0a1449d 100644 --- a/core/include/JellyfinQt/DTO/createplaylistdto.h +++ b/core/include/JellyfinQt/DTO/createplaylistdto.h @@ -92,18 +92,6 @@ protected: QString m_mediaType; }; -} // NS DTO - -namespace Support { - -using CreatePlaylistDto = Jellyfin::DTO::CreatePlaylistDto; - -template <> -CreatePlaylistDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return CreatePlaylistDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/createuserbyname.h b/core/include/JellyfinQt/DTO/createuserbyname.h index c85735b..d842796 100644 --- a/core/include/JellyfinQt/DTO/createuserbyname.h +++ b/core/include/JellyfinQt/DTO/createuserbyname.h @@ -71,18 +71,6 @@ protected: QString m_password; }; -} // NS DTO - -namespace Support { - -using CreateUserByName = Jellyfin::DTO::CreateUserByName; - -template <> -CreateUserByName fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return CreateUserByName::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/culturedto.h b/core/include/JellyfinQt/DTO/culturedto.h index 01d2505..8549026 100644 --- a/core/include/JellyfinQt/DTO/culturedto.h +++ b/core/include/JellyfinQt/DTO/culturedto.h @@ -96,18 +96,6 @@ protected: QStringList m_threeLetterISOLanguageNames; }; -} // NS DTO - -namespace Support { - -using CultureDto = Jellyfin::DTO::CultureDto; - -template <> -CultureDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return CultureDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/dayofweek.h b/core/include/JellyfinQt/DTO/dayofweek.h index fba7e1a..c16d5f0 100644 --- a/core/include/JellyfinQt/DTO/dayofweek.h +++ b/core/include/JellyfinQt/DTO/dayofweek.h @@ -59,43 +59,6 @@ private: typedef DayOfWeekClass::Value DayOfWeek; -} // NS DTO - -namespace Support { - -using DayOfWeek = Jellyfin::DTO::DayOfWeek; -using DayOfWeekClass = Jellyfin::DTO::DayOfWeekClass; - -template <> -DayOfWeek fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return DayOfWeekClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Sunday")) { - return DayOfWeekClass::Sunday; - } - if (str == QStringLiteral("Monday")) { - return DayOfWeekClass::Monday; - } - if (str == QStringLiteral("Tuesday")) { - return DayOfWeekClass::Tuesday; - } - if (str == QStringLiteral("Wednesday")) { - return DayOfWeekClass::Wednesday; - } - if (str == QStringLiteral("Thursday")) { - return DayOfWeekClass::Thursday; - } - if (str == QStringLiteral("Friday")) { - return DayOfWeekClass::Friday; - } - if (str == QStringLiteral("Saturday")) { - return DayOfWeekClass::Saturday; - } - - return DayOfWeekClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/daypattern.h b/core/include/JellyfinQt/DTO/daypattern.h index fe5ebee..1804a92 100644 --- a/core/include/JellyfinQt/DTO/daypattern.h +++ b/core/include/JellyfinQt/DTO/daypattern.h @@ -55,31 +55,6 @@ private: typedef DayPatternClass::Value DayPattern; -} // NS DTO - -namespace Support { - -using DayPattern = Jellyfin::DTO::DayPattern; -using DayPatternClass = Jellyfin::DTO::DayPatternClass; - -template <> -DayPattern fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return DayPatternClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Daily")) { - return DayPatternClass::Daily; - } - if (str == QStringLiteral("Weekdays")) { - return DayPatternClass::Weekdays; - } - if (str == QStringLiteral("Weekends")) { - return DayPatternClass::Weekends; - } - - return DayPatternClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/defaultdirectorybrowserinfodto.h b/core/include/JellyfinQt/DTO/defaultdirectorybrowserinfodto.h index 23bb219..6aae9e0 100644 --- a/core/include/JellyfinQt/DTO/defaultdirectorybrowserinfodto.h +++ b/core/include/JellyfinQt/DTO/defaultdirectorybrowserinfodto.h @@ -62,18 +62,6 @@ protected: QString m_path; }; -} // NS DTO - -namespace Support { - -using DefaultDirectoryBrowserInfoDto = Jellyfin::DTO::DefaultDirectoryBrowserInfoDto; - -template <> -DefaultDirectoryBrowserInfoDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return DefaultDirectoryBrowserInfoDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/deviceidentification.h b/core/include/JellyfinQt/DTO/deviceidentification.h index 6db8525..e7866df 100644 --- a/core/include/JellyfinQt/DTO/deviceidentification.h +++ b/core/include/JellyfinQt/DTO/deviceidentification.h @@ -138,18 +138,6 @@ protected: QList> m_headers; }; -} // NS DTO - -namespace Support { - -using DeviceIdentification = Jellyfin::DTO::DeviceIdentification; - -template <> -DeviceIdentification fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return DeviceIdentification::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/deviceinfo.h b/core/include/JellyfinQt/DTO/deviceinfo.h index 636659b..dd3a8c8 100644 --- a/core/include/JellyfinQt/DTO/deviceinfo.h +++ b/core/include/JellyfinQt/DTO/deviceinfo.h @@ -126,18 +126,6 @@ protected: QString m_iconUrl; }; -} // NS DTO - -namespace Support { - -using DeviceInfo = Jellyfin::DTO::DeviceInfo; - -template <> -DeviceInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return DeviceInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/deviceinfoqueryresult.h b/core/include/JellyfinQt/DTO/deviceinfoqueryresult.h index 0e9d3b4..978f432 100644 --- a/core/include/JellyfinQt/DTO/deviceinfoqueryresult.h +++ b/core/include/JellyfinQt/DTO/deviceinfoqueryresult.h @@ -83,18 +83,6 @@ protected: qint32 m_startIndex; }; -} // NS DTO - -namespace Support { - -using DeviceInfoQueryResult = Jellyfin::DTO::DeviceInfoQueryResult; - -template <> -DeviceInfoQueryResult fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return DeviceInfoQueryResult::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/deviceoptions.h b/core/include/JellyfinQt/DTO/deviceoptions.h index 94e6064..91380f3 100644 --- a/core/include/JellyfinQt/DTO/deviceoptions.h +++ b/core/include/JellyfinQt/DTO/deviceoptions.h @@ -58,18 +58,6 @@ protected: QString m_customName; }; -} // NS DTO - -namespace Support { - -using DeviceOptions = Jellyfin::DTO::DeviceOptions; - -template <> -DeviceOptions fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return DeviceOptions::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/deviceprofile.h b/core/include/JellyfinQt/DTO/deviceprofile.h index 4e4125c..0024791 100644 --- a/core/include/JellyfinQt/DTO/deviceprofile.h +++ b/core/include/JellyfinQt/DTO/deviceprofile.h @@ -411,18 +411,6 @@ protected: QList> m_subtitleProfiles; }; -} // NS DTO - -namespace Support { - -using DeviceProfile = Jellyfin::DTO::DeviceProfile; - -template <> -DeviceProfile fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return DeviceProfile::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/deviceprofileinfo.h b/core/include/JellyfinQt/DTO/deviceprofileinfo.h index 653bd2b..a370c97 100644 --- a/core/include/JellyfinQt/DTO/deviceprofileinfo.h +++ b/core/include/JellyfinQt/DTO/deviceprofileinfo.h @@ -77,18 +77,6 @@ protected: DeviceProfileType m_type; }; -} // NS DTO - -namespace Support { - -using DeviceProfileInfo = Jellyfin::DTO::DeviceProfileInfo; - -template <> -DeviceProfileInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return DeviceProfileInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/deviceprofiletype.h b/core/include/JellyfinQt/DTO/deviceprofiletype.h index 98fc24f..3f6c69b 100644 --- a/core/include/JellyfinQt/DTO/deviceprofiletype.h +++ b/core/include/JellyfinQt/DTO/deviceprofiletype.h @@ -54,28 +54,6 @@ private: typedef DeviceProfileTypeClass::Value DeviceProfileType; -} // NS DTO - -namespace Support { - -using DeviceProfileType = Jellyfin::DTO::DeviceProfileType; -using DeviceProfileTypeClass = Jellyfin::DTO::DeviceProfileTypeClass; - -template <> -DeviceProfileType fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return DeviceProfileTypeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("System")) { - return DeviceProfileTypeClass::System; - } - if (str == QStringLiteral("User")) { - return DeviceProfileTypeClass::User; - } - - return DeviceProfileTypeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/directplayprofile.h b/core/include/JellyfinQt/DTO/directplayprofile.h index ef94eb7..f0b1f46 100644 --- a/core/include/JellyfinQt/DTO/directplayprofile.h +++ b/core/include/JellyfinQt/DTO/directplayprofile.h @@ -74,18 +74,6 @@ protected: DlnaProfileType m_type; }; -} // NS DTO - -namespace Support { - -using DirectPlayProfile = Jellyfin::DTO::DirectPlayProfile; - -template <> -DirectPlayProfile fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return DirectPlayProfile::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/displaypreferencesdto.h b/core/include/JellyfinQt/DTO/displaypreferencesdto.h index 1cc4fd8..4839833 100644 --- a/core/include/JellyfinQt/DTO/displaypreferencesdto.h +++ b/core/include/JellyfinQt/DTO/displaypreferencesdto.h @@ -173,18 +173,6 @@ protected: QString m_client; }; -} // NS DTO - -namespace Support { - -using DisplayPreferencesDto = Jellyfin::DTO::DisplayPreferencesDto; - -template <> -DisplayPreferencesDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return DisplayPreferencesDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/dlnaprofiletype.h b/core/include/JellyfinQt/DTO/dlnaprofiletype.h index 7b58d3b..26f7a4b 100644 --- a/core/include/JellyfinQt/DTO/dlnaprofiletype.h +++ b/core/include/JellyfinQt/DTO/dlnaprofiletype.h @@ -55,31 +55,6 @@ private: typedef DlnaProfileTypeClass::Value DlnaProfileType; -} // NS DTO - -namespace Support { - -using DlnaProfileType = Jellyfin::DTO::DlnaProfileType; -using DlnaProfileTypeClass = Jellyfin::DTO::DlnaProfileTypeClass; - -template <> -DlnaProfileType fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return DlnaProfileTypeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Audio")) { - return DlnaProfileTypeClass::Audio; - } - if (str == QStringLiteral("Video")) { - return DlnaProfileTypeClass::Video; - } - if (str == QStringLiteral("Photo")) { - return DlnaProfileTypeClass::Photo; - } - - return DlnaProfileTypeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/dynamicdayofweek.h b/core/include/JellyfinQt/DTO/dynamicdayofweek.h index da719f8..d8be27f 100644 --- a/core/include/JellyfinQt/DTO/dynamicdayofweek.h +++ b/core/include/JellyfinQt/DTO/dynamicdayofweek.h @@ -62,52 +62,6 @@ private: typedef DynamicDayOfWeekClass::Value DynamicDayOfWeek; -} // NS DTO - -namespace Support { - -using DynamicDayOfWeek = Jellyfin::DTO::DynamicDayOfWeek; -using DynamicDayOfWeekClass = Jellyfin::DTO::DynamicDayOfWeekClass; - -template <> -DynamicDayOfWeek fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return DynamicDayOfWeekClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Sunday")) { - return DynamicDayOfWeekClass::Sunday; - } - if (str == QStringLiteral("Monday")) { - return DynamicDayOfWeekClass::Monday; - } - if (str == QStringLiteral("Tuesday")) { - return DynamicDayOfWeekClass::Tuesday; - } - if (str == QStringLiteral("Wednesday")) { - return DynamicDayOfWeekClass::Wednesday; - } - if (str == QStringLiteral("Thursday")) { - return DynamicDayOfWeekClass::Thursday; - } - if (str == QStringLiteral("Friday")) { - return DynamicDayOfWeekClass::Friday; - } - if (str == QStringLiteral("Saturday")) { - return DynamicDayOfWeekClass::Saturday; - } - if (str == QStringLiteral("Everyday")) { - return DynamicDayOfWeekClass::Everyday; - } - if (str == QStringLiteral("Weekday")) { - return DynamicDayOfWeekClass::Weekday; - } - if (str == QStringLiteral("Weekend")) { - return DynamicDayOfWeekClass::Weekend; - } - - return DynamicDayOfWeekClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/encodingcontext.h b/core/include/JellyfinQt/DTO/encodingcontext.h index 00cf74e..96e27b8 100644 --- a/core/include/JellyfinQt/DTO/encodingcontext.h +++ b/core/include/JellyfinQt/DTO/encodingcontext.h @@ -54,28 +54,6 @@ private: typedef EncodingContextClass::Value EncodingContext; -} // NS DTO - -namespace Support { - -using EncodingContext = Jellyfin::DTO::EncodingContext; -using EncodingContextClass = Jellyfin::DTO::EncodingContextClass; - -template <> -EncodingContext fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return EncodingContextClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Streaming")) { - return EncodingContextClass::Streaming; - } - if (str == QStringLiteral("Static")) { - return EncodingContextClass::Static; - } - - return EncodingContextClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/endpointinfo.h b/core/include/JellyfinQt/DTO/endpointinfo.h index 8849468..ae5013c 100644 --- a/core/include/JellyfinQt/DTO/endpointinfo.h +++ b/core/include/JellyfinQt/DTO/endpointinfo.h @@ -62,18 +62,6 @@ protected: bool m_isInNetwork; }; -} // NS DTO - -namespace Support { - -using EndPointInfo = Jellyfin::DTO::EndPointInfo; - -template <> -EndPointInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return EndPointInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/externalidinfo.h b/core/include/JellyfinQt/DTO/externalidinfo.h index faaa653..41066e1 100644 --- a/core/include/JellyfinQt/DTO/externalidinfo.h +++ b/core/include/JellyfinQt/DTO/externalidinfo.h @@ -86,18 +86,6 @@ protected: QString m_urlFormatString; }; -} // NS DTO - -namespace Support { - -using ExternalIdInfo = Jellyfin::DTO::ExternalIdInfo; - -template <> -ExternalIdInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ExternalIdInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/externalidmediatype.h b/core/include/JellyfinQt/DTO/externalidmediatype.h index a3b873c..003ee8e 100644 --- a/core/include/JellyfinQt/DTO/externalidmediatype.h +++ b/core/include/JellyfinQt/DTO/externalidmediatype.h @@ -64,58 +64,6 @@ private: typedef ExternalIdMediaTypeClass::Value ExternalIdMediaType; -} // NS DTO - -namespace Support { - -using ExternalIdMediaType = Jellyfin::DTO::ExternalIdMediaType; -using ExternalIdMediaTypeClass = Jellyfin::DTO::ExternalIdMediaTypeClass; - -template <> -ExternalIdMediaType fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return ExternalIdMediaTypeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Album")) { - return ExternalIdMediaTypeClass::Album; - } - if (str == QStringLiteral("AlbumArtist")) { - return ExternalIdMediaTypeClass::AlbumArtist; - } - if (str == QStringLiteral("Artist")) { - return ExternalIdMediaTypeClass::Artist; - } - if (str == QStringLiteral("BoxSet")) { - return ExternalIdMediaTypeClass::BoxSet; - } - if (str == QStringLiteral("Episode")) { - return ExternalIdMediaTypeClass::Episode; - } - if (str == QStringLiteral("Movie")) { - return ExternalIdMediaTypeClass::Movie; - } - if (str == QStringLiteral("OtherArtist")) { - return ExternalIdMediaTypeClass::OtherArtist; - } - if (str == QStringLiteral("Person")) { - return ExternalIdMediaTypeClass::Person; - } - if (str == QStringLiteral("ReleaseGroup")) { - return ExternalIdMediaTypeClass::ReleaseGroup; - } - if (str == QStringLiteral("Season")) { - return ExternalIdMediaTypeClass::Season; - } - if (str == QStringLiteral("Series")) { - return ExternalIdMediaTypeClass::Series; - } - if (str == QStringLiteral("Track")) { - return ExternalIdMediaTypeClass::Track; - } - - return ExternalIdMediaTypeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/externalurl.h b/core/include/JellyfinQt/DTO/externalurl.h index 8066d50..fd8c608 100644 --- a/core/include/JellyfinQt/DTO/externalurl.h +++ b/core/include/JellyfinQt/DTO/externalurl.h @@ -71,18 +71,6 @@ protected: QString m_url; }; -} // NS DTO - -namespace Support { - -using ExternalUrl = Jellyfin::DTO::ExternalUrl; - -template <> -ExternalUrl fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ExternalUrl::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/ffmpeglocation.h b/core/include/JellyfinQt/DTO/ffmpeglocation.h index 7e1a916..b5956ef 100644 --- a/core/include/JellyfinQt/DTO/ffmpeglocation.h +++ b/core/include/JellyfinQt/DTO/ffmpeglocation.h @@ -56,34 +56,6 @@ private: typedef FFmpegLocationClass::Value FFmpegLocation; -} // NS DTO - -namespace Support { - -using FFmpegLocation = Jellyfin::DTO::FFmpegLocation; -using FFmpegLocationClass = Jellyfin::DTO::FFmpegLocationClass; - -template <> -FFmpegLocation fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return FFmpegLocationClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("NotFound")) { - return FFmpegLocationClass::NotFound; - } - if (str == QStringLiteral("SetByArgument")) { - return FFmpegLocationClass::SetByArgument; - } - if (str == QStringLiteral("Custom")) { - return FFmpegLocationClass::Custom; - } - if (str == QStringLiteral("System")) { - return FFmpegLocationClass::System; - } - - return FFmpegLocationClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/filesystementryinfo.h b/core/include/JellyfinQt/DTO/filesystementryinfo.h index 34e58d1..38d1a41 100644 --- a/core/include/JellyfinQt/DTO/filesystementryinfo.h +++ b/core/include/JellyfinQt/DTO/filesystementryinfo.h @@ -77,18 +77,6 @@ protected: FileSystemEntryType m_type; }; -} // NS DTO - -namespace Support { - -using FileSystemEntryInfo = Jellyfin::DTO::FileSystemEntryInfo; - -template <> -FileSystemEntryInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return FileSystemEntryInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/filesystementrytype.h b/core/include/JellyfinQt/DTO/filesystementrytype.h index b1b6250..154421c 100644 --- a/core/include/JellyfinQt/DTO/filesystementrytype.h +++ b/core/include/JellyfinQt/DTO/filesystementrytype.h @@ -56,34 +56,6 @@ private: typedef FileSystemEntryTypeClass::Value FileSystemEntryType; -} // NS DTO - -namespace Support { - -using FileSystemEntryType = Jellyfin::DTO::FileSystemEntryType; -using FileSystemEntryTypeClass = Jellyfin::DTO::FileSystemEntryTypeClass; - -template <> -FileSystemEntryType fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return FileSystemEntryTypeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("File")) { - return FileSystemEntryTypeClass::File; - } - if (str == QStringLiteral("Directory")) { - return FileSystemEntryTypeClass::Directory; - } - if (str == QStringLiteral("NetworkComputer")) { - return FileSystemEntryTypeClass::NetworkComputer; - } - if (str == QStringLiteral("NetworkShare")) { - return FileSystemEntryTypeClass::NetworkShare; - } - - return FileSystemEntryTypeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/fontfile.h b/core/include/JellyfinQt/DTO/fontfile.h index fac8d2b..a1ac025 100644 --- a/core/include/JellyfinQt/DTO/fontfile.h +++ b/core/include/JellyfinQt/DTO/fontfile.h @@ -90,18 +90,6 @@ protected: QDateTime m_dateModified; }; -} // NS DTO - -namespace Support { - -using FontFile = Jellyfin::DTO::FontFile; - -template <> -FontFile fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return FontFile::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/forgotpasswordaction.h b/core/include/JellyfinQt/DTO/forgotpasswordaction.h index 7053906..01fca4c 100644 --- a/core/include/JellyfinQt/DTO/forgotpasswordaction.h +++ b/core/include/JellyfinQt/DTO/forgotpasswordaction.h @@ -55,31 +55,6 @@ private: typedef ForgotPasswordActionClass::Value ForgotPasswordAction; -} // NS DTO - -namespace Support { - -using ForgotPasswordAction = Jellyfin::DTO::ForgotPasswordAction; -using ForgotPasswordActionClass = Jellyfin::DTO::ForgotPasswordActionClass; - -template <> -ForgotPasswordAction fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return ForgotPasswordActionClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("ContactAdmin")) { - return ForgotPasswordActionClass::ContactAdmin; - } - if (str == QStringLiteral("PinCode")) { - return ForgotPasswordActionClass::PinCode; - } - if (str == QStringLiteral("InNetworkRequired")) { - return ForgotPasswordActionClass::InNetworkRequired; - } - - return ForgotPasswordActionClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/forgotpassworddto.h b/core/include/JellyfinQt/DTO/forgotpassworddto.h index 8c2b2ba..41e8dc1 100644 --- a/core/include/JellyfinQt/DTO/forgotpassworddto.h +++ b/core/include/JellyfinQt/DTO/forgotpassworddto.h @@ -62,18 +62,6 @@ protected: QString m_enteredUsername; }; -} // NS DTO - -namespace Support { - -using ForgotPasswordDto = Jellyfin::DTO::ForgotPasswordDto; - -template <> -ForgotPasswordDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ForgotPasswordDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/forgotpasswordresult.h b/core/include/JellyfinQt/DTO/forgotpasswordresult.h index 7992432..6595b6f 100644 --- a/core/include/JellyfinQt/DTO/forgotpasswordresult.h +++ b/core/include/JellyfinQt/DTO/forgotpasswordresult.h @@ -78,18 +78,6 @@ protected: QDateTime m_pinExpirationDate; }; -} // NS DTO - -namespace Support { - -using ForgotPasswordResult = Jellyfin::DTO::ForgotPasswordResult; - -template <> -ForgotPasswordResult fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ForgotPasswordResult::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/generalcommand.h b/core/include/JellyfinQt/DTO/generalcommand.h index b771255..b3b5d99 100644 --- a/core/include/JellyfinQt/DTO/generalcommand.h +++ b/core/include/JellyfinQt/DTO/generalcommand.h @@ -69,18 +69,6 @@ protected: QJsonObject m_arguments; }; -} // NS DTO - -namespace Support { - -using GeneralCommand = Jellyfin::DTO::GeneralCommand; - -template <> -GeneralCommand fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return GeneralCommand::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/generalcommandtype.h b/core/include/JellyfinQt/DTO/generalcommandtype.h index ac9d409..90b99c2 100644 --- a/core/include/JellyfinQt/DTO/generalcommandtype.h +++ b/core/include/JellyfinQt/DTO/generalcommandtype.h @@ -93,145 +93,6 @@ private: typedef GeneralCommandTypeClass::Value GeneralCommandType; -} // NS DTO - -namespace Support { - -using GeneralCommandType = Jellyfin::DTO::GeneralCommandType; -using GeneralCommandTypeClass = Jellyfin::DTO::GeneralCommandTypeClass; - -template <> -GeneralCommandType fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return GeneralCommandTypeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("MoveUp")) { - return GeneralCommandTypeClass::MoveUp; - } - if (str == QStringLiteral("MoveDown")) { - return GeneralCommandTypeClass::MoveDown; - } - if (str == QStringLiteral("MoveLeft")) { - return GeneralCommandTypeClass::MoveLeft; - } - if (str == QStringLiteral("MoveRight")) { - return GeneralCommandTypeClass::MoveRight; - } - if (str == QStringLiteral("PageUp")) { - return GeneralCommandTypeClass::PageUp; - } - if (str == QStringLiteral("PageDown")) { - return GeneralCommandTypeClass::PageDown; - } - if (str == QStringLiteral("PreviousLetter")) { - return GeneralCommandTypeClass::PreviousLetter; - } - if (str == QStringLiteral("NextLetter")) { - return GeneralCommandTypeClass::NextLetter; - } - if (str == QStringLiteral("ToggleOsd")) { - return GeneralCommandTypeClass::ToggleOsd; - } - if (str == QStringLiteral("ToggleContextMenu")) { - return GeneralCommandTypeClass::ToggleContextMenu; - } - if (str == QStringLiteral("Select")) { - return GeneralCommandTypeClass::Select; - } - if (str == QStringLiteral("Back")) { - return GeneralCommandTypeClass::Back; - } - if (str == QStringLiteral("TakeScreenshot")) { - return GeneralCommandTypeClass::TakeScreenshot; - } - if (str == QStringLiteral("SendKey")) { - return GeneralCommandTypeClass::SendKey; - } - if (str == QStringLiteral("SendString")) { - return GeneralCommandTypeClass::SendString; - } - if (str == QStringLiteral("GoHome")) { - return GeneralCommandTypeClass::GoHome; - } - if (str == QStringLiteral("GoToSettings")) { - return GeneralCommandTypeClass::GoToSettings; - } - if (str == QStringLiteral("VolumeUp")) { - return GeneralCommandTypeClass::VolumeUp; - } - if (str == QStringLiteral("VolumeDown")) { - return GeneralCommandTypeClass::VolumeDown; - } - if (str == QStringLiteral("Mute")) { - return GeneralCommandTypeClass::Mute; - } - if (str == QStringLiteral("Unmute")) { - return GeneralCommandTypeClass::Unmute; - } - if (str == QStringLiteral("ToggleMute")) { - return GeneralCommandTypeClass::ToggleMute; - } - if (str == QStringLiteral("SetVolume")) { - return GeneralCommandTypeClass::SetVolume; - } - if (str == QStringLiteral("SetAudioStreamIndex")) { - return GeneralCommandTypeClass::SetAudioStreamIndex; - } - if (str == QStringLiteral("SetSubtitleStreamIndex")) { - return GeneralCommandTypeClass::SetSubtitleStreamIndex; - } - if (str == QStringLiteral("ToggleFullscreen")) { - return GeneralCommandTypeClass::ToggleFullscreen; - } - if (str == QStringLiteral("DisplayContent")) { - return GeneralCommandTypeClass::DisplayContent; - } - if (str == QStringLiteral("GoToSearch")) { - return GeneralCommandTypeClass::GoToSearch; - } - if (str == QStringLiteral("DisplayMessage")) { - return GeneralCommandTypeClass::DisplayMessage; - } - if (str == QStringLiteral("SetRepeatMode")) { - return GeneralCommandTypeClass::SetRepeatMode; - } - if (str == QStringLiteral("ChannelUp")) { - return GeneralCommandTypeClass::ChannelUp; - } - if (str == QStringLiteral("ChannelDown")) { - return GeneralCommandTypeClass::ChannelDown; - } - if (str == QStringLiteral("Guide")) { - return GeneralCommandTypeClass::Guide; - } - if (str == QStringLiteral("ToggleStats")) { - return GeneralCommandTypeClass::ToggleStats; - } - if (str == QStringLiteral("PlayMediaSource")) { - return GeneralCommandTypeClass::PlayMediaSource; - } - if (str == QStringLiteral("PlayTrailers")) { - return GeneralCommandTypeClass::PlayTrailers; - } - if (str == QStringLiteral("SetShuffleQueue")) { - return GeneralCommandTypeClass::SetShuffleQueue; - } - if (str == QStringLiteral("PlayState")) { - return GeneralCommandTypeClass::PlayState; - } - if (str == QStringLiteral("PlayNext")) { - return GeneralCommandTypeClass::PlayNext; - } - if (str == QStringLiteral("ToggleOsdMenu")) { - return GeneralCommandTypeClass::ToggleOsdMenu; - } - if (str == QStringLiteral("Play")) { - return GeneralCommandTypeClass::Play; - } - - return GeneralCommandTypeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/getprogramsdto.h b/core/include/JellyfinQt/DTO/getprogramsdto.h index ab2bd48..5d78915 100644 --- a/core/include/JellyfinQt/DTO/getprogramsdto.h +++ b/core/include/JellyfinQt/DTO/getprogramsdto.h @@ -344,18 +344,6 @@ protected: QList m_fields; }; -} // NS DTO - -namespace Support { - -using GetProgramsDto = Jellyfin::DTO::GetProgramsDto; - -template <> -GetProgramsDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return GetProgramsDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/groupinfodto.h b/core/include/JellyfinQt/DTO/groupinfodto.h index 2a2b986..69b0fb5 100644 --- a/core/include/JellyfinQt/DTO/groupinfodto.h +++ b/core/include/JellyfinQt/DTO/groupinfodto.h @@ -99,18 +99,6 @@ protected: QDateTime m_lastUpdatedAt; }; -} // NS DTO - -namespace Support { - -using GroupInfoDto = Jellyfin::DTO::GroupInfoDto; - -template <> -GroupInfoDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return GroupInfoDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/groupqueuemode.h b/core/include/JellyfinQt/DTO/groupqueuemode.h index d65a97e..07e530d 100644 --- a/core/include/JellyfinQt/DTO/groupqueuemode.h +++ b/core/include/JellyfinQt/DTO/groupqueuemode.h @@ -54,28 +54,6 @@ private: typedef GroupQueueModeClass::Value GroupQueueMode; -} // NS DTO - -namespace Support { - -using GroupQueueMode = Jellyfin::DTO::GroupQueueMode; -using GroupQueueModeClass = Jellyfin::DTO::GroupQueueModeClass; - -template <> -GroupQueueMode fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return GroupQueueModeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Queue")) { - return GroupQueueModeClass::Queue; - } - if (str == QStringLiteral("QueueNext")) { - return GroupQueueModeClass::QueueNext; - } - - return GroupQueueModeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/grouprepeatmode.h b/core/include/JellyfinQt/DTO/grouprepeatmode.h index 3ae0565..b08f145 100644 --- a/core/include/JellyfinQt/DTO/grouprepeatmode.h +++ b/core/include/JellyfinQt/DTO/grouprepeatmode.h @@ -55,31 +55,6 @@ private: typedef GroupRepeatModeClass::Value GroupRepeatMode; -} // NS DTO - -namespace Support { - -using GroupRepeatMode = Jellyfin::DTO::GroupRepeatMode; -using GroupRepeatModeClass = Jellyfin::DTO::GroupRepeatModeClass; - -template <> -GroupRepeatMode fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return GroupRepeatModeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("RepeatOne")) { - return GroupRepeatModeClass::RepeatOne; - } - if (str == QStringLiteral("RepeatAll")) { - return GroupRepeatModeClass::RepeatAll; - } - if (str == QStringLiteral("RepeatNone")) { - return GroupRepeatModeClass::RepeatNone; - } - - return GroupRepeatModeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/groupshufflemode.h b/core/include/JellyfinQt/DTO/groupshufflemode.h index 5514804..4749050 100644 --- a/core/include/JellyfinQt/DTO/groupshufflemode.h +++ b/core/include/JellyfinQt/DTO/groupshufflemode.h @@ -54,28 +54,6 @@ private: typedef GroupShuffleModeClass::Value GroupShuffleMode; -} // NS DTO - -namespace Support { - -using GroupShuffleMode = Jellyfin::DTO::GroupShuffleMode; -using GroupShuffleModeClass = Jellyfin::DTO::GroupShuffleModeClass; - -template <> -GroupShuffleMode fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return GroupShuffleModeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Sorted")) { - return GroupShuffleModeClass::Sorted; - } - if (str == QStringLiteral("Shuffle")) { - return GroupShuffleModeClass::Shuffle; - } - - return GroupShuffleModeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/groupstatetype.h b/core/include/JellyfinQt/DTO/groupstatetype.h index ca0f7e5..efb166f 100644 --- a/core/include/JellyfinQt/DTO/groupstatetype.h +++ b/core/include/JellyfinQt/DTO/groupstatetype.h @@ -56,34 +56,6 @@ private: typedef GroupStateTypeClass::Value GroupStateType; -} // NS DTO - -namespace Support { - -using GroupStateType = Jellyfin::DTO::GroupStateType; -using GroupStateTypeClass = Jellyfin::DTO::GroupStateTypeClass; - -template <> -GroupStateType fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return GroupStateTypeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Idle")) { - return GroupStateTypeClass::Idle; - } - if (str == QStringLiteral("Waiting")) { - return GroupStateTypeClass::Waiting; - } - if (str == QStringLiteral("Paused")) { - return GroupStateTypeClass::Paused; - } - if (str == QStringLiteral("Playing")) { - return GroupStateTypeClass::Playing; - } - - return GroupStateTypeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/groupupdatetype.h b/core/include/JellyfinQt/DTO/groupupdatetype.h index 0479fdb..e471b9d 100644 --- a/core/include/JellyfinQt/DTO/groupupdatetype.h +++ b/core/include/JellyfinQt/DTO/groupupdatetype.h @@ -63,55 +63,6 @@ private: typedef GroupUpdateTypeClass::Value GroupUpdateType; -} // NS DTO - -namespace Support { - -using GroupUpdateType = Jellyfin::DTO::GroupUpdateType; -using GroupUpdateTypeClass = Jellyfin::DTO::GroupUpdateTypeClass; - -template <> -GroupUpdateType fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return GroupUpdateTypeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("UserJoined")) { - return GroupUpdateTypeClass::UserJoined; - } - if (str == QStringLiteral("UserLeft")) { - return GroupUpdateTypeClass::UserLeft; - } - if (str == QStringLiteral("GroupJoined")) { - return GroupUpdateTypeClass::GroupJoined; - } - if (str == QStringLiteral("GroupLeft")) { - return GroupUpdateTypeClass::GroupLeft; - } - if (str == QStringLiteral("StateUpdate")) { - return GroupUpdateTypeClass::StateUpdate; - } - if (str == QStringLiteral("PlayQueue")) { - return GroupUpdateTypeClass::PlayQueue; - } - if (str == QStringLiteral("NotInGroup")) { - return GroupUpdateTypeClass::NotInGroup; - } - if (str == QStringLiteral("GroupDoesNotExist")) { - return GroupUpdateTypeClass::GroupDoesNotExist; - } - if (str == QStringLiteral("CreateGroupDenied")) { - return GroupUpdateTypeClass::CreateGroupDenied; - } - if (str == QStringLiteral("JoinGroupDenied")) { - return GroupUpdateTypeClass::JoinGroupDenied; - } - if (str == QStringLiteral("LibraryAccessDenied")) { - return GroupUpdateTypeClass::LibraryAccessDenied; - } - - return GroupUpdateTypeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/guideinfo.h b/core/include/JellyfinQt/DTO/guideinfo.h index 783f151..70c7e14 100644 --- a/core/include/JellyfinQt/DTO/guideinfo.h +++ b/core/include/JellyfinQt/DTO/guideinfo.h @@ -71,18 +71,6 @@ protected: QDateTime m_endDate; }; -} // NS DTO - -namespace Support { - -using GuideInfo = Jellyfin::DTO::GuideInfo; - -template <> -GuideInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return GuideInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/headermatchtype.h b/core/include/JellyfinQt/DTO/headermatchtype.h index d5ca9b3..5463176 100644 --- a/core/include/JellyfinQt/DTO/headermatchtype.h +++ b/core/include/JellyfinQt/DTO/headermatchtype.h @@ -55,31 +55,6 @@ private: typedef HeaderMatchTypeClass::Value HeaderMatchType; -} // NS DTO - -namespace Support { - -using HeaderMatchType = Jellyfin::DTO::HeaderMatchType; -using HeaderMatchTypeClass = Jellyfin::DTO::HeaderMatchTypeClass; - -template <> -HeaderMatchType fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return HeaderMatchTypeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Equals")) { - return HeaderMatchTypeClass::Equals; - } - if (str == QStringLiteral("Regex")) { - return HeaderMatchTypeClass::Regex; - } - if (str == QStringLiteral("Substring")) { - return HeaderMatchTypeClass::Substring; - } - - return HeaderMatchTypeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/httpheaderinfo.h b/core/include/JellyfinQt/DTO/httpheaderinfo.h index 3371da4..c01171c 100644 --- a/core/include/JellyfinQt/DTO/httpheaderinfo.h +++ b/core/include/JellyfinQt/DTO/httpheaderinfo.h @@ -69,18 +69,6 @@ protected: HeaderMatchType m_match; }; -} // NS DTO - -namespace Support { - -using HttpHeaderInfo = Jellyfin::DTO::HttpHeaderInfo; - -template <> -HttpHeaderInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return HttpHeaderInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/ignorewaitrequestdto.h b/core/include/JellyfinQt/DTO/ignorewaitrequestdto.h index d5b8d35..74ecccb 100644 --- a/core/include/JellyfinQt/DTO/ignorewaitrequestdto.h +++ b/core/include/JellyfinQt/DTO/ignorewaitrequestdto.h @@ -61,18 +61,6 @@ protected: bool m_ignoreWait; }; -} // NS DTO - -namespace Support { - -using IgnoreWaitRequestDto = Jellyfin::DTO::IgnoreWaitRequestDto; - -template <> -IgnoreWaitRequestDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return IgnoreWaitRequestDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/imagebynameinfo.h b/core/include/JellyfinQt/DTO/imagebynameinfo.h index 2f25da5..3d011a0 100644 --- a/core/include/JellyfinQt/DTO/imagebynameinfo.h +++ b/core/include/JellyfinQt/DTO/imagebynameinfo.h @@ -98,18 +98,6 @@ protected: QString m_format; }; -} // NS DTO - -namespace Support { - -using ImageByNameInfo = Jellyfin::DTO::ImageByNameInfo; - -template <> -ImageByNameInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ImageByNameInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/imageformat.h b/core/include/JellyfinQt/DTO/imageformat.h index 6eb9081..c26da21 100644 --- a/core/include/JellyfinQt/DTO/imageformat.h +++ b/core/include/JellyfinQt/DTO/imageformat.h @@ -57,37 +57,6 @@ private: typedef ImageFormatClass::Value ImageFormat; -} // NS DTO - -namespace Support { - -using ImageFormat = Jellyfin::DTO::ImageFormat; -using ImageFormatClass = Jellyfin::DTO::ImageFormatClass; - -template <> -ImageFormat fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return ImageFormatClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Bmp")) { - return ImageFormatClass::Bmp; - } - if (str == QStringLiteral("Gif")) { - return ImageFormatClass::Gif; - } - if (str == QStringLiteral("Jpg")) { - return ImageFormatClass::Jpg; - } - if (str == QStringLiteral("Png")) { - return ImageFormatClass::Png; - } - if (str == QStringLiteral("Webp")) { - return ImageFormatClass::Webp; - } - - return ImageFormatClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/imageinfo.h b/core/include/JellyfinQt/DTO/imageinfo.h index cb72972..fc8cac4 100644 --- a/core/include/JellyfinQt/DTO/imageinfo.h +++ b/core/include/JellyfinQt/DTO/imageinfo.h @@ -122,18 +122,6 @@ protected: qint64 m_size; }; -} // NS DTO - -namespace Support { - -using ImageInfo = Jellyfin::DTO::ImageInfo; - -template <> -ImageInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ImageInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/imageoption.h b/core/include/JellyfinQt/DTO/imageoption.h index 8b0d7fc..bf6754e 100644 --- a/core/include/JellyfinQt/DTO/imageoption.h +++ b/core/include/JellyfinQt/DTO/imageoption.h @@ -76,18 +76,6 @@ protected: qint32 m_minWidth; }; -} // NS DTO - -namespace Support { - -using ImageOption = Jellyfin::DTO::ImageOption; - -template <> -ImageOption fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ImageOption::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/imageorientation.h b/core/include/JellyfinQt/DTO/imageorientation.h index 3a959e7..6deaf27 100644 --- a/core/include/JellyfinQt/DTO/imageorientation.h +++ b/core/include/JellyfinQt/DTO/imageorientation.h @@ -60,46 +60,6 @@ private: typedef ImageOrientationClass::Value ImageOrientation; -} // NS DTO - -namespace Support { - -using ImageOrientation = Jellyfin::DTO::ImageOrientation; -using ImageOrientationClass = Jellyfin::DTO::ImageOrientationClass; - -template <> -ImageOrientation fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return ImageOrientationClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("TopLeft")) { - return ImageOrientationClass::TopLeft; - } - if (str == QStringLiteral("TopRight")) { - return ImageOrientationClass::TopRight; - } - if (str == QStringLiteral("BottomRight")) { - return ImageOrientationClass::BottomRight; - } - if (str == QStringLiteral("BottomLeft")) { - return ImageOrientationClass::BottomLeft; - } - if (str == QStringLiteral("LeftTop")) { - return ImageOrientationClass::LeftTop; - } - if (str == QStringLiteral("RightTop")) { - return ImageOrientationClass::RightTop; - } - if (str == QStringLiteral("RightBottom")) { - return ImageOrientationClass::RightBottom; - } - if (str == QStringLiteral("LeftBottom")) { - return ImageOrientationClass::LeftBottom; - } - - return ImageOrientationClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/imageproviderinfo.h b/core/include/JellyfinQt/DTO/imageproviderinfo.h index ad6eafc..2c88d2e 100644 --- a/core/include/JellyfinQt/DTO/imageproviderinfo.h +++ b/core/include/JellyfinQt/DTO/imageproviderinfo.h @@ -74,18 +74,6 @@ protected: QList m_supportedImages; }; -} // NS DTO - -namespace Support { - -using ImageProviderInfo = Jellyfin::DTO::ImageProviderInfo; - -template <> -ImageProviderInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ImageProviderInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/imagesavingconvention.h b/core/include/JellyfinQt/DTO/imagesavingconvention.h index 6d8411e..bb300a7 100644 --- a/core/include/JellyfinQt/DTO/imagesavingconvention.h +++ b/core/include/JellyfinQt/DTO/imagesavingconvention.h @@ -54,28 +54,6 @@ private: typedef ImageSavingConventionClass::Value ImageSavingConvention; -} // NS DTO - -namespace Support { - -using ImageSavingConvention = Jellyfin::DTO::ImageSavingConvention; -using ImageSavingConventionClass = Jellyfin::DTO::ImageSavingConventionClass; - -template <> -ImageSavingConvention fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return ImageSavingConventionClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Legacy")) { - return ImageSavingConventionClass::Legacy; - } - if (str == QStringLiteral("Compatible")) { - return ImageSavingConventionClass::Compatible; - } - - return ImageSavingConventionClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/imagetype.h b/core/include/JellyfinQt/DTO/imagetype.h index 0802c40..8ab7bf5 100644 --- a/core/include/JellyfinQt/DTO/imagetype.h +++ b/core/include/JellyfinQt/DTO/imagetype.h @@ -65,61 +65,6 @@ private: typedef ImageTypeClass::Value ImageType; -} // NS DTO - -namespace Support { - -using ImageType = Jellyfin::DTO::ImageType; -using ImageTypeClass = Jellyfin::DTO::ImageTypeClass; - -template <> -ImageType fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return ImageTypeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Primary")) { - return ImageTypeClass::Primary; - } - if (str == QStringLiteral("Art")) { - return ImageTypeClass::Art; - } - if (str == QStringLiteral("Backdrop")) { - return ImageTypeClass::Backdrop; - } - if (str == QStringLiteral("Banner")) { - return ImageTypeClass::Banner; - } - if (str == QStringLiteral("Logo")) { - return ImageTypeClass::Logo; - } - if (str == QStringLiteral("Thumb")) { - return ImageTypeClass::Thumb; - } - if (str == QStringLiteral("Disc")) { - return ImageTypeClass::Disc; - } - if (str == QStringLiteral("Box")) { - return ImageTypeClass::Box; - } - if (str == QStringLiteral("Screenshot")) { - return ImageTypeClass::Screenshot; - } - if (str == QStringLiteral("Menu")) { - return ImageTypeClass::Menu; - } - if (str == QStringLiteral("Chapter")) { - return ImageTypeClass::Chapter; - } - if (str == QStringLiteral("BoxRear")) { - return ImageTypeClass::BoxRear; - } - if (str == QStringLiteral("Profile")) { - return ImageTypeClass::Profile; - } - - return ImageTypeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/installationinfo.h b/core/include/JellyfinQt/DTO/installationinfo.h index f287ae5..65b3a61 100644 --- a/core/include/JellyfinQt/DTO/installationinfo.h +++ b/core/include/JellyfinQt/DTO/installationinfo.h @@ -106,18 +106,6 @@ protected: QString m_checksum; }; -} // NS DTO - -namespace Support { - -using InstallationInfo = Jellyfin::DTO::InstallationInfo; - -template <> -InstallationInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return InstallationInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/iplugin.h b/core/include/JellyfinQt/DTO/iplugin.h index 9dde757..a13846c 100644 --- a/core/include/JellyfinQt/DTO/iplugin.h +++ b/core/include/JellyfinQt/DTO/iplugin.h @@ -115,18 +115,6 @@ protected: QString m_dataFolderPath; }; -} // NS DTO - -namespace Support { - -using IPlugin = Jellyfin::DTO::IPlugin; - -template <> -IPlugin fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return IPlugin::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/isotype.h b/core/include/JellyfinQt/DTO/isotype.h index aec1a28..4583102 100644 --- a/core/include/JellyfinQt/DTO/isotype.h +++ b/core/include/JellyfinQt/DTO/isotype.h @@ -54,28 +54,6 @@ private: typedef IsoTypeClass::Value IsoType; -} // NS DTO - -namespace Support { - -using IsoType = Jellyfin::DTO::IsoType; -using IsoTypeClass = Jellyfin::DTO::IsoTypeClass; - -template <> -IsoType fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return IsoTypeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Dvd")) { - return IsoTypeClass::Dvd; - } - if (str == QStringLiteral("BluRay")) { - return IsoTypeClass::BluRay; - } - - return IsoTypeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/item.h b/core/include/JellyfinQt/DTO/item.h deleted file mode 100644 index bc7a76c..0000000 --- a/core/include/JellyfinQt/DTO/item.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Sailfin: a Jellyfin client written using Qt - * Copyright (C) 2021 Chris Josten and the Sailfin Contributors. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -/* - * WARNING: THIS IS AN AUTOMATICALLY GENERATED FILE! PLEASE DO NOT EDIT THIS, AS YOUR EDITS WILL GET - * OVERWRITTEN AT SOME POINT! - * - * If there is a bug in this file, please fix the code generator used to generate this file found in - * core/openapigenerator.d. - * - * This file is generated based on Jellyfin's OpenAPI description, "openapi.json". Please update that - * file with a newer file if needed instead of manually updating the files. - */ - -#ifndef JELLYFIN_DTO_ITEM_H -#define JELLYFIN_DTO_ITEM_H - -#include "JellyfinQt/BaseItemDto" - -namespace Jellyfin { -namespace DTO { - -using Item = BaseItemDto; - -} // NS Jellyfin -} // NS DTO - -#endif // JELLYFIN_DTO_ITEM_H diff --git a/core/include/JellyfinQt/DTO/itemcounts.h b/core/include/JellyfinQt/DTO/itemcounts.h index e990b66..0d928f5 100644 --- a/core/include/JellyfinQt/DTO/itemcounts.h +++ b/core/include/JellyfinQt/DTO/itemcounts.h @@ -160,18 +160,6 @@ protected: qint32 m_itemCount; }; -} // NS DTO - -namespace Support { - -using ItemCounts = Jellyfin::DTO::ItemCounts; - -template <> -ItemCounts fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ItemCounts::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/itemfields.h b/core/include/JellyfinQt/DTO/itemfields.h index 31d0761..88b03a4 100644 --- a/core/include/JellyfinQt/DTO/itemfields.h +++ b/core/include/JellyfinQt/DTO/itemfields.h @@ -113,205 +113,6 @@ private: typedef ItemFieldsClass::Value ItemFields; -} // NS DTO - -namespace Support { - -using ItemFields = Jellyfin::DTO::ItemFields; -using ItemFieldsClass = Jellyfin::DTO::ItemFieldsClass; - -template <> -ItemFields fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return ItemFieldsClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("AirTime")) { - return ItemFieldsClass::AirTime; - } - if (str == QStringLiteral("CanDelete")) { - return ItemFieldsClass::CanDelete; - } - if (str == QStringLiteral("CanDownload")) { - return ItemFieldsClass::CanDownload; - } - if (str == QStringLiteral("ChannelInfo")) { - return ItemFieldsClass::ChannelInfo; - } - if (str == QStringLiteral("Chapters")) { - return ItemFieldsClass::Chapters; - } - if (str == QStringLiteral("ChildCount")) { - return ItemFieldsClass::ChildCount; - } - if (str == QStringLiteral("CumulativeRunTimeTicks")) { - return ItemFieldsClass::CumulativeRunTimeTicks; - } - if (str == QStringLiteral("CustomRating")) { - return ItemFieldsClass::CustomRating; - } - if (str == QStringLiteral("DateCreated")) { - return ItemFieldsClass::DateCreated; - } - if (str == QStringLiteral("DateLastMediaAdded")) { - return ItemFieldsClass::DateLastMediaAdded; - } - if (str == QStringLiteral("DisplayPreferencesId")) { - return ItemFieldsClass::DisplayPreferencesId; - } - if (str == QStringLiteral("Etag")) { - return ItemFieldsClass::Etag; - } - if (str == QStringLiteral("ExternalUrls")) { - return ItemFieldsClass::ExternalUrls; - } - if (str == QStringLiteral("Genres")) { - return ItemFieldsClass::Genres; - } - if (str == QStringLiteral("HomePageUrl")) { - return ItemFieldsClass::HomePageUrl; - } - if (str == QStringLiteral("ItemCounts")) { - return ItemFieldsClass::ItemCounts; - } - if (str == QStringLiteral("MediaSourceCount")) { - return ItemFieldsClass::MediaSourceCount; - } - if (str == QStringLiteral("MediaSources")) { - return ItemFieldsClass::MediaSources; - } - if (str == QStringLiteral("OriginalTitle")) { - return ItemFieldsClass::OriginalTitle; - } - if (str == QStringLiteral("Overview")) { - return ItemFieldsClass::Overview; - } - if (str == QStringLiteral("ParentId")) { - return ItemFieldsClass::ParentId; - } - if (str == QStringLiteral("Path")) { - return ItemFieldsClass::Path; - } - if (str == QStringLiteral("People")) { - return ItemFieldsClass::People; - } - if (str == QStringLiteral("PlayAccess")) { - return ItemFieldsClass::PlayAccess; - } - if (str == QStringLiteral("ProductionLocations")) { - return ItemFieldsClass::ProductionLocations; - } - if (str == QStringLiteral("ProviderIds")) { - return ItemFieldsClass::ProviderIds; - } - if (str == QStringLiteral("PrimaryImageAspectRatio")) { - return ItemFieldsClass::PrimaryImageAspectRatio; - } - if (str == QStringLiteral("RecursiveItemCount")) { - return ItemFieldsClass::RecursiveItemCount; - } - if (str == QStringLiteral("Settings")) { - return ItemFieldsClass::Settings; - } - if (str == QStringLiteral("ScreenshotImageTags")) { - return ItemFieldsClass::ScreenshotImageTags; - } - if (str == QStringLiteral("SeriesPrimaryImage")) { - return ItemFieldsClass::SeriesPrimaryImage; - } - if (str == QStringLiteral("SeriesStudio")) { - return ItemFieldsClass::SeriesStudio; - } - if (str == QStringLiteral("SortName")) { - return ItemFieldsClass::SortName; - } - if (str == QStringLiteral("SpecialEpisodeNumbers")) { - return ItemFieldsClass::SpecialEpisodeNumbers; - } - if (str == QStringLiteral("Studios")) { - return ItemFieldsClass::Studios; - } - if (str == QStringLiteral("BasicSyncInfo")) { - return ItemFieldsClass::BasicSyncInfo; - } - if (str == QStringLiteral("SyncInfo")) { - return ItemFieldsClass::SyncInfo; - } - if (str == QStringLiteral("Taglines")) { - return ItemFieldsClass::Taglines; - } - if (str == QStringLiteral("Tags")) { - return ItemFieldsClass::Tags; - } - if (str == QStringLiteral("RemoteTrailers")) { - return ItemFieldsClass::RemoteTrailers; - } - if (str == QStringLiteral("MediaStreams")) { - return ItemFieldsClass::MediaStreams; - } - if (str == QStringLiteral("SeasonUserData")) { - return ItemFieldsClass::SeasonUserData; - } - if (str == QStringLiteral("ServiceName")) { - return ItemFieldsClass::ServiceName; - } - if (str == QStringLiteral("ThemeSongIds")) { - return ItemFieldsClass::ThemeSongIds; - } - if (str == QStringLiteral("ThemeVideoIds")) { - return ItemFieldsClass::ThemeVideoIds; - } - if (str == QStringLiteral("ExternalEtag")) { - return ItemFieldsClass::ExternalEtag; - } - if (str == QStringLiteral("PresentationUniqueKey")) { - return ItemFieldsClass::PresentationUniqueKey; - } - if (str == QStringLiteral("InheritedParentalRatingValue")) { - return ItemFieldsClass::InheritedParentalRatingValue; - } - if (str == QStringLiteral("ExternalSeriesId")) { - return ItemFieldsClass::ExternalSeriesId; - } - if (str == QStringLiteral("SeriesPresentationUniqueKey")) { - return ItemFieldsClass::SeriesPresentationUniqueKey; - } - if (str == QStringLiteral("DateLastRefreshed")) { - return ItemFieldsClass::DateLastRefreshed; - } - if (str == QStringLiteral("DateLastSaved")) { - return ItemFieldsClass::DateLastSaved; - } - if (str == QStringLiteral("RefreshState")) { - return ItemFieldsClass::RefreshState; - } - if (str == QStringLiteral("ChannelImage")) { - return ItemFieldsClass::ChannelImage; - } - if (str == QStringLiteral("EnableMediaSourceDisplay")) { - return ItemFieldsClass::EnableMediaSourceDisplay; - } - if (str == QStringLiteral("Width")) { - return ItemFieldsClass::Width; - } - if (str == QStringLiteral("Height")) { - return ItemFieldsClass::Height; - } - if (str == QStringLiteral("ExtraIds")) { - return ItemFieldsClass::ExtraIds; - } - if (str == QStringLiteral("LocalTrailerCount")) { - return ItemFieldsClass::LocalTrailerCount; - } - if (str == QStringLiteral("IsHD")) { - return ItemFieldsClass::IsHD; - } - if (str == QStringLiteral("SpecialFeatureCount")) { - return ItemFieldsClass::SpecialFeatureCount; - } - - return ItemFieldsClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/itemfilter.h b/core/include/JellyfinQt/DTO/itemfilter.h index a27d36c..88ef233 100644 --- a/core/include/JellyfinQt/DTO/itemfilter.h +++ b/core/include/JellyfinQt/DTO/itemfilter.h @@ -61,49 +61,6 @@ private: typedef ItemFilterClass::Value ItemFilter; -} // NS DTO - -namespace Support { - -using ItemFilter = Jellyfin::DTO::ItemFilter; -using ItemFilterClass = Jellyfin::DTO::ItemFilterClass; - -template <> -ItemFilter fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return ItemFilterClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("IsFolder")) { - return ItemFilterClass::IsFolder; - } - if (str == QStringLiteral("IsNotFolder")) { - return ItemFilterClass::IsNotFolder; - } - if (str == QStringLiteral("IsUnplayed")) { - return ItemFilterClass::IsUnplayed; - } - if (str == QStringLiteral("IsPlayed")) { - return ItemFilterClass::IsPlayed; - } - if (str == QStringLiteral("IsFavorite")) { - return ItemFilterClass::IsFavorite; - } - if (str == QStringLiteral("IsResumable")) { - return ItemFilterClass::IsResumable; - } - if (str == QStringLiteral("Likes")) { - return ItemFilterClass::Likes; - } - if (str == QStringLiteral("Dislikes")) { - return ItemFilterClass::Dislikes; - } - if (str == QStringLiteral("IsFavoriteOrLikes")) { - return ItemFilterClass::IsFavoriteOrLikes; - } - - return ItemFilterClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/joingrouprequestdto.h b/core/include/JellyfinQt/DTO/joingrouprequestdto.h index 2cd237d..531706b 100644 --- a/core/include/JellyfinQt/DTO/joingrouprequestdto.h +++ b/core/include/JellyfinQt/DTO/joingrouprequestdto.h @@ -62,18 +62,6 @@ protected: QUuid m_groupId; }; -} // NS DTO - -namespace Support { - -using JoinGroupRequestDto = Jellyfin::DTO::JoinGroupRequestDto; - -template <> -JoinGroupRequestDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return JoinGroupRequestDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/keepuntil.h b/core/include/JellyfinQt/DTO/keepuntil.h index fb8ae0f..fae5c1d 100644 --- a/core/include/JellyfinQt/DTO/keepuntil.h +++ b/core/include/JellyfinQt/DTO/keepuntil.h @@ -56,34 +56,6 @@ private: typedef KeepUntilClass::Value KeepUntil; -} // NS DTO - -namespace Support { - -using KeepUntil = Jellyfin::DTO::KeepUntil; -using KeepUntilClass = Jellyfin::DTO::KeepUntilClass; - -template <> -KeepUntil fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return KeepUntilClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("UntilDeleted")) { - return KeepUntilClass::UntilDeleted; - } - if (str == QStringLiteral("UntilSpaceNeeded")) { - return KeepUntilClass::UntilSpaceNeeded; - } - if (str == QStringLiteral("UntilWatched")) { - return KeepUntilClass::UntilWatched; - } - if (str == QStringLiteral("UntilDate")) { - return KeepUntilClass::UntilDate; - } - - return KeepUntilClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/libraryoptioninfodto.h b/core/include/JellyfinQt/DTO/libraryoptioninfodto.h index 8fcddf6..c9f1f0d 100644 --- a/core/include/JellyfinQt/DTO/libraryoptioninfodto.h +++ b/core/include/JellyfinQt/DTO/libraryoptioninfodto.h @@ -71,18 +71,6 @@ protected: bool m_defaultEnabled; }; -} // NS DTO - -namespace Support { - -using LibraryOptionInfoDto = Jellyfin::DTO::LibraryOptionInfoDto; - -template <> -LibraryOptionInfoDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return LibraryOptionInfoDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/libraryoptions.h b/core/include/JellyfinQt/DTO/libraryoptions.h index 10bc13f..896d415 100644 --- a/core/include/JellyfinQt/DTO/libraryoptions.h +++ b/core/include/JellyfinQt/DTO/libraryoptions.h @@ -191,18 +191,6 @@ protected: QList> m_typeOptions; }; -} // NS DTO - -namespace Support { - -using LibraryOptions = Jellyfin::DTO::LibraryOptions; - -template <> -LibraryOptions fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return LibraryOptions::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/libraryoptionsresultdto.h b/core/include/JellyfinQt/DTO/libraryoptionsresultdto.h index 8240c44..50823a3 100644 --- a/core/include/JellyfinQt/DTO/libraryoptionsresultdto.h +++ b/core/include/JellyfinQt/DTO/libraryoptionsresultdto.h @@ -93,18 +93,6 @@ protected: QList> m_typeOptions; }; -} // NS DTO - -namespace Support { - -using LibraryOptionsResultDto = Jellyfin::DTO::LibraryOptionsResultDto; - -template <> -LibraryOptionsResultDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return LibraryOptionsResultDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/librarytypeoptionsdto.h b/core/include/JellyfinQt/DTO/librarytypeoptionsdto.h index 0d3a97d..9ee1e1e 100644 --- a/core/include/JellyfinQt/DTO/librarytypeoptionsdto.h +++ b/core/include/JellyfinQt/DTO/librarytypeoptionsdto.h @@ -104,18 +104,6 @@ protected: QList> m_defaultImageOptions; }; -} // NS DTO - -namespace Support { - -using LibraryTypeOptionsDto = Jellyfin::DTO::LibraryTypeOptionsDto; - -template <> -LibraryTypeOptionsDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return LibraryTypeOptionsDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/libraryupdateinfo.h b/core/include/JellyfinQt/DTO/libraryupdateinfo.h index 374605f..36dc9cd 100644 --- a/core/include/JellyfinQt/DTO/libraryupdateinfo.h +++ b/core/include/JellyfinQt/DTO/libraryupdateinfo.h @@ -110,18 +110,6 @@ protected: bool m_isEmpty; }; -} // NS DTO - -namespace Support { - -using LibraryUpdateInfo = Jellyfin::DTO::LibraryUpdateInfo; - -template <> -LibraryUpdateInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return LibraryUpdateInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/listingsproviderinfo.h b/core/include/JellyfinQt/DTO/listingsproviderinfo.h index a322c85..5fc73cd 100644 --- a/core/include/JellyfinQt/DTO/listingsproviderinfo.h +++ b/core/include/JellyfinQt/DTO/listingsproviderinfo.h @@ -147,18 +147,6 @@ protected: QString m_userAgent; }; -} // NS DTO - -namespace Support { - -using ListingsProviderInfo = Jellyfin::DTO::ListingsProviderInfo; - -template <> -ListingsProviderInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ListingsProviderInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/livestreamresponse.h b/core/include/JellyfinQt/DTO/livestreamresponse.h index ea721e2..4c88e81 100644 --- a/core/include/JellyfinQt/DTO/livestreamresponse.h +++ b/core/include/JellyfinQt/DTO/livestreamresponse.h @@ -59,18 +59,6 @@ protected: QSharedPointer m_mediaSource = nullptr; }; -} // NS DTO - -namespace Support { - -using LiveStreamResponse = Jellyfin::DTO::LiveStreamResponse; - -template <> -LiveStreamResponse fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return LiveStreamResponse::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/livetvinfo.h b/core/include/JellyfinQt/DTO/livetvinfo.h index d62801c..80345ef 100644 --- a/core/include/JellyfinQt/DTO/livetvinfo.h +++ b/core/include/JellyfinQt/DTO/livetvinfo.h @@ -83,18 +83,6 @@ protected: QStringList m_enabledUsers; }; -} // NS DTO - -namespace Support { - -using LiveTvInfo = Jellyfin::DTO::LiveTvInfo; - -template <> -LiveTvInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return LiveTvInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/livetvserviceinfo.h b/core/include/JellyfinQt/DTO/livetvserviceinfo.h index d9b7815..41f2ff3 100644 --- a/core/include/JellyfinQt/DTO/livetvserviceinfo.h +++ b/core/include/JellyfinQt/DTO/livetvserviceinfo.h @@ -120,18 +120,6 @@ protected: QStringList m_tuners; }; -} // NS DTO - -namespace Support { - -using LiveTvServiceInfo = Jellyfin::DTO::LiveTvServiceInfo; - -template <> -LiveTvServiceInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return LiveTvServiceInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/livetvservicestatus.h b/core/include/JellyfinQt/DTO/livetvservicestatus.h index 37e840a..cd95293 100644 --- a/core/include/JellyfinQt/DTO/livetvservicestatus.h +++ b/core/include/JellyfinQt/DTO/livetvservicestatus.h @@ -54,28 +54,6 @@ private: typedef LiveTvServiceStatusClass::Value LiveTvServiceStatus; -} // NS DTO - -namespace Support { - -using LiveTvServiceStatus = Jellyfin::DTO::LiveTvServiceStatus; -using LiveTvServiceStatusClass = Jellyfin::DTO::LiveTvServiceStatusClass; - -template <> -LiveTvServiceStatus fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return LiveTvServiceStatusClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Ok")) { - return LiveTvServiceStatusClass::Ok; - } - if (str == QStringLiteral("Unavailable")) { - return LiveTvServiceStatusClass::Unavailable; - } - - return LiveTvServiceStatusClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/localizationoption.h b/core/include/JellyfinQt/DTO/localizationoption.h index a96c296..ca6c391 100644 --- a/core/include/JellyfinQt/DTO/localizationoption.h +++ b/core/include/JellyfinQt/DTO/localizationoption.h @@ -63,18 +63,6 @@ protected: QString m_value; }; -} // NS DTO - -namespace Support { - -using LocalizationOption = Jellyfin::DTO::LocalizationOption; - -template <> -LocalizationOption fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return LocalizationOption::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/locationtype.h b/core/include/JellyfinQt/DTO/locationtype.h index 1debaff..27fd9ca 100644 --- a/core/include/JellyfinQt/DTO/locationtype.h +++ b/core/include/JellyfinQt/DTO/locationtype.h @@ -56,34 +56,6 @@ private: typedef LocationTypeClass::Value LocationType; -} // NS DTO - -namespace Support { - -using LocationType = Jellyfin::DTO::LocationType; -using LocationTypeClass = Jellyfin::DTO::LocationTypeClass; - -template <> -LocationType fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return LocationTypeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("FileSystem")) { - return LocationTypeClass::FileSystem; - } - if (str == QStringLiteral("Remote")) { - return LocationTypeClass::Remote; - } - if (str == QStringLiteral("Virtual")) { - return LocationTypeClass::Virtual; - } - if (str == QStringLiteral("Offline")) { - return LocationTypeClass::Offline; - } - - return LocationTypeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/logfile.h b/core/include/JellyfinQt/DTO/logfile.h index a941f2a..6358a24 100644 --- a/core/include/JellyfinQt/DTO/logfile.h +++ b/core/include/JellyfinQt/DTO/logfile.h @@ -90,18 +90,6 @@ protected: QString m_name; }; -} // NS DTO - -namespace Support { - -using LogFile = Jellyfin::DTO::LogFile; - -template <> -LogFile fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return LogFile::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/loglevel.h b/core/include/JellyfinQt/DTO/loglevel.h index f2b3655..0663164 100644 --- a/core/include/JellyfinQt/DTO/loglevel.h +++ b/core/include/JellyfinQt/DTO/loglevel.h @@ -59,43 +59,6 @@ private: typedef LogLevelClass::Value LogLevel; -} // NS DTO - -namespace Support { - -using LogLevel = Jellyfin::DTO::LogLevel; -using LogLevelClass = Jellyfin::DTO::LogLevelClass; - -template <> -LogLevel fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return LogLevelClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Trace")) { - return LogLevelClass::Trace; - } - if (str == QStringLiteral("Debug")) { - return LogLevelClass::Debug; - } - if (str == QStringLiteral("Information")) { - return LogLevelClass::Information; - } - if (str == QStringLiteral("Warning")) { - return LogLevelClass::Warning; - } - if (str == QStringLiteral("Error")) { - return LogLevelClass::Error; - } - if (str == QStringLiteral("Critical")) { - return LogLevelClass::Critical; - } - if (str == QStringLiteral("None")) { - return LogLevelClass::None; - } - - return LogLevelClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/mediaattachment.h b/core/include/JellyfinQt/DTO/mediaattachment.h index 25f7035..94aed7a 100644 --- a/core/include/JellyfinQt/DTO/mediaattachment.h +++ b/core/include/JellyfinQt/DTO/mediaattachment.h @@ -116,18 +116,6 @@ protected: QString m_deliveryUrl; }; -} // NS DTO - -namespace Support { - -using MediaAttachment = Jellyfin::DTO::MediaAttachment; - -template <> -MediaAttachment fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return MediaAttachment::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/mediaencoderpathdto.h b/core/include/JellyfinQt/DTO/mediaencoderpathdto.h index 4452e85..8ab34ef 100644 --- a/core/include/JellyfinQt/DTO/mediaencoderpathdto.h +++ b/core/include/JellyfinQt/DTO/mediaencoderpathdto.h @@ -71,18 +71,6 @@ protected: QString m_pathType; }; -} // NS DTO - -namespace Support { - -using MediaEncoderPathDto = Jellyfin::DTO::MediaEncoderPathDto; - -template <> -MediaEncoderPathDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return MediaEncoderPathDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/mediapathdto.h b/core/include/JellyfinQt/DTO/mediapathdto.h index 45fd348..f6be18e 100644 --- a/core/include/JellyfinQt/DTO/mediapathdto.h +++ b/core/include/JellyfinQt/DTO/mediapathdto.h @@ -78,18 +78,6 @@ protected: QSharedPointer m_pathInfo = nullptr; }; -} // NS DTO - -namespace Support { - -using MediaPathDto = Jellyfin::DTO::MediaPathDto; - -template <> -MediaPathDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return MediaPathDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/mediapathinfo.h b/core/include/JellyfinQt/DTO/mediapathinfo.h index 8b3c968..0a12e79 100644 --- a/core/include/JellyfinQt/DTO/mediapathinfo.h +++ b/core/include/JellyfinQt/DTO/mediapathinfo.h @@ -63,18 +63,6 @@ protected: QString m_networkPath; }; -} // NS DTO - -namespace Support { - -using MediaPathInfo = Jellyfin::DTO::MediaPathInfo; - -template <> -MediaPathInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return MediaPathInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/mediaprotocol.h b/core/include/JellyfinQt/DTO/mediaprotocol.h index 30aacac..ff8e164 100644 --- a/core/include/JellyfinQt/DTO/mediaprotocol.h +++ b/core/include/JellyfinQt/DTO/mediaprotocol.h @@ -59,43 +59,6 @@ private: typedef MediaProtocolClass::Value MediaProtocol; -} // NS DTO - -namespace Support { - -using MediaProtocol = Jellyfin::DTO::MediaProtocol; -using MediaProtocolClass = Jellyfin::DTO::MediaProtocolClass; - -template <> -MediaProtocol fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return MediaProtocolClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("File")) { - return MediaProtocolClass::File; - } - if (str == QStringLiteral("Http")) { - return MediaProtocolClass::Http; - } - if (str == QStringLiteral("Rtmp")) { - return MediaProtocolClass::Rtmp; - } - if (str == QStringLiteral("Rtsp")) { - return MediaProtocolClass::Rtsp; - } - if (str == QStringLiteral("Udp")) { - return MediaProtocolClass::Udp; - } - if (str == QStringLiteral("Rtp")) { - return MediaProtocolClass::Rtp; - } - if (str == QStringLiteral("Ftp")) { - return MediaProtocolClass::Ftp; - } - - return MediaProtocolClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/mediasourceinfo.h b/core/include/JellyfinQt/DTO/mediasourceinfo.h index 24bc3a6..22f11e0 100644 --- a/core/include/JellyfinQt/DTO/mediasourceinfo.h +++ b/core/include/JellyfinQt/DTO/mediasourceinfo.h @@ -278,18 +278,6 @@ protected: qint32 m_defaultSubtitleStreamIndex; }; -} // NS DTO - -namespace Support { - -using MediaSourceInfo = Jellyfin::DTO::MediaSourceInfo; - -template <> -MediaSourceInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return MediaSourceInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/mediasourcetype.h b/core/include/JellyfinQt/DTO/mediasourcetype.h index f7567c8..1ed5fe2 100644 --- a/core/include/JellyfinQt/DTO/mediasourcetype.h +++ b/core/include/JellyfinQt/DTO/mediasourcetype.h @@ -55,31 +55,6 @@ private: typedef MediaSourceTypeClass::Value MediaSourceType; -} // NS DTO - -namespace Support { - -using MediaSourceType = Jellyfin::DTO::MediaSourceType; -using MediaSourceTypeClass = Jellyfin::DTO::MediaSourceTypeClass; - -template <> -MediaSourceType fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return MediaSourceTypeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Default")) { - return MediaSourceTypeClass::Default; - } - if (str == QStringLiteral("Grouping")) { - return MediaSourceTypeClass::Grouping; - } - if (str == QStringLiteral("Placeholder")) { - return MediaSourceTypeClass::Placeholder; - } - - return MediaSourceTypeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/mediastream.h b/core/include/JellyfinQt/DTO/mediastream.h index ad2c366..048b86d 100644 --- a/core/include/JellyfinQt/DTO/mediastream.h +++ b/core/include/JellyfinQt/DTO/mediastream.h @@ -442,18 +442,6 @@ protected: bool m_isAnamorphic; }; -} // NS DTO - -namespace Support { - -using MediaStream = Jellyfin::DTO::MediaStream; - -template <> -MediaStream fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return MediaStream::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/mediastreamtype.h b/core/include/JellyfinQt/DTO/mediastreamtype.h index 1f8f7cf..9607bda 100644 --- a/core/include/JellyfinQt/DTO/mediastreamtype.h +++ b/core/include/JellyfinQt/DTO/mediastreamtype.h @@ -56,34 +56,6 @@ private: typedef MediaStreamTypeClass::Value MediaStreamType; -} // NS DTO - -namespace Support { - -using MediaStreamType = Jellyfin::DTO::MediaStreamType; -using MediaStreamTypeClass = Jellyfin::DTO::MediaStreamTypeClass; - -template <> -MediaStreamType fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return MediaStreamTypeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Audio")) { - return MediaStreamTypeClass::Audio; - } - if (str == QStringLiteral("Video")) { - return MediaStreamTypeClass::Video; - } - if (str == QStringLiteral("Subtitle")) { - return MediaStreamTypeClass::Subtitle; - } - if (str == QStringLiteral("EmbeddedImage")) { - return MediaStreamTypeClass::EmbeddedImage; - } - - return MediaStreamTypeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/mediaupdateinfodto.h b/core/include/JellyfinQt/DTO/mediaupdateinfodto.h index 5bec512..c94f0ec 100644 --- a/core/include/JellyfinQt/DTO/mediaupdateinfodto.h +++ b/core/include/JellyfinQt/DTO/mediaupdateinfodto.h @@ -73,18 +73,6 @@ protected: QString m_updateType; }; -} // NS DTO - -namespace Support { - -using MediaUpdateInfoDto = Jellyfin::DTO::MediaUpdateInfoDto; - -template <> -MediaUpdateInfoDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return MediaUpdateInfoDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/mediaurl.h b/core/include/JellyfinQt/DTO/mediaurl.h index 959f995..dc7143e 100644 --- a/core/include/JellyfinQt/DTO/mediaurl.h +++ b/core/include/JellyfinQt/DTO/mediaurl.h @@ -63,18 +63,6 @@ protected: QString m_name; }; -} // NS DTO - -namespace Support { - -using MediaUrl = Jellyfin::DTO::MediaUrl; - -template <> -MediaUrl fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return MediaUrl::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/metadataeditorinfo.h b/core/include/JellyfinQt/DTO/metadataeditorinfo.h index 8b44810..1ba6f66 100644 --- a/core/include/JellyfinQt/DTO/metadataeditorinfo.h +++ b/core/include/JellyfinQt/DTO/metadataeditorinfo.h @@ -91,18 +91,6 @@ protected: QList> m_contentTypeOptions; }; -} // NS DTO - -namespace Support { - -using MetadataEditorInfo = Jellyfin::DTO::MetadataEditorInfo; - -template <> -MetadataEditorInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return MetadataEditorInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/metadatafield.h b/core/include/JellyfinQt/DTO/metadatafield.h index 337c315..ddab32c 100644 --- a/core/include/JellyfinQt/DTO/metadatafield.h +++ b/core/include/JellyfinQt/DTO/metadatafield.h @@ -61,49 +61,6 @@ private: typedef MetadataFieldClass::Value MetadataField; -} // NS DTO - -namespace Support { - -using MetadataField = Jellyfin::DTO::MetadataField; -using MetadataFieldClass = Jellyfin::DTO::MetadataFieldClass; - -template <> -MetadataField fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return MetadataFieldClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Cast")) { - return MetadataFieldClass::Cast; - } - if (str == QStringLiteral("Genres")) { - return MetadataFieldClass::Genres; - } - if (str == QStringLiteral("ProductionLocations")) { - return MetadataFieldClass::ProductionLocations; - } - if (str == QStringLiteral("Studios")) { - return MetadataFieldClass::Studios; - } - if (str == QStringLiteral("Tags")) { - return MetadataFieldClass::Tags; - } - if (str == QStringLiteral("Name")) { - return MetadataFieldClass::Name; - } - if (str == QStringLiteral("Overview")) { - return MetadataFieldClass::Overview; - } - if (str == QStringLiteral("Runtime")) { - return MetadataFieldClass::Runtime; - } - if (str == QStringLiteral("OfficialRating")) { - return MetadataFieldClass::OfficialRating; - } - - return MetadataFieldClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/metadataoptions.h b/core/include/JellyfinQt/DTO/metadataoptions.h index 54ccd42..e59ee74 100644 --- a/core/include/JellyfinQt/DTO/metadataoptions.h +++ b/core/include/JellyfinQt/DTO/metadataoptions.h @@ -90,18 +90,6 @@ protected: QStringList m_imageFetcherOrder; }; -} // NS DTO - -namespace Support { - -using MetadataOptions = Jellyfin::DTO::MetadataOptions; - -template <> -MetadataOptions fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return MetadataOptions::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/metadatarefreshmode.h b/core/include/JellyfinQt/DTO/metadatarefreshmode.h index 2ce8f52..4fdd3d3 100644 --- a/core/include/JellyfinQt/DTO/metadatarefreshmode.h +++ b/core/include/JellyfinQt/DTO/metadatarefreshmode.h @@ -56,34 +56,6 @@ private: typedef MetadataRefreshModeClass::Value MetadataRefreshMode; -} // NS DTO - -namespace Support { - -using MetadataRefreshMode = Jellyfin::DTO::MetadataRefreshMode; -using MetadataRefreshModeClass = Jellyfin::DTO::MetadataRefreshModeClass; - -template <> -MetadataRefreshMode fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return MetadataRefreshModeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("None")) { - return MetadataRefreshModeClass::None; - } - if (str == QStringLiteral("ValidationOnly")) { - return MetadataRefreshModeClass::ValidationOnly; - } - if (str == QStringLiteral("Default")) { - return MetadataRefreshModeClass::Default; - } - if (str == QStringLiteral("FullRefresh")) { - return MetadataRefreshModeClass::FullRefresh; - } - - return MetadataRefreshModeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/moveplaylistitemrequestdto.h b/core/include/JellyfinQt/DTO/moveplaylistitemrequestdto.h index 87a16a7..1b876a6 100644 --- a/core/include/JellyfinQt/DTO/moveplaylistitemrequestdto.h +++ b/core/include/JellyfinQt/DTO/moveplaylistitemrequestdto.h @@ -71,18 +71,6 @@ protected: qint32 m_newIndex; }; -} // NS DTO - -namespace Support { - -using MovePlaylistItemRequestDto = Jellyfin::DTO::MovePlaylistItemRequestDto; - -template <> -MovePlaylistItemRequestDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return MovePlaylistItemRequestDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/movieinfo.h b/core/include/JellyfinQt/DTO/movieinfo.h index f03935d..c78487c 100644 --- a/core/include/JellyfinQt/DTO/movieinfo.h +++ b/core/include/JellyfinQt/DTO/movieinfo.h @@ -128,18 +128,6 @@ protected: bool m_isAutomated; }; -} // NS DTO - -namespace Support { - -using MovieInfo = Jellyfin::DTO::MovieInfo; - -template <> -MovieInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return MovieInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/movieinforemotesearchquery.h b/core/include/JellyfinQt/DTO/movieinforemotesearchquery.h index b7279ea..03dc1b1 100644 --- a/core/include/JellyfinQt/DTO/movieinforemotesearchquery.h +++ b/core/include/JellyfinQt/DTO/movieinforemotesearchquery.h @@ -84,18 +84,6 @@ protected: bool m_includeDisabledProviders; }; -} // NS DTO - -namespace Support { - -using MovieInfoRemoteSearchQuery = Jellyfin::DTO::MovieInfoRemoteSearchQuery; - -template <> -MovieInfoRemoteSearchQuery fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return MovieInfoRemoteSearchQuery::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/musicvideoinfo.h b/core/include/JellyfinQt/DTO/musicvideoinfo.h index a53fdf0..035ae6e 100644 --- a/core/include/JellyfinQt/DTO/musicvideoinfo.h +++ b/core/include/JellyfinQt/DTO/musicvideoinfo.h @@ -135,18 +135,6 @@ protected: QStringList m_artists; }; -} // NS DTO - -namespace Support { - -using MusicVideoInfo = Jellyfin::DTO::MusicVideoInfo; - -template <> -MusicVideoInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return MusicVideoInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/musicvideoinforemotesearchquery.h b/core/include/JellyfinQt/DTO/musicvideoinforemotesearchquery.h index 8ff9616..06bd2c3 100644 --- a/core/include/JellyfinQt/DTO/musicvideoinforemotesearchquery.h +++ b/core/include/JellyfinQt/DTO/musicvideoinforemotesearchquery.h @@ -84,18 +84,6 @@ protected: bool m_includeDisabledProviders; }; -} // NS DTO - -namespace Support { - -using MusicVideoInfoRemoteSearchQuery = Jellyfin::DTO::MusicVideoInfoRemoteSearchQuery; - -template <> -MusicVideoInfoRemoteSearchQuery fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return MusicVideoInfoRemoteSearchQuery::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/nameguidpair.h b/core/include/JellyfinQt/DTO/nameguidpair.h index c379925..3d18f19 100644 --- a/core/include/JellyfinQt/DTO/nameguidpair.h +++ b/core/include/JellyfinQt/DTO/nameguidpair.h @@ -64,18 +64,6 @@ protected: QUuid m_jellyfinId; }; -} // NS DTO - -namespace Support { - -using NameGuidPair = Jellyfin::DTO::NameGuidPair; - -template <> -NameGuidPair fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return NameGuidPair::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/nameidpair.h b/core/include/JellyfinQt/DTO/nameidpair.h index 1db8f10..2b505e2 100644 --- a/core/include/JellyfinQt/DTO/nameidpair.h +++ b/core/include/JellyfinQt/DTO/nameidpair.h @@ -71,18 +71,6 @@ protected: QString m_jellyfinId; }; -} // NS DTO - -namespace Support { - -using NameIdPair = Jellyfin::DTO::NameIdPair; - -template <> -NameIdPair fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return NameIdPair::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/namevaluepair.h b/core/include/JellyfinQt/DTO/namevaluepair.h index e3756cb..b01b042 100644 --- a/core/include/JellyfinQt/DTO/namevaluepair.h +++ b/core/include/JellyfinQt/DTO/namevaluepair.h @@ -71,18 +71,6 @@ protected: QString m_value; }; -} // NS DTO - -namespace Support { - -using NameValuePair = Jellyfin::DTO::NameValuePair; - -template <> -NameValuePair fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return NameValuePair::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/newgrouprequestdto.h b/core/include/JellyfinQt/DTO/newgrouprequestdto.h index 0835374..95256f0 100644 --- a/core/include/JellyfinQt/DTO/newgrouprequestdto.h +++ b/core/include/JellyfinQt/DTO/newgrouprequestdto.h @@ -62,18 +62,6 @@ protected: QString m_groupName; }; -} // NS DTO - -namespace Support { - -using NewGroupRequestDto = Jellyfin::DTO::NewGroupRequestDto; - -template <> -NewGroupRequestDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return NewGroupRequestDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/nextitemrequestdto.h b/core/include/JellyfinQt/DTO/nextitemrequestdto.h index b520b98..7e0134e 100644 --- a/core/include/JellyfinQt/DTO/nextitemrequestdto.h +++ b/core/include/JellyfinQt/DTO/nextitemrequestdto.h @@ -62,18 +62,6 @@ protected: QUuid m_playlistItemId; }; -} // NS DTO - -namespace Support { - -using NextItemRequestDto = Jellyfin::DTO::NextItemRequestDto; - -template <> -NextItemRequestDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return NextItemRequestDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/notificationdto.h b/core/include/JellyfinQt/DTO/notificationdto.h index c7e7576..1106640 100644 --- a/core/include/JellyfinQt/DTO/notificationdto.h +++ b/core/include/JellyfinQt/DTO/notificationdto.h @@ -123,18 +123,6 @@ protected: NotificationLevel m_level; }; -} // NS DTO - -namespace Support { - -using NotificationDto = Jellyfin::DTO::NotificationDto; - -template <> -NotificationDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return NotificationDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/notificationlevel.h b/core/include/JellyfinQt/DTO/notificationlevel.h index acb8bf2..5eb0a28 100644 --- a/core/include/JellyfinQt/DTO/notificationlevel.h +++ b/core/include/JellyfinQt/DTO/notificationlevel.h @@ -55,31 +55,6 @@ private: typedef NotificationLevelClass::Value NotificationLevel; -} // NS DTO - -namespace Support { - -using NotificationLevel = Jellyfin::DTO::NotificationLevel; -using NotificationLevelClass = Jellyfin::DTO::NotificationLevelClass; - -template <> -NotificationLevel fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return NotificationLevelClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Normal")) { - return NotificationLevelClass::Normal; - } - if (str == QStringLiteral("Warning")) { - return NotificationLevelClass::Warning; - } - if (str == QStringLiteral("Error")) { - return NotificationLevelClass::Error; - } - - return NotificationLevelClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/notificationresultdto.h b/core/include/JellyfinQt/DTO/notificationresultdto.h index 4d3c484..3c82d5b 100644 --- a/core/include/JellyfinQt/DTO/notificationresultdto.h +++ b/core/include/JellyfinQt/DTO/notificationresultdto.h @@ -74,18 +74,6 @@ protected: qint32 m_totalRecordCount; }; -} // NS DTO - -namespace Support { - -using NotificationResultDto = Jellyfin::DTO::NotificationResultDto; - -template <> -NotificationResultDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return NotificationResultDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/notificationssummarydto.h b/core/include/JellyfinQt/DTO/notificationssummarydto.h index 1569ffd..c53d58b 100644 --- a/core/include/JellyfinQt/DTO/notificationssummarydto.h +++ b/core/include/JellyfinQt/DTO/notificationssummarydto.h @@ -67,18 +67,6 @@ protected: NotificationLevel m_maxUnreadNotificationLevel; }; -} // NS DTO - -namespace Support { - -using NotificationsSummaryDto = Jellyfin::DTO::NotificationsSummaryDto; - -template <> -NotificationsSummaryDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return NotificationsSummaryDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/notificationtypeinfo.h b/core/include/JellyfinQt/DTO/notificationtypeinfo.h index 0dc4fab..e555998 100644 --- a/core/include/JellyfinQt/DTO/notificationtypeinfo.h +++ b/core/include/JellyfinQt/DTO/notificationtypeinfo.h @@ -78,18 +78,6 @@ protected: bool m_isBasedOnUserEvent; }; -} // NS DTO - -namespace Support { - -using NotificationTypeInfo = Jellyfin::DTO::NotificationTypeInfo; - -template <> -NotificationTypeInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return NotificationTypeInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/objectgroupupdate.h b/core/include/JellyfinQt/DTO/objectgroupupdate.h index 1f1a057..06c4581 100644 --- a/core/include/JellyfinQt/DTO/objectgroupupdate.h +++ b/core/include/JellyfinQt/DTO/objectgroupupdate.h @@ -78,18 +78,6 @@ protected: QVariant m_data; }; -} // NS DTO - -namespace Support { - -using ObjectGroupUpdate = Jellyfin::DTO::ObjectGroupUpdate; - -template <> -ObjectGroupUpdate fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ObjectGroupUpdate::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/openlivestreamdto.h b/core/include/JellyfinQt/DTO/openlivestreamdto.h index c376a9b..f02e596 100644 --- a/core/include/JellyfinQt/DTO/openlivestreamdto.h +++ b/core/include/JellyfinQt/DTO/openlivestreamdto.h @@ -172,18 +172,6 @@ protected: QList m_directPlayProtocols; }; -} // NS DTO - -namespace Support { - -using OpenLiveStreamDto = Jellyfin::DTO::OpenLiveStreamDto; - -template <> -OpenLiveStreamDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return OpenLiveStreamDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/packageinfo.h b/core/include/JellyfinQt/DTO/packageinfo.h index 73f2d7c..e28520e 100644 --- a/core/include/JellyfinQt/DTO/packageinfo.h +++ b/core/include/JellyfinQt/DTO/packageinfo.h @@ -131,18 +131,6 @@ protected: QString m_imageUrl; }; -} // NS DTO - -namespace Support { - -using PackageInfo = Jellyfin::DTO::PackageInfo; - -template <> -PackageInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return PackageInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/parentalrating.h b/core/include/JellyfinQt/DTO/parentalrating.h index dec58a4..a7646f4 100644 --- a/core/include/JellyfinQt/DTO/parentalrating.h +++ b/core/include/JellyfinQt/DTO/parentalrating.h @@ -71,18 +71,6 @@ protected: qint32 m_value; }; -} // NS DTO - -namespace Support { - -using ParentalRating = Jellyfin::DTO::ParentalRating; - -template <> -ParentalRating fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ParentalRating::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/pathsubstitution.h b/core/include/JellyfinQt/DTO/pathsubstitution.h index 71d977d..5147173 100644 --- a/core/include/JellyfinQt/DTO/pathsubstitution.h +++ b/core/include/JellyfinQt/DTO/pathsubstitution.h @@ -71,18 +71,6 @@ protected: QString m_to; }; -} // NS DTO - -namespace Support { - -using PathSubstitution = Jellyfin::DTO::PathSubstitution; - -template <> -PathSubstitution fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return PathSubstitution::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/personlookupinfo.h b/core/include/JellyfinQt/DTO/personlookupinfo.h index 7e63f11..35a94ef 100644 --- a/core/include/JellyfinQt/DTO/personlookupinfo.h +++ b/core/include/JellyfinQt/DTO/personlookupinfo.h @@ -128,18 +128,6 @@ protected: bool m_isAutomated; }; -} // NS DTO - -namespace Support { - -using PersonLookupInfo = Jellyfin::DTO::PersonLookupInfo; - -template <> -PersonLookupInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return PersonLookupInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/personlookupinforemotesearchquery.h b/core/include/JellyfinQt/DTO/personlookupinforemotesearchquery.h index 0a0711e..ba80179 100644 --- a/core/include/JellyfinQt/DTO/personlookupinforemotesearchquery.h +++ b/core/include/JellyfinQt/DTO/personlookupinforemotesearchquery.h @@ -84,18 +84,6 @@ protected: bool m_includeDisabledProviders; }; -} // NS DTO - -namespace Support { - -using PersonLookupInfoRemoteSearchQuery = Jellyfin::DTO::PersonLookupInfoRemoteSearchQuery; - -template <> -PersonLookupInfoRemoteSearchQuery fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return PersonLookupInfoRemoteSearchQuery::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/pingrequestdto.h b/core/include/JellyfinQt/DTO/pingrequestdto.h index c98f94e..bd7e710 100644 --- a/core/include/JellyfinQt/DTO/pingrequestdto.h +++ b/core/include/JellyfinQt/DTO/pingrequestdto.h @@ -61,18 +61,6 @@ protected: qint64 m_ping; }; -} // NS DTO - -namespace Support { - -using PingRequestDto = Jellyfin::DTO::PingRequestDto; - -template <> -PingRequestDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return PingRequestDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/pinredeemresult.h b/core/include/JellyfinQt/DTO/pinredeemresult.h index bf1b26a..a8fd1e4 100644 --- a/core/include/JellyfinQt/DTO/pinredeemresult.h +++ b/core/include/JellyfinQt/DTO/pinredeemresult.h @@ -73,18 +73,6 @@ protected: QStringList m_usersReset; }; -} // NS DTO - -namespace Support { - -using PinRedeemResult = Jellyfin::DTO::PinRedeemResult; - -template <> -PinRedeemResult fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return PinRedeemResult::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/playaccess.h b/core/include/JellyfinQt/DTO/playaccess.h index 231956c..bcf679f 100644 --- a/core/include/JellyfinQt/DTO/playaccess.h +++ b/core/include/JellyfinQt/DTO/playaccess.h @@ -54,28 +54,6 @@ private: typedef PlayAccessClass::Value PlayAccess; -} // NS DTO - -namespace Support { - -using PlayAccess = Jellyfin::DTO::PlayAccess; -using PlayAccessClass = Jellyfin::DTO::PlayAccessClass; - -template <> -PlayAccess fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return PlayAccessClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Full")) { - return PlayAccessClass::Full; - } - if (str == QStringLiteral("None")) { - return PlayAccessClass::None; - } - - return PlayAccessClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/playbackerrorcode.h b/core/include/JellyfinQt/DTO/playbackerrorcode.h index b8cc9be..10d0471 100644 --- a/core/include/JellyfinQt/DTO/playbackerrorcode.h +++ b/core/include/JellyfinQt/DTO/playbackerrorcode.h @@ -55,31 +55,6 @@ private: typedef PlaybackErrorCodeClass::Value PlaybackErrorCode; -} // NS DTO - -namespace Support { - -using PlaybackErrorCode = Jellyfin::DTO::PlaybackErrorCode; -using PlaybackErrorCodeClass = Jellyfin::DTO::PlaybackErrorCodeClass; - -template <> -PlaybackErrorCode fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return PlaybackErrorCodeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("NotAllowed")) { - return PlaybackErrorCodeClass::NotAllowed; - } - if (str == QStringLiteral("NoCompatibleStream")) { - return PlaybackErrorCodeClass::NoCompatibleStream; - } - if (str == QStringLiteral("RateLimitExceeded")) { - return PlaybackErrorCodeClass::RateLimitExceeded; - } - - return PlaybackErrorCodeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/playbackinfodto.h b/core/include/JellyfinQt/DTO/playbackinfodto.h index b1e32cd..211aa1d 100644 --- a/core/include/JellyfinQt/DTO/playbackinfodto.h +++ b/core/include/JellyfinQt/DTO/playbackinfodto.h @@ -187,18 +187,6 @@ protected: bool m_autoOpenLiveStream; }; -} // NS DTO - -namespace Support { - -using PlaybackInfoDto = Jellyfin::DTO::PlaybackInfoDto; - -template <> -PlaybackInfoDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return PlaybackInfoDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/playbackinforesponse.h b/core/include/JellyfinQt/DTO/playbackinforesponse.h index 6e61c4b..72b61bc 100644 --- a/core/include/JellyfinQt/DTO/playbackinforesponse.h +++ b/core/include/JellyfinQt/DTO/playbackinforesponse.h @@ -81,18 +81,6 @@ protected: PlaybackErrorCode m_errorCode; }; -} // NS DTO - -namespace Support { - -using PlaybackInfoResponse = Jellyfin::DTO::PlaybackInfoResponse; - -template <> -PlaybackInfoResponse fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return PlaybackInfoResponse::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/playbackprogressinfo.h b/core/include/JellyfinQt/DTO/playbackprogressinfo.h index a7beefa..698c004 100644 --- a/core/include/JellyfinQt/DTO/playbackprogressinfo.h +++ b/core/include/JellyfinQt/DTO/playbackprogressinfo.h @@ -209,18 +209,6 @@ protected: QString m_playlistItemId; }; -} // NS DTO - -namespace Support { - -using PlaybackProgressInfo = Jellyfin::DTO::PlaybackProgressInfo; - -template <> -PlaybackProgressInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return PlaybackProgressInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/playbackstartinfo.h b/core/include/JellyfinQt/DTO/playbackstartinfo.h index bf3a325..46d0b5a 100644 --- a/core/include/JellyfinQt/DTO/playbackstartinfo.h +++ b/core/include/JellyfinQt/DTO/playbackstartinfo.h @@ -209,18 +209,6 @@ protected: QString m_playlistItemId; }; -} // NS DTO - -namespace Support { - -using PlaybackStartInfo = Jellyfin::DTO::PlaybackStartInfo; - -template <> -PlaybackStartInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return PlaybackStartInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/playbackstopinfo.h b/core/include/JellyfinQt/DTO/playbackstopinfo.h index b99bc21..d9ec728 100644 --- a/core/include/JellyfinQt/DTO/playbackstopinfo.h +++ b/core/include/JellyfinQt/DTO/playbackstopinfo.h @@ -142,18 +142,6 @@ protected: QList> m_nowPlayingQueue; }; -} // NS DTO - -namespace Support { - -using PlaybackStopInfo = Jellyfin::DTO::PlaybackStopInfo; - -template <> -PlaybackStopInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return PlaybackStopInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/playcommand.h b/core/include/JellyfinQt/DTO/playcommand.h index fcc0f90..52da967 100644 --- a/core/include/JellyfinQt/DTO/playcommand.h +++ b/core/include/JellyfinQt/DTO/playcommand.h @@ -57,37 +57,6 @@ private: typedef PlayCommandClass::Value PlayCommand; -} // NS DTO - -namespace Support { - -using PlayCommand = Jellyfin::DTO::PlayCommand; -using PlayCommandClass = Jellyfin::DTO::PlayCommandClass; - -template <> -PlayCommand fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return PlayCommandClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("PlayNow")) { - return PlayCommandClass::PlayNow; - } - if (str == QStringLiteral("PlayNext")) { - return PlayCommandClass::PlayNext; - } - if (str == QStringLiteral("PlayLast")) { - return PlayCommandClass::PlayLast; - } - if (str == QStringLiteral("PlayInstantMix")) { - return PlayCommandClass::PlayInstantMix; - } - if (str == QStringLiteral("PlayShuffle")) { - return PlayCommandClass::PlayShuffle; - } - - return PlayCommandClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/playerstateinfo.h b/core/include/JellyfinQt/DTO/playerstateinfo.h index ff7b9b0..9111229 100644 --- a/core/include/JellyfinQt/DTO/playerstateinfo.h +++ b/core/include/JellyfinQt/DTO/playerstateinfo.h @@ -137,18 +137,6 @@ protected: RepeatMode m_repeatMode; }; -} // NS DTO - -namespace Support { - -using PlayerStateInfo = Jellyfin::DTO::PlayerStateInfo; - -template <> -PlayerStateInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return PlayerStateInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/playlistcreationresult.h b/core/include/JellyfinQt/DTO/playlistcreationresult.h index 2c10d08..7a8ce97 100644 --- a/core/include/JellyfinQt/DTO/playlistcreationresult.h +++ b/core/include/JellyfinQt/DTO/playlistcreationresult.h @@ -58,18 +58,6 @@ protected: QString m_jellyfinId; }; -} // NS DTO - -namespace Support { - -using PlaylistCreationResult = Jellyfin::DTO::PlaylistCreationResult; - -template <> -PlaylistCreationResult fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return PlaylistCreationResult::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/playmethod.h b/core/include/JellyfinQt/DTO/playmethod.h index f709d5e..373e0d4 100644 --- a/core/include/JellyfinQt/DTO/playmethod.h +++ b/core/include/JellyfinQt/DTO/playmethod.h @@ -55,31 +55,6 @@ private: typedef PlayMethodClass::Value PlayMethod; -} // NS DTO - -namespace Support { - -using PlayMethod = Jellyfin::DTO::PlayMethod; -using PlayMethodClass = Jellyfin::DTO::PlayMethodClass; - -template <> -PlayMethod fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return PlayMethodClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Transcode")) { - return PlayMethodClass::Transcode; - } - if (str == QStringLiteral("DirectStream")) { - return PlayMethodClass::DirectStream; - } - if (str == QStringLiteral("DirectPlay")) { - return PlayMethodClass::DirectPlay; - } - - return PlayMethodClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/playrequest.h b/core/include/JellyfinQt/DTO/playrequest.h index 16b5467..d30b2a8 100644 --- a/core/include/JellyfinQt/DTO/playrequest.h +++ b/core/include/JellyfinQt/DTO/playrequest.h @@ -109,18 +109,6 @@ protected: qint32 m_startIndex; }; -} // NS DTO - -namespace Support { - -using PlayRequest = Jellyfin::DTO::PlayRequest; - -template <> -PlayRequest fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return PlayRequest::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/playrequestdto.h b/core/include/JellyfinQt/DTO/playrequestdto.h index ebdcba4..86d9e0b 100644 --- a/core/include/JellyfinQt/DTO/playrequestdto.h +++ b/core/include/JellyfinQt/DTO/playrequestdto.h @@ -82,18 +82,6 @@ protected: qint64 m_startPositionTicks; }; -} // NS DTO - -namespace Support { - -using PlayRequestDto = Jellyfin::DTO::PlayRequestDto; - -template <> -PlayRequestDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return PlayRequestDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/playstatecommand.h b/core/include/JellyfinQt/DTO/playstatecommand.h index 26436d4..1fdf108 100644 --- a/core/include/JellyfinQt/DTO/playstatecommand.h +++ b/core/include/JellyfinQt/DTO/playstatecommand.h @@ -61,49 +61,6 @@ private: typedef PlaystateCommandClass::Value PlaystateCommand; -} // NS DTO - -namespace Support { - -using PlaystateCommand = Jellyfin::DTO::PlaystateCommand; -using PlaystateCommandClass = Jellyfin::DTO::PlaystateCommandClass; - -template <> -PlaystateCommand fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return PlaystateCommandClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Stop")) { - return PlaystateCommandClass::Stop; - } - if (str == QStringLiteral("Pause")) { - return PlaystateCommandClass::Pause; - } - if (str == QStringLiteral("Unpause")) { - return PlaystateCommandClass::Unpause; - } - if (str == QStringLiteral("NextTrack")) { - return PlaystateCommandClass::NextTrack; - } - if (str == QStringLiteral("PreviousTrack")) { - return PlaystateCommandClass::PreviousTrack; - } - if (str == QStringLiteral("Seek")) { - return PlaystateCommandClass::Seek; - } - if (str == QStringLiteral("Rewind")) { - return PlaystateCommandClass::Rewind; - } - if (str == QStringLiteral("FastForward")) { - return PlaystateCommandClass::FastForward; - } - if (str == QStringLiteral("PlayPause")) { - return PlaystateCommandClass::PlayPause; - } - - return PlaystateCommandClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/playstaterequest.h b/core/include/JellyfinQt/DTO/playstaterequest.h index 0758bdc..32b2044 100644 --- a/core/include/JellyfinQt/DTO/playstaterequest.h +++ b/core/include/JellyfinQt/DTO/playstaterequest.h @@ -73,18 +73,6 @@ protected: QString m_controllingUserId; }; -} // NS DTO - -namespace Support { - -using PlaystateRequest = Jellyfin::DTO::PlaystateRequest; - -template <> -PlaystateRequest fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return PlaystateRequest::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/plugininfo.h b/core/include/JellyfinQt/DTO/plugininfo.h index a9cf77e..ef43a67 100644 --- a/core/include/JellyfinQt/DTO/plugininfo.h +++ b/core/include/JellyfinQt/DTO/plugininfo.h @@ -121,18 +121,6 @@ protected: PluginStatus m_status; }; -} // NS DTO - -namespace Support { - -using PluginInfo = Jellyfin::DTO::PluginInfo; - -template <> -PluginInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return PluginInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/pluginsecurityinfo.h b/core/include/JellyfinQt/DTO/pluginsecurityinfo.h index 0c32bd0..b852b7d 100644 --- a/core/include/JellyfinQt/DTO/pluginsecurityinfo.h +++ b/core/include/JellyfinQt/DTO/pluginsecurityinfo.h @@ -71,18 +71,6 @@ protected: bool m_isMbSupporter; }; -} // NS DTO - -namespace Support { - -using PluginSecurityInfo = Jellyfin::DTO::PluginSecurityInfo; - -template <> -PluginSecurityInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return PluginSecurityInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/pluginstatus.h b/core/include/JellyfinQt/DTO/pluginstatus.h index 795ceb4..ec80939 100644 --- a/core/include/JellyfinQt/DTO/pluginstatus.h +++ b/core/include/JellyfinQt/DTO/pluginstatus.h @@ -59,43 +59,6 @@ private: typedef PluginStatusClass::Value PluginStatus; -} // NS DTO - -namespace Support { - -using PluginStatus = Jellyfin::DTO::PluginStatus; -using PluginStatusClass = Jellyfin::DTO::PluginStatusClass; - -template <> -PluginStatus fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return PluginStatusClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Active")) { - return PluginStatusClass::Active; - } - if (str == QStringLiteral("Restart")) { - return PluginStatusClass::Restart; - } - if (str == QStringLiteral("Deleted")) { - return PluginStatusClass::Deleted; - } - if (str == QStringLiteral("Superceded")) { - return PluginStatusClass::Superceded; - } - if (str == QStringLiteral("Malfunctioned")) { - return PluginStatusClass::Malfunctioned; - } - if (str == QStringLiteral("NotSupported")) { - return PluginStatusClass::NotSupported; - } - if (str == QStringLiteral("Disabled")) { - return PluginStatusClass::Disabled; - } - - return PluginStatusClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/previousitemrequestdto.h b/core/include/JellyfinQt/DTO/previousitemrequestdto.h index 76a9950..0b7acbe 100644 --- a/core/include/JellyfinQt/DTO/previousitemrequestdto.h +++ b/core/include/JellyfinQt/DTO/previousitemrequestdto.h @@ -62,18 +62,6 @@ protected: QUuid m_playlistItemId; }; -} // NS DTO - -namespace Support { - -using PreviousItemRequestDto = Jellyfin::DTO::PreviousItemRequestDto; - -template <> -PreviousItemRequestDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return PreviousItemRequestDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/problemdetails.h b/core/include/JellyfinQt/DTO/problemdetails.h index f0c8e6f..df60734 100644 --- a/core/include/JellyfinQt/DTO/problemdetails.h +++ b/core/include/JellyfinQt/DTO/problemdetails.h @@ -78,18 +78,6 @@ protected: QString m_instance; }; -} // NS DTO - -namespace Support { - -using ProblemDetails = Jellyfin::DTO::ProblemDetails; - -template <> -ProblemDetails fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ProblemDetails::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/profilecondition.h b/core/include/JellyfinQt/DTO/profilecondition.h index 1098b7f..45d0d63 100644 --- a/core/include/JellyfinQt/DTO/profilecondition.h +++ b/core/include/JellyfinQt/DTO/profilecondition.h @@ -75,18 +75,6 @@ protected: bool m_isRequired; }; -} // NS DTO - -namespace Support { - -using ProfileCondition = Jellyfin::DTO::ProfileCondition; - -template <> -ProfileCondition fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ProfileCondition::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/profileconditiontype.h b/core/include/JellyfinQt/DTO/profileconditiontype.h index 8a51152..df3eef2 100644 --- a/core/include/JellyfinQt/DTO/profileconditiontype.h +++ b/core/include/JellyfinQt/DTO/profileconditiontype.h @@ -57,37 +57,6 @@ private: typedef ProfileConditionTypeClass::Value ProfileConditionType; -} // NS DTO - -namespace Support { - -using ProfileConditionType = Jellyfin::DTO::ProfileConditionType; -using ProfileConditionTypeClass = Jellyfin::DTO::ProfileConditionTypeClass; - -template <> -ProfileConditionType fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return ProfileConditionTypeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Equals")) { - return ProfileConditionTypeClass::Equals; - } - if (str == QStringLiteral("NotEquals")) { - return ProfileConditionTypeClass::NotEquals; - } - if (str == QStringLiteral("LessThanEqual")) { - return ProfileConditionTypeClass::LessThanEqual; - } - if (str == QStringLiteral("GreaterThanEqual")) { - return ProfileConditionTypeClass::GreaterThanEqual; - } - if (str == QStringLiteral("EqualsAny")) { - return ProfileConditionTypeClass::EqualsAny; - } - - return ProfileConditionTypeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/profileconditionvalue.h b/core/include/JellyfinQt/DTO/profileconditionvalue.h index c5bebdd..1bb4aae 100644 --- a/core/include/JellyfinQt/DTO/profileconditionvalue.h +++ b/core/include/JellyfinQt/DTO/profileconditionvalue.h @@ -75,91 +75,6 @@ private: typedef ProfileConditionValueClass::Value ProfileConditionValue; -} // NS DTO - -namespace Support { - -using ProfileConditionValue = Jellyfin::DTO::ProfileConditionValue; -using ProfileConditionValueClass = Jellyfin::DTO::ProfileConditionValueClass; - -template <> -ProfileConditionValue fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return ProfileConditionValueClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("AudioChannels")) { - return ProfileConditionValueClass::AudioChannels; - } - if (str == QStringLiteral("AudioBitrate")) { - return ProfileConditionValueClass::AudioBitrate; - } - if (str == QStringLiteral("AudioProfile")) { - return ProfileConditionValueClass::AudioProfile; - } - if (str == QStringLiteral("Width")) { - return ProfileConditionValueClass::Width; - } - if (str == QStringLiteral("Height")) { - return ProfileConditionValueClass::Height; - } - if (str == QStringLiteral("Has64BitOffsets")) { - return ProfileConditionValueClass::Has64BitOffsets; - } - if (str == QStringLiteral("PacketLength")) { - return ProfileConditionValueClass::PacketLength; - } - if (str == QStringLiteral("VideoBitDepth")) { - return ProfileConditionValueClass::VideoBitDepth; - } - if (str == QStringLiteral("VideoBitrate")) { - return ProfileConditionValueClass::VideoBitrate; - } - if (str == QStringLiteral("VideoFramerate")) { - return ProfileConditionValueClass::VideoFramerate; - } - if (str == QStringLiteral("VideoLevel")) { - return ProfileConditionValueClass::VideoLevel; - } - if (str == QStringLiteral("VideoProfile")) { - return ProfileConditionValueClass::VideoProfile; - } - if (str == QStringLiteral("VideoTimestamp")) { - return ProfileConditionValueClass::VideoTimestamp; - } - if (str == QStringLiteral("IsAnamorphic")) { - return ProfileConditionValueClass::IsAnamorphic; - } - if (str == QStringLiteral("RefFrames")) { - return ProfileConditionValueClass::RefFrames; - } - if (str == QStringLiteral("NumAudioStreams")) { - return ProfileConditionValueClass::NumAudioStreams; - } - if (str == QStringLiteral("NumVideoStreams")) { - return ProfileConditionValueClass::NumVideoStreams; - } - if (str == QStringLiteral("IsSecondaryAudio")) { - return ProfileConditionValueClass::IsSecondaryAudio; - } - if (str == QStringLiteral("VideoCodecTag")) { - return ProfileConditionValueClass::VideoCodecTag; - } - if (str == QStringLiteral("IsAvc")) { - return ProfileConditionValueClass::IsAvc; - } - if (str == QStringLiteral("IsInterlaced")) { - return ProfileConditionValueClass::IsInterlaced; - } - if (str == QStringLiteral("AudioSampleRate")) { - return ProfileConditionValueClass::AudioSampleRate; - } - if (str == QStringLiteral("AudioBitDepth")) { - return ProfileConditionValueClass::AudioBitDepth; - } - - return ProfileConditionValueClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/programaudio.h b/core/include/JellyfinQt/DTO/programaudio.h index f10f7d9..76c87a0 100644 --- a/core/include/JellyfinQt/DTO/programaudio.h +++ b/core/include/JellyfinQt/DTO/programaudio.h @@ -58,40 +58,6 @@ private: typedef ProgramAudioClass::Value ProgramAudio; -} // NS DTO - -namespace Support { - -using ProgramAudio = Jellyfin::DTO::ProgramAudio; -using ProgramAudioClass = Jellyfin::DTO::ProgramAudioClass; - -template <> -ProgramAudio fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return ProgramAudioClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Mono")) { - return ProgramAudioClass::Mono; - } - if (str == QStringLiteral("Stereo")) { - return ProgramAudioClass::Stereo; - } - if (str == QStringLiteral("Dolby")) { - return ProgramAudioClass::Dolby; - } - if (str == QStringLiteral("DolbyDigital")) { - return ProgramAudioClass::DolbyDigital; - } - if (str == QStringLiteral("Thx")) { - return ProgramAudioClass::Thx; - } - if (str == QStringLiteral("Atmos")) { - return ProgramAudioClass::Atmos; - } - - return ProgramAudioClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/publicsysteminfo.h b/core/include/JellyfinQt/DTO/publicsysteminfo.h index d2b7f1c..c75ae38 100644 --- a/core/include/JellyfinQt/DTO/publicsysteminfo.h +++ b/core/include/JellyfinQt/DTO/publicsysteminfo.h @@ -116,18 +116,6 @@ protected: bool m_startupWizardCompleted; }; -} // NS DTO - -namespace Support { - -using PublicSystemInfo = Jellyfin::DTO::PublicSystemInfo; - -template <> -PublicSystemInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return PublicSystemInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/queryfilters.h b/core/include/JellyfinQt/DTO/queryfilters.h index b00316d..24f1105 100644 --- a/core/include/JellyfinQt/DTO/queryfilters.h +++ b/core/include/JellyfinQt/DTO/queryfilters.h @@ -66,18 +66,6 @@ protected: QStringList m_tags; }; -} // NS DTO - -namespace Support { - -using QueryFilters = Jellyfin::DTO::QueryFilters; - -template <> -QueryFilters fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return QueryFilters::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/queryfilterslegacy.h b/core/include/JellyfinQt/DTO/queryfilterslegacy.h index 035d483..9903837 100644 --- a/core/include/JellyfinQt/DTO/queryfilterslegacy.h +++ b/core/include/JellyfinQt/DTO/queryfilterslegacy.h @@ -75,18 +75,6 @@ protected: QList m_years; }; -} // NS DTO - -namespace Support { - -using QueryFiltersLegacy = Jellyfin::DTO::QueryFiltersLegacy; - -template <> -QueryFiltersLegacy fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return QueryFiltersLegacy::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/queueitem.h b/core/include/JellyfinQt/DTO/queueitem.h index 6408c56..d98ef46 100644 --- a/core/include/JellyfinQt/DTO/queueitem.h +++ b/core/include/JellyfinQt/DTO/queueitem.h @@ -64,18 +64,6 @@ protected: QString m_playlistItemId; }; -} // NS DTO - -namespace Support { - -using QueueItem = Jellyfin::DTO::QueueItem; - -template <> -QueueItem fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return QueueItem::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/queuerequestdto.h b/core/include/JellyfinQt/DTO/queuerequestdto.h index 586b43c..7179ccd 100644 --- a/core/include/JellyfinQt/DTO/queuerequestdto.h +++ b/core/include/JellyfinQt/DTO/queuerequestdto.h @@ -70,18 +70,6 @@ protected: GroupQueueMode m_mode; }; -} // NS DTO - -namespace Support { - -using QueueRequestDto = Jellyfin::DTO::QueueRequestDto; - -template <> -QueueRequestDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return QueueRequestDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/quickconnectdto.h b/core/include/JellyfinQt/DTO/quickconnectdto.h index 121f05b..ddd1efc 100644 --- a/core/include/JellyfinQt/DTO/quickconnectdto.h +++ b/core/include/JellyfinQt/DTO/quickconnectdto.h @@ -62,18 +62,6 @@ protected: QString m_token; }; -} // NS DTO - -namespace Support { - -using QuickConnectDto = Jellyfin::DTO::QuickConnectDto; - -template <> -QuickConnectDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return QuickConnectDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/quickconnectresult.h b/core/include/JellyfinQt/DTO/quickconnectresult.h index 3fc2020..a27b25c 100644 --- a/core/include/JellyfinQt/DTO/quickconnectresult.h +++ b/core/include/JellyfinQt/DTO/quickconnectresult.h @@ -108,18 +108,6 @@ protected: QDateTime m_dateAdded; }; -} // NS DTO - -namespace Support { - -using QuickConnectResult = Jellyfin::DTO::QuickConnectResult; - -template <> -QuickConnectResult fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return QuickConnectResult::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/quickconnectstate.h b/core/include/JellyfinQt/DTO/quickconnectstate.h index 9d5e0f2..a267963 100644 --- a/core/include/JellyfinQt/DTO/quickconnectstate.h +++ b/core/include/JellyfinQt/DTO/quickconnectstate.h @@ -55,31 +55,6 @@ private: typedef QuickConnectStateClass::Value QuickConnectState; -} // NS DTO - -namespace Support { - -using QuickConnectState = Jellyfin::DTO::QuickConnectState; -using QuickConnectStateClass = Jellyfin::DTO::QuickConnectStateClass; - -template <> -QuickConnectState fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return QuickConnectStateClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Unavailable")) { - return QuickConnectStateClass::Unavailable; - } - if (str == QStringLiteral("Available")) { - return QuickConnectStateClass::Available; - } - if (str == QStringLiteral("Active")) { - return QuickConnectStateClass::Active; - } - - return QuickConnectStateClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/ratingtype.h b/core/include/JellyfinQt/DTO/ratingtype.h index 2a8271c..4ff43ee 100644 --- a/core/include/JellyfinQt/DTO/ratingtype.h +++ b/core/include/JellyfinQt/DTO/ratingtype.h @@ -54,28 +54,6 @@ private: typedef RatingTypeClass::Value RatingType; -} // NS DTO - -namespace Support { - -using RatingType = Jellyfin::DTO::RatingType; -using RatingTypeClass = Jellyfin::DTO::RatingTypeClass; - -template <> -RatingType fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return RatingTypeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Score")) { - return RatingTypeClass::Score; - } - if (str == QStringLiteral("Likes")) { - return RatingTypeClass::Likes; - } - - return RatingTypeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/readyrequestdto.h b/core/include/JellyfinQt/DTO/readyrequestdto.h index 221bdb9..d51ebd5 100644 --- a/core/include/JellyfinQt/DTO/readyrequestdto.h +++ b/core/include/JellyfinQt/DTO/readyrequestdto.h @@ -90,18 +90,6 @@ protected: QUuid m_playlistItemId; }; -} // NS DTO - -namespace Support { - -using ReadyRequestDto = Jellyfin::DTO::ReadyRequestDto; - -template <> -ReadyRequestDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ReadyRequestDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/recommendationdto.h b/core/include/JellyfinQt/DTO/recommendationdto.h index a220850..0c91267 100644 --- a/core/include/JellyfinQt/DTO/recommendationdto.h +++ b/core/include/JellyfinQt/DTO/recommendationdto.h @@ -79,18 +79,6 @@ protected: QUuid m_categoryId; }; -} // NS DTO - -namespace Support { - -using RecommendationDto = Jellyfin::DTO::RecommendationDto; - -template <> -RecommendationDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return RecommendationDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/recommendationtype.h b/core/include/JellyfinQt/DTO/recommendationtype.h index 2a99823..e3f885a 100644 --- a/core/include/JellyfinQt/DTO/recommendationtype.h +++ b/core/include/JellyfinQt/DTO/recommendationtype.h @@ -58,40 +58,6 @@ private: typedef RecommendationTypeClass::Value RecommendationType; -} // NS DTO - -namespace Support { - -using RecommendationType = Jellyfin::DTO::RecommendationType; -using RecommendationTypeClass = Jellyfin::DTO::RecommendationTypeClass; - -template <> -RecommendationType fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return RecommendationTypeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("SimilarToRecentlyPlayed")) { - return RecommendationTypeClass::SimilarToRecentlyPlayed; - } - if (str == QStringLiteral("SimilarToLikedItem")) { - return RecommendationTypeClass::SimilarToLikedItem; - } - if (str == QStringLiteral("HasDirectorFromRecentlyPlayed")) { - return RecommendationTypeClass::HasDirectorFromRecentlyPlayed; - } - if (str == QStringLiteral("HasActorFromRecentlyPlayed")) { - return RecommendationTypeClass::HasActorFromRecentlyPlayed; - } - if (str == QStringLiteral("HasLikedDirector")) { - return RecommendationTypeClass::HasLikedDirector; - } - if (str == QStringLiteral("HasLikedActor")) { - return RecommendationTypeClass::HasLikedActor; - } - - return RecommendationTypeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/recordingstatus.h b/core/include/JellyfinQt/DTO/recordingstatus.h index 1b4bdfa..3d12b39 100644 --- a/core/include/JellyfinQt/DTO/recordingstatus.h +++ b/core/include/JellyfinQt/DTO/recordingstatus.h @@ -59,43 +59,6 @@ private: typedef RecordingStatusClass::Value RecordingStatus; -} // NS DTO - -namespace Support { - -using RecordingStatus = Jellyfin::DTO::RecordingStatus; -using RecordingStatusClass = Jellyfin::DTO::RecordingStatusClass; - -template <> -RecordingStatus fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return RecordingStatusClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("New")) { - return RecordingStatusClass::New; - } - if (str == QStringLiteral("InProgress")) { - return RecordingStatusClass::InProgress; - } - if (str == QStringLiteral("Completed")) { - return RecordingStatusClass::Completed; - } - if (str == QStringLiteral("Cancelled")) { - return RecordingStatusClass::Cancelled; - } - if (str == QStringLiteral("ConflictedOk")) { - return RecordingStatusClass::ConflictedOk; - } - if (str == QStringLiteral("ConflictedNotOk")) { - return RecordingStatusClass::ConflictedNotOk; - } - if (str == QStringLiteral("Error")) { - return RecordingStatusClass::Error; - } - - return RecordingStatusClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/remoteimageinfo.h b/core/include/JellyfinQt/DTO/remoteimageinfo.h index 8228f56..3fcaba3 100644 --- a/core/include/JellyfinQt/DTO/remoteimageinfo.h +++ b/core/include/JellyfinQt/DTO/remoteimageinfo.h @@ -137,18 +137,6 @@ protected: RatingType m_ratingType; }; -} // NS DTO - -namespace Support { - -using RemoteImageInfo = Jellyfin::DTO::RemoteImageInfo; - -template <> -RemoteImageInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return RemoteImageInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/remoteimageresult.h b/core/include/JellyfinQt/DTO/remoteimageresult.h index 6e82885..5b784ed 100644 --- a/core/include/JellyfinQt/DTO/remoteimageresult.h +++ b/core/include/JellyfinQt/DTO/remoteimageresult.h @@ -83,18 +83,6 @@ protected: QStringList m_providers; }; -} // NS DTO - -namespace Support { - -using RemoteImageResult = Jellyfin::DTO::RemoteImageResult; - -template <> -RemoteImageResult fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return RemoteImageResult::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/remotesearchresult.h b/core/include/JellyfinQt/DTO/remotesearchresult.h index 55ee7fd..ce37f88 100644 --- a/core/include/JellyfinQt/DTO/remotesearchresult.h +++ b/core/include/JellyfinQt/DTO/remotesearchresult.h @@ -129,18 +129,6 @@ protected: QList> m_artists; }; -} // NS DTO - -namespace Support { - -using RemoteSearchResult = Jellyfin::DTO::RemoteSearchResult; - -template <> -RemoteSearchResult fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return RemoteSearchResult::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/remotesubtitleinfo.h b/core/include/JellyfinQt/DTO/remotesubtitleinfo.h index cbee670..00ee857 100644 --- a/core/include/JellyfinQt/DTO/remotesubtitleinfo.h +++ b/core/include/JellyfinQt/DTO/remotesubtitleinfo.h @@ -109,18 +109,6 @@ protected: bool m_isHashMatch; }; -} // NS DTO - -namespace Support { - -using RemoteSubtitleInfo = Jellyfin::DTO::RemoteSubtitleInfo; - -template <> -RemoteSubtitleInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return RemoteSubtitleInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/removefromplaylistrequestdto.h b/core/include/JellyfinQt/DTO/removefromplaylistrequestdto.h index bcd668f..8562fc1 100644 --- a/core/include/JellyfinQt/DTO/removefromplaylistrequestdto.h +++ b/core/include/JellyfinQt/DTO/removefromplaylistrequestdto.h @@ -64,18 +64,6 @@ protected: QList m_playlistItemIds; }; -} // NS DTO - -namespace Support { - -using RemoveFromPlaylistRequestDto = Jellyfin::DTO::RemoveFromPlaylistRequestDto; - -template <> -RemoveFromPlaylistRequestDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return RemoveFromPlaylistRequestDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/repeatmode.h b/core/include/JellyfinQt/DTO/repeatmode.h index 099d1c7..477c330 100644 --- a/core/include/JellyfinQt/DTO/repeatmode.h +++ b/core/include/JellyfinQt/DTO/repeatmode.h @@ -55,31 +55,6 @@ private: typedef RepeatModeClass::Value RepeatMode; -} // NS DTO - -namespace Support { - -using RepeatMode = Jellyfin::DTO::RepeatMode; -using RepeatModeClass = Jellyfin::DTO::RepeatModeClass; - -template <> -RepeatMode fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return RepeatModeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("RepeatNone")) { - return RepeatModeClass::RepeatNone; - } - if (str == QStringLiteral("RepeatAll")) { - return RepeatModeClass::RepeatAll; - } - if (str == QStringLiteral("RepeatOne")) { - return RepeatModeClass::RepeatOne; - } - - return RepeatModeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/repositoryinfo.h b/core/include/JellyfinQt/DTO/repositoryinfo.h index ddceef2..37c6fed 100644 --- a/core/include/JellyfinQt/DTO/repositoryinfo.h +++ b/core/include/JellyfinQt/DTO/repositoryinfo.h @@ -80,18 +80,6 @@ protected: bool m_enabled; }; -} // NS DTO - -namespace Support { - -using RepositoryInfo = Jellyfin::DTO::RepositoryInfo; - -template <> -RepositoryInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return RepositoryInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/responseprofile.h b/core/include/JellyfinQt/DTO/responseprofile.h index 025bf33..381c60a 100644 --- a/core/include/JellyfinQt/DTO/responseprofile.h +++ b/core/include/JellyfinQt/DTO/responseprofile.h @@ -93,18 +93,6 @@ protected: QList> m_conditions; }; -} // NS DTO - -namespace Support { - -using ResponseProfile = Jellyfin::DTO::ResponseProfile; - -template <> -ResponseProfile fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ResponseProfile::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/scrolldirection.h b/core/include/JellyfinQt/DTO/scrolldirection.h index 1c90464..348a0fa 100644 --- a/core/include/JellyfinQt/DTO/scrolldirection.h +++ b/core/include/JellyfinQt/DTO/scrolldirection.h @@ -54,28 +54,6 @@ private: typedef ScrollDirectionClass::Value ScrollDirection; -} // NS DTO - -namespace Support { - -using ScrollDirection = Jellyfin::DTO::ScrollDirection; -using ScrollDirectionClass = Jellyfin::DTO::ScrollDirectionClass; - -template <> -ScrollDirection fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return ScrollDirectionClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Horizontal")) { - return ScrollDirectionClass::Horizontal; - } - if (str == QStringLiteral("Vertical")) { - return ScrollDirectionClass::Vertical; - } - - return ScrollDirectionClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/searchhint.h b/core/include/JellyfinQt/DTO/searchhint.h index 76e0ad4..1348b7e 100644 --- a/core/include/JellyfinQt/DTO/searchhint.h +++ b/core/include/JellyfinQt/DTO/searchhint.h @@ -294,18 +294,6 @@ protected: double m_primaryImageAspectRatio; }; -} // NS DTO - -namespace Support { - -using SearchHint = Jellyfin::DTO::SearchHint; - -template <> -SearchHint fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return SearchHint::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/searchhintresult.h b/core/include/JellyfinQt/DTO/searchhintresult.h index 74c9f05..be4a04e 100644 --- a/core/include/JellyfinQt/DTO/searchhintresult.h +++ b/core/include/JellyfinQt/DTO/searchhintresult.h @@ -74,18 +74,6 @@ protected: qint32 m_totalRecordCount; }; -} // NS DTO - -namespace Support { - -using SearchHintResult = Jellyfin::DTO::SearchHintResult; - -template <> -SearchHintResult fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return SearchHintResult::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/seekrequestdto.h b/core/include/JellyfinQt/DTO/seekrequestdto.h index 5739ee8..ab58156 100644 --- a/core/include/JellyfinQt/DTO/seekrequestdto.h +++ b/core/include/JellyfinQt/DTO/seekrequestdto.h @@ -61,18 +61,6 @@ protected: qint64 m_positionTicks; }; -} // NS DTO - -namespace Support { - -using SeekRequestDto = Jellyfin::DTO::SeekRequestDto; - -template <> -SeekRequestDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return SeekRequestDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/sendcommand.h b/core/include/JellyfinQt/DTO/sendcommand.h index 8d80a3d..4a37315 100644 --- a/core/include/JellyfinQt/DTO/sendcommand.h +++ b/core/include/JellyfinQt/DTO/sendcommand.h @@ -105,18 +105,6 @@ protected: QDateTime m_emittedAt; }; -} // NS DTO - -namespace Support { - -using SendCommand = Jellyfin::DTO::SendCommand; - -template <> -SendCommand fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return SendCommand::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/sendcommandtype.h b/core/include/JellyfinQt/DTO/sendcommandtype.h index 66e18f7..9641aee 100644 --- a/core/include/JellyfinQt/DTO/sendcommandtype.h +++ b/core/include/JellyfinQt/DTO/sendcommandtype.h @@ -56,34 +56,6 @@ private: typedef SendCommandTypeClass::Value SendCommandType; -} // NS DTO - -namespace Support { - -using SendCommandType = Jellyfin::DTO::SendCommandType; -using SendCommandTypeClass = Jellyfin::DTO::SendCommandTypeClass; - -template <> -SendCommandType fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return SendCommandTypeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Unpause")) { - return SendCommandTypeClass::Unpause; - } - if (str == QStringLiteral("Pause")) { - return SendCommandTypeClass::Pause; - } - if (str == QStringLiteral("Stop")) { - return SendCommandTypeClass::Stop; - } - if (str == QStringLiteral("Seek")) { - return SendCommandTypeClass::Seek; - } - - return SendCommandTypeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/seriesinfo.h b/core/include/JellyfinQt/DTO/seriesinfo.h index 3543aaf..812aa3e 100644 --- a/core/include/JellyfinQt/DTO/seriesinfo.h +++ b/core/include/JellyfinQt/DTO/seriesinfo.h @@ -128,18 +128,6 @@ protected: bool m_isAutomated; }; -} // NS DTO - -namespace Support { - -using SeriesInfo = Jellyfin::DTO::SeriesInfo; - -template <> -SeriesInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return SeriesInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/seriesinforemotesearchquery.h b/core/include/JellyfinQt/DTO/seriesinforemotesearchquery.h index e08cd6f..42cd1ad 100644 --- a/core/include/JellyfinQt/DTO/seriesinforemotesearchquery.h +++ b/core/include/JellyfinQt/DTO/seriesinforemotesearchquery.h @@ -84,18 +84,6 @@ protected: bool m_includeDisabledProviders; }; -} // NS DTO - -namespace Support { - -using SeriesInfoRemoteSearchQuery = Jellyfin::DTO::SeriesInfoRemoteSearchQuery; - -template <> -SeriesInfoRemoteSearchQuery fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return SeriesInfoRemoteSearchQuery::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/seriesstatus.h b/core/include/JellyfinQt/DTO/seriesstatus.h index 906353a..96393e8 100644 --- a/core/include/JellyfinQt/DTO/seriesstatus.h +++ b/core/include/JellyfinQt/DTO/seriesstatus.h @@ -54,28 +54,6 @@ private: typedef SeriesStatusClass::Value SeriesStatus; -} // NS DTO - -namespace Support { - -using SeriesStatus = Jellyfin::DTO::SeriesStatus; -using SeriesStatusClass = Jellyfin::DTO::SeriesStatusClass; - -template <> -SeriesStatus fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return SeriesStatusClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Continuing")) { - return SeriesStatusClass::Continuing; - } - if (str == QStringLiteral("Ended")) { - return SeriesStatusClass::Ended; - } - - return SeriesStatusClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/seriestimerinfodto.h b/core/include/JellyfinQt/DTO/seriestimerinfodto.h index 6f04be0..baca2f8 100644 --- a/core/include/JellyfinQt/DTO/seriestimerinfodto.h +++ b/core/include/JellyfinQt/DTO/seriestimerinfodto.h @@ -351,18 +351,6 @@ protected: QString m_parentPrimaryImageTag; }; -} // NS DTO - -namespace Support { - -using SeriesTimerInfoDto = Jellyfin::DTO::SeriesTimerInfoDto; - -template <> -SeriesTimerInfoDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return SeriesTimerInfoDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/seriestimerinfodtoqueryresult.h b/core/include/JellyfinQt/DTO/seriestimerinfodtoqueryresult.h index 26b8b7e..222a941 100644 --- a/core/include/JellyfinQt/DTO/seriestimerinfodtoqueryresult.h +++ b/core/include/JellyfinQt/DTO/seriestimerinfodtoqueryresult.h @@ -83,18 +83,6 @@ protected: qint32 m_startIndex; }; -} // NS DTO - -namespace Support { - -using SeriesTimerInfoDtoQueryResult = Jellyfin::DTO::SeriesTimerInfoDtoQueryResult; - -template <> -SeriesTimerInfoDtoQueryResult fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return SeriesTimerInfoDtoQueryResult::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/serverconfiguration.h b/core/include/JellyfinQt/DTO/serverconfiguration.h index 0ab3bf6..6920f20 100644 --- a/core/include/JellyfinQt/DTO/serverconfiguration.h +++ b/core/include/JellyfinQt/DTO/serverconfiguration.h @@ -745,18 +745,6 @@ protected: bool m_disablePluginImages; }; -} // NS DTO - -namespace Support { - -using ServerConfiguration = Jellyfin::DTO::ServerConfiguration; - -template <> -ServerConfiguration fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ServerConfiguration::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/sessioninfo.h b/core/include/JellyfinQt/DTO/sessioninfo.h index 5dafb4f..880281f 100644 --- a/core/include/JellyfinQt/DTO/sessioninfo.h +++ b/core/include/JellyfinQt/DTO/sessioninfo.h @@ -262,18 +262,6 @@ protected: QList m_supportedCommands; }; -} // NS DTO - -namespace Support { - -using SessionInfo = Jellyfin::DTO::SessionInfo; - -template <> -SessionInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return SessionInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/sessionuserinfo.h b/core/include/JellyfinQt/DTO/sessionuserinfo.h index 3c15bdc..6fd172f 100644 --- a/core/include/JellyfinQt/DTO/sessionuserinfo.h +++ b/core/include/JellyfinQt/DTO/sessionuserinfo.h @@ -72,18 +72,6 @@ protected: QString m_userName; }; -} // NS DTO - -namespace Support { - -using SessionUserInfo = Jellyfin::DTO::SessionUserInfo; - -template <> -SessionUserInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return SessionUserInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/setchannelmappingdto.h b/core/include/JellyfinQt/DTO/setchannelmappingdto.h index 52b1131..fddbbdc 100644 --- a/core/include/JellyfinQt/DTO/setchannelmappingdto.h +++ b/core/include/JellyfinQt/DTO/setchannelmappingdto.h @@ -80,18 +80,6 @@ protected: QString m_providerChannelId; }; -} // NS DTO - -namespace Support { - -using SetChannelMappingDto = Jellyfin::DTO::SetChannelMappingDto; - -template <> -SetChannelMappingDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return SetChannelMappingDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/setplaylistitemrequestdto.h b/core/include/JellyfinQt/DTO/setplaylistitemrequestdto.h index 8e3bd75..7162a05 100644 --- a/core/include/JellyfinQt/DTO/setplaylistitemrequestdto.h +++ b/core/include/JellyfinQt/DTO/setplaylistitemrequestdto.h @@ -62,18 +62,6 @@ protected: QUuid m_playlistItemId; }; -} // NS DTO - -namespace Support { - -using SetPlaylistItemRequestDto = Jellyfin::DTO::SetPlaylistItemRequestDto; - -template <> -SetPlaylistItemRequestDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return SetPlaylistItemRequestDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/setrepeatmoderequestdto.h b/core/include/JellyfinQt/DTO/setrepeatmoderequestdto.h index e2c03e6..ffcb72b 100644 --- a/core/include/JellyfinQt/DTO/setrepeatmoderequestdto.h +++ b/core/include/JellyfinQt/DTO/setrepeatmoderequestdto.h @@ -58,18 +58,6 @@ protected: GroupRepeatMode m_mode; }; -} // NS DTO - -namespace Support { - -using SetRepeatModeRequestDto = Jellyfin::DTO::SetRepeatModeRequestDto; - -template <> -SetRepeatModeRequestDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return SetRepeatModeRequestDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/setshufflemoderequestdto.h b/core/include/JellyfinQt/DTO/setshufflemoderequestdto.h index 20161af..1b1a664 100644 --- a/core/include/JellyfinQt/DTO/setshufflemoderequestdto.h +++ b/core/include/JellyfinQt/DTO/setshufflemoderequestdto.h @@ -58,18 +58,6 @@ protected: GroupShuffleMode m_mode; }; -} // NS DTO - -namespace Support { - -using SetShuffleModeRequestDto = Jellyfin::DTO::SetShuffleModeRequestDto; - -template <> -SetShuffleModeRequestDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return SetShuffleModeRequestDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/songinfo.h b/core/include/JellyfinQt/DTO/songinfo.h index 9a4bc58..81067f5 100644 --- a/core/include/JellyfinQt/DTO/songinfo.h +++ b/core/include/JellyfinQt/DTO/songinfo.h @@ -145,18 +145,6 @@ protected: QStringList m_artists; }; -} // NS DTO - -namespace Support { - -using SongInfo = Jellyfin::DTO::SongInfo; - -template <> -SongInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return SongInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/sortorder.h b/core/include/JellyfinQt/DTO/sortorder.h index 22d2ff1..653af3e 100644 --- a/core/include/JellyfinQt/DTO/sortorder.h +++ b/core/include/JellyfinQt/DTO/sortorder.h @@ -54,28 +54,6 @@ private: typedef SortOrderClass::Value SortOrder; -} // NS DTO - -namespace Support { - -using SortOrder = Jellyfin::DTO::SortOrder; -using SortOrderClass = Jellyfin::DTO::SortOrderClass; - -template <> -SortOrder fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return SortOrderClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Ascending")) { - return SortOrderClass::Ascending; - } - if (str == QStringLiteral("Descending")) { - return SortOrderClass::Descending; - } - - return SortOrderClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/specialviewoptiondto.h b/core/include/JellyfinQt/DTO/specialviewoptiondto.h index 7a9d921..c8183cd 100644 --- a/core/include/JellyfinQt/DTO/specialviewoptiondto.h +++ b/core/include/JellyfinQt/DTO/specialviewoptiondto.h @@ -71,18 +71,6 @@ protected: QString m_jellyfinId; }; -} // NS DTO - -namespace Support { - -using SpecialViewOptionDto = Jellyfin::DTO::SpecialViewOptionDto; - -template <> -SpecialViewOptionDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return SpecialViewOptionDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/startupconfigurationdto.h b/core/include/JellyfinQt/DTO/startupconfigurationdto.h index 9f3deb0..f6d0509 100644 --- a/core/include/JellyfinQt/DTO/startupconfigurationdto.h +++ b/core/include/JellyfinQt/DTO/startupconfigurationdto.h @@ -80,18 +80,6 @@ protected: QString m_preferredMetadataLanguage; }; -} // NS DTO - -namespace Support { - -using StartupConfigurationDto = Jellyfin::DTO::StartupConfigurationDto; - -template <> -StartupConfigurationDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return StartupConfigurationDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/startupremoteaccessdto.h b/core/include/JellyfinQt/DTO/startupremoteaccessdto.h index 04e3f96..a568484 100644 --- a/core/include/JellyfinQt/DTO/startupremoteaccessdto.h +++ b/core/include/JellyfinQt/DTO/startupremoteaccessdto.h @@ -70,18 +70,6 @@ protected: bool m_enableAutomaticPortMapping; }; -} // NS DTO - -namespace Support { - -using StartupRemoteAccessDto = Jellyfin::DTO::StartupRemoteAccessDto; - -template <> -StartupRemoteAccessDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return StartupRemoteAccessDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/startupuserdto.h b/core/include/JellyfinQt/DTO/startupuserdto.h index fe52704..13ea286 100644 --- a/core/include/JellyfinQt/DTO/startupuserdto.h +++ b/core/include/JellyfinQt/DTO/startupuserdto.h @@ -71,18 +71,6 @@ protected: QString m_password; }; -} // NS DTO - -namespace Support { - -using StartupUserDto = Jellyfin::DTO::StartupUserDto; - -template <> -StartupUserDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return StartupUserDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/subtitledeliverymethod.h b/core/include/JellyfinQt/DTO/subtitledeliverymethod.h index 7a6c9c3..79a04c3 100644 --- a/core/include/JellyfinQt/DTO/subtitledeliverymethod.h +++ b/core/include/JellyfinQt/DTO/subtitledeliverymethod.h @@ -56,34 +56,6 @@ private: typedef SubtitleDeliveryMethodClass::Value SubtitleDeliveryMethod; -} // NS DTO - -namespace Support { - -using SubtitleDeliveryMethod = Jellyfin::DTO::SubtitleDeliveryMethod; -using SubtitleDeliveryMethodClass = Jellyfin::DTO::SubtitleDeliveryMethodClass; - -template <> -SubtitleDeliveryMethod fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return SubtitleDeliveryMethodClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Encode")) { - return SubtitleDeliveryMethodClass::Encode; - } - if (str == QStringLiteral("Embed")) { - return SubtitleDeliveryMethodClass::Embed; - } - if (str == QStringLiteral("External")) { - return SubtitleDeliveryMethodClass::External; - } - if (str == QStringLiteral("Hls")) { - return SubtitleDeliveryMethodClass::Hls; - } - - return SubtitleDeliveryMethodClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/subtitleplaybackmode.h b/core/include/JellyfinQt/DTO/subtitleplaybackmode.h index 217efe9..0fba0a3 100644 --- a/core/include/JellyfinQt/DTO/subtitleplaybackmode.h +++ b/core/include/JellyfinQt/DTO/subtitleplaybackmode.h @@ -57,37 +57,6 @@ private: typedef SubtitlePlaybackModeClass::Value SubtitlePlaybackMode; -} // NS DTO - -namespace Support { - -using SubtitlePlaybackMode = Jellyfin::DTO::SubtitlePlaybackMode; -using SubtitlePlaybackModeClass = Jellyfin::DTO::SubtitlePlaybackModeClass; - -template <> -SubtitlePlaybackMode fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return SubtitlePlaybackModeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Default")) { - return SubtitlePlaybackModeClass::Default; - } - if (str == QStringLiteral("Always")) { - return SubtitlePlaybackModeClass::Always; - } - if (str == QStringLiteral("OnlyForced")) { - return SubtitlePlaybackModeClass::OnlyForced; - } - if (str == QStringLiteral("None")) { - return SubtitlePlaybackModeClass::None; - } - if (str == QStringLiteral("Smart")) { - return SubtitlePlaybackModeClass::Smart; - } - - return SubtitlePlaybackModeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/subtitleprofile.h b/core/include/JellyfinQt/DTO/subtitleprofile.h index 41c88c1..eecda65 100644 --- a/core/include/JellyfinQt/DTO/subtitleprofile.h +++ b/core/include/JellyfinQt/DTO/subtitleprofile.h @@ -79,18 +79,6 @@ protected: QString m_container; }; -} // NS DTO - -namespace Support { - -using SubtitleProfile = Jellyfin::DTO::SubtitleProfile; - -template <> -SubtitleProfile fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return SubtitleProfile::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/syncplayuseraccesstype.h b/core/include/JellyfinQt/DTO/syncplayuseraccesstype.h index 2838534..db2a627 100644 --- a/core/include/JellyfinQt/DTO/syncplayuseraccesstype.h +++ b/core/include/JellyfinQt/DTO/syncplayuseraccesstype.h @@ -55,31 +55,6 @@ private: typedef SyncPlayUserAccessTypeClass::Value SyncPlayUserAccessType; -} // NS DTO - -namespace Support { - -using SyncPlayUserAccessType = Jellyfin::DTO::SyncPlayUserAccessType; -using SyncPlayUserAccessTypeClass = Jellyfin::DTO::SyncPlayUserAccessTypeClass; - -template <> -SyncPlayUserAccessType fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return SyncPlayUserAccessTypeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("CreateAndJoinGroups")) { - return SyncPlayUserAccessTypeClass::CreateAndJoinGroups; - } - if (str == QStringLiteral("JoinGroups")) { - return SyncPlayUserAccessTypeClass::JoinGroups; - } - if (str == QStringLiteral("None")) { - return SyncPlayUserAccessTypeClass::None; - } - - return SyncPlayUserAccessTypeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/systeminfo.h b/core/include/JellyfinQt/DTO/systeminfo.h index a8a9762..2c079eb 100644 --- a/core/include/JellyfinQt/DTO/systeminfo.h +++ b/core/include/JellyfinQt/DTO/systeminfo.h @@ -277,18 +277,6 @@ protected: Architecture m_systemArchitecture; }; -} // NS DTO - -namespace Support { - -using SystemInfo = Jellyfin::DTO::SystemInfo; - -template <> -SystemInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return SystemInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/taskcompletionstatus.h b/core/include/JellyfinQt/DTO/taskcompletionstatus.h index b4ce2b3..0fe95c4 100644 --- a/core/include/JellyfinQt/DTO/taskcompletionstatus.h +++ b/core/include/JellyfinQt/DTO/taskcompletionstatus.h @@ -56,34 +56,6 @@ private: typedef TaskCompletionStatusClass::Value TaskCompletionStatus; -} // NS DTO - -namespace Support { - -using TaskCompletionStatus = Jellyfin::DTO::TaskCompletionStatus; -using TaskCompletionStatusClass = Jellyfin::DTO::TaskCompletionStatusClass; - -template <> -TaskCompletionStatus fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return TaskCompletionStatusClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Completed")) { - return TaskCompletionStatusClass::Completed; - } - if (str == QStringLiteral("Failed")) { - return TaskCompletionStatusClass::Failed; - } - if (str == QStringLiteral("Cancelled")) { - return TaskCompletionStatusClass::Cancelled; - } - if (str == QStringLiteral("Aborted")) { - return TaskCompletionStatusClass::Aborted; - } - - return TaskCompletionStatusClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/taskinfo.h b/core/include/JellyfinQt/DTO/taskinfo.h index 48ff19f..c4a0be8 100644 --- a/core/include/JellyfinQt/DTO/taskinfo.h +++ b/core/include/JellyfinQt/DTO/taskinfo.h @@ -141,18 +141,6 @@ protected: QString m_key; }; -} // NS DTO - -namespace Support { - -using TaskInfo = Jellyfin::DTO::TaskInfo; - -template <> -TaskInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return TaskInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/taskresult.h b/core/include/JellyfinQt/DTO/taskresult.h index 0480714..65c207c 100644 --- a/core/include/JellyfinQt/DTO/taskresult.h +++ b/core/include/JellyfinQt/DTO/taskresult.h @@ -123,18 +123,6 @@ protected: QString m_longErrorMessage; }; -} // NS DTO - -namespace Support { - -using TaskResult = Jellyfin::DTO::TaskResult; - -template <> -TaskResult fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return TaskResult::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/taskstate.h b/core/include/JellyfinQt/DTO/taskstate.h index 7ed6873..25aeaf0 100644 --- a/core/include/JellyfinQt/DTO/taskstate.h +++ b/core/include/JellyfinQt/DTO/taskstate.h @@ -55,31 +55,6 @@ private: typedef TaskStateClass::Value TaskState; -} // NS DTO - -namespace Support { - -using TaskState = Jellyfin::DTO::TaskState; -using TaskStateClass = Jellyfin::DTO::TaskStateClass; - -template <> -TaskState fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return TaskStateClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Idle")) { - return TaskStateClass::Idle; - } - if (str == QStringLiteral("Cancelling")) { - return TaskStateClass::Cancelling; - } - if (str == QStringLiteral("Running")) { - return TaskStateClass::Running; - } - - return TaskStateClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/tasktriggerinfo.h b/core/include/JellyfinQt/DTO/tasktriggerinfo.h index fe8e854..02b42aa 100644 --- a/core/include/JellyfinQt/DTO/tasktriggerinfo.h +++ b/core/include/JellyfinQt/DTO/tasktriggerinfo.h @@ -95,18 +95,6 @@ protected: qint64 m_maxRuntimeTicks; }; -} // NS DTO - -namespace Support { - -using TaskTriggerInfo = Jellyfin::DTO::TaskTriggerInfo; - -template <> -TaskTriggerInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return TaskTriggerInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/thememediaresult.h b/core/include/JellyfinQt/DTO/thememediaresult.h index feac230..a80ef95 100644 --- a/core/include/JellyfinQt/DTO/thememediaresult.h +++ b/core/include/JellyfinQt/DTO/thememediaresult.h @@ -93,18 +93,6 @@ protected: QUuid m_ownerId; }; -} // NS DTO - -namespace Support { - -using ThemeMediaResult = Jellyfin::DTO::ThemeMediaResult; - -template <> -ThemeMediaResult fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ThemeMediaResult::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/timereventinfo.h b/core/include/JellyfinQt/DTO/timereventinfo.h index 1bf3774..5838c85 100644 --- a/core/include/JellyfinQt/DTO/timereventinfo.h +++ b/core/include/JellyfinQt/DTO/timereventinfo.h @@ -64,18 +64,6 @@ protected: QUuid m_programId; }; -} // NS DTO - -namespace Support { - -using TimerEventInfo = Jellyfin::DTO::TimerEventInfo; - -template <> -TimerEventInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return TimerEventInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/timerinfodto.h b/core/include/JellyfinQt/DTO/timerinfodto.h index c3abd8b..b6ed51c 100644 --- a/core/include/JellyfinQt/DTO/timerinfodto.h +++ b/core/include/JellyfinQt/DTO/timerinfodto.h @@ -293,18 +293,6 @@ protected: QSharedPointer m_programInfo = nullptr; }; -} // NS DTO - -namespace Support { - -using TimerInfoDto = Jellyfin::DTO::TimerInfoDto; - -template <> -TimerInfoDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return TimerInfoDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/timerinfodtoqueryresult.h b/core/include/JellyfinQt/DTO/timerinfodtoqueryresult.h index 090ac0b..7d0e89d 100644 --- a/core/include/JellyfinQt/DTO/timerinfodtoqueryresult.h +++ b/core/include/JellyfinQt/DTO/timerinfodtoqueryresult.h @@ -83,18 +83,6 @@ protected: qint32 m_startIndex; }; -} // NS DTO - -namespace Support { - -using TimerInfoDtoQueryResult = Jellyfin::DTO::TimerInfoDtoQueryResult; - -template <> -TimerInfoDtoQueryResult fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return TimerInfoDtoQueryResult::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/trailerinfo.h b/core/include/JellyfinQt/DTO/trailerinfo.h index 6334a4f..690d2ab 100644 --- a/core/include/JellyfinQt/DTO/trailerinfo.h +++ b/core/include/JellyfinQt/DTO/trailerinfo.h @@ -128,18 +128,6 @@ protected: bool m_isAutomated; }; -} // NS DTO - -namespace Support { - -using TrailerInfo = Jellyfin::DTO::TrailerInfo; - -template <> -TrailerInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return TrailerInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/trailerinforemotesearchquery.h b/core/include/JellyfinQt/DTO/trailerinforemotesearchquery.h index 913a59a..f4c9d53 100644 --- a/core/include/JellyfinQt/DTO/trailerinforemotesearchquery.h +++ b/core/include/JellyfinQt/DTO/trailerinforemotesearchquery.h @@ -84,18 +84,6 @@ protected: bool m_includeDisabledProviders; }; -} // NS DTO - -namespace Support { - -using TrailerInfoRemoteSearchQuery = Jellyfin::DTO::TrailerInfoRemoteSearchQuery; - -template <> -TrailerInfoRemoteSearchQuery fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return TrailerInfoRemoteSearchQuery::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/transcodereason.h b/core/include/JellyfinQt/DTO/transcodereason.h index 218aa68..fae6760 100644 --- a/core/include/JellyfinQt/DTO/transcodereason.h +++ b/core/include/JellyfinQt/DTO/transcodereason.h @@ -75,91 +75,6 @@ private: typedef TranscodeReasonClass::Value TranscodeReason; -} // NS DTO - -namespace Support { - -using TranscodeReason = Jellyfin::DTO::TranscodeReason; -using TranscodeReasonClass = Jellyfin::DTO::TranscodeReasonClass; - -template <> -TranscodeReason fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return TranscodeReasonClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("ContainerNotSupported")) { - return TranscodeReasonClass::ContainerNotSupported; - } - if (str == QStringLiteral("VideoCodecNotSupported")) { - return TranscodeReasonClass::VideoCodecNotSupported; - } - if (str == QStringLiteral("AudioCodecNotSupported")) { - return TranscodeReasonClass::AudioCodecNotSupported; - } - if (str == QStringLiteral("ContainerBitrateExceedsLimit")) { - return TranscodeReasonClass::ContainerBitrateExceedsLimit; - } - if (str == QStringLiteral("AudioBitrateNotSupported")) { - return TranscodeReasonClass::AudioBitrateNotSupported; - } - if (str == QStringLiteral("AudioChannelsNotSupported")) { - return TranscodeReasonClass::AudioChannelsNotSupported; - } - if (str == QStringLiteral("VideoResolutionNotSupported")) { - return TranscodeReasonClass::VideoResolutionNotSupported; - } - if (str == QStringLiteral("UnknownVideoStreamInfo")) { - return TranscodeReasonClass::UnknownVideoStreamInfo; - } - if (str == QStringLiteral("UnknownAudioStreamInfo")) { - return TranscodeReasonClass::UnknownAudioStreamInfo; - } - if (str == QStringLiteral("AudioProfileNotSupported")) { - return TranscodeReasonClass::AudioProfileNotSupported; - } - if (str == QStringLiteral("AudioSampleRateNotSupported")) { - return TranscodeReasonClass::AudioSampleRateNotSupported; - } - if (str == QStringLiteral("AnamorphicVideoNotSupported")) { - return TranscodeReasonClass::AnamorphicVideoNotSupported; - } - if (str == QStringLiteral("InterlacedVideoNotSupported")) { - return TranscodeReasonClass::InterlacedVideoNotSupported; - } - if (str == QStringLiteral("SecondaryAudioNotSupported")) { - return TranscodeReasonClass::SecondaryAudioNotSupported; - } - if (str == QStringLiteral("RefFramesNotSupported")) { - return TranscodeReasonClass::RefFramesNotSupported; - } - if (str == QStringLiteral("VideoBitDepthNotSupported")) { - return TranscodeReasonClass::VideoBitDepthNotSupported; - } - if (str == QStringLiteral("VideoBitrateNotSupported")) { - return TranscodeReasonClass::VideoBitrateNotSupported; - } - if (str == QStringLiteral("VideoFramerateNotSupported")) { - return TranscodeReasonClass::VideoFramerateNotSupported; - } - if (str == QStringLiteral("VideoLevelNotSupported")) { - return TranscodeReasonClass::VideoLevelNotSupported; - } - if (str == QStringLiteral("VideoProfileNotSupported")) { - return TranscodeReasonClass::VideoProfileNotSupported; - } - if (str == QStringLiteral("AudioBitDepthNotSupported")) { - return TranscodeReasonClass::AudioBitDepthNotSupported; - } - if (str == QStringLiteral("SubtitleCodecNotSupported")) { - return TranscodeReasonClass::SubtitleCodecNotSupported; - } - if (str == QStringLiteral("DirectPlayError")) { - return TranscodeReasonClass::DirectPlayError; - } - - return TranscodeReasonClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/transcodeseekinfo.h b/core/include/JellyfinQt/DTO/transcodeseekinfo.h index 6239b8e..9de3964 100644 --- a/core/include/JellyfinQt/DTO/transcodeseekinfo.h +++ b/core/include/JellyfinQt/DTO/transcodeseekinfo.h @@ -54,28 +54,6 @@ private: typedef TranscodeSeekInfoClass::Value TranscodeSeekInfo; -} // NS DTO - -namespace Support { - -using TranscodeSeekInfo = Jellyfin::DTO::TranscodeSeekInfo; -using TranscodeSeekInfoClass = Jellyfin::DTO::TranscodeSeekInfoClass; - -template <> -TranscodeSeekInfo fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return TranscodeSeekInfoClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Auto")) { - return TranscodeSeekInfoClass::Auto; - } - if (str == QStringLiteral("Bytes")) { - return TranscodeSeekInfoClass::Bytes; - } - - return TranscodeSeekInfoClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/transcodinginfo.h b/core/include/JellyfinQt/DTO/transcodinginfo.h index 9ad26c1..cbb5362 100644 --- a/core/include/JellyfinQt/DTO/transcodinginfo.h +++ b/core/include/JellyfinQt/DTO/transcodinginfo.h @@ -116,18 +116,6 @@ protected: QList m_transcodeReasons; }; -} // NS DTO - -namespace Support { - -using TranscodingInfo = Jellyfin::DTO::TranscodingInfo; - -template <> -TranscodingInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return TranscodingInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/transcodingprofile.h b/core/include/JellyfinQt/DTO/transcodingprofile.h index 852fe89..97bfcd0 100644 --- a/core/include/JellyfinQt/DTO/transcodingprofile.h +++ b/core/include/JellyfinQt/DTO/transcodingprofile.h @@ -131,18 +131,6 @@ protected: bool m_breakOnNonKeyFrames; }; -} // NS DTO - -namespace Support { - -using TranscodingProfile = Jellyfin::DTO::TranscodingProfile; - -template <> -TranscodingProfile fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return TranscodingProfile::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/transportstreamtimestamp.h b/core/include/JellyfinQt/DTO/transportstreamtimestamp.h index fd2e7fc..c521a9f 100644 --- a/core/include/JellyfinQt/DTO/transportstreamtimestamp.h +++ b/core/include/JellyfinQt/DTO/transportstreamtimestamp.h @@ -55,31 +55,6 @@ private: typedef TransportStreamTimestampClass::Value TransportStreamTimestamp; -} // NS DTO - -namespace Support { - -using TransportStreamTimestamp = Jellyfin::DTO::TransportStreamTimestamp; -using TransportStreamTimestampClass = Jellyfin::DTO::TransportStreamTimestampClass; - -template <> -TransportStreamTimestamp fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return TransportStreamTimestampClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("None")) { - return TransportStreamTimestampClass::None; - } - if (str == QStringLiteral("Zero")) { - return TransportStreamTimestampClass::Zero; - } - if (str == QStringLiteral("Valid")) { - return TransportStreamTimestampClass::Valid; - } - - return TransportStreamTimestampClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/tunerchannelmapping.h b/core/include/JellyfinQt/DTO/tunerchannelmapping.h index 83ce6eb..cd23947 100644 --- a/core/include/JellyfinQt/DTO/tunerchannelmapping.h +++ b/core/include/JellyfinQt/DTO/tunerchannelmapping.h @@ -73,18 +73,6 @@ protected: QString m_jellyfinId; }; -} // NS DTO - -namespace Support { - -using TunerChannelMapping = Jellyfin::DTO::TunerChannelMapping; - -template <> -TunerChannelMapping fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return TunerChannelMapping::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/tunerhostinfo.h b/core/include/JellyfinQt/DTO/tunerhostinfo.h index e09aab3..edcd3bb 100644 --- a/core/include/JellyfinQt/DTO/tunerhostinfo.h +++ b/core/include/JellyfinQt/DTO/tunerhostinfo.h @@ -108,18 +108,6 @@ protected: QString m_userAgent; }; -} // NS DTO - -namespace Support { - -using TunerHostInfo = Jellyfin::DTO::TunerHostInfo; - -template <> -TunerHostInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return TunerHostInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/typeoptions.h b/core/include/JellyfinQt/DTO/typeoptions.h index 843bb0c..8967508 100644 --- a/core/include/JellyfinQt/DTO/typeoptions.h +++ b/core/include/JellyfinQt/DTO/typeoptions.h @@ -87,18 +87,6 @@ protected: QList> m_imageOptions; }; -} // NS DTO - -namespace Support { - -using TypeOptions = Jellyfin::DTO::TypeOptions; - -template <> -TypeOptions fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return TypeOptions::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/unrateditem.h b/core/include/JellyfinQt/DTO/unrateditem.h index 0b61b67..9bed85d 100644 --- a/core/include/JellyfinQt/DTO/unrateditem.h +++ b/core/include/JellyfinQt/DTO/unrateditem.h @@ -61,49 +61,6 @@ private: typedef UnratedItemClass::Value UnratedItem; -} // NS DTO - -namespace Support { - -using UnratedItem = Jellyfin::DTO::UnratedItem; -using UnratedItemClass = Jellyfin::DTO::UnratedItemClass; - -template <> -UnratedItem fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return UnratedItemClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("Movie")) { - return UnratedItemClass::Movie; - } - if (str == QStringLiteral("Trailer")) { - return UnratedItemClass::Trailer; - } - if (str == QStringLiteral("Series")) { - return UnratedItemClass::Series; - } - if (str == QStringLiteral("Music")) { - return UnratedItemClass::Music; - } - if (str == QStringLiteral("Book")) { - return UnratedItemClass::Book; - } - if (str == QStringLiteral("LiveTvChannel")) { - return UnratedItemClass::LiveTvChannel; - } - if (str == QStringLiteral("LiveTvProgram")) { - return UnratedItemClass::LiveTvProgram; - } - if (str == QStringLiteral("ChannelContent")) { - return UnratedItemClass::ChannelContent; - } - if (str == QStringLiteral("Other")) { - return UnratedItemClass::Other; - } - - return UnratedItemClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/updatelibraryoptionsdto.h b/core/include/JellyfinQt/DTO/updatelibraryoptionsdto.h index 751dfc6..97126ee 100644 --- a/core/include/JellyfinQt/DTO/updatelibraryoptionsdto.h +++ b/core/include/JellyfinQt/DTO/updatelibraryoptionsdto.h @@ -69,18 +69,6 @@ protected: QSharedPointer m_libraryOptions = nullptr; }; -} // NS DTO - -namespace Support { - -using UpdateLibraryOptionsDto = Jellyfin::DTO::UpdateLibraryOptionsDto; - -template <> -UpdateLibraryOptionsDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return UpdateLibraryOptionsDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/updateusereasypassword.h b/core/include/JellyfinQt/DTO/updateusereasypassword.h index 3d60e04..f944ea7 100644 --- a/core/include/JellyfinQt/DTO/updateusereasypassword.h +++ b/core/include/JellyfinQt/DTO/updateusereasypassword.h @@ -80,18 +80,6 @@ protected: bool m_resetPassword; }; -} // NS DTO - -namespace Support { - -using UpdateUserEasyPassword = Jellyfin::DTO::UpdateUserEasyPassword; - -template <> -UpdateUserEasyPassword fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return UpdateUserEasyPassword::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/updateuserpassword.h b/core/include/JellyfinQt/DTO/updateuserpassword.h index 2ebaddb..37920c0 100644 --- a/core/include/JellyfinQt/DTO/updateuserpassword.h +++ b/core/include/JellyfinQt/DTO/updateuserpassword.h @@ -89,18 +89,6 @@ protected: bool m_resetPassword; }; -} // NS DTO - -namespace Support { - -using UpdateUserPassword = Jellyfin::DTO::UpdateUserPassword; - -template <> -UpdateUserPassword fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return UpdateUserPassword::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/uploadsubtitledto.h b/core/include/JellyfinQt/DTO/uploadsubtitledto.h index de3bcab..7d61467 100644 --- a/core/include/JellyfinQt/DTO/uploadsubtitledto.h +++ b/core/include/JellyfinQt/DTO/uploadsubtitledto.h @@ -89,18 +89,6 @@ protected: QString m_data; }; -} // NS DTO - -namespace Support { - -using UploadSubtitleDto = Jellyfin::DTO::UploadSubtitleDto; - -template <> -UploadSubtitleDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return UploadSubtitleDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/user.h b/core/include/JellyfinQt/DTO/user.h deleted file mode 100644 index db2ae29..0000000 --- a/core/include/JellyfinQt/DTO/user.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Sailfin: a Jellyfin client written using Qt - * Copyright (C) 2021 Chris Josten and the Sailfin Contributors. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -/* - * WARNING: THIS IS AN AUTOMATICALLY GENERATED FILE! PLEASE DO NOT EDIT THIS, AS YOUR EDITS WILL GET - * OVERWRITTEN AT SOME POINT! - * - * If there is a bug in this file, please fix the code generator used to generate this file found in - * core/openapigenerator.d. - * - * This file is generated based on Jellyfin's OpenAPI description, "openapi.json". Please update that - * file with a newer file if needed instead of manually updating the files. - */ - -#ifndef JELLYFIN_DTO_USER_H -#define JELLYFIN_DTO_USER_H - -#include "JellyfinQt/UserDto" - -namespace Jellyfin { -namespace DTO { - -using User = UserDto; - -} // NS Jellyfin -} // NS DTO - -#endif // JELLYFIN_DTO_USER_H diff --git a/core/include/JellyfinQt/DTO/userconfiguration.h b/core/include/JellyfinQt/DTO/userconfiguration.h index ad76d2f..b87bfa9 100644 --- a/core/include/JellyfinQt/DTO/userconfiguration.h +++ b/core/include/JellyfinQt/DTO/userconfiguration.h @@ -143,18 +143,6 @@ protected: bool m_enableNextEpisodeAutoPlay; }; -} // NS DTO - -namespace Support { - -using UserConfiguration = Jellyfin::DTO::UserConfiguration; - -template <> -UserConfiguration fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return UserConfiguration::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/userdata.h b/core/include/JellyfinQt/DTO/userdata.h deleted file mode 100644 index 5a7ded4..0000000 --- a/core/include/JellyfinQt/DTO/userdata.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Sailfin: a Jellyfin client written using Qt - * Copyright (C) 2021 Chris Josten and the Sailfin Contributors. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -/* - * WARNING: THIS IS AN AUTOMATICALLY GENERATED FILE! PLEASE DO NOT EDIT THIS, AS YOUR EDITS WILL GET - * OVERWRITTEN AT SOME POINT! - * - * If there is a bug in this file, please fix the code generator used to generate this file found in - * core/openapigenerator.d. - * - * This file is generated based on Jellyfin's OpenAPI description, "openapi.json". Please update that - * file with a newer file if needed instead of manually updating the files. - */ - -#ifndef JELLYFIN_DTO_USERDATA_H -#define JELLYFIN_DTO_USERDATA_H - -#include "JellyfinQt/UserItemDataDto" - -namespace Jellyfin { -namespace DTO { - -using UserData = UserItemDataDto; - -} // NS Jellyfin -} // NS DTO - -#endif // JELLYFIN_DTO_USERDATA_H diff --git a/core/include/JellyfinQt/DTO/userdto.h b/core/include/JellyfinQt/DTO/userdto.h index 99ea979..371e563 100644 --- a/core/include/JellyfinQt/DTO/userdto.h +++ b/core/include/JellyfinQt/DTO/userdto.h @@ -178,18 +178,6 @@ protected: double m_primaryImageAspectRatio; }; -} // NS DTO - -namespace Support { - -using UserDto = Jellyfin::DTO::UserDto; - -template <> -UserDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return UserDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/useritemdatadto.h b/core/include/JellyfinQt/DTO/useritemdatadto.h index a74482b..3371bd5 100644 --- a/core/include/JellyfinQt/DTO/useritemdatadto.h +++ b/core/include/JellyfinQt/DTO/useritemdatadto.h @@ -153,18 +153,6 @@ protected: QString m_itemId; }; -} // NS DTO - -namespace Support { - -using UserItemDataDto = Jellyfin::DTO::UserItemDataDto; - -template <> -UserItemDataDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return UserItemDataDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/userpolicy.h b/core/include/JellyfinQt/DTO/userpolicy.h index 7dca51b..012c12f 100644 --- a/core/include/JellyfinQt/DTO/userpolicy.h +++ b/core/include/JellyfinQt/DTO/userpolicy.h @@ -275,18 +275,6 @@ protected: SyncPlayUserAccessType m_syncPlayAccess; }; -} // NS DTO - -namespace Support { - -using UserPolicy = Jellyfin::DTO::UserPolicy; - -template <> -UserPolicy fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return UserPolicy::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/utctimeresponse.h b/core/include/JellyfinQt/DTO/utctimeresponse.h index 48e9fff..8006002 100644 --- a/core/include/JellyfinQt/DTO/utctimeresponse.h +++ b/core/include/JellyfinQt/DTO/utctimeresponse.h @@ -71,18 +71,6 @@ protected: QDateTime m_responseTransmissionTime; }; -} // NS DTO - -namespace Support { - -using UtcTimeResponse = Jellyfin::DTO::UtcTimeResponse; - -template <> -UtcTimeResponse fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return UtcTimeResponse::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/validatepathdto.h b/core/include/JellyfinQt/DTO/validatepathdto.h index cf3a892..b900dd7 100644 --- a/core/include/JellyfinQt/DTO/validatepathdto.h +++ b/core/include/JellyfinQt/DTO/validatepathdto.h @@ -80,18 +80,6 @@ protected: bool m_isFile; }; -} // NS DTO - -namespace Support { - -using ValidatePathDto = Jellyfin::DTO::ValidatePathDto; - -template <> -ValidatePathDto fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return ValidatePathDto::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/version.h b/core/include/JellyfinQt/DTO/version.h index bdad334..33b70c4 100644 --- a/core/include/JellyfinQt/DTO/version.h +++ b/core/include/JellyfinQt/DTO/version.h @@ -82,18 +82,6 @@ protected: qint32 m_minorRevision; }; -} // NS DTO - -namespace Support { - -using Version = Jellyfin::DTO::Version; - -template <> -Version fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return Version::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/versioninfo.h b/core/include/JellyfinQt/DTO/versioninfo.h index 231f5e2..bf5ed80 100644 --- a/core/include/JellyfinQt/DTO/versioninfo.h +++ b/core/include/JellyfinQt/DTO/versioninfo.h @@ -132,18 +132,6 @@ protected: QString m_repositoryUrl; }; -} // NS DTO - -namespace Support { - -using VersionInfo = Jellyfin::DTO::VersionInfo; - -template <> -VersionInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return VersionInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/video3dformat.h b/core/include/JellyfinQt/DTO/video3dformat.h index 23d10b9..34cb6ec 100644 --- a/core/include/JellyfinQt/DTO/video3dformat.h +++ b/core/include/JellyfinQt/DTO/video3dformat.h @@ -57,37 +57,6 @@ private: typedef Video3DFormatClass::Value Video3DFormat; -} // NS DTO - -namespace Support { - -using Video3DFormat = Jellyfin::DTO::Video3DFormat; -using Video3DFormatClass = Jellyfin::DTO::Video3DFormatClass; - -template <> -Video3DFormat fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return Video3DFormatClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("HalfSideBySide")) { - return Video3DFormatClass::HalfSideBySide; - } - if (str == QStringLiteral("FullSideBySide")) { - return Video3DFormatClass::FullSideBySide; - } - if (str == QStringLiteral("FullTopAndBottom")) { - return Video3DFormatClass::FullTopAndBottom; - } - if (str == QStringLiteral("HalfTopAndBottom")) { - return Video3DFormatClass::HalfTopAndBottom; - } - if (str == QStringLiteral("MVC")) { - return Video3DFormatClass::MVC; - } - - return Video3DFormatClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/videotype.h b/core/include/JellyfinQt/DTO/videotype.h index 5157541..671ab2c 100644 --- a/core/include/JellyfinQt/DTO/videotype.h +++ b/core/include/JellyfinQt/DTO/videotype.h @@ -56,34 +56,6 @@ private: typedef VideoTypeClass::Value VideoType; -} // NS DTO - -namespace Support { - -using VideoType = Jellyfin::DTO::VideoType; -using VideoTypeClass = Jellyfin::DTO::VideoTypeClass; - -template <> -VideoType fromJsonValue(const QJsonValue &source) { - if (!source.isString()) return VideoTypeClass::EnumNotSet; - - QString str = source.toString(); - if (str == QStringLiteral("VideoFile")) { - return VideoTypeClass::VideoFile; - } - if (str == QStringLiteral("Iso")) { - return VideoTypeClass::Iso; - } - if (str == QStringLiteral("Dvd")) { - return VideoTypeClass::Dvd; - } - if (str == QStringLiteral("BluRay")) { - return VideoTypeClass::BluRay; - } - - return VideoTypeClass::EnumNotSet; -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/virtualfolderinfo.h b/core/include/JellyfinQt/DTO/virtualfolderinfo.h index 4e0b0ad..e7cee2f 100644 --- a/core/include/JellyfinQt/DTO/virtualfolderinfo.h +++ b/core/include/JellyfinQt/DTO/virtualfolderinfo.h @@ -117,18 +117,6 @@ protected: QString m_refreshStatus; }; -} // NS DTO - -namespace Support { - -using VirtualFolderInfo = Jellyfin::DTO::VirtualFolderInfo; - -template <> -VirtualFolderInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return VirtualFolderInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/wakeonlaninfo.h b/core/include/JellyfinQt/DTO/wakeonlaninfo.h index 64f2f30..4762e8e 100644 --- a/core/include/JellyfinQt/DTO/wakeonlaninfo.h +++ b/core/include/JellyfinQt/DTO/wakeonlaninfo.h @@ -71,18 +71,6 @@ protected: qint32 m_port; }; -} // NS DTO - -namespace Support { - -using WakeOnLanInfo = Jellyfin::DTO::WakeOnLanInfo; - -template <> -WakeOnLanInfo fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return WakeOnLanInfo::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/DTO/xmlattribute.h b/core/include/JellyfinQt/DTO/xmlattribute.h index d4aca1a..57c5aff 100644 --- a/core/include/JellyfinQt/DTO/xmlattribute.h +++ b/core/include/JellyfinQt/DTO/xmlattribute.h @@ -71,18 +71,6 @@ protected: QString m_value; }; -} // NS DTO - -namespace Support { - -using XmlAttribute = Jellyfin::DTO::XmlAttribute; - -template <> -XmlAttribute fromJsonValue(const QJsonValue &source) { - if (!source.isObject()) throw new ParseException("Expected JSON Object"); - return XmlAttribute::fromJson(source.toObject()); -} - } // NS Jellyfin } // NS DTO diff --git a/core/include/JellyfinQt/apimodel.h b/core/include/JellyfinQt/apimodel.h index fa6e91f..50b29a8 100644 --- a/core/include/JellyfinQt/apimodel.h +++ b/core/include/JellyfinQt/apimodel.h @@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include -#include +#include #include #include #include @@ -33,9 +33,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include "apiclient.h" #include "jsonhelper.h" -#include "DTO/item.h" -#include "DTO/user.h" -#include "DTO/userdata.h" +#include "DTO/baseitemdto.h" +#include "DTO/userdto.h" +#include "DTO/useritemdatadto.h" namespace Jellyfin { @@ -306,7 +306,7 @@ private: /** * @brief List of the public users on the server. */ -class PublicUserModel : public ApiModel { +class PublicUserModel : public ApiModel { public: explicit PublicUserModel (QObject *parent = nullptr); }; @@ -316,7 +316,7 @@ public: * * Listens for updates in the library and updates the model accordingly. */ -class ItemModel : public ApiModel { +class ItemModel : public ApiModel { Q_OBJECT public: explicit ItemModel (QString path, bool responseHasRecords, bool replaceUser, QObject *parent = nullptr); diff --git a/core/include/JellyfinQt/jellyfin.h b/core/include/JellyfinQt/jellyfin.h index 2b0255b..4d34c82 100644 --- a/core/include/JellyfinQt/jellyfin.h +++ b/core/include/JellyfinQt/jellyfin.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include // #include "DTO/dto.h" -#include "DTO/item.h" +#include "model/item.h" #include "DTO/mediastream.h" #include "DTO/nameguidpair.h" #include "DTO/userdto.h" diff --git a/core/include/JellyfinQt/model/item.h b/core/include/JellyfinQt/model/item.h new file mode 100644 index 0000000..8b8f531 --- /dev/null +++ b/core/include/JellyfinQt/model/item.h @@ -0,0 +1,193 @@ +/* +Sailfin: a Jellyfin client written using Qt +Copyright (C) 2021 Chris Josten +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef JELLYFIN_MODEL_ITEM_H +#define JELLYFIN_MODEL_ITEM_H + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include + +/*#include "dto.h" +#include "mediastream.h" +#include "namedguidpair.h" +#include "userdata.h"*/ + +#include "../DTO/baseitemdto.h" + +namespace Jellyfin{ + +namespace Model { + +class Item : public QObject { + Q_OBJECT +public: + Q_INVOKABLE explicit Item(QObject *parent = nullptr); + + Q_PROPERTY(QUuid jellyfinId READ jellyfinId NOTIFY jellyfinIdChanged) + + // Based on https://github.com/jellyfin/jellyfin/blob/907695dec7fda152d0e17c1197637bc0e17c9928/MediaBrowser.Model/Dto/BaseItemDto.cs + // I copy, pasted and replaced. I feel like a Go programmer implementing generic containers. + // If this were D, I would've writed a compile-time C# parser to parse that source code at compile time, extract + // the properties and generate a class based on that. + // Doing that in C++ would be more difficult and I dislike qmake. Does it even support running programs at compile time? + // But here I am, using ctrl-C++ + + // Please keep the order of the properties the same as in the file linked above. + Q_PROPERTY(QString name READ name NOTIFY nameChanged) + Q_PROPERTY(QString originalTitle READ originalTitle NOTIFY originalTitleChanged) + Q_PROPERTY(QString serverId READ serverId NOTIFY serverIdChanged) + Q_PROPERTY(QString etag READ etag NOTIFY etagChanged) + Q_PROPERTY(QString sourceType READ sourceType NOTIFY sourceTypeChanged) + Q_PROPERTY(QString playlistItemId READ playlistItemId NOTIFY playlistItemIdChanged) + Q_PROPERTY(QDateTime dateCreated READ dateCreated NOTIFY dateCreatedChanged) + Q_PROPERTY(QDateTime dateLastMediaAdded READ dateLastMediaAdded NOTIFY dateLastMediaAddedChanged) + Q_PROPERTY(QString extraType READ extraType NOTIFY extraTypeChanged) + Q_PROPERTY(int airsBeforeSeasonNumber READ airsBeforeSeasonNumber NOTIFY airsBeforeSeasonNumberChanged) + Q_PROPERTY(int airsAfterSeasonNumber READ airsAfterSeasonNumber NOTIFY airsAfterSeasonNumberChanged) + Q_PROPERTY(int airsBeforeEpisodeNumber READ airsBeforeEpisodeNumber NOTIFY airsBeforeEpisodeNumberChanged) + /*Q_PROPERTY(bool canDelete READ canDelete NOTIFY canDeleteChanged) + Q_PROPERTY(bool canDownload READ canDownload NOTIFY canDownloadChanged) + Q_PROPERTY(bool hasSubtitles READ hasSubtitles NOTIFY hasSubtitlesChanged) + Q_PROPERTY(QString preferredMetadataLanguage READ preferredMetadataLanguage NOTIFY preferredMetadataLanguageChanged) + Q_PROPERTY(QString preferredMetadataCountryCode READ preferredMetadataCountryCode NOTIFY preferredMetadataCountryCodeChanged) + Q_PROPERTY(bool supportsSync READ supportsSync NOTIFY supportsSyncChanged) + Q_PROPERTY(QString container READ container NOTIFY containerChanged) + Q_PROPERTY(QString sortName READ sortName NOTIFY sortNameChanged) + Q_PROPERTY(QString forcedSortName READ forcedSortName NOTIFY forcedSortNameChanged) + //SKIP: Video3DFormat + Q_PROPERTY(QDateTime premiereData READ premiereDate NOTIFY premiereDateChanged) + //SKIP: ExternalUrls + //SKIP: MediaSources + Q_PROPERTY(float criticRating READ criticRating NOTIFY criticRatingChanged) + Q_PROPERTY(QStringList productionLocations READ productionLocations NOTIFY productionLocationsChanged) + + // Handpicked, important ones + Q_PROPERTY(qint64 runTimeTicks READ runTimeTicks NOTIFY runTimeTicksChanged) + Q_PROPERTY(QString overview READ overview NOTIFY overviewChanged) + Q_PROPERTY(int productionYear READ productionYear NOTIFY productionYearChanged) + Q_PROPERTY(int indexNumber READ indexNumber NOTIFY indexNumberChanged) + Q_PROPERTY(int indexNumberEnd READ indexNumberEnd NOTIFY indexNumberEndChanged) + Q_PROPERTY(bool isFolder READ isFolder NOTIFY isFolderChanged) + Q_PROPERTY(QString type READ type NOTIFY typeChanged) + Q_PROPERTY(QString parentBackdropItemId READ parentBackdropItemId NOTIFY parentBackdropItemIdChanged) + Q_PROPERTY(QStringList parentBackdropImageTags READ parentBackdropImageTags NOTIFY parentBackdropImageTagsChanged) + Q_PROPERTY(UserData *userData READ userData NOTIFY userDataChanged) + Q_PROPERTY(int recursiveItemCount READ recursiveItemCount NOTIFY recursiveItemCountChanged) + Q_PROPERTY(int childCount READ childCount NOTIFY childCountChanged) + Q_PROPERTY(QString albumArtist READ albumArtist NOTIFY albumArtistChanged) + Q_PROPERTY(QVariantList albumArtists READ albumArtists NOTIFY albumArtistsChanged) + Q_PROPERTY(QString seriesName READ seriesName NOTIFY seriesNameChanged) + Q_PROPERTY(QString seasonName READ seasonName NOTIFY seasonNameChanged) + Q_PROPERTY(QList __list__mediaStreams MEMBER __list__m_mediaStreams NOTIFY mediaStreamsChanged) + Q_PROPERTY(QVariantList mediaStreams READ mediaStreams NOTIFY mediaStreamsChanged STORED false) + Q_PROPERTY(QStringList artists READ artists NOTIFY artistsChanged) + // Why is this a QJsonObject? Well, because I couldn't be bothered to implement the deserialisations of + // a QHash at the moment. + Q_PROPERTY(QJsonObject imageTags READ imageTags NOTIFY imageTagsChanged) + Q_PROPERTY(QStringList backdropImageTags READ backdropImageTags NOTIFY backdropImageTagsChanged) + Q_PROPERTY(QJsonObject imageBlurHashes READ imageBlurHashes NOTIFY imageBlurHashesChanged) + Q_PROPERTY(QString mediaType READ mediaType READ mediaType NOTIFY mediaTypeChanged) + Q_PROPERTY(int width READ width NOTIFY widthChanged) + Q_PROPERTY(int height READ height NOTIFY heightChanged)*/ + + QUuid jellyfinId() const { return m_data->jellyfinId(); } + QString name() const { return m_data->name(); } + QString originalTitle() const { return m_data->originalTitle(); } + QString serverId() const { return m_data->serverId(); } + QString etag() const { return m_data->etag(); } + QString sourceType() const { return m_data->sourceType(); } + QString playlistItemId() const { return m_data->playlistItemId(); } + QDateTime dateCreated() const { return m_data->dateCreated(); } + QDateTime dateLastMediaAdded() const { return m_data->dateLastMediaAdded(); } + QString extraType() const { return m_data->extraType(); } + int airsBeforeSeasonNumber() const { return m_data->airsBeforeSeasonNumber(); } + int airsAfterSeasonNumber() const { return m_data->airsAfterSeasonNumber(); } + int airsBeforeEpisodeNumber() const { return m_data->airsBeforeEpisodeNumber(); } + + QSharedPointer data() const { return m_data; } +signals: + void jellyfinIdChanged(const QUuid &newId); + void nameChanged(const QString &newName); + void originalTitleChanged(const QString &newOriginalTitle); + void serverIdChanged(const QString &newServerId); + void etagChanged(const QString &newEtag); + void sourceTypeChanged(const QString &sourceType); + void playlistItemIdChanged(const QString &playlistItemIdChanged); + void dateCreatedChanged(QDateTime newDateCreatedChanged); + void dateLastMediaAddedChanged(QDateTime newDateLastMediaAdded); + void extraTypeChanged(const QString &newExtraType); + void airsBeforeSeasonNumberChanged(int newAirsBeforeSeasonNumber); + void airsAfterSeasonNumberChanged(int newAirsAfterSeasonNumber); + void airsBeforeEpisodeNumberChanged(int newAirsAfterEpisodeNumber); + bool canDeleteChanged(bool newCanDelete); + void canDownloadChanged(bool newCanDownload); + void hasSubtitlesChanged(bool newHasSubtitles); + void preferredMetadataLanguageChanged(const QString &newPreferredMetadataLanguage); + void preferredMetadataCountryCodeChanged(const QString &newPreferredMetadataCountryCode); + void supportsSyncChanged(bool newSupportsSync); + void containerChanged(const QString &newContainer); + void sortNameChanged(const QString &newSortName); + void forcedSortNameChanged(const QString &newForcedSortName); + void premiereDateChanged(QDateTime newPremiereDate); + void criticRatingChanged(float newCriticRating); + void productionLocationsChanged(QStringList newProductionLocations); + + // Handpicked, important ones + void runTimeTicksChanged(qint64 newRunTimeTicks); + void overviewChanged(const QString &newOverview); + void productionYearChanged(int newProductionYear); + void indexNumberChanged(int newIndexNumber); + void indexNumberEndChanged(int newIndexNumberEnd); + void isFolderChanged(bool newIsFolder); + void typeChanged(const QString &newType); + void parentBackdropItemIdChanged(); + void parentBackdropImageTagsChanged(); + //void userDataChanged(UserData *newUserData); + void recursiveItemCountChanged(int newRecursiveItemCount); + void childCountChanged(int newChildCount); + void albumArtistChanged(const QString &newAlbumArtist); + //void albumArtistsChanged(NameGuidPair *newAlbumArtists); + void seriesNameChanged(const QString &newSeriesName); + void seasonNameChanged(const QString &newSeasonName); + void mediaStreamsChanged(/*const QList &newMediaStreams*/); + void artistsChanged(const QStringList &newArtists); + void imageTagsChanged(); + void backdropImageTagsChanged(); + void imageBlurHashesChanged(); + void mediaTypeChanged(const QString &newMediaType); + void widthChanged(int newWidth); + void heightChanged(int newHeight); +protected: + QSharedPointer m_data; +}; + +} // NS Model +} // NS Jellyfin + +#endif // JELLYFIN_MODEL_ITEM_H diff --git a/core/include/JellyfinQt/playbackmanager.h b/core/include/JellyfinQt/playbackmanager.h index 08efa7b..c48d269 100644 --- a/core/include/JellyfinQt/playbackmanager.h +++ b/core/include/JellyfinQt/playbackmanager.h @@ -35,7 +35,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include "remotedata.h" +#include "support/jsonconv.h" +#include "model/item.h" #include "apiclient.h" @@ -78,7 +79,7 @@ public: Q_PROPERTY(PlayMethod playMethod READ playMethod NOTIFY playMethodChanged) // Current Item and queue informatoion - Q_PROPERTY(Item *item READ item NOTIFY itemChanged) + Q_PROPERTY(Model::Item *item READ item NOTIFY itemChanged) Q_PROPERTY(QAbstractItemModel *queue READ queue NOTIFY queueChanged) Q_PROPERTY(int queueIndex READ queueIndex NOTIFY queueIndexChanged) @@ -92,7 +93,7 @@ public: Q_PROPERTY(QMediaPlayer::State playbackState READ playbackState NOTIFY playbackStateChanged) Q_PROPERTY(qint64 position READ position NOTIFY positionChanged) - BaseItemDto *item() const { return m_item->data(); } + Model::Item *item() const { return m_item; } void setApiClient(ApiClient *apiClient); QString streamUrl() const { return m_streamUrl; } @@ -166,7 +167,7 @@ private slots: private: QTimer m_updateTimer; ApiClient *m_apiClient = nullptr; - RemoteItem *m_item; + Model::Item *m_item; QString m_streamUrl; QString m_playSessionId; int m_audioIndex = 0; @@ -186,7 +187,7 @@ private: int m_queueIndex = 0; bool m_resumePlayback = true; - void setItem(BaseItemDto *newItem); + void setItem(Model::Item *newItem); void swapMediaPlayer(); bool m_qmlIsParsingComponent = false; @@ -199,12 +200,12 @@ private: /** * @brief Retrieves the URL of the stream to open. */ - void fetchStreamUrl(const BaseItemDto *item, bool autoOpen, const FetchCallback &callback); - void fetchAndSetStreamUrl(const BaseItemDto *item); + void fetchStreamUrl(const Model::Item *item, bool autoOpen, const FetchCallback &callback); + void fetchAndSetStreamUrl(const Model::Item *item); void setStreamUrl(const QString &streamUrl); void setPlaybackState(QMediaPlayer::State newState); - BaseItemDto *nextItem(); + Model::Item *nextItem(); void setQueue(ItemModel *itemModel); // Factor to multiply with when converting from milliseconds to ticks. diff --git a/core/include/JellyfinQt/remotedata.h b/core/include/JellyfinQt/remotedata.h index 5ba4394..d3c211f 100644 --- a/core/include/JellyfinQt/remotedata.h +++ b/core/include/JellyfinQt/remotedata.h @@ -32,6 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include "jsonhelper.h" #include "DTO/baseitemdto.h" +#include "support/jsonconv.h" namespace Jellyfin { /** @@ -197,7 +198,7 @@ protected: virtual void emitDataChanged() = 0; }; -class RemoteItem : public RemoteData { +/*class RemoteItem : public RemoteData { Q_OBJECT public: RemoteItem(QObject *parent = nullptr); @@ -206,14 +207,14 @@ public: Q_PROPERTY(QString jellyfinId READ jellyfinId WRITE setJellyfinId NOTIFY jellyfinIdChanged) QString getDataUrl() const override { - return QString("/Users/") + m_apiClient->userId() + "/Items/" + m_data->jellyfinId(); + return QString("/Users/") + m_apiClient->userId() + "/Items/" + Support::uuidToString(m_data->jellyfinId()); } bool canReload() const override { return RemoteData::canReload() && !m_data->jellyfinId().isNull(); } - QString jellyfinId() const { return m_data->jellyfinId(); } + QString jellyfinId() const { return Support::uuidToString(m_data->jellyfinId()); } void setJellyfinId(QString newId) { m_data->setJellyfinId(newId); if (canReload()) reload(); @@ -225,7 +226,7 @@ protected: void emitDataChanged() override { emit dataChanged(m_data); } -}; +};*/ void registerRemoteTypes(const char *uri); } // NS Jellyfin diff --git a/core/include/JellyfinQt/support/jsonconv.h b/core/include/JellyfinQt/support/jsonconv.h index b859791..f886b46 100644 --- a/core/include/JellyfinQt/support/jsonconv.h +++ b/core/include/JellyfinQt/support/jsonconv.h @@ -14,6 +14,10 @@ namespace Jellyfin { namespace Support { +// Helper functions +QString uuidToString(const QUuid &source); +QUuid stringToUuid(const QString &source); + /** * @brief Thrown when JSON cannot be parsed. */ @@ -38,100 +42,7 @@ QJsonValue toJsonValue(const T &source) { Q_ASSERT_X(false, "toJsonValue", "toJsonValue called with unimplemented type"); } -// Trivial converters for built-in classes and simple types -// int -template <> -int fromJsonValue(const QJsonValue &source) { - if (!source.isDouble()) throw new ParseException("Error while trying to parse JSON value as integer: not an integer"); - return source.toInt(); -} - -template <> -QJsonValue toJsonValue(const int &source) { - return QJsonValue(source); -} - -// bool -template <> -bool fromJsonValue(const QJsonValue &source) { - if (!source.isBool()) throw new ParseException("Error while trying to parse JSON value as boolean: not a boolean"); - return source.toBool(); -} - -template <> -QJsonValue toJsonValue(const bool &source) { - return QJsonValue(source); -} - -// QString -template <> -QString fromJsonValue(const QJsonValue &source) { - if (!source.isString()) throw new ParseException("Error while trying to parse JSON value as string: not a string"); - return source.toString(); -} - -template <> -QJsonValue toJsonValue(const QString &source) { - return QJsonValue(source); -} - -// Double -template <> -double fromJsonValue(const QJsonValue &source) { - if (!source.isDouble()) throw new ParseException("Error while trying to parse JSON value as integer: not a double"); - return source.toDouble(); -} - -template <> -QJsonValue toJsonValue(const double &source) { - return QJsonValue(source); -} - -// QDateTime -template <> -QDateTime fromJsonValue(const QJsonValue &source) { - if (!source.isString()) throw new ParseException("Error while trying to parse JSON value as DateTime: not a string"); - return QDateTime::fromString(source.toString(), Qt::ISODateWithMs); -} - -template <> -QJsonValue toJsonValue(const QDateTime &source) { - return QJsonValue(source.toString(Qt::ISODateWithMs)); -} - -// QUuid -template <> -QUuid fromJsonValue(const QJsonValue &source) { - if (!source.isString()) throw new ParseException("Error while trying to parse JSON value as QUuid: not a string"); - QString sourceString = source.toString(); - if (sourceString.size() != 32) throw new ParseException("Error while trying to parse JSON value as QUid: invalid length"); - // Convert xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (length: 32) - // to {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} (length: 38) - QString qtParseableString; - qtParseableString.reserve(38); - qtParseableString += QStringLiteral("{") - + sourceString.mid(0, 8) - + QStringLiteral("-") - + sourceString.mid(8, 4) - + QStringLiteral("-") - + sourceString.mid(12, 4) - + QStringLiteral("-") - + sourceString.mid(16, 4) - + QStringLiteral("-") - + sourceString.mid(20, 12) - + QStringLiteral("}"); - - return QUuid(qtParseableString); -} - -template <> -QJsonValue toJsonValue(const QUuid &source) { - QString str = source.toString(); - // Convert {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} (length: 38) - // to xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (lenght: 32) - return QJsonValue(str.mid(1, 8) + str.mid(10, 4) + str.mid(15, 4) + str.mid(20, 4) + str.mid(25 + 12)); -} // QList template diff --git a/core/openapigenerator.d b/core/openapigenerator.d index 25dcd9f..13f1d7b 100755 --- a/core/openapigenerator.d +++ b/core/openapigenerator.d @@ -72,9 +72,9 @@ string[string] compatAliases; string[string] memberAliases; static this() { - compatAliases["BaseItemDto"] = "Item"; + /*compatAliases["BaseItemDto"] = "Item"; compatAliases["UserDto"] = "User"; - compatAliases["UserItemDataDto"] = "UserData"; + compatAliases["UserItemDataDto"] = "UserData";*/ memberAliases["id"] = "jellyfinId"; } @@ -199,7 +199,7 @@ void generateFileForSchema(ref string name, ref const Node scheme, Node allSchem writeHeaderPostamble(headerFile, CPP_NAMESPACE_DTO, name); writeImplementationPreamble(implementationFile, CPP_NAMESPACE_DTO, name); - writeEnumImplementation(implementationFile, name); + writeEnumImplementation(implementationFile, name, values[]); writeImplementationPostamble(implementationFile, CPP_NAMESPACE_DTO, name); } if (scheme["type"].as!string == "object" && "properties" in scheme) { @@ -415,9 +415,16 @@ void writeEnumHeader(File output, string name, string[] values, string doc = "") output.writeln(render!(import("enum_header.hbs"), Controller)(controller)); } -void writeEnumImplementation(File output, string name) { - string className = name.applyCasePolicy(OPENAPI_CASING, CPP_CLASS_CASING); - output.writefln("%sClass::%sClass() {}", name, name); +void writeEnumImplementation(File output, string name, string[] values) { + class Controller { + string className; + string[] values; + string supportNamespace = namespaceString!CPP_NAMESPACE_SUPPORT; + } + Controller controller = new Controller(); + controller.className = name.applyCasePolicy(OPENAPI_CASING, CPP_CLASS_CASING); + controller.values = values; + output.writeln(render!(import("enum_implementation.hbs"), Controller)(controller)); } // Common diff --git a/core/src/DTO/accessschedule.cpp b/core/src/DTO/accessschedule.cpp index 516e5c1..7a385b8 100644 --- a/core/src/DTO/accessschedule.cpp +++ b/core/src/DTO/accessschedule.cpp @@ -32,30 +32,31 @@ namespace Jellyfin { namespace DTO { -AccessSchedule::AccessSchedule(QObject *parent) {} +AccessSchedule::AccessSchedule() {} -AccessSchedule AccessSchedule::fromJson(QJsonObject source) {AccessSchedule instance; - instance->setFromJson(source, false); +AccessSchedule AccessSchedule::fromJson(QJsonObject source) { + AccessSchedule instance; + instance.setFromJson(source); return instance; } void AccessSchedule::setFromJson(QJsonObject source) { - m_jellyfinId = fromJsonValue(source["Id"]); - m_userId = fromJsonValue(source["UserId"]); - m_dayOfWeek = fromJsonValue(source["DayOfWeek"]); - m_startHour = fromJsonValue(source["StartHour"]); - m_endHour = fromJsonValue(source["EndHour"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); + m_userId = Jellyfin::Support::fromJsonValue(source["UserId"]); + m_dayOfWeek = Jellyfin::Support::fromJsonValue(source["DayOfWeek"]); + m_startHour = Jellyfin::Support::fromJsonValue(source["StartHour"]); + m_endHour = Jellyfin::Support::fromJsonValue(source["EndHour"]); } QJsonObject AccessSchedule::toJson() { QJsonObject result; - result["Id"] = toJsonValue(m_jellyfinId); - result["UserId"] = toJsonValue(m_userId); - result["DayOfWeek"] = toJsonValue(m_dayOfWeek); - result["StartHour"] = toJsonValue(m_startHour); - result["EndHour"] = toJsonValue(m_endHour); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); + result["DayOfWeek"] = Jellyfin::Support::toJsonValue(m_dayOfWeek); + result["StartHour"] = Jellyfin::Support::toJsonValue(m_startHour); + result["EndHour"] = Jellyfin::Support::toJsonValue(m_endHour); return result; } @@ -86,6 +87,17 @@ void AccessSchedule::setEndHour(double newEndHour) { m_endHour = newEndHour; } +} // NS DTO + +namespace Support { + +using AccessSchedule = Jellyfin::DTO::AccessSchedule; + +template <> +AccessSchedule fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return AccessSchedule::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/activitylogentry.cpp b/core/src/DTO/activitylogentry.cpp index 1f962c6..2270e83 100644 --- a/core/src/DTO/activitylogentry.cpp +++ b/core/src/DTO/activitylogentry.cpp @@ -32,40 +32,41 @@ namespace Jellyfin { namespace DTO { -ActivityLogEntry::ActivityLogEntry(QObject *parent) {} +ActivityLogEntry::ActivityLogEntry() {} -ActivityLogEntry ActivityLogEntry::fromJson(QJsonObject source) {ActivityLogEntry instance; - instance->setFromJson(source, false); +ActivityLogEntry ActivityLogEntry::fromJson(QJsonObject source) { + ActivityLogEntry instance; + instance.setFromJson(source); return instance; } void ActivityLogEntry::setFromJson(QJsonObject source) { - m_jellyfinId = fromJsonValue(source["Id"]); - m_name = fromJsonValue(source["Name"]); - m_overview = fromJsonValue(source["Overview"]); - m_shortOverview = fromJsonValue(source["ShortOverview"]); - m_type = fromJsonValue(source["Type"]); - m_itemId = fromJsonValue(source["ItemId"]); - m_date = fromJsonValue(source["Date"]); - m_userId = fromJsonValue(source["UserId"]); - m_userPrimaryImageTag = fromJsonValue(source["UserPrimaryImageTag"]); - m_severity = fromJsonValue(source["Severity"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_overview = Jellyfin::Support::fromJsonValue(source["Overview"]); + m_shortOverview = Jellyfin::Support::fromJsonValue(source["ShortOverview"]); + m_type = Jellyfin::Support::fromJsonValue(source["Type"]); + m_itemId = Jellyfin::Support::fromJsonValue(source["ItemId"]); + m_date = Jellyfin::Support::fromJsonValue(source["Date"]); + m_userId = Jellyfin::Support::fromJsonValue(source["UserId"]); + m_userPrimaryImageTag = Jellyfin::Support::fromJsonValue(source["UserPrimaryImageTag"]); + m_severity = Jellyfin::Support::fromJsonValue(source["Severity"]); } QJsonObject ActivityLogEntry::toJson() { QJsonObject result; - result["Id"] = toJsonValue(m_jellyfinId); - result["Name"] = toJsonValue(m_name); - result["Overview"] = toJsonValue(m_overview); - result["ShortOverview"] = toJsonValue(m_shortOverview); - result["Type"] = toJsonValue(m_type); - result["ItemId"] = toJsonValue(m_itemId); - result["Date"] = toJsonValue(m_date); - result["UserId"] = toJsonValue(m_userId); - result["UserPrimaryImageTag"] = toJsonValue(m_userPrimaryImageTag); - result["Severity"] = toJsonValue(m_severity); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Overview"] = Jellyfin::Support::toJsonValue(m_overview); + result["ShortOverview"] = Jellyfin::Support::toJsonValue(m_shortOverview); + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + result["Date"] = Jellyfin::Support::toJsonValue(m_date); + result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); + result["UserPrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_userPrimaryImageTag); + result["Severity"] = Jellyfin::Support::toJsonValue(m_severity); return result; } @@ -121,6 +122,17 @@ void ActivityLogEntry::setSeverity(LogLevel newSeverity) { m_severity = newSeverity; } +} // NS DTO + +namespace Support { + +using ActivityLogEntry = Jellyfin::DTO::ActivityLogEntry; + +template <> +ActivityLogEntry fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ActivityLogEntry::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/activitylogentryqueryresult.cpp b/core/src/DTO/activitylogentryqueryresult.cpp index 8453a2b..77d2cd3 100644 --- a/core/src/DTO/activitylogentryqueryresult.cpp +++ b/core/src/DTO/activitylogentryqueryresult.cpp @@ -32,26 +32,27 @@ namespace Jellyfin { namespace DTO { -ActivityLogEntryQueryResult::ActivityLogEntryQueryResult(QObject *parent) {} +ActivityLogEntryQueryResult::ActivityLogEntryQueryResult() {} -ActivityLogEntryQueryResult ActivityLogEntryQueryResult::fromJson(QJsonObject source) {ActivityLogEntryQueryResult instance; - instance->setFromJson(source, false); +ActivityLogEntryQueryResult ActivityLogEntryQueryResult::fromJson(QJsonObject source) { + ActivityLogEntryQueryResult instance; + instance.setFromJson(source); return instance; } void ActivityLogEntryQueryResult::setFromJson(QJsonObject source) { - m_items = fromJsonValue>>(source["Items"]); - m_totalRecordCount = fromJsonValue(source["TotalRecordCount"]); - m_startIndex = fromJsonValue(source["StartIndex"]); + m_items = Jellyfin::Support::fromJsonValue>>(source["Items"]); + m_totalRecordCount = Jellyfin::Support::fromJsonValue(source["TotalRecordCount"]); + m_startIndex = Jellyfin::Support::fromJsonValue(source["StartIndex"]); } QJsonObject ActivityLogEntryQueryResult::toJson() { QJsonObject result; - result["Items"] = toJsonValue>>(m_items); - result["TotalRecordCount"] = toJsonValue(m_totalRecordCount); - result["StartIndex"] = toJsonValue(m_startIndex); + result["Items"] = Jellyfin::Support::toJsonValue>>(m_items); + result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); + result["StartIndex"] = Jellyfin::Support::toJsonValue(m_startIndex); return result; } @@ -72,6 +73,17 @@ void ActivityLogEntryQueryResult::setStartIndex(qint32 newStartIndex) { m_startIndex = newStartIndex; } +} // NS DTO + +namespace Support { + +using ActivityLogEntryQueryResult = Jellyfin::DTO::ActivityLogEntryQueryResult; + +template <> +ActivityLogEntryQueryResult fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ActivityLogEntryQueryResult::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/addvirtualfolderdto.cpp b/core/src/DTO/addvirtualfolderdto.cpp index af9f1df..b045679 100644 --- a/core/src/DTO/addvirtualfolderdto.cpp +++ b/core/src/DTO/addvirtualfolderdto.cpp @@ -32,22 +32,23 @@ namespace Jellyfin { namespace DTO { -AddVirtualFolderDto::AddVirtualFolderDto(QObject *parent) {} +AddVirtualFolderDto::AddVirtualFolderDto() {} -AddVirtualFolderDto AddVirtualFolderDto::fromJson(QJsonObject source) {AddVirtualFolderDto instance; - instance->setFromJson(source, false); +AddVirtualFolderDto AddVirtualFolderDto::fromJson(QJsonObject source) { + AddVirtualFolderDto instance; + instance.setFromJson(source); return instance; } void AddVirtualFolderDto::setFromJson(QJsonObject source) { - m_libraryOptions = fromJsonValue>(source["LibraryOptions"]); + m_libraryOptions = Jellyfin::Support::fromJsonValue>(source["LibraryOptions"]); } QJsonObject AddVirtualFolderDto::toJson() { QJsonObject result; - result["LibraryOptions"] = toJsonValue>(m_libraryOptions); + result["LibraryOptions"] = Jellyfin::Support::toJsonValue>(m_libraryOptions); return result; } @@ -58,6 +59,17 @@ void AddVirtualFolderDto::setLibraryOptions(QSharedPointer newLi m_libraryOptions = newLibraryOptions; } +} // NS DTO + +namespace Support { + +using AddVirtualFolderDto = Jellyfin::DTO::AddVirtualFolderDto; + +template <> +AddVirtualFolderDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return AddVirtualFolderDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/albuminfo.cpp b/core/src/DTO/albuminfo.cpp index 2c43f9e..032e99a 100644 --- a/core/src/DTO/albuminfo.cpp +++ b/core/src/DTO/albuminfo.cpp @@ -32,46 +32,47 @@ namespace Jellyfin { namespace DTO { -AlbumInfo::AlbumInfo(QObject *parent) {} +AlbumInfo::AlbumInfo() {} -AlbumInfo AlbumInfo::fromJson(QJsonObject source) {AlbumInfo instance; - instance->setFromJson(source, false); +AlbumInfo AlbumInfo::fromJson(QJsonObject source) { + AlbumInfo instance; + instance.setFromJson(source); return instance; } void AlbumInfo::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_path = fromJsonValue(source["Path"]); - m_metadataLanguage = fromJsonValue(source["MetadataLanguage"]); - m_metadataCountryCode = fromJsonValue(source["MetadataCountryCode"]); - m_providerIds = fromJsonValue(source["ProviderIds"]); - m_year = fromJsonValue(source["Year"]); - m_indexNumber = fromJsonValue(source["IndexNumber"]); - m_parentIndexNumber = fromJsonValue(source["ParentIndexNumber"]); - m_premiereDate = fromJsonValue(source["PremiereDate"]); - m_isAutomated = fromJsonValue(source["IsAutomated"]); - m_albumArtists = fromJsonValue(source["AlbumArtists"]); - m_artistProviderIds = fromJsonValue(source["ArtistProviderIds"]); - m_songInfos = fromJsonValue>>(source["SongInfos"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_path = Jellyfin::Support::fromJsonValue(source["Path"]); + m_metadataLanguage = Jellyfin::Support::fromJsonValue(source["MetadataLanguage"]); + m_metadataCountryCode = Jellyfin::Support::fromJsonValue(source["MetadataCountryCode"]); + m_providerIds = Jellyfin::Support::fromJsonValue(source["ProviderIds"]); + m_year = Jellyfin::Support::fromJsonValue(source["Year"]); + m_indexNumber = Jellyfin::Support::fromJsonValue(source["IndexNumber"]); + m_parentIndexNumber = Jellyfin::Support::fromJsonValue(source["ParentIndexNumber"]); + m_premiereDate = Jellyfin::Support::fromJsonValue(source["PremiereDate"]); + m_isAutomated = Jellyfin::Support::fromJsonValue(source["IsAutomated"]); + m_albumArtists = Jellyfin::Support::fromJsonValue(source["AlbumArtists"]); + m_artistProviderIds = Jellyfin::Support::fromJsonValue(source["ArtistProviderIds"]); + m_songInfos = Jellyfin::Support::fromJsonValue>>(source["SongInfos"]); } QJsonObject AlbumInfo::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Path"] = toJsonValue(m_path); - result["MetadataLanguage"] = toJsonValue(m_metadataLanguage); - result["MetadataCountryCode"] = toJsonValue(m_metadataCountryCode); - result["ProviderIds"] = toJsonValue(m_providerIds); - result["Year"] = toJsonValue(m_year); - result["IndexNumber"] = toJsonValue(m_indexNumber); - result["ParentIndexNumber"] = toJsonValue(m_parentIndexNumber); - result["PremiereDate"] = toJsonValue(m_premiereDate); - result["IsAutomated"] = toJsonValue(m_isAutomated); - result["AlbumArtists"] = toJsonValue(m_albumArtists); - result["ArtistProviderIds"] = toJsonValue(m_artistProviderIds); - result["SongInfos"] = toJsonValue>>(m_songInfos); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); + result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); + result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); + result["Year"] = Jellyfin::Support::toJsonValue(m_year); + result["IndexNumber"] = Jellyfin::Support::toJsonValue(m_indexNumber); + result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue(m_parentIndexNumber); + result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); + result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); + result["AlbumArtists"] = Jellyfin::Support::toJsonValue(m_albumArtists); + result["ArtistProviderIds"] = Jellyfin::Support::toJsonValue(m_artistProviderIds); + result["SongInfos"] = Jellyfin::Support::toJsonValue>>(m_songInfos); return result; } @@ -142,6 +143,17 @@ void AlbumInfo::setSongInfos(QList> newSongInfos) { m_songInfos = newSongInfos; } +} // NS DTO + +namespace Support { + +using AlbumInfo = Jellyfin::DTO::AlbumInfo; + +template <> +AlbumInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return AlbumInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/albuminforemotesearchquery.cpp b/core/src/DTO/albuminforemotesearchquery.cpp index 9f6d391..a7c05dc 100644 --- a/core/src/DTO/albuminforemotesearchquery.cpp +++ b/core/src/DTO/albuminforemotesearchquery.cpp @@ -32,28 +32,29 @@ namespace Jellyfin { namespace DTO { -AlbumInfoRemoteSearchQuery::AlbumInfoRemoteSearchQuery(QObject *parent) {} +AlbumInfoRemoteSearchQuery::AlbumInfoRemoteSearchQuery() {} -AlbumInfoRemoteSearchQuery AlbumInfoRemoteSearchQuery::fromJson(QJsonObject source) {AlbumInfoRemoteSearchQuery instance; - instance->setFromJson(source, false); +AlbumInfoRemoteSearchQuery AlbumInfoRemoteSearchQuery::fromJson(QJsonObject source) { + AlbumInfoRemoteSearchQuery instance; + instance.setFromJson(source); return instance; } void AlbumInfoRemoteSearchQuery::setFromJson(QJsonObject source) { - m_searchInfo = fromJsonValue>(source["SearchInfo"]); - m_itemId = fromJsonValue(source["ItemId"]); - m_searchProviderName = fromJsonValue(source["SearchProviderName"]); - m_includeDisabledProviders = fromJsonValue(source["IncludeDisabledProviders"]); + m_searchInfo = Jellyfin::Support::fromJsonValue>(source["SearchInfo"]); + m_itemId = Jellyfin::Support::fromJsonValue(source["ItemId"]); + m_searchProviderName = Jellyfin::Support::fromJsonValue(source["SearchProviderName"]); + m_includeDisabledProviders = Jellyfin::Support::fromJsonValue(source["IncludeDisabledProviders"]); } QJsonObject AlbumInfoRemoteSearchQuery::toJson() { QJsonObject result; - result["SearchInfo"] = toJsonValue>(m_searchInfo); - result["ItemId"] = toJsonValue(m_itemId); - result["SearchProviderName"] = toJsonValue(m_searchProviderName); - result["IncludeDisabledProviders"] = toJsonValue(m_includeDisabledProviders); + result["SearchInfo"] = Jellyfin::Support::toJsonValue>(m_searchInfo); + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); + result["IncludeDisabledProviders"] = Jellyfin::Support::toJsonValue(m_includeDisabledProviders); return result; } @@ -79,6 +80,17 @@ void AlbumInfoRemoteSearchQuery::setIncludeDisabledProviders(bool newIncludeDisa m_includeDisabledProviders = newIncludeDisabledProviders; } +} // NS DTO + +namespace Support { + +using AlbumInfoRemoteSearchQuery = Jellyfin::DTO::AlbumInfoRemoteSearchQuery; + +template <> +AlbumInfoRemoteSearchQuery fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return AlbumInfoRemoteSearchQuery::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/allthememediaresult.cpp b/core/src/DTO/allthememediaresult.cpp index 748eb23..92bd8bc 100644 --- a/core/src/DTO/allthememediaresult.cpp +++ b/core/src/DTO/allthememediaresult.cpp @@ -32,26 +32,27 @@ namespace Jellyfin { namespace DTO { -AllThemeMediaResult::AllThemeMediaResult(QObject *parent) {} +AllThemeMediaResult::AllThemeMediaResult() {} -AllThemeMediaResult AllThemeMediaResult::fromJson(QJsonObject source) {AllThemeMediaResult instance; - instance->setFromJson(source, false); +AllThemeMediaResult AllThemeMediaResult::fromJson(QJsonObject source) { + AllThemeMediaResult instance; + instance.setFromJson(source); return instance; } void AllThemeMediaResult::setFromJson(QJsonObject source) { - m_themeVideosResult = fromJsonValue>(source["ThemeVideosResult"]); - m_themeSongsResult = fromJsonValue>(source["ThemeSongsResult"]); - m_soundtrackSongsResult = fromJsonValue>(source["SoundtrackSongsResult"]); + m_themeVideosResult = Jellyfin::Support::fromJsonValue>(source["ThemeVideosResult"]); + m_themeSongsResult = Jellyfin::Support::fromJsonValue>(source["ThemeSongsResult"]); + m_soundtrackSongsResult = Jellyfin::Support::fromJsonValue>(source["SoundtrackSongsResult"]); } QJsonObject AllThemeMediaResult::toJson() { QJsonObject result; - result["ThemeVideosResult"] = toJsonValue>(m_themeVideosResult); - result["ThemeSongsResult"] = toJsonValue>(m_themeSongsResult); - result["SoundtrackSongsResult"] = toJsonValue>(m_soundtrackSongsResult); + result["ThemeVideosResult"] = Jellyfin::Support::toJsonValue>(m_themeVideosResult); + result["ThemeSongsResult"] = Jellyfin::Support::toJsonValue>(m_themeSongsResult); + result["SoundtrackSongsResult"] = Jellyfin::Support::toJsonValue>(m_soundtrackSongsResult); return result; } @@ -72,6 +73,17 @@ void AllThemeMediaResult::setSoundtrackSongsResult(QSharedPointer +AllThemeMediaResult fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return AllThemeMediaResult::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/architecture.cpp b/core/src/DTO/architecture.cpp index 0b721e1..8f8cd84 100644 --- a/core/src/DTO/architecture.cpp +++ b/core/src/DTO/architecture.cpp @@ -34,5 +34,36 @@ namespace DTO { ArchitectureClass::ArchitectureClass() {} + +} // NS DTO + +namespace Support { + +using Architecture = Jellyfin::DTO::Architecture; + +template <> +Architecture fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return Architecture::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("X86")) { + return Architecture::X86; + } + if (str == QStringLiteral("X64")) { + return Architecture::X64; + } + if (str == QStringLiteral("Arm")) { + return Architecture::Arm; + } + if (str == QStringLiteral("Arm64")) { + return Architecture::Arm64; + } + if (str == QStringLiteral("Wasm")) { + return Architecture::Wasm; + } + + return Architecture::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/artistinfo.cpp b/core/src/DTO/artistinfo.cpp index 00cdb96..dd075eb 100644 --- a/core/src/DTO/artistinfo.cpp +++ b/core/src/DTO/artistinfo.cpp @@ -32,42 +32,43 @@ namespace Jellyfin { namespace DTO { -ArtistInfo::ArtistInfo(QObject *parent) {} +ArtistInfo::ArtistInfo() {} -ArtistInfo ArtistInfo::fromJson(QJsonObject source) {ArtistInfo instance; - instance->setFromJson(source, false); +ArtistInfo ArtistInfo::fromJson(QJsonObject source) { + ArtistInfo instance; + instance.setFromJson(source); return instance; } void ArtistInfo::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_path = fromJsonValue(source["Path"]); - m_metadataLanguage = fromJsonValue(source["MetadataLanguage"]); - m_metadataCountryCode = fromJsonValue(source["MetadataCountryCode"]); - m_providerIds = fromJsonValue(source["ProviderIds"]); - m_year = fromJsonValue(source["Year"]); - m_indexNumber = fromJsonValue(source["IndexNumber"]); - m_parentIndexNumber = fromJsonValue(source["ParentIndexNumber"]); - m_premiereDate = fromJsonValue(source["PremiereDate"]); - m_isAutomated = fromJsonValue(source["IsAutomated"]); - m_songInfos = fromJsonValue>>(source["SongInfos"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_path = Jellyfin::Support::fromJsonValue(source["Path"]); + m_metadataLanguage = Jellyfin::Support::fromJsonValue(source["MetadataLanguage"]); + m_metadataCountryCode = Jellyfin::Support::fromJsonValue(source["MetadataCountryCode"]); + m_providerIds = Jellyfin::Support::fromJsonValue(source["ProviderIds"]); + m_year = Jellyfin::Support::fromJsonValue(source["Year"]); + m_indexNumber = Jellyfin::Support::fromJsonValue(source["IndexNumber"]); + m_parentIndexNumber = Jellyfin::Support::fromJsonValue(source["ParentIndexNumber"]); + m_premiereDate = Jellyfin::Support::fromJsonValue(source["PremiereDate"]); + m_isAutomated = Jellyfin::Support::fromJsonValue(source["IsAutomated"]); + m_songInfos = Jellyfin::Support::fromJsonValue>>(source["SongInfos"]); } QJsonObject ArtistInfo::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Path"] = toJsonValue(m_path); - result["MetadataLanguage"] = toJsonValue(m_metadataLanguage); - result["MetadataCountryCode"] = toJsonValue(m_metadataCountryCode); - result["ProviderIds"] = toJsonValue(m_providerIds); - result["Year"] = toJsonValue(m_year); - result["IndexNumber"] = toJsonValue(m_indexNumber); - result["ParentIndexNumber"] = toJsonValue(m_parentIndexNumber); - result["PremiereDate"] = toJsonValue(m_premiereDate); - result["IsAutomated"] = toJsonValue(m_isAutomated); - result["SongInfos"] = toJsonValue>>(m_songInfos); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); + result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); + result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); + result["Year"] = Jellyfin::Support::toJsonValue(m_year); + result["IndexNumber"] = Jellyfin::Support::toJsonValue(m_indexNumber); + result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue(m_parentIndexNumber); + result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); + result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); + result["SongInfos"] = Jellyfin::Support::toJsonValue>>(m_songInfos); return result; } @@ -128,6 +129,17 @@ void ArtistInfo::setSongInfos(QList> newSongInfos) { m_songInfos = newSongInfos; } +} // NS DTO + +namespace Support { + +using ArtistInfo = Jellyfin::DTO::ArtistInfo; + +template <> +ArtistInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ArtistInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/artistinforemotesearchquery.cpp b/core/src/DTO/artistinforemotesearchquery.cpp index c86aa62..3241e97 100644 --- a/core/src/DTO/artistinforemotesearchquery.cpp +++ b/core/src/DTO/artistinforemotesearchquery.cpp @@ -32,28 +32,29 @@ namespace Jellyfin { namespace DTO { -ArtistInfoRemoteSearchQuery::ArtistInfoRemoteSearchQuery(QObject *parent) {} +ArtistInfoRemoteSearchQuery::ArtistInfoRemoteSearchQuery() {} -ArtistInfoRemoteSearchQuery ArtistInfoRemoteSearchQuery::fromJson(QJsonObject source) {ArtistInfoRemoteSearchQuery instance; - instance->setFromJson(source, false); +ArtistInfoRemoteSearchQuery ArtistInfoRemoteSearchQuery::fromJson(QJsonObject source) { + ArtistInfoRemoteSearchQuery instance; + instance.setFromJson(source); return instance; } void ArtistInfoRemoteSearchQuery::setFromJson(QJsonObject source) { - m_searchInfo = fromJsonValue>(source["SearchInfo"]); - m_itemId = fromJsonValue(source["ItemId"]); - m_searchProviderName = fromJsonValue(source["SearchProviderName"]); - m_includeDisabledProviders = fromJsonValue(source["IncludeDisabledProviders"]); + m_searchInfo = Jellyfin::Support::fromJsonValue>(source["SearchInfo"]); + m_itemId = Jellyfin::Support::fromJsonValue(source["ItemId"]); + m_searchProviderName = Jellyfin::Support::fromJsonValue(source["SearchProviderName"]); + m_includeDisabledProviders = Jellyfin::Support::fromJsonValue(source["IncludeDisabledProviders"]); } QJsonObject ArtistInfoRemoteSearchQuery::toJson() { QJsonObject result; - result["SearchInfo"] = toJsonValue>(m_searchInfo); - result["ItemId"] = toJsonValue(m_itemId); - result["SearchProviderName"] = toJsonValue(m_searchProviderName); - result["IncludeDisabledProviders"] = toJsonValue(m_includeDisabledProviders); + result["SearchInfo"] = Jellyfin::Support::toJsonValue>(m_searchInfo); + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); + result["IncludeDisabledProviders"] = Jellyfin::Support::toJsonValue(m_includeDisabledProviders); return result; } @@ -79,6 +80,17 @@ void ArtistInfoRemoteSearchQuery::setIncludeDisabledProviders(bool newIncludeDis m_includeDisabledProviders = newIncludeDisabledProviders; } +} // NS DTO + +namespace Support { + +using ArtistInfoRemoteSearchQuery = Jellyfin::DTO::ArtistInfoRemoteSearchQuery; + +template <> +ArtistInfoRemoteSearchQuery fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ArtistInfoRemoteSearchQuery::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/authenticateuserbyname.cpp b/core/src/DTO/authenticateuserbyname.cpp index 89dbb06..608cba1 100644 --- a/core/src/DTO/authenticateuserbyname.cpp +++ b/core/src/DTO/authenticateuserbyname.cpp @@ -32,26 +32,27 @@ namespace Jellyfin { namespace DTO { -AuthenticateUserByName::AuthenticateUserByName(QObject *parent) {} +AuthenticateUserByName::AuthenticateUserByName() {} -AuthenticateUserByName AuthenticateUserByName::fromJson(QJsonObject source) {AuthenticateUserByName instance; - instance->setFromJson(source, false); +AuthenticateUserByName AuthenticateUserByName::fromJson(QJsonObject source) { + AuthenticateUserByName instance; + instance.setFromJson(source); return instance; } void AuthenticateUserByName::setFromJson(QJsonObject source) { - m_username = fromJsonValue(source["Username"]); - m_pw = fromJsonValue(source["Pw"]); - m_password = fromJsonValue(source["Password"]); + m_username = Jellyfin::Support::fromJsonValue(source["Username"]); + m_pw = Jellyfin::Support::fromJsonValue(source["Pw"]); + m_password = Jellyfin::Support::fromJsonValue(source["Password"]); } QJsonObject AuthenticateUserByName::toJson() { QJsonObject result; - result["Username"] = toJsonValue(m_username); - result["Pw"] = toJsonValue(m_pw); - result["Password"] = toJsonValue(m_password); + result["Username"] = Jellyfin::Support::toJsonValue(m_username); + result["Pw"] = Jellyfin::Support::toJsonValue(m_pw); + result["Password"] = Jellyfin::Support::toJsonValue(m_password); return result; } @@ -72,6 +73,17 @@ void AuthenticateUserByName::setPassword(QString newPassword) { m_password = newPassword; } +} // NS DTO + +namespace Support { + +using AuthenticateUserByName = Jellyfin::DTO::AuthenticateUserByName; + +template <> +AuthenticateUserByName fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return AuthenticateUserByName::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/authenticationinfo.cpp b/core/src/DTO/authenticationinfo.cpp index 0ea7234..a9dfda3 100644 --- a/core/src/DTO/authenticationinfo.cpp +++ b/core/src/DTO/authenticationinfo.cpp @@ -32,44 +32,45 @@ namespace Jellyfin { namespace DTO { -AuthenticationInfo::AuthenticationInfo(QObject *parent) {} +AuthenticationInfo::AuthenticationInfo() {} -AuthenticationInfo AuthenticationInfo::fromJson(QJsonObject source) {AuthenticationInfo instance; - instance->setFromJson(source, false); +AuthenticationInfo AuthenticationInfo::fromJson(QJsonObject source) { + AuthenticationInfo instance; + instance.setFromJson(source); return instance; } void AuthenticationInfo::setFromJson(QJsonObject source) { - m_jellyfinId = fromJsonValue(source["Id"]); - m_accessToken = fromJsonValue(source["AccessToken"]); - m_deviceId = fromJsonValue(source["DeviceId"]); - m_appName = fromJsonValue(source["AppName"]); - m_appVersion = fromJsonValue(source["AppVersion"]); - m_deviceName = fromJsonValue(source["DeviceName"]); - m_userId = fromJsonValue(source["UserId"]); - m_isActive = fromJsonValue(source["IsActive"]); - m_dateCreated = fromJsonValue(source["DateCreated"]); - m_dateRevoked = fromJsonValue(source["DateRevoked"]); - m_dateLastActivity = fromJsonValue(source["DateLastActivity"]); - m_userName = fromJsonValue(source["UserName"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); + m_accessToken = Jellyfin::Support::fromJsonValue(source["AccessToken"]); + m_deviceId = Jellyfin::Support::fromJsonValue(source["DeviceId"]); + m_appName = Jellyfin::Support::fromJsonValue(source["AppName"]); + m_appVersion = Jellyfin::Support::fromJsonValue(source["AppVersion"]); + m_deviceName = Jellyfin::Support::fromJsonValue(source["DeviceName"]); + m_userId = Jellyfin::Support::fromJsonValue(source["UserId"]); + m_isActive = Jellyfin::Support::fromJsonValue(source["IsActive"]); + m_dateCreated = Jellyfin::Support::fromJsonValue(source["DateCreated"]); + m_dateRevoked = Jellyfin::Support::fromJsonValue(source["DateRevoked"]); + m_dateLastActivity = Jellyfin::Support::fromJsonValue(source["DateLastActivity"]); + m_userName = Jellyfin::Support::fromJsonValue(source["UserName"]); } QJsonObject AuthenticationInfo::toJson() { QJsonObject result; - result["Id"] = toJsonValue(m_jellyfinId); - result["AccessToken"] = toJsonValue(m_accessToken); - result["DeviceId"] = toJsonValue(m_deviceId); - result["AppName"] = toJsonValue(m_appName); - result["AppVersion"] = toJsonValue(m_appVersion); - result["DeviceName"] = toJsonValue(m_deviceName); - result["UserId"] = toJsonValue(m_userId); - result["IsActive"] = toJsonValue(m_isActive); - result["DateCreated"] = toJsonValue(m_dateCreated); - result["DateRevoked"] = toJsonValue(m_dateRevoked); - result["DateLastActivity"] = toJsonValue(m_dateLastActivity); - result["UserName"] = toJsonValue(m_userName); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["AccessToken"] = Jellyfin::Support::toJsonValue(m_accessToken); + result["DeviceId"] = Jellyfin::Support::toJsonValue(m_deviceId); + result["AppName"] = Jellyfin::Support::toJsonValue(m_appName); + result["AppVersion"] = Jellyfin::Support::toJsonValue(m_appVersion); + result["DeviceName"] = Jellyfin::Support::toJsonValue(m_deviceName); + result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); + result["IsActive"] = Jellyfin::Support::toJsonValue(m_isActive); + result["DateCreated"] = Jellyfin::Support::toJsonValue(m_dateCreated); + result["DateRevoked"] = Jellyfin::Support::toJsonValue(m_dateRevoked); + result["DateLastActivity"] = Jellyfin::Support::toJsonValue(m_dateLastActivity); + result["UserName"] = Jellyfin::Support::toJsonValue(m_userName); return result; } @@ -135,6 +136,17 @@ void AuthenticationInfo::setUserName(QString newUserName) { m_userName = newUserName; } +} // NS DTO + +namespace Support { + +using AuthenticationInfo = Jellyfin::DTO::AuthenticationInfo; + +template <> +AuthenticationInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return AuthenticationInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/authenticationinfoqueryresult.cpp b/core/src/DTO/authenticationinfoqueryresult.cpp index c0dd616..6156a00 100644 --- a/core/src/DTO/authenticationinfoqueryresult.cpp +++ b/core/src/DTO/authenticationinfoqueryresult.cpp @@ -32,26 +32,27 @@ namespace Jellyfin { namespace DTO { -AuthenticationInfoQueryResult::AuthenticationInfoQueryResult(QObject *parent) {} +AuthenticationInfoQueryResult::AuthenticationInfoQueryResult() {} -AuthenticationInfoQueryResult AuthenticationInfoQueryResult::fromJson(QJsonObject source) {AuthenticationInfoQueryResult instance; - instance->setFromJson(source, false); +AuthenticationInfoQueryResult AuthenticationInfoQueryResult::fromJson(QJsonObject source) { + AuthenticationInfoQueryResult instance; + instance.setFromJson(source); return instance; } void AuthenticationInfoQueryResult::setFromJson(QJsonObject source) { - m_items = fromJsonValue>>(source["Items"]); - m_totalRecordCount = fromJsonValue(source["TotalRecordCount"]); - m_startIndex = fromJsonValue(source["StartIndex"]); + m_items = Jellyfin::Support::fromJsonValue>>(source["Items"]); + m_totalRecordCount = Jellyfin::Support::fromJsonValue(source["TotalRecordCount"]); + m_startIndex = Jellyfin::Support::fromJsonValue(source["StartIndex"]); } QJsonObject AuthenticationInfoQueryResult::toJson() { QJsonObject result; - result["Items"] = toJsonValue>>(m_items); - result["TotalRecordCount"] = toJsonValue(m_totalRecordCount); - result["StartIndex"] = toJsonValue(m_startIndex); + result["Items"] = Jellyfin::Support::toJsonValue>>(m_items); + result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); + result["StartIndex"] = Jellyfin::Support::toJsonValue(m_startIndex); return result; } @@ -72,6 +73,17 @@ void AuthenticationInfoQueryResult::setStartIndex(qint32 newStartIndex) { m_startIndex = newStartIndex; } +} // NS DTO + +namespace Support { + +using AuthenticationInfoQueryResult = Jellyfin::DTO::AuthenticationInfoQueryResult; + +template <> +AuthenticationInfoQueryResult fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return AuthenticationInfoQueryResult::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/authenticationresult.cpp b/core/src/DTO/authenticationresult.cpp index efbeaf2..f03a822 100644 --- a/core/src/DTO/authenticationresult.cpp +++ b/core/src/DTO/authenticationresult.cpp @@ -32,28 +32,29 @@ namespace Jellyfin { namespace DTO { -AuthenticationResult::AuthenticationResult(QObject *parent) {} +AuthenticationResult::AuthenticationResult() {} -AuthenticationResult AuthenticationResult::fromJson(QJsonObject source) {AuthenticationResult instance; - instance->setFromJson(source, false); +AuthenticationResult AuthenticationResult::fromJson(QJsonObject source) { + AuthenticationResult instance; + instance.setFromJson(source); return instance; } void AuthenticationResult::setFromJson(QJsonObject source) { - m_user = fromJsonValue>(source["User"]); - m_sessionInfo = fromJsonValue>(source["SessionInfo"]); - m_accessToken = fromJsonValue(source["AccessToken"]); - m_serverId = fromJsonValue(source["ServerId"]); + m_user = Jellyfin::Support::fromJsonValue>(source["User"]); + m_sessionInfo = Jellyfin::Support::fromJsonValue>(source["SessionInfo"]); + m_accessToken = Jellyfin::Support::fromJsonValue(source["AccessToken"]); + m_serverId = Jellyfin::Support::fromJsonValue(source["ServerId"]); } QJsonObject AuthenticationResult::toJson() { QJsonObject result; - result["User"] = toJsonValue>(m_user); - result["SessionInfo"] = toJsonValue>(m_sessionInfo); - result["AccessToken"] = toJsonValue(m_accessToken); - result["ServerId"] = toJsonValue(m_serverId); + result["User"] = Jellyfin::Support::toJsonValue>(m_user); + result["SessionInfo"] = Jellyfin::Support::toJsonValue>(m_sessionInfo); + result["AccessToken"] = Jellyfin::Support::toJsonValue(m_accessToken); + result["ServerId"] = Jellyfin::Support::toJsonValue(m_serverId); return result; } @@ -79,6 +80,17 @@ void AuthenticationResult::setServerId(QString newServerId) { m_serverId = newServerId; } +} // NS DTO + +namespace Support { + +using AuthenticationResult = Jellyfin::DTO::AuthenticationResult; + +template <> +AuthenticationResult fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return AuthenticationResult::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/baseitem.cpp b/core/src/DTO/baseitem.cpp index 4aca154..e2e5fb0 100644 --- a/core/src/DTO/baseitem.cpp +++ b/core/src/DTO/baseitem.cpp @@ -32,42 +32,43 @@ namespace Jellyfin { namespace DTO { -BaseItem::BaseItem(QObject *parent) {} +BaseItem::BaseItem() {} -BaseItem BaseItem::fromJson(QJsonObject source) {BaseItem instance; - instance->setFromJson(source, false); +BaseItem BaseItem::fromJson(QJsonObject source) { + BaseItem instance; + instance.setFromJson(source); return instance; } void BaseItem::setFromJson(QJsonObject source) { - m_size = fromJsonValue(source["Size"]); - m_container = fromJsonValue(source["Container"]); - m_dateLastSaved = fromJsonValue(source["DateLastSaved"]); - m_remoteTrailers = fromJsonValue>>(source["RemoteTrailers"]); - m_isHD = fromJsonValue(source["IsHD"]); - m_isShortcut = fromJsonValue(source["IsShortcut"]); - m_shortcutPath = fromJsonValue(source["ShortcutPath"]); - m_width = fromJsonValue(source["Width"]); - m_height = fromJsonValue(source["Height"]); - m_extraIds = fromJsonValue>(source["ExtraIds"]); - m_supportsExternalTransfer = fromJsonValue(source["SupportsExternalTransfer"]); + m_size = Jellyfin::Support::fromJsonValue(source["Size"]); + m_container = Jellyfin::Support::fromJsonValue(source["Container"]); + m_dateLastSaved = Jellyfin::Support::fromJsonValue(source["DateLastSaved"]); + m_remoteTrailers = Jellyfin::Support::fromJsonValue>>(source["RemoteTrailers"]); + m_isHD = Jellyfin::Support::fromJsonValue(source["IsHD"]); + m_isShortcut = Jellyfin::Support::fromJsonValue(source["IsShortcut"]); + m_shortcutPath = Jellyfin::Support::fromJsonValue(source["ShortcutPath"]); + m_width = Jellyfin::Support::fromJsonValue(source["Width"]); + m_height = Jellyfin::Support::fromJsonValue(source["Height"]); + m_extraIds = Jellyfin::Support::fromJsonValue>(source["ExtraIds"]); + m_supportsExternalTransfer = Jellyfin::Support::fromJsonValue(source["SupportsExternalTransfer"]); } QJsonObject BaseItem::toJson() { QJsonObject result; - result["Size"] = toJsonValue(m_size); - result["Container"] = toJsonValue(m_container); - result["DateLastSaved"] = toJsonValue(m_dateLastSaved); - result["RemoteTrailers"] = toJsonValue>>(m_remoteTrailers); - result["IsHD"] = toJsonValue(m_isHD); - result["IsShortcut"] = toJsonValue(m_isShortcut); - result["ShortcutPath"] = toJsonValue(m_shortcutPath); - result["Width"] = toJsonValue(m_width); - result["Height"] = toJsonValue(m_height); - result["ExtraIds"] = toJsonValue>(m_extraIds); - result["SupportsExternalTransfer"] = toJsonValue(m_supportsExternalTransfer); + result["Size"] = Jellyfin::Support::toJsonValue(m_size); + result["Container"] = Jellyfin::Support::toJsonValue(m_container); + result["DateLastSaved"] = Jellyfin::Support::toJsonValue(m_dateLastSaved); + result["RemoteTrailers"] = Jellyfin::Support::toJsonValue>>(m_remoteTrailers); + result["IsHD"] = Jellyfin::Support::toJsonValue(m_isHD); + result["IsShortcut"] = Jellyfin::Support::toJsonValue(m_isShortcut); + result["ShortcutPath"] = Jellyfin::Support::toJsonValue(m_shortcutPath); + result["Width"] = Jellyfin::Support::toJsonValue(m_width); + result["Height"] = Jellyfin::Support::toJsonValue(m_height); + result["ExtraIds"] = Jellyfin::Support::toJsonValue>(m_extraIds); + result["SupportsExternalTransfer"] = Jellyfin::Support::toJsonValue(m_supportsExternalTransfer); return result; } @@ -128,6 +129,17 @@ void BaseItem::setSupportsExternalTransfer(bool newSupportsExternalTransfer) { m_supportsExternalTransfer = newSupportsExternalTransfer; } +} // NS DTO + +namespace Support { + +using BaseItem = Jellyfin::DTO::BaseItem; + +template <> +BaseItem fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return BaseItem::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/baseitemdto.cpp b/core/src/DTO/baseitemdto.cpp index fbe185c..dca876e 100644 --- a/core/src/DTO/baseitemdto.cpp +++ b/core/src/DTO/baseitemdto.cpp @@ -32,322 +32,323 @@ namespace Jellyfin { namespace DTO { -BaseItemDto::BaseItemDto(QObject *parent) {} +BaseItemDto::BaseItemDto() {} -BaseItemDto BaseItemDto::fromJson(QJsonObject source) {BaseItemDto instance; - instance->setFromJson(source, false); +BaseItemDto BaseItemDto::fromJson(QJsonObject source) { + BaseItemDto instance; + instance.setFromJson(source); return instance; } void BaseItemDto::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_originalTitle = fromJsonValue(source["OriginalTitle"]); - m_serverId = fromJsonValue(source["ServerId"]); - m_jellyfinId = fromJsonValue(source["Id"]); - m_etag = fromJsonValue(source["Etag"]); - m_sourceType = fromJsonValue(source["SourceType"]); - m_playlistItemId = fromJsonValue(source["PlaylistItemId"]); - m_dateCreated = fromJsonValue(source["DateCreated"]); - m_dateLastMediaAdded = fromJsonValue(source["DateLastMediaAdded"]); - m_extraType = fromJsonValue(source["ExtraType"]); - m_airsBeforeSeasonNumber = fromJsonValue(source["AirsBeforeSeasonNumber"]); - m_airsAfterSeasonNumber = fromJsonValue(source["AirsAfterSeasonNumber"]); - m_airsBeforeEpisodeNumber = fromJsonValue(source["AirsBeforeEpisodeNumber"]); - m_canDelete = fromJsonValue(source["CanDelete"]); - m_canDownload = fromJsonValue(source["CanDownload"]); - m_hasSubtitles = fromJsonValue(source["HasSubtitles"]); - m_preferredMetadataLanguage = fromJsonValue(source["PreferredMetadataLanguage"]); - m_preferredMetadataCountryCode = fromJsonValue(source["PreferredMetadataCountryCode"]); - m_supportsSync = fromJsonValue(source["SupportsSync"]); - m_container = fromJsonValue(source["Container"]); - m_sortName = fromJsonValue(source["SortName"]); - m_forcedSortName = fromJsonValue(source["ForcedSortName"]); - m_video3DFormat = fromJsonValue(source["Video3DFormat"]); - m_premiereDate = fromJsonValue(source["PremiereDate"]); - m_externalUrls = fromJsonValue>>(source["ExternalUrls"]); - m_mediaSources = fromJsonValue>>(source["MediaSources"]); - m_criticRating = fromJsonValue(source["CriticRating"]); - m_productionLocations = fromJsonValue(source["ProductionLocations"]); - m_path = fromJsonValue(source["Path"]); - m_enableMediaSourceDisplay = fromJsonValue(source["EnableMediaSourceDisplay"]); - m_officialRating = fromJsonValue(source["OfficialRating"]); - m_customRating = fromJsonValue(source["CustomRating"]); - m_channelId = fromJsonValue(source["ChannelId"]); - m_channelName = fromJsonValue(source["ChannelName"]); - m_overview = fromJsonValue(source["Overview"]); - m_taglines = fromJsonValue(source["Taglines"]); - m_genres = fromJsonValue(source["Genres"]); - m_communityRating = fromJsonValue(source["CommunityRating"]); - m_cumulativeRunTimeTicks = fromJsonValue(source["CumulativeRunTimeTicks"]); - m_runTimeTicks = fromJsonValue(source["RunTimeTicks"]); - m_playAccess = fromJsonValue(source["PlayAccess"]); - m_aspectRatio = fromJsonValue(source["AspectRatio"]); - m_productionYear = fromJsonValue(source["ProductionYear"]); - m_isPlaceHolder = fromJsonValue(source["IsPlaceHolder"]); - m_number = fromJsonValue(source["Number"]); - m_channelNumber = fromJsonValue(source["ChannelNumber"]); - m_indexNumber = fromJsonValue(source["IndexNumber"]); - m_indexNumberEnd = fromJsonValue(source["IndexNumberEnd"]); - m_parentIndexNumber = fromJsonValue(source["ParentIndexNumber"]); - m_remoteTrailers = fromJsonValue>>(source["RemoteTrailers"]); - m_providerIds = fromJsonValue(source["ProviderIds"]); - m_isHD = fromJsonValue(source["IsHD"]); - m_isFolder = fromJsonValue(source["IsFolder"]); - m_parentId = fromJsonValue(source["ParentId"]); - m_type = fromJsonValue(source["Type"]); - m_people = fromJsonValue>>(source["People"]); - m_studios = fromJsonValue>>(source["Studios"]); - m_genreItems = fromJsonValue>>(source["GenreItems"]); - m_parentLogoItemId = fromJsonValue(source["ParentLogoItemId"]); - m_parentBackdropItemId = fromJsonValue(source["ParentBackdropItemId"]); - m_parentBackdropImageTags = fromJsonValue(source["ParentBackdropImageTags"]); - m_localTrailerCount = fromJsonValue(source["LocalTrailerCount"]); - m_userData = fromJsonValue>(source["UserData"]); - m_recursiveItemCount = fromJsonValue(source["RecursiveItemCount"]); - m_childCount = fromJsonValue(source["ChildCount"]); - m_seriesName = fromJsonValue(source["SeriesName"]); - m_seriesId = fromJsonValue(source["SeriesId"]); - m_seasonId = fromJsonValue(source["SeasonId"]); - m_specialFeatureCount = fromJsonValue(source["SpecialFeatureCount"]); - m_displayPreferencesId = fromJsonValue(source["DisplayPreferencesId"]); - m_status = fromJsonValue(source["Status"]); - m_airTime = fromJsonValue(source["AirTime"]); - m_airDays = fromJsonValue>(source["AirDays"]); - m_tags = fromJsonValue(source["Tags"]); - m_primaryImageAspectRatio = fromJsonValue(source["PrimaryImageAspectRatio"]); - m_artists = fromJsonValue(source["Artists"]); - m_artistItems = fromJsonValue>>(source["ArtistItems"]); - m_album = fromJsonValue(source["Album"]); - m_collectionType = fromJsonValue(source["CollectionType"]); - m_displayOrder = fromJsonValue(source["DisplayOrder"]); - m_albumId = fromJsonValue(source["AlbumId"]); - m_albumPrimaryImageTag = fromJsonValue(source["AlbumPrimaryImageTag"]); - m_seriesPrimaryImageTag = fromJsonValue(source["SeriesPrimaryImageTag"]); - m_albumArtist = fromJsonValue(source["AlbumArtist"]); - m_albumArtists = fromJsonValue>>(source["AlbumArtists"]); - m_seasonName = fromJsonValue(source["SeasonName"]); - m_mediaStreams = fromJsonValue>>(source["MediaStreams"]); - m_videoType = fromJsonValue(source["VideoType"]); - m_partCount = fromJsonValue(source["PartCount"]); - m_mediaSourceCount = fromJsonValue(source["MediaSourceCount"]); - m_imageTags = fromJsonValue(source["ImageTags"]); - m_backdropImageTags = fromJsonValue(source["BackdropImageTags"]); - m_screenshotImageTags = fromJsonValue(source["ScreenshotImageTags"]); - m_parentLogoImageTag = fromJsonValue(source["ParentLogoImageTag"]); - m_parentArtItemId = fromJsonValue(source["ParentArtItemId"]); - m_parentArtImageTag = fromJsonValue(source["ParentArtImageTag"]); - m_seriesThumbImageTag = fromJsonValue(source["SeriesThumbImageTag"]); - m_imageBlurHashes = fromJsonValue(source["ImageBlurHashes"]); - m_seriesStudio = fromJsonValue(source["SeriesStudio"]); - m_parentThumbItemId = fromJsonValue(source["ParentThumbItemId"]); - m_parentThumbImageTag = fromJsonValue(source["ParentThumbImageTag"]); - m_parentPrimaryImageItemId = fromJsonValue(source["ParentPrimaryImageItemId"]); - m_parentPrimaryImageTag = fromJsonValue(source["ParentPrimaryImageTag"]); - m_chapters = fromJsonValue>>(source["Chapters"]); - m_locationType = fromJsonValue(source["LocationType"]); - m_isoType = fromJsonValue(source["IsoType"]); - m_mediaType = fromJsonValue(source["MediaType"]); - m_endDate = fromJsonValue(source["EndDate"]); - m_lockedFields = fromJsonValue>(source["LockedFields"]); - m_trailerCount = fromJsonValue(source["TrailerCount"]); - m_movieCount = fromJsonValue(source["MovieCount"]); - m_seriesCount = fromJsonValue(source["SeriesCount"]); - m_programCount = fromJsonValue(source["ProgramCount"]); - m_episodeCount = fromJsonValue(source["EpisodeCount"]); - m_songCount = fromJsonValue(source["SongCount"]); - m_albumCount = fromJsonValue(source["AlbumCount"]); - m_artistCount = fromJsonValue(source["ArtistCount"]); - m_musicVideoCount = fromJsonValue(source["MusicVideoCount"]); - m_lockData = fromJsonValue(source["LockData"]); - m_width = fromJsonValue(source["Width"]); - m_height = fromJsonValue(source["Height"]); - m_cameraMake = fromJsonValue(source["CameraMake"]); - m_cameraModel = fromJsonValue(source["CameraModel"]); - m_software = fromJsonValue(source["Software"]); - m_exposureTime = fromJsonValue(source["ExposureTime"]); - m_focalLength = fromJsonValue(source["FocalLength"]); - m_imageOrientation = fromJsonValue(source["ImageOrientation"]); - m_aperture = fromJsonValue(source["Aperture"]); - m_shutterSpeed = fromJsonValue(source["ShutterSpeed"]); - m_latitude = fromJsonValue(source["Latitude"]); - m_longitude = fromJsonValue(source["Longitude"]); - m_altitude = fromJsonValue(source["Altitude"]); - m_isoSpeedRating = fromJsonValue(source["IsoSpeedRating"]); - m_seriesTimerId = fromJsonValue(source["SeriesTimerId"]); - m_programId = fromJsonValue(source["ProgramId"]); - m_channelPrimaryImageTag = fromJsonValue(source["ChannelPrimaryImageTag"]); - m_startDate = fromJsonValue(source["StartDate"]); - m_completionPercentage = fromJsonValue(source["CompletionPercentage"]); - m_isRepeat = fromJsonValue(source["IsRepeat"]); - m_episodeTitle = fromJsonValue(source["EpisodeTitle"]); - m_channelType = fromJsonValue(source["ChannelType"]); - m_audio = fromJsonValue(source["Audio"]); - m_isMovie = fromJsonValue(source["IsMovie"]); - m_isSports = fromJsonValue(source["IsSports"]); - m_isSeries = fromJsonValue(source["IsSeries"]); - m_isLive = fromJsonValue(source["IsLive"]); - m_isNews = fromJsonValue(source["IsNews"]); - m_isKids = fromJsonValue(source["IsKids"]); - m_isPremiere = fromJsonValue(source["IsPremiere"]); - m_timerId = fromJsonValue(source["TimerId"]); - m_currentProgram = fromJsonValue>(source["CurrentProgram"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_originalTitle = Jellyfin::Support::fromJsonValue(source["OriginalTitle"]); + m_serverId = Jellyfin::Support::fromJsonValue(source["ServerId"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); + m_etag = Jellyfin::Support::fromJsonValue(source["Etag"]); + m_sourceType = Jellyfin::Support::fromJsonValue(source["SourceType"]); + m_playlistItemId = Jellyfin::Support::fromJsonValue(source["PlaylistItemId"]); + m_dateCreated = Jellyfin::Support::fromJsonValue(source["DateCreated"]); + m_dateLastMediaAdded = Jellyfin::Support::fromJsonValue(source["DateLastMediaAdded"]); + m_extraType = Jellyfin::Support::fromJsonValue(source["ExtraType"]); + m_airsBeforeSeasonNumber = Jellyfin::Support::fromJsonValue(source["AirsBeforeSeasonNumber"]); + m_airsAfterSeasonNumber = Jellyfin::Support::fromJsonValue(source["AirsAfterSeasonNumber"]); + m_airsBeforeEpisodeNumber = Jellyfin::Support::fromJsonValue(source["AirsBeforeEpisodeNumber"]); + m_canDelete = Jellyfin::Support::fromJsonValue(source["CanDelete"]); + m_canDownload = Jellyfin::Support::fromJsonValue(source["CanDownload"]); + m_hasSubtitles = Jellyfin::Support::fromJsonValue(source["HasSubtitles"]); + m_preferredMetadataLanguage = Jellyfin::Support::fromJsonValue(source["PreferredMetadataLanguage"]); + m_preferredMetadataCountryCode = Jellyfin::Support::fromJsonValue(source["PreferredMetadataCountryCode"]); + m_supportsSync = Jellyfin::Support::fromJsonValue(source["SupportsSync"]); + m_container = Jellyfin::Support::fromJsonValue(source["Container"]); + m_sortName = Jellyfin::Support::fromJsonValue(source["SortName"]); + m_forcedSortName = Jellyfin::Support::fromJsonValue(source["ForcedSortName"]); + m_video3DFormat = Jellyfin::Support::fromJsonValue(source["Video3DFormat"]); + m_premiereDate = Jellyfin::Support::fromJsonValue(source["PremiereDate"]); + m_externalUrls = Jellyfin::Support::fromJsonValue>>(source["ExternalUrls"]); + m_mediaSources = Jellyfin::Support::fromJsonValue>>(source["MediaSources"]); + m_criticRating = Jellyfin::Support::fromJsonValue(source["CriticRating"]); + m_productionLocations = Jellyfin::Support::fromJsonValue(source["ProductionLocations"]); + m_path = Jellyfin::Support::fromJsonValue(source["Path"]); + m_enableMediaSourceDisplay = Jellyfin::Support::fromJsonValue(source["EnableMediaSourceDisplay"]); + m_officialRating = Jellyfin::Support::fromJsonValue(source["OfficialRating"]); + m_customRating = Jellyfin::Support::fromJsonValue(source["CustomRating"]); + m_channelId = Jellyfin::Support::fromJsonValue(source["ChannelId"]); + m_channelName = Jellyfin::Support::fromJsonValue(source["ChannelName"]); + m_overview = Jellyfin::Support::fromJsonValue(source["Overview"]); + m_taglines = Jellyfin::Support::fromJsonValue(source["Taglines"]); + m_genres = Jellyfin::Support::fromJsonValue(source["Genres"]); + m_communityRating = Jellyfin::Support::fromJsonValue(source["CommunityRating"]); + m_cumulativeRunTimeTicks = Jellyfin::Support::fromJsonValue(source["CumulativeRunTimeTicks"]); + m_runTimeTicks = Jellyfin::Support::fromJsonValue(source["RunTimeTicks"]); + m_playAccess = Jellyfin::Support::fromJsonValue(source["PlayAccess"]); + m_aspectRatio = Jellyfin::Support::fromJsonValue(source["AspectRatio"]); + m_productionYear = Jellyfin::Support::fromJsonValue(source["ProductionYear"]); + m_isPlaceHolder = Jellyfin::Support::fromJsonValue(source["IsPlaceHolder"]); + m_number = Jellyfin::Support::fromJsonValue(source["Number"]); + m_channelNumber = Jellyfin::Support::fromJsonValue(source["ChannelNumber"]); + m_indexNumber = Jellyfin::Support::fromJsonValue(source["IndexNumber"]); + m_indexNumberEnd = Jellyfin::Support::fromJsonValue(source["IndexNumberEnd"]); + m_parentIndexNumber = Jellyfin::Support::fromJsonValue(source["ParentIndexNumber"]); + m_remoteTrailers = Jellyfin::Support::fromJsonValue>>(source["RemoteTrailers"]); + m_providerIds = Jellyfin::Support::fromJsonValue(source["ProviderIds"]); + m_isHD = Jellyfin::Support::fromJsonValue(source["IsHD"]); + m_isFolder = Jellyfin::Support::fromJsonValue(source["IsFolder"]); + m_parentId = Jellyfin::Support::fromJsonValue(source["ParentId"]); + m_type = Jellyfin::Support::fromJsonValue(source["Type"]); + m_people = Jellyfin::Support::fromJsonValue>>(source["People"]); + m_studios = Jellyfin::Support::fromJsonValue>>(source["Studios"]); + m_genreItems = Jellyfin::Support::fromJsonValue>>(source["GenreItems"]); + m_parentLogoItemId = Jellyfin::Support::fromJsonValue(source["ParentLogoItemId"]); + m_parentBackdropItemId = Jellyfin::Support::fromJsonValue(source["ParentBackdropItemId"]); + m_parentBackdropImageTags = Jellyfin::Support::fromJsonValue(source["ParentBackdropImageTags"]); + m_localTrailerCount = Jellyfin::Support::fromJsonValue(source["LocalTrailerCount"]); + m_userData = Jellyfin::Support::fromJsonValue>(source["UserData"]); + m_recursiveItemCount = Jellyfin::Support::fromJsonValue(source["RecursiveItemCount"]); + m_childCount = Jellyfin::Support::fromJsonValue(source["ChildCount"]); + m_seriesName = Jellyfin::Support::fromJsonValue(source["SeriesName"]); + m_seriesId = Jellyfin::Support::fromJsonValue(source["SeriesId"]); + m_seasonId = Jellyfin::Support::fromJsonValue(source["SeasonId"]); + m_specialFeatureCount = Jellyfin::Support::fromJsonValue(source["SpecialFeatureCount"]); + m_displayPreferencesId = Jellyfin::Support::fromJsonValue(source["DisplayPreferencesId"]); + m_status = Jellyfin::Support::fromJsonValue(source["Status"]); + m_airTime = Jellyfin::Support::fromJsonValue(source["AirTime"]); + m_airDays = Jellyfin::Support::fromJsonValue>(source["AirDays"]); + m_tags = Jellyfin::Support::fromJsonValue(source["Tags"]); + m_primaryImageAspectRatio = Jellyfin::Support::fromJsonValue(source["PrimaryImageAspectRatio"]); + m_artists = Jellyfin::Support::fromJsonValue(source["Artists"]); + m_artistItems = Jellyfin::Support::fromJsonValue>>(source["ArtistItems"]); + m_album = Jellyfin::Support::fromJsonValue(source["Album"]); + m_collectionType = Jellyfin::Support::fromJsonValue(source["CollectionType"]); + m_displayOrder = Jellyfin::Support::fromJsonValue(source["DisplayOrder"]); + m_albumId = Jellyfin::Support::fromJsonValue(source["AlbumId"]); + m_albumPrimaryImageTag = Jellyfin::Support::fromJsonValue(source["AlbumPrimaryImageTag"]); + m_seriesPrimaryImageTag = Jellyfin::Support::fromJsonValue(source["SeriesPrimaryImageTag"]); + m_albumArtist = Jellyfin::Support::fromJsonValue(source["AlbumArtist"]); + m_albumArtists = Jellyfin::Support::fromJsonValue>>(source["AlbumArtists"]); + m_seasonName = Jellyfin::Support::fromJsonValue(source["SeasonName"]); + m_mediaStreams = Jellyfin::Support::fromJsonValue>>(source["MediaStreams"]); + m_videoType = Jellyfin::Support::fromJsonValue(source["VideoType"]); + m_partCount = Jellyfin::Support::fromJsonValue(source["PartCount"]); + m_mediaSourceCount = Jellyfin::Support::fromJsonValue(source["MediaSourceCount"]); + m_imageTags = Jellyfin::Support::fromJsonValue(source["ImageTags"]); + m_backdropImageTags = Jellyfin::Support::fromJsonValue(source["BackdropImageTags"]); + m_screenshotImageTags = Jellyfin::Support::fromJsonValue(source["ScreenshotImageTags"]); + m_parentLogoImageTag = Jellyfin::Support::fromJsonValue(source["ParentLogoImageTag"]); + m_parentArtItemId = Jellyfin::Support::fromJsonValue(source["ParentArtItemId"]); + m_parentArtImageTag = Jellyfin::Support::fromJsonValue(source["ParentArtImageTag"]); + m_seriesThumbImageTag = Jellyfin::Support::fromJsonValue(source["SeriesThumbImageTag"]); + m_imageBlurHashes = Jellyfin::Support::fromJsonValue(source["ImageBlurHashes"]); + m_seriesStudio = Jellyfin::Support::fromJsonValue(source["SeriesStudio"]); + m_parentThumbItemId = Jellyfin::Support::fromJsonValue(source["ParentThumbItemId"]); + m_parentThumbImageTag = Jellyfin::Support::fromJsonValue(source["ParentThumbImageTag"]); + m_parentPrimaryImageItemId = Jellyfin::Support::fromJsonValue(source["ParentPrimaryImageItemId"]); + m_parentPrimaryImageTag = Jellyfin::Support::fromJsonValue(source["ParentPrimaryImageTag"]); + m_chapters = Jellyfin::Support::fromJsonValue>>(source["Chapters"]); + m_locationType = Jellyfin::Support::fromJsonValue(source["LocationType"]); + m_isoType = Jellyfin::Support::fromJsonValue(source["IsoType"]); + m_mediaType = Jellyfin::Support::fromJsonValue(source["MediaType"]); + m_endDate = Jellyfin::Support::fromJsonValue(source["EndDate"]); + m_lockedFields = Jellyfin::Support::fromJsonValue>(source["LockedFields"]); + m_trailerCount = Jellyfin::Support::fromJsonValue(source["TrailerCount"]); + m_movieCount = Jellyfin::Support::fromJsonValue(source["MovieCount"]); + m_seriesCount = Jellyfin::Support::fromJsonValue(source["SeriesCount"]); + m_programCount = Jellyfin::Support::fromJsonValue(source["ProgramCount"]); + m_episodeCount = Jellyfin::Support::fromJsonValue(source["EpisodeCount"]); + m_songCount = Jellyfin::Support::fromJsonValue(source["SongCount"]); + m_albumCount = Jellyfin::Support::fromJsonValue(source["AlbumCount"]); + m_artistCount = Jellyfin::Support::fromJsonValue(source["ArtistCount"]); + m_musicVideoCount = Jellyfin::Support::fromJsonValue(source["MusicVideoCount"]); + m_lockData = Jellyfin::Support::fromJsonValue(source["LockData"]); + m_width = Jellyfin::Support::fromJsonValue(source["Width"]); + m_height = Jellyfin::Support::fromJsonValue(source["Height"]); + m_cameraMake = Jellyfin::Support::fromJsonValue(source["CameraMake"]); + m_cameraModel = Jellyfin::Support::fromJsonValue(source["CameraModel"]); + m_software = Jellyfin::Support::fromJsonValue(source["Software"]); + m_exposureTime = Jellyfin::Support::fromJsonValue(source["ExposureTime"]); + m_focalLength = Jellyfin::Support::fromJsonValue(source["FocalLength"]); + m_imageOrientation = Jellyfin::Support::fromJsonValue(source["ImageOrientation"]); + m_aperture = Jellyfin::Support::fromJsonValue(source["Aperture"]); + m_shutterSpeed = Jellyfin::Support::fromJsonValue(source["ShutterSpeed"]); + m_latitude = Jellyfin::Support::fromJsonValue(source["Latitude"]); + m_longitude = Jellyfin::Support::fromJsonValue(source["Longitude"]); + m_altitude = Jellyfin::Support::fromJsonValue(source["Altitude"]); + m_isoSpeedRating = Jellyfin::Support::fromJsonValue(source["IsoSpeedRating"]); + m_seriesTimerId = Jellyfin::Support::fromJsonValue(source["SeriesTimerId"]); + m_programId = Jellyfin::Support::fromJsonValue(source["ProgramId"]); + m_channelPrimaryImageTag = Jellyfin::Support::fromJsonValue(source["ChannelPrimaryImageTag"]); + m_startDate = Jellyfin::Support::fromJsonValue(source["StartDate"]); + m_completionPercentage = Jellyfin::Support::fromJsonValue(source["CompletionPercentage"]); + m_isRepeat = Jellyfin::Support::fromJsonValue(source["IsRepeat"]); + m_episodeTitle = Jellyfin::Support::fromJsonValue(source["EpisodeTitle"]); + m_channelType = Jellyfin::Support::fromJsonValue(source["ChannelType"]); + m_audio = Jellyfin::Support::fromJsonValue(source["Audio"]); + m_isMovie = Jellyfin::Support::fromJsonValue(source["IsMovie"]); + m_isSports = Jellyfin::Support::fromJsonValue(source["IsSports"]); + m_isSeries = Jellyfin::Support::fromJsonValue(source["IsSeries"]); + m_isLive = Jellyfin::Support::fromJsonValue(source["IsLive"]); + m_isNews = Jellyfin::Support::fromJsonValue(source["IsNews"]); + m_isKids = Jellyfin::Support::fromJsonValue(source["IsKids"]); + m_isPremiere = Jellyfin::Support::fromJsonValue(source["IsPremiere"]); + m_timerId = Jellyfin::Support::fromJsonValue(source["TimerId"]); + m_currentProgram = Jellyfin::Support::fromJsonValue>(source["CurrentProgram"]); } QJsonObject BaseItemDto::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["OriginalTitle"] = toJsonValue(m_originalTitle); - result["ServerId"] = toJsonValue(m_serverId); - result["Id"] = toJsonValue(m_jellyfinId); - result["Etag"] = toJsonValue(m_etag); - result["SourceType"] = toJsonValue(m_sourceType); - result["PlaylistItemId"] = toJsonValue(m_playlistItemId); - result["DateCreated"] = toJsonValue(m_dateCreated); - result["DateLastMediaAdded"] = toJsonValue(m_dateLastMediaAdded); - result["ExtraType"] = toJsonValue(m_extraType); - result["AirsBeforeSeasonNumber"] = toJsonValue(m_airsBeforeSeasonNumber); - result["AirsAfterSeasonNumber"] = toJsonValue(m_airsAfterSeasonNumber); - result["AirsBeforeEpisodeNumber"] = toJsonValue(m_airsBeforeEpisodeNumber); - result["CanDelete"] = toJsonValue(m_canDelete); - result["CanDownload"] = toJsonValue(m_canDownload); - result["HasSubtitles"] = toJsonValue(m_hasSubtitles); - result["PreferredMetadataLanguage"] = toJsonValue(m_preferredMetadataLanguage); - result["PreferredMetadataCountryCode"] = toJsonValue(m_preferredMetadataCountryCode); - result["SupportsSync"] = toJsonValue(m_supportsSync); - result["Container"] = toJsonValue(m_container); - result["SortName"] = toJsonValue(m_sortName); - result["ForcedSortName"] = toJsonValue(m_forcedSortName); - result["Video3DFormat"] = toJsonValue(m_video3DFormat); - result["PremiereDate"] = toJsonValue(m_premiereDate); - result["ExternalUrls"] = toJsonValue>>(m_externalUrls); - result["MediaSources"] = toJsonValue>>(m_mediaSources); - result["CriticRating"] = toJsonValue(m_criticRating); - result["ProductionLocations"] = toJsonValue(m_productionLocations); - result["Path"] = toJsonValue(m_path); - result["EnableMediaSourceDisplay"] = toJsonValue(m_enableMediaSourceDisplay); - result["OfficialRating"] = toJsonValue(m_officialRating); - result["CustomRating"] = toJsonValue(m_customRating); - result["ChannelId"] = toJsonValue(m_channelId); - result["ChannelName"] = toJsonValue(m_channelName); - result["Overview"] = toJsonValue(m_overview); - result["Taglines"] = toJsonValue(m_taglines); - result["Genres"] = toJsonValue(m_genres); - result["CommunityRating"] = toJsonValue(m_communityRating); - result["CumulativeRunTimeTicks"] = toJsonValue(m_cumulativeRunTimeTicks); - result["RunTimeTicks"] = toJsonValue(m_runTimeTicks); - result["PlayAccess"] = toJsonValue(m_playAccess); - result["AspectRatio"] = toJsonValue(m_aspectRatio); - result["ProductionYear"] = toJsonValue(m_productionYear); - result["IsPlaceHolder"] = toJsonValue(m_isPlaceHolder); - result["Number"] = toJsonValue(m_number); - result["ChannelNumber"] = toJsonValue(m_channelNumber); - result["IndexNumber"] = toJsonValue(m_indexNumber); - result["IndexNumberEnd"] = toJsonValue(m_indexNumberEnd); - result["ParentIndexNumber"] = toJsonValue(m_parentIndexNumber); - result["RemoteTrailers"] = toJsonValue>>(m_remoteTrailers); - result["ProviderIds"] = toJsonValue(m_providerIds); - result["IsHD"] = toJsonValue(m_isHD); - result["IsFolder"] = toJsonValue(m_isFolder); - result["ParentId"] = toJsonValue(m_parentId); - result["Type"] = toJsonValue(m_type); - result["People"] = toJsonValue>>(m_people); - result["Studios"] = toJsonValue>>(m_studios); - result["GenreItems"] = toJsonValue>>(m_genreItems); - result["ParentLogoItemId"] = toJsonValue(m_parentLogoItemId); - result["ParentBackdropItemId"] = toJsonValue(m_parentBackdropItemId); - result["ParentBackdropImageTags"] = toJsonValue(m_parentBackdropImageTags); - result["LocalTrailerCount"] = toJsonValue(m_localTrailerCount); - result["UserData"] = toJsonValue>(m_userData); - result["RecursiveItemCount"] = toJsonValue(m_recursiveItemCount); - result["ChildCount"] = toJsonValue(m_childCount); - result["SeriesName"] = toJsonValue(m_seriesName); - result["SeriesId"] = toJsonValue(m_seriesId); - result["SeasonId"] = toJsonValue(m_seasonId); - result["SpecialFeatureCount"] = toJsonValue(m_specialFeatureCount); - result["DisplayPreferencesId"] = toJsonValue(m_displayPreferencesId); - result["Status"] = toJsonValue(m_status); - result["AirTime"] = toJsonValue(m_airTime); - result["AirDays"] = toJsonValue>(m_airDays); - result["Tags"] = toJsonValue(m_tags); - result["PrimaryImageAspectRatio"] = toJsonValue(m_primaryImageAspectRatio); - result["Artists"] = toJsonValue(m_artists); - result["ArtistItems"] = toJsonValue>>(m_artistItems); - result["Album"] = toJsonValue(m_album); - result["CollectionType"] = toJsonValue(m_collectionType); - result["DisplayOrder"] = toJsonValue(m_displayOrder); - result["AlbumId"] = toJsonValue(m_albumId); - result["AlbumPrimaryImageTag"] = toJsonValue(m_albumPrimaryImageTag); - result["SeriesPrimaryImageTag"] = toJsonValue(m_seriesPrimaryImageTag); - result["AlbumArtist"] = toJsonValue(m_albumArtist); - result["AlbumArtists"] = toJsonValue>>(m_albumArtists); - result["SeasonName"] = toJsonValue(m_seasonName); - result["MediaStreams"] = toJsonValue>>(m_mediaStreams); - result["VideoType"] = toJsonValue(m_videoType); - result["PartCount"] = toJsonValue(m_partCount); - result["MediaSourceCount"] = toJsonValue(m_mediaSourceCount); - result["ImageTags"] = toJsonValue(m_imageTags); - result["BackdropImageTags"] = toJsonValue(m_backdropImageTags); - result["ScreenshotImageTags"] = toJsonValue(m_screenshotImageTags); - result["ParentLogoImageTag"] = toJsonValue(m_parentLogoImageTag); - result["ParentArtItemId"] = toJsonValue(m_parentArtItemId); - result["ParentArtImageTag"] = toJsonValue(m_parentArtImageTag); - result["SeriesThumbImageTag"] = toJsonValue(m_seriesThumbImageTag); - result["ImageBlurHashes"] = toJsonValue(m_imageBlurHashes); - result["SeriesStudio"] = toJsonValue(m_seriesStudio); - result["ParentThumbItemId"] = toJsonValue(m_parentThumbItemId); - result["ParentThumbImageTag"] = toJsonValue(m_parentThumbImageTag); - result["ParentPrimaryImageItemId"] = toJsonValue(m_parentPrimaryImageItemId); - result["ParentPrimaryImageTag"] = toJsonValue(m_parentPrimaryImageTag); - result["Chapters"] = toJsonValue>>(m_chapters); - result["LocationType"] = toJsonValue(m_locationType); - result["IsoType"] = toJsonValue(m_isoType); - result["MediaType"] = toJsonValue(m_mediaType); - result["EndDate"] = toJsonValue(m_endDate); - result["LockedFields"] = toJsonValue>(m_lockedFields); - result["TrailerCount"] = toJsonValue(m_trailerCount); - result["MovieCount"] = toJsonValue(m_movieCount); - result["SeriesCount"] = toJsonValue(m_seriesCount); - result["ProgramCount"] = toJsonValue(m_programCount); - result["EpisodeCount"] = toJsonValue(m_episodeCount); - result["SongCount"] = toJsonValue(m_songCount); - result["AlbumCount"] = toJsonValue(m_albumCount); - result["ArtistCount"] = toJsonValue(m_artistCount); - result["MusicVideoCount"] = toJsonValue(m_musicVideoCount); - result["LockData"] = toJsonValue(m_lockData); - result["Width"] = toJsonValue(m_width); - result["Height"] = toJsonValue(m_height); - result["CameraMake"] = toJsonValue(m_cameraMake); - result["CameraModel"] = toJsonValue(m_cameraModel); - result["Software"] = toJsonValue(m_software); - result["ExposureTime"] = toJsonValue(m_exposureTime); - result["FocalLength"] = toJsonValue(m_focalLength); - result["ImageOrientation"] = toJsonValue(m_imageOrientation); - result["Aperture"] = toJsonValue(m_aperture); - result["ShutterSpeed"] = toJsonValue(m_shutterSpeed); - result["Latitude"] = toJsonValue(m_latitude); - result["Longitude"] = toJsonValue(m_longitude); - result["Altitude"] = toJsonValue(m_altitude); - result["IsoSpeedRating"] = toJsonValue(m_isoSpeedRating); - result["SeriesTimerId"] = toJsonValue(m_seriesTimerId); - result["ProgramId"] = toJsonValue(m_programId); - result["ChannelPrimaryImageTag"] = toJsonValue(m_channelPrimaryImageTag); - result["StartDate"] = toJsonValue(m_startDate); - result["CompletionPercentage"] = toJsonValue(m_completionPercentage); - result["IsRepeat"] = toJsonValue(m_isRepeat); - result["EpisodeTitle"] = toJsonValue(m_episodeTitle); - result["ChannelType"] = toJsonValue(m_channelType); - result["Audio"] = toJsonValue(m_audio); - result["IsMovie"] = toJsonValue(m_isMovie); - result["IsSports"] = toJsonValue(m_isSports); - result["IsSeries"] = toJsonValue(m_isSeries); - result["IsLive"] = toJsonValue(m_isLive); - result["IsNews"] = toJsonValue(m_isNews); - result["IsKids"] = toJsonValue(m_isKids); - result["IsPremiere"] = toJsonValue(m_isPremiere); - result["TimerId"] = toJsonValue(m_timerId); - result["CurrentProgram"] = toJsonValue>(m_currentProgram); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["OriginalTitle"] = Jellyfin::Support::toJsonValue(m_originalTitle); + result["ServerId"] = Jellyfin::Support::toJsonValue(m_serverId); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["Etag"] = Jellyfin::Support::toJsonValue(m_etag); + result["SourceType"] = Jellyfin::Support::toJsonValue(m_sourceType); + result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); + result["DateCreated"] = Jellyfin::Support::toJsonValue(m_dateCreated); + result["DateLastMediaAdded"] = Jellyfin::Support::toJsonValue(m_dateLastMediaAdded); + result["ExtraType"] = Jellyfin::Support::toJsonValue(m_extraType); + result["AirsBeforeSeasonNumber"] = Jellyfin::Support::toJsonValue(m_airsBeforeSeasonNumber); + result["AirsAfterSeasonNumber"] = Jellyfin::Support::toJsonValue(m_airsAfterSeasonNumber); + result["AirsBeforeEpisodeNumber"] = Jellyfin::Support::toJsonValue(m_airsBeforeEpisodeNumber); + result["CanDelete"] = Jellyfin::Support::toJsonValue(m_canDelete); + result["CanDownload"] = Jellyfin::Support::toJsonValue(m_canDownload); + result["HasSubtitles"] = Jellyfin::Support::toJsonValue(m_hasSubtitles); + result["PreferredMetadataLanguage"] = Jellyfin::Support::toJsonValue(m_preferredMetadataLanguage); + result["PreferredMetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_preferredMetadataCountryCode); + result["SupportsSync"] = Jellyfin::Support::toJsonValue(m_supportsSync); + result["Container"] = Jellyfin::Support::toJsonValue(m_container); + result["SortName"] = Jellyfin::Support::toJsonValue(m_sortName); + result["ForcedSortName"] = Jellyfin::Support::toJsonValue(m_forcedSortName); + result["Video3DFormat"] = Jellyfin::Support::toJsonValue(m_video3DFormat); + result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); + result["ExternalUrls"] = Jellyfin::Support::toJsonValue>>(m_externalUrls); + result["MediaSources"] = Jellyfin::Support::toJsonValue>>(m_mediaSources); + result["CriticRating"] = Jellyfin::Support::toJsonValue(m_criticRating); + result["ProductionLocations"] = Jellyfin::Support::toJsonValue(m_productionLocations); + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + result["EnableMediaSourceDisplay"] = Jellyfin::Support::toJsonValue(m_enableMediaSourceDisplay); + result["OfficialRating"] = Jellyfin::Support::toJsonValue(m_officialRating); + result["CustomRating"] = Jellyfin::Support::toJsonValue(m_customRating); + result["ChannelId"] = Jellyfin::Support::toJsonValue(m_channelId); + result["ChannelName"] = Jellyfin::Support::toJsonValue(m_channelName); + result["Overview"] = Jellyfin::Support::toJsonValue(m_overview); + result["Taglines"] = Jellyfin::Support::toJsonValue(m_taglines); + result["Genres"] = Jellyfin::Support::toJsonValue(m_genres); + result["CommunityRating"] = Jellyfin::Support::toJsonValue(m_communityRating); + result["CumulativeRunTimeTicks"] = Jellyfin::Support::toJsonValue(m_cumulativeRunTimeTicks); + result["RunTimeTicks"] = Jellyfin::Support::toJsonValue(m_runTimeTicks); + result["PlayAccess"] = Jellyfin::Support::toJsonValue(m_playAccess); + result["AspectRatio"] = Jellyfin::Support::toJsonValue(m_aspectRatio); + result["ProductionYear"] = Jellyfin::Support::toJsonValue(m_productionYear); + result["IsPlaceHolder"] = Jellyfin::Support::toJsonValue(m_isPlaceHolder); + result["Number"] = Jellyfin::Support::toJsonValue(m_number); + result["ChannelNumber"] = Jellyfin::Support::toJsonValue(m_channelNumber); + result["IndexNumber"] = Jellyfin::Support::toJsonValue(m_indexNumber); + result["IndexNumberEnd"] = Jellyfin::Support::toJsonValue(m_indexNumberEnd); + result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue(m_parentIndexNumber); + result["RemoteTrailers"] = Jellyfin::Support::toJsonValue>>(m_remoteTrailers); + result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); + result["IsHD"] = Jellyfin::Support::toJsonValue(m_isHD); + result["IsFolder"] = Jellyfin::Support::toJsonValue(m_isFolder); + result["ParentId"] = Jellyfin::Support::toJsonValue(m_parentId); + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + result["People"] = Jellyfin::Support::toJsonValue>>(m_people); + result["Studios"] = Jellyfin::Support::toJsonValue>>(m_studios); + result["GenreItems"] = Jellyfin::Support::toJsonValue>>(m_genreItems); + result["ParentLogoItemId"] = Jellyfin::Support::toJsonValue(m_parentLogoItemId); + result["ParentBackdropItemId"] = Jellyfin::Support::toJsonValue(m_parentBackdropItemId); + result["ParentBackdropImageTags"] = Jellyfin::Support::toJsonValue(m_parentBackdropImageTags); + result["LocalTrailerCount"] = Jellyfin::Support::toJsonValue(m_localTrailerCount); + result["UserData"] = Jellyfin::Support::toJsonValue>(m_userData); + result["RecursiveItemCount"] = Jellyfin::Support::toJsonValue(m_recursiveItemCount); + result["ChildCount"] = Jellyfin::Support::toJsonValue(m_childCount); + result["SeriesName"] = Jellyfin::Support::toJsonValue(m_seriesName); + result["SeriesId"] = Jellyfin::Support::toJsonValue(m_seriesId); + result["SeasonId"] = Jellyfin::Support::toJsonValue(m_seasonId); + result["SpecialFeatureCount"] = Jellyfin::Support::toJsonValue(m_specialFeatureCount); + result["DisplayPreferencesId"] = Jellyfin::Support::toJsonValue(m_displayPreferencesId); + result["Status"] = Jellyfin::Support::toJsonValue(m_status); + result["AirTime"] = Jellyfin::Support::toJsonValue(m_airTime); + result["AirDays"] = Jellyfin::Support::toJsonValue>(m_airDays); + result["Tags"] = Jellyfin::Support::toJsonValue(m_tags); + result["PrimaryImageAspectRatio"] = Jellyfin::Support::toJsonValue(m_primaryImageAspectRatio); + result["Artists"] = Jellyfin::Support::toJsonValue(m_artists); + result["ArtistItems"] = Jellyfin::Support::toJsonValue>>(m_artistItems); + result["Album"] = Jellyfin::Support::toJsonValue(m_album); + result["CollectionType"] = Jellyfin::Support::toJsonValue(m_collectionType); + result["DisplayOrder"] = Jellyfin::Support::toJsonValue(m_displayOrder); + result["AlbumId"] = Jellyfin::Support::toJsonValue(m_albumId); + result["AlbumPrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_albumPrimaryImageTag); + result["SeriesPrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_seriesPrimaryImageTag); + result["AlbumArtist"] = Jellyfin::Support::toJsonValue(m_albumArtist); + result["AlbumArtists"] = Jellyfin::Support::toJsonValue>>(m_albumArtists); + result["SeasonName"] = Jellyfin::Support::toJsonValue(m_seasonName); + result["MediaStreams"] = Jellyfin::Support::toJsonValue>>(m_mediaStreams); + result["VideoType"] = Jellyfin::Support::toJsonValue(m_videoType); + result["PartCount"] = Jellyfin::Support::toJsonValue(m_partCount); + result["MediaSourceCount"] = Jellyfin::Support::toJsonValue(m_mediaSourceCount); + result["ImageTags"] = Jellyfin::Support::toJsonValue(m_imageTags); + result["BackdropImageTags"] = Jellyfin::Support::toJsonValue(m_backdropImageTags); + result["ScreenshotImageTags"] = Jellyfin::Support::toJsonValue(m_screenshotImageTags); + result["ParentLogoImageTag"] = Jellyfin::Support::toJsonValue(m_parentLogoImageTag); + result["ParentArtItemId"] = Jellyfin::Support::toJsonValue(m_parentArtItemId); + result["ParentArtImageTag"] = Jellyfin::Support::toJsonValue(m_parentArtImageTag); + result["SeriesThumbImageTag"] = Jellyfin::Support::toJsonValue(m_seriesThumbImageTag); + result["ImageBlurHashes"] = Jellyfin::Support::toJsonValue(m_imageBlurHashes); + result["SeriesStudio"] = Jellyfin::Support::toJsonValue(m_seriesStudio); + result["ParentThumbItemId"] = Jellyfin::Support::toJsonValue(m_parentThumbItemId); + result["ParentThumbImageTag"] = Jellyfin::Support::toJsonValue(m_parentThumbImageTag); + result["ParentPrimaryImageItemId"] = Jellyfin::Support::toJsonValue(m_parentPrimaryImageItemId); + result["ParentPrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_parentPrimaryImageTag); + result["Chapters"] = Jellyfin::Support::toJsonValue>>(m_chapters); + result["LocationType"] = Jellyfin::Support::toJsonValue(m_locationType); + result["IsoType"] = Jellyfin::Support::toJsonValue(m_isoType); + result["MediaType"] = Jellyfin::Support::toJsonValue(m_mediaType); + result["EndDate"] = Jellyfin::Support::toJsonValue(m_endDate); + result["LockedFields"] = Jellyfin::Support::toJsonValue>(m_lockedFields); + result["TrailerCount"] = Jellyfin::Support::toJsonValue(m_trailerCount); + result["MovieCount"] = Jellyfin::Support::toJsonValue(m_movieCount); + result["SeriesCount"] = Jellyfin::Support::toJsonValue(m_seriesCount); + result["ProgramCount"] = Jellyfin::Support::toJsonValue(m_programCount); + result["EpisodeCount"] = Jellyfin::Support::toJsonValue(m_episodeCount); + result["SongCount"] = Jellyfin::Support::toJsonValue(m_songCount); + result["AlbumCount"] = Jellyfin::Support::toJsonValue(m_albumCount); + result["ArtistCount"] = Jellyfin::Support::toJsonValue(m_artistCount); + result["MusicVideoCount"] = Jellyfin::Support::toJsonValue(m_musicVideoCount); + result["LockData"] = Jellyfin::Support::toJsonValue(m_lockData); + result["Width"] = Jellyfin::Support::toJsonValue(m_width); + result["Height"] = Jellyfin::Support::toJsonValue(m_height); + result["CameraMake"] = Jellyfin::Support::toJsonValue(m_cameraMake); + result["CameraModel"] = Jellyfin::Support::toJsonValue(m_cameraModel); + result["Software"] = Jellyfin::Support::toJsonValue(m_software); + result["ExposureTime"] = Jellyfin::Support::toJsonValue(m_exposureTime); + result["FocalLength"] = Jellyfin::Support::toJsonValue(m_focalLength); + result["ImageOrientation"] = Jellyfin::Support::toJsonValue(m_imageOrientation); + result["Aperture"] = Jellyfin::Support::toJsonValue(m_aperture); + result["ShutterSpeed"] = Jellyfin::Support::toJsonValue(m_shutterSpeed); + result["Latitude"] = Jellyfin::Support::toJsonValue(m_latitude); + result["Longitude"] = Jellyfin::Support::toJsonValue(m_longitude); + result["Altitude"] = Jellyfin::Support::toJsonValue(m_altitude); + result["IsoSpeedRating"] = Jellyfin::Support::toJsonValue(m_isoSpeedRating); + result["SeriesTimerId"] = Jellyfin::Support::toJsonValue(m_seriesTimerId); + result["ProgramId"] = Jellyfin::Support::toJsonValue(m_programId); + result["ChannelPrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_channelPrimaryImageTag); + result["StartDate"] = Jellyfin::Support::toJsonValue(m_startDate); + result["CompletionPercentage"] = Jellyfin::Support::toJsonValue(m_completionPercentage); + result["IsRepeat"] = Jellyfin::Support::toJsonValue(m_isRepeat); + result["EpisodeTitle"] = Jellyfin::Support::toJsonValue(m_episodeTitle); + result["ChannelType"] = Jellyfin::Support::toJsonValue(m_channelType); + result["Audio"] = Jellyfin::Support::toJsonValue(m_audio); + result["IsMovie"] = Jellyfin::Support::toJsonValue(m_isMovie); + result["IsSports"] = Jellyfin::Support::toJsonValue(m_isSports); + result["IsSeries"] = Jellyfin::Support::toJsonValue(m_isSeries); + result["IsLive"] = Jellyfin::Support::toJsonValue(m_isLive); + result["IsNews"] = Jellyfin::Support::toJsonValue(m_isNews); + result["IsKids"] = Jellyfin::Support::toJsonValue(m_isKids); + result["IsPremiere"] = Jellyfin::Support::toJsonValue(m_isPremiere); + result["TimerId"] = Jellyfin::Support::toJsonValue(m_timerId); + result["CurrentProgram"] = Jellyfin::Support::toJsonValue>(m_currentProgram); return result; } @@ -1108,6 +1109,17 @@ void BaseItemDto::setCurrentProgram(QSharedPointer newCurrentProgra m_currentProgram = newCurrentProgram; } +} // NS DTO + +namespace Support { + +using BaseItemDto = Jellyfin::DTO::BaseItemDto; + +template <> +BaseItemDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return BaseItemDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/baseitemdtoqueryresult.cpp b/core/src/DTO/baseitemdtoqueryresult.cpp index 6730786..884256d 100644 --- a/core/src/DTO/baseitemdtoqueryresult.cpp +++ b/core/src/DTO/baseitemdtoqueryresult.cpp @@ -32,26 +32,27 @@ namespace Jellyfin { namespace DTO { -BaseItemDtoQueryResult::BaseItemDtoQueryResult(QObject *parent) {} +BaseItemDtoQueryResult::BaseItemDtoQueryResult() {} -BaseItemDtoQueryResult BaseItemDtoQueryResult::fromJson(QJsonObject source) {BaseItemDtoQueryResult instance; - instance->setFromJson(source, false); +BaseItemDtoQueryResult BaseItemDtoQueryResult::fromJson(QJsonObject source) { + BaseItemDtoQueryResult instance; + instance.setFromJson(source); return instance; } void BaseItemDtoQueryResult::setFromJson(QJsonObject source) { - m_items = fromJsonValue>>(source["Items"]); - m_totalRecordCount = fromJsonValue(source["TotalRecordCount"]); - m_startIndex = fromJsonValue(source["StartIndex"]); + m_items = Jellyfin::Support::fromJsonValue>>(source["Items"]); + m_totalRecordCount = Jellyfin::Support::fromJsonValue(source["TotalRecordCount"]); + m_startIndex = Jellyfin::Support::fromJsonValue(source["StartIndex"]); } QJsonObject BaseItemDtoQueryResult::toJson() { QJsonObject result; - result["Items"] = toJsonValue>>(m_items); - result["TotalRecordCount"] = toJsonValue(m_totalRecordCount); - result["StartIndex"] = toJsonValue(m_startIndex); + result["Items"] = Jellyfin::Support::toJsonValue>>(m_items); + result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); + result["StartIndex"] = Jellyfin::Support::toJsonValue(m_startIndex); return result; } @@ -72,6 +73,17 @@ void BaseItemDtoQueryResult::setStartIndex(qint32 newStartIndex) { m_startIndex = newStartIndex; } +} // NS DTO + +namespace Support { + +using BaseItemDtoQueryResult = Jellyfin::DTO::BaseItemDtoQueryResult; + +template <> +BaseItemDtoQueryResult fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return BaseItemDtoQueryResult::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/baseitemperson.cpp b/core/src/DTO/baseitemperson.cpp index a462a5b..1ce2bbb 100644 --- a/core/src/DTO/baseitemperson.cpp +++ b/core/src/DTO/baseitemperson.cpp @@ -32,32 +32,33 @@ namespace Jellyfin { namespace DTO { -BaseItemPerson::BaseItemPerson(QObject *parent) {} +BaseItemPerson::BaseItemPerson() {} -BaseItemPerson BaseItemPerson::fromJson(QJsonObject source) {BaseItemPerson instance; - instance->setFromJson(source, false); +BaseItemPerson BaseItemPerson::fromJson(QJsonObject source) { + BaseItemPerson instance; + instance.setFromJson(source); return instance; } void BaseItemPerson::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_jellyfinId = fromJsonValue(source["Id"]); - m_role = fromJsonValue(source["Role"]); - m_type = fromJsonValue(source["Type"]); - m_primaryImageTag = fromJsonValue(source["PrimaryImageTag"]); - m_imageBlurHashes = fromJsonValue(source["ImageBlurHashes"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); + m_role = Jellyfin::Support::fromJsonValue(source["Role"]); + m_type = Jellyfin::Support::fromJsonValue(source["Type"]); + m_primaryImageTag = Jellyfin::Support::fromJsonValue(source["PrimaryImageTag"]); + m_imageBlurHashes = Jellyfin::Support::fromJsonValue(source["ImageBlurHashes"]); } QJsonObject BaseItemPerson::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Id"] = toJsonValue(m_jellyfinId); - result["Role"] = toJsonValue(m_role); - result["Type"] = toJsonValue(m_type); - result["PrimaryImageTag"] = toJsonValue(m_primaryImageTag); - result["ImageBlurHashes"] = toJsonValue(m_imageBlurHashes); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["Role"] = Jellyfin::Support::toJsonValue(m_role); + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + result["PrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_primaryImageTag); + result["ImageBlurHashes"] = Jellyfin::Support::toJsonValue(m_imageBlurHashes); return result; } @@ -93,6 +94,17 @@ void BaseItemPerson::setImageBlurHashes(QJsonObject newImageBlurHashes) { m_imageBlurHashes = newImageBlurHashes; } +} // NS DTO + +namespace Support { + +using BaseItemPerson = Jellyfin::DTO::BaseItemPerson; + +template <> +BaseItemPerson fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return BaseItemPerson::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/bookinfo.cpp b/core/src/DTO/bookinfo.cpp index 098b55f..ec445a2 100644 --- a/core/src/DTO/bookinfo.cpp +++ b/core/src/DTO/bookinfo.cpp @@ -32,42 +32,43 @@ namespace Jellyfin { namespace DTO { -BookInfo::BookInfo(QObject *parent) {} +BookInfo::BookInfo() {} -BookInfo BookInfo::fromJson(QJsonObject source) {BookInfo instance; - instance->setFromJson(source, false); +BookInfo BookInfo::fromJson(QJsonObject source) { + BookInfo instance; + instance.setFromJson(source); return instance; } void BookInfo::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_path = fromJsonValue(source["Path"]); - m_metadataLanguage = fromJsonValue(source["MetadataLanguage"]); - m_metadataCountryCode = fromJsonValue(source["MetadataCountryCode"]); - m_providerIds = fromJsonValue(source["ProviderIds"]); - m_year = fromJsonValue(source["Year"]); - m_indexNumber = fromJsonValue(source["IndexNumber"]); - m_parentIndexNumber = fromJsonValue(source["ParentIndexNumber"]); - m_premiereDate = fromJsonValue(source["PremiereDate"]); - m_isAutomated = fromJsonValue(source["IsAutomated"]); - m_seriesName = fromJsonValue(source["SeriesName"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_path = Jellyfin::Support::fromJsonValue(source["Path"]); + m_metadataLanguage = Jellyfin::Support::fromJsonValue(source["MetadataLanguage"]); + m_metadataCountryCode = Jellyfin::Support::fromJsonValue(source["MetadataCountryCode"]); + m_providerIds = Jellyfin::Support::fromJsonValue(source["ProviderIds"]); + m_year = Jellyfin::Support::fromJsonValue(source["Year"]); + m_indexNumber = Jellyfin::Support::fromJsonValue(source["IndexNumber"]); + m_parentIndexNumber = Jellyfin::Support::fromJsonValue(source["ParentIndexNumber"]); + m_premiereDate = Jellyfin::Support::fromJsonValue(source["PremiereDate"]); + m_isAutomated = Jellyfin::Support::fromJsonValue(source["IsAutomated"]); + m_seriesName = Jellyfin::Support::fromJsonValue(source["SeriesName"]); } QJsonObject BookInfo::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Path"] = toJsonValue(m_path); - result["MetadataLanguage"] = toJsonValue(m_metadataLanguage); - result["MetadataCountryCode"] = toJsonValue(m_metadataCountryCode); - result["ProviderIds"] = toJsonValue(m_providerIds); - result["Year"] = toJsonValue(m_year); - result["IndexNumber"] = toJsonValue(m_indexNumber); - result["ParentIndexNumber"] = toJsonValue(m_parentIndexNumber); - result["PremiereDate"] = toJsonValue(m_premiereDate); - result["IsAutomated"] = toJsonValue(m_isAutomated); - result["SeriesName"] = toJsonValue(m_seriesName); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); + result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); + result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); + result["Year"] = Jellyfin::Support::toJsonValue(m_year); + result["IndexNumber"] = Jellyfin::Support::toJsonValue(m_indexNumber); + result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue(m_parentIndexNumber); + result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); + result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); + result["SeriesName"] = Jellyfin::Support::toJsonValue(m_seriesName); return result; } @@ -128,6 +129,17 @@ void BookInfo::setSeriesName(QString newSeriesName) { m_seriesName = newSeriesName; } +} // NS DTO + +namespace Support { + +using BookInfo = Jellyfin::DTO::BookInfo; + +template <> +BookInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return BookInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/bookinforemotesearchquery.cpp b/core/src/DTO/bookinforemotesearchquery.cpp index 5be3d92..a8eec5c 100644 --- a/core/src/DTO/bookinforemotesearchquery.cpp +++ b/core/src/DTO/bookinforemotesearchquery.cpp @@ -32,28 +32,29 @@ namespace Jellyfin { namespace DTO { -BookInfoRemoteSearchQuery::BookInfoRemoteSearchQuery(QObject *parent) {} +BookInfoRemoteSearchQuery::BookInfoRemoteSearchQuery() {} -BookInfoRemoteSearchQuery BookInfoRemoteSearchQuery::fromJson(QJsonObject source) {BookInfoRemoteSearchQuery instance; - instance->setFromJson(source, false); +BookInfoRemoteSearchQuery BookInfoRemoteSearchQuery::fromJson(QJsonObject source) { + BookInfoRemoteSearchQuery instance; + instance.setFromJson(source); return instance; } void BookInfoRemoteSearchQuery::setFromJson(QJsonObject source) { - m_searchInfo = fromJsonValue>(source["SearchInfo"]); - m_itemId = fromJsonValue(source["ItemId"]); - m_searchProviderName = fromJsonValue(source["SearchProviderName"]); - m_includeDisabledProviders = fromJsonValue(source["IncludeDisabledProviders"]); + m_searchInfo = Jellyfin::Support::fromJsonValue>(source["SearchInfo"]); + m_itemId = Jellyfin::Support::fromJsonValue(source["ItemId"]); + m_searchProviderName = Jellyfin::Support::fromJsonValue(source["SearchProviderName"]); + m_includeDisabledProviders = Jellyfin::Support::fromJsonValue(source["IncludeDisabledProviders"]); } QJsonObject BookInfoRemoteSearchQuery::toJson() { QJsonObject result; - result["SearchInfo"] = toJsonValue>(m_searchInfo); - result["ItemId"] = toJsonValue(m_itemId); - result["SearchProviderName"] = toJsonValue(m_searchProviderName); - result["IncludeDisabledProviders"] = toJsonValue(m_includeDisabledProviders); + result["SearchInfo"] = Jellyfin::Support::toJsonValue>(m_searchInfo); + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); + result["IncludeDisabledProviders"] = Jellyfin::Support::toJsonValue(m_includeDisabledProviders); return result; } @@ -79,6 +80,17 @@ void BookInfoRemoteSearchQuery::setIncludeDisabledProviders(bool newIncludeDisab m_includeDisabledProviders = newIncludeDisabledProviders; } +} // NS DTO + +namespace Support { + +using BookInfoRemoteSearchQuery = Jellyfin::DTO::BookInfoRemoteSearchQuery; + +template <> +BookInfoRemoteSearchQuery fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return BookInfoRemoteSearchQuery::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/boxsetinfo.cpp b/core/src/DTO/boxsetinfo.cpp index 183fe4d..ed8623b 100644 --- a/core/src/DTO/boxsetinfo.cpp +++ b/core/src/DTO/boxsetinfo.cpp @@ -32,40 +32,41 @@ namespace Jellyfin { namespace DTO { -BoxSetInfo::BoxSetInfo(QObject *parent) {} +BoxSetInfo::BoxSetInfo() {} -BoxSetInfo BoxSetInfo::fromJson(QJsonObject source) {BoxSetInfo instance; - instance->setFromJson(source, false); +BoxSetInfo BoxSetInfo::fromJson(QJsonObject source) { + BoxSetInfo instance; + instance.setFromJson(source); return instance; } void BoxSetInfo::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_path = fromJsonValue(source["Path"]); - m_metadataLanguage = fromJsonValue(source["MetadataLanguage"]); - m_metadataCountryCode = fromJsonValue(source["MetadataCountryCode"]); - m_providerIds = fromJsonValue(source["ProviderIds"]); - m_year = fromJsonValue(source["Year"]); - m_indexNumber = fromJsonValue(source["IndexNumber"]); - m_parentIndexNumber = fromJsonValue(source["ParentIndexNumber"]); - m_premiereDate = fromJsonValue(source["PremiereDate"]); - m_isAutomated = fromJsonValue(source["IsAutomated"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_path = Jellyfin::Support::fromJsonValue(source["Path"]); + m_metadataLanguage = Jellyfin::Support::fromJsonValue(source["MetadataLanguage"]); + m_metadataCountryCode = Jellyfin::Support::fromJsonValue(source["MetadataCountryCode"]); + m_providerIds = Jellyfin::Support::fromJsonValue(source["ProviderIds"]); + m_year = Jellyfin::Support::fromJsonValue(source["Year"]); + m_indexNumber = Jellyfin::Support::fromJsonValue(source["IndexNumber"]); + m_parentIndexNumber = Jellyfin::Support::fromJsonValue(source["ParentIndexNumber"]); + m_premiereDate = Jellyfin::Support::fromJsonValue(source["PremiereDate"]); + m_isAutomated = Jellyfin::Support::fromJsonValue(source["IsAutomated"]); } QJsonObject BoxSetInfo::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Path"] = toJsonValue(m_path); - result["MetadataLanguage"] = toJsonValue(m_metadataLanguage); - result["MetadataCountryCode"] = toJsonValue(m_metadataCountryCode); - result["ProviderIds"] = toJsonValue(m_providerIds); - result["Year"] = toJsonValue(m_year); - result["IndexNumber"] = toJsonValue(m_indexNumber); - result["ParentIndexNumber"] = toJsonValue(m_parentIndexNumber); - result["PremiereDate"] = toJsonValue(m_premiereDate); - result["IsAutomated"] = toJsonValue(m_isAutomated); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); + result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); + result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); + result["Year"] = Jellyfin::Support::toJsonValue(m_year); + result["IndexNumber"] = Jellyfin::Support::toJsonValue(m_indexNumber); + result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue(m_parentIndexNumber); + result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); + result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); return result; } @@ -121,6 +122,17 @@ void BoxSetInfo::setIsAutomated(bool newIsAutomated) { m_isAutomated = newIsAutomated; } +} // NS DTO + +namespace Support { + +using BoxSetInfo = Jellyfin::DTO::BoxSetInfo; + +template <> +BoxSetInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return BoxSetInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/boxsetinforemotesearchquery.cpp b/core/src/DTO/boxsetinforemotesearchquery.cpp index 8bc3136..3418687 100644 --- a/core/src/DTO/boxsetinforemotesearchquery.cpp +++ b/core/src/DTO/boxsetinforemotesearchquery.cpp @@ -32,28 +32,29 @@ namespace Jellyfin { namespace DTO { -BoxSetInfoRemoteSearchQuery::BoxSetInfoRemoteSearchQuery(QObject *parent) {} +BoxSetInfoRemoteSearchQuery::BoxSetInfoRemoteSearchQuery() {} -BoxSetInfoRemoteSearchQuery BoxSetInfoRemoteSearchQuery::fromJson(QJsonObject source) {BoxSetInfoRemoteSearchQuery instance; - instance->setFromJson(source, false); +BoxSetInfoRemoteSearchQuery BoxSetInfoRemoteSearchQuery::fromJson(QJsonObject source) { + BoxSetInfoRemoteSearchQuery instance; + instance.setFromJson(source); return instance; } void BoxSetInfoRemoteSearchQuery::setFromJson(QJsonObject source) { - m_searchInfo = fromJsonValue>(source["SearchInfo"]); - m_itemId = fromJsonValue(source["ItemId"]); - m_searchProviderName = fromJsonValue(source["SearchProviderName"]); - m_includeDisabledProviders = fromJsonValue(source["IncludeDisabledProviders"]); + m_searchInfo = Jellyfin::Support::fromJsonValue>(source["SearchInfo"]); + m_itemId = Jellyfin::Support::fromJsonValue(source["ItemId"]); + m_searchProviderName = Jellyfin::Support::fromJsonValue(source["SearchProviderName"]); + m_includeDisabledProviders = Jellyfin::Support::fromJsonValue(source["IncludeDisabledProviders"]); } QJsonObject BoxSetInfoRemoteSearchQuery::toJson() { QJsonObject result; - result["SearchInfo"] = toJsonValue>(m_searchInfo); - result["ItemId"] = toJsonValue(m_itemId); - result["SearchProviderName"] = toJsonValue(m_searchProviderName); - result["IncludeDisabledProviders"] = toJsonValue(m_includeDisabledProviders); + result["SearchInfo"] = Jellyfin::Support::toJsonValue>(m_searchInfo); + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); + result["IncludeDisabledProviders"] = Jellyfin::Support::toJsonValue(m_includeDisabledProviders); return result; } @@ -79,6 +80,17 @@ void BoxSetInfoRemoteSearchQuery::setIncludeDisabledProviders(bool newIncludeDis m_includeDisabledProviders = newIncludeDisabledProviders; } +} // NS DTO + +namespace Support { + +using BoxSetInfoRemoteSearchQuery = Jellyfin::DTO::BoxSetInfoRemoteSearchQuery; + +template <> +BoxSetInfoRemoteSearchQuery fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return BoxSetInfoRemoteSearchQuery::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/brandingoptions.cpp b/core/src/DTO/brandingoptions.cpp index d282b3c..091337b 100644 --- a/core/src/DTO/brandingoptions.cpp +++ b/core/src/DTO/brandingoptions.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -BrandingOptions::BrandingOptions(QObject *parent) {} +BrandingOptions::BrandingOptions() {} -BrandingOptions BrandingOptions::fromJson(QJsonObject source) {BrandingOptions instance; - instance->setFromJson(source, false); +BrandingOptions BrandingOptions::fromJson(QJsonObject source) { + BrandingOptions instance; + instance.setFromJson(source); return instance; } void BrandingOptions::setFromJson(QJsonObject source) { - m_loginDisclaimer = fromJsonValue(source["LoginDisclaimer"]); - m_customCss = fromJsonValue(source["CustomCss"]); + m_loginDisclaimer = Jellyfin::Support::fromJsonValue(source["LoginDisclaimer"]); + m_customCss = Jellyfin::Support::fromJsonValue(source["CustomCss"]); } QJsonObject BrandingOptions::toJson() { QJsonObject result; - result["LoginDisclaimer"] = toJsonValue(m_loginDisclaimer); - result["CustomCss"] = toJsonValue(m_customCss); + result["LoginDisclaimer"] = Jellyfin::Support::toJsonValue(m_loginDisclaimer); + result["CustomCss"] = Jellyfin::Support::toJsonValue(m_customCss); return result; } @@ -65,6 +66,17 @@ void BrandingOptions::setCustomCss(QString newCustomCss) { m_customCss = newCustomCss; } +} // NS DTO + +namespace Support { + +using BrandingOptions = Jellyfin::DTO::BrandingOptions; + +template <> +BrandingOptions fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return BrandingOptions::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/bufferrequestdto.cpp b/core/src/DTO/bufferrequestdto.cpp index e77588b..fa1d0ad 100644 --- a/core/src/DTO/bufferrequestdto.cpp +++ b/core/src/DTO/bufferrequestdto.cpp @@ -32,28 +32,29 @@ namespace Jellyfin { namespace DTO { -BufferRequestDto::BufferRequestDto(QObject *parent) {} +BufferRequestDto::BufferRequestDto() {} -BufferRequestDto BufferRequestDto::fromJson(QJsonObject source) {BufferRequestDto instance; - instance->setFromJson(source, false); +BufferRequestDto BufferRequestDto::fromJson(QJsonObject source) { + BufferRequestDto instance; + instance.setFromJson(source); return instance; } void BufferRequestDto::setFromJson(QJsonObject source) { - m_when = fromJsonValue(source["When"]); - m_positionTicks = fromJsonValue(source["PositionTicks"]); - m_isPlaying = fromJsonValue(source["IsPlaying"]); - m_playlistItemId = fromJsonValue(source["PlaylistItemId"]); + m_when = Jellyfin::Support::fromJsonValue(source["When"]); + m_positionTicks = Jellyfin::Support::fromJsonValue(source["PositionTicks"]); + m_isPlaying = Jellyfin::Support::fromJsonValue(source["IsPlaying"]); + m_playlistItemId = Jellyfin::Support::fromJsonValue(source["PlaylistItemId"]); } QJsonObject BufferRequestDto::toJson() { QJsonObject result; - result["When"] = toJsonValue(m_when); - result["PositionTicks"] = toJsonValue(m_positionTicks); - result["IsPlaying"] = toJsonValue(m_isPlaying); - result["PlaylistItemId"] = toJsonValue(m_playlistItemId); + result["When"] = Jellyfin::Support::toJsonValue(m_when); + result["PositionTicks"] = Jellyfin::Support::toJsonValue(m_positionTicks); + result["IsPlaying"] = Jellyfin::Support::toJsonValue(m_isPlaying); + result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); return result; } @@ -79,6 +80,17 @@ void BufferRequestDto::setPlaylistItemId(QUuid newPlaylistItemId) { m_playlistItemId = newPlaylistItemId; } +} // NS DTO + +namespace Support { + +using BufferRequestDto = Jellyfin::DTO::BufferRequestDto; + +template <> +BufferRequestDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return BufferRequestDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/channelfeatures.cpp b/core/src/DTO/channelfeatures.cpp index 371adb1..c089e78 100644 --- a/core/src/DTO/channelfeatures.cpp +++ b/core/src/DTO/channelfeatures.cpp @@ -32,44 +32,45 @@ namespace Jellyfin { namespace DTO { -ChannelFeatures::ChannelFeatures(QObject *parent) {} +ChannelFeatures::ChannelFeatures() {} -ChannelFeatures ChannelFeatures::fromJson(QJsonObject source) {ChannelFeatures instance; - instance->setFromJson(source, false); +ChannelFeatures ChannelFeatures::fromJson(QJsonObject source) { + ChannelFeatures instance; + instance.setFromJson(source); return instance; } void ChannelFeatures::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_jellyfinId = fromJsonValue(source["Id"]); - m_canSearch = fromJsonValue(source["CanSearch"]); - m_mediaTypes = fromJsonValue>(source["MediaTypes"]); - m_contentTypes = fromJsonValue>(source["ContentTypes"]); - m_maxPageSize = fromJsonValue(source["MaxPageSize"]); - m_autoRefreshLevels = fromJsonValue(source["AutoRefreshLevels"]); - m_defaultSortFields = fromJsonValue>(source["DefaultSortFields"]); - m_supportsSortOrderToggle = fromJsonValue(source["SupportsSortOrderToggle"]); - m_supportsLatestMedia = fromJsonValue(source["SupportsLatestMedia"]); - m_canFilter = fromJsonValue(source["CanFilter"]); - m_supportsContentDownloading = fromJsonValue(source["SupportsContentDownloading"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); + m_canSearch = Jellyfin::Support::fromJsonValue(source["CanSearch"]); + m_mediaTypes = Jellyfin::Support::fromJsonValue>(source["MediaTypes"]); + m_contentTypes = Jellyfin::Support::fromJsonValue>(source["ContentTypes"]); + m_maxPageSize = Jellyfin::Support::fromJsonValue(source["MaxPageSize"]); + m_autoRefreshLevels = Jellyfin::Support::fromJsonValue(source["AutoRefreshLevels"]); + m_defaultSortFields = Jellyfin::Support::fromJsonValue>(source["DefaultSortFields"]); + m_supportsSortOrderToggle = Jellyfin::Support::fromJsonValue(source["SupportsSortOrderToggle"]); + m_supportsLatestMedia = Jellyfin::Support::fromJsonValue(source["SupportsLatestMedia"]); + m_canFilter = Jellyfin::Support::fromJsonValue(source["CanFilter"]); + m_supportsContentDownloading = Jellyfin::Support::fromJsonValue(source["SupportsContentDownloading"]); } QJsonObject ChannelFeatures::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Id"] = toJsonValue(m_jellyfinId); - result["CanSearch"] = toJsonValue(m_canSearch); - result["MediaTypes"] = toJsonValue>(m_mediaTypes); - result["ContentTypes"] = toJsonValue>(m_contentTypes); - result["MaxPageSize"] = toJsonValue(m_maxPageSize); - result["AutoRefreshLevels"] = toJsonValue(m_autoRefreshLevels); - result["DefaultSortFields"] = toJsonValue>(m_defaultSortFields); - result["SupportsSortOrderToggle"] = toJsonValue(m_supportsSortOrderToggle); - result["SupportsLatestMedia"] = toJsonValue(m_supportsLatestMedia); - result["CanFilter"] = toJsonValue(m_canFilter); - result["SupportsContentDownloading"] = toJsonValue(m_supportsContentDownloading); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["CanSearch"] = Jellyfin::Support::toJsonValue(m_canSearch); + result["MediaTypes"] = Jellyfin::Support::toJsonValue>(m_mediaTypes); + result["ContentTypes"] = Jellyfin::Support::toJsonValue>(m_contentTypes); + result["MaxPageSize"] = Jellyfin::Support::toJsonValue(m_maxPageSize); + result["AutoRefreshLevels"] = Jellyfin::Support::toJsonValue(m_autoRefreshLevels); + result["DefaultSortFields"] = Jellyfin::Support::toJsonValue>(m_defaultSortFields); + result["SupportsSortOrderToggle"] = Jellyfin::Support::toJsonValue(m_supportsSortOrderToggle); + result["SupportsLatestMedia"] = Jellyfin::Support::toJsonValue(m_supportsLatestMedia); + result["CanFilter"] = Jellyfin::Support::toJsonValue(m_canFilter); + result["SupportsContentDownloading"] = Jellyfin::Support::toJsonValue(m_supportsContentDownloading); return result; } @@ -135,6 +136,17 @@ void ChannelFeatures::setSupportsContentDownloading(bool newSupportsContentDownl m_supportsContentDownloading = newSupportsContentDownloading; } +} // NS DTO + +namespace Support { + +using ChannelFeatures = Jellyfin::DTO::ChannelFeatures; + +template <> +ChannelFeatures fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ChannelFeatures::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/channelitemsortfield.cpp b/core/src/DTO/channelitemsortfield.cpp index 04485e6..986a9cd 100644 --- a/core/src/DTO/channelitemsortfield.cpp +++ b/core/src/DTO/channelitemsortfield.cpp @@ -34,5 +34,42 @@ namespace DTO { ChannelItemSortFieldClass::ChannelItemSortFieldClass() {} + +} // NS DTO + +namespace Support { + +using ChannelItemSortField = Jellyfin::DTO::ChannelItemSortField; + +template <> +ChannelItemSortField fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return ChannelItemSortField::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Name")) { + return ChannelItemSortField::Name; + } + if (str == QStringLiteral("CommunityRating")) { + return ChannelItemSortField::CommunityRating; + } + if (str == QStringLiteral("PremiereDate")) { + return ChannelItemSortField::PremiereDate; + } + if (str == QStringLiteral("DateCreated")) { + return ChannelItemSortField::DateCreated; + } + if (str == QStringLiteral("Runtime")) { + return ChannelItemSortField::Runtime; + } + if (str == QStringLiteral("PlayCount")) { + return ChannelItemSortField::PlayCount; + } + if (str == QStringLiteral("CommunityPlayCount")) { + return ChannelItemSortField::CommunityPlayCount; + } + + return ChannelItemSortField::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/channelmappingoptionsdto.cpp b/core/src/DTO/channelmappingoptionsdto.cpp index 93dfbf6..3af1e35 100644 --- a/core/src/DTO/channelmappingoptionsdto.cpp +++ b/core/src/DTO/channelmappingoptionsdto.cpp @@ -32,28 +32,29 @@ namespace Jellyfin { namespace DTO { -ChannelMappingOptionsDto::ChannelMappingOptionsDto(QObject *parent) {} +ChannelMappingOptionsDto::ChannelMappingOptionsDto() {} -ChannelMappingOptionsDto ChannelMappingOptionsDto::fromJson(QJsonObject source) {ChannelMappingOptionsDto instance; - instance->setFromJson(source, false); +ChannelMappingOptionsDto ChannelMappingOptionsDto::fromJson(QJsonObject source) { + ChannelMappingOptionsDto instance; + instance.setFromJson(source); return instance; } void ChannelMappingOptionsDto::setFromJson(QJsonObject source) { - m_tunerChannels = fromJsonValue>>(source["TunerChannels"]); - m_providerChannels = fromJsonValue>>(source["ProviderChannels"]); - m_mappings = fromJsonValue>>(source["Mappings"]); - m_providerName = fromJsonValue(source["ProviderName"]); + m_tunerChannels = Jellyfin::Support::fromJsonValue>>(source["TunerChannels"]); + m_providerChannels = Jellyfin::Support::fromJsonValue>>(source["ProviderChannels"]); + m_mappings = Jellyfin::Support::fromJsonValue>>(source["Mappings"]); + m_providerName = Jellyfin::Support::fromJsonValue(source["ProviderName"]); } QJsonObject ChannelMappingOptionsDto::toJson() { QJsonObject result; - result["TunerChannels"] = toJsonValue>>(m_tunerChannels); - result["ProviderChannels"] = toJsonValue>>(m_providerChannels); - result["Mappings"] = toJsonValue>>(m_mappings); - result["ProviderName"] = toJsonValue(m_providerName); + result["TunerChannels"] = Jellyfin::Support::toJsonValue>>(m_tunerChannels); + result["ProviderChannels"] = Jellyfin::Support::toJsonValue>>(m_providerChannels); + result["Mappings"] = Jellyfin::Support::toJsonValue>>(m_mappings); + result["ProviderName"] = Jellyfin::Support::toJsonValue(m_providerName); return result; } @@ -79,6 +80,17 @@ void ChannelMappingOptionsDto::setProviderName(QString newProviderName) { m_providerName = newProviderName; } +} // NS DTO + +namespace Support { + +using ChannelMappingOptionsDto = Jellyfin::DTO::ChannelMappingOptionsDto; + +template <> +ChannelMappingOptionsDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ChannelMappingOptionsDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/channelmediacontenttype.cpp b/core/src/DTO/channelmediacontenttype.cpp index 509fda4..926a763 100644 --- a/core/src/DTO/channelmediacontenttype.cpp +++ b/core/src/DTO/channelmediacontenttype.cpp @@ -34,5 +34,45 @@ namespace DTO { ChannelMediaContentTypeClass::ChannelMediaContentTypeClass() {} + +} // NS DTO + +namespace Support { + +using ChannelMediaContentType = Jellyfin::DTO::ChannelMediaContentType; + +template <> +ChannelMediaContentType fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return ChannelMediaContentType::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Clip")) { + return ChannelMediaContentType::Clip; + } + if (str == QStringLiteral("Podcast")) { + return ChannelMediaContentType::Podcast; + } + if (str == QStringLiteral("Trailer")) { + return ChannelMediaContentType::Trailer; + } + if (str == QStringLiteral("Movie")) { + return ChannelMediaContentType::Movie; + } + if (str == QStringLiteral("Episode")) { + return ChannelMediaContentType::Episode; + } + if (str == QStringLiteral("Song")) { + return ChannelMediaContentType::Song; + } + if (str == QStringLiteral("MovieExtra")) { + return ChannelMediaContentType::MovieExtra; + } + if (str == QStringLiteral("TvExtra")) { + return ChannelMediaContentType::TvExtra; + } + + return ChannelMediaContentType::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/channelmediatype.cpp b/core/src/DTO/channelmediatype.cpp index f312205..2ae2018 100644 --- a/core/src/DTO/channelmediatype.cpp +++ b/core/src/DTO/channelmediatype.cpp @@ -34,5 +34,30 @@ namespace DTO { ChannelMediaTypeClass::ChannelMediaTypeClass() {} + +} // NS DTO + +namespace Support { + +using ChannelMediaType = Jellyfin::DTO::ChannelMediaType; + +template <> +ChannelMediaType fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return ChannelMediaType::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Audio")) { + return ChannelMediaType::Audio; + } + if (str == QStringLiteral("Video")) { + return ChannelMediaType::Video; + } + if (str == QStringLiteral("Photo")) { + return ChannelMediaType::Photo; + } + + return ChannelMediaType::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/channeltype.cpp b/core/src/DTO/channeltype.cpp index 2ae979c..770cb15 100644 --- a/core/src/DTO/channeltype.cpp +++ b/core/src/DTO/channeltype.cpp @@ -34,5 +34,27 @@ namespace DTO { ChannelTypeClass::ChannelTypeClass() {} + +} // NS DTO + +namespace Support { + +using ChannelType = Jellyfin::DTO::ChannelType; + +template <> +ChannelType fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return ChannelType::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("TV")) { + return ChannelType::TV; + } + if (str == QStringLiteral("Radio")) { + return ChannelType::Radio; + } + + return ChannelType::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/chapterinfo.cpp b/core/src/DTO/chapterinfo.cpp index 86d76a3..07ab300 100644 --- a/core/src/DTO/chapterinfo.cpp +++ b/core/src/DTO/chapterinfo.cpp @@ -32,30 +32,31 @@ namespace Jellyfin { namespace DTO { -ChapterInfo::ChapterInfo(QObject *parent) {} +ChapterInfo::ChapterInfo() {} -ChapterInfo ChapterInfo::fromJson(QJsonObject source) {ChapterInfo instance; - instance->setFromJson(source, false); +ChapterInfo ChapterInfo::fromJson(QJsonObject source) { + ChapterInfo instance; + instance.setFromJson(source); return instance; } void ChapterInfo::setFromJson(QJsonObject source) { - m_startPositionTicks = fromJsonValue(source["StartPositionTicks"]); - m_name = fromJsonValue(source["Name"]); - m_imagePath = fromJsonValue(source["ImagePath"]); - m_imageDateModified = fromJsonValue(source["ImageDateModified"]); - m_imageTag = fromJsonValue(source["ImageTag"]); + m_startPositionTicks = Jellyfin::Support::fromJsonValue(source["StartPositionTicks"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_imagePath = Jellyfin::Support::fromJsonValue(source["ImagePath"]); + m_imageDateModified = Jellyfin::Support::fromJsonValue(source["ImageDateModified"]); + m_imageTag = Jellyfin::Support::fromJsonValue(source["ImageTag"]); } QJsonObject ChapterInfo::toJson() { QJsonObject result; - result["StartPositionTicks"] = toJsonValue(m_startPositionTicks); - result["Name"] = toJsonValue(m_name); - result["ImagePath"] = toJsonValue(m_imagePath); - result["ImageDateModified"] = toJsonValue(m_imageDateModified); - result["ImageTag"] = toJsonValue(m_imageTag); + result["StartPositionTicks"] = Jellyfin::Support::toJsonValue(m_startPositionTicks); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["ImagePath"] = Jellyfin::Support::toJsonValue(m_imagePath); + result["ImageDateModified"] = Jellyfin::Support::toJsonValue(m_imageDateModified); + result["ImageTag"] = Jellyfin::Support::toJsonValue(m_imageTag); return result; } @@ -86,6 +87,17 @@ void ChapterInfo::setImageTag(QString newImageTag) { m_imageTag = newImageTag; } +} // NS DTO + +namespace Support { + +using ChapterInfo = Jellyfin::DTO::ChapterInfo; + +template <> +ChapterInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ChapterInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/clientcapabilities.cpp b/core/src/DTO/clientcapabilities.cpp index f3d0e7c..a68d03d 100644 --- a/core/src/DTO/clientcapabilities.cpp +++ b/core/src/DTO/clientcapabilities.cpp @@ -32,40 +32,41 @@ namespace Jellyfin { namespace DTO { -ClientCapabilities::ClientCapabilities(QObject *parent) {} +ClientCapabilities::ClientCapabilities() {} -ClientCapabilities ClientCapabilities::fromJson(QJsonObject source) {ClientCapabilities instance; - instance->setFromJson(source, false); +ClientCapabilities ClientCapabilities::fromJson(QJsonObject source) { + ClientCapabilities instance; + instance.setFromJson(source); return instance; } void ClientCapabilities::setFromJson(QJsonObject source) { - m_playableMediaTypes = fromJsonValue(source["PlayableMediaTypes"]); - m_supportedCommands = fromJsonValue>(source["SupportedCommands"]); - m_supportsMediaControl = fromJsonValue(source["SupportsMediaControl"]); - m_supportsContentUploading = fromJsonValue(source["SupportsContentUploading"]); - m_messageCallbackUrl = fromJsonValue(source["MessageCallbackUrl"]); - m_supportsPersistentIdentifier = fromJsonValue(source["SupportsPersistentIdentifier"]); - m_supportsSync = fromJsonValue(source["SupportsSync"]); - m_deviceProfile = fromJsonValue>(source["DeviceProfile"]); - m_appStoreUrl = fromJsonValue(source["AppStoreUrl"]); - m_iconUrl = fromJsonValue(source["IconUrl"]); + m_playableMediaTypes = Jellyfin::Support::fromJsonValue(source["PlayableMediaTypes"]); + m_supportedCommands = Jellyfin::Support::fromJsonValue>(source["SupportedCommands"]); + m_supportsMediaControl = Jellyfin::Support::fromJsonValue(source["SupportsMediaControl"]); + m_supportsContentUploading = Jellyfin::Support::fromJsonValue(source["SupportsContentUploading"]); + m_messageCallbackUrl = Jellyfin::Support::fromJsonValue(source["MessageCallbackUrl"]); + m_supportsPersistentIdentifier = Jellyfin::Support::fromJsonValue(source["SupportsPersistentIdentifier"]); + m_supportsSync = Jellyfin::Support::fromJsonValue(source["SupportsSync"]); + m_deviceProfile = Jellyfin::Support::fromJsonValue>(source["DeviceProfile"]); + m_appStoreUrl = Jellyfin::Support::fromJsonValue(source["AppStoreUrl"]); + m_iconUrl = Jellyfin::Support::fromJsonValue(source["IconUrl"]); } QJsonObject ClientCapabilities::toJson() { QJsonObject result; - result["PlayableMediaTypes"] = toJsonValue(m_playableMediaTypes); - result["SupportedCommands"] = toJsonValue>(m_supportedCommands); - result["SupportsMediaControl"] = toJsonValue(m_supportsMediaControl); - result["SupportsContentUploading"] = toJsonValue(m_supportsContentUploading); - result["MessageCallbackUrl"] = toJsonValue(m_messageCallbackUrl); - result["SupportsPersistentIdentifier"] = toJsonValue(m_supportsPersistentIdentifier); - result["SupportsSync"] = toJsonValue(m_supportsSync); - result["DeviceProfile"] = toJsonValue>(m_deviceProfile); - result["AppStoreUrl"] = toJsonValue(m_appStoreUrl); - result["IconUrl"] = toJsonValue(m_iconUrl); + result["PlayableMediaTypes"] = Jellyfin::Support::toJsonValue(m_playableMediaTypes); + result["SupportedCommands"] = Jellyfin::Support::toJsonValue>(m_supportedCommands); + result["SupportsMediaControl"] = Jellyfin::Support::toJsonValue(m_supportsMediaControl); + result["SupportsContentUploading"] = Jellyfin::Support::toJsonValue(m_supportsContentUploading); + result["MessageCallbackUrl"] = Jellyfin::Support::toJsonValue(m_messageCallbackUrl); + result["SupportsPersistentIdentifier"] = Jellyfin::Support::toJsonValue(m_supportsPersistentIdentifier); + result["SupportsSync"] = Jellyfin::Support::toJsonValue(m_supportsSync); + result["DeviceProfile"] = Jellyfin::Support::toJsonValue>(m_deviceProfile); + result["AppStoreUrl"] = Jellyfin::Support::toJsonValue(m_appStoreUrl); + result["IconUrl"] = Jellyfin::Support::toJsonValue(m_iconUrl); return result; } @@ -121,6 +122,17 @@ void ClientCapabilities::setIconUrl(QString newIconUrl) { m_iconUrl = newIconUrl; } +} // NS DTO + +namespace Support { + +using ClientCapabilities = Jellyfin::DTO::ClientCapabilities; + +template <> +ClientCapabilities fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ClientCapabilities::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/clientcapabilitiesdto.cpp b/core/src/DTO/clientcapabilitiesdto.cpp index a37e83d..d49d753 100644 --- a/core/src/DTO/clientcapabilitiesdto.cpp +++ b/core/src/DTO/clientcapabilitiesdto.cpp @@ -32,40 +32,41 @@ namespace Jellyfin { namespace DTO { -ClientCapabilitiesDto::ClientCapabilitiesDto(QObject *parent) {} +ClientCapabilitiesDto::ClientCapabilitiesDto() {} -ClientCapabilitiesDto ClientCapabilitiesDto::fromJson(QJsonObject source) {ClientCapabilitiesDto instance; - instance->setFromJson(source, false); +ClientCapabilitiesDto ClientCapabilitiesDto::fromJson(QJsonObject source) { + ClientCapabilitiesDto instance; + instance.setFromJson(source); return instance; } void ClientCapabilitiesDto::setFromJson(QJsonObject source) { - m_playableMediaTypes = fromJsonValue(source["PlayableMediaTypes"]); - m_supportedCommands = fromJsonValue>(source["SupportedCommands"]); - m_supportsMediaControl = fromJsonValue(source["SupportsMediaControl"]); - m_supportsContentUploading = fromJsonValue(source["SupportsContentUploading"]); - m_messageCallbackUrl = fromJsonValue(source["MessageCallbackUrl"]); - m_supportsPersistentIdentifier = fromJsonValue(source["SupportsPersistentIdentifier"]); - m_supportsSync = fromJsonValue(source["SupportsSync"]); - m_deviceProfile = fromJsonValue>(source["DeviceProfile"]); - m_appStoreUrl = fromJsonValue(source["AppStoreUrl"]); - m_iconUrl = fromJsonValue(source["IconUrl"]); + m_playableMediaTypes = Jellyfin::Support::fromJsonValue(source["PlayableMediaTypes"]); + m_supportedCommands = Jellyfin::Support::fromJsonValue>(source["SupportedCommands"]); + m_supportsMediaControl = Jellyfin::Support::fromJsonValue(source["SupportsMediaControl"]); + m_supportsContentUploading = Jellyfin::Support::fromJsonValue(source["SupportsContentUploading"]); + m_messageCallbackUrl = Jellyfin::Support::fromJsonValue(source["MessageCallbackUrl"]); + m_supportsPersistentIdentifier = Jellyfin::Support::fromJsonValue(source["SupportsPersistentIdentifier"]); + m_supportsSync = Jellyfin::Support::fromJsonValue(source["SupportsSync"]); + m_deviceProfile = Jellyfin::Support::fromJsonValue>(source["DeviceProfile"]); + m_appStoreUrl = Jellyfin::Support::fromJsonValue(source["AppStoreUrl"]); + m_iconUrl = Jellyfin::Support::fromJsonValue(source["IconUrl"]); } QJsonObject ClientCapabilitiesDto::toJson() { QJsonObject result; - result["PlayableMediaTypes"] = toJsonValue(m_playableMediaTypes); - result["SupportedCommands"] = toJsonValue>(m_supportedCommands); - result["SupportsMediaControl"] = toJsonValue(m_supportsMediaControl); - result["SupportsContentUploading"] = toJsonValue(m_supportsContentUploading); - result["MessageCallbackUrl"] = toJsonValue(m_messageCallbackUrl); - result["SupportsPersistentIdentifier"] = toJsonValue(m_supportsPersistentIdentifier); - result["SupportsSync"] = toJsonValue(m_supportsSync); - result["DeviceProfile"] = toJsonValue>(m_deviceProfile); - result["AppStoreUrl"] = toJsonValue(m_appStoreUrl); - result["IconUrl"] = toJsonValue(m_iconUrl); + result["PlayableMediaTypes"] = Jellyfin::Support::toJsonValue(m_playableMediaTypes); + result["SupportedCommands"] = Jellyfin::Support::toJsonValue>(m_supportedCommands); + result["SupportsMediaControl"] = Jellyfin::Support::toJsonValue(m_supportsMediaControl); + result["SupportsContentUploading"] = Jellyfin::Support::toJsonValue(m_supportsContentUploading); + result["MessageCallbackUrl"] = Jellyfin::Support::toJsonValue(m_messageCallbackUrl); + result["SupportsPersistentIdentifier"] = Jellyfin::Support::toJsonValue(m_supportsPersistentIdentifier); + result["SupportsSync"] = Jellyfin::Support::toJsonValue(m_supportsSync); + result["DeviceProfile"] = Jellyfin::Support::toJsonValue>(m_deviceProfile); + result["AppStoreUrl"] = Jellyfin::Support::toJsonValue(m_appStoreUrl); + result["IconUrl"] = Jellyfin::Support::toJsonValue(m_iconUrl); return result; } @@ -121,6 +122,17 @@ void ClientCapabilitiesDto::setIconUrl(QString newIconUrl) { m_iconUrl = newIconUrl; } +} // NS DTO + +namespace Support { + +using ClientCapabilitiesDto = Jellyfin::DTO::ClientCapabilitiesDto; + +template <> +ClientCapabilitiesDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ClientCapabilitiesDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/codecprofile.cpp b/core/src/DTO/codecprofile.cpp index 87a6d14..ef94411 100644 --- a/core/src/DTO/codecprofile.cpp +++ b/core/src/DTO/codecprofile.cpp @@ -32,30 +32,31 @@ namespace Jellyfin { namespace DTO { -CodecProfile::CodecProfile(QObject *parent) {} +CodecProfile::CodecProfile() {} -CodecProfile CodecProfile::fromJson(QJsonObject source) {CodecProfile instance; - instance->setFromJson(source, false); +CodecProfile CodecProfile::fromJson(QJsonObject source) { + CodecProfile instance; + instance.setFromJson(source); return instance; } void CodecProfile::setFromJson(QJsonObject source) { - m_type = fromJsonValue(source["Type"]); - m_conditions = fromJsonValue>>(source["Conditions"]); - m_applyConditions = fromJsonValue>>(source["ApplyConditions"]); - m_codec = fromJsonValue(source["Codec"]); - m_container = fromJsonValue(source["Container"]); + m_type = Jellyfin::Support::fromJsonValue(source["Type"]); + m_conditions = Jellyfin::Support::fromJsonValue>>(source["Conditions"]); + m_applyConditions = Jellyfin::Support::fromJsonValue>>(source["ApplyConditions"]); + m_codec = Jellyfin::Support::fromJsonValue(source["Codec"]); + m_container = Jellyfin::Support::fromJsonValue(source["Container"]); } QJsonObject CodecProfile::toJson() { QJsonObject result; - result["Type"] = toJsonValue(m_type); - result["Conditions"] = toJsonValue>>(m_conditions); - result["ApplyConditions"] = toJsonValue>>(m_applyConditions); - result["Codec"] = toJsonValue(m_codec); - result["Container"] = toJsonValue(m_container); + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + result["Conditions"] = Jellyfin::Support::toJsonValue>>(m_conditions); + result["ApplyConditions"] = Jellyfin::Support::toJsonValue>>(m_applyConditions); + result["Codec"] = Jellyfin::Support::toJsonValue(m_codec); + result["Container"] = Jellyfin::Support::toJsonValue(m_container); return result; } @@ -86,6 +87,17 @@ void CodecProfile::setContainer(QString newContainer) { m_container = newContainer; } +} // NS DTO + +namespace Support { + +using CodecProfile = Jellyfin::DTO::CodecProfile; + +template <> +CodecProfile fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return CodecProfile::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/codectype.cpp b/core/src/DTO/codectype.cpp index 7c20326..5675a4f 100644 --- a/core/src/DTO/codectype.cpp +++ b/core/src/DTO/codectype.cpp @@ -34,5 +34,30 @@ namespace DTO { CodecTypeClass::CodecTypeClass() {} + +} // NS DTO + +namespace Support { + +using CodecType = Jellyfin::DTO::CodecType; + +template <> +CodecType fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return CodecType::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Video")) { + return CodecType::Video; + } + if (str == QStringLiteral("VideoAudio")) { + return CodecType::VideoAudio; + } + if (str == QStringLiteral("Audio")) { + return CodecType::Audio; + } + + return CodecType::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/collectioncreationresult.cpp b/core/src/DTO/collectioncreationresult.cpp index 318934e..f20ee28 100644 --- a/core/src/DTO/collectioncreationresult.cpp +++ b/core/src/DTO/collectioncreationresult.cpp @@ -32,22 +32,23 @@ namespace Jellyfin { namespace DTO { -CollectionCreationResult::CollectionCreationResult(QObject *parent) {} +CollectionCreationResult::CollectionCreationResult() {} -CollectionCreationResult CollectionCreationResult::fromJson(QJsonObject source) {CollectionCreationResult instance; - instance->setFromJson(source, false); +CollectionCreationResult CollectionCreationResult::fromJson(QJsonObject source) { + CollectionCreationResult instance; + instance.setFromJson(source); return instance; } void CollectionCreationResult::setFromJson(QJsonObject source) { - m_jellyfinId = fromJsonValue(source["Id"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); } QJsonObject CollectionCreationResult::toJson() { QJsonObject result; - result["Id"] = toJsonValue(m_jellyfinId); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); return result; } @@ -58,6 +59,17 @@ void CollectionCreationResult::setJellyfinId(QUuid newJellyfinId) { m_jellyfinId = newJellyfinId; } +} // NS DTO + +namespace Support { + +using CollectionCreationResult = Jellyfin::DTO::CollectionCreationResult; + +template <> +CollectionCreationResult fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return CollectionCreationResult::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/configurationpageinfo.cpp b/core/src/DTO/configurationpageinfo.cpp index 42ef061..8ba52c6 100644 --- a/core/src/DTO/configurationpageinfo.cpp +++ b/core/src/DTO/configurationpageinfo.cpp @@ -32,34 +32,35 @@ namespace Jellyfin { namespace DTO { -ConfigurationPageInfo::ConfigurationPageInfo(QObject *parent) {} +ConfigurationPageInfo::ConfigurationPageInfo() {} -ConfigurationPageInfo ConfigurationPageInfo::fromJson(QJsonObject source) {ConfigurationPageInfo instance; - instance->setFromJson(source, false); +ConfigurationPageInfo ConfigurationPageInfo::fromJson(QJsonObject source) { + ConfigurationPageInfo instance; + instance.setFromJson(source); return instance; } void ConfigurationPageInfo::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_enableInMainMenu = fromJsonValue(source["EnableInMainMenu"]); - m_menuSection = fromJsonValue(source["MenuSection"]); - m_menuIcon = fromJsonValue(source["MenuIcon"]); - m_displayName = fromJsonValue(source["DisplayName"]); - m_configurationPageType = fromJsonValue(source["ConfigurationPageType"]); - m_pluginId = fromJsonValue(source["PluginId"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_enableInMainMenu = Jellyfin::Support::fromJsonValue(source["EnableInMainMenu"]); + m_menuSection = Jellyfin::Support::fromJsonValue(source["MenuSection"]); + m_menuIcon = Jellyfin::Support::fromJsonValue(source["MenuIcon"]); + m_displayName = Jellyfin::Support::fromJsonValue(source["DisplayName"]); + m_configurationPageType = Jellyfin::Support::fromJsonValue(source["ConfigurationPageType"]); + m_pluginId = Jellyfin::Support::fromJsonValue(source["PluginId"]); } QJsonObject ConfigurationPageInfo::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["EnableInMainMenu"] = toJsonValue(m_enableInMainMenu); - result["MenuSection"] = toJsonValue(m_menuSection); - result["MenuIcon"] = toJsonValue(m_menuIcon); - result["DisplayName"] = toJsonValue(m_displayName); - result["ConfigurationPageType"] = toJsonValue(m_configurationPageType); - result["PluginId"] = toJsonValue(m_pluginId); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["EnableInMainMenu"] = Jellyfin::Support::toJsonValue(m_enableInMainMenu); + result["MenuSection"] = Jellyfin::Support::toJsonValue(m_menuSection); + result["MenuIcon"] = Jellyfin::Support::toJsonValue(m_menuIcon); + result["DisplayName"] = Jellyfin::Support::toJsonValue(m_displayName); + result["ConfigurationPageType"] = Jellyfin::Support::toJsonValue(m_configurationPageType); + result["PluginId"] = Jellyfin::Support::toJsonValue(m_pluginId); return result; } @@ -100,6 +101,17 @@ void ConfigurationPageInfo::setPluginId(QUuid newPluginId) { m_pluginId = newPluginId; } +} // NS DTO + +namespace Support { + +using ConfigurationPageInfo = Jellyfin::DTO::ConfigurationPageInfo; + +template <> +ConfigurationPageInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ConfigurationPageInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/configurationpagetype.cpp b/core/src/DTO/configurationpagetype.cpp index e109cb9..59c4ecc 100644 --- a/core/src/DTO/configurationpagetype.cpp +++ b/core/src/DTO/configurationpagetype.cpp @@ -34,5 +34,27 @@ namespace DTO { ConfigurationPageTypeClass::ConfigurationPageTypeClass() {} + +} // NS DTO + +namespace Support { + +using ConfigurationPageType = Jellyfin::DTO::ConfigurationPageType; + +template <> +ConfigurationPageType fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return ConfigurationPageType::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("PluginConfiguration")) { + return ConfigurationPageType::PluginConfiguration; + } + if (str == QStringLiteral("None")) { + return ConfigurationPageType::None; + } + + return ConfigurationPageType::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/containerprofile.cpp b/core/src/DTO/containerprofile.cpp index d0cca95..bad1605 100644 --- a/core/src/DTO/containerprofile.cpp +++ b/core/src/DTO/containerprofile.cpp @@ -32,26 +32,27 @@ namespace Jellyfin { namespace DTO { -ContainerProfile::ContainerProfile(QObject *parent) {} +ContainerProfile::ContainerProfile() {} -ContainerProfile ContainerProfile::fromJson(QJsonObject source) {ContainerProfile instance; - instance->setFromJson(source, false); +ContainerProfile ContainerProfile::fromJson(QJsonObject source) { + ContainerProfile instance; + instance.setFromJson(source); return instance; } void ContainerProfile::setFromJson(QJsonObject source) { - m_type = fromJsonValue(source["Type"]); - m_conditions = fromJsonValue>>(source["Conditions"]); - m_container = fromJsonValue(source["Container"]); + m_type = Jellyfin::Support::fromJsonValue(source["Type"]); + m_conditions = Jellyfin::Support::fromJsonValue>>(source["Conditions"]); + m_container = Jellyfin::Support::fromJsonValue(source["Container"]); } QJsonObject ContainerProfile::toJson() { QJsonObject result; - result["Type"] = toJsonValue(m_type); - result["Conditions"] = toJsonValue>>(m_conditions); - result["Container"] = toJsonValue(m_container); + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + result["Conditions"] = Jellyfin::Support::toJsonValue>>(m_conditions); + result["Container"] = Jellyfin::Support::toJsonValue(m_container); return result; } @@ -72,6 +73,17 @@ void ContainerProfile::setContainer(QString newContainer) { m_container = newContainer; } +} // NS DTO + +namespace Support { + +using ContainerProfile = Jellyfin::DTO::ContainerProfile; + +template <> +ContainerProfile fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ContainerProfile::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/controlresponse.cpp b/core/src/DTO/controlresponse.cpp index 529f77e..c914e90 100644 --- a/core/src/DTO/controlresponse.cpp +++ b/core/src/DTO/controlresponse.cpp @@ -32,26 +32,27 @@ namespace Jellyfin { namespace DTO { -ControlResponse::ControlResponse(QObject *parent) {} +ControlResponse::ControlResponse() {} -ControlResponse ControlResponse::fromJson(QJsonObject source) {ControlResponse instance; - instance->setFromJson(source, false); +ControlResponse ControlResponse::fromJson(QJsonObject source) { + ControlResponse instance; + instance.setFromJson(source); return instance; } void ControlResponse::setFromJson(QJsonObject source) { - m_headers = fromJsonValue(source["Headers"]); - m_xml = fromJsonValue(source["Xml"]); - m_isSuccessful = fromJsonValue(source["IsSuccessful"]); + m_headers = Jellyfin::Support::fromJsonValue(source["Headers"]); + m_xml = Jellyfin::Support::fromJsonValue(source["Xml"]); + m_isSuccessful = Jellyfin::Support::fromJsonValue(source["IsSuccessful"]); } QJsonObject ControlResponse::toJson() { QJsonObject result; - result["Headers"] = toJsonValue(m_headers); - result["Xml"] = toJsonValue(m_xml); - result["IsSuccessful"] = toJsonValue(m_isSuccessful); + result["Headers"] = Jellyfin::Support::toJsonValue(m_headers); + result["Xml"] = Jellyfin::Support::toJsonValue(m_xml); + result["IsSuccessful"] = Jellyfin::Support::toJsonValue(m_isSuccessful); return result; } @@ -72,6 +73,17 @@ void ControlResponse::setIsSuccessful(bool newIsSuccessful) { m_isSuccessful = newIsSuccessful; } +} // NS DTO + +namespace Support { + +using ControlResponse = Jellyfin::DTO::ControlResponse; + +template <> +ControlResponse fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ControlResponse::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/countryinfo.cpp b/core/src/DTO/countryinfo.cpp index f6f2053..12b2f2d 100644 --- a/core/src/DTO/countryinfo.cpp +++ b/core/src/DTO/countryinfo.cpp @@ -32,28 +32,29 @@ namespace Jellyfin { namespace DTO { -CountryInfo::CountryInfo(QObject *parent) {} +CountryInfo::CountryInfo() {} -CountryInfo CountryInfo::fromJson(QJsonObject source) {CountryInfo instance; - instance->setFromJson(source, false); +CountryInfo CountryInfo::fromJson(QJsonObject source) { + CountryInfo instance; + instance.setFromJson(source); return instance; } void CountryInfo::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_displayName = fromJsonValue(source["DisplayName"]); - m_twoLetterISORegionName = fromJsonValue(source["TwoLetterISORegionName"]); - m_threeLetterISORegionName = fromJsonValue(source["ThreeLetterISORegionName"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_displayName = Jellyfin::Support::fromJsonValue(source["DisplayName"]); + m_twoLetterISORegionName = Jellyfin::Support::fromJsonValue(source["TwoLetterISORegionName"]); + m_threeLetterISORegionName = Jellyfin::Support::fromJsonValue(source["ThreeLetterISORegionName"]); } QJsonObject CountryInfo::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["DisplayName"] = toJsonValue(m_displayName); - result["TwoLetterISORegionName"] = toJsonValue(m_twoLetterISORegionName); - result["ThreeLetterISORegionName"] = toJsonValue(m_threeLetterISORegionName); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["DisplayName"] = Jellyfin::Support::toJsonValue(m_displayName); + result["TwoLetterISORegionName"] = Jellyfin::Support::toJsonValue(m_twoLetterISORegionName); + result["ThreeLetterISORegionName"] = Jellyfin::Support::toJsonValue(m_threeLetterISORegionName); return result; } @@ -79,6 +80,17 @@ void CountryInfo::setThreeLetterISORegionName(QString newThreeLetterISORegionNam m_threeLetterISORegionName = newThreeLetterISORegionName; } +} // NS DTO + +namespace Support { + +using CountryInfo = Jellyfin::DTO::CountryInfo; + +template <> +CountryInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return CountryInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/createplaylistdto.cpp b/core/src/DTO/createplaylistdto.cpp index b9a859d..c89239f 100644 --- a/core/src/DTO/createplaylistdto.cpp +++ b/core/src/DTO/createplaylistdto.cpp @@ -32,28 +32,29 @@ namespace Jellyfin { namespace DTO { -CreatePlaylistDto::CreatePlaylistDto(QObject *parent) {} +CreatePlaylistDto::CreatePlaylistDto() {} -CreatePlaylistDto CreatePlaylistDto::fromJson(QJsonObject source) {CreatePlaylistDto instance; - instance->setFromJson(source, false); +CreatePlaylistDto CreatePlaylistDto::fromJson(QJsonObject source) { + CreatePlaylistDto instance; + instance.setFromJson(source); return instance; } void CreatePlaylistDto::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_ids = fromJsonValue>(source["Ids"]); - m_userId = fromJsonValue(source["UserId"]); - m_mediaType = fromJsonValue(source["MediaType"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_ids = Jellyfin::Support::fromJsonValue>(source["Ids"]); + m_userId = Jellyfin::Support::fromJsonValue(source["UserId"]); + m_mediaType = Jellyfin::Support::fromJsonValue(source["MediaType"]); } QJsonObject CreatePlaylistDto::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Ids"] = toJsonValue>(m_ids); - result["UserId"] = toJsonValue(m_userId); - result["MediaType"] = toJsonValue(m_mediaType); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Ids"] = Jellyfin::Support::toJsonValue>(m_ids); + result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); + result["MediaType"] = Jellyfin::Support::toJsonValue(m_mediaType); return result; } @@ -79,6 +80,17 @@ void CreatePlaylistDto::setMediaType(QString newMediaType) { m_mediaType = newMediaType; } +} // NS DTO + +namespace Support { + +using CreatePlaylistDto = Jellyfin::DTO::CreatePlaylistDto; + +template <> +CreatePlaylistDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return CreatePlaylistDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/createuserbyname.cpp b/core/src/DTO/createuserbyname.cpp index dc13016..e157c80 100644 --- a/core/src/DTO/createuserbyname.cpp +++ b/core/src/DTO/createuserbyname.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -CreateUserByName::CreateUserByName(QObject *parent) {} +CreateUserByName::CreateUserByName() {} -CreateUserByName CreateUserByName::fromJson(QJsonObject source) {CreateUserByName instance; - instance->setFromJson(source, false); +CreateUserByName CreateUserByName::fromJson(QJsonObject source) { + CreateUserByName instance; + instance.setFromJson(source); return instance; } void CreateUserByName::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_password = fromJsonValue(source["Password"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_password = Jellyfin::Support::fromJsonValue(source["Password"]); } QJsonObject CreateUserByName::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Password"] = toJsonValue(m_password); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Password"] = Jellyfin::Support::toJsonValue(m_password); return result; } @@ -65,6 +66,17 @@ void CreateUserByName::setPassword(QString newPassword) { m_password = newPassword; } +} // NS DTO + +namespace Support { + +using CreateUserByName = Jellyfin::DTO::CreateUserByName; + +template <> +CreateUserByName fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return CreateUserByName::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/culturedto.cpp b/core/src/DTO/culturedto.cpp index e183080..5757eda 100644 --- a/core/src/DTO/culturedto.cpp +++ b/core/src/DTO/culturedto.cpp @@ -32,30 +32,31 @@ namespace Jellyfin { namespace DTO { -CultureDto::CultureDto(QObject *parent) {} +CultureDto::CultureDto() {} -CultureDto CultureDto::fromJson(QJsonObject source) {CultureDto instance; - instance->setFromJson(source, false); +CultureDto CultureDto::fromJson(QJsonObject source) { + CultureDto instance; + instance.setFromJson(source); return instance; } void CultureDto::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_displayName = fromJsonValue(source["DisplayName"]); - m_twoLetterISOLanguageName = fromJsonValue(source["TwoLetterISOLanguageName"]); - m_threeLetterISOLanguageName = fromJsonValue(source["ThreeLetterISOLanguageName"]); - m_threeLetterISOLanguageNames = fromJsonValue(source["ThreeLetterISOLanguageNames"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_displayName = Jellyfin::Support::fromJsonValue(source["DisplayName"]); + m_twoLetterISOLanguageName = Jellyfin::Support::fromJsonValue(source["TwoLetterISOLanguageName"]); + m_threeLetterISOLanguageName = Jellyfin::Support::fromJsonValue(source["ThreeLetterISOLanguageName"]); + m_threeLetterISOLanguageNames = Jellyfin::Support::fromJsonValue(source["ThreeLetterISOLanguageNames"]); } QJsonObject CultureDto::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["DisplayName"] = toJsonValue(m_displayName); - result["TwoLetterISOLanguageName"] = toJsonValue(m_twoLetterISOLanguageName); - result["ThreeLetterISOLanguageName"] = toJsonValue(m_threeLetterISOLanguageName); - result["ThreeLetterISOLanguageNames"] = toJsonValue(m_threeLetterISOLanguageNames); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["DisplayName"] = Jellyfin::Support::toJsonValue(m_displayName); + result["TwoLetterISOLanguageName"] = Jellyfin::Support::toJsonValue(m_twoLetterISOLanguageName); + result["ThreeLetterISOLanguageName"] = Jellyfin::Support::toJsonValue(m_threeLetterISOLanguageName); + result["ThreeLetterISOLanguageNames"] = Jellyfin::Support::toJsonValue(m_threeLetterISOLanguageNames); return result; } @@ -86,6 +87,17 @@ void CultureDto::setThreeLetterISOLanguageNames(QStringList newThreeLetterISOLan m_threeLetterISOLanguageNames = newThreeLetterISOLanguageNames; } +} // NS DTO + +namespace Support { + +using CultureDto = Jellyfin::DTO::CultureDto; + +template <> +CultureDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return CultureDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/dayofweek.cpp b/core/src/DTO/dayofweek.cpp index 2494b96..a6cc5a2 100644 --- a/core/src/DTO/dayofweek.cpp +++ b/core/src/DTO/dayofweek.cpp @@ -34,5 +34,42 @@ namespace DTO { DayOfWeekClass::DayOfWeekClass() {} + +} // NS DTO + +namespace Support { + +using DayOfWeek = Jellyfin::DTO::DayOfWeek; + +template <> +DayOfWeek fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return DayOfWeek::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Sunday")) { + return DayOfWeek::Sunday; + } + if (str == QStringLiteral("Monday")) { + return DayOfWeek::Monday; + } + if (str == QStringLiteral("Tuesday")) { + return DayOfWeek::Tuesday; + } + if (str == QStringLiteral("Wednesday")) { + return DayOfWeek::Wednesday; + } + if (str == QStringLiteral("Thursday")) { + return DayOfWeek::Thursday; + } + if (str == QStringLiteral("Friday")) { + return DayOfWeek::Friday; + } + if (str == QStringLiteral("Saturday")) { + return DayOfWeek::Saturday; + } + + return DayOfWeek::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/daypattern.cpp b/core/src/DTO/daypattern.cpp index 433253d..72cf83e 100644 --- a/core/src/DTO/daypattern.cpp +++ b/core/src/DTO/daypattern.cpp @@ -34,5 +34,30 @@ namespace DTO { DayPatternClass::DayPatternClass() {} + +} // NS DTO + +namespace Support { + +using DayPattern = Jellyfin::DTO::DayPattern; + +template <> +DayPattern fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return DayPattern::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Daily")) { + return DayPattern::Daily; + } + if (str == QStringLiteral("Weekdays")) { + return DayPattern::Weekdays; + } + if (str == QStringLiteral("Weekends")) { + return DayPattern::Weekends; + } + + return DayPattern::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/defaultdirectorybrowserinfodto.cpp b/core/src/DTO/defaultdirectorybrowserinfodto.cpp index ad03f9c..859b904 100644 --- a/core/src/DTO/defaultdirectorybrowserinfodto.cpp +++ b/core/src/DTO/defaultdirectorybrowserinfodto.cpp @@ -32,22 +32,23 @@ namespace Jellyfin { namespace DTO { -DefaultDirectoryBrowserInfoDto::DefaultDirectoryBrowserInfoDto(QObject *parent) {} +DefaultDirectoryBrowserInfoDto::DefaultDirectoryBrowserInfoDto() {} -DefaultDirectoryBrowserInfoDto DefaultDirectoryBrowserInfoDto::fromJson(QJsonObject source) {DefaultDirectoryBrowserInfoDto instance; - instance->setFromJson(source, false); +DefaultDirectoryBrowserInfoDto DefaultDirectoryBrowserInfoDto::fromJson(QJsonObject source) { + DefaultDirectoryBrowserInfoDto instance; + instance.setFromJson(source); return instance; } void DefaultDirectoryBrowserInfoDto::setFromJson(QJsonObject source) { - m_path = fromJsonValue(source["Path"]); + m_path = Jellyfin::Support::fromJsonValue(source["Path"]); } QJsonObject DefaultDirectoryBrowserInfoDto::toJson() { QJsonObject result; - result["Path"] = toJsonValue(m_path); + result["Path"] = Jellyfin::Support::toJsonValue(m_path); return result; } @@ -58,6 +59,17 @@ void DefaultDirectoryBrowserInfoDto::setPath(QString newPath) { m_path = newPath; } +} // NS DTO + +namespace Support { + +using DefaultDirectoryBrowserInfoDto = Jellyfin::DTO::DefaultDirectoryBrowserInfoDto; + +template <> +DefaultDirectoryBrowserInfoDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return DefaultDirectoryBrowserInfoDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/deviceidentification.cpp b/core/src/DTO/deviceidentification.cpp index 4af656f..ba05bba 100644 --- a/core/src/DTO/deviceidentification.cpp +++ b/core/src/DTO/deviceidentification.cpp @@ -32,38 +32,39 @@ namespace Jellyfin { namespace DTO { -DeviceIdentification::DeviceIdentification(QObject *parent) {} +DeviceIdentification::DeviceIdentification() {} -DeviceIdentification DeviceIdentification::fromJson(QJsonObject source) {DeviceIdentification instance; - instance->setFromJson(source, false); +DeviceIdentification DeviceIdentification::fromJson(QJsonObject source) { + DeviceIdentification instance; + instance.setFromJson(source); return instance; } void DeviceIdentification::setFromJson(QJsonObject source) { - m_friendlyName = fromJsonValue(source["FriendlyName"]); - m_modelNumber = fromJsonValue(source["ModelNumber"]); - m_serialNumber = fromJsonValue(source["SerialNumber"]); - m_modelName = fromJsonValue(source["ModelName"]); - m_modelDescription = fromJsonValue(source["ModelDescription"]); - m_modelUrl = fromJsonValue(source["ModelUrl"]); - m_manufacturer = fromJsonValue(source["Manufacturer"]); - m_manufacturerUrl = fromJsonValue(source["ManufacturerUrl"]); - m_headers = fromJsonValue>>(source["Headers"]); + m_friendlyName = Jellyfin::Support::fromJsonValue(source["FriendlyName"]); + m_modelNumber = Jellyfin::Support::fromJsonValue(source["ModelNumber"]); + m_serialNumber = Jellyfin::Support::fromJsonValue(source["SerialNumber"]); + m_modelName = Jellyfin::Support::fromJsonValue(source["ModelName"]); + m_modelDescription = Jellyfin::Support::fromJsonValue(source["ModelDescription"]); + m_modelUrl = Jellyfin::Support::fromJsonValue(source["ModelUrl"]); + m_manufacturer = Jellyfin::Support::fromJsonValue(source["Manufacturer"]); + m_manufacturerUrl = Jellyfin::Support::fromJsonValue(source["ManufacturerUrl"]); + m_headers = Jellyfin::Support::fromJsonValue>>(source["Headers"]); } QJsonObject DeviceIdentification::toJson() { QJsonObject result; - result["FriendlyName"] = toJsonValue(m_friendlyName); - result["ModelNumber"] = toJsonValue(m_modelNumber); - result["SerialNumber"] = toJsonValue(m_serialNumber); - result["ModelName"] = toJsonValue(m_modelName); - result["ModelDescription"] = toJsonValue(m_modelDescription); - result["ModelUrl"] = toJsonValue(m_modelUrl); - result["Manufacturer"] = toJsonValue(m_manufacturer); - result["ManufacturerUrl"] = toJsonValue(m_manufacturerUrl); - result["Headers"] = toJsonValue>>(m_headers); + result["FriendlyName"] = Jellyfin::Support::toJsonValue(m_friendlyName); + result["ModelNumber"] = Jellyfin::Support::toJsonValue(m_modelNumber); + result["SerialNumber"] = Jellyfin::Support::toJsonValue(m_serialNumber); + result["ModelName"] = Jellyfin::Support::toJsonValue(m_modelName); + result["ModelDescription"] = Jellyfin::Support::toJsonValue(m_modelDescription); + result["ModelUrl"] = Jellyfin::Support::toJsonValue(m_modelUrl); + result["Manufacturer"] = Jellyfin::Support::toJsonValue(m_manufacturer); + result["ManufacturerUrl"] = Jellyfin::Support::toJsonValue(m_manufacturerUrl); + result["Headers"] = Jellyfin::Support::toJsonValue>>(m_headers); return result; } @@ -114,6 +115,17 @@ void DeviceIdentification::setHeaders(QList> newH m_headers = newHeaders; } +} // NS DTO + +namespace Support { + +using DeviceIdentification = Jellyfin::DTO::DeviceIdentification; + +template <> +DeviceIdentification fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return DeviceIdentification::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/deviceinfo.cpp b/core/src/DTO/deviceinfo.cpp index 4c339c3..2e92fa0 100644 --- a/core/src/DTO/deviceinfo.cpp +++ b/core/src/DTO/deviceinfo.cpp @@ -32,38 +32,39 @@ namespace Jellyfin { namespace DTO { -DeviceInfo::DeviceInfo(QObject *parent) {} +DeviceInfo::DeviceInfo() {} -DeviceInfo DeviceInfo::fromJson(QJsonObject source) {DeviceInfo instance; - instance->setFromJson(source, false); +DeviceInfo DeviceInfo::fromJson(QJsonObject source) { + DeviceInfo instance; + instance.setFromJson(source); return instance; } void DeviceInfo::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_jellyfinId = fromJsonValue(source["Id"]); - m_lastUserName = fromJsonValue(source["LastUserName"]); - m_appName = fromJsonValue(source["AppName"]); - m_appVersion = fromJsonValue(source["AppVersion"]); - m_lastUserId = fromJsonValue(source["LastUserId"]); - m_dateLastActivity = fromJsonValue(source["DateLastActivity"]); - m_capabilities = fromJsonValue>(source["Capabilities"]); - m_iconUrl = fromJsonValue(source["IconUrl"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); + m_lastUserName = Jellyfin::Support::fromJsonValue(source["LastUserName"]); + m_appName = Jellyfin::Support::fromJsonValue(source["AppName"]); + m_appVersion = Jellyfin::Support::fromJsonValue(source["AppVersion"]); + m_lastUserId = Jellyfin::Support::fromJsonValue(source["LastUserId"]); + m_dateLastActivity = Jellyfin::Support::fromJsonValue(source["DateLastActivity"]); + m_capabilities = Jellyfin::Support::fromJsonValue>(source["Capabilities"]); + m_iconUrl = Jellyfin::Support::fromJsonValue(source["IconUrl"]); } QJsonObject DeviceInfo::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Id"] = toJsonValue(m_jellyfinId); - result["LastUserName"] = toJsonValue(m_lastUserName); - result["AppName"] = toJsonValue(m_appName); - result["AppVersion"] = toJsonValue(m_appVersion); - result["LastUserId"] = toJsonValue(m_lastUserId); - result["DateLastActivity"] = toJsonValue(m_dateLastActivity); - result["Capabilities"] = toJsonValue>(m_capabilities); - result["IconUrl"] = toJsonValue(m_iconUrl); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["LastUserName"] = Jellyfin::Support::toJsonValue(m_lastUserName); + result["AppName"] = Jellyfin::Support::toJsonValue(m_appName); + result["AppVersion"] = Jellyfin::Support::toJsonValue(m_appVersion); + result["LastUserId"] = Jellyfin::Support::toJsonValue(m_lastUserId); + result["DateLastActivity"] = Jellyfin::Support::toJsonValue(m_dateLastActivity); + result["Capabilities"] = Jellyfin::Support::toJsonValue>(m_capabilities); + result["IconUrl"] = Jellyfin::Support::toJsonValue(m_iconUrl); return result; } @@ -114,6 +115,17 @@ void DeviceInfo::setIconUrl(QString newIconUrl) { m_iconUrl = newIconUrl; } +} // NS DTO + +namespace Support { + +using DeviceInfo = Jellyfin::DTO::DeviceInfo; + +template <> +DeviceInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return DeviceInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/deviceinfoqueryresult.cpp b/core/src/DTO/deviceinfoqueryresult.cpp index d4d9c08..4ad71b2 100644 --- a/core/src/DTO/deviceinfoqueryresult.cpp +++ b/core/src/DTO/deviceinfoqueryresult.cpp @@ -32,26 +32,27 @@ namespace Jellyfin { namespace DTO { -DeviceInfoQueryResult::DeviceInfoQueryResult(QObject *parent) {} +DeviceInfoQueryResult::DeviceInfoQueryResult() {} -DeviceInfoQueryResult DeviceInfoQueryResult::fromJson(QJsonObject source) {DeviceInfoQueryResult instance; - instance->setFromJson(source, false); +DeviceInfoQueryResult DeviceInfoQueryResult::fromJson(QJsonObject source) { + DeviceInfoQueryResult instance; + instance.setFromJson(source); return instance; } void DeviceInfoQueryResult::setFromJson(QJsonObject source) { - m_items = fromJsonValue>>(source["Items"]); - m_totalRecordCount = fromJsonValue(source["TotalRecordCount"]); - m_startIndex = fromJsonValue(source["StartIndex"]); + m_items = Jellyfin::Support::fromJsonValue>>(source["Items"]); + m_totalRecordCount = Jellyfin::Support::fromJsonValue(source["TotalRecordCount"]); + m_startIndex = Jellyfin::Support::fromJsonValue(source["StartIndex"]); } QJsonObject DeviceInfoQueryResult::toJson() { QJsonObject result; - result["Items"] = toJsonValue>>(m_items); - result["TotalRecordCount"] = toJsonValue(m_totalRecordCount); - result["StartIndex"] = toJsonValue(m_startIndex); + result["Items"] = Jellyfin::Support::toJsonValue>>(m_items); + result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); + result["StartIndex"] = Jellyfin::Support::toJsonValue(m_startIndex); return result; } @@ -72,6 +73,17 @@ void DeviceInfoQueryResult::setStartIndex(qint32 newStartIndex) { m_startIndex = newStartIndex; } +} // NS DTO + +namespace Support { + +using DeviceInfoQueryResult = Jellyfin::DTO::DeviceInfoQueryResult; + +template <> +DeviceInfoQueryResult fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return DeviceInfoQueryResult::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/deviceoptions.cpp b/core/src/DTO/deviceoptions.cpp index e3f1cef..3cc2e4a 100644 --- a/core/src/DTO/deviceoptions.cpp +++ b/core/src/DTO/deviceoptions.cpp @@ -32,22 +32,23 @@ namespace Jellyfin { namespace DTO { -DeviceOptions::DeviceOptions(QObject *parent) {} +DeviceOptions::DeviceOptions() {} -DeviceOptions DeviceOptions::fromJson(QJsonObject source) {DeviceOptions instance; - instance->setFromJson(source, false); +DeviceOptions DeviceOptions::fromJson(QJsonObject source) { + DeviceOptions instance; + instance.setFromJson(source); return instance; } void DeviceOptions::setFromJson(QJsonObject source) { - m_customName = fromJsonValue(source["CustomName"]); + m_customName = Jellyfin::Support::fromJsonValue(source["CustomName"]); } QJsonObject DeviceOptions::toJson() { QJsonObject result; - result["CustomName"] = toJsonValue(m_customName); + result["CustomName"] = Jellyfin::Support::toJsonValue(m_customName); return result; } @@ -58,6 +59,17 @@ void DeviceOptions::setCustomName(QString newCustomName) { m_customName = newCustomName; } +} // NS DTO + +namespace Support { + +using DeviceOptions = Jellyfin::DTO::DeviceOptions; + +template <> +DeviceOptions fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return DeviceOptions::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/deviceprofile.cpp b/core/src/DTO/deviceprofile.cpp index 5798324..610061a 100644 --- a/core/src/DTO/deviceprofile.cpp +++ b/core/src/DTO/deviceprofile.cpp @@ -32,98 +32,99 @@ namespace Jellyfin { namespace DTO { -DeviceProfile::DeviceProfile(QObject *parent) {} +DeviceProfile::DeviceProfile() {} -DeviceProfile DeviceProfile::fromJson(QJsonObject source) {DeviceProfile instance; - instance->setFromJson(source, false); +DeviceProfile DeviceProfile::fromJson(QJsonObject source) { + DeviceProfile instance; + instance.setFromJson(source); return instance; } void DeviceProfile::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_jellyfinId = fromJsonValue(source["Id"]); - m_identification = fromJsonValue>(source["Identification"]); - m_friendlyName = fromJsonValue(source["FriendlyName"]); - m_manufacturer = fromJsonValue(source["Manufacturer"]); - m_manufacturerUrl = fromJsonValue(source["ManufacturerUrl"]); - m_modelName = fromJsonValue(source["ModelName"]); - m_modelDescription = fromJsonValue(source["ModelDescription"]); - m_modelNumber = fromJsonValue(source["ModelNumber"]); - m_modelUrl = fromJsonValue(source["ModelUrl"]); - m_serialNumber = fromJsonValue(source["SerialNumber"]); - m_enableAlbumArtInDidl = fromJsonValue(source["EnableAlbumArtInDidl"]); - m_enableSingleAlbumArtLimit = fromJsonValue(source["EnableSingleAlbumArtLimit"]); - m_enableSingleSubtitleLimit = fromJsonValue(source["EnableSingleSubtitleLimit"]); - m_supportedMediaTypes = fromJsonValue(source["SupportedMediaTypes"]); - m_userId = fromJsonValue(source["UserId"]); - m_albumArtPn = fromJsonValue(source["AlbumArtPn"]); - m_maxAlbumArtWidth = fromJsonValue(source["MaxAlbumArtWidth"]); - m_maxAlbumArtHeight = fromJsonValue(source["MaxAlbumArtHeight"]); - m_maxIconWidth = fromJsonValue(source["MaxIconWidth"]); - m_maxIconHeight = fromJsonValue(source["MaxIconHeight"]); - m_maxStreamingBitrate = fromJsonValue(source["MaxStreamingBitrate"]); - m_maxStaticBitrate = fromJsonValue(source["MaxStaticBitrate"]); - m_musicStreamingTranscodingBitrate = fromJsonValue(source["MusicStreamingTranscodingBitrate"]); - m_maxStaticMusicBitrate = fromJsonValue(source["MaxStaticMusicBitrate"]); - m_sonyAggregationFlags = fromJsonValue(source["SonyAggregationFlags"]); - m_protocolInfo = fromJsonValue(source["ProtocolInfo"]); - m_timelineOffsetSeconds = fromJsonValue(source["TimelineOffsetSeconds"]); - m_requiresPlainVideoItems = fromJsonValue(source["RequiresPlainVideoItems"]); - m_requiresPlainFolders = fromJsonValue(source["RequiresPlainFolders"]); - m_enableMSMediaReceiverRegistrar = fromJsonValue(source["EnableMSMediaReceiverRegistrar"]); - m_ignoreTranscodeByteRangeRequests = fromJsonValue(source["IgnoreTranscodeByteRangeRequests"]); - m_xmlRootAttributes = fromJsonValue>>(source["XmlRootAttributes"]); - m_directPlayProfiles = fromJsonValue>>(source["DirectPlayProfiles"]); - m_transcodingProfiles = fromJsonValue>>(source["TranscodingProfiles"]); - m_containerProfiles = fromJsonValue>>(source["ContainerProfiles"]); - m_codecProfiles = fromJsonValue>>(source["CodecProfiles"]); - m_responseProfiles = fromJsonValue>>(source["ResponseProfiles"]); - m_subtitleProfiles = fromJsonValue>>(source["SubtitleProfiles"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); + m_identification = Jellyfin::Support::fromJsonValue>(source["Identification"]); + m_friendlyName = Jellyfin::Support::fromJsonValue(source["FriendlyName"]); + m_manufacturer = Jellyfin::Support::fromJsonValue(source["Manufacturer"]); + m_manufacturerUrl = Jellyfin::Support::fromJsonValue(source["ManufacturerUrl"]); + m_modelName = Jellyfin::Support::fromJsonValue(source["ModelName"]); + m_modelDescription = Jellyfin::Support::fromJsonValue(source["ModelDescription"]); + m_modelNumber = Jellyfin::Support::fromJsonValue(source["ModelNumber"]); + m_modelUrl = Jellyfin::Support::fromJsonValue(source["ModelUrl"]); + m_serialNumber = Jellyfin::Support::fromJsonValue(source["SerialNumber"]); + m_enableAlbumArtInDidl = Jellyfin::Support::fromJsonValue(source["EnableAlbumArtInDidl"]); + m_enableSingleAlbumArtLimit = Jellyfin::Support::fromJsonValue(source["EnableSingleAlbumArtLimit"]); + m_enableSingleSubtitleLimit = Jellyfin::Support::fromJsonValue(source["EnableSingleSubtitleLimit"]); + m_supportedMediaTypes = Jellyfin::Support::fromJsonValue(source["SupportedMediaTypes"]); + m_userId = Jellyfin::Support::fromJsonValue(source["UserId"]); + m_albumArtPn = Jellyfin::Support::fromJsonValue(source["AlbumArtPn"]); + m_maxAlbumArtWidth = Jellyfin::Support::fromJsonValue(source["MaxAlbumArtWidth"]); + m_maxAlbumArtHeight = Jellyfin::Support::fromJsonValue(source["MaxAlbumArtHeight"]); + m_maxIconWidth = Jellyfin::Support::fromJsonValue(source["MaxIconWidth"]); + m_maxIconHeight = Jellyfin::Support::fromJsonValue(source["MaxIconHeight"]); + m_maxStreamingBitrate = Jellyfin::Support::fromJsonValue(source["MaxStreamingBitrate"]); + m_maxStaticBitrate = Jellyfin::Support::fromJsonValue(source["MaxStaticBitrate"]); + m_musicStreamingTranscodingBitrate = Jellyfin::Support::fromJsonValue(source["MusicStreamingTranscodingBitrate"]); + m_maxStaticMusicBitrate = Jellyfin::Support::fromJsonValue(source["MaxStaticMusicBitrate"]); + m_sonyAggregationFlags = Jellyfin::Support::fromJsonValue(source["SonyAggregationFlags"]); + m_protocolInfo = Jellyfin::Support::fromJsonValue(source["ProtocolInfo"]); + m_timelineOffsetSeconds = Jellyfin::Support::fromJsonValue(source["TimelineOffsetSeconds"]); + m_requiresPlainVideoItems = Jellyfin::Support::fromJsonValue(source["RequiresPlainVideoItems"]); + m_requiresPlainFolders = Jellyfin::Support::fromJsonValue(source["RequiresPlainFolders"]); + m_enableMSMediaReceiverRegistrar = Jellyfin::Support::fromJsonValue(source["EnableMSMediaReceiverRegistrar"]); + m_ignoreTranscodeByteRangeRequests = Jellyfin::Support::fromJsonValue(source["IgnoreTranscodeByteRangeRequests"]); + m_xmlRootAttributes = Jellyfin::Support::fromJsonValue>>(source["XmlRootAttributes"]); + m_directPlayProfiles = Jellyfin::Support::fromJsonValue>>(source["DirectPlayProfiles"]); + m_transcodingProfiles = Jellyfin::Support::fromJsonValue>>(source["TranscodingProfiles"]); + m_containerProfiles = Jellyfin::Support::fromJsonValue>>(source["ContainerProfiles"]); + m_codecProfiles = Jellyfin::Support::fromJsonValue>>(source["CodecProfiles"]); + m_responseProfiles = Jellyfin::Support::fromJsonValue>>(source["ResponseProfiles"]); + m_subtitleProfiles = Jellyfin::Support::fromJsonValue>>(source["SubtitleProfiles"]); } QJsonObject DeviceProfile::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Id"] = toJsonValue(m_jellyfinId); - result["Identification"] = toJsonValue>(m_identification); - result["FriendlyName"] = toJsonValue(m_friendlyName); - result["Manufacturer"] = toJsonValue(m_manufacturer); - result["ManufacturerUrl"] = toJsonValue(m_manufacturerUrl); - result["ModelName"] = toJsonValue(m_modelName); - result["ModelDescription"] = toJsonValue(m_modelDescription); - result["ModelNumber"] = toJsonValue(m_modelNumber); - result["ModelUrl"] = toJsonValue(m_modelUrl); - result["SerialNumber"] = toJsonValue(m_serialNumber); - result["EnableAlbumArtInDidl"] = toJsonValue(m_enableAlbumArtInDidl); - result["EnableSingleAlbumArtLimit"] = toJsonValue(m_enableSingleAlbumArtLimit); - result["EnableSingleSubtitleLimit"] = toJsonValue(m_enableSingleSubtitleLimit); - result["SupportedMediaTypes"] = toJsonValue(m_supportedMediaTypes); - result["UserId"] = toJsonValue(m_userId); - result["AlbumArtPn"] = toJsonValue(m_albumArtPn); - result["MaxAlbumArtWidth"] = toJsonValue(m_maxAlbumArtWidth); - result["MaxAlbumArtHeight"] = toJsonValue(m_maxAlbumArtHeight); - result["MaxIconWidth"] = toJsonValue(m_maxIconWidth); - result["MaxIconHeight"] = toJsonValue(m_maxIconHeight); - result["MaxStreamingBitrate"] = toJsonValue(m_maxStreamingBitrate); - result["MaxStaticBitrate"] = toJsonValue(m_maxStaticBitrate); - result["MusicStreamingTranscodingBitrate"] = toJsonValue(m_musicStreamingTranscodingBitrate); - result["MaxStaticMusicBitrate"] = toJsonValue(m_maxStaticMusicBitrate); - result["SonyAggregationFlags"] = toJsonValue(m_sonyAggregationFlags); - result["ProtocolInfo"] = toJsonValue(m_protocolInfo); - result["TimelineOffsetSeconds"] = toJsonValue(m_timelineOffsetSeconds); - result["RequiresPlainVideoItems"] = toJsonValue(m_requiresPlainVideoItems); - result["RequiresPlainFolders"] = toJsonValue(m_requiresPlainFolders); - result["EnableMSMediaReceiverRegistrar"] = toJsonValue(m_enableMSMediaReceiverRegistrar); - result["IgnoreTranscodeByteRangeRequests"] = toJsonValue(m_ignoreTranscodeByteRangeRequests); - result["XmlRootAttributes"] = toJsonValue>>(m_xmlRootAttributes); - result["DirectPlayProfiles"] = toJsonValue>>(m_directPlayProfiles); - result["TranscodingProfiles"] = toJsonValue>>(m_transcodingProfiles); - result["ContainerProfiles"] = toJsonValue>>(m_containerProfiles); - result["CodecProfiles"] = toJsonValue>>(m_codecProfiles); - result["ResponseProfiles"] = toJsonValue>>(m_responseProfiles); - result["SubtitleProfiles"] = toJsonValue>>(m_subtitleProfiles); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["Identification"] = Jellyfin::Support::toJsonValue>(m_identification); + result["FriendlyName"] = Jellyfin::Support::toJsonValue(m_friendlyName); + result["Manufacturer"] = Jellyfin::Support::toJsonValue(m_manufacturer); + result["ManufacturerUrl"] = Jellyfin::Support::toJsonValue(m_manufacturerUrl); + result["ModelName"] = Jellyfin::Support::toJsonValue(m_modelName); + result["ModelDescription"] = Jellyfin::Support::toJsonValue(m_modelDescription); + result["ModelNumber"] = Jellyfin::Support::toJsonValue(m_modelNumber); + result["ModelUrl"] = Jellyfin::Support::toJsonValue(m_modelUrl); + result["SerialNumber"] = Jellyfin::Support::toJsonValue(m_serialNumber); + result["EnableAlbumArtInDidl"] = Jellyfin::Support::toJsonValue(m_enableAlbumArtInDidl); + result["EnableSingleAlbumArtLimit"] = Jellyfin::Support::toJsonValue(m_enableSingleAlbumArtLimit); + result["EnableSingleSubtitleLimit"] = Jellyfin::Support::toJsonValue(m_enableSingleSubtitleLimit); + result["SupportedMediaTypes"] = Jellyfin::Support::toJsonValue(m_supportedMediaTypes); + result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); + result["AlbumArtPn"] = Jellyfin::Support::toJsonValue(m_albumArtPn); + result["MaxAlbumArtWidth"] = Jellyfin::Support::toJsonValue(m_maxAlbumArtWidth); + result["MaxAlbumArtHeight"] = Jellyfin::Support::toJsonValue(m_maxAlbumArtHeight); + result["MaxIconWidth"] = Jellyfin::Support::toJsonValue(m_maxIconWidth); + result["MaxIconHeight"] = Jellyfin::Support::toJsonValue(m_maxIconHeight); + result["MaxStreamingBitrate"] = Jellyfin::Support::toJsonValue(m_maxStreamingBitrate); + result["MaxStaticBitrate"] = Jellyfin::Support::toJsonValue(m_maxStaticBitrate); + result["MusicStreamingTranscodingBitrate"] = Jellyfin::Support::toJsonValue(m_musicStreamingTranscodingBitrate); + result["MaxStaticMusicBitrate"] = Jellyfin::Support::toJsonValue(m_maxStaticMusicBitrate); + result["SonyAggregationFlags"] = Jellyfin::Support::toJsonValue(m_sonyAggregationFlags); + result["ProtocolInfo"] = Jellyfin::Support::toJsonValue(m_protocolInfo); + result["TimelineOffsetSeconds"] = Jellyfin::Support::toJsonValue(m_timelineOffsetSeconds); + result["RequiresPlainVideoItems"] = Jellyfin::Support::toJsonValue(m_requiresPlainVideoItems); + result["RequiresPlainFolders"] = Jellyfin::Support::toJsonValue(m_requiresPlainFolders); + result["EnableMSMediaReceiverRegistrar"] = Jellyfin::Support::toJsonValue(m_enableMSMediaReceiverRegistrar); + result["IgnoreTranscodeByteRangeRequests"] = Jellyfin::Support::toJsonValue(m_ignoreTranscodeByteRangeRequests); + result["XmlRootAttributes"] = Jellyfin::Support::toJsonValue>>(m_xmlRootAttributes); + result["DirectPlayProfiles"] = Jellyfin::Support::toJsonValue>>(m_directPlayProfiles); + result["TranscodingProfiles"] = Jellyfin::Support::toJsonValue>>(m_transcodingProfiles); + result["ContainerProfiles"] = Jellyfin::Support::toJsonValue>>(m_containerProfiles); + result["CodecProfiles"] = Jellyfin::Support::toJsonValue>>(m_codecProfiles); + result["ResponseProfiles"] = Jellyfin::Support::toJsonValue>>(m_responseProfiles); + result["SubtitleProfiles"] = Jellyfin::Support::toJsonValue>>(m_subtitleProfiles); return result; } @@ -324,6 +325,17 @@ void DeviceProfile::setSubtitleProfiles(QList> n m_subtitleProfiles = newSubtitleProfiles; } +} // NS DTO + +namespace Support { + +using DeviceProfile = Jellyfin::DTO::DeviceProfile; + +template <> +DeviceProfile fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return DeviceProfile::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/deviceprofileinfo.cpp b/core/src/DTO/deviceprofileinfo.cpp index b8238f2..2ccf8f2 100644 --- a/core/src/DTO/deviceprofileinfo.cpp +++ b/core/src/DTO/deviceprofileinfo.cpp @@ -32,26 +32,27 @@ namespace Jellyfin { namespace DTO { -DeviceProfileInfo::DeviceProfileInfo(QObject *parent) {} +DeviceProfileInfo::DeviceProfileInfo() {} -DeviceProfileInfo DeviceProfileInfo::fromJson(QJsonObject source) {DeviceProfileInfo instance; - instance->setFromJson(source, false); +DeviceProfileInfo DeviceProfileInfo::fromJson(QJsonObject source) { + DeviceProfileInfo instance; + instance.setFromJson(source); return instance; } void DeviceProfileInfo::setFromJson(QJsonObject source) { - m_jellyfinId = fromJsonValue(source["Id"]); - m_name = fromJsonValue(source["Name"]); - m_type = fromJsonValue(source["Type"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_type = Jellyfin::Support::fromJsonValue(source["Type"]); } QJsonObject DeviceProfileInfo::toJson() { QJsonObject result; - result["Id"] = toJsonValue(m_jellyfinId); - result["Name"] = toJsonValue(m_name); - result["Type"] = toJsonValue(m_type); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Type"] = Jellyfin::Support::toJsonValue(m_type); return result; } @@ -72,6 +73,17 @@ void DeviceProfileInfo::setType(DeviceProfileType newType) { m_type = newType; } +} // NS DTO + +namespace Support { + +using DeviceProfileInfo = Jellyfin::DTO::DeviceProfileInfo; + +template <> +DeviceProfileInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return DeviceProfileInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/deviceprofiletype.cpp b/core/src/DTO/deviceprofiletype.cpp index cc1dc27..796b8ac 100644 --- a/core/src/DTO/deviceprofiletype.cpp +++ b/core/src/DTO/deviceprofiletype.cpp @@ -34,5 +34,27 @@ namespace DTO { DeviceProfileTypeClass::DeviceProfileTypeClass() {} + +} // NS DTO + +namespace Support { + +using DeviceProfileType = Jellyfin::DTO::DeviceProfileType; + +template <> +DeviceProfileType fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return DeviceProfileType::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("System")) { + return DeviceProfileType::System; + } + if (str == QStringLiteral("User")) { + return DeviceProfileType::User; + } + + return DeviceProfileType::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/directplayprofile.cpp b/core/src/DTO/directplayprofile.cpp index be3e1db..9a5ac29 100644 --- a/core/src/DTO/directplayprofile.cpp +++ b/core/src/DTO/directplayprofile.cpp @@ -32,28 +32,29 @@ namespace Jellyfin { namespace DTO { -DirectPlayProfile::DirectPlayProfile(QObject *parent) {} +DirectPlayProfile::DirectPlayProfile() {} -DirectPlayProfile DirectPlayProfile::fromJson(QJsonObject source) {DirectPlayProfile instance; - instance->setFromJson(source, false); +DirectPlayProfile DirectPlayProfile::fromJson(QJsonObject source) { + DirectPlayProfile instance; + instance.setFromJson(source); return instance; } void DirectPlayProfile::setFromJson(QJsonObject source) { - m_container = fromJsonValue(source["Container"]); - m_audioCodec = fromJsonValue(source["AudioCodec"]); - m_videoCodec = fromJsonValue(source["VideoCodec"]); - m_type = fromJsonValue(source["Type"]); + m_container = Jellyfin::Support::fromJsonValue(source["Container"]); + m_audioCodec = Jellyfin::Support::fromJsonValue(source["AudioCodec"]); + m_videoCodec = Jellyfin::Support::fromJsonValue(source["VideoCodec"]); + m_type = Jellyfin::Support::fromJsonValue(source["Type"]); } QJsonObject DirectPlayProfile::toJson() { QJsonObject result; - result["Container"] = toJsonValue(m_container); - result["AudioCodec"] = toJsonValue(m_audioCodec); - result["VideoCodec"] = toJsonValue(m_videoCodec); - result["Type"] = toJsonValue(m_type); + result["Container"] = Jellyfin::Support::toJsonValue(m_container); + result["AudioCodec"] = Jellyfin::Support::toJsonValue(m_audioCodec); + result["VideoCodec"] = Jellyfin::Support::toJsonValue(m_videoCodec); + result["Type"] = Jellyfin::Support::toJsonValue(m_type); return result; } @@ -79,6 +80,17 @@ void DirectPlayProfile::setType(DlnaProfileType newType) { m_type = newType; } +} // NS DTO + +namespace Support { + +using DirectPlayProfile = Jellyfin::DTO::DirectPlayProfile; + +template <> +DirectPlayProfile fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return DirectPlayProfile::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/displaypreferencesdto.cpp b/core/src/DTO/displaypreferencesdto.cpp index 4d5bb51..12758eb 100644 --- a/core/src/DTO/displaypreferencesdto.cpp +++ b/core/src/DTO/displaypreferencesdto.cpp @@ -32,48 +32,49 @@ namespace Jellyfin { namespace DTO { -DisplayPreferencesDto::DisplayPreferencesDto(QObject *parent) {} +DisplayPreferencesDto::DisplayPreferencesDto() {} -DisplayPreferencesDto DisplayPreferencesDto::fromJson(QJsonObject source) {DisplayPreferencesDto instance; - instance->setFromJson(source, false); +DisplayPreferencesDto DisplayPreferencesDto::fromJson(QJsonObject source) { + DisplayPreferencesDto instance; + instance.setFromJson(source); return instance; } void DisplayPreferencesDto::setFromJson(QJsonObject source) { - m_jellyfinId = fromJsonValue(source["Id"]); - m_viewType = fromJsonValue(source["ViewType"]); - m_sortBy = fromJsonValue(source["SortBy"]); - m_indexBy = fromJsonValue(source["IndexBy"]); - m_rememberIndexing = fromJsonValue(source["RememberIndexing"]); - m_primaryImageHeight = fromJsonValue(source["PrimaryImageHeight"]); - m_primaryImageWidth = fromJsonValue(source["PrimaryImageWidth"]); - m_customPrefs = fromJsonValue(source["CustomPrefs"]); - m_scrollDirection = fromJsonValue(source["ScrollDirection"]); - m_showBackdrop = fromJsonValue(source["ShowBackdrop"]); - m_rememberSorting = fromJsonValue(source["RememberSorting"]); - m_sortOrder = fromJsonValue(source["SortOrder"]); - m_showSidebar = fromJsonValue(source["ShowSidebar"]); - m_client = fromJsonValue(source["Client"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); + m_viewType = Jellyfin::Support::fromJsonValue(source["ViewType"]); + m_sortBy = Jellyfin::Support::fromJsonValue(source["SortBy"]); + m_indexBy = Jellyfin::Support::fromJsonValue(source["IndexBy"]); + m_rememberIndexing = Jellyfin::Support::fromJsonValue(source["RememberIndexing"]); + m_primaryImageHeight = Jellyfin::Support::fromJsonValue(source["PrimaryImageHeight"]); + m_primaryImageWidth = Jellyfin::Support::fromJsonValue(source["PrimaryImageWidth"]); + m_customPrefs = Jellyfin::Support::fromJsonValue(source["CustomPrefs"]); + m_scrollDirection = Jellyfin::Support::fromJsonValue(source["ScrollDirection"]); + m_showBackdrop = Jellyfin::Support::fromJsonValue(source["ShowBackdrop"]); + m_rememberSorting = Jellyfin::Support::fromJsonValue(source["RememberSorting"]); + m_sortOrder = Jellyfin::Support::fromJsonValue(source["SortOrder"]); + m_showSidebar = Jellyfin::Support::fromJsonValue(source["ShowSidebar"]); + m_client = Jellyfin::Support::fromJsonValue(source["Client"]); } QJsonObject DisplayPreferencesDto::toJson() { QJsonObject result; - result["Id"] = toJsonValue(m_jellyfinId); - result["ViewType"] = toJsonValue(m_viewType); - result["SortBy"] = toJsonValue(m_sortBy); - result["IndexBy"] = toJsonValue(m_indexBy); - result["RememberIndexing"] = toJsonValue(m_rememberIndexing); - result["PrimaryImageHeight"] = toJsonValue(m_primaryImageHeight); - result["PrimaryImageWidth"] = toJsonValue(m_primaryImageWidth); - result["CustomPrefs"] = toJsonValue(m_customPrefs); - result["ScrollDirection"] = toJsonValue(m_scrollDirection); - result["ShowBackdrop"] = toJsonValue(m_showBackdrop); - result["RememberSorting"] = toJsonValue(m_rememberSorting); - result["SortOrder"] = toJsonValue(m_sortOrder); - result["ShowSidebar"] = toJsonValue(m_showSidebar); - result["Client"] = toJsonValue(m_client); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["ViewType"] = Jellyfin::Support::toJsonValue(m_viewType); + result["SortBy"] = Jellyfin::Support::toJsonValue(m_sortBy); + result["IndexBy"] = Jellyfin::Support::toJsonValue(m_indexBy); + result["RememberIndexing"] = Jellyfin::Support::toJsonValue(m_rememberIndexing); + result["PrimaryImageHeight"] = Jellyfin::Support::toJsonValue(m_primaryImageHeight); + result["PrimaryImageWidth"] = Jellyfin::Support::toJsonValue(m_primaryImageWidth); + result["CustomPrefs"] = Jellyfin::Support::toJsonValue(m_customPrefs); + result["ScrollDirection"] = Jellyfin::Support::toJsonValue(m_scrollDirection); + result["ShowBackdrop"] = Jellyfin::Support::toJsonValue(m_showBackdrop); + result["RememberSorting"] = Jellyfin::Support::toJsonValue(m_rememberSorting); + result["SortOrder"] = Jellyfin::Support::toJsonValue(m_sortOrder); + result["ShowSidebar"] = Jellyfin::Support::toJsonValue(m_showSidebar); + result["Client"] = Jellyfin::Support::toJsonValue(m_client); return result; } @@ -149,6 +150,17 @@ void DisplayPreferencesDto::setClient(QString newClient) { m_client = newClient; } +} // NS DTO + +namespace Support { + +using DisplayPreferencesDto = Jellyfin::DTO::DisplayPreferencesDto; + +template <> +DisplayPreferencesDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return DisplayPreferencesDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/dlnaprofiletype.cpp b/core/src/DTO/dlnaprofiletype.cpp index 215f873..ab20d98 100644 --- a/core/src/DTO/dlnaprofiletype.cpp +++ b/core/src/DTO/dlnaprofiletype.cpp @@ -34,5 +34,30 @@ namespace DTO { DlnaProfileTypeClass::DlnaProfileTypeClass() {} + +} // NS DTO + +namespace Support { + +using DlnaProfileType = Jellyfin::DTO::DlnaProfileType; + +template <> +DlnaProfileType fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return DlnaProfileType::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Audio")) { + return DlnaProfileType::Audio; + } + if (str == QStringLiteral("Video")) { + return DlnaProfileType::Video; + } + if (str == QStringLiteral("Photo")) { + return DlnaProfileType::Photo; + } + + return DlnaProfileType::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/dynamicdayofweek.cpp b/core/src/DTO/dynamicdayofweek.cpp index b5c2269..ae9580e 100644 --- a/core/src/DTO/dynamicdayofweek.cpp +++ b/core/src/DTO/dynamicdayofweek.cpp @@ -34,5 +34,51 @@ namespace DTO { DynamicDayOfWeekClass::DynamicDayOfWeekClass() {} + +} // NS DTO + +namespace Support { + +using DynamicDayOfWeek = Jellyfin::DTO::DynamicDayOfWeek; + +template <> +DynamicDayOfWeek fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return DynamicDayOfWeek::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Sunday")) { + return DynamicDayOfWeek::Sunday; + } + if (str == QStringLiteral("Monday")) { + return DynamicDayOfWeek::Monday; + } + if (str == QStringLiteral("Tuesday")) { + return DynamicDayOfWeek::Tuesday; + } + if (str == QStringLiteral("Wednesday")) { + return DynamicDayOfWeek::Wednesday; + } + if (str == QStringLiteral("Thursday")) { + return DynamicDayOfWeek::Thursday; + } + if (str == QStringLiteral("Friday")) { + return DynamicDayOfWeek::Friday; + } + if (str == QStringLiteral("Saturday")) { + return DynamicDayOfWeek::Saturday; + } + if (str == QStringLiteral("Everyday")) { + return DynamicDayOfWeek::Everyday; + } + if (str == QStringLiteral("Weekday")) { + return DynamicDayOfWeek::Weekday; + } + if (str == QStringLiteral("Weekend")) { + return DynamicDayOfWeek::Weekend; + } + + return DynamicDayOfWeek::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/encodingcontext.cpp b/core/src/DTO/encodingcontext.cpp index dd7c57a..fa583af 100644 --- a/core/src/DTO/encodingcontext.cpp +++ b/core/src/DTO/encodingcontext.cpp @@ -34,5 +34,27 @@ namespace DTO { EncodingContextClass::EncodingContextClass() {} + +} // NS DTO + +namespace Support { + +using EncodingContext = Jellyfin::DTO::EncodingContext; + +template <> +EncodingContext fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return EncodingContext::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Streaming")) { + return EncodingContext::Streaming; + } + if (str == QStringLiteral("Static")) { + return EncodingContext::Static; + } + + return EncodingContext::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/endpointinfo.cpp b/core/src/DTO/endpointinfo.cpp index d7e00a5..c5903ab 100644 --- a/core/src/DTO/endpointinfo.cpp +++ b/core/src/DTO/endpointinfo.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -EndPointInfo::EndPointInfo(QObject *parent) {} +EndPointInfo::EndPointInfo() {} -EndPointInfo EndPointInfo::fromJson(QJsonObject source) {EndPointInfo instance; - instance->setFromJson(source, false); +EndPointInfo EndPointInfo::fromJson(QJsonObject source) { + EndPointInfo instance; + instance.setFromJson(source); return instance; } void EndPointInfo::setFromJson(QJsonObject source) { - m_isLocal = fromJsonValue(source["IsLocal"]); - m_isInNetwork = fromJsonValue(source["IsInNetwork"]); + m_isLocal = Jellyfin::Support::fromJsonValue(source["IsLocal"]); + m_isInNetwork = Jellyfin::Support::fromJsonValue(source["IsInNetwork"]); } QJsonObject EndPointInfo::toJson() { QJsonObject result; - result["IsLocal"] = toJsonValue(m_isLocal); - result["IsInNetwork"] = toJsonValue(m_isInNetwork); + result["IsLocal"] = Jellyfin::Support::toJsonValue(m_isLocal); + result["IsInNetwork"] = Jellyfin::Support::toJsonValue(m_isInNetwork); return result; } @@ -65,6 +66,17 @@ void EndPointInfo::setIsInNetwork(bool newIsInNetwork) { m_isInNetwork = newIsInNetwork; } +} // NS DTO + +namespace Support { + +using EndPointInfo = Jellyfin::DTO::EndPointInfo; + +template <> +EndPointInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return EndPointInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/externalidinfo.cpp b/core/src/DTO/externalidinfo.cpp index 063135b..547211f 100644 --- a/core/src/DTO/externalidinfo.cpp +++ b/core/src/DTO/externalidinfo.cpp @@ -32,28 +32,29 @@ namespace Jellyfin { namespace DTO { -ExternalIdInfo::ExternalIdInfo(QObject *parent) {} +ExternalIdInfo::ExternalIdInfo() {} -ExternalIdInfo ExternalIdInfo::fromJson(QJsonObject source) {ExternalIdInfo instance; - instance->setFromJson(source, false); +ExternalIdInfo ExternalIdInfo::fromJson(QJsonObject source) { + ExternalIdInfo instance; + instance.setFromJson(source); return instance; } void ExternalIdInfo::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_key = fromJsonValue(source["Key"]); - m_type = fromJsonValue(source["Type"]); - m_urlFormatString = fromJsonValue(source["UrlFormatString"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_key = Jellyfin::Support::fromJsonValue(source["Key"]); + m_type = Jellyfin::Support::fromJsonValue(source["Type"]); + m_urlFormatString = Jellyfin::Support::fromJsonValue(source["UrlFormatString"]); } QJsonObject ExternalIdInfo::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Key"] = toJsonValue(m_key); - result["Type"] = toJsonValue(m_type); - result["UrlFormatString"] = toJsonValue(m_urlFormatString); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Key"] = Jellyfin::Support::toJsonValue(m_key); + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + result["UrlFormatString"] = Jellyfin::Support::toJsonValue(m_urlFormatString); return result; } @@ -79,6 +80,17 @@ void ExternalIdInfo::setUrlFormatString(QString newUrlFormatString) { m_urlFormatString = newUrlFormatString; } +} // NS DTO + +namespace Support { + +using ExternalIdInfo = Jellyfin::DTO::ExternalIdInfo; + +template <> +ExternalIdInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ExternalIdInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/externalidmediatype.cpp b/core/src/DTO/externalidmediatype.cpp index c9a31a3..62cb928 100644 --- a/core/src/DTO/externalidmediatype.cpp +++ b/core/src/DTO/externalidmediatype.cpp @@ -34,5 +34,57 @@ namespace DTO { ExternalIdMediaTypeClass::ExternalIdMediaTypeClass() {} + +} // NS DTO + +namespace Support { + +using ExternalIdMediaType = Jellyfin::DTO::ExternalIdMediaType; + +template <> +ExternalIdMediaType fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return ExternalIdMediaType::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Album")) { + return ExternalIdMediaType::Album; + } + if (str == QStringLiteral("AlbumArtist")) { + return ExternalIdMediaType::AlbumArtist; + } + if (str == QStringLiteral("Artist")) { + return ExternalIdMediaType::Artist; + } + if (str == QStringLiteral("BoxSet")) { + return ExternalIdMediaType::BoxSet; + } + if (str == QStringLiteral("Episode")) { + return ExternalIdMediaType::Episode; + } + if (str == QStringLiteral("Movie")) { + return ExternalIdMediaType::Movie; + } + if (str == QStringLiteral("OtherArtist")) { + return ExternalIdMediaType::OtherArtist; + } + if (str == QStringLiteral("Person")) { + return ExternalIdMediaType::Person; + } + if (str == QStringLiteral("ReleaseGroup")) { + return ExternalIdMediaType::ReleaseGroup; + } + if (str == QStringLiteral("Season")) { + return ExternalIdMediaType::Season; + } + if (str == QStringLiteral("Series")) { + return ExternalIdMediaType::Series; + } + if (str == QStringLiteral("Track")) { + return ExternalIdMediaType::Track; + } + + return ExternalIdMediaType::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/externalurl.cpp b/core/src/DTO/externalurl.cpp index 9326bc5..538a291 100644 --- a/core/src/DTO/externalurl.cpp +++ b/core/src/DTO/externalurl.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -ExternalUrl::ExternalUrl(QObject *parent) {} +ExternalUrl::ExternalUrl() {} -ExternalUrl ExternalUrl::fromJson(QJsonObject source) {ExternalUrl instance; - instance->setFromJson(source, false); +ExternalUrl ExternalUrl::fromJson(QJsonObject source) { + ExternalUrl instance; + instance.setFromJson(source); return instance; } void ExternalUrl::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_url = fromJsonValue(source["Url"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_url = Jellyfin::Support::fromJsonValue(source["Url"]); } QJsonObject ExternalUrl::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Url"] = toJsonValue(m_url); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Url"] = Jellyfin::Support::toJsonValue(m_url); return result; } @@ -65,6 +66,17 @@ void ExternalUrl::setUrl(QString newUrl) { m_url = newUrl; } +} // NS DTO + +namespace Support { + +using ExternalUrl = Jellyfin::DTO::ExternalUrl; + +template <> +ExternalUrl fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ExternalUrl::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/ffmpeglocation.cpp b/core/src/DTO/ffmpeglocation.cpp index 3080c7c..77f082e 100644 --- a/core/src/DTO/ffmpeglocation.cpp +++ b/core/src/DTO/ffmpeglocation.cpp @@ -34,5 +34,33 @@ namespace DTO { FFmpegLocationClass::FFmpegLocationClass() {} + +} // NS DTO + +namespace Support { + +using FFmpegLocation = Jellyfin::DTO::FFmpegLocation; + +template <> +FFmpegLocation fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return FFmpegLocation::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("NotFound")) { + return FFmpegLocation::NotFound; + } + if (str == QStringLiteral("SetByArgument")) { + return FFmpegLocation::SetByArgument; + } + if (str == QStringLiteral("Custom")) { + return FFmpegLocation::Custom; + } + if (str == QStringLiteral("System")) { + return FFmpegLocation::System; + } + + return FFmpegLocation::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/filesystementryinfo.cpp b/core/src/DTO/filesystementryinfo.cpp index d638a5b..efb76dc 100644 --- a/core/src/DTO/filesystementryinfo.cpp +++ b/core/src/DTO/filesystementryinfo.cpp @@ -32,26 +32,27 @@ namespace Jellyfin { namespace DTO { -FileSystemEntryInfo::FileSystemEntryInfo(QObject *parent) {} +FileSystemEntryInfo::FileSystemEntryInfo() {} -FileSystemEntryInfo FileSystemEntryInfo::fromJson(QJsonObject source) {FileSystemEntryInfo instance; - instance->setFromJson(source, false); +FileSystemEntryInfo FileSystemEntryInfo::fromJson(QJsonObject source) { + FileSystemEntryInfo instance; + instance.setFromJson(source); return instance; } void FileSystemEntryInfo::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_path = fromJsonValue(source["Path"]); - m_type = fromJsonValue(source["Type"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_path = Jellyfin::Support::fromJsonValue(source["Path"]); + m_type = Jellyfin::Support::fromJsonValue(source["Type"]); } QJsonObject FileSystemEntryInfo::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Path"] = toJsonValue(m_path); - result["Type"] = toJsonValue(m_type); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + result["Type"] = Jellyfin::Support::toJsonValue(m_type); return result; } @@ -72,6 +73,17 @@ void FileSystemEntryInfo::setType(FileSystemEntryType newType) { m_type = newType; } +} // NS DTO + +namespace Support { + +using FileSystemEntryInfo = Jellyfin::DTO::FileSystemEntryInfo; + +template <> +FileSystemEntryInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return FileSystemEntryInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/filesystementrytype.cpp b/core/src/DTO/filesystementrytype.cpp index 9b73687..28f44cc 100644 --- a/core/src/DTO/filesystementrytype.cpp +++ b/core/src/DTO/filesystementrytype.cpp @@ -34,5 +34,33 @@ namespace DTO { FileSystemEntryTypeClass::FileSystemEntryTypeClass() {} + +} // NS DTO + +namespace Support { + +using FileSystemEntryType = Jellyfin::DTO::FileSystemEntryType; + +template <> +FileSystemEntryType fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return FileSystemEntryType::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("File")) { + return FileSystemEntryType::File; + } + if (str == QStringLiteral("Directory")) { + return FileSystemEntryType::Directory; + } + if (str == QStringLiteral("NetworkComputer")) { + return FileSystemEntryType::NetworkComputer; + } + if (str == QStringLiteral("NetworkShare")) { + return FileSystemEntryType::NetworkShare; + } + + return FileSystemEntryType::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/fontfile.cpp b/core/src/DTO/fontfile.cpp index 8539534..f07b874 100644 --- a/core/src/DTO/fontfile.cpp +++ b/core/src/DTO/fontfile.cpp @@ -32,28 +32,29 @@ namespace Jellyfin { namespace DTO { -FontFile::FontFile(QObject *parent) {} +FontFile::FontFile() {} -FontFile FontFile::fromJson(QJsonObject source) {FontFile instance; - instance->setFromJson(source, false); +FontFile FontFile::fromJson(QJsonObject source) { + FontFile instance; + instance.setFromJson(source); return instance; } void FontFile::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_size = fromJsonValue(source["Size"]); - m_dateCreated = fromJsonValue(source["DateCreated"]); - m_dateModified = fromJsonValue(source["DateModified"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_size = Jellyfin::Support::fromJsonValue(source["Size"]); + m_dateCreated = Jellyfin::Support::fromJsonValue(source["DateCreated"]); + m_dateModified = Jellyfin::Support::fromJsonValue(source["DateModified"]); } QJsonObject FontFile::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Size"] = toJsonValue(m_size); - result["DateCreated"] = toJsonValue(m_dateCreated); - result["DateModified"] = toJsonValue(m_dateModified); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Size"] = Jellyfin::Support::toJsonValue(m_size); + result["DateCreated"] = Jellyfin::Support::toJsonValue(m_dateCreated); + result["DateModified"] = Jellyfin::Support::toJsonValue(m_dateModified); return result; } @@ -79,6 +80,17 @@ void FontFile::setDateModified(QDateTime newDateModified) { m_dateModified = newDateModified; } +} // NS DTO + +namespace Support { + +using FontFile = Jellyfin::DTO::FontFile; + +template <> +FontFile fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return FontFile::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/forgotpasswordaction.cpp b/core/src/DTO/forgotpasswordaction.cpp index 25d2fc2..052c614 100644 --- a/core/src/DTO/forgotpasswordaction.cpp +++ b/core/src/DTO/forgotpasswordaction.cpp @@ -34,5 +34,30 @@ namespace DTO { ForgotPasswordActionClass::ForgotPasswordActionClass() {} + +} // NS DTO + +namespace Support { + +using ForgotPasswordAction = Jellyfin::DTO::ForgotPasswordAction; + +template <> +ForgotPasswordAction fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return ForgotPasswordAction::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("ContactAdmin")) { + return ForgotPasswordAction::ContactAdmin; + } + if (str == QStringLiteral("PinCode")) { + return ForgotPasswordAction::PinCode; + } + if (str == QStringLiteral("InNetworkRequired")) { + return ForgotPasswordAction::InNetworkRequired; + } + + return ForgotPasswordAction::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/forgotpassworddto.cpp b/core/src/DTO/forgotpassworddto.cpp index dd5fa48..8a08a7e 100644 --- a/core/src/DTO/forgotpassworddto.cpp +++ b/core/src/DTO/forgotpassworddto.cpp @@ -32,22 +32,23 @@ namespace Jellyfin { namespace DTO { -ForgotPasswordDto::ForgotPasswordDto(QObject *parent) {} +ForgotPasswordDto::ForgotPasswordDto() {} -ForgotPasswordDto ForgotPasswordDto::fromJson(QJsonObject source) {ForgotPasswordDto instance; - instance->setFromJson(source, false); +ForgotPasswordDto ForgotPasswordDto::fromJson(QJsonObject source) { + ForgotPasswordDto instance; + instance.setFromJson(source); return instance; } void ForgotPasswordDto::setFromJson(QJsonObject source) { - m_enteredUsername = fromJsonValue(source["EnteredUsername"]); + m_enteredUsername = Jellyfin::Support::fromJsonValue(source["EnteredUsername"]); } QJsonObject ForgotPasswordDto::toJson() { QJsonObject result; - result["EnteredUsername"] = toJsonValue(m_enteredUsername); + result["EnteredUsername"] = Jellyfin::Support::toJsonValue(m_enteredUsername); return result; } @@ -58,6 +59,17 @@ void ForgotPasswordDto::setEnteredUsername(QString newEnteredUsername) { m_enteredUsername = newEnteredUsername; } +} // NS DTO + +namespace Support { + +using ForgotPasswordDto = Jellyfin::DTO::ForgotPasswordDto; + +template <> +ForgotPasswordDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ForgotPasswordDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/forgotpasswordresult.cpp b/core/src/DTO/forgotpasswordresult.cpp index 76cdedf..a7eb847 100644 --- a/core/src/DTO/forgotpasswordresult.cpp +++ b/core/src/DTO/forgotpasswordresult.cpp @@ -32,26 +32,27 @@ namespace Jellyfin { namespace DTO { -ForgotPasswordResult::ForgotPasswordResult(QObject *parent) {} +ForgotPasswordResult::ForgotPasswordResult() {} -ForgotPasswordResult ForgotPasswordResult::fromJson(QJsonObject source) {ForgotPasswordResult instance; - instance->setFromJson(source, false); +ForgotPasswordResult ForgotPasswordResult::fromJson(QJsonObject source) { + ForgotPasswordResult instance; + instance.setFromJson(source); return instance; } void ForgotPasswordResult::setFromJson(QJsonObject source) { - m_action = fromJsonValue(source["Action"]); - m_pinFile = fromJsonValue(source["PinFile"]); - m_pinExpirationDate = fromJsonValue(source["PinExpirationDate"]); + m_action = Jellyfin::Support::fromJsonValue(source["Action"]); + m_pinFile = Jellyfin::Support::fromJsonValue(source["PinFile"]); + m_pinExpirationDate = Jellyfin::Support::fromJsonValue(source["PinExpirationDate"]); } QJsonObject ForgotPasswordResult::toJson() { QJsonObject result; - result["Action"] = toJsonValue(m_action); - result["PinFile"] = toJsonValue(m_pinFile); - result["PinExpirationDate"] = toJsonValue(m_pinExpirationDate); + result["Action"] = Jellyfin::Support::toJsonValue(m_action); + result["PinFile"] = Jellyfin::Support::toJsonValue(m_pinFile); + result["PinExpirationDate"] = Jellyfin::Support::toJsonValue(m_pinExpirationDate); return result; } @@ -72,6 +73,17 @@ void ForgotPasswordResult::setPinExpirationDate(QDateTime newPinExpirationDate) m_pinExpirationDate = newPinExpirationDate; } +} // NS DTO + +namespace Support { + +using ForgotPasswordResult = Jellyfin::DTO::ForgotPasswordResult; + +template <> +ForgotPasswordResult fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ForgotPasswordResult::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/generalcommand.cpp b/core/src/DTO/generalcommand.cpp index a3644b4..7d44aa0 100644 --- a/core/src/DTO/generalcommand.cpp +++ b/core/src/DTO/generalcommand.cpp @@ -32,26 +32,27 @@ namespace Jellyfin { namespace DTO { -GeneralCommand::GeneralCommand(QObject *parent) {} +GeneralCommand::GeneralCommand() {} -GeneralCommand GeneralCommand::fromJson(QJsonObject source) {GeneralCommand instance; - instance->setFromJson(source, false); +GeneralCommand GeneralCommand::fromJson(QJsonObject source) { + GeneralCommand instance; + instance.setFromJson(source); return instance; } void GeneralCommand::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_controllingUserId = fromJsonValue(source["ControllingUserId"]); - m_arguments = fromJsonValue(source["Arguments"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_controllingUserId = Jellyfin::Support::fromJsonValue(source["ControllingUserId"]); + m_arguments = Jellyfin::Support::fromJsonValue(source["Arguments"]); } QJsonObject GeneralCommand::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["ControllingUserId"] = toJsonValue(m_controllingUserId); - result["Arguments"] = toJsonValue(m_arguments); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["ControllingUserId"] = Jellyfin::Support::toJsonValue(m_controllingUserId); + result["Arguments"] = Jellyfin::Support::toJsonValue(m_arguments); return result; } @@ -72,6 +73,17 @@ void GeneralCommand::setArguments(QJsonObject newArguments) { m_arguments = newArguments; } +} // NS DTO + +namespace Support { + +using GeneralCommand = Jellyfin::DTO::GeneralCommand; + +template <> +GeneralCommand fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return GeneralCommand::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/generalcommandtype.cpp b/core/src/DTO/generalcommandtype.cpp index de71c7e..6044b97 100644 --- a/core/src/DTO/generalcommandtype.cpp +++ b/core/src/DTO/generalcommandtype.cpp @@ -34,5 +34,144 @@ namespace DTO { GeneralCommandTypeClass::GeneralCommandTypeClass() {} + +} // NS DTO + +namespace Support { + +using GeneralCommandType = Jellyfin::DTO::GeneralCommandType; + +template <> +GeneralCommandType fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return GeneralCommandType::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("MoveUp")) { + return GeneralCommandType::MoveUp; + } + if (str == QStringLiteral("MoveDown")) { + return GeneralCommandType::MoveDown; + } + if (str == QStringLiteral("MoveLeft")) { + return GeneralCommandType::MoveLeft; + } + if (str == QStringLiteral("MoveRight")) { + return GeneralCommandType::MoveRight; + } + if (str == QStringLiteral("PageUp")) { + return GeneralCommandType::PageUp; + } + if (str == QStringLiteral("PageDown")) { + return GeneralCommandType::PageDown; + } + if (str == QStringLiteral("PreviousLetter")) { + return GeneralCommandType::PreviousLetter; + } + if (str == QStringLiteral("NextLetter")) { + return GeneralCommandType::NextLetter; + } + if (str == QStringLiteral("ToggleOsd")) { + return GeneralCommandType::ToggleOsd; + } + if (str == QStringLiteral("ToggleContextMenu")) { + return GeneralCommandType::ToggleContextMenu; + } + if (str == QStringLiteral("Select")) { + return GeneralCommandType::Select; + } + if (str == QStringLiteral("Back")) { + return GeneralCommandType::Back; + } + if (str == QStringLiteral("TakeScreenshot")) { + return GeneralCommandType::TakeScreenshot; + } + if (str == QStringLiteral("SendKey")) { + return GeneralCommandType::SendKey; + } + if (str == QStringLiteral("SendString")) { + return GeneralCommandType::SendString; + } + if (str == QStringLiteral("GoHome")) { + return GeneralCommandType::GoHome; + } + if (str == QStringLiteral("GoToSettings")) { + return GeneralCommandType::GoToSettings; + } + if (str == QStringLiteral("VolumeUp")) { + return GeneralCommandType::VolumeUp; + } + if (str == QStringLiteral("VolumeDown")) { + return GeneralCommandType::VolumeDown; + } + if (str == QStringLiteral("Mute")) { + return GeneralCommandType::Mute; + } + if (str == QStringLiteral("Unmute")) { + return GeneralCommandType::Unmute; + } + if (str == QStringLiteral("ToggleMute")) { + return GeneralCommandType::ToggleMute; + } + if (str == QStringLiteral("SetVolume")) { + return GeneralCommandType::SetVolume; + } + if (str == QStringLiteral("SetAudioStreamIndex")) { + return GeneralCommandType::SetAudioStreamIndex; + } + if (str == QStringLiteral("SetSubtitleStreamIndex")) { + return GeneralCommandType::SetSubtitleStreamIndex; + } + if (str == QStringLiteral("ToggleFullscreen")) { + return GeneralCommandType::ToggleFullscreen; + } + if (str == QStringLiteral("DisplayContent")) { + return GeneralCommandType::DisplayContent; + } + if (str == QStringLiteral("GoToSearch")) { + return GeneralCommandType::GoToSearch; + } + if (str == QStringLiteral("DisplayMessage")) { + return GeneralCommandType::DisplayMessage; + } + if (str == QStringLiteral("SetRepeatMode")) { + return GeneralCommandType::SetRepeatMode; + } + if (str == QStringLiteral("ChannelUp")) { + return GeneralCommandType::ChannelUp; + } + if (str == QStringLiteral("ChannelDown")) { + return GeneralCommandType::ChannelDown; + } + if (str == QStringLiteral("Guide")) { + return GeneralCommandType::Guide; + } + if (str == QStringLiteral("ToggleStats")) { + return GeneralCommandType::ToggleStats; + } + if (str == QStringLiteral("PlayMediaSource")) { + return GeneralCommandType::PlayMediaSource; + } + if (str == QStringLiteral("PlayTrailers")) { + return GeneralCommandType::PlayTrailers; + } + if (str == QStringLiteral("SetShuffleQueue")) { + return GeneralCommandType::SetShuffleQueue; + } + if (str == QStringLiteral("PlayState")) { + return GeneralCommandType::PlayState; + } + if (str == QStringLiteral("PlayNext")) { + return GeneralCommandType::PlayNext; + } + if (str == QStringLiteral("ToggleOsdMenu")) { + return GeneralCommandType::ToggleOsdMenu; + } + if (str == QStringLiteral("Play")) { + return GeneralCommandType::Play; + } + + return GeneralCommandType::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/getprogramsdto.cpp b/core/src/DTO/getprogramsdto.cpp index f90e197..765a50d 100644 --- a/core/src/DTO/getprogramsdto.cpp +++ b/core/src/DTO/getprogramsdto.cpp @@ -32,74 +32,75 @@ namespace Jellyfin { namespace DTO { -GetProgramsDto::GetProgramsDto(QObject *parent) {} +GetProgramsDto::GetProgramsDto() {} -GetProgramsDto GetProgramsDto::fromJson(QJsonObject source) {GetProgramsDto instance; - instance->setFromJson(source, false); +GetProgramsDto GetProgramsDto::fromJson(QJsonObject source) { + GetProgramsDto instance; + instance.setFromJson(source); return instance; } void GetProgramsDto::setFromJson(QJsonObject source) { - m_channelIds = fromJsonValue>(source["ChannelIds"]); - m_userId = fromJsonValue(source["UserId"]); - m_minStartDate = fromJsonValue(source["MinStartDate"]); - m_hasAired = fromJsonValue(source["HasAired"]); - m_isAiring = fromJsonValue(source["IsAiring"]); - m_maxStartDate = fromJsonValue(source["MaxStartDate"]); - m_minEndDate = fromJsonValue(source["MinEndDate"]); - m_maxEndDate = fromJsonValue(source["MaxEndDate"]); - m_isMovie = fromJsonValue(source["IsMovie"]); - m_isSeries = fromJsonValue(source["IsSeries"]); - m_isNews = fromJsonValue(source["IsNews"]); - m_isKids = fromJsonValue(source["IsKids"]); - m_isSports = fromJsonValue(source["IsSports"]); - m_startIndex = fromJsonValue(source["StartIndex"]); - m_limit = fromJsonValue(source["Limit"]); - m_sortBy = fromJsonValue(source["SortBy"]); - m_sortOrder = fromJsonValue(source["SortOrder"]); - m_genres = fromJsonValue(source["Genres"]); - m_genreIds = fromJsonValue>(source["GenreIds"]); - m_enableImages = fromJsonValue(source["EnableImages"]); - m_enableTotalRecordCount = fromJsonValue(source["EnableTotalRecordCount"]); - m_imageTypeLimit = fromJsonValue(source["ImageTypeLimit"]); - m_enableImageTypes = fromJsonValue>(source["EnableImageTypes"]); - m_enableUserData = fromJsonValue(source["EnableUserData"]); - m_seriesTimerId = fromJsonValue(source["SeriesTimerId"]); - m_librarySeriesId = fromJsonValue(source["LibrarySeriesId"]); - m_fields = fromJsonValue>(source["Fields"]); + m_channelIds = Jellyfin::Support::fromJsonValue>(source["ChannelIds"]); + m_userId = Jellyfin::Support::fromJsonValue(source["UserId"]); + m_minStartDate = Jellyfin::Support::fromJsonValue(source["MinStartDate"]); + m_hasAired = Jellyfin::Support::fromJsonValue(source["HasAired"]); + m_isAiring = Jellyfin::Support::fromJsonValue(source["IsAiring"]); + m_maxStartDate = Jellyfin::Support::fromJsonValue(source["MaxStartDate"]); + m_minEndDate = Jellyfin::Support::fromJsonValue(source["MinEndDate"]); + m_maxEndDate = Jellyfin::Support::fromJsonValue(source["MaxEndDate"]); + m_isMovie = Jellyfin::Support::fromJsonValue(source["IsMovie"]); + m_isSeries = Jellyfin::Support::fromJsonValue(source["IsSeries"]); + m_isNews = Jellyfin::Support::fromJsonValue(source["IsNews"]); + m_isKids = Jellyfin::Support::fromJsonValue(source["IsKids"]); + m_isSports = Jellyfin::Support::fromJsonValue(source["IsSports"]); + m_startIndex = Jellyfin::Support::fromJsonValue(source["StartIndex"]); + m_limit = Jellyfin::Support::fromJsonValue(source["Limit"]); + m_sortBy = Jellyfin::Support::fromJsonValue(source["SortBy"]); + m_sortOrder = Jellyfin::Support::fromJsonValue(source["SortOrder"]); + m_genres = Jellyfin::Support::fromJsonValue(source["Genres"]); + m_genreIds = Jellyfin::Support::fromJsonValue>(source["GenreIds"]); + m_enableImages = Jellyfin::Support::fromJsonValue(source["EnableImages"]); + m_enableTotalRecordCount = Jellyfin::Support::fromJsonValue(source["EnableTotalRecordCount"]); + m_imageTypeLimit = Jellyfin::Support::fromJsonValue(source["ImageTypeLimit"]); + m_enableImageTypes = Jellyfin::Support::fromJsonValue>(source["EnableImageTypes"]); + m_enableUserData = Jellyfin::Support::fromJsonValue(source["EnableUserData"]); + m_seriesTimerId = Jellyfin::Support::fromJsonValue(source["SeriesTimerId"]); + m_librarySeriesId = Jellyfin::Support::fromJsonValue(source["LibrarySeriesId"]); + m_fields = Jellyfin::Support::fromJsonValue>(source["Fields"]); } QJsonObject GetProgramsDto::toJson() { QJsonObject result; - result["ChannelIds"] = toJsonValue>(m_channelIds); - result["UserId"] = toJsonValue(m_userId); - result["MinStartDate"] = toJsonValue(m_minStartDate); - result["HasAired"] = toJsonValue(m_hasAired); - result["IsAiring"] = toJsonValue(m_isAiring); - result["MaxStartDate"] = toJsonValue(m_maxStartDate); - result["MinEndDate"] = toJsonValue(m_minEndDate); - result["MaxEndDate"] = toJsonValue(m_maxEndDate); - result["IsMovie"] = toJsonValue(m_isMovie); - result["IsSeries"] = toJsonValue(m_isSeries); - result["IsNews"] = toJsonValue(m_isNews); - result["IsKids"] = toJsonValue(m_isKids); - result["IsSports"] = toJsonValue(m_isSports); - result["StartIndex"] = toJsonValue(m_startIndex); - result["Limit"] = toJsonValue(m_limit); - result["SortBy"] = toJsonValue(m_sortBy); - result["SortOrder"] = toJsonValue(m_sortOrder); - result["Genres"] = toJsonValue(m_genres); - result["GenreIds"] = toJsonValue>(m_genreIds); - result["EnableImages"] = toJsonValue(m_enableImages); - result["EnableTotalRecordCount"] = toJsonValue(m_enableTotalRecordCount); - result["ImageTypeLimit"] = toJsonValue(m_imageTypeLimit); - result["EnableImageTypes"] = toJsonValue>(m_enableImageTypes); - result["EnableUserData"] = toJsonValue(m_enableUserData); - result["SeriesTimerId"] = toJsonValue(m_seriesTimerId); - result["LibrarySeriesId"] = toJsonValue(m_librarySeriesId); - result["Fields"] = toJsonValue>(m_fields); + result["ChannelIds"] = Jellyfin::Support::toJsonValue>(m_channelIds); + result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); + result["MinStartDate"] = Jellyfin::Support::toJsonValue(m_minStartDate); + result["HasAired"] = Jellyfin::Support::toJsonValue(m_hasAired); + result["IsAiring"] = Jellyfin::Support::toJsonValue(m_isAiring); + result["MaxStartDate"] = Jellyfin::Support::toJsonValue(m_maxStartDate); + result["MinEndDate"] = Jellyfin::Support::toJsonValue(m_minEndDate); + result["MaxEndDate"] = Jellyfin::Support::toJsonValue(m_maxEndDate); + result["IsMovie"] = Jellyfin::Support::toJsonValue(m_isMovie); + result["IsSeries"] = Jellyfin::Support::toJsonValue(m_isSeries); + result["IsNews"] = Jellyfin::Support::toJsonValue(m_isNews); + result["IsKids"] = Jellyfin::Support::toJsonValue(m_isKids); + result["IsSports"] = Jellyfin::Support::toJsonValue(m_isSports); + result["StartIndex"] = Jellyfin::Support::toJsonValue(m_startIndex); + result["Limit"] = Jellyfin::Support::toJsonValue(m_limit); + result["SortBy"] = Jellyfin::Support::toJsonValue(m_sortBy); + result["SortOrder"] = Jellyfin::Support::toJsonValue(m_sortOrder); + result["Genres"] = Jellyfin::Support::toJsonValue(m_genres); + result["GenreIds"] = Jellyfin::Support::toJsonValue>(m_genreIds); + result["EnableImages"] = Jellyfin::Support::toJsonValue(m_enableImages); + result["EnableTotalRecordCount"] = Jellyfin::Support::toJsonValue(m_enableTotalRecordCount); + result["ImageTypeLimit"] = Jellyfin::Support::toJsonValue(m_imageTypeLimit); + result["EnableImageTypes"] = Jellyfin::Support::toJsonValue>(m_enableImageTypes); + result["EnableUserData"] = Jellyfin::Support::toJsonValue(m_enableUserData); + result["SeriesTimerId"] = Jellyfin::Support::toJsonValue(m_seriesTimerId); + result["LibrarySeriesId"] = Jellyfin::Support::toJsonValue(m_librarySeriesId); + result["Fields"] = Jellyfin::Support::toJsonValue>(m_fields); return result; } @@ -240,6 +241,17 @@ void GetProgramsDto::setFields(QList newFields) { m_fields = newFields; } +} // NS DTO + +namespace Support { + +using GetProgramsDto = Jellyfin::DTO::GetProgramsDto; + +template <> +GetProgramsDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return GetProgramsDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/groupinfodto.cpp b/core/src/DTO/groupinfodto.cpp index 87564b7..60b7bc6 100644 --- a/core/src/DTO/groupinfodto.cpp +++ b/core/src/DTO/groupinfodto.cpp @@ -32,30 +32,31 @@ namespace Jellyfin { namespace DTO { -GroupInfoDto::GroupInfoDto(QObject *parent) {} +GroupInfoDto::GroupInfoDto() {} -GroupInfoDto GroupInfoDto::fromJson(QJsonObject source) {GroupInfoDto instance; - instance->setFromJson(source, false); +GroupInfoDto GroupInfoDto::fromJson(QJsonObject source) { + GroupInfoDto instance; + instance.setFromJson(source); return instance; } void GroupInfoDto::setFromJson(QJsonObject source) { - m_groupId = fromJsonValue(source["GroupId"]); - m_groupName = fromJsonValue(source["GroupName"]); - m_state = fromJsonValue(source["State"]); - m_participants = fromJsonValue(source["Participants"]); - m_lastUpdatedAt = fromJsonValue(source["LastUpdatedAt"]); + m_groupId = Jellyfin::Support::fromJsonValue(source["GroupId"]); + m_groupName = Jellyfin::Support::fromJsonValue(source["GroupName"]); + m_state = Jellyfin::Support::fromJsonValue(source["State"]); + m_participants = Jellyfin::Support::fromJsonValue(source["Participants"]); + m_lastUpdatedAt = Jellyfin::Support::fromJsonValue(source["LastUpdatedAt"]); } QJsonObject GroupInfoDto::toJson() { QJsonObject result; - result["GroupId"] = toJsonValue(m_groupId); - result["GroupName"] = toJsonValue(m_groupName); - result["State"] = toJsonValue(m_state); - result["Participants"] = toJsonValue(m_participants); - result["LastUpdatedAt"] = toJsonValue(m_lastUpdatedAt); + result["GroupId"] = Jellyfin::Support::toJsonValue(m_groupId); + result["GroupName"] = Jellyfin::Support::toJsonValue(m_groupName); + result["State"] = Jellyfin::Support::toJsonValue(m_state); + result["Participants"] = Jellyfin::Support::toJsonValue(m_participants); + result["LastUpdatedAt"] = Jellyfin::Support::toJsonValue(m_lastUpdatedAt); return result; } @@ -86,6 +87,17 @@ void GroupInfoDto::setLastUpdatedAt(QDateTime newLastUpdatedAt) { m_lastUpdatedAt = newLastUpdatedAt; } +} // NS DTO + +namespace Support { + +using GroupInfoDto = Jellyfin::DTO::GroupInfoDto; + +template <> +GroupInfoDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return GroupInfoDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/groupqueuemode.cpp b/core/src/DTO/groupqueuemode.cpp index 762c61f..fd1b9b6 100644 --- a/core/src/DTO/groupqueuemode.cpp +++ b/core/src/DTO/groupqueuemode.cpp @@ -34,5 +34,27 @@ namespace DTO { GroupQueueModeClass::GroupQueueModeClass() {} + +} // NS DTO + +namespace Support { + +using GroupQueueMode = Jellyfin::DTO::GroupQueueMode; + +template <> +GroupQueueMode fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return GroupQueueMode::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Queue")) { + return GroupQueueMode::Queue; + } + if (str == QStringLiteral("QueueNext")) { + return GroupQueueMode::QueueNext; + } + + return GroupQueueMode::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/grouprepeatmode.cpp b/core/src/DTO/grouprepeatmode.cpp index 567b354..3e6a2c5 100644 --- a/core/src/DTO/grouprepeatmode.cpp +++ b/core/src/DTO/grouprepeatmode.cpp @@ -34,5 +34,30 @@ namespace DTO { GroupRepeatModeClass::GroupRepeatModeClass() {} + +} // NS DTO + +namespace Support { + +using GroupRepeatMode = Jellyfin::DTO::GroupRepeatMode; + +template <> +GroupRepeatMode fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return GroupRepeatMode::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("RepeatOne")) { + return GroupRepeatMode::RepeatOne; + } + if (str == QStringLiteral("RepeatAll")) { + return GroupRepeatMode::RepeatAll; + } + if (str == QStringLiteral("RepeatNone")) { + return GroupRepeatMode::RepeatNone; + } + + return GroupRepeatMode::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/groupshufflemode.cpp b/core/src/DTO/groupshufflemode.cpp index 8f9133e..afa8593 100644 --- a/core/src/DTO/groupshufflemode.cpp +++ b/core/src/DTO/groupshufflemode.cpp @@ -34,5 +34,27 @@ namespace DTO { GroupShuffleModeClass::GroupShuffleModeClass() {} + +} // NS DTO + +namespace Support { + +using GroupShuffleMode = Jellyfin::DTO::GroupShuffleMode; + +template <> +GroupShuffleMode fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return GroupShuffleMode::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Sorted")) { + return GroupShuffleMode::Sorted; + } + if (str == QStringLiteral("Shuffle")) { + return GroupShuffleMode::Shuffle; + } + + return GroupShuffleMode::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/groupstatetype.cpp b/core/src/DTO/groupstatetype.cpp index 498df4a..b476740 100644 --- a/core/src/DTO/groupstatetype.cpp +++ b/core/src/DTO/groupstatetype.cpp @@ -34,5 +34,33 @@ namespace DTO { GroupStateTypeClass::GroupStateTypeClass() {} + +} // NS DTO + +namespace Support { + +using GroupStateType = Jellyfin::DTO::GroupStateType; + +template <> +GroupStateType fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return GroupStateType::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Idle")) { + return GroupStateType::Idle; + } + if (str == QStringLiteral("Waiting")) { + return GroupStateType::Waiting; + } + if (str == QStringLiteral("Paused")) { + return GroupStateType::Paused; + } + if (str == QStringLiteral("Playing")) { + return GroupStateType::Playing; + } + + return GroupStateType::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/groupupdatetype.cpp b/core/src/DTO/groupupdatetype.cpp index eb4ad49..a7b56de 100644 --- a/core/src/DTO/groupupdatetype.cpp +++ b/core/src/DTO/groupupdatetype.cpp @@ -34,5 +34,54 @@ namespace DTO { GroupUpdateTypeClass::GroupUpdateTypeClass() {} + +} // NS DTO + +namespace Support { + +using GroupUpdateType = Jellyfin::DTO::GroupUpdateType; + +template <> +GroupUpdateType fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return GroupUpdateType::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("UserJoined")) { + return GroupUpdateType::UserJoined; + } + if (str == QStringLiteral("UserLeft")) { + return GroupUpdateType::UserLeft; + } + if (str == QStringLiteral("GroupJoined")) { + return GroupUpdateType::GroupJoined; + } + if (str == QStringLiteral("GroupLeft")) { + return GroupUpdateType::GroupLeft; + } + if (str == QStringLiteral("StateUpdate")) { + return GroupUpdateType::StateUpdate; + } + if (str == QStringLiteral("PlayQueue")) { + return GroupUpdateType::PlayQueue; + } + if (str == QStringLiteral("NotInGroup")) { + return GroupUpdateType::NotInGroup; + } + if (str == QStringLiteral("GroupDoesNotExist")) { + return GroupUpdateType::GroupDoesNotExist; + } + if (str == QStringLiteral("CreateGroupDenied")) { + return GroupUpdateType::CreateGroupDenied; + } + if (str == QStringLiteral("JoinGroupDenied")) { + return GroupUpdateType::JoinGroupDenied; + } + if (str == QStringLiteral("LibraryAccessDenied")) { + return GroupUpdateType::LibraryAccessDenied; + } + + return GroupUpdateType::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/guideinfo.cpp b/core/src/DTO/guideinfo.cpp index d200adc..cf980dd 100644 --- a/core/src/DTO/guideinfo.cpp +++ b/core/src/DTO/guideinfo.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -GuideInfo::GuideInfo(QObject *parent) {} +GuideInfo::GuideInfo() {} -GuideInfo GuideInfo::fromJson(QJsonObject source) {GuideInfo instance; - instance->setFromJson(source, false); +GuideInfo GuideInfo::fromJson(QJsonObject source) { + GuideInfo instance; + instance.setFromJson(source); return instance; } void GuideInfo::setFromJson(QJsonObject source) { - m_startDate = fromJsonValue(source["StartDate"]); - m_endDate = fromJsonValue(source["EndDate"]); + m_startDate = Jellyfin::Support::fromJsonValue(source["StartDate"]); + m_endDate = Jellyfin::Support::fromJsonValue(source["EndDate"]); } QJsonObject GuideInfo::toJson() { QJsonObject result; - result["StartDate"] = toJsonValue(m_startDate); - result["EndDate"] = toJsonValue(m_endDate); + result["StartDate"] = Jellyfin::Support::toJsonValue(m_startDate); + result["EndDate"] = Jellyfin::Support::toJsonValue(m_endDate); return result; } @@ -65,6 +66,17 @@ void GuideInfo::setEndDate(QDateTime newEndDate) { m_endDate = newEndDate; } +} // NS DTO + +namespace Support { + +using GuideInfo = Jellyfin::DTO::GuideInfo; + +template <> +GuideInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return GuideInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/headermatchtype.cpp b/core/src/DTO/headermatchtype.cpp index f212437..03e8c02 100644 --- a/core/src/DTO/headermatchtype.cpp +++ b/core/src/DTO/headermatchtype.cpp @@ -34,5 +34,30 @@ namespace DTO { HeaderMatchTypeClass::HeaderMatchTypeClass() {} + +} // NS DTO + +namespace Support { + +using HeaderMatchType = Jellyfin::DTO::HeaderMatchType; + +template <> +HeaderMatchType fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return HeaderMatchType::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Equals")) { + return HeaderMatchType::Equals; + } + if (str == QStringLiteral("Regex")) { + return HeaderMatchType::Regex; + } + if (str == QStringLiteral("Substring")) { + return HeaderMatchType::Substring; + } + + return HeaderMatchType::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/httpheaderinfo.cpp b/core/src/DTO/httpheaderinfo.cpp index ea80618..93b7ae2 100644 --- a/core/src/DTO/httpheaderinfo.cpp +++ b/core/src/DTO/httpheaderinfo.cpp @@ -32,26 +32,27 @@ namespace Jellyfin { namespace DTO { -HttpHeaderInfo::HttpHeaderInfo(QObject *parent) {} +HttpHeaderInfo::HttpHeaderInfo() {} -HttpHeaderInfo HttpHeaderInfo::fromJson(QJsonObject source) {HttpHeaderInfo instance; - instance->setFromJson(source, false); +HttpHeaderInfo HttpHeaderInfo::fromJson(QJsonObject source) { + HttpHeaderInfo instance; + instance.setFromJson(source); return instance; } void HttpHeaderInfo::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_value = fromJsonValue(source["Value"]); - m_match = fromJsonValue(source["Match"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_value = Jellyfin::Support::fromJsonValue(source["Value"]); + m_match = Jellyfin::Support::fromJsonValue(source["Match"]); } QJsonObject HttpHeaderInfo::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Value"] = toJsonValue(m_value); - result["Match"] = toJsonValue(m_match); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Value"] = Jellyfin::Support::toJsonValue(m_value); + result["Match"] = Jellyfin::Support::toJsonValue(m_match); return result; } @@ -72,6 +73,17 @@ void HttpHeaderInfo::setMatch(HeaderMatchType newMatch) { m_match = newMatch; } +} // NS DTO + +namespace Support { + +using HttpHeaderInfo = Jellyfin::DTO::HttpHeaderInfo; + +template <> +HttpHeaderInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return HttpHeaderInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/ignorewaitrequestdto.cpp b/core/src/DTO/ignorewaitrequestdto.cpp index 2a43acd..b390bb2 100644 --- a/core/src/DTO/ignorewaitrequestdto.cpp +++ b/core/src/DTO/ignorewaitrequestdto.cpp @@ -32,22 +32,23 @@ namespace Jellyfin { namespace DTO { -IgnoreWaitRequestDto::IgnoreWaitRequestDto(QObject *parent) {} +IgnoreWaitRequestDto::IgnoreWaitRequestDto() {} -IgnoreWaitRequestDto IgnoreWaitRequestDto::fromJson(QJsonObject source) {IgnoreWaitRequestDto instance; - instance->setFromJson(source, false); +IgnoreWaitRequestDto IgnoreWaitRequestDto::fromJson(QJsonObject source) { + IgnoreWaitRequestDto instance; + instance.setFromJson(source); return instance; } void IgnoreWaitRequestDto::setFromJson(QJsonObject source) { - m_ignoreWait = fromJsonValue(source["IgnoreWait"]); + m_ignoreWait = Jellyfin::Support::fromJsonValue(source["IgnoreWait"]); } QJsonObject IgnoreWaitRequestDto::toJson() { QJsonObject result; - result["IgnoreWait"] = toJsonValue(m_ignoreWait); + result["IgnoreWait"] = Jellyfin::Support::toJsonValue(m_ignoreWait); return result; } @@ -58,6 +59,17 @@ void IgnoreWaitRequestDto::setIgnoreWait(bool newIgnoreWait) { m_ignoreWait = newIgnoreWait; } +} // NS DTO + +namespace Support { + +using IgnoreWaitRequestDto = Jellyfin::DTO::IgnoreWaitRequestDto; + +template <> +IgnoreWaitRequestDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return IgnoreWaitRequestDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/imagebynameinfo.cpp b/core/src/DTO/imagebynameinfo.cpp index bb98cd4..035d074 100644 --- a/core/src/DTO/imagebynameinfo.cpp +++ b/core/src/DTO/imagebynameinfo.cpp @@ -32,30 +32,31 @@ namespace Jellyfin { namespace DTO { -ImageByNameInfo::ImageByNameInfo(QObject *parent) {} +ImageByNameInfo::ImageByNameInfo() {} -ImageByNameInfo ImageByNameInfo::fromJson(QJsonObject source) {ImageByNameInfo instance; - instance->setFromJson(source, false); +ImageByNameInfo ImageByNameInfo::fromJson(QJsonObject source) { + ImageByNameInfo instance; + instance.setFromJson(source); return instance; } void ImageByNameInfo::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_theme = fromJsonValue(source["Theme"]); - m_context = fromJsonValue(source["Context"]); - m_fileLength = fromJsonValue(source["FileLength"]); - m_format = fromJsonValue(source["Format"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_theme = Jellyfin::Support::fromJsonValue(source["Theme"]); + m_context = Jellyfin::Support::fromJsonValue(source["Context"]); + m_fileLength = Jellyfin::Support::fromJsonValue(source["FileLength"]); + m_format = Jellyfin::Support::fromJsonValue(source["Format"]); } QJsonObject ImageByNameInfo::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Theme"] = toJsonValue(m_theme); - result["Context"] = toJsonValue(m_context); - result["FileLength"] = toJsonValue(m_fileLength); - result["Format"] = toJsonValue(m_format); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Theme"] = Jellyfin::Support::toJsonValue(m_theme); + result["Context"] = Jellyfin::Support::toJsonValue(m_context); + result["FileLength"] = Jellyfin::Support::toJsonValue(m_fileLength); + result["Format"] = Jellyfin::Support::toJsonValue(m_format); return result; } @@ -86,6 +87,17 @@ void ImageByNameInfo::setFormat(QString newFormat) { m_format = newFormat; } +} // NS DTO + +namespace Support { + +using ImageByNameInfo = Jellyfin::DTO::ImageByNameInfo; + +template <> +ImageByNameInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ImageByNameInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/imageformat.cpp b/core/src/DTO/imageformat.cpp index 32cd7f5..0fa3f0c 100644 --- a/core/src/DTO/imageformat.cpp +++ b/core/src/DTO/imageformat.cpp @@ -34,5 +34,36 @@ namespace DTO { ImageFormatClass::ImageFormatClass() {} + +} // NS DTO + +namespace Support { + +using ImageFormat = Jellyfin::DTO::ImageFormat; + +template <> +ImageFormat fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return ImageFormat::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Bmp")) { + return ImageFormat::Bmp; + } + if (str == QStringLiteral("Gif")) { + return ImageFormat::Gif; + } + if (str == QStringLiteral("Jpg")) { + return ImageFormat::Jpg; + } + if (str == QStringLiteral("Png")) { + return ImageFormat::Png; + } + if (str == QStringLiteral("Webp")) { + return ImageFormat::Webp; + } + + return ImageFormat::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/imageinfo.cpp b/core/src/DTO/imageinfo.cpp index edf0240..bb4928e 100644 --- a/core/src/DTO/imageinfo.cpp +++ b/core/src/DTO/imageinfo.cpp @@ -32,36 +32,37 @@ namespace Jellyfin { namespace DTO { -ImageInfo::ImageInfo(QObject *parent) {} +ImageInfo::ImageInfo() {} -ImageInfo ImageInfo::fromJson(QJsonObject source) {ImageInfo instance; - instance->setFromJson(source, false); +ImageInfo ImageInfo::fromJson(QJsonObject source) { + ImageInfo instance; + instance.setFromJson(source); return instance; } void ImageInfo::setFromJson(QJsonObject source) { - m_imageType = fromJsonValue(source["ImageType"]); - m_imageIndex = fromJsonValue(source["ImageIndex"]); - m_imageTag = fromJsonValue(source["ImageTag"]); - m_path = fromJsonValue(source["Path"]); - m_blurHash = fromJsonValue(source["BlurHash"]); - m_height = fromJsonValue(source["Height"]); - m_width = fromJsonValue(source["Width"]); - m_size = fromJsonValue(source["Size"]); + m_imageType = Jellyfin::Support::fromJsonValue(source["ImageType"]); + m_imageIndex = Jellyfin::Support::fromJsonValue(source["ImageIndex"]); + m_imageTag = Jellyfin::Support::fromJsonValue(source["ImageTag"]); + m_path = Jellyfin::Support::fromJsonValue(source["Path"]); + m_blurHash = Jellyfin::Support::fromJsonValue(source["BlurHash"]); + m_height = Jellyfin::Support::fromJsonValue(source["Height"]); + m_width = Jellyfin::Support::fromJsonValue(source["Width"]); + m_size = Jellyfin::Support::fromJsonValue(source["Size"]); } QJsonObject ImageInfo::toJson() { QJsonObject result; - result["ImageType"] = toJsonValue(m_imageType); - result["ImageIndex"] = toJsonValue(m_imageIndex); - result["ImageTag"] = toJsonValue(m_imageTag); - result["Path"] = toJsonValue(m_path); - result["BlurHash"] = toJsonValue(m_blurHash); - result["Height"] = toJsonValue(m_height); - result["Width"] = toJsonValue(m_width); - result["Size"] = toJsonValue(m_size); + result["ImageType"] = Jellyfin::Support::toJsonValue(m_imageType); + result["ImageIndex"] = Jellyfin::Support::toJsonValue(m_imageIndex); + result["ImageTag"] = Jellyfin::Support::toJsonValue(m_imageTag); + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + result["BlurHash"] = Jellyfin::Support::toJsonValue(m_blurHash); + result["Height"] = Jellyfin::Support::toJsonValue(m_height); + result["Width"] = Jellyfin::Support::toJsonValue(m_width); + result["Size"] = Jellyfin::Support::toJsonValue(m_size); return result; } @@ -107,6 +108,17 @@ void ImageInfo::setSize(qint64 newSize) { m_size = newSize; } +} // NS DTO + +namespace Support { + +using ImageInfo = Jellyfin::DTO::ImageInfo; + +template <> +ImageInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ImageInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/imageoption.cpp b/core/src/DTO/imageoption.cpp index 8b6d675..ccc8f57 100644 --- a/core/src/DTO/imageoption.cpp +++ b/core/src/DTO/imageoption.cpp @@ -32,26 +32,27 @@ namespace Jellyfin { namespace DTO { -ImageOption::ImageOption(QObject *parent) {} +ImageOption::ImageOption() {} -ImageOption ImageOption::fromJson(QJsonObject source) {ImageOption instance; - instance->setFromJson(source, false); +ImageOption ImageOption::fromJson(QJsonObject source) { + ImageOption instance; + instance.setFromJson(source); return instance; } void ImageOption::setFromJson(QJsonObject source) { - m_type = fromJsonValue(source["Type"]); - m_limit = fromJsonValue(source["Limit"]); - m_minWidth = fromJsonValue(source["MinWidth"]); + m_type = Jellyfin::Support::fromJsonValue(source["Type"]); + m_limit = Jellyfin::Support::fromJsonValue(source["Limit"]); + m_minWidth = Jellyfin::Support::fromJsonValue(source["MinWidth"]); } QJsonObject ImageOption::toJson() { QJsonObject result; - result["Type"] = toJsonValue(m_type); - result["Limit"] = toJsonValue(m_limit); - result["MinWidth"] = toJsonValue(m_minWidth); + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + result["Limit"] = Jellyfin::Support::toJsonValue(m_limit); + result["MinWidth"] = Jellyfin::Support::toJsonValue(m_minWidth); return result; } @@ -72,6 +73,17 @@ void ImageOption::setMinWidth(qint32 newMinWidth) { m_minWidth = newMinWidth; } +} // NS DTO + +namespace Support { + +using ImageOption = Jellyfin::DTO::ImageOption; + +template <> +ImageOption fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ImageOption::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/imageorientation.cpp b/core/src/DTO/imageorientation.cpp index 85b6781..d10d00d 100644 --- a/core/src/DTO/imageorientation.cpp +++ b/core/src/DTO/imageorientation.cpp @@ -34,5 +34,45 @@ namespace DTO { ImageOrientationClass::ImageOrientationClass() {} + +} // NS DTO + +namespace Support { + +using ImageOrientation = Jellyfin::DTO::ImageOrientation; + +template <> +ImageOrientation fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return ImageOrientation::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("TopLeft")) { + return ImageOrientation::TopLeft; + } + if (str == QStringLiteral("TopRight")) { + return ImageOrientation::TopRight; + } + if (str == QStringLiteral("BottomRight")) { + return ImageOrientation::BottomRight; + } + if (str == QStringLiteral("BottomLeft")) { + return ImageOrientation::BottomLeft; + } + if (str == QStringLiteral("LeftTop")) { + return ImageOrientation::LeftTop; + } + if (str == QStringLiteral("RightTop")) { + return ImageOrientation::RightTop; + } + if (str == QStringLiteral("RightBottom")) { + return ImageOrientation::RightBottom; + } + if (str == QStringLiteral("LeftBottom")) { + return ImageOrientation::LeftBottom; + } + + return ImageOrientation::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/imageproviderinfo.cpp b/core/src/DTO/imageproviderinfo.cpp index 30de7a4..65c6e65 100644 --- a/core/src/DTO/imageproviderinfo.cpp +++ b/core/src/DTO/imageproviderinfo.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -ImageProviderInfo::ImageProviderInfo(QObject *parent) {} +ImageProviderInfo::ImageProviderInfo() {} -ImageProviderInfo ImageProviderInfo::fromJson(QJsonObject source) {ImageProviderInfo instance; - instance->setFromJson(source, false); +ImageProviderInfo ImageProviderInfo::fromJson(QJsonObject source) { + ImageProviderInfo instance; + instance.setFromJson(source); return instance; } void ImageProviderInfo::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_supportedImages = fromJsonValue>(source["SupportedImages"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_supportedImages = Jellyfin::Support::fromJsonValue>(source["SupportedImages"]); } QJsonObject ImageProviderInfo::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["SupportedImages"] = toJsonValue>(m_supportedImages); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["SupportedImages"] = Jellyfin::Support::toJsonValue>(m_supportedImages); return result; } @@ -65,6 +66,17 @@ void ImageProviderInfo::setSupportedImages(QList newSupportedImages) m_supportedImages = newSupportedImages; } +} // NS DTO + +namespace Support { + +using ImageProviderInfo = Jellyfin::DTO::ImageProviderInfo; + +template <> +ImageProviderInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ImageProviderInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/imagesavingconvention.cpp b/core/src/DTO/imagesavingconvention.cpp index 9686d98..991562d 100644 --- a/core/src/DTO/imagesavingconvention.cpp +++ b/core/src/DTO/imagesavingconvention.cpp @@ -34,5 +34,27 @@ namespace DTO { ImageSavingConventionClass::ImageSavingConventionClass() {} + +} // NS DTO + +namespace Support { + +using ImageSavingConvention = Jellyfin::DTO::ImageSavingConvention; + +template <> +ImageSavingConvention fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return ImageSavingConvention::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Legacy")) { + return ImageSavingConvention::Legacy; + } + if (str == QStringLiteral("Compatible")) { + return ImageSavingConvention::Compatible; + } + + return ImageSavingConvention::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/imagetype.cpp b/core/src/DTO/imagetype.cpp index 8624806..2753532 100644 --- a/core/src/DTO/imagetype.cpp +++ b/core/src/DTO/imagetype.cpp @@ -34,5 +34,60 @@ namespace DTO { ImageTypeClass::ImageTypeClass() {} + +} // NS DTO + +namespace Support { + +using ImageType = Jellyfin::DTO::ImageType; + +template <> +ImageType fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return ImageType::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Primary")) { + return ImageType::Primary; + } + if (str == QStringLiteral("Art")) { + return ImageType::Art; + } + if (str == QStringLiteral("Backdrop")) { + return ImageType::Backdrop; + } + if (str == QStringLiteral("Banner")) { + return ImageType::Banner; + } + if (str == QStringLiteral("Logo")) { + return ImageType::Logo; + } + if (str == QStringLiteral("Thumb")) { + return ImageType::Thumb; + } + if (str == QStringLiteral("Disc")) { + return ImageType::Disc; + } + if (str == QStringLiteral("Box")) { + return ImageType::Box; + } + if (str == QStringLiteral("Screenshot")) { + return ImageType::Screenshot; + } + if (str == QStringLiteral("Menu")) { + return ImageType::Menu; + } + if (str == QStringLiteral("Chapter")) { + return ImageType::Chapter; + } + if (str == QStringLiteral("BoxRear")) { + return ImageType::BoxRear; + } + if (str == QStringLiteral("Profile")) { + return ImageType::Profile; + } + + return ImageType::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/installationinfo.cpp b/core/src/DTO/installationinfo.cpp index ca3fb26..81981b7 100644 --- a/core/src/DTO/installationinfo.cpp +++ b/core/src/DTO/installationinfo.cpp @@ -32,32 +32,33 @@ namespace Jellyfin { namespace DTO { -InstallationInfo::InstallationInfo(QObject *parent) {} +InstallationInfo::InstallationInfo() {} -InstallationInfo InstallationInfo::fromJson(QJsonObject source) {InstallationInfo instance; - instance->setFromJson(source, false); +InstallationInfo InstallationInfo::fromJson(QJsonObject source) { + InstallationInfo instance; + instance.setFromJson(source); return instance; } void InstallationInfo::setFromJson(QJsonObject source) { - m_guid = fromJsonValue(source["Guid"]); - m_name = fromJsonValue(source["Name"]); - m_version = fromJsonValue>(source["Version"]); - m_changelog = fromJsonValue(source["Changelog"]); - m_sourceUrl = fromJsonValue(source["SourceUrl"]); - m_checksum = fromJsonValue(source["Checksum"]); + m_guid = Jellyfin::Support::fromJsonValue(source["Guid"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_version = Jellyfin::Support::fromJsonValue>(source["Version"]); + m_changelog = Jellyfin::Support::fromJsonValue(source["Changelog"]); + m_sourceUrl = Jellyfin::Support::fromJsonValue(source["SourceUrl"]); + m_checksum = Jellyfin::Support::fromJsonValue(source["Checksum"]); } QJsonObject InstallationInfo::toJson() { QJsonObject result; - result["Guid"] = toJsonValue(m_guid); - result["Name"] = toJsonValue(m_name); - result["Version"] = toJsonValue>(m_version); - result["Changelog"] = toJsonValue(m_changelog); - result["SourceUrl"] = toJsonValue(m_sourceUrl); - result["Checksum"] = toJsonValue(m_checksum); + result["Guid"] = Jellyfin::Support::toJsonValue(m_guid); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Version"] = Jellyfin::Support::toJsonValue>(m_version); + result["Changelog"] = Jellyfin::Support::toJsonValue(m_changelog); + result["SourceUrl"] = Jellyfin::Support::toJsonValue(m_sourceUrl); + result["Checksum"] = Jellyfin::Support::toJsonValue(m_checksum); return result; } @@ -93,6 +94,17 @@ void InstallationInfo::setChecksum(QString newChecksum) { m_checksum = newChecksum; } +} // NS DTO + +namespace Support { + +using InstallationInfo = Jellyfin::DTO::InstallationInfo; + +template <> +InstallationInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return InstallationInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/iplugin.cpp b/core/src/DTO/iplugin.cpp index 2d10d7a..983fcd6 100644 --- a/core/src/DTO/iplugin.cpp +++ b/core/src/DTO/iplugin.cpp @@ -32,34 +32,35 @@ namespace Jellyfin { namespace DTO { -IPlugin::IPlugin(QObject *parent) {} +IPlugin::IPlugin() {} -IPlugin IPlugin::fromJson(QJsonObject source) {IPlugin instance; - instance->setFromJson(source, false); +IPlugin IPlugin::fromJson(QJsonObject source) { + IPlugin instance; + instance.setFromJson(source); return instance; } void IPlugin::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_description = fromJsonValue(source["Description"]); - m_jellyfinId = fromJsonValue(source["Id"]); - m_version = fromJsonValue>(source["Version"]); - m_assemblyFilePath = fromJsonValue(source["AssemblyFilePath"]); - m_canUninstall = fromJsonValue(source["CanUninstall"]); - m_dataFolderPath = fromJsonValue(source["DataFolderPath"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_description = Jellyfin::Support::fromJsonValue(source["Description"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); + m_version = Jellyfin::Support::fromJsonValue>(source["Version"]); + m_assemblyFilePath = Jellyfin::Support::fromJsonValue(source["AssemblyFilePath"]); + m_canUninstall = Jellyfin::Support::fromJsonValue(source["CanUninstall"]); + m_dataFolderPath = Jellyfin::Support::fromJsonValue(source["DataFolderPath"]); } QJsonObject IPlugin::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Description"] = toJsonValue(m_description); - result["Id"] = toJsonValue(m_jellyfinId); - result["Version"] = toJsonValue>(m_version); - result["AssemblyFilePath"] = toJsonValue(m_assemblyFilePath); - result["CanUninstall"] = toJsonValue(m_canUninstall); - result["DataFolderPath"] = toJsonValue(m_dataFolderPath); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Description"] = Jellyfin::Support::toJsonValue(m_description); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["Version"] = Jellyfin::Support::toJsonValue>(m_version); + result["AssemblyFilePath"] = Jellyfin::Support::toJsonValue(m_assemblyFilePath); + result["CanUninstall"] = Jellyfin::Support::toJsonValue(m_canUninstall); + result["DataFolderPath"] = Jellyfin::Support::toJsonValue(m_dataFolderPath); return result; } @@ -100,6 +101,17 @@ void IPlugin::setDataFolderPath(QString newDataFolderPath) { m_dataFolderPath = newDataFolderPath; } +} // NS DTO + +namespace Support { + +using IPlugin = Jellyfin::DTO::IPlugin; + +template <> +IPlugin fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return IPlugin::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/isotype.cpp b/core/src/DTO/isotype.cpp index 52e8cfb..a944193 100644 --- a/core/src/DTO/isotype.cpp +++ b/core/src/DTO/isotype.cpp @@ -34,5 +34,27 @@ namespace DTO { IsoTypeClass::IsoTypeClass() {} + +} // NS DTO + +namespace Support { + +using IsoType = Jellyfin::DTO::IsoType; + +template <> +IsoType fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return IsoType::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Dvd")) { + return IsoType::Dvd; + } + if (str == QStringLiteral("BluRay")) { + return IsoType::BluRay; + } + + return IsoType::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/item.cpp b/core/src/DTO/item.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/core/src/DTO/itemcounts.cpp b/core/src/DTO/itemcounts.cpp index ecd3ef9..641da8e 100644 --- a/core/src/DTO/itemcounts.cpp +++ b/core/src/DTO/itemcounts.cpp @@ -32,44 +32,45 @@ namespace Jellyfin { namespace DTO { -ItemCounts::ItemCounts(QObject *parent) {} +ItemCounts::ItemCounts() {} -ItemCounts ItemCounts::fromJson(QJsonObject source) {ItemCounts instance; - instance->setFromJson(source, false); +ItemCounts ItemCounts::fromJson(QJsonObject source) { + ItemCounts instance; + instance.setFromJson(source); return instance; } void ItemCounts::setFromJson(QJsonObject source) { - m_movieCount = fromJsonValue(source["MovieCount"]); - m_seriesCount = fromJsonValue(source["SeriesCount"]); - m_episodeCount = fromJsonValue(source["EpisodeCount"]); - m_artistCount = fromJsonValue(source["ArtistCount"]); - m_programCount = fromJsonValue(source["ProgramCount"]); - m_trailerCount = fromJsonValue(source["TrailerCount"]); - m_songCount = fromJsonValue(source["SongCount"]); - m_albumCount = fromJsonValue(source["AlbumCount"]); - m_musicVideoCount = fromJsonValue(source["MusicVideoCount"]); - m_boxSetCount = fromJsonValue(source["BoxSetCount"]); - m_bookCount = fromJsonValue(source["BookCount"]); - m_itemCount = fromJsonValue(source["ItemCount"]); + m_movieCount = Jellyfin::Support::fromJsonValue(source["MovieCount"]); + m_seriesCount = Jellyfin::Support::fromJsonValue(source["SeriesCount"]); + m_episodeCount = Jellyfin::Support::fromJsonValue(source["EpisodeCount"]); + m_artistCount = Jellyfin::Support::fromJsonValue(source["ArtistCount"]); + m_programCount = Jellyfin::Support::fromJsonValue(source["ProgramCount"]); + m_trailerCount = Jellyfin::Support::fromJsonValue(source["TrailerCount"]); + m_songCount = Jellyfin::Support::fromJsonValue(source["SongCount"]); + m_albumCount = Jellyfin::Support::fromJsonValue(source["AlbumCount"]); + m_musicVideoCount = Jellyfin::Support::fromJsonValue(source["MusicVideoCount"]); + m_boxSetCount = Jellyfin::Support::fromJsonValue(source["BoxSetCount"]); + m_bookCount = Jellyfin::Support::fromJsonValue(source["BookCount"]); + m_itemCount = Jellyfin::Support::fromJsonValue(source["ItemCount"]); } QJsonObject ItemCounts::toJson() { QJsonObject result; - result["MovieCount"] = toJsonValue(m_movieCount); - result["SeriesCount"] = toJsonValue(m_seriesCount); - result["EpisodeCount"] = toJsonValue(m_episodeCount); - result["ArtistCount"] = toJsonValue(m_artistCount); - result["ProgramCount"] = toJsonValue(m_programCount); - result["TrailerCount"] = toJsonValue(m_trailerCount); - result["SongCount"] = toJsonValue(m_songCount); - result["AlbumCount"] = toJsonValue(m_albumCount); - result["MusicVideoCount"] = toJsonValue(m_musicVideoCount); - result["BoxSetCount"] = toJsonValue(m_boxSetCount); - result["BookCount"] = toJsonValue(m_bookCount); - result["ItemCount"] = toJsonValue(m_itemCount); + result["MovieCount"] = Jellyfin::Support::toJsonValue(m_movieCount); + result["SeriesCount"] = Jellyfin::Support::toJsonValue(m_seriesCount); + result["EpisodeCount"] = Jellyfin::Support::toJsonValue(m_episodeCount); + result["ArtistCount"] = Jellyfin::Support::toJsonValue(m_artistCount); + result["ProgramCount"] = Jellyfin::Support::toJsonValue(m_programCount); + result["TrailerCount"] = Jellyfin::Support::toJsonValue(m_trailerCount); + result["SongCount"] = Jellyfin::Support::toJsonValue(m_songCount); + result["AlbumCount"] = Jellyfin::Support::toJsonValue(m_albumCount); + result["MusicVideoCount"] = Jellyfin::Support::toJsonValue(m_musicVideoCount); + result["BoxSetCount"] = Jellyfin::Support::toJsonValue(m_boxSetCount); + result["BookCount"] = Jellyfin::Support::toJsonValue(m_bookCount); + result["ItemCount"] = Jellyfin::Support::toJsonValue(m_itemCount); return result; } @@ -135,6 +136,17 @@ void ItemCounts::setItemCount(qint32 newItemCount) { m_itemCount = newItemCount; } +} // NS DTO + +namespace Support { + +using ItemCounts = Jellyfin::DTO::ItemCounts; + +template <> +ItemCounts fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ItemCounts::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/itemfields.cpp b/core/src/DTO/itemfields.cpp index 3b7ca8c..1b91f62 100644 --- a/core/src/DTO/itemfields.cpp +++ b/core/src/DTO/itemfields.cpp @@ -34,5 +34,204 @@ namespace DTO { ItemFieldsClass::ItemFieldsClass() {} + +} // NS DTO + +namespace Support { + +using ItemFields = Jellyfin::DTO::ItemFields; + +template <> +ItemFields fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return ItemFields::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("AirTime")) { + return ItemFields::AirTime; + } + if (str == QStringLiteral("CanDelete")) { + return ItemFields::CanDelete; + } + if (str == QStringLiteral("CanDownload")) { + return ItemFields::CanDownload; + } + if (str == QStringLiteral("ChannelInfo")) { + return ItemFields::ChannelInfo; + } + if (str == QStringLiteral("Chapters")) { + return ItemFields::Chapters; + } + if (str == QStringLiteral("ChildCount")) { + return ItemFields::ChildCount; + } + if (str == QStringLiteral("CumulativeRunTimeTicks")) { + return ItemFields::CumulativeRunTimeTicks; + } + if (str == QStringLiteral("CustomRating")) { + return ItemFields::CustomRating; + } + if (str == QStringLiteral("DateCreated")) { + return ItemFields::DateCreated; + } + if (str == QStringLiteral("DateLastMediaAdded")) { + return ItemFields::DateLastMediaAdded; + } + if (str == QStringLiteral("DisplayPreferencesId")) { + return ItemFields::DisplayPreferencesId; + } + if (str == QStringLiteral("Etag")) { + return ItemFields::Etag; + } + if (str == QStringLiteral("ExternalUrls")) { + return ItemFields::ExternalUrls; + } + if (str == QStringLiteral("Genres")) { + return ItemFields::Genres; + } + if (str == QStringLiteral("HomePageUrl")) { + return ItemFields::HomePageUrl; + } + if (str == QStringLiteral("ItemCounts")) { + return ItemFields::ItemCounts; + } + if (str == QStringLiteral("MediaSourceCount")) { + return ItemFields::MediaSourceCount; + } + if (str == QStringLiteral("MediaSources")) { + return ItemFields::MediaSources; + } + if (str == QStringLiteral("OriginalTitle")) { + return ItemFields::OriginalTitle; + } + if (str == QStringLiteral("Overview")) { + return ItemFields::Overview; + } + if (str == QStringLiteral("ParentId")) { + return ItemFields::ParentId; + } + if (str == QStringLiteral("Path")) { + return ItemFields::Path; + } + if (str == QStringLiteral("People")) { + return ItemFields::People; + } + if (str == QStringLiteral("PlayAccess")) { + return ItemFields::PlayAccess; + } + if (str == QStringLiteral("ProductionLocations")) { + return ItemFields::ProductionLocations; + } + if (str == QStringLiteral("ProviderIds")) { + return ItemFields::ProviderIds; + } + if (str == QStringLiteral("PrimaryImageAspectRatio")) { + return ItemFields::PrimaryImageAspectRatio; + } + if (str == QStringLiteral("RecursiveItemCount")) { + return ItemFields::RecursiveItemCount; + } + if (str == QStringLiteral("Settings")) { + return ItemFields::Settings; + } + if (str == QStringLiteral("ScreenshotImageTags")) { + return ItemFields::ScreenshotImageTags; + } + if (str == QStringLiteral("SeriesPrimaryImage")) { + return ItemFields::SeriesPrimaryImage; + } + if (str == QStringLiteral("SeriesStudio")) { + return ItemFields::SeriesStudio; + } + if (str == QStringLiteral("SortName")) { + return ItemFields::SortName; + } + if (str == QStringLiteral("SpecialEpisodeNumbers")) { + return ItemFields::SpecialEpisodeNumbers; + } + if (str == QStringLiteral("Studios")) { + return ItemFields::Studios; + } + if (str == QStringLiteral("BasicSyncInfo")) { + return ItemFields::BasicSyncInfo; + } + if (str == QStringLiteral("SyncInfo")) { + return ItemFields::SyncInfo; + } + if (str == QStringLiteral("Taglines")) { + return ItemFields::Taglines; + } + if (str == QStringLiteral("Tags")) { + return ItemFields::Tags; + } + if (str == QStringLiteral("RemoteTrailers")) { + return ItemFields::RemoteTrailers; + } + if (str == QStringLiteral("MediaStreams")) { + return ItemFields::MediaStreams; + } + if (str == QStringLiteral("SeasonUserData")) { + return ItemFields::SeasonUserData; + } + if (str == QStringLiteral("ServiceName")) { + return ItemFields::ServiceName; + } + if (str == QStringLiteral("ThemeSongIds")) { + return ItemFields::ThemeSongIds; + } + if (str == QStringLiteral("ThemeVideoIds")) { + return ItemFields::ThemeVideoIds; + } + if (str == QStringLiteral("ExternalEtag")) { + return ItemFields::ExternalEtag; + } + if (str == QStringLiteral("PresentationUniqueKey")) { + return ItemFields::PresentationUniqueKey; + } + if (str == QStringLiteral("InheritedParentalRatingValue")) { + return ItemFields::InheritedParentalRatingValue; + } + if (str == QStringLiteral("ExternalSeriesId")) { + return ItemFields::ExternalSeriesId; + } + if (str == QStringLiteral("SeriesPresentationUniqueKey")) { + return ItemFields::SeriesPresentationUniqueKey; + } + if (str == QStringLiteral("DateLastRefreshed")) { + return ItemFields::DateLastRefreshed; + } + if (str == QStringLiteral("DateLastSaved")) { + return ItemFields::DateLastSaved; + } + if (str == QStringLiteral("RefreshState")) { + return ItemFields::RefreshState; + } + if (str == QStringLiteral("ChannelImage")) { + return ItemFields::ChannelImage; + } + if (str == QStringLiteral("EnableMediaSourceDisplay")) { + return ItemFields::EnableMediaSourceDisplay; + } + if (str == QStringLiteral("Width")) { + return ItemFields::Width; + } + if (str == QStringLiteral("Height")) { + return ItemFields::Height; + } + if (str == QStringLiteral("ExtraIds")) { + return ItemFields::ExtraIds; + } + if (str == QStringLiteral("LocalTrailerCount")) { + return ItemFields::LocalTrailerCount; + } + if (str == QStringLiteral("IsHD")) { + return ItemFields::IsHD; + } + if (str == QStringLiteral("SpecialFeatureCount")) { + return ItemFields::SpecialFeatureCount; + } + + return ItemFields::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/itemfilter.cpp b/core/src/DTO/itemfilter.cpp index aac4d37..f60a779 100644 --- a/core/src/DTO/itemfilter.cpp +++ b/core/src/DTO/itemfilter.cpp @@ -34,5 +34,48 @@ namespace DTO { ItemFilterClass::ItemFilterClass() {} + +} // NS DTO + +namespace Support { + +using ItemFilter = Jellyfin::DTO::ItemFilter; + +template <> +ItemFilter fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return ItemFilter::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("IsFolder")) { + return ItemFilter::IsFolder; + } + if (str == QStringLiteral("IsNotFolder")) { + return ItemFilter::IsNotFolder; + } + if (str == QStringLiteral("IsUnplayed")) { + return ItemFilter::IsUnplayed; + } + if (str == QStringLiteral("IsPlayed")) { + return ItemFilter::IsPlayed; + } + if (str == QStringLiteral("IsFavorite")) { + return ItemFilter::IsFavorite; + } + if (str == QStringLiteral("IsResumable")) { + return ItemFilter::IsResumable; + } + if (str == QStringLiteral("Likes")) { + return ItemFilter::Likes; + } + if (str == QStringLiteral("Dislikes")) { + return ItemFilter::Dislikes; + } + if (str == QStringLiteral("IsFavoriteOrLikes")) { + return ItemFilter::IsFavoriteOrLikes; + } + + return ItemFilter::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/joingrouprequestdto.cpp b/core/src/DTO/joingrouprequestdto.cpp index 926b8e5..f7ac3b3 100644 --- a/core/src/DTO/joingrouprequestdto.cpp +++ b/core/src/DTO/joingrouprequestdto.cpp @@ -32,22 +32,23 @@ namespace Jellyfin { namespace DTO { -JoinGroupRequestDto::JoinGroupRequestDto(QObject *parent) {} +JoinGroupRequestDto::JoinGroupRequestDto() {} -JoinGroupRequestDto JoinGroupRequestDto::fromJson(QJsonObject source) {JoinGroupRequestDto instance; - instance->setFromJson(source, false); +JoinGroupRequestDto JoinGroupRequestDto::fromJson(QJsonObject source) { + JoinGroupRequestDto instance; + instance.setFromJson(source); return instance; } void JoinGroupRequestDto::setFromJson(QJsonObject source) { - m_groupId = fromJsonValue(source["GroupId"]); + m_groupId = Jellyfin::Support::fromJsonValue(source["GroupId"]); } QJsonObject JoinGroupRequestDto::toJson() { QJsonObject result; - result["GroupId"] = toJsonValue(m_groupId); + result["GroupId"] = Jellyfin::Support::toJsonValue(m_groupId); return result; } @@ -58,6 +59,17 @@ void JoinGroupRequestDto::setGroupId(QUuid newGroupId) { m_groupId = newGroupId; } +} // NS DTO + +namespace Support { + +using JoinGroupRequestDto = Jellyfin::DTO::JoinGroupRequestDto; + +template <> +JoinGroupRequestDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return JoinGroupRequestDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/keepuntil.cpp b/core/src/DTO/keepuntil.cpp index 40b5d43..ac7945a 100644 --- a/core/src/DTO/keepuntil.cpp +++ b/core/src/DTO/keepuntil.cpp @@ -34,5 +34,33 @@ namespace DTO { KeepUntilClass::KeepUntilClass() {} + +} // NS DTO + +namespace Support { + +using KeepUntil = Jellyfin::DTO::KeepUntil; + +template <> +KeepUntil fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return KeepUntil::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("UntilDeleted")) { + return KeepUntil::UntilDeleted; + } + if (str == QStringLiteral("UntilSpaceNeeded")) { + return KeepUntil::UntilSpaceNeeded; + } + if (str == QStringLiteral("UntilWatched")) { + return KeepUntil::UntilWatched; + } + if (str == QStringLiteral("UntilDate")) { + return KeepUntil::UntilDate; + } + + return KeepUntil::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/libraryoptioninfodto.cpp b/core/src/DTO/libraryoptioninfodto.cpp index 6975399..85259f1 100644 --- a/core/src/DTO/libraryoptioninfodto.cpp +++ b/core/src/DTO/libraryoptioninfodto.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -LibraryOptionInfoDto::LibraryOptionInfoDto(QObject *parent) {} +LibraryOptionInfoDto::LibraryOptionInfoDto() {} -LibraryOptionInfoDto LibraryOptionInfoDto::fromJson(QJsonObject source) {LibraryOptionInfoDto instance; - instance->setFromJson(source, false); +LibraryOptionInfoDto LibraryOptionInfoDto::fromJson(QJsonObject source) { + LibraryOptionInfoDto instance; + instance.setFromJson(source); return instance; } void LibraryOptionInfoDto::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_defaultEnabled = fromJsonValue(source["DefaultEnabled"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_defaultEnabled = Jellyfin::Support::fromJsonValue(source["DefaultEnabled"]); } QJsonObject LibraryOptionInfoDto::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["DefaultEnabled"] = toJsonValue(m_defaultEnabled); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["DefaultEnabled"] = Jellyfin::Support::toJsonValue(m_defaultEnabled); return result; } @@ -65,6 +66,17 @@ void LibraryOptionInfoDto::setDefaultEnabled(bool newDefaultEnabled) { m_defaultEnabled = newDefaultEnabled; } +} // NS DTO + +namespace Support { + +using LibraryOptionInfoDto = Jellyfin::DTO::LibraryOptionInfoDto; + +template <> +LibraryOptionInfoDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return LibraryOptionInfoDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/libraryoptions.cpp b/core/src/DTO/libraryoptions.cpp index 4e2a222..ac5c8c9 100644 --- a/core/src/DTO/libraryoptions.cpp +++ b/core/src/DTO/libraryoptions.cpp @@ -32,70 +32,71 @@ namespace Jellyfin { namespace DTO { -LibraryOptions::LibraryOptions(QObject *parent) {} +LibraryOptions::LibraryOptions() {} -LibraryOptions LibraryOptions::fromJson(QJsonObject source) {LibraryOptions instance; - instance->setFromJson(source, false); +LibraryOptions LibraryOptions::fromJson(QJsonObject source) { + LibraryOptions instance; + instance.setFromJson(source); return instance; } void LibraryOptions::setFromJson(QJsonObject source) { - m_enablePhotos = fromJsonValue(source["EnablePhotos"]); - m_enableRealtimeMonitor = fromJsonValue(source["EnableRealtimeMonitor"]); - m_enableChapterImageExtraction = fromJsonValue(source["EnableChapterImageExtraction"]); - m_extractChapterImagesDuringLibraryScan = fromJsonValue(source["ExtractChapterImagesDuringLibraryScan"]); - m_pathInfos = fromJsonValue>>(source["PathInfos"]); - m_saveLocalMetadata = fromJsonValue(source["SaveLocalMetadata"]); - m_enableInternetProviders = fromJsonValue(source["EnableInternetProviders"]); - m_enableAutomaticSeriesGrouping = fromJsonValue(source["EnableAutomaticSeriesGrouping"]); - m_enableEmbeddedTitles = fromJsonValue(source["EnableEmbeddedTitles"]); - m_enableEmbeddedEpisodeInfos = fromJsonValue(source["EnableEmbeddedEpisodeInfos"]); - m_automaticRefreshIntervalDays = fromJsonValue(source["AutomaticRefreshIntervalDays"]); - m_preferredMetadataLanguage = fromJsonValue(source["PreferredMetadataLanguage"]); - m_metadataCountryCode = fromJsonValue(source["MetadataCountryCode"]); - m_seasonZeroDisplayName = fromJsonValue(source["SeasonZeroDisplayName"]); - m_metadataSavers = fromJsonValue(source["MetadataSavers"]); - m_disabledLocalMetadataReaders = fromJsonValue(source["DisabledLocalMetadataReaders"]); - m_localMetadataReaderOrder = fromJsonValue(source["LocalMetadataReaderOrder"]); - m_disabledSubtitleFetchers = fromJsonValue(source["DisabledSubtitleFetchers"]); - m_subtitleFetcherOrder = fromJsonValue(source["SubtitleFetcherOrder"]); - m_skipSubtitlesIfEmbeddedSubtitlesPresent = fromJsonValue(source["SkipSubtitlesIfEmbeddedSubtitlesPresent"]); - m_skipSubtitlesIfAudioTrackMatches = fromJsonValue(source["SkipSubtitlesIfAudioTrackMatches"]); - m_subtitleDownloadLanguages = fromJsonValue(source["SubtitleDownloadLanguages"]); - m_requirePerfectSubtitleMatch = fromJsonValue(source["RequirePerfectSubtitleMatch"]); - m_saveSubtitlesWithMedia = fromJsonValue(source["SaveSubtitlesWithMedia"]); - m_typeOptions = fromJsonValue>>(source["TypeOptions"]); + m_enablePhotos = Jellyfin::Support::fromJsonValue(source["EnablePhotos"]); + m_enableRealtimeMonitor = Jellyfin::Support::fromJsonValue(source["EnableRealtimeMonitor"]); + m_enableChapterImageExtraction = Jellyfin::Support::fromJsonValue(source["EnableChapterImageExtraction"]); + m_extractChapterImagesDuringLibraryScan = Jellyfin::Support::fromJsonValue(source["ExtractChapterImagesDuringLibraryScan"]); + m_pathInfos = Jellyfin::Support::fromJsonValue>>(source["PathInfos"]); + m_saveLocalMetadata = Jellyfin::Support::fromJsonValue(source["SaveLocalMetadata"]); + m_enableInternetProviders = Jellyfin::Support::fromJsonValue(source["EnableInternetProviders"]); + m_enableAutomaticSeriesGrouping = Jellyfin::Support::fromJsonValue(source["EnableAutomaticSeriesGrouping"]); + m_enableEmbeddedTitles = Jellyfin::Support::fromJsonValue(source["EnableEmbeddedTitles"]); + m_enableEmbeddedEpisodeInfos = Jellyfin::Support::fromJsonValue(source["EnableEmbeddedEpisodeInfos"]); + m_automaticRefreshIntervalDays = Jellyfin::Support::fromJsonValue(source["AutomaticRefreshIntervalDays"]); + m_preferredMetadataLanguage = Jellyfin::Support::fromJsonValue(source["PreferredMetadataLanguage"]); + m_metadataCountryCode = Jellyfin::Support::fromJsonValue(source["MetadataCountryCode"]); + m_seasonZeroDisplayName = Jellyfin::Support::fromJsonValue(source["SeasonZeroDisplayName"]); + m_metadataSavers = Jellyfin::Support::fromJsonValue(source["MetadataSavers"]); + m_disabledLocalMetadataReaders = Jellyfin::Support::fromJsonValue(source["DisabledLocalMetadataReaders"]); + m_localMetadataReaderOrder = Jellyfin::Support::fromJsonValue(source["LocalMetadataReaderOrder"]); + m_disabledSubtitleFetchers = Jellyfin::Support::fromJsonValue(source["DisabledSubtitleFetchers"]); + m_subtitleFetcherOrder = Jellyfin::Support::fromJsonValue(source["SubtitleFetcherOrder"]); + m_skipSubtitlesIfEmbeddedSubtitlesPresent = Jellyfin::Support::fromJsonValue(source["SkipSubtitlesIfEmbeddedSubtitlesPresent"]); + m_skipSubtitlesIfAudioTrackMatches = Jellyfin::Support::fromJsonValue(source["SkipSubtitlesIfAudioTrackMatches"]); + m_subtitleDownloadLanguages = Jellyfin::Support::fromJsonValue(source["SubtitleDownloadLanguages"]); + m_requirePerfectSubtitleMatch = Jellyfin::Support::fromJsonValue(source["RequirePerfectSubtitleMatch"]); + m_saveSubtitlesWithMedia = Jellyfin::Support::fromJsonValue(source["SaveSubtitlesWithMedia"]); + m_typeOptions = Jellyfin::Support::fromJsonValue>>(source["TypeOptions"]); } QJsonObject LibraryOptions::toJson() { QJsonObject result; - result["EnablePhotos"] = toJsonValue(m_enablePhotos); - result["EnableRealtimeMonitor"] = toJsonValue(m_enableRealtimeMonitor); - result["EnableChapterImageExtraction"] = toJsonValue(m_enableChapterImageExtraction); - result["ExtractChapterImagesDuringLibraryScan"] = toJsonValue(m_extractChapterImagesDuringLibraryScan); - result["PathInfos"] = toJsonValue>>(m_pathInfos); - result["SaveLocalMetadata"] = toJsonValue(m_saveLocalMetadata); - result["EnableInternetProviders"] = toJsonValue(m_enableInternetProviders); - result["EnableAutomaticSeriesGrouping"] = toJsonValue(m_enableAutomaticSeriesGrouping); - result["EnableEmbeddedTitles"] = toJsonValue(m_enableEmbeddedTitles); - result["EnableEmbeddedEpisodeInfos"] = toJsonValue(m_enableEmbeddedEpisodeInfos); - result["AutomaticRefreshIntervalDays"] = toJsonValue(m_automaticRefreshIntervalDays); - result["PreferredMetadataLanguage"] = toJsonValue(m_preferredMetadataLanguage); - result["MetadataCountryCode"] = toJsonValue(m_metadataCountryCode); - result["SeasonZeroDisplayName"] = toJsonValue(m_seasonZeroDisplayName); - result["MetadataSavers"] = toJsonValue(m_metadataSavers); - result["DisabledLocalMetadataReaders"] = toJsonValue(m_disabledLocalMetadataReaders); - result["LocalMetadataReaderOrder"] = toJsonValue(m_localMetadataReaderOrder); - result["DisabledSubtitleFetchers"] = toJsonValue(m_disabledSubtitleFetchers); - result["SubtitleFetcherOrder"] = toJsonValue(m_subtitleFetcherOrder); - result["SkipSubtitlesIfEmbeddedSubtitlesPresent"] = toJsonValue(m_skipSubtitlesIfEmbeddedSubtitlesPresent); - result["SkipSubtitlesIfAudioTrackMatches"] = toJsonValue(m_skipSubtitlesIfAudioTrackMatches); - result["SubtitleDownloadLanguages"] = toJsonValue(m_subtitleDownloadLanguages); - result["RequirePerfectSubtitleMatch"] = toJsonValue(m_requirePerfectSubtitleMatch); - result["SaveSubtitlesWithMedia"] = toJsonValue(m_saveSubtitlesWithMedia); - result["TypeOptions"] = toJsonValue>>(m_typeOptions); + result["EnablePhotos"] = Jellyfin::Support::toJsonValue(m_enablePhotos); + result["EnableRealtimeMonitor"] = Jellyfin::Support::toJsonValue(m_enableRealtimeMonitor); + result["EnableChapterImageExtraction"] = Jellyfin::Support::toJsonValue(m_enableChapterImageExtraction); + result["ExtractChapterImagesDuringLibraryScan"] = Jellyfin::Support::toJsonValue(m_extractChapterImagesDuringLibraryScan); + result["PathInfos"] = Jellyfin::Support::toJsonValue>>(m_pathInfos); + result["SaveLocalMetadata"] = Jellyfin::Support::toJsonValue(m_saveLocalMetadata); + result["EnableInternetProviders"] = Jellyfin::Support::toJsonValue(m_enableInternetProviders); + result["EnableAutomaticSeriesGrouping"] = Jellyfin::Support::toJsonValue(m_enableAutomaticSeriesGrouping); + result["EnableEmbeddedTitles"] = Jellyfin::Support::toJsonValue(m_enableEmbeddedTitles); + result["EnableEmbeddedEpisodeInfos"] = Jellyfin::Support::toJsonValue(m_enableEmbeddedEpisodeInfos); + result["AutomaticRefreshIntervalDays"] = Jellyfin::Support::toJsonValue(m_automaticRefreshIntervalDays); + result["PreferredMetadataLanguage"] = Jellyfin::Support::toJsonValue(m_preferredMetadataLanguage); + result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); + result["SeasonZeroDisplayName"] = Jellyfin::Support::toJsonValue(m_seasonZeroDisplayName); + result["MetadataSavers"] = Jellyfin::Support::toJsonValue(m_metadataSavers); + result["DisabledLocalMetadataReaders"] = Jellyfin::Support::toJsonValue(m_disabledLocalMetadataReaders); + result["LocalMetadataReaderOrder"] = Jellyfin::Support::toJsonValue(m_localMetadataReaderOrder); + result["DisabledSubtitleFetchers"] = Jellyfin::Support::toJsonValue(m_disabledSubtitleFetchers); + result["SubtitleFetcherOrder"] = Jellyfin::Support::toJsonValue(m_subtitleFetcherOrder); + result["SkipSubtitlesIfEmbeddedSubtitlesPresent"] = Jellyfin::Support::toJsonValue(m_skipSubtitlesIfEmbeddedSubtitlesPresent); + result["SkipSubtitlesIfAudioTrackMatches"] = Jellyfin::Support::toJsonValue(m_skipSubtitlesIfAudioTrackMatches); + result["SubtitleDownloadLanguages"] = Jellyfin::Support::toJsonValue(m_subtitleDownloadLanguages); + result["RequirePerfectSubtitleMatch"] = Jellyfin::Support::toJsonValue(m_requirePerfectSubtitleMatch); + result["SaveSubtitlesWithMedia"] = Jellyfin::Support::toJsonValue(m_saveSubtitlesWithMedia); + result["TypeOptions"] = Jellyfin::Support::toJsonValue>>(m_typeOptions); return result; } @@ -226,6 +227,17 @@ void LibraryOptions::setTypeOptions(QList> newTypeOp m_typeOptions = newTypeOptions; } +} // NS DTO + +namespace Support { + +using LibraryOptions = Jellyfin::DTO::LibraryOptions; + +template <> +LibraryOptions fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return LibraryOptions::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/libraryoptionsresultdto.cpp b/core/src/DTO/libraryoptionsresultdto.cpp index d609fdd..dde40b5 100644 --- a/core/src/DTO/libraryoptionsresultdto.cpp +++ b/core/src/DTO/libraryoptionsresultdto.cpp @@ -32,28 +32,29 @@ namespace Jellyfin { namespace DTO { -LibraryOptionsResultDto::LibraryOptionsResultDto(QObject *parent) {} +LibraryOptionsResultDto::LibraryOptionsResultDto() {} -LibraryOptionsResultDto LibraryOptionsResultDto::fromJson(QJsonObject source) {LibraryOptionsResultDto instance; - instance->setFromJson(source, false); +LibraryOptionsResultDto LibraryOptionsResultDto::fromJson(QJsonObject source) { + LibraryOptionsResultDto instance; + instance.setFromJson(source); return instance; } void LibraryOptionsResultDto::setFromJson(QJsonObject source) { - m_metadataSavers = fromJsonValue>>(source["MetadataSavers"]); - m_metadataReaders = fromJsonValue>>(source["MetadataReaders"]); - m_subtitleFetchers = fromJsonValue>>(source["SubtitleFetchers"]); - m_typeOptions = fromJsonValue>>(source["TypeOptions"]); + m_metadataSavers = Jellyfin::Support::fromJsonValue>>(source["MetadataSavers"]); + m_metadataReaders = Jellyfin::Support::fromJsonValue>>(source["MetadataReaders"]); + m_subtitleFetchers = Jellyfin::Support::fromJsonValue>>(source["SubtitleFetchers"]); + m_typeOptions = Jellyfin::Support::fromJsonValue>>(source["TypeOptions"]); } QJsonObject LibraryOptionsResultDto::toJson() { QJsonObject result; - result["MetadataSavers"] = toJsonValue>>(m_metadataSavers); - result["MetadataReaders"] = toJsonValue>>(m_metadataReaders); - result["SubtitleFetchers"] = toJsonValue>>(m_subtitleFetchers); - result["TypeOptions"] = toJsonValue>>(m_typeOptions); + result["MetadataSavers"] = Jellyfin::Support::toJsonValue>>(m_metadataSavers); + result["MetadataReaders"] = Jellyfin::Support::toJsonValue>>(m_metadataReaders); + result["SubtitleFetchers"] = Jellyfin::Support::toJsonValue>>(m_subtitleFetchers); + result["TypeOptions"] = Jellyfin::Support::toJsonValue>>(m_typeOptions); return result; } @@ -79,6 +80,17 @@ void LibraryOptionsResultDto::setTypeOptions(QList +LibraryOptionsResultDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return LibraryOptionsResultDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/librarytypeoptionsdto.cpp b/core/src/DTO/librarytypeoptionsdto.cpp index 79fcfff..072c8be 100644 --- a/core/src/DTO/librarytypeoptionsdto.cpp +++ b/core/src/DTO/librarytypeoptionsdto.cpp @@ -32,30 +32,31 @@ namespace Jellyfin { namespace DTO { -LibraryTypeOptionsDto::LibraryTypeOptionsDto(QObject *parent) {} +LibraryTypeOptionsDto::LibraryTypeOptionsDto() {} -LibraryTypeOptionsDto LibraryTypeOptionsDto::fromJson(QJsonObject source) {LibraryTypeOptionsDto instance; - instance->setFromJson(source, false); +LibraryTypeOptionsDto LibraryTypeOptionsDto::fromJson(QJsonObject source) { + LibraryTypeOptionsDto instance; + instance.setFromJson(source); return instance; } void LibraryTypeOptionsDto::setFromJson(QJsonObject source) { - m_type = fromJsonValue(source["Type"]); - m_metadataFetchers = fromJsonValue>>(source["MetadataFetchers"]); - m_imageFetchers = fromJsonValue>>(source["ImageFetchers"]); - m_supportedImageTypes = fromJsonValue>(source["SupportedImageTypes"]); - m_defaultImageOptions = fromJsonValue>>(source["DefaultImageOptions"]); + m_type = Jellyfin::Support::fromJsonValue(source["Type"]); + m_metadataFetchers = Jellyfin::Support::fromJsonValue>>(source["MetadataFetchers"]); + m_imageFetchers = Jellyfin::Support::fromJsonValue>>(source["ImageFetchers"]); + m_supportedImageTypes = Jellyfin::Support::fromJsonValue>(source["SupportedImageTypes"]); + m_defaultImageOptions = Jellyfin::Support::fromJsonValue>>(source["DefaultImageOptions"]); } QJsonObject LibraryTypeOptionsDto::toJson() { QJsonObject result; - result["Type"] = toJsonValue(m_type); - result["MetadataFetchers"] = toJsonValue>>(m_metadataFetchers); - result["ImageFetchers"] = toJsonValue>>(m_imageFetchers); - result["SupportedImageTypes"] = toJsonValue>(m_supportedImageTypes); - result["DefaultImageOptions"] = toJsonValue>>(m_defaultImageOptions); + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + result["MetadataFetchers"] = Jellyfin::Support::toJsonValue>>(m_metadataFetchers); + result["ImageFetchers"] = Jellyfin::Support::toJsonValue>>(m_imageFetchers); + result["SupportedImageTypes"] = Jellyfin::Support::toJsonValue>(m_supportedImageTypes); + result["DefaultImageOptions"] = Jellyfin::Support::toJsonValue>>(m_defaultImageOptions); return result; } @@ -86,6 +87,17 @@ void LibraryTypeOptionsDto::setDefaultImageOptions(QList +LibraryTypeOptionsDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return LibraryTypeOptionsDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/libraryupdateinfo.cpp b/core/src/DTO/libraryupdateinfo.cpp index 7939a46..f2217aa 100644 --- a/core/src/DTO/libraryupdateinfo.cpp +++ b/core/src/DTO/libraryupdateinfo.cpp @@ -32,34 +32,35 @@ namespace Jellyfin { namespace DTO { -LibraryUpdateInfo::LibraryUpdateInfo(QObject *parent) {} +LibraryUpdateInfo::LibraryUpdateInfo() {} -LibraryUpdateInfo LibraryUpdateInfo::fromJson(QJsonObject source) {LibraryUpdateInfo instance; - instance->setFromJson(source, false); +LibraryUpdateInfo LibraryUpdateInfo::fromJson(QJsonObject source) { + LibraryUpdateInfo instance; + instance.setFromJson(source); return instance; } void LibraryUpdateInfo::setFromJson(QJsonObject source) { - m_foldersAddedTo = fromJsonValue(source["FoldersAddedTo"]); - m_foldersRemovedFrom = fromJsonValue(source["FoldersRemovedFrom"]); - m_itemsAdded = fromJsonValue(source["ItemsAdded"]); - m_itemsRemoved = fromJsonValue(source["ItemsRemoved"]); - m_itemsUpdated = fromJsonValue(source["ItemsUpdated"]); - m_collectionFolders = fromJsonValue(source["CollectionFolders"]); - m_isEmpty = fromJsonValue(source["IsEmpty"]); + m_foldersAddedTo = Jellyfin::Support::fromJsonValue(source["FoldersAddedTo"]); + m_foldersRemovedFrom = Jellyfin::Support::fromJsonValue(source["FoldersRemovedFrom"]); + m_itemsAdded = Jellyfin::Support::fromJsonValue(source["ItemsAdded"]); + m_itemsRemoved = Jellyfin::Support::fromJsonValue(source["ItemsRemoved"]); + m_itemsUpdated = Jellyfin::Support::fromJsonValue(source["ItemsUpdated"]); + m_collectionFolders = Jellyfin::Support::fromJsonValue(source["CollectionFolders"]); + m_isEmpty = Jellyfin::Support::fromJsonValue(source["IsEmpty"]); } QJsonObject LibraryUpdateInfo::toJson() { QJsonObject result; - result["FoldersAddedTo"] = toJsonValue(m_foldersAddedTo); - result["FoldersRemovedFrom"] = toJsonValue(m_foldersRemovedFrom); - result["ItemsAdded"] = toJsonValue(m_itemsAdded); - result["ItemsRemoved"] = toJsonValue(m_itemsRemoved); - result["ItemsUpdated"] = toJsonValue(m_itemsUpdated); - result["CollectionFolders"] = toJsonValue(m_collectionFolders); - result["IsEmpty"] = toJsonValue(m_isEmpty); + result["FoldersAddedTo"] = Jellyfin::Support::toJsonValue(m_foldersAddedTo); + result["FoldersRemovedFrom"] = Jellyfin::Support::toJsonValue(m_foldersRemovedFrom); + result["ItemsAdded"] = Jellyfin::Support::toJsonValue(m_itemsAdded); + result["ItemsRemoved"] = Jellyfin::Support::toJsonValue(m_itemsRemoved); + result["ItemsUpdated"] = Jellyfin::Support::toJsonValue(m_itemsUpdated); + result["CollectionFolders"] = Jellyfin::Support::toJsonValue(m_collectionFolders); + result["IsEmpty"] = Jellyfin::Support::toJsonValue(m_isEmpty); return result; } @@ -100,6 +101,17 @@ void LibraryUpdateInfo::setIsEmpty(bool newIsEmpty) { m_isEmpty = newIsEmpty; } +} // NS DTO + +namespace Support { + +using LibraryUpdateInfo = Jellyfin::DTO::LibraryUpdateInfo; + +template <> +LibraryUpdateInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return LibraryUpdateInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/listingsproviderinfo.cpp b/core/src/DTO/listingsproviderinfo.cpp index da02c85..b43b9d3 100644 --- a/core/src/DTO/listingsproviderinfo.cpp +++ b/core/src/DTO/listingsproviderinfo.cpp @@ -32,56 +32,57 @@ namespace Jellyfin { namespace DTO { -ListingsProviderInfo::ListingsProviderInfo(QObject *parent) {} +ListingsProviderInfo::ListingsProviderInfo() {} -ListingsProviderInfo ListingsProviderInfo::fromJson(QJsonObject source) {ListingsProviderInfo instance; - instance->setFromJson(source, false); +ListingsProviderInfo ListingsProviderInfo::fromJson(QJsonObject source) { + ListingsProviderInfo instance; + instance.setFromJson(source); return instance; } void ListingsProviderInfo::setFromJson(QJsonObject source) { - m_jellyfinId = fromJsonValue(source["Id"]); - m_type = fromJsonValue(source["Type"]); - m_username = fromJsonValue(source["Username"]); - m_password = fromJsonValue(source["Password"]); - m_listingsId = fromJsonValue(source["ListingsId"]); - m_zipCode = fromJsonValue(source["ZipCode"]); - m_country = fromJsonValue(source["Country"]); - m_path = fromJsonValue(source["Path"]); - m_enabledTuners = fromJsonValue(source["EnabledTuners"]); - m_enableAllTuners = fromJsonValue(source["EnableAllTuners"]); - m_newsCategories = fromJsonValue(source["NewsCategories"]); - m_sportsCategories = fromJsonValue(source["SportsCategories"]); - m_kidsCategories = fromJsonValue(source["KidsCategories"]); - m_movieCategories = fromJsonValue(source["MovieCategories"]); - m_channelMappings = fromJsonValue>>(source["ChannelMappings"]); - m_moviePrefix = fromJsonValue(source["MoviePrefix"]); - m_preferredLanguage = fromJsonValue(source["PreferredLanguage"]); - m_userAgent = fromJsonValue(source["UserAgent"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); + m_type = Jellyfin::Support::fromJsonValue(source["Type"]); + m_username = Jellyfin::Support::fromJsonValue(source["Username"]); + m_password = Jellyfin::Support::fromJsonValue(source["Password"]); + m_listingsId = Jellyfin::Support::fromJsonValue(source["ListingsId"]); + m_zipCode = Jellyfin::Support::fromJsonValue(source["ZipCode"]); + m_country = Jellyfin::Support::fromJsonValue(source["Country"]); + m_path = Jellyfin::Support::fromJsonValue(source["Path"]); + m_enabledTuners = Jellyfin::Support::fromJsonValue(source["EnabledTuners"]); + m_enableAllTuners = Jellyfin::Support::fromJsonValue(source["EnableAllTuners"]); + m_newsCategories = Jellyfin::Support::fromJsonValue(source["NewsCategories"]); + m_sportsCategories = Jellyfin::Support::fromJsonValue(source["SportsCategories"]); + m_kidsCategories = Jellyfin::Support::fromJsonValue(source["KidsCategories"]); + m_movieCategories = Jellyfin::Support::fromJsonValue(source["MovieCategories"]); + m_channelMappings = Jellyfin::Support::fromJsonValue>>(source["ChannelMappings"]); + m_moviePrefix = Jellyfin::Support::fromJsonValue(source["MoviePrefix"]); + m_preferredLanguage = Jellyfin::Support::fromJsonValue(source["PreferredLanguage"]); + m_userAgent = Jellyfin::Support::fromJsonValue(source["UserAgent"]); } QJsonObject ListingsProviderInfo::toJson() { QJsonObject result; - result["Id"] = toJsonValue(m_jellyfinId); - result["Type"] = toJsonValue(m_type); - result["Username"] = toJsonValue(m_username); - result["Password"] = toJsonValue(m_password); - result["ListingsId"] = toJsonValue(m_listingsId); - result["ZipCode"] = toJsonValue(m_zipCode); - result["Country"] = toJsonValue(m_country); - result["Path"] = toJsonValue(m_path); - result["EnabledTuners"] = toJsonValue(m_enabledTuners); - result["EnableAllTuners"] = toJsonValue(m_enableAllTuners); - result["NewsCategories"] = toJsonValue(m_newsCategories); - result["SportsCategories"] = toJsonValue(m_sportsCategories); - result["KidsCategories"] = toJsonValue(m_kidsCategories); - result["MovieCategories"] = toJsonValue(m_movieCategories); - result["ChannelMappings"] = toJsonValue>>(m_channelMappings); - result["MoviePrefix"] = toJsonValue(m_moviePrefix); - result["PreferredLanguage"] = toJsonValue(m_preferredLanguage); - result["UserAgent"] = toJsonValue(m_userAgent); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + result["Username"] = Jellyfin::Support::toJsonValue(m_username); + result["Password"] = Jellyfin::Support::toJsonValue(m_password); + result["ListingsId"] = Jellyfin::Support::toJsonValue(m_listingsId); + result["ZipCode"] = Jellyfin::Support::toJsonValue(m_zipCode); + result["Country"] = Jellyfin::Support::toJsonValue(m_country); + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + result["EnabledTuners"] = Jellyfin::Support::toJsonValue(m_enabledTuners); + result["EnableAllTuners"] = Jellyfin::Support::toJsonValue(m_enableAllTuners); + result["NewsCategories"] = Jellyfin::Support::toJsonValue(m_newsCategories); + result["SportsCategories"] = Jellyfin::Support::toJsonValue(m_sportsCategories); + result["KidsCategories"] = Jellyfin::Support::toJsonValue(m_kidsCategories); + result["MovieCategories"] = Jellyfin::Support::toJsonValue(m_movieCategories); + result["ChannelMappings"] = Jellyfin::Support::toJsonValue>>(m_channelMappings); + result["MoviePrefix"] = Jellyfin::Support::toJsonValue(m_moviePrefix); + result["PreferredLanguage"] = Jellyfin::Support::toJsonValue(m_preferredLanguage); + result["UserAgent"] = Jellyfin::Support::toJsonValue(m_userAgent); return result; } @@ -177,6 +178,17 @@ void ListingsProviderInfo::setUserAgent(QString newUserAgent) { m_userAgent = newUserAgent; } +} // NS DTO + +namespace Support { + +using ListingsProviderInfo = Jellyfin::DTO::ListingsProviderInfo; + +template <> +ListingsProviderInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ListingsProviderInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/livestreamresponse.cpp b/core/src/DTO/livestreamresponse.cpp index be29bfc..96c1d8e 100644 --- a/core/src/DTO/livestreamresponse.cpp +++ b/core/src/DTO/livestreamresponse.cpp @@ -32,22 +32,23 @@ namespace Jellyfin { namespace DTO { -LiveStreamResponse::LiveStreamResponse(QObject *parent) {} +LiveStreamResponse::LiveStreamResponse() {} -LiveStreamResponse LiveStreamResponse::fromJson(QJsonObject source) {LiveStreamResponse instance; - instance->setFromJson(source, false); +LiveStreamResponse LiveStreamResponse::fromJson(QJsonObject source) { + LiveStreamResponse instance; + instance.setFromJson(source); return instance; } void LiveStreamResponse::setFromJson(QJsonObject source) { - m_mediaSource = fromJsonValue>(source["MediaSource"]); + m_mediaSource = Jellyfin::Support::fromJsonValue>(source["MediaSource"]); } QJsonObject LiveStreamResponse::toJson() { QJsonObject result; - result["MediaSource"] = toJsonValue>(m_mediaSource); + result["MediaSource"] = Jellyfin::Support::toJsonValue>(m_mediaSource); return result; } @@ -58,6 +59,17 @@ void LiveStreamResponse::setMediaSource(QSharedPointer newMedia m_mediaSource = newMediaSource; } +} // NS DTO + +namespace Support { + +using LiveStreamResponse = Jellyfin::DTO::LiveStreamResponse; + +template <> +LiveStreamResponse fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return LiveStreamResponse::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/livetvinfo.cpp b/core/src/DTO/livetvinfo.cpp index f0851dd..0685a7b 100644 --- a/core/src/DTO/livetvinfo.cpp +++ b/core/src/DTO/livetvinfo.cpp @@ -32,26 +32,27 @@ namespace Jellyfin { namespace DTO { -LiveTvInfo::LiveTvInfo(QObject *parent) {} +LiveTvInfo::LiveTvInfo() {} -LiveTvInfo LiveTvInfo::fromJson(QJsonObject source) {LiveTvInfo instance; - instance->setFromJson(source, false); +LiveTvInfo LiveTvInfo::fromJson(QJsonObject source) { + LiveTvInfo instance; + instance.setFromJson(source); return instance; } void LiveTvInfo::setFromJson(QJsonObject source) { - m_services = fromJsonValue>>(source["Services"]); - m_isEnabled = fromJsonValue(source["IsEnabled"]); - m_enabledUsers = fromJsonValue(source["EnabledUsers"]); + m_services = Jellyfin::Support::fromJsonValue>>(source["Services"]); + m_isEnabled = Jellyfin::Support::fromJsonValue(source["IsEnabled"]); + m_enabledUsers = Jellyfin::Support::fromJsonValue(source["EnabledUsers"]); } QJsonObject LiveTvInfo::toJson() { QJsonObject result; - result["Services"] = toJsonValue>>(m_services); - result["IsEnabled"] = toJsonValue(m_isEnabled); - result["EnabledUsers"] = toJsonValue(m_enabledUsers); + result["Services"] = Jellyfin::Support::toJsonValue>>(m_services); + result["IsEnabled"] = Jellyfin::Support::toJsonValue(m_isEnabled); + result["EnabledUsers"] = Jellyfin::Support::toJsonValue(m_enabledUsers); return result; } @@ -72,6 +73,17 @@ void LiveTvInfo::setEnabledUsers(QStringList newEnabledUsers) { m_enabledUsers = newEnabledUsers; } +} // NS DTO + +namespace Support { + +using LiveTvInfo = Jellyfin::DTO::LiveTvInfo; + +template <> +LiveTvInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return LiveTvInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/livetvserviceinfo.cpp b/core/src/DTO/livetvserviceinfo.cpp index d6a3d94..81dd38a 100644 --- a/core/src/DTO/livetvserviceinfo.cpp +++ b/core/src/DTO/livetvserviceinfo.cpp @@ -32,36 +32,37 @@ namespace Jellyfin { namespace DTO { -LiveTvServiceInfo::LiveTvServiceInfo(QObject *parent) {} +LiveTvServiceInfo::LiveTvServiceInfo() {} -LiveTvServiceInfo LiveTvServiceInfo::fromJson(QJsonObject source) {LiveTvServiceInfo instance; - instance->setFromJson(source, false); +LiveTvServiceInfo LiveTvServiceInfo::fromJson(QJsonObject source) { + LiveTvServiceInfo instance; + instance.setFromJson(source); return instance; } void LiveTvServiceInfo::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_homePageUrl = fromJsonValue(source["HomePageUrl"]); - m_status = fromJsonValue(source["Status"]); - m_statusMessage = fromJsonValue(source["StatusMessage"]); - m_version = fromJsonValue(source["Version"]); - m_hasUpdateAvailable = fromJsonValue(source["HasUpdateAvailable"]); - m_isVisible = fromJsonValue(source["IsVisible"]); - m_tuners = fromJsonValue(source["Tuners"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_homePageUrl = Jellyfin::Support::fromJsonValue(source["HomePageUrl"]); + m_status = Jellyfin::Support::fromJsonValue(source["Status"]); + m_statusMessage = Jellyfin::Support::fromJsonValue(source["StatusMessage"]); + m_version = Jellyfin::Support::fromJsonValue(source["Version"]); + m_hasUpdateAvailable = Jellyfin::Support::fromJsonValue(source["HasUpdateAvailable"]); + m_isVisible = Jellyfin::Support::fromJsonValue(source["IsVisible"]); + m_tuners = Jellyfin::Support::fromJsonValue(source["Tuners"]); } QJsonObject LiveTvServiceInfo::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["HomePageUrl"] = toJsonValue(m_homePageUrl); - result["Status"] = toJsonValue(m_status); - result["StatusMessage"] = toJsonValue(m_statusMessage); - result["Version"] = toJsonValue(m_version); - result["HasUpdateAvailable"] = toJsonValue(m_hasUpdateAvailable); - result["IsVisible"] = toJsonValue(m_isVisible); - result["Tuners"] = toJsonValue(m_tuners); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["HomePageUrl"] = Jellyfin::Support::toJsonValue(m_homePageUrl); + result["Status"] = Jellyfin::Support::toJsonValue(m_status); + result["StatusMessage"] = Jellyfin::Support::toJsonValue(m_statusMessage); + result["Version"] = Jellyfin::Support::toJsonValue(m_version); + result["HasUpdateAvailable"] = Jellyfin::Support::toJsonValue(m_hasUpdateAvailable); + result["IsVisible"] = Jellyfin::Support::toJsonValue(m_isVisible); + result["Tuners"] = Jellyfin::Support::toJsonValue(m_tuners); return result; } @@ -107,6 +108,17 @@ void LiveTvServiceInfo::setTuners(QStringList newTuners) { m_tuners = newTuners; } +} // NS DTO + +namespace Support { + +using LiveTvServiceInfo = Jellyfin::DTO::LiveTvServiceInfo; + +template <> +LiveTvServiceInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return LiveTvServiceInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/livetvservicestatus.cpp b/core/src/DTO/livetvservicestatus.cpp index 26cac76..97e23b2 100644 --- a/core/src/DTO/livetvservicestatus.cpp +++ b/core/src/DTO/livetvservicestatus.cpp @@ -34,5 +34,27 @@ namespace DTO { LiveTvServiceStatusClass::LiveTvServiceStatusClass() {} + +} // NS DTO + +namespace Support { + +using LiveTvServiceStatus = Jellyfin::DTO::LiveTvServiceStatus; + +template <> +LiveTvServiceStatus fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return LiveTvServiceStatus::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Ok")) { + return LiveTvServiceStatus::Ok; + } + if (str == QStringLiteral("Unavailable")) { + return LiveTvServiceStatus::Unavailable; + } + + return LiveTvServiceStatus::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/localizationoption.cpp b/core/src/DTO/localizationoption.cpp index 018aa27..66385a5 100644 --- a/core/src/DTO/localizationoption.cpp +++ b/core/src/DTO/localizationoption.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -LocalizationOption::LocalizationOption(QObject *parent) {} +LocalizationOption::LocalizationOption() {} -LocalizationOption LocalizationOption::fromJson(QJsonObject source) {LocalizationOption instance; - instance->setFromJson(source, false); +LocalizationOption LocalizationOption::fromJson(QJsonObject source) { + LocalizationOption instance; + instance.setFromJson(source); return instance; } void LocalizationOption::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_value = fromJsonValue(source["Value"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_value = Jellyfin::Support::fromJsonValue(source["Value"]); } QJsonObject LocalizationOption::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Value"] = toJsonValue(m_value); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Value"] = Jellyfin::Support::toJsonValue(m_value); return result; } @@ -65,6 +66,17 @@ void LocalizationOption::setValue(QString newValue) { m_value = newValue; } +} // NS DTO + +namespace Support { + +using LocalizationOption = Jellyfin::DTO::LocalizationOption; + +template <> +LocalizationOption fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return LocalizationOption::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/locationtype.cpp b/core/src/DTO/locationtype.cpp index 04f74fb..4f98273 100644 --- a/core/src/DTO/locationtype.cpp +++ b/core/src/DTO/locationtype.cpp @@ -34,5 +34,33 @@ namespace DTO { LocationTypeClass::LocationTypeClass() {} + +} // NS DTO + +namespace Support { + +using LocationType = Jellyfin::DTO::LocationType; + +template <> +LocationType fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return LocationType::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("FileSystem")) { + return LocationType::FileSystem; + } + if (str == QStringLiteral("Remote")) { + return LocationType::Remote; + } + if (str == QStringLiteral("Virtual")) { + return LocationType::Virtual; + } + if (str == QStringLiteral("Offline")) { + return LocationType::Offline; + } + + return LocationType::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/logfile.cpp b/core/src/DTO/logfile.cpp index 9168197..bfd622f 100644 --- a/core/src/DTO/logfile.cpp +++ b/core/src/DTO/logfile.cpp @@ -32,28 +32,29 @@ namespace Jellyfin { namespace DTO { -LogFile::LogFile(QObject *parent) {} +LogFile::LogFile() {} -LogFile LogFile::fromJson(QJsonObject source) {LogFile instance; - instance->setFromJson(source, false); +LogFile LogFile::fromJson(QJsonObject source) { + LogFile instance; + instance.setFromJson(source); return instance; } void LogFile::setFromJson(QJsonObject source) { - m_dateCreated = fromJsonValue(source["DateCreated"]); - m_dateModified = fromJsonValue(source["DateModified"]); - m_size = fromJsonValue(source["Size"]); - m_name = fromJsonValue(source["Name"]); + m_dateCreated = Jellyfin::Support::fromJsonValue(source["DateCreated"]); + m_dateModified = Jellyfin::Support::fromJsonValue(source["DateModified"]); + m_size = Jellyfin::Support::fromJsonValue(source["Size"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); } QJsonObject LogFile::toJson() { QJsonObject result; - result["DateCreated"] = toJsonValue(m_dateCreated); - result["DateModified"] = toJsonValue(m_dateModified); - result["Size"] = toJsonValue(m_size); - result["Name"] = toJsonValue(m_name); + result["DateCreated"] = Jellyfin::Support::toJsonValue(m_dateCreated); + result["DateModified"] = Jellyfin::Support::toJsonValue(m_dateModified); + result["Size"] = Jellyfin::Support::toJsonValue(m_size); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); return result; } @@ -79,6 +80,17 @@ void LogFile::setName(QString newName) { m_name = newName; } +} // NS DTO + +namespace Support { + +using LogFile = Jellyfin::DTO::LogFile; + +template <> +LogFile fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return LogFile::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/loglevel.cpp b/core/src/DTO/loglevel.cpp index 0b4e7ad..04af5dc 100644 --- a/core/src/DTO/loglevel.cpp +++ b/core/src/DTO/loglevel.cpp @@ -34,5 +34,42 @@ namespace DTO { LogLevelClass::LogLevelClass() {} + +} // NS DTO + +namespace Support { + +using LogLevel = Jellyfin::DTO::LogLevel; + +template <> +LogLevel fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return LogLevel::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Trace")) { + return LogLevel::Trace; + } + if (str == QStringLiteral("Debug")) { + return LogLevel::Debug; + } + if (str == QStringLiteral("Information")) { + return LogLevel::Information; + } + if (str == QStringLiteral("Warning")) { + return LogLevel::Warning; + } + if (str == QStringLiteral("Error")) { + return LogLevel::Error; + } + if (str == QStringLiteral("Critical")) { + return LogLevel::Critical; + } + if (str == QStringLiteral("None")) { + return LogLevel::None; + } + + return LogLevel::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/mediaattachment.cpp b/core/src/DTO/mediaattachment.cpp index 8622c78..cf2c604 100644 --- a/core/src/DTO/mediaattachment.cpp +++ b/core/src/DTO/mediaattachment.cpp @@ -32,34 +32,35 @@ namespace Jellyfin { namespace DTO { -MediaAttachment::MediaAttachment(QObject *parent) {} +MediaAttachment::MediaAttachment() {} -MediaAttachment MediaAttachment::fromJson(QJsonObject source) {MediaAttachment instance; - instance->setFromJson(source, false); +MediaAttachment MediaAttachment::fromJson(QJsonObject source) { + MediaAttachment instance; + instance.setFromJson(source); return instance; } void MediaAttachment::setFromJson(QJsonObject source) { - m_codec = fromJsonValue(source["Codec"]); - m_codecTag = fromJsonValue(source["CodecTag"]); - m_comment = fromJsonValue(source["Comment"]); - m_index = fromJsonValue(source["Index"]); - m_fileName = fromJsonValue(source["FileName"]); - m_mimeType = fromJsonValue(source["MimeType"]); - m_deliveryUrl = fromJsonValue(source["DeliveryUrl"]); + m_codec = Jellyfin::Support::fromJsonValue(source["Codec"]); + m_codecTag = Jellyfin::Support::fromJsonValue(source["CodecTag"]); + m_comment = Jellyfin::Support::fromJsonValue(source["Comment"]); + m_index = Jellyfin::Support::fromJsonValue(source["Index"]); + m_fileName = Jellyfin::Support::fromJsonValue(source["FileName"]); + m_mimeType = Jellyfin::Support::fromJsonValue(source["MimeType"]); + m_deliveryUrl = Jellyfin::Support::fromJsonValue(source["DeliveryUrl"]); } QJsonObject MediaAttachment::toJson() { QJsonObject result; - result["Codec"] = toJsonValue(m_codec); - result["CodecTag"] = toJsonValue(m_codecTag); - result["Comment"] = toJsonValue(m_comment); - result["Index"] = toJsonValue(m_index); - result["FileName"] = toJsonValue(m_fileName); - result["MimeType"] = toJsonValue(m_mimeType); - result["DeliveryUrl"] = toJsonValue(m_deliveryUrl); + result["Codec"] = Jellyfin::Support::toJsonValue(m_codec); + result["CodecTag"] = Jellyfin::Support::toJsonValue(m_codecTag); + result["Comment"] = Jellyfin::Support::toJsonValue(m_comment); + result["Index"] = Jellyfin::Support::toJsonValue(m_index); + result["FileName"] = Jellyfin::Support::toJsonValue(m_fileName); + result["MimeType"] = Jellyfin::Support::toJsonValue(m_mimeType); + result["DeliveryUrl"] = Jellyfin::Support::toJsonValue(m_deliveryUrl); return result; } @@ -100,6 +101,17 @@ void MediaAttachment::setDeliveryUrl(QString newDeliveryUrl) { m_deliveryUrl = newDeliveryUrl; } +} // NS DTO + +namespace Support { + +using MediaAttachment = Jellyfin::DTO::MediaAttachment; + +template <> +MediaAttachment fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return MediaAttachment::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/mediaencoderpathdto.cpp b/core/src/DTO/mediaencoderpathdto.cpp index 5e3ed54..43c566d 100644 --- a/core/src/DTO/mediaencoderpathdto.cpp +++ b/core/src/DTO/mediaencoderpathdto.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -MediaEncoderPathDto::MediaEncoderPathDto(QObject *parent) {} +MediaEncoderPathDto::MediaEncoderPathDto() {} -MediaEncoderPathDto MediaEncoderPathDto::fromJson(QJsonObject source) {MediaEncoderPathDto instance; - instance->setFromJson(source, false); +MediaEncoderPathDto MediaEncoderPathDto::fromJson(QJsonObject source) { + MediaEncoderPathDto instance; + instance.setFromJson(source); return instance; } void MediaEncoderPathDto::setFromJson(QJsonObject source) { - m_path = fromJsonValue(source["Path"]); - m_pathType = fromJsonValue(source["PathType"]); + m_path = Jellyfin::Support::fromJsonValue(source["Path"]); + m_pathType = Jellyfin::Support::fromJsonValue(source["PathType"]); } QJsonObject MediaEncoderPathDto::toJson() { QJsonObject result; - result["Path"] = toJsonValue(m_path); - result["PathType"] = toJsonValue(m_pathType); + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + result["PathType"] = Jellyfin::Support::toJsonValue(m_pathType); return result; } @@ -65,6 +66,17 @@ void MediaEncoderPathDto::setPathType(QString newPathType) { m_pathType = newPathType; } +} // NS DTO + +namespace Support { + +using MediaEncoderPathDto = Jellyfin::DTO::MediaEncoderPathDto; + +template <> +MediaEncoderPathDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return MediaEncoderPathDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/mediapathdto.cpp b/core/src/DTO/mediapathdto.cpp index ee9950c..44b891b 100644 --- a/core/src/DTO/mediapathdto.cpp +++ b/core/src/DTO/mediapathdto.cpp @@ -32,26 +32,27 @@ namespace Jellyfin { namespace DTO { -MediaPathDto::MediaPathDto(QObject *parent) {} +MediaPathDto::MediaPathDto() {} -MediaPathDto MediaPathDto::fromJson(QJsonObject source) {MediaPathDto instance; - instance->setFromJson(source, false); +MediaPathDto MediaPathDto::fromJson(QJsonObject source) { + MediaPathDto instance; + instance.setFromJson(source); return instance; } void MediaPathDto::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_path = fromJsonValue(source["Path"]); - m_pathInfo = fromJsonValue>(source["PathInfo"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_path = Jellyfin::Support::fromJsonValue(source["Path"]); + m_pathInfo = Jellyfin::Support::fromJsonValue>(source["PathInfo"]); } QJsonObject MediaPathDto::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Path"] = toJsonValue(m_path); - result["PathInfo"] = toJsonValue>(m_pathInfo); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + result["PathInfo"] = Jellyfin::Support::toJsonValue>(m_pathInfo); return result; } @@ -72,6 +73,17 @@ void MediaPathDto::setPathInfo(QSharedPointer newPathInfo) { m_pathInfo = newPathInfo; } +} // NS DTO + +namespace Support { + +using MediaPathDto = Jellyfin::DTO::MediaPathDto; + +template <> +MediaPathDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return MediaPathDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/mediapathinfo.cpp b/core/src/DTO/mediapathinfo.cpp index 1e93938..0601405 100644 --- a/core/src/DTO/mediapathinfo.cpp +++ b/core/src/DTO/mediapathinfo.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -MediaPathInfo::MediaPathInfo(QObject *parent) {} +MediaPathInfo::MediaPathInfo() {} -MediaPathInfo MediaPathInfo::fromJson(QJsonObject source) {MediaPathInfo instance; - instance->setFromJson(source, false); +MediaPathInfo MediaPathInfo::fromJson(QJsonObject source) { + MediaPathInfo instance; + instance.setFromJson(source); return instance; } void MediaPathInfo::setFromJson(QJsonObject source) { - m_path = fromJsonValue(source["Path"]); - m_networkPath = fromJsonValue(source["NetworkPath"]); + m_path = Jellyfin::Support::fromJsonValue(source["Path"]); + m_networkPath = Jellyfin::Support::fromJsonValue(source["NetworkPath"]); } QJsonObject MediaPathInfo::toJson() { QJsonObject result; - result["Path"] = toJsonValue(m_path); - result["NetworkPath"] = toJsonValue(m_networkPath); + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + result["NetworkPath"] = Jellyfin::Support::toJsonValue(m_networkPath); return result; } @@ -65,6 +66,17 @@ void MediaPathInfo::setNetworkPath(QString newNetworkPath) { m_networkPath = newNetworkPath; } +} // NS DTO + +namespace Support { + +using MediaPathInfo = Jellyfin::DTO::MediaPathInfo; + +template <> +MediaPathInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return MediaPathInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/mediaprotocol.cpp b/core/src/DTO/mediaprotocol.cpp index c4aa9da..21cde8a 100644 --- a/core/src/DTO/mediaprotocol.cpp +++ b/core/src/DTO/mediaprotocol.cpp @@ -34,5 +34,42 @@ namespace DTO { MediaProtocolClass::MediaProtocolClass() {} + +} // NS DTO + +namespace Support { + +using MediaProtocol = Jellyfin::DTO::MediaProtocol; + +template <> +MediaProtocol fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return MediaProtocol::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("File")) { + return MediaProtocol::File; + } + if (str == QStringLiteral("Http")) { + return MediaProtocol::Http; + } + if (str == QStringLiteral("Rtmp")) { + return MediaProtocol::Rtmp; + } + if (str == QStringLiteral("Rtsp")) { + return MediaProtocol::Rtsp; + } + if (str == QStringLiteral("Udp")) { + return MediaProtocol::Udp; + } + if (str == QStringLiteral("Rtp")) { + return MediaProtocol::Rtp; + } + if (str == QStringLiteral("Ftp")) { + return MediaProtocol::Ftp; + } + + return MediaProtocol::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/mediasourceinfo.cpp b/core/src/DTO/mediasourceinfo.cpp index 8175b65..39dfe58 100644 --- a/core/src/DTO/mediasourceinfo.cpp +++ b/core/src/DTO/mediasourceinfo.cpp @@ -32,104 +32,105 @@ namespace Jellyfin { namespace DTO { -MediaSourceInfo::MediaSourceInfo(QObject *parent) {} +MediaSourceInfo::MediaSourceInfo() {} -MediaSourceInfo MediaSourceInfo::fromJson(QJsonObject source) {MediaSourceInfo instance; - instance->setFromJson(source, false); +MediaSourceInfo MediaSourceInfo::fromJson(QJsonObject source) { + MediaSourceInfo instance; + instance.setFromJson(source); return instance; } void MediaSourceInfo::setFromJson(QJsonObject source) { - m_protocol = fromJsonValue(source["Protocol"]); - m_jellyfinId = fromJsonValue(source["Id"]); - m_path = fromJsonValue(source["Path"]); - m_encoderPath = fromJsonValue(source["EncoderPath"]); - m_encoderProtocol = fromJsonValue(source["EncoderProtocol"]); - m_type = fromJsonValue(source["Type"]); - m_container = fromJsonValue(source["Container"]); - m_size = fromJsonValue(source["Size"]); - m_name = fromJsonValue(source["Name"]); - m_isRemote = fromJsonValue(source["IsRemote"]); - m_eTag = fromJsonValue(source["ETag"]); - m_runTimeTicks = fromJsonValue(source["RunTimeTicks"]); - m_readAtNativeFramerate = fromJsonValue(source["ReadAtNativeFramerate"]); - m_ignoreDts = fromJsonValue(source["IgnoreDts"]); - m_ignoreIndex = fromJsonValue(source["IgnoreIndex"]); - m_genPtsInput = fromJsonValue(source["GenPtsInput"]); - m_supportsTranscoding = fromJsonValue(source["SupportsTranscoding"]); - m_supportsDirectStream = fromJsonValue(source["SupportsDirectStream"]); - m_supportsDirectPlay = fromJsonValue(source["SupportsDirectPlay"]); - m_isInfiniteStream = fromJsonValue(source["IsInfiniteStream"]); - m_requiresOpening = fromJsonValue(source["RequiresOpening"]); - m_openToken = fromJsonValue(source["OpenToken"]); - m_requiresClosing = fromJsonValue(source["RequiresClosing"]); - m_liveStreamId = fromJsonValue(source["LiveStreamId"]); - m_bufferMs = fromJsonValue(source["BufferMs"]); - m_requiresLooping = fromJsonValue(source["RequiresLooping"]); - m_supportsProbing = fromJsonValue(source["SupportsProbing"]); - m_videoType = fromJsonValue(source["VideoType"]); - m_isoType = fromJsonValue(source["IsoType"]); - m_video3DFormat = fromJsonValue(source["Video3DFormat"]); - m_mediaStreams = fromJsonValue>>(source["MediaStreams"]); - m_mediaAttachments = fromJsonValue>>(source["MediaAttachments"]); - m_formats = fromJsonValue(source["Formats"]); - m_bitrate = fromJsonValue(source["Bitrate"]); - m_timestamp = fromJsonValue(source["Timestamp"]); - m_requiredHttpHeaders = fromJsonValue(source["RequiredHttpHeaders"]); - m_transcodingUrl = fromJsonValue(source["TranscodingUrl"]); - m_transcodingSubProtocol = fromJsonValue(source["TranscodingSubProtocol"]); - m_transcodingContainer = fromJsonValue(source["TranscodingContainer"]); - m_analyzeDurationMs = fromJsonValue(source["AnalyzeDurationMs"]); - m_defaultAudioStreamIndex = fromJsonValue(source["DefaultAudioStreamIndex"]); - m_defaultSubtitleStreamIndex = fromJsonValue(source["DefaultSubtitleStreamIndex"]); + m_protocol = Jellyfin::Support::fromJsonValue(source["Protocol"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); + m_path = Jellyfin::Support::fromJsonValue(source["Path"]); + m_encoderPath = Jellyfin::Support::fromJsonValue(source["EncoderPath"]); + m_encoderProtocol = Jellyfin::Support::fromJsonValue(source["EncoderProtocol"]); + m_type = Jellyfin::Support::fromJsonValue(source["Type"]); + m_container = Jellyfin::Support::fromJsonValue(source["Container"]); + m_size = Jellyfin::Support::fromJsonValue(source["Size"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_isRemote = Jellyfin::Support::fromJsonValue(source["IsRemote"]); + m_eTag = Jellyfin::Support::fromJsonValue(source["ETag"]); + m_runTimeTicks = Jellyfin::Support::fromJsonValue(source["RunTimeTicks"]); + m_readAtNativeFramerate = Jellyfin::Support::fromJsonValue(source["ReadAtNativeFramerate"]); + m_ignoreDts = Jellyfin::Support::fromJsonValue(source["IgnoreDts"]); + m_ignoreIndex = Jellyfin::Support::fromJsonValue(source["IgnoreIndex"]); + m_genPtsInput = Jellyfin::Support::fromJsonValue(source["GenPtsInput"]); + m_supportsTranscoding = Jellyfin::Support::fromJsonValue(source["SupportsTranscoding"]); + m_supportsDirectStream = Jellyfin::Support::fromJsonValue(source["SupportsDirectStream"]); + m_supportsDirectPlay = Jellyfin::Support::fromJsonValue(source["SupportsDirectPlay"]); + m_isInfiniteStream = Jellyfin::Support::fromJsonValue(source["IsInfiniteStream"]); + m_requiresOpening = Jellyfin::Support::fromJsonValue(source["RequiresOpening"]); + m_openToken = Jellyfin::Support::fromJsonValue(source["OpenToken"]); + m_requiresClosing = Jellyfin::Support::fromJsonValue(source["RequiresClosing"]); + m_liveStreamId = Jellyfin::Support::fromJsonValue(source["LiveStreamId"]); + m_bufferMs = Jellyfin::Support::fromJsonValue(source["BufferMs"]); + m_requiresLooping = Jellyfin::Support::fromJsonValue(source["RequiresLooping"]); + m_supportsProbing = Jellyfin::Support::fromJsonValue(source["SupportsProbing"]); + m_videoType = Jellyfin::Support::fromJsonValue(source["VideoType"]); + m_isoType = Jellyfin::Support::fromJsonValue(source["IsoType"]); + m_video3DFormat = Jellyfin::Support::fromJsonValue(source["Video3DFormat"]); + m_mediaStreams = Jellyfin::Support::fromJsonValue>>(source["MediaStreams"]); + m_mediaAttachments = Jellyfin::Support::fromJsonValue>>(source["MediaAttachments"]); + m_formats = Jellyfin::Support::fromJsonValue(source["Formats"]); + m_bitrate = Jellyfin::Support::fromJsonValue(source["Bitrate"]); + m_timestamp = Jellyfin::Support::fromJsonValue(source["Timestamp"]); + m_requiredHttpHeaders = Jellyfin::Support::fromJsonValue(source["RequiredHttpHeaders"]); + m_transcodingUrl = Jellyfin::Support::fromJsonValue(source["TranscodingUrl"]); + m_transcodingSubProtocol = Jellyfin::Support::fromJsonValue(source["TranscodingSubProtocol"]); + m_transcodingContainer = Jellyfin::Support::fromJsonValue(source["TranscodingContainer"]); + m_analyzeDurationMs = Jellyfin::Support::fromJsonValue(source["AnalyzeDurationMs"]); + m_defaultAudioStreamIndex = Jellyfin::Support::fromJsonValue(source["DefaultAudioStreamIndex"]); + m_defaultSubtitleStreamIndex = Jellyfin::Support::fromJsonValue(source["DefaultSubtitleStreamIndex"]); } QJsonObject MediaSourceInfo::toJson() { QJsonObject result; - result["Protocol"] = toJsonValue(m_protocol); - result["Id"] = toJsonValue(m_jellyfinId); - result["Path"] = toJsonValue(m_path); - result["EncoderPath"] = toJsonValue(m_encoderPath); - result["EncoderProtocol"] = toJsonValue(m_encoderProtocol); - result["Type"] = toJsonValue(m_type); - result["Container"] = toJsonValue(m_container); - result["Size"] = toJsonValue(m_size); - result["Name"] = toJsonValue(m_name); - result["IsRemote"] = toJsonValue(m_isRemote); - result["ETag"] = toJsonValue(m_eTag); - result["RunTimeTicks"] = toJsonValue(m_runTimeTicks); - result["ReadAtNativeFramerate"] = toJsonValue(m_readAtNativeFramerate); - result["IgnoreDts"] = toJsonValue(m_ignoreDts); - result["IgnoreIndex"] = toJsonValue(m_ignoreIndex); - result["GenPtsInput"] = toJsonValue(m_genPtsInput); - result["SupportsTranscoding"] = toJsonValue(m_supportsTranscoding); - result["SupportsDirectStream"] = toJsonValue(m_supportsDirectStream); - result["SupportsDirectPlay"] = toJsonValue(m_supportsDirectPlay); - result["IsInfiniteStream"] = toJsonValue(m_isInfiniteStream); - result["RequiresOpening"] = toJsonValue(m_requiresOpening); - result["OpenToken"] = toJsonValue(m_openToken); - result["RequiresClosing"] = toJsonValue(m_requiresClosing); - result["LiveStreamId"] = toJsonValue(m_liveStreamId); - result["BufferMs"] = toJsonValue(m_bufferMs); - result["RequiresLooping"] = toJsonValue(m_requiresLooping); - result["SupportsProbing"] = toJsonValue(m_supportsProbing); - result["VideoType"] = toJsonValue(m_videoType); - result["IsoType"] = toJsonValue(m_isoType); - result["Video3DFormat"] = toJsonValue(m_video3DFormat); - result["MediaStreams"] = toJsonValue>>(m_mediaStreams); - result["MediaAttachments"] = toJsonValue>>(m_mediaAttachments); - result["Formats"] = toJsonValue(m_formats); - result["Bitrate"] = toJsonValue(m_bitrate); - result["Timestamp"] = toJsonValue(m_timestamp); - result["RequiredHttpHeaders"] = toJsonValue(m_requiredHttpHeaders); - result["TranscodingUrl"] = toJsonValue(m_transcodingUrl); - result["TranscodingSubProtocol"] = toJsonValue(m_transcodingSubProtocol); - result["TranscodingContainer"] = toJsonValue(m_transcodingContainer); - result["AnalyzeDurationMs"] = toJsonValue(m_analyzeDurationMs); - result["DefaultAudioStreamIndex"] = toJsonValue(m_defaultAudioStreamIndex); - result["DefaultSubtitleStreamIndex"] = toJsonValue(m_defaultSubtitleStreamIndex); + result["Protocol"] = Jellyfin::Support::toJsonValue(m_protocol); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + result["EncoderPath"] = Jellyfin::Support::toJsonValue(m_encoderPath); + result["EncoderProtocol"] = Jellyfin::Support::toJsonValue(m_encoderProtocol); + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + result["Container"] = Jellyfin::Support::toJsonValue(m_container); + result["Size"] = Jellyfin::Support::toJsonValue(m_size); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["IsRemote"] = Jellyfin::Support::toJsonValue(m_isRemote); + result["ETag"] = Jellyfin::Support::toJsonValue(m_eTag); + result["RunTimeTicks"] = Jellyfin::Support::toJsonValue(m_runTimeTicks); + result["ReadAtNativeFramerate"] = Jellyfin::Support::toJsonValue(m_readAtNativeFramerate); + result["IgnoreDts"] = Jellyfin::Support::toJsonValue(m_ignoreDts); + result["IgnoreIndex"] = Jellyfin::Support::toJsonValue(m_ignoreIndex); + result["GenPtsInput"] = Jellyfin::Support::toJsonValue(m_genPtsInput); + result["SupportsTranscoding"] = Jellyfin::Support::toJsonValue(m_supportsTranscoding); + result["SupportsDirectStream"] = Jellyfin::Support::toJsonValue(m_supportsDirectStream); + result["SupportsDirectPlay"] = Jellyfin::Support::toJsonValue(m_supportsDirectPlay); + result["IsInfiniteStream"] = Jellyfin::Support::toJsonValue(m_isInfiniteStream); + result["RequiresOpening"] = Jellyfin::Support::toJsonValue(m_requiresOpening); + result["OpenToken"] = Jellyfin::Support::toJsonValue(m_openToken); + result["RequiresClosing"] = Jellyfin::Support::toJsonValue(m_requiresClosing); + result["LiveStreamId"] = Jellyfin::Support::toJsonValue(m_liveStreamId); + result["BufferMs"] = Jellyfin::Support::toJsonValue(m_bufferMs); + result["RequiresLooping"] = Jellyfin::Support::toJsonValue(m_requiresLooping); + result["SupportsProbing"] = Jellyfin::Support::toJsonValue(m_supportsProbing); + result["VideoType"] = Jellyfin::Support::toJsonValue(m_videoType); + result["IsoType"] = Jellyfin::Support::toJsonValue(m_isoType); + result["Video3DFormat"] = Jellyfin::Support::toJsonValue(m_video3DFormat); + result["MediaStreams"] = Jellyfin::Support::toJsonValue>>(m_mediaStreams); + result["MediaAttachments"] = Jellyfin::Support::toJsonValue>>(m_mediaAttachments); + result["Formats"] = Jellyfin::Support::toJsonValue(m_formats); + result["Bitrate"] = Jellyfin::Support::toJsonValue(m_bitrate); + result["Timestamp"] = Jellyfin::Support::toJsonValue(m_timestamp); + result["RequiredHttpHeaders"] = Jellyfin::Support::toJsonValue(m_requiredHttpHeaders); + result["TranscodingUrl"] = Jellyfin::Support::toJsonValue(m_transcodingUrl); + result["TranscodingSubProtocol"] = Jellyfin::Support::toJsonValue(m_transcodingSubProtocol); + result["TranscodingContainer"] = Jellyfin::Support::toJsonValue(m_transcodingContainer); + result["AnalyzeDurationMs"] = Jellyfin::Support::toJsonValue(m_analyzeDurationMs); + result["DefaultAudioStreamIndex"] = Jellyfin::Support::toJsonValue(m_defaultAudioStreamIndex); + result["DefaultSubtitleStreamIndex"] = Jellyfin::Support::toJsonValue(m_defaultSubtitleStreamIndex); return result; } @@ -345,6 +346,17 @@ void MediaSourceInfo::setDefaultSubtitleStreamIndex(qint32 newDefaultSubtitleStr m_defaultSubtitleStreamIndex = newDefaultSubtitleStreamIndex; } +} // NS DTO + +namespace Support { + +using MediaSourceInfo = Jellyfin::DTO::MediaSourceInfo; + +template <> +MediaSourceInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return MediaSourceInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/mediasourcetype.cpp b/core/src/DTO/mediasourcetype.cpp index 2cb1339..80f9857 100644 --- a/core/src/DTO/mediasourcetype.cpp +++ b/core/src/DTO/mediasourcetype.cpp @@ -34,5 +34,30 @@ namespace DTO { MediaSourceTypeClass::MediaSourceTypeClass() {} + +} // NS DTO + +namespace Support { + +using MediaSourceType = Jellyfin::DTO::MediaSourceType; + +template <> +MediaSourceType fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return MediaSourceType::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Default")) { + return MediaSourceType::Default; + } + if (str == QStringLiteral("Grouping")) { + return MediaSourceType::Grouping; + } + if (str == QStringLiteral("Placeholder")) { + return MediaSourceType::Placeholder; + } + + return MediaSourceType::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/mediastream.cpp b/core/src/DTO/mediastream.cpp index 9571ffd..44cb6f0 100644 --- a/core/src/DTO/mediastream.cpp +++ b/core/src/DTO/mediastream.cpp @@ -32,114 +32,115 @@ namespace Jellyfin { namespace DTO { -MediaStream::MediaStream(QObject *parent) {} +MediaStream::MediaStream() {} -MediaStream MediaStream::fromJson(QJsonObject source) {MediaStream instance; - instance->setFromJson(source, false); +MediaStream MediaStream::fromJson(QJsonObject source) { + MediaStream instance; + instance.setFromJson(source); return instance; } void MediaStream::setFromJson(QJsonObject source) { - m_codec = fromJsonValue(source["Codec"]); - m_codecTag = fromJsonValue(source["CodecTag"]); - m_language = fromJsonValue(source["Language"]); - m_colorRange = fromJsonValue(source["ColorRange"]); - m_colorSpace = fromJsonValue(source["ColorSpace"]); - m_colorTransfer = fromJsonValue(source["ColorTransfer"]); - m_colorPrimaries = fromJsonValue(source["ColorPrimaries"]); - m_comment = fromJsonValue(source["Comment"]); - m_timeBase = fromJsonValue(source["TimeBase"]); - m_codecTimeBase = fromJsonValue(source["CodecTimeBase"]); - m_title = fromJsonValue(source["Title"]); - m_videoRange = fromJsonValue(source["VideoRange"]); - m_localizedUndefined = fromJsonValue(source["localizedUndefined"]); - m_localizedDefault = fromJsonValue(source["localizedDefault"]); - m_localizedForced = fromJsonValue(source["localizedForced"]); - m_displayTitle = fromJsonValue(source["DisplayTitle"]); - m_nalLengthSize = fromJsonValue(source["NalLengthSize"]); - m_isInterlaced = fromJsonValue(source["IsInterlaced"]); - m_isAVC = fromJsonValue(source["IsAVC"]); - m_channelLayout = fromJsonValue(source["ChannelLayout"]); - m_bitRate = fromJsonValue(source["BitRate"]); - m_bitDepth = fromJsonValue(source["BitDepth"]); - m_refFrames = fromJsonValue(source["RefFrames"]); - m_packetLength = fromJsonValue(source["PacketLength"]); - m_channels = fromJsonValue(source["Channels"]); - m_sampleRate = fromJsonValue(source["SampleRate"]); - m_isDefault = fromJsonValue(source["IsDefault"]); - m_isForced = fromJsonValue(source["IsForced"]); - m_height = fromJsonValue(source["Height"]); - m_width = fromJsonValue(source["Width"]); - m_averageFrameRate = fromJsonValue(source["AverageFrameRate"]); - m_realFrameRate = fromJsonValue(source["RealFrameRate"]); - m_profile = fromJsonValue(source["Profile"]); - m_type = fromJsonValue(source["Type"]); - m_aspectRatio = fromJsonValue(source["AspectRatio"]); - m_index = fromJsonValue(source["Index"]); - m_score = fromJsonValue(source["Score"]); - m_isExternal = fromJsonValue(source["IsExternal"]); - m_deliveryMethod = fromJsonValue(source["DeliveryMethod"]); - m_deliveryUrl = fromJsonValue(source["DeliveryUrl"]); - m_isExternalUrl = fromJsonValue(source["IsExternalUrl"]); - m_isTextSubtitleStream = fromJsonValue(source["IsTextSubtitleStream"]); - m_supportsExternalStream = fromJsonValue(source["SupportsExternalStream"]); - m_path = fromJsonValue(source["Path"]); - m_pixelFormat = fromJsonValue(source["PixelFormat"]); - m_level = fromJsonValue(source["Level"]); - m_isAnamorphic = fromJsonValue(source["IsAnamorphic"]); + m_codec = Jellyfin::Support::fromJsonValue(source["Codec"]); + m_codecTag = Jellyfin::Support::fromJsonValue(source["CodecTag"]); + m_language = Jellyfin::Support::fromJsonValue(source["Language"]); + m_colorRange = Jellyfin::Support::fromJsonValue(source["ColorRange"]); + m_colorSpace = Jellyfin::Support::fromJsonValue(source["ColorSpace"]); + m_colorTransfer = Jellyfin::Support::fromJsonValue(source["ColorTransfer"]); + m_colorPrimaries = Jellyfin::Support::fromJsonValue(source["ColorPrimaries"]); + m_comment = Jellyfin::Support::fromJsonValue(source["Comment"]); + m_timeBase = Jellyfin::Support::fromJsonValue(source["TimeBase"]); + m_codecTimeBase = Jellyfin::Support::fromJsonValue(source["CodecTimeBase"]); + m_title = Jellyfin::Support::fromJsonValue(source["Title"]); + m_videoRange = Jellyfin::Support::fromJsonValue(source["VideoRange"]); + m_localizedUndefined = Jellyfin::Support::fromJsonValue(source["localizedUndefined"]); + m_localizedDefault = Jellyfin::Support::fromJsonValue(source["localizedDefault"]); + m_localizedForced = Jellyfin::Support::fromJsonValue(source["localizedForced"]); + m_displayTitle = Jellyfin::Support::fromJsonValue(source["DisplayTitle"]); + m_nalLengthSize = Jellyfin::Support::fromJsonValue(source["NalLengthSize"]); + m_isInterlaced = Jellyfin::Support::fromJsonValue(source["IsInterlaced"]); + m_isAVC = Jellyfin::Support::fromJsonValue(source["IsAVC"]); + m_channelLayout = Jellyfin::Support::fromJsonValue(source["ChannelLayout"]); + m_bitRate = Jellyfin::Support::fromJsonValue(source["BitRate"]); + m_bitDepth = Jellyfin::Support::fromJsonValue(source["BitDepth"]); + m_refFrames = Jellyfin::Support::fromJsonValue(source["RefFrames"]); + m_packetLength = Jellyfin::Support::fromJsonValue(source["PacketLength"]); + m_channels = Jellyfin::Support::fromJsonValue(source["Channels"]); + m_sampleRate = Jellyfin::Support::fromJsonValue(source["SampleRate"]); + m_isDefault = Jellyfin::Support::fromJsonValue(source["IsDefault"]); + m_isForced = Jellyfin::Support::fromJsonValue(source["IsForced"]); + m_height = Jellyfin::Support::fromJsonValue(source["Height"]); + m_width = Jellyfin::Support::fromJsonValue(source["Width"]); + m_averageFrameRate = Jellyfin::Support::fromJsonValue(source["AverageFrameRate"]); + m_realFrameRate = Jellyfin::Support::fromJsonValue(source["RealFrameRate"]); + m_profile = Jellyfin::Support::fromJsonValue(source["Profile"]); + m_type = Jellyfin::Support::fromJsonValue(source["Type"]); + m_aspectRatio = Jellyfin::Support::fromJsonValue(source["AspectRatio"]); + m_index = Jellyfin::Support::fromJsonValue(source["Index"]); + m_score = Jellyfin::Support::fromJsonValue(source["Score"]); + m_isExternal = Jellyfin::Support::fromJsonValue(source["IsExternal"]); + m_deliveryMethod = Jellyfin::Support::fromJsonValue(source["DeliveryMethod"]); + m_deliveryUrl = Jellyfin::Support::fromJsonValue(source["DeliveryUrl"]); + m_isExternalUrl = Jellyfin::Support::fromJsonValue(source["IsExternalUrl"]); + m_isTextSubtitleStream = Jellyfin::Support::fromJsonValue(source["IsTextSubtitleStream"]); + m_supportsExternalStream = Jellyfin::Support::fromJsonValue(source["SupportsExternalStream"]); + m_path = Jellyfin::Support::fromJsonValue(source["Path"]); + m_pixelFormat = Jellyfin::Support::fromJsonValue(source["PixelFormat"]); + m_level = Jellyfin::Support::fromJsonValue(source["Level"]); + m_isAnamorphic = Jellyfin::Support::fromJsonValue(source["IsAnamorphic"]); } QJsonObject MediaStream::toJson() { QJsonObject result; - result["Codec"] = toJsonValue(m_codec); - result["CodecTag"] = toJsonValue(m_codecTag); - result["Language"] = toJsonValue(m_language); - result["ColorRange"] = toJsonValue(m_colorRange); - result["ColorSpace"] = toJsonValue(m_colorSpace); - result["ColorTransfer"] = toJsonValue(m_colorTransfer); - result["ColorPrimaries"] = toJsonValue(m_colorPrimaries); - result["Comment"] = toJsonValue(m_comment); - result["TimeBase"] = toJsonValue(m_timeBase); - result["CodecTimeBase"] = toJsonValue(m_codecTimeBase); - result["Title"] = toJsonValue(m_title); - result["VideoRange"] = toJsonValue(m_videoRange); - result["localizedUndefined"] = toJsonValue(m_localizedUndefined); - result["localizedDefault"] = toJsonValue(m_localizedDefault); - result["localizedForced"] = toJsonValue(m_localizedForced); - result["DisplayTitle"] = toJsonValue(m_displayTitle); - result["NalLengthSize"] = toJsonValue(m_nalLengthSize); - result["IsInterlaced"] = toJsonValue(m_isInterlaced); - result["IsAVC"] = toJsonValue(m_isAVC); - result["ChannelLayout"] = toJsonValue(m_channelLayout); - result["BitRate"] = toJsonValue(m_bitRate); - result["BitDepth"] = toJsonValue(m_bitDepth); - result["RefFrames"] = toJsonValue(m_refFrames); - result["PacketLength"] = toJsonValue(m_packetLength); - result["Channels"] = toJsonValue(m_channels); - result["SampleRate"] = toJsonValue(m_sampleRate); - result["IsDefault"] = toJsonValue(m_isDefault); - result["IsForced"] = toJsonValue(m_isForced); - result["Height"] = toJsonValue(m_height); - result["Width"] = toJsonValue(m_width); - result["AverageFrameRate"] = toJsonValue(m_averageFrameRate); - result["RealFrameRate"] = toJsonValue(m_realFrameRate); - result["Profile"] = toJsonValue(m_profile); - result["Type"] = toJsonValue(m_type); - result["AspectRatio"] = toJsonValue(m_aspectRatio); - result["Index"] = toJsonValue(m_index); - result["Score"] = toJsonValue(m_score); - result["IsExternal"] = toJsonValue(m_isExternal); - result["DeliveryMethod"] = toJsonValue(m_deliveryMethod); - result["DeliveryUrl"] = toJsonValue(m_deliveryUrl); - result["IsExternalUrl"] = toJsonValue(m_isExternalUrl); - result["IsTextSubtitleStream"] = toJsonValue(m_isTextSubtitleStream); - result["SupportsExternalStream"] = toJsonValue(m_supportsExternalStream); - result["Path"] = toJsonValue(m_path); - result["PixelFormat"] = toJsonValue(m_pixelFormat); - result["Level"] = toJsonValue(m_level); - result["IsAnamorphic"] = toJsonValue(m_isAnamorphic); + result["Codec"] = Jellyfin::Support::toJsonValue(m_codec); + result["CodecTag"] = Jellyfin::Support::toJsonValue(m_codecTag); + result["Language"] = Jellyfin::Support::toJsonValue(m_language); + result["ColorRange"] = Jellyfin::Support::toJsonValue(m_colorRange); + result["ColorSpace"] = Jellyfin::Support::toJsonValue(m_colorSpace); + result["ColorTransfer"] = Jellyfin::Support::toJsonValue(m_colorTransfer); + result["ColorPrimaries"] = Jellyfin::Support::toJsonValue(m_colorPrimaries); + result["Comment"] = Jellyfin::Support::toJsonValue(m_comment); + result["TimeBase"] = Jellyfin::Support::toJsonValue(m_timeBase); + result["CodecTimeBase"] = Jellyfin::Support::toJsonValue(m_codecTimeBase); + result["Title"] = Jellyfin::Support::toJsonValue(m_title); + result["VideoRange"] = Jellyfin::Support::toJsonValue(m_videoRange); + result["localizedUndefined"] = Jellyfin::Support::toJsonValue(m_localizedUndefined); + result["localizedDefault"] = Jellyfin::Support::toJsonValue(m_localizedDefault); + result["localizedForced"] = Jellyfin::Support::toJsonValue(m_localizedForced); + result["DisplayTitle"] = Jellyfin::Support::toJsonValue(m_displayTitle); + result["NalLengthSize"] = Jellyfin::Support::toJsonValue(m_nalLengthSize); + result["IsInterlaced"] = Jellyfin::Support::toJsonValue(m_isInterlaced); + result["IsAVC"] = Jellyfin::Support::toJsonValue(m_isAVC); + result["ChannelLayout"] = Jellyfin::Support::toJsonValue(m_channelLayout); + result["BitRate"] = Jellyfin::Support::toJsonValue(m_bitRate); + result["BitDepth"] = Jellyfin::Support::toJsonValue(m_bitDepth); + result["RefFrames"] = Jellyfin::Support::toJsonValue(m_refFrames); + result["PacketLength"] = Jellyfin::Support::toJsonValue(m_packetLength); + result["Channels"] = Jellyfin::Support::toJsonValue(m_channels); + result["SampleRate"] = Jellyfin::Support::toJsonValue(m_sampleRate); + result["IsDefault"] = Jellyfin::Support::toJsonValue(m_isDefault); + result["IsForced"] = Jellyfin::Support::toJsonValue(m_isForced); + result["Height"] = Jellyfin::Support::toJsonValue(m_height); + result["Width"] = Jellyfin::Support::toJsonValue(m_width); + result["AverageFrameRate"] = Jellyfin::Support::toJsonValue(m_averageFrameRate); + result["RealFrameRate"] = Jellyfin::Support::toJsonValue(m_realFrameRate); + result["Profile"] = Jellyfin::Support::toJsonValue(m_profile); + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + result["AspectRatio"] = Jellyfin::Support::toJsonValue(m_aspectRatio); + result["Index"] = Jellyfin::Support::toJsonValue(m_index); + result["Score"] = Jellyfin::Support::toJsonValue(m_score); + result["IsExternal"] = Jellyfin::Support::toJsonValue(m_isExternal); + result["DeliveryMethod"] = Jellyfin::Support::toJsonValue(m_deliveryMethod); + result["DeliveryUrl"] = Jellyfin::Support::toJsonValue(m_deliveryUrl); + result["IsExternalUrl"] = Jellyfin::Support::toJsonValue(m_isExternalUrl); + result["IsTextSubtitleStream"] = Jellyfin::Support::toJsonValue(m_isTextSubtitleStream); + result["SupportsExternalStream"] = Jellyfin::Support::toJsonValue(m_supportsExternalStream); + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + result["PixelFormat"] = Jellyfin::Support::toJsonValue(m_pixelFormat); + result["Level"] = Jellyfin::Support::toJsonValue(m_level); + result["IsAnamorphic"] = Jellyfin::Support::toJsonValue(m_isAnamorphic); return result; } @@ -380,6 +381,17 @@ void MediaStream::setIsAnamorphic(bool newIsAnamorphic) { m_isAnamorphic = newIsAnamorphic; } +} // NS DTO + +namespace Support { + +using MediaStream = Jellyfin::DTO::MediaStream; + +template <> +MediaStream fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return MediaStream::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/mediastreamtype.cpp b/core/src/DTO/mediastreamtype.cpp index 0023f52..8741706 100644 --- a/core/src/DTO/mediastreamtype.cpp +++ b/core/src/DTO/mediastreamtype.cpp @@ -34,5 +34,33 @@ namespace DTO { MediaStreamTypeClass::MediaStreamTypeClass() {} + +} // NS DTO + +namespace Support { + +using MediaStreamType = Jellyfin::DTO::MediaStreamType; + +template <> +MediaStreamType fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return MediaStreamType::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Audio")) { + return MediaStreamType::Audio; + } + if (str == QStringLiteral("Video")) { + return MediaStreamType::Video; + } + if (str == QStringLiteral("Subtitle")) { + return MediaStreamType::Subtitle; + } + if (str == QStringLiteral("EmbeddedImage")) { + return MediaStreamType::EmbeddedImage; + } + + return MediaStreamType::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/mediaupdateinfodto.cpp b/core/src/DTO/mediaupdateinfodto.cpp index c0f0cab..048ebdf 100644 --- a/core/src/DTO/mediaupdateinfodto.cpp +++ b/core/src/DTO/mediaupdateinfodto.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -MediaUpdateInfoDto::MediaUpdateInfoDto(QObject *parent) {} +MediaUpdateInfoDto::MediaUpdateInfoDto() {} -MediaUpdateInfoDto MediaUpdateInfoDto::fromJson(QJsonObject source) {MediaUpdateInfoDto instance; - instance->setFromJson(source, false); +MediaUpdateInfoDto MediaUpdateInfoDto::fromJson(QJsonObject source) { + MediaUpdateInfoDto instance; + instance.setFromJson(source); return instance; } void MediaUpdateInfoDto::setFromJson(QJsonObject source) { - m_path = fromJsonValue(source["Path"]); - m_updateType = fromJsonValue(source["UpdateType"]); + m_path = Jellyfin::Support::fromJsonValue(source["Path"]); + m_updateType = Jellyfin::Support::fromJsonValue(source["UpdateType"]); } QJsonObject MediaUpdateInfoDto::toJson() { QJsonObject result; - result["Path"] = toJsonValue(m_path); - result["UpdateType"] = toJsonValue(m_updateType); + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + result["UpdateType"] = Jellyfin::Support::toJsonValue(m_updateType); return result; } @@ -65,6 +66,17 @@ void MediaUpdateInfoDto::setUpdateType(QString newUpdateType) { m_updateType = newUpdateType; } +} // NS DTO + +namespace Support { + +using MediaUpdateInfoDto = Jellyfin::DTO::MediaUpdateInfoDto; + +template <> +MediaUpdateInfoDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return MediaUpdateInfoDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/mediaurl.cpp b/core/src/DTO/mediaurl.cpp index 3f67bf6..d269d29 100644 --- a/core/src/DTO/mediaurl.cpp +++ b/core/src/DTO/mediaurl.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -MediaUrl::MediaUrl(QObject *parent) {} +MediaUrl::MediaUrl() {} -MediaUrl MediaUrl::fromJson(QJsonObject source) {MediaUrl instance; - instance->setFromJson(source, false); +MediaUrl MediaUrl::fromJson(QJsonObject source) { + MediaUrl instance; + instance.setFromJson(source); return instance; } void MediaUrl::setFromJson(QJsonObject source) { - m_url = fromJsonValue(source["Url"]); - m_name = fromJsonValue(source["Name"]); + m_url = Jellyfin::Support::fromJsonValue(source["Url"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); } QJsonObject MediaUrl::toJson() { QJsonObject result; - result["Url"] = toJsonValue(m_url); - result["Name"] = toJsonValue(m_name); + result["Url"] = Jellyfin::Support::toJsonValue(m_url); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); return result; } @@ -65,6 +66,17 @@ void MediaUrl::setName(QString newName) { m_name = newName; } +} // NS DTO + +namespace Support { + +using MediaUrl = Jellyfin::DTO::MediaUrl; + +template <> +MediaUrl fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return MediaUrl::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/metadataeditorinfo.cpp b/core/src/DTO/metadataeditorinfo.cpp index 5789d66..69aeb43 100644 --- a/core/src/DTO/metadataeditorinfo.cpp +++ b/core/src/DTO/metadataeditorinfo.cpp @@ -32,32 +32,33 @@ namespace Jellyfin { namespace DTO { -MetadataEditorInfo::MetadataEditorInfo(QObject *parent) {} +MetadataEditorInfo::MetadataEditorInfo() {} -MetadataEditorInfo MetadataEditorInfo::fromJson(QJsonObject source) {MetadataEditorInfo instance; - instance->setFromJson(source, false); +MetadataEditorInfo MetadataEditorInfo::fromJson(QJsonObject source) { + MetadataEditorInfo instance; + instance.setFromJson(source); return instance; } void MetadataEditorInfo::setFromJson(QJsonObject source) { - m_parentalRatingOptions = fromJsonValue>>(source["ParentalRatingOptions"]); - m_countries = fromJsonValue>>(source["Countries"]); - m_cultures = fromJsonValue>>(source["Cultures"]); - m_externalIdInfos = fromJsonValue>>(source["ExternalIdInfos"]); - m_contentType = fromJsonValue(source["ContentType"]); - m_contentTypeOptions = fromJsonValue>>(source["ContentTypeOptions"]); + m_parentalRatingOptions = Jellyfin::Support::fromJsonValue>>(source["ParentalRatingOptions"]); + m_countries = Jellyfin::Support::fromJsonValue>>(source["Countries"]); + m_cultures = Jellyfin::Support::fromJsonValue>>(source["Cultures"]); + m_externalIdInfos = Jellyfin::Support::fromJsonValue>>(source["ExternalIdInfos"]); + m_contentType = Jellyfin::Support::fromJsonValue(source["ContentType"]); + m_contentTypeOptions = Jellyfin::Support::fromJsonValue>>(source["ContentTypeOptions"]); } QJsonObject MetadataEditorInfo::toJson() { QJsonObject result; - result["ParentalRatingOptions"] = toJsonValue>>(m_parentalRatingOptions); - result["Countries"] = toJsonValue>>(m_countries); - result["Cultures"] = toJsonValue>>(m_cultures); - result["ExternalIdInfos"] = toJsonValue>>(m_externalIdInfos); - result["ContentType"] = toJsonValue(m_contentType); - result["ContentTypeOptions"] = toJsonValue>>(m_contentTypeOptions); + result["ParentalRatingOptions"] = Jellyfin::Support::toJsonValue>>(m_parentalRatingOptions); + result["Countries"] = Jellyfin::Support::toJsonValue>>(m_countries); + result["Cultures"] = Jellyfin::Support::toJsonValue>>(m_cultures); + result["ExternalIdInfos"] = Jellyfin::Support::toJsonValue>>(m_externalIdInfos); + result["ContentType"] = Jellyfin::Support::toJsonValue(m_contentType); + result["ContentTypeOptions"] = Jellyfin::Support::toJsonValue>>(m_contentTypeOptions); return result; } @@ -93,6 +94,17 @@ void MetadataEditorInfo::setContentTypeOptions(QList +MetadataEditorInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return MetadataEditorInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/metadatafield.cpp b/core/src/DTO/metadatafield.cpp index da1802a..680c63b 100644 --- a/core/src/DTO/metadatafield.cpp +++ b/core/src/DTO/metadatafield.cpp @@ -34,5 +34,48 @@ namespace DTO { MetadataFieldClass::MetadataFieldClass() {} + +} // NS DTO + +namespace Support { + +using MetadataField = Jellyfin::DTO::MetadataField; + +template <> +MetadataField fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return MetadataField::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Cast")) { + return MetadataField::Cast; + } + if (str == QStringLiteral("Genres")) { + return MetadataField::Genres; + } + if (str == QStringLiteral("ProductionLocations")) { + return MetadataField::ProductionLocations; + } + if (str == QStringLiteral("Studios")) { + return MetadataField::Studios; + } + if (str == QStringLiteral("Tags")) { + return MetadataField::Tags; + } + if (str == QStringLiteral("Name")) { + return MetadataField::Name; + } + if (str == QStringLiteral("Overview")) { + return MetadataField::Overview; + } + if (str == QStringLiteral("Runtime")) { + return MetadataField::Runtime; + } + if (str == QStringLiteral("OfficialRating")) { + return MetadataField::OfficialRating; + } + + return MetadataField::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/metadataoptions.cpp b/core/src/DTO/metadataoptions.cpp index 20e4909..cc27370 100644 --- a/core/src/DTO/metadataoptions.cpp +++ b/core/src/DTO/metadataoptions.cpp @@ -32,34 +32,35 @@ namespace Jellyfin { namespace DTO { -MetadataOptions::MetadataOptions(QObject *parent) {} +MetadataOptions::MetadataOptions() {} -MetadataOptions MetadataOptions::fromJson(QJsonObject source) {MetadataOptions instance; - instance->setFromJson(source, false); +MetadataOptions MetadataOptions::fromJson(QJsonObject source) { + MetadataOptions instance; + instance.setFromJson(source); return instance; } void MetadataOptions::setFromJson(QJsonObject source) { - m_itemType = fromJsonValue(source["ItemType"]); - m_disabledMetadataSavers = fromJsonValue(source["DisabledMetadataSavers"]); - m_localMetadataReaderOrder = fromJsonValue(source["LocalMetadataReaderOrder"]); - m_disabledMetadataFetchers = fromJsonValue(source["DisabledMetadataFetchers"]); - m_metadataFetcherOrder = fromJsonValue(source["MetadataFetcherOrder"]); - m_disabledImageFetchers = fromJsonValue(source["DisabledImageFetchers"]); - m_imageFetcherOrder = fromJsonValue(source["ImageFetcherOrder"]); + m_itemType = Jellyfin::Support::fromJsonValue(source["ItemType"]); + m_disabledMetadataSavers = Jellyfin::Support::fromJsonValue(source["DisabledMetadataSavers"]); + m_localMetadataReaderOrder = Jellyfin::Support::fromJsonValue(source["LocalMetadataReaderOrder"]); + m_disabledMetadataFetchers = Jellyfin::Support::fromJsonValue(source["DisabledMetadataFetchers"]); + m_metadataFetcherOrder = Jellyfin::Support::fromJsonValue(source["MetadataFetcherOrder"]); + m_disabledImageFetchers = Jellyfin::Support::fromJsonValue(source["DisabledImageFetchers"]); + m_imageFetcherOrder = Jellyfin::Support::fromJsonValue(source["ImageFetcherOrder"]); } QJsonObject MetadataOptions::toJson() { QJsonObject result; - result["ItemType"] = toJsonValue(m_itemType); - result["DisabledMetadataSavers"] = toJsonValue(m_disabledMetadataSavers); - result["LocalMetadataReaderOrder"] = toJsonValue(m_localMetadataReaderOrder); - result["DisabledMetadataFetchers"] = toJsonValue(m_disabledMetadataFetchers); - result["MetadataFetcherOrder"] = toJsonValue(m_metadataFetcherOrder); - result["DisabledImageFetchers"] = toJsonValue(m_disabledImageFetchers); - result["ImageFetcherOrder"] = toJsonValue(m_imageFetcherOrder); + result["ItemType"] = Jellyfin::Support::toJsonValue(m_itemType); + result["DisabledMetadataSavers"] = Jellyfin::Support::toJsonValue(m_disabledMetadataSavers); + result["LocalMetadataReaderOrder"] = Jellyfin::Support::toJsonValue(m_localMetadataReaderOrder); + result["DisabledMetadataFetchers"] = Jellyfin::Support::toJsonValue(m_disabledMetadataFetchers); + result["MetadataFetcherOrder"] = Jellyfin::Support::toJsonValue(m_metadataFetcherOrder); + result["DisabledImageFetchers"] = Jellyfin::Support::toJsonValue(m_disabledImageFetchers); + result["ImageFetcherOrder"] = Jellyfin::Support::toJsonValue(m_imageFetcherOrder); return result; } @@ -100,6 +101,17 @@ void MetadataOptions::setImageFetcherOrder(QStringList newImageFetcherOrder) { m_imageFetcherOrder = newImageFetcherOrder; } +} // NS DTO + +namespace Support { + +using MetadataOptions = Jellyfin::DTO::MetadataOptions; + +template <> +MetadataOptions fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return MetadataOptions::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/metadatarefreshmode.cpp b/core/src/DTO/metadatarefreshmode.cpp index 7ff3398..a3ce175 100644 --- a/core/src/DTO/metadatarefreshmode.cpp +++ b/core/src/DTO/metadatarefreshmode.cpp @@ -34,5 +34,33 @@ namespace DTO { MetadataRefreshModeClass::MetadataRefreshModeClass() {} + +} // NS DTO + +namespace Support { + +using MetadataRefreshMode = Jellyfin::DTO::MetadataRefreshMode; + +template <> +MetadataRefreshMode fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return MetadataRefreshMode::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("None")) { + return MetadataRefreshMode::None; + } + if (str == QStringLiteral("ValidationOnly")) { + return MetadataRefreshMode::ValidationOnly; + } + if (str == QStringLiteral("Default")) { + return MetadataRefreshMode::Default; + } + if (str == QStringLiteral("FullRefresh")) { + return MetadataRefreshMode::FullRefresh; + } + + return MetadataRefreshMode::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/moveplaylistitemrequestdto.cpp b/core/src/DTO/moveplaylistitemrequestdto.cpp index b58bda4..52f01f6 100644 --- a/core/src/DTO/moveplaylistitemrequestdto.cpp +++ b/core/src/DTO/moveplaylistitemrequestdto.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -MovePlaylistItemRequestDto::MovePlaylistItemRequestDto(QObject *parent) {} +MovePlaylistItemRequestDto::MovePlaylistItemRequestDto() {} -MovePlaylistItemRequestDto MovePlaylistItemRequestDto::fromJson(QJsonObject source) {MovePlaylistItemRequestDto instance; - instance->setFromJson(source, false); +MovePlaylistItemRequestDto MovePlaylistItemRequestDto::fromJson(QJsonObject source) { + MovePlaylistItemRequestDto instance; + instance.setFromJson(source); return instance; } void MovePlaylistItemRequestDto::setFromJson(QJsonObject source) { - m_playlistItemId = fromJsonValue(source["PlaylistItemId"]); - m_newIndex = fromJsonValue(source["NewIndex"]); + m_playlistItemId = Jellyfin::Support::fromJsonValue(source["PlaylistItemId"]); + m_newIndex = Jellyfin::Support::fromJsonValue(source["NewIndex"]); } QJsonObject MovePlaylistItemRequestDto::toJson() { QJsonObject result; - result["PlaylistItemId"] = toJsonValue(m_playlistItemId); - result["NewIndex"] = toJsonValue(m_newIndex); + result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); + result["NewIndex"] = Jellyfin::Support::toJsonValue(m_newIndex); return result; } @@ -65,6 +66,17 @@ void MovePlaylistItemRequestDto::setNewIndex(qint32 newNewIndex) { m_newIndex = newNewIndex; } +} // NS DTO + +namespace Support { + +using MovePlaylistItemRequestDto = Jellyfin::DTO::MovePlaylistItemRequestDto; + +template <> +MovePlaylistItemRequestDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return MovePlaylistItemRequestDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/movieinfo.cpp b/core/src/DTO/movieinfo.cpp index 52ebed7..88eefe5 100644 --- a/core/src/DTO/movieinfo.cpp +++ b/core/src/DTO/movieinfo.cpp @@ -32,40 +32,41 @@ namespace Jellyfin { namespace DTO { -MovieInfo::MovieInfo(QObject *parent) {} +MovieInfo::MovieInfo() {} -MovieInfo MovieInfo::fromJson(QJsonObject source) {MovieInfo instance; - instance->setFromJson(source, false); +MovieInfo MovieInfo::fromJson(QJsonObject source) { + MovieInfo instance; + instance.setFromJson(source); return instance; } void MovieInfo::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_path = fromJsonValue(source["Path"]); - m_metadataLanguage = fromJsonValue(source["MetadataLanguage"]); - m_metadataCountryCode = fromJsonValue(source["MetadataCountryCode"]); - m_providerIds = fromJsonValue(source["ProviderIds"]); - m_year = fromJsonValue(source["Year"]); - m_indexNumber = fromJsonValue(source["IndexNumber"]); - m_parentIndexNumber = fromJsonValue(source["ParentIndexNumber"]); - m_premiereDate = fromJsonValue(source["PremiereDate"]); - m_isAutomated = fromJsonValue(source["IsAutomated"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_path = Jellyfin::Support::fromJsonValue(source["Path"]); + m_metadataLanguage = Jellyfin::Support::fromJsonValue(source["MetadataLanguage"]); + m_metadataCountryCode = Jellyfin::Support::fromJsonValue(source["MetadataCountryCode"]); + m_providerIds = Jellyfin::Support::fromJsonValue(source["ProviderIds"]); + m_year = Jellyfin::Support::fromJsonValue(source["Year"]); + m_indexNumber = Jellyfin::Support::fromJsonValue(source["IndexNumber"]); + m_parentIndexNumber = Jellyfin::Support::fromJsonValue(source["ParentIndexNumber"]); + m_premiereDate = Jellyfin::Support::fromJsonValue(source["PremiereDate"]); + m_isAutomated = Jellyfin::Support::fromJsonValue(source["IsAutomated"]); } QJsonObject MovieInfo::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Path"] = toJsonValue(m_path); - result["MetadataLanguage"] = toJsonValue(m_metadataLanguage); - result["MetadataCountryCode"] = toJsonValue(m_metadataCountryCode); - result["ProviderIds"] = toJsonValue(m_providerIds); - result["Year"] = toJsonValue(m_year); - result["IndexNumber"] = toJsonValue(m_indexNumber); - result["ParentIndexNumber"] = toJsonValue(m_parentIndexNumber); - result["PremiereDate"] = toJsonValue(m_premiereDate); - result["IsAutomated"] = toJsonValue(m_isAutomated); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); + result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); + result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); + result["Year"] = Jellyfin::Support::toJsonValue(m_year); + result["IndexNumber"] = Jellyfin::Support::toJsonValue(m_indexNumber); + result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue(m_parentIndexNumber); + result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); + result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); return result; } @@ -121,6 +122,17 @@ void MovieInfo::setIsAutomated(bool newIsAutomated) { m_isAutomated = newIsAutomated; } +} // NS DTO + +namespace Support { + +using MovieInfo = Jellyfin::DTO::MovieInfo; + +template <> +MovieInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return MovieInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/movieinforemotesearchquery.cpp b/core/src/DTO/movieinforemotesearchquery.cpp index 2ab6ef5..a8d96f3 100644 --- a/core/src/DTO/movieinforemotesearchquery.cpp +++ b/core/src/DTO/movieinforemotesearchquery.cpp @@ -32,28 +32,29 @@ namespace Jellyfin { namespace DTO { -MovieInfoRemoteSearchQuery::MovieInfoRemoteSearchQuery(QObject *parent) {} +MovieInfoRemoteSearchQuery::MovieInfoRemoteSearchQuery() {} -MovieInfoRemoteSearchQuery MovieInfoRemoteSearchQuery::fromJson(QJsonObject source) {MovieInfoRemoteSearchQuery instance; - instance->setFromJson(source, false); +MovieInfoRemoteSearchQuery MovieInfoRemoteSearchQuery::fromJson(QJsonObject source) { + MovieInfoRemoteSearchQuery instance; + instance.setFromJson(source); return instance; } void MovieInfoRemoteSearchQuery::setFromJson(QJsonObject source) { - m_searchInfo = fromJsonValue>(source["SearchInfo"]); - m_itemId = fromJsonValue(source["ItemId"]); - m_searchProviderName = fromJsonValue(source["SearchProviderName"]); - m_includeDisabledProviders = fromJsonValue(source["IncludeDisabledProviders"]); + m_searchInfo = Jellyfin::Support::fromJsonValue>(source["SearchInfo"]); + m_itemId = Jellyfin::Support::fromJsonValue(source["ItemId"]); + m_searchProviderName = Jellyfin::Support::fromJsonValue(source["SearchProviderName"]); + m_includeDisabledProviders = Jellyfin::Support::fromJsonValue(source["IncludeDisabledProviders"]); } QJsonObject MovieInfoRemoteSearchQuery::toJson() { QJsonObject result; - result["SearchInfo"] = toJsonValue>(m_searchInfo); - result["ItemId"] = toJsonValue(m_itemId); - result["SearchProviderName"] = toJsonValue(m_searchProviderName); - result["IncludeDisabledProviders"] = toJsonValue(m_includeDisabledProviders); + result["SearchInfo"] = Jellyfin::Support::toJsonValue>(m_searchInfo); + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); + result["IncludeDisabledProviders"] = Jellyfin::Support::toJsonValue(m_includeDisabledProviders); return result; } @@ -79,6 +80,17 @@ void MovieInfoRemoteSearchQuery::setIncludeDisabledProviders(bool newIncludeDisa m_includeDisabledProviders = newIncludeDisabledProviders; } +} // NS DTO + +namespace Support { + +using MovieInfoRemoteSearchQuery = Jellyfin::DTO::MovieInfoRemoteSearchQuery; + +template <> +MovieInfoRemoteSearchQuery fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return MovieInfoRemoteSearchQuery::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/musicvideoinfo.cpp b/core/src/DTO/musicvideoinfo.cpp index 06e768b..7b2eb70 100644 --- a/core/src/DTO/musicvideoinfo.cpp +++ b/core/src/DTO/musicvideoinfo.cpp @@ -32,42 +32,43 @@ namespace Jellyfin { namespace DTO { -MusicVideoInfo::MusicVideoInfo(QObject *parent) {} +MusicVideoInfo::MusicVideoInfo() {} -MusicVideoInfo MusicVideoInfo::fromJson(QJsonObject source) {MusicVideoInfo instance; - instance->setFromJson(source, false); +MusicVideoInfo MusicVideoInfo::fromJson(QJsonObject source) { + MusicVideoInfo instance; + instance.setFromJson(source); return instance; } void MusicVideoInfo::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_path = fromJsonValue(source["Path"]); - m_metadataLanguage = fromJsonValue(source["MetadataLanguage"]); - m_metadataCountryCode = fromJsonValue(source["MetadataCountryCode"]); - m_providerIds = fromJsonValue(source["ProviderIds"]); - m_year = fromJsonValue(source["Year"]); - m_indexNumber = fromJsonValue(source["IndexNumber"]); - m_parentIndexNumber = fromJsonValue(source["ParentIndexNumber"]); - m_premiereDate = fromJsonValue(source["PremiereDate"]); - m_isAutomated = fromJsonValue(source["IsAutomated"]); - m_artists = fromJsonValue(source["Artists"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_path = Jellyfin::Support::fromJsonValue(source["Path"]); + m_metadataLanguage = Jellyfin::Support::fromJsonValue(source["MetadataLanguage"]); + m_metadataCountryCode = Jellyfin::Support::fromJsonValue(source["MetadataCountryCode"]); + m_providerIds = Jellyfin::Support::fromJsonValue(source["ProviderIds"]); + m_year = Jellyfin::Support::fromJsonValue(source["Year"]); + m_indexNumber = Jellyfin::Support::fromJsonValue(source["IndexNumber"]); + m_parentIndexNumber = Jellyfin::Support::fromJsonValue(source["ParentIndexNumber"]); + m_premiereDate = Jellyfin::Support::fromJsonValue(source["PremiereDate"]); + m_isAutomated = Jellyfin::Support::fromJsonValue(source["IsAutomated"]); + m_artists = Jellyfin::Support::fromJsonValue(source["Artists"]); } QJsonObject MusicVideoInfo::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Path"] = toJsonValue(m_path); - result["MetadataLanguage"] = toJsonValue(m_metadataLanguage); - result["MetadataCountryCode"] = toJsonValue(m_metadataCountryCode); - result["ProviderIds"] = toJsonValue(m_providerIds); - result["Year"] = toJsonValue(m_year); - result["IndexNumber"] = toJsonValue(m_indexNumber); - result["ParentIndexNumber"] = toJsonValue(m_parentIndexNumber); - result["PremiereDate"] = toJsonValue(m_premiereDate); - result["IsAutomated"] = toJsonValue(m_isAutomated); - result["Artists"] = toJsonValue(m_artists); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); + result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); + result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); + result["Year"] = Jellyfin::Support::toJsonValue(m_year); + result["IndexNumber"] = Jellyfin::Support::toJsonValue(m_indexNumber); + result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue(m_parentIndexNumber); + result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); + result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); + result["Artists"] = Jellyfin::Support::toJsonValue(m_artists); return result; } @@ -128,6 +129,17 @@ void MusicVideoInfo::setArtists(QStringList newArtists) { m_artists = newArtists; } +} // NS DTO + +namespace Support { + +using MusicVideoInfo = Jellyfin::DTO::MusicVideoInfo; + +template <> +MusicVideoInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return MusicVideoInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/musicvideoinforemotesearchquery.cpp b/core/src/DTO/musicvideoinforemotesearchquery.cpp index a5c4dd9..d1c8b9d 100644 --- a/core/src/DTO/musicvideoinforemotesearchquery.cpp +++ b/core/src/DTO/musicvideoinforemotesearchquery.cpp @@ -32,28 +32,29 @@ namespace Jellyfin { namespace DTO { -MusicVideoInfoRemoteSearchQuery::MusicVideoInfoRemoteSearchQuery(QObject *parent) {} +MusicVideoInfoRemoteSearchQuery::MusicVideoInfoRemoteSearchQuery() {} -MusicVideoInfoRemoteSearchQuery MusicVideoInfoRemoteSearchQuery::fromJson(QJsonObject source) {MusicVideoInfoRemoteSearchQuery instance; - instance->setFromJson(source, false); +MusicVideoInfoRemoteSearchQuery MusicVideoInfoRemoteSearchQuery::fromJson(QJsonObject source) { + MusicVideoInfoRemoteSearchQuery instance; + instance.setFromJson(source); return instance; } void MusicVideoInfoRemoteSearchQuery::setFromJson(QJsonObject source) { - m_searchInfo = fromJsonValue>(source["SearchInfo"]); - m_itemId = fromJsonValue(source["ItemId"]); - m_searchProviderName = fromJsonValue(source["SearchProviderName"]); - m_includeDisabledProviders = fromJsonValue(source["IncludeDisabledProviders"]); + m_searchInfo = Jellyfin::Support::fromJsonValue>(source["SearchInfo"]); + m_itemId = Jellyfin::Support::fromJsonValue(source["ItemId"]); + m_searchProviderName = Jellyfin::Support::fromJsonValue(source["SearchProviderName"]); + m_includeDisabledProviders = Jellyfin::Support::fromJsonValue(source["IncludeDisabledProviders"]); } QJsonObject MusicVideoInfoRemoteSearchQuery::toJson() { QJsonObject result; - result["SearchInfo"] = toJsonValue>(m_searchInfo); - result["ItemId"] = toJsonValue(m_itemId); - result["SearchProviderName"] = toJsonValue(m_searchProviderName); - result["IncludeDisabledProviders"] = toJsonValue(m_includeDisabledProviders); + result["SearchInfo"] = Jellyfin::Support::toJsonValue>(m_searchInfo); + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); + result["IncludeDisabledProviders"] = Jellyfin::Support::toJsonValue(m_includeDisabledProviders); return result; } @@ -79,6 +80,17 @@ void MusicVideoInfoRemoteSearchQuery::setIncludeDisabledProviders(bool newInclud m_includeDisabledProviders = newIncludeDisabledProviders; } +} // NS DTO + +namespace Support { + +using MusicVideoInfoRemoteSearchQuery = Jellyfin::DTO::MusicVideoInfoRemoteSearchQuery; + +template <> +MusicVideoInfoRemoteSearchQuery fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return MusicVideoInfoRemoteSearchQuery::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/nameguidpair.cpp b/core/src/DTO/nameguidpair.cpp index 7cc7c2c..60dcfee 100644 --- a/core/src/DTO/nameguidpair.cpp +++ b/core/src/DTO/nameguidpair.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -NameGuidPair::NameGuidPair(QObject *parent) {} +NameGuidPair::NameGuidPair() {} -NameGuidPair NameGuidPair::fromJson(QJsonObject source) {NameGuidPair instance; - instance->setFromJson(source, false); +NameGuidPair NameGuidPair::fromJson(QJsonObject source) { + NameGuidPair instance; + instance.setFromJson(source); return instance; } void NameGuidPair::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_jellyfinId = fromJsonValue(source["Id"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); } QJsonObject NameGuidPair::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Id"] = toJsonValue(m_jellyfinId); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); return result; } @@ -65,6 +66,17 @@ void NameGuidPair::setJellyfinId(QUuid newJellyfinId) { m_jellyfinId = newJellyfinId; } +} // NS DTO + +namespace Support { + +using NameGuidPair = Jellyfin::DTO::NameGuidPair; + +template <> +NameGuidPair fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return NameGuidPair::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/nameidpair.cpp b/core/src/DTO/nameidpair.cpp index 3d33962..3700bc4 100644 --- a/core/src/DTO/nameidpair.cpp +++ b/core/src/DTO/nameidpair.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -NameIdPair::NameIdPair(QObject *parent) {} +NameIdPair::NameIdPair() {} -NameIdPair NameIdPair::fromJson(QJsonObject source) {NameIdPair instance; - instance->setFromJson(source, false); +NameIdPair NameIdPair::fromJson(QJsonObject source) { + NameIdPair instance; + instance.setFromJson(source); return instance; } void NameIdPair::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_jellyfinId = fromJsonValue(source["Id"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); } QJsonObject NameIdPair::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Id"] = toJsonValue(m_jellyfinId); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); return result; } @@ -65,6 +66,17 @@ void NameIdPair::setJellyfinId(QString newJellyfinId) { m_jellyfinId = newJellyfinId; } +} // NS DTO + +namespace Support { + +using NameIdPair = Jellyfin::DTO::NameIdPair; + +template <> +NameIdPair fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return NameIdPair::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/namevaluepair.cpp b/core/src/DTO/namevaluepair.cpp index e3c99a0..afb2809 100644 --- a/core/src/DTO/namevaluepair.cpp +++ b/core/src/DTO/namevaluepair.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -NameValuePair::NameValuePair(QObject *parent) {} +NameValuePair::NameValuePair() {} -NameValuePair NameValuePair::fromJson(QJsonObject source) {NameValuePair instance; - instance->setFromJson(source, false); +NameValuePair NameValuePair::fromJson(QJsonObject source) { + NameValuePair instance; + instance.setFromJson(source); return instance; } void NameValuePair::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_value = fromJsonValue(source["Value"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_value = Jellyfin::Support::fromJsonValue(source["Value"]); } QJsonObject NameValuePair::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Value"] = toJsonValue(m_value); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Value"] = Jellyfin::Support::toJsonValue(m_value); return result; } @@ -65,6 +66,17 @@ void NameValuePair::setValue(QString newValue) { m_value = newValue; } +} // NS DTO + +namespace Support { + +using NameValuePair = Jellyfin::DTO::NameValuePair; + +template <> +NameValuePair fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return NameValuePair::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/newgrouprequestdto.cpp b/core/src/DTO/newgrouprequestdto.cpp index 10f2260..06545ae 100644 --- a/core/src/DTO/newgrouprequestdto.cpp +++ b/core/src/DTO/newgrouprequestdto.cpp @@ -32,22 +32,23 @@ namespace Jellyfin { namespace DTO { -NewGroupRequestDto::NewGroupRequestDto(QObject *parent) {} +NewGroupRequestDto::NewGroupRequestDto() {} -NewGroupRequestDto NewGroupRequestDto::fromJson(QJsonObject source) {NewGroupRequestDto instance; - instance->setFromJson(source, false); +NewGroupRequestDto NewGroupRequestDto::fromJson(QJsonObject source) { + NewGroupRequestDto instance; + instance.setFromJson(source); return instance; } void NewGroupRequestDto::setFromJson(QJsonObject source) { - m_groupName = fromJsonValue(source["GroupName"]); + m_groupName = Jellyfin::Support::fromJsonValue(source["GroupName"]); } QJsonObject NewGroupRequestDto::toJson() { QJsonObject result; - result["GroupName"] = toJsonValue(m_groupName); + result["GroupName"] = Jellyfin::Support::toJsonValue(m_groupName); return result; } @@ -58,6 +59,17 @@ void NewGroupRequestDto::setGroupName(QString newGroupName) { m_groupName = newGroupName; } +} // NS DTO + +namespace Support { + +using NewGroupRequestDto = Jellyfin::DTO::NewGroupRequestDto; + +template <> +NewGroupRequestDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return NewGroupRequestDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/nextitemrequestdto.cpp b/core/src/DTO/nextitemrequestdto.cpp index 0534e18..0ab7052 100644 --- a/core/src/DTO/nextitemrequestdto.cpp +++ b/core/src/DTO/nextitemrequestdto.cpp @@ -32,22 +32,23 @@ namespace Jellyfin { namespace DTO { -NextItemRequestDto::NextItemRequestDto(QObject *parent) {} +NextItemRequestDto::NextItemRequestDto() {} -NextItemRequestDto NextItemRequestDto::fromJson(QJsonObject source) {NextItemRequestDto instance; - instance->setFromJson(source, false); +NextItemRequestDto NextItemRequestDto::fromJson(QJsonObject source) { + NextItemRequestDto instance; + instance.setFromJson(source); return instance; } void NextItemRequestDto::setFromJson(QJsonObject source) { - m_playlistItemId = fromJsonValue(source["PlaylistItemId"]); + m_playlistItemId = Jellyfin::Support::fromJsonValue(source["PlaylistItemId"]); } QJsonObject NextItemRequestDto::toJson() { QJsonObject result; - result["PlaylistItemId"] = toJsonValue(m_playlistItemId); + result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); return result; } @@ -58,6 +59,17 @@ void NextItemRequestDto::setPlaylistItemId(QUuid newPlaylistItemId) { m_playlistItemId = newPlaylistItemId; } +} // NS DTO + +namespace Support { + +using NextItemRequestDto = Jellyfin::DTO::NextItemRequestDto; + +template <> +NextItemRequestDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return NextItemRequestDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/notificationdto.cpp b/core/src/DTO/notificationdto.cpp index 5715156..55dea6d 100644 --- a/core/src/DTO/notificationdto.cpp +++ b/core/src/DTO/notificationdto.cpp @@ -32,36 +32,37 @@ namespace Jellyfin { namespace DTO { -NotificationDto::NotificationDto(QObject *parent) {} +NotificationDto::NotificationDto() {} -NotificationDto NotificationDto::fromJson(QJsonObject source) {NotificationDto instance; - instance->setFromJson(source, false); +NotificationDto NotificationDto::fromJson(QJsonObject source) { + NotificationDto instance; + instance.setFromJson(source); return instance; } void NotificationDto::setFromJson(QJsonObject source) { - m_jellyfinId = fromJsonValue(source["Id"]); - m_userId = fromJsonValue(source["UserId"]); - m_date = fromJsonValue(source["Date"]); - m_isRead = fromJsonValue(source["IsRead"]); - m_name = fromJsonValue(source["Name"]); - m_description = fromJsonValue(source["Description"]); - m_url = fromJsonValue(source["Url"]); - m_level = fromJsonValue(source["Level"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); + m_userId = Jellyfin::Support::fromJsonValue(source["UserId"]); + m_date = Jellyfin::Support::fromJsonValue(source["Date"]); + m_isRead = Jellyfin::Support::fromJsonValue(source["IsRead"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_description = Jellyfin::Support::fromJsonValue(source["Description"]); + m_url = Jellyfin::Support::fromJsonValue(source["Url"]); + m_level = Jellyfin::Support::fromJsonValue(source["Level"]); } QJsonObject NotificationDto::toJson() { QJsonObject result; - result["Id"] = toJsonValue(m_jellyfinId); - result["UserId"] = toJsonValue(m_userId); - result["Date"] = toJsonValue(m_date); - result["IsRead"] = toJsonValue(m_isRead); - result["Name"] = toJsonValue(m_name); - result["Description"] = toJsonValue(m_description); - result["Url"] = toJsonValue(m_url); - result["Level"] = toJsonValue(m_level); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); + result["Date"] = Jellyfin::Support::toJsonValue(m_date); + result["IsRead"] = Jellyfin::Support::toJsonValue(m_isRead); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Description"] = Jellyfin::Support::toJsonValue(m_description); + result["Url"] = Jellyfin::Support::toJsonValue(m_url); + result["Level"] = Jellyfin::Support::toJsonValue(m_level); return result; } @@ -107,6 +108,17 @@ void NotificationDto::setLevel(NotificationLevel newLevel) { m_level = newLevel; } +} // NS DTO + +namespace Support { + +using NotificationDto = Jellyfin::DTO::NotificationDto; + +template <> +NotificationDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return NotificationDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/notificationlevel.cpp b/core/src/DTO/notificationlevel.cpp index 3506efa..1294708 100644 --- a/core/src/DTO/notificationlevel.cpp +++ b/core/src/DTO/notificationlevel.cpp @@ -34,5 +34,30 @@ namespace DTO { NotificationLevelClass::NotificationLevelClass() {} + +} // NS DTO + +namespace Support { + +using NotificationLevel = Jellyfin::DTO::NotificationLevel; + +template <> +NotificationLevel fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return NotificationLevel::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Normal")) { + return NotificationLevel::Normal; + } + if (str == QStringLiteral("Warning")) { + return NotificationLevel::Warning; + } + if (str == QStringLiteral("Error")) { + return NotificationLevel::Error; + } + + return NotificationLevel::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/notificationresultdto.cpp b/core/src/DTO/notificationresultdto.cpp index 36c14fe..f32401a 100644 --- a/core/src/DTO/notificationresultdto.cpp +++ b/core/src/DTO/notificationresultdto.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -NotificationResultDto::NotificationResultDto(QObject *parent) {} +NotificationResultDto::NotificationResultDto() {} -NotificationResultDto NotificationResultDto::fromJson(QJsonObject source) {NotificationResultDto instance; - instance->setFromJson(source, false); +NotificationResultDto NotificationResultDto::fromJson(QJsonObject source) { + NotificationResultDto instance; + instance.setFromJson(source); return instance; } void NotificationResultDto::setFromJson(QJsonObject source) { - m_notifications = fromJsonValue>>(source["Notifications"]); - m_totalRecordCount = fromJsonValue(source["TotalRecordCount"]); + m_notifications = Jellyfin::Support::fromJsonValue>>(source["Notifications"]); + m_totalRecordCount = Jellyfin::Support::fromJsonValue(source["TotalRecordCount"]); } QJsonObject NotificationResultDto::toJson() { QJsonObject result; - result["Notifications"] = toJsonValue>>(m_notifications); - result["TotalRecordCount"] = toJsonValue(m_totalRecordCount); + result["Notifications"] = Jellyfin::Support::toJsonValue>>(m_notifications); + result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); return result; } @@ -65,6 +66,17 @@ void NotificationResultDto::setTotalRecordCount(qint32 newTotalRecordCount) { m_totalRecordCount = newTotalRecordCount; } +} // NS DTO + +namespace Support { + +using NotificationResultDto = Jellyfin::DTO::NotificationResultDto; + +template <> +NotificationResultDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return NotificationResultDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/notificationssummarydto.cpp b/core/src/DTO/notificationssummarydto.cpp index 9943bfc..dfa0ea6 100644 --- a/core/src/DTO/notificationssummarydto.cpp +++ b/core/src/DTO/notificationssummarydto.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -NotificationsSummaryDto::NotificationsSummaryDto(QObject *parent) {} +NotificationsSummaryDto::NotificationsSummaryDto() {} -NotificationsSummaryDto NotificationsSummaryDto::fromJson(QJsonObject source) {NotificationsSummaryDto instance; - instance->setFromJson(source, false); +NotificationsSummaryDto NotificationsSummaryDto::fromJson(QJsonObject source) { + NotificationsSummaryDto instance; + instance.setFromJson(source); return instance; } void NotificationsSummaryDto::setFromJson(QJsonObject source) { - m_unreadCount = fromJsonValue(source["UnreadCount"]); - m_maxUnreadNotificationLevel = fromJsonValue(source["MaxUnreadNotificationLevel"]); + m_unreadCount = Jellyfin::Support::fromJsonValue(source["UnreadCount"]); + m_maxUnreadNotificationLevel = Jellyfin::Support::fromJsonValue(source["MaxUnreadNotificationLevel"]); } QJsonObject NotificationsSummaryDto::toJson() { QJsonObject result; - result["UnreadCount"] = toJsonValue(m_unreadCount); - result["MaxUnreadNotificationLevel"] = toJsonValue(m_maxUnreadNotificationLevel); + result["UnreadCount"] = Jellyfin::Support::toJsonValue(m_unreadCount); + result["MaxUnreadNotificationLevel"] = Jellyfin::Support::toJsonValue(m_maxUnreadNotificationLevel); return result; } @@ -65,6 +66,17 @@ void NotificationsSummaryDto::setMaxUnreadNotificationLevel(NotificationLevel ne m_maxUnreadNotificationLevel = newMaxUnreadNotificationLevel; } +} // NS DTO + +namespace Support { + +using NotificationsSummaryDto = Jellyfin::DTO::NotificationsSummaryDto; + +template <> +NotificationsSummaryDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return NotificationsSummaryDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/notificationtypeinfo.cpp b/core/src/DTO/notificationtypeinfo.cpp index 38eebef..18575a9 100644 --- a/core/src/DTO/notificationtypeinfo.cpp +++ b/core/src/DTO/notificationtypeinfo.cpp @@ -32,30 +32,31 @@ namespace Jellyfin { namespace DTO { -NotificationTypeInfo::NotificationTypeInfo(QObject *parent) {} +NotificationTypeInfo::NotificationTypeInfo() {} -NotificationTypeInfo NotificationTypeInfo::fromJson(QJsonObject source) {NotificationTypeInfo instance; - instance->setFromJson(source, false); +NotificationTypeInfo NotificationTypeInfo::fromJson(QJsonObject source) { + NotificationTypeInfo instance; + instance.setFromJson(source); return instance; } void NotificationTypeInfo::setFromJson(QJsonObject source) { - m_type = fromJsonValue(source["Type"]); - m_name = fromJsonValue(source["Name"]); - m_enabled = fromJsonValue(source["Enabled"]); - m_category = fromJsonValue(source["Category"]); - m_isBasedOnUserEvent = fromJsonValue(source["IsBasedOnUserEvent"]); + m_type = Jellyfin::Support::fromJsonValue(source["Type"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_enabled = Jellyfin::Support::fromJsonValue(source["Enabled"]); + m_category = Jellyfin::Support::fromJsonValue(source["Category"]); + m_isBasedOnUserEvent = Jellyfin::Support::fromJsonValue(source["IsBasedOnUserEvent"]); } QJsonObject NotificationTypeInfo::toJson() { QJsonObject result; - result["Type"] = toJsonValue(m_type); - result["Name"] = toJsonValue(m_name); - result["Enabled"] = toJsonValue(m_enabled); - result["Category"] = toJsonValue(m_category); - result["IsBasedOnUserEvent"] = toJsonValue(m_isBasedOnUserEvent); + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Enabled"] = Jellyfin::Support::toJsonValue(m_enabled); + result["Category"] = Jellyfin::Support::toJsonValue(m_category); + result["IsBasedOnUserEvent"] = Jellyfin::Support::toJsonValue(m_isBasedOnUserEvent); return result; } @@ -86,6 +87,17 @@ void NotificationTypeInfo::setIsBasedOnUserEvent(bool newIsBasedOnUserEvent) { m_isBasedOnUserEvent = newIsBasedOnUserEvent; } +} // NS DTO + +namespace Support { + +using NotificationTypeInfo = Jellyfin::DTO::NotificationTypeInfo; + +template <> +NotificationTypeInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return NotificationTypeInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/objectgroupupdate.cpp b/core/src/DTO/objectgroupupdate.cpp index ed95dff..12008ad 100644 --- a/core/src/DTO/objectgroupupdate.cpp +++ b/core/src/DTO/objectgroupupdate.cpp @@ -32,26 +32,27 @@ namespace Jellyfin { namespace DTO { -ObjectGroupUpdate::ObjectGroupUpdate(QObject *parent) {} +ObjectGroupUpdate::ObjectGroupUpdate() {} -ObjectGroupUpdate ObjectGroupUpdate::fromJson(QJsonObject source) {ObjectGroupUpdate instance; - instance->setFromJson(source, false); +ObjectGroupUpdate ObjectGroupUpdate::fromJson(QJsonObject source) { + ObjectGroupUpdate instance; + instance.setFromJson(source); return instance; } void ObjectGroupUpdate::setFromJson(QJsonObject source) { - m_groupId = fromJsonValue(source["GroupId"]); - m_type = fromJsonValue(source["Type"]); - m_data = fromJsonValue(source["Data"]); + m_groupId = Jellyfin::Support::fromJsonValue(source["GroupId"]); + m_type = Jellyfin::Support::fromJsonValue(source["Type"]); + m_data = Jellyfin::Support::fromJsonValue(source["Data"]); } QJsonObject ObjectGroupUpdate::toJson() { QJsonObject result; - result["GroupId"] = toJsonValue(m_groupId); - result["Type"] = toJsonValue(m_type); - result["Data"] = toJsonValue(m_data); + result["GroupId"] = Jellyfin::Support::toJsonValue(m_groupId); + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + result["Data"] = Jellyfin::Support::toJsonValue(m_data); return result; } @@ -72,6 +73,17 @@ void ObjectGroupUpdate::setData(QVariant newData) { m_data = newData; } +} // NS DTO + +namespace Support { + +using ObjectGroupUpdate = Jellyfin::DTO::ObjectGroupUpdate; + +template <> +ObjectGroupUpdate fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ObjectGroupUpdate::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/openlivestreamdto.cpp b/core/src/DTO/openlivestreamdto.cpp index 4ffda7c..a4cc48d 100644 --- a/core/src/DTO/openlivestreamdto.cpp +++ b/core/src/DTO/openlivestreamdto.cpp @@ -32,46 +32,47 @@ namespace Jellyfin { namespace DTO { -OpenLiveStreamDto::OpenLiveStreamDto(QObject *parent) {} +OpenLiveStreamDto::OpenLiveStreamDto() {} -OpenLiveStreamDto OpenLiveStreamDto::fromJson(QJsonObject source) {OpenLiveStreamDto instance; - instance->setFromJson(source, false); +OpenLiveStreamDto OpenLiveStreamDto::fromJson(QJsonObject source) { + OpenLiveStreamDto instance; + instance.setFromJson(source); return instance; } void OpenLiveStreamDto::setFromJson(QJsonObject source) { - m_openToken = fromJsonValue(source["OpenToken"]); - m_userId = fromJsonValue(source["UserId"]); - m_playSessionId = fromJsonValue(source["PlaySessionId"]); - m_maxStreamingBitrate = fromJsonValue(source["MaxStreamingBitrate"]); - m_startTimeTicks = fromJsonValue(source["StartTimeTicks"]); - m_audioStreamIndex = fromJsonValue(source["AudioStreamIndex"]); - m_subtitleStreamIndex = fromJsonValue(source["SubtitleStreamIndex"]); - m_maxAudioChannels = fromJsonValue(source["MaxAudioChannels"]); - m_itemId = fromJsonValue(source["ItemId"]); - m_enableDirectPlay = fromJsonValue(source["EnableDirectPlay"]); - m_enableDirectStream = fromJsonValue(source["EnableDirectStream"]); - m_deviceProfile = fromJsonValue>(source["DeviceProfile"]); - m_directPlayProtocols = fromJsonValue>(source["DirectPlayProtocols"]); + m_openToken = Jellyfin::Support::fromJsonValue(source["OpenToken"]); + m_userId = Jellyfin::Support::fromJsonValue(source["UserId"]); + m_playSessionId = Jellyfin::Support::fromJsonValue(source["PlaySessionId"]); + m_maxStreamingBitrate = Jellyfin::Support::fromJsonValue(source["MaxStreamingBitrate"]); + m_startTimeTicks = Jellyfin::Support::fromJsonValue(source["StartTimeTicks"]); + m_audioStreamIndex = Jellyfin::Support::fromJsonValue(source["AudioStreamIndex"]); + m_subtitleStreamIndex = Jellyfin::Support::fromJsonValue(source["SubtitleStreamIndex"]); + m_maxAudioChannels = Jellyfin::Support::fromJsonValue(source["MaxAudioChannels"]); + m_itemId = Jellyfin::Support::fromJsonValue(source["ItemId"]); + m_enableDirectPlay = Jellyfin::Support::fromJsonValue(source["EnableDirectPlay"]); + m_enableDirectStream = Jellyfin::Support::fromJsonValue(source["EnableDirectStream"]); + m_deviceProfile = Jellyfin::Support::fromJsonValue>(source["DeviceProfile"]); + m_directPlayProtocols = Jellyfin::Support::fromJsonValue>(source["DirectPlayProtocols"]); } QJsonObject OpenLiveStreamDto::toJson() { QJsonObject result; - result["OpenToken"] = toJsonValue(m_openToken); - result["UserId"] = toJsonValue(m_userId); - result["PlaySessionId"] = toJsonValue(m_playSessionId); - result["MaxStreamingBitrate"] = toJsonValue(m_maxStreamingBitrate); - result["StartTimeTicks"] = toJsonValue(m_startTimeTicks); - result["AudioStreamIndex"] = toJsonValue(m_audioStreamIndex); - result["SubtitleStreamIndex"] = toJsonValue(m_subtitleStreamIndex); - result["MaxAudioChannels"] = toJsonValue(m_maxAudioChannels); - result["ItemId"] = toJsonValue(m_itemId); - result["EnableDirectPlay"] = toJsonValue(m_enableDirectPlay); - result["EnableDirectStream"] = toJsonValue(m_enableDirectStream); - result["DeviceProfile"] = toJsonValue>(m_deviceProfile); - result["DirectPlayProtocols"] = toJsonValue>(m_directPlayProtocols); + result["OpenToken"] = Jellyfin::Support::toJsonValue(m_openToken); + result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); + result["PlaySessionId"] = Jellyfin::Support::toJsonValue(m_playSessionId); + result["MaxStreamingBitrate"] = Jellyfin::Support::toJsonValue(m_maxStreamingBitrate); + result["StartTimeTicks"] = Jellyfin::Support::toJsonValue(m_startTimeTicks); + result["AudioStreamIndex"] = Jellyfin::Support::toJsonValue(m_audioStreamIndex); + result["SubtitleStreamIndex"] = Jellyfin::Support::toJsonValue(m_subtitleStreamIndex); + result["MaxAudioChannels"] = Jellyfin::Support::toJsonValue(m_maxAudioChannels); + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + result["EnableDirectPlay"] = Jellyfin::Support::toJsonValue(m_enableDirectPlay); + result["EnableDirectStream"] = Jellyfin::Support::toJsonValue(m_enableDirectStream); + result["DeviceProfile"] = Jellyfin::Support::toJsonValue>(m_deviceProfile); + result["DirectPlayProtocols"] = Jellyfin::Support::toJsonValue>(m_directPlayProtocols); return result; } @@ -142,6 +143,17 @@ void OpenLiveStreamDto::setDirectPlayProtocols(QList newDirectPla m_directPlayProtocols = newDirectPlayProtocols; } +} // NS DTO + +namespace Support { + +using OpenLiveStreamDto = Jellyfin::DTO::OpenLiveStreamDto; + +template <> +OpenLiveStreamDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return OpenLiveStreamDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/packageinfo.cpp b/core/src/DTO/packageinfo.cpp index fa38ef5..85abded 100644 --- a/core/src/DTO/packageinfo.cpp +++ b/core/src/DTO/packageinfo.cpp @@ -32,36 +32,37 @@ namespace Jellyfin { namespace DTO { -PackageInfo::PackageInfo(QObject *parent) {} +PackageInfo::PackageInfo() {} -PackageInfo PackageInfo::fromJson(QJsonObject source) {PackageInfo instance; - instance->setFromJson(source, false); +PackageInfo PackageInfo::fromJson(QJsonObject source) { + PackageInfo instance; + instance.setFromJson(source); return instance; } void PackageInfo::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["name"]); - m_description = fromJsonValue(source["description"]); - m_overview = fromJsonValue(source["overview"]); - m_owner = fromJsonValue(source["owner"]); - m_category = fromJsonValue(source["category"]); - m_guid = fromJsonValue(source["guid"]); - m_versions = fromJsonValue>>(source["versions"]); - m_imageUrl = fromJsonValue(source["imageUrl"]); + m_name = Jellyfin::Support::fromJsonValue(source["name"]); + m_description = Jellyfin::Support::fromJsonValue(source["description"]); + m_overview = Jellyfin::Support::fromJsonValue(source["overview"]); + m_owner = Jellyfin::Support::fromJsonValue(source["owner"]); + m_category = Jellyfin::Support::fromJsonValue(source["category"]); + m_guid = Jellyfin::Support::fromJsonValue(source["guid"]); + m_versions = Jellyfin::Support::fromJsonValue>>(source["versions"]); + m_imageUrl = Jellyfin::Support::fromJsonValue(source["imageUrl"]); } QJsonObject PackageInfo::toJson() { QJsonObject result; - result["name"] = toJsonValue(m_name); - result["description"] = toJsonValue(m_description); - result["overview"] = toJsonValue(m_overview); - result["owner"] = toJsonValue(m_owner); - result["category"] = toJsonValue(m_category); - result["guid"] = toJsonValue(m_guid); - result["versions"] = toJsonValue>>(m_versions); - result["imageUrl"] = toJsonValue(m_imageUrl); + result["name"] = Jellyfin::Support::toJsonValue(m_name); + result["description"] = Jellyfin::Support::toJsonValue(m_description); + result["overview"] = Jellyfin::Support::toJsonValue(m_overview); + result["owner"] = Jellyfin::Support::toJsonValue(m_owner); + result["category"] = Jellyfin::Support::toJsonValue(m_category); + result["guid"] = Jellyfin::Support::toJsonValue(m_guid); + result["versions"] = Jellyfin::Support::toJsonValue>>(m_versions); + result["imageUrl"] = Jellyfin::Support::toJsonValue(m_imageUrl); return result; } @@ -107,6 +108,17 @@ void PackageInfo::setImageUrl(QString newImageUrl) { m_imageUrl = newImageUrl; } +} // NS DTO + +namespace Support { + +using PackageInfo = Jellyfin::DTO::PackageInfo; + +template <> +PackageInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return PackageInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/parentalrating.cpp b/core/src/DTO/parentalrating.cpp index 39f1c40..7bd42ee 100644 --- a/core/src/DTO/parentalrating.cpp +++ b/core/src/DTO/parentalrating.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -ParentalRating::ParentalRating(QObject *parent) {} +ParentalRating::ParentalRating() {} -ParentalRating ParentalRating::fromJson(QJsonObject source) {ParentalRating instance; - instance->setFromJson(source, false); +ParentalRating ParentalRating::fromJson(QJsonObject source) { + ParentalRating instance; + instance.setFromJson(source); return instance; } void ParentalRating::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_value = fromJsonValue(source["Value"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_value = Jellyfin::Support::fromJsonValue(source["Value"]); } QJsonObject ParentalRating::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Value"] = toJsonValue(m_value); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Value"] = Jellyfin::Support::toJsonValue(m_value); return result; } @@ -65,6 +66,17 @@ void ParentalRating::setValue(qint32 newValue) { m_value = newValue; } +} // NS DTO + +namespace Support { + +using ParentalRating = Jellyfin::DTO::ParentalRating; + +template <> +ParentalRating fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ParentalRating::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/pathsubstitution.cpp b/core/src/DTO/pathsubstitution.cpp index 980fe46..43b5fa1 100644 --- a/core/src/DTO/pathsubstitution.cpp +++ b/core/src/DTO/pathsubstitution.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -PathSubstitution::PathSubstitution(QObject *parent) {} +PathSubstitution::PathSubstitution() {} -PathSubstitution PathSubstitution::fromJson(QJsonObject source) {PathSubstitution instance; - instance->setFromJson(source, false); +PathSubstitution PathSubstitution::fromJson(QJsonObject source) { + PathSubstitution instance; + instance.setFromJson(source); return instance; } void PathSubstitution::setFromJson(QJsonObject source) { - m_from = fromJsonValue(source["From"]); - m_to = fromJsonValue(source["To"]); + m_from = Jellyfin::Support::fromJsonValue(source["From"]); + m_to = Jellyfin::Support::fromJsonValue(source["To"]); } QJsonObject PathSubstitution::toJson() { QJsonObject result; - result["From"] = toJsonValue(m_from); - result["To"] = toJsonValue(m_to); + result["From"] = Jellyfin::Support::toJsonValue(m_from); + result["To"] = Jellyfin::Support::toJsonValue(m_to); return result; } @@ -65,6 +66,17 @@ void PathSubstitution::setTo(QString newTo) { m_to = newTo; } +} // NS DTO + +namespace Support { + +using PathSubstitution = Jellyfin::DTO::PathSubstitution; + +template <> +PathSubstitution fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return PathSubstitution::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/personlookupinfo.cpp b/core/src/DTO/personlookupinfo.cpp index 98df859..05ba83d 100644 --- a/core/src/DTO/personlookupinfo.cpp +++ b/core/src/DTO/personlookupinfo.cpp @@ -32,40 +32,41 @@ namespace Jellyfin { namespace DTO { -PersonLookupInfo::PersonLookupInfo(QObject *parent) {} +PersonLookupInfo::PersonLookupInfo() {} -PersonLookupInfo PersonLookupInfo::fromJson(QJsonObject source) {PersonLookupInfo instance; - instance->setFromJson(source, false); +PersonLookupInfo PersonLookupInfo::fromJson(QJsonObject source) { + PersonLookupInfo instance; + instance.setFromJson(source); return instance; } void PersonLookupInfo::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_path = fromJsonValue(source["Path"]); - m_metadataLanguage = fromJsonValue(source["MetadataLanguage"]); - m_metadataCountryCode = fromJsonValue(source["MetadataCountryCode"]); - m_providerIds = fromJsonValue(source["ProviderIds"]); - m_year = fromJsonValue(source["Year"]); - m_indexNumber = fromJsonValue(source["IndexNumber"]); - m_parentIndexNumber = fromJsonValue(source["ParentIndexNumber"]); - m_premiereDate = fromJsonValue(source["PremiereDate"]); - m_isAutomated = fromJsonValue(source["IsAutomated"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_path = Jellyfin::Support::fromJsonValue(source["Path"]); + m_metadataLanguage = Jellyfin::Support::fromJsonValue(source["MetadataLanguage"]); + m_metadataCountryCode = Jellyfin::Support::fromJsonValue(source["MetadataCountryCode"]); + m_providerIds = Jellyfin::Support::fromJsonValue(source["ProviderIds"]); + m_year = Jellyfin::Support::fromJsonValue(source["Year"]); + m_indexNumber = Jellyfin::Support::fromJsonValue(source["IndexNumber"]); + m_parentIndexNumber = Jellyfin::Support::fromJsonValue(source["ParentIndexNumber"]); + m_premiereDate = Jellyfin::Support::fromJsonValue(source["PremiereDate"]); + m_isAutomated = Jellyfin::Support::fromJsonValue(source["IsAutomated"]); } QJsonObject PersonLookupInfo::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Path"] = toJsonValue(m_path); - result["MetadataLanguage"] = toJsonValue(m_metadataLanguage); - result["MetadataCountryCode"] = toJsonValue(m_metadataCountryCode); - result["ProviderIds"] = toJsonValue(m_providerIds); - result["Year"] = toJsonValue(m_year); - result["IndexNumber"] = toJsonValue(m_indexNumber); - result["ParentIndexNumber"] = toJsonValue(m_parentIndexNumber); - result["PremiereDate"] = toJsonValue(m_premiereDate); - result["IsAutomated"] = toJsonValue(m_isAutomated); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); + result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); + result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); + result["Year"] = Jellyfin::Support::toJsonValue(m_year); + result["IndexNumber"] = Jellyfin::Support::toJsonValue(m_indexNumber); + result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue(m_parentIndexNumber); + result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); + result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); return result; } @@ -121,6 +122,17 @@ void PersonLookupInfo::setIsAutomated(bool newIsAutomated) { m_isAutomated = newIsAutomated; } +} // NS DTO + +namespace Support { + +using PersonLookupInfo = Jellyfin::DTO::PersonLookupInfo; + +template <> +PersonLookupInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return PersonLookupInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/personlookupinforemotesearchquery.cpp b/core/src/DTO/personlookupinforemotesearchquery.cpp index 9aadefd..8d1b4d1 100644 --- a/core/src/DTO/personlookupinforemotesearchquery.cpp +++ b/core/src/DTO/personlookupinforemotesearchquery.cpp @@ -32,28 +32,29 @@ namespace Jellyfin { namespace DTO { -PersonLookupInfoRemoteSearchQuery::PersonLookupInfoRemoteSearchQuery(QObject *parent) {} +PersonLookupInfoRemoteSearchQuery::PersonLookupInfoRemoteSearchQuery() {} -PersonLookupInfoRemoteSearchQuery PersonLookupInfoRemoteSearchQuery::fromJson(QJsonObject source) {PersonLookupInfoRemoteSearchQuery instance; - instance->setFromJson(source, false); +PersonLookupInfoRemoteSearchQuery PersonLookupInfoRemoteSearchQuery::fromJson(QJsonObject source) { + PersonLookupInfoRemoteSearchQuery instance; + instance.setFromJson(source); return instance; } void PersonLookupInfoRemoteSearchQuery::setFromJson(QJsonObject source) { - m_searchInfo = fromJsonValue>(source["SearchInfo"]); - m_itemId = fromJsonValue(source["ItemId"]); - m_searchProviderName = fromJsonValue(source["SearchProviderName"]); - m_includeDisabledProviders = fromJsonValue(source["IncludeDisabledProviders"]); + m_searchInfo = Jellyfin::Support::fromJsonValue>(source["SearchInfo"]); + m_itemId = Jellyfin::Support::fromJsonValue(source["ItemId"]); + m_searchProviderName = Jellyfin::Support::fromJsonValue(source["SearchProviderName"]); + m_includeDisabledProviders = Jellyfin::Support::fromJsonValue(source["IncludeDisabledProviders"]); } QJsonObject PersonLookupInfoRemoteSearchQuery::toJson() { QJsonObject result; - result["SearchInfo"] = toJsonValue>(m_searchInfo); - result["ItemId"] = toJsonValue(m_itemId); - result["SearchProviderName"] = toJsonValue(m_searchProviderName); - result["IncludeDisabledProviders"] = toJsonValue(m_includeDisabledProviders); + result["SearchInfo"] = Jellyfin::Support::toJsonValue>(m_searchInfo); + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); + result["IncludeDisabledProviders"] = Jellyfin::Support::toJsonValue(m_includeDisabledProviders); return result; } @@ -79,6 +80,17 @@ void PersonLookupInfoRemoteSearchQuery::setIncludeDisabledProviders(bool newIncl m_includeDisabledProviders = newIncludeDisabledProviders; } +} // NS DTO + +namespace Support { + +using PersonLookupInfoRemoteSearchQuery = Jellyfin::DTO::PersonLookupInfoRemoteSearchQuery; + +template <> +PersonLookupInfoRemoteSearchQuery fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return PersonLookupInfoRemoteSearchQuery::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/pingrequestdto.cpp b/core/src/DTO/pingrequestdto.cpp index 9c9610c..1554284 100644 --- a/core/src/DTO/pingrequestdto.cpp +++ b/core/src/DTO/pingrequestdto.cpp @@ -32,22 +32,23 @@ namespace Jellyfin { namespace DTO { -PingRequestDto::PingRequestDto(QObject *parent) {} +PingRequestDto::PingRequestDto() {} -PingRequestDto PingRequestDto::fromJson(QJsonObject source) {PingRequestDto instance; - instance->setFromJson(source, false); +PingRequestDto PingRequestDto::fromJson(QJsonObject source) { + PingRequestDto instance; + instance.setFromJson(source); return instance; } void PingRequestDto::setFromJson(QJsonObject source) { - m_ping = fromJsonValue(source["Ping"]); + m_ping = Jellyfin::Support::fromJsonValue(source["Ping"]); } QJsonObject PingRequestDto::toJson() { QJsonObject result; - result["Ping"] = toJsonValue(m_ping); + result["Ping"] = Jellyfin::Support::toJsonValue(m_ping); return result; } @@ -58,6 +59,17 @@ void PingRequestDto::setPing(qint64 newPing) { m_ping = newPing; } +} // NS DTO + +namespace Support { + +using PingRequestDto = Jellyfin::DTO::PingRequestDto; + +template <> +PingRequestDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return PingRequestDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/pinredeemresult.cpp b/core/src/DTO/pinredeemresult.cpp index 350eea0..2eacef5 100644 --- a/core/src/DTO/pinredeemresult.cpp +++ b/core/src/DTO/pinredeemresult.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -PinRedeemResult::PinRedeemResult(QObject *parent) {} +PinRedeemResult::PinRedeemResult() {} -PinRedeemResult PinRedeemResult::fromJson(QJsonObject source) {PinRedeemResult instance; - instance->setFromJson(source, false); +PinRedeemResult PinRedeemResult::fromJson(QJsonObject source) { + PinRedeemResult instance; + instance.setFromJson(source); return instance; } void PinRedeemResult::setFromJson(QJsonObject source) { - m_success = fromJsonValue(source["Success"]); - m_usersReset = fromJsonValue(source["UsersReset"]); + m_success = Jellyfin::Support::fromJsonValue(source["Success"]); + m_usersReset = Jellyfin::Support::fromJsonValue(source["UsersReset"]); } QJsonObject PinRedeemResult::toJson() { QJsonObject result; - result["Success"] = toJsonValue(m_success); - result["UsersReset"] = toJsonValue(m_usersReset); + result["Success"] = Jellyfin::Support::toJsonValue(m_success); + result["UsersReset"] = Jellyfin::Support::toJsonValue(m_usersReset); return result; } @@ -65,6 +66,17 @@ void PinRedeemResult::setUsersReset(QStringList newUsersReset) { m_usersReset = newUsersReset; } +} // NS DTO + +namespace Support { + +using PinRedeemResult = Jellyfin::DTO::PinRedeemResult; + +template <> +PinRedeemResult fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return PinRedeemResult::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/playaccess.cpp b/core/src/DTO/playaccess.cpp index 7fe65a7..46d0b43 100644 --- a/core/src/DTO/playaccess.cpp +++ b/core/src/DTO/playaccess.cpp @@ -34,5 +34,27 @@ namespace DTO { PlayAccessClass::PlayAccessClass() {} + +} // NS DTO + +namespace Support { + +using PlayAccess = Jellyfin::DTO::PlayAccess; + +template <> +PlayAccess fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return PlayAccess::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Full")) { + return PlayAccess::Full; + } + if (str == QStringLiteral("None")) { + return PlayAccess::None; + } + + return PlayAccess::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/playbackerrorcode.cpp b/core/src/DTO/playbackerrorcode.cpp index 2249a95..24de5ab 100644 --- a/core/src/DTO/playbackerrorcode.cpp +++ b/core/src/DTO/playbackerrorcode.cpp @@ -34,5 +34,30 @@ namespace DTO { PlaybackErrorCodeClass::PlaybackErrorCodeClass() {} + +} // NS DTO + +namespace Support { + +using PlaybackErrorCode = Jellyfin::DTO::PlaybackErrorCode; + +template <> +PlaybackErrorCode fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return PlaybackErrorCode::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("NotAllowed")) { + return PlaybackErrorCode::NotAllowed; + } + if (str == QStringLiteral("NoCompatibleStream")) { + return PlaybackErrorCode::NoCompatibleStream; + } + if (str == QStringLiteral("RateLimitExceeded")) { + return PlaybackErrorCode::RateLimitExceeded; + } + + return PlaybackErrorCode::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/playbackinfodto.cpp b/core/src/DTO/playbackinfodto.cpp index c123e2b..794574c 100644 --- a/core/src/DTO/playbackinfodto.cpp +++ b/core/src/DTO/playbackinfodto.cpp @@ -32,50 +32,51 @@ namespace Jellyfin { namespace DTO { -PlaybackInfoDto::PlaybackInfoDto(QObject *parent) {} +PlaybackInfoDto::PlaybackInfoDto() {} -PlaybackInfoDto PlaybackInfoDto::fromJson(QJsonObject source) {PlaybackInfoDto instance; - instance->setFromJson(source, false); +PlaybackInfoDto PlaybackInfoDto::fromJson(QJsonObject source) { + PlaybackInfoDto instance; + instance.setFromJson(source); return instance; } void PlaybackInfoDto::setFromJson(QJsonObject source) { - m_userId = fromJsonValue(source["UserId"]); - m_maxStreamingBitrate = fromJsonValue(source["MaxStreamingBitrate"]); - m_startTimeTicks = fromJsonValue(source["StartTimeTicks"]); - m_audioStreamIndex = fromJsonValue(source["AudioStreamIndex"]); - m_subtitleStreamIndex = fromJsonValue(source["SubtitleStreamIndex"]); - m_maxAudioChannels = fromJsonValue(source["MaxAudioChannels"]); - m_mediaSourceId = fromJsonValue(source["MediaSourceId"]); - m_liveStreamId = fromJsonValue(source["LiveStreamId"]); - m_deviceProfile = fromJsonValue>(source["DeviceProfile"]); - m_enableDirectPlay = fromJsonValue(source["EnableDirectPlay"]); - m_enableDirectStream = fromJsonValue(source["EnableDirectStream"]); - m_enableTranscoding = fromJsonValue(source["EnableTranscoding"]); - m_allowVideoStreamCopy = fromJsonValue(source["AllowVideoStreamCopy"]); - m_allowAudioStreamCopy = fromJsonValue(source["AllowAudioStreamCopy"]); - m_autoOpenLiveStream = fromJsonValue(source["AutoOpenLiveStream"]); + m_userId = Jellyfin::Support::fromJsonValue(source["UserId"]); + m_maxStreamingBitrate = Jellyfin::Support::fromJsonValue(source["MaxStreamingBitrate"]); + m_startTimeTicks = Jellyfin::Support::fromJsonValue(source["StartTimeTicks"]); + m_audioStreamIndex = Jellyfin::Support::fromJsonValue(source["AudioStreamIndex"]); + m_subtitleStreamIndex = Jellyfin::Support::fromJsonValue(source["SubtitleStreamIndex"]); + m_maxAudioChannels = Jellyfin::Support::fromJsonValue(source["MaxAudioChannels"]); + m_mediaSourceId = Jellyfin::Support::fromJsonValue(source["MediaSourceId"]); + m_liveStreamId = Jellyfin::Support::fromJsonValue(source["LiveStreamId"]); + m_deviceProfile = Jellyfin::Support::fromJsonValue>(source["DeviceProfile"]); + m_enableDirectPlay = Jellyfin::Support::fromJsonValue(source["EnableDirectPlay"]); + m_enableDirectStream = Jellyfin::Support::fromJsonValue(source["EnableDirectStream"]); + m_enableTranscoding = Jellyfin::Support::fromJsonValue(source["EnableTranscoding"]); + m_allowVideoStreamCopy = Jellyfin::Support::fromJsonValue(source["AllowVideoStreamCopy"]); + m_allowAudioStreamCopy = Jellyfin::Support::fromJsonValue(source["AllowAudioStreamCopy"]); + m_autoOpenLiveStream = Jellyfin::Support::fromJsonValue(source["AutoOpenLiveStream"]); } QJsonObject PlaybackInfoDto::toJson() { QJsonObject result; - result["UserId"] = toJsonValue(m_userId); - result["MaxStreamingBitrate"] = toJsonValue(m_maxStreamingBitrate); - result["StartTimeTicks"] = toJsonValue(m_startTimeTicks); - result["AudioStreamIndex"] = toJsonValue(m_audioStreamIndex); - result["SubtitleStreamIndex"] = toJsonValue(m_subtitleStreamIndex); - result["MaxAudioChannels"] = toJsonValue(m_maxAudioChannels); - result["MediaSourceId"] = toJsonValue(m_mediaSourceId); - result["LiveStreamId"] = toJsonValue(m_liveStreamId); - result["DeviceProfile"] = toJsonValue>(m_deviceProfile); - result["EnableDirectPlay"] = toJsonValue(m_enableDirectPlay); - result["EnableDirectStream"] = toJsonValue(m_enableDirectStream); - result["EnableTranscoding"] = toJsonValue(m_enableTranscoding); - result["AllowVideoStreamCopy"] = toJsonValue(m_allowVideoStreamCopy); - result["AllowAudioStreamCopy"] = toJsonValue(m_allowAudioStreamCopy); - result["AutoOpenLiveStream"] = toJsonValue(m_autoOpenLiveStream); + result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); + result["MaxStreamingBitrate"] = Jellyfin::Support::toJsonValue(m_maxStreamingBitrate); + result["StartTimeTicks"] = Jellyfin::Support::toJsonValue(m_startTimeTicks); + result["AudioStreamIndex"] = Jellyfin::Support::toJsonValue(m_audioStreamIndex); + result["SubtitleStreamIndex"] = Jellyfin::Support::toJsonValue(m_subtitleStreamIndex); + result["MaxAudioChannels"] = Jellyfin::Support::toJsonValue(m_maxAudioChannels); + result["MediaSourceId"] = Jellyfin::Support::toJsonValue(m_mediaSourceId); + result["LiveStreamId"] = Jellyfin::Support::toJsonValue(m_liveStreamId); + result["DeviceProfile"] = Jellyfin::Support::toJsonValue>(m_deviceProfile); + result["EnableDirectPlay"] = Jellyfin::Support::toJsonValue(m_enableDirectPlay); + result["EnableDirectStream"] = Jellyfin::Support::toJsonValue(m_enableDirectStream); + result["EnableTranscoding"] = Jellyfin::Support::toJsonValue(m_enableTranscoding); + result["AllowVideoStreamCopy"] = Jellyfin::Support::toJsonValue(m_allowVideoStreamCopy); + result["AllowAudioStreamCopy"] = Jellyfin::Support::toJsonValue(m_allowAudioStreamCopy); + result["AutoOpenLiveStream"] = Jellyfin::Support::toJsonValue(m_autoOpenLiveStream); return result; } @@ -156,6 +157,17 @@ void PlaybackInfoDto::setAutoOpenLiveStream(bool newAutoOpenLiveStream) { m_autoOpenLiveStream = newAutoOpenLiveStream; } +} // NS DTO + +namespace Support { + +using PlaybackInfoDto = Jellyfin::DTO::PlaybackInfoDto; + +template <> +PlaybackInfoDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return PlaybackInfoDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/playbackinforesponse.cpp b/core/src/DTO/playbackinforesponse.cpp index 2253c40..c383537 100644 --- a/core/src/DTO/playbackinforesponse.cpp +++ b/core/src/DTO/playbackinforesponse.cpp @@ -32,26 +32,27 @@ namespace Jellyfin { namespace DTO { -PlaybackInfoResponse::PlaybackInfoResponse(QObject *parent) {} +PlaybackInfoResponse::PlaybackInfoResponse() {} -PlaybackInfoResponse PlaybackInfoResponse::fromJson(QJsonObject source) {PlaybackInfoResponse instance; - instance->setFromJson(source, false); +PlaybackInfoResponse PlaybackInfoResponse::fromJson(QJsonObject source) { + PlaybackInfoResponse instance; + instance.setFromJson(source); return instance; } void PlaybackInfoResponse::setFromJson(QJsonObject source) { - m_mediaSources = fromJsonValue>>(source["MediaSources"]); - m_playSessionId = fromJsonValue(source["PlaySessionId"]); - m_errorCode = fromJsonValue(source["ErrorCode"]); + m_mediaSources = Jellyfin::Support::fromJsonValue>>(source["MediaSources"]); + m_playSessionId = Jellyfin::Support::fromJsonValue(source["PlaySessionId"]); + m_errorCode = Jellyfin::Support::fromJsonValue(source["ErrorCode"]); } QJsonObject PlaybackInfoResponse::toJson() { QJsonObject result; - result["MediaSources"] = toJsonValue>>(m_mediaSources); - result["PlaySessionId"] = toJsonValue(m_playSessionId); - result["ErrorCode"] = toJsonValue(m_errorCode); + result["MediaSources"] = Jellyfin::Support::toJsonValue>>(m_mediaSources); + result["PlaySessionId"] = Jellyfin::Support::toJsonValue(m_playSessionId); + result["ErrorCode"] = Jellyfin::Support::toJsonValue(m_errorCode); return result; } @@ -72,6 +73,17 @@ void PlaybackInfoResponse::setErrorCode(PlaybackErrorCode newErrorCode) { m_errorCode = newErrorCode; } +} // NS DTO + +namespace Support { + +using PlaybackInfoResponse = Jellyfin::DTO::PlaybackInfoResponse; + +template <> +PlaybackInfoResponse fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return PlaybackInfoResponse::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/playbackprogressinfo.cpp b/core/src/DTO/playbackprogressinfo.cpp index 908b93c..0f0924d 100644 --- a/core/src/DTO/playbackprogressinfo.cpp +++ b/core/src/DTO/playbackprogressinfo.cpp @@ -32,60 +32,61 @@ namespace Jellyfin { namespace DTO { -PlaybackProgressInfo::PlaybackProgressInfo(QObject *parent) {} +PlaybackProgressInfo::PlaybackProgressInfo() {} -PlaybackProgressInfo PlaybackProgressInfo::fromJson(QJsonObject source) {PlaybackProgressInfo instance; - instance->setFromJson(source, false); +PlaybackProgressInfo PlaybackProgressInfo::fromJson(QJsonObject source) { + PlaybackProgressInfo instance; + instance.setFromJson(source); return instance; } void PlaybackProgressInfo::setFromJson(QJsonObject source) { - m_canSeek = fromJsonValue(source["CanSeek"]); - m_item = fromJsonValue>(source["Item"]); - m_itemId = fromJsonValue(source["ItemId"]); - m_sessionId = fromJsonValue(source["SessionId"]); - m_mediaSourceId = fromJsonValue(source["MediaSourceId"]); - m_audioStreamIndex = fromJsonValue(source["AudioStreamIndex"]); - m_subtitleStreamIndex = fromJsonValue(source["SubtitleStreamIndex"]); - m_isPaused = fromJsonValue(source["IsPaused"]); - m_isMuted = fromJsonValue(source["IsMuted"]); - m_positionTicks = fromJsonValue(source["PositionTicks"]); - m_playbackStartTimeTicks = fromJsonValue(source["PlaybackStartTimeTicks"]); - m_volumeLevel = fromJsonValue(source["VolumeLevel"]); - m_brightness = fromJsonValue(source["Brightness"]); - m_aspectRatio = fromJsonValue(source["AspectRatio"]); - m_playMethod = fromJsonValue(source["PlayMethod"]); - m_liveStreamId = fromJsonValue(source["LiveStreamId"]); - m_playSessionId = fromJsonValue(source["PlaySessionId"]); - m_repeatMode = fromJsonValue(source["RepeatMode"]); - m_nowPlayingQueue = fromJsonValue>>(source["NowPlayingQueue"]); - m_playlistItemId = fromJsonValue(source["PlaylistItemId"]); + m_canSeek = Jellyfin::Support::fromJsonValue(source["CanSeek"]); + m_item = Jellyfin::Support::fromJsonValue>(source["Item"]); + m_itemId = Jellyfin::Support::fromJsonValue(source["ItemId"]); + m_sessionId = Jellyfin::Support::fromJsonValue(source["SessionId"]); + m_mediaSourceId = Jellyfin::Support::fromJsonValue(source["MediaSourceId"]); + m_audioStreamIndex = Jellyfin::Support::fromJsonValue(source["AudioStreamIndex"]); + m_subtitleStreamIndex = Jellyfin::Support::fromJsonValue(source["SubtitleStreamIndex"]); + m_isPaused = Jellyfin::Support::fromJsonValue(source["IsPaused"]); + m_isMuted = Jellyfin::Support::fromJsonValue(source["IsMuted"]); + m_positionTicks = Jellyfin::Support::fromJsonValue(source["PositionTicks"]); + m_playbackStartTimeTicks = Jellyfin::Support::fromJsonValue(source["PlaybackStartTimeTicks"]); + m_volumeLevel = Jellyfin::Support::fromJsonValue(source["VolumeLevel"]); + m_brightness = Jellyfin::Support::fromJsonValue(source["Brightness"]); + m_aspectRatio = Jellyfin::Support::fromJsonValue(source["AspectRatio"]); + m_playMethod = Jellyfin::Support::fromJsonValue(source["PlayMethod"]); + m_liveStreamId = Jellyfin::Support::fromJsonValue(source["LiveStreamId"]); + m_playSessionId = Jellyfin::Support::fromJsonValue(source["PlaySessionId"]); + m_repeatMode = Jellyfin::Support::fromJsonValue(source["RepeatMode"]); + m_nowPlayingQueue = Jellyfin::Support::fromJsonValue>>(source["NowPlayingQueue"]); + m_playlistItemId = Jellyfin::Support::fromJsonValue(source["PlaylistItemId"]); } QJsonObject PlaybackProgressInfo::toJson() { QJsonObject result; - result["CanSeek"] = toJsonValue(m_canSeek); - result["Item"] = toJsonValue>(m_item); - result["ItemId"] = toJsonValue(m_itemId); - result["SessionId"] = toJsonValue(m_sessionId); - result["MediaSourceId"] = toJsonValue(m_mediaSourceId); - result["AudioStreamIndex"] = toJsonValue(m_audioStreamIndex); - result["SubtitleStreamIndex"] = toJsonValue(m_subtitleStreamIndex); - result["IsPaused"] = toJsonValue(m_isPaused); - result["IsMuted"] = toJsonValue(m_isMuted); - result["PositionTicks"] = toJsonValue(m_positionTicks); - result["PlaybackStartTimeTicks"] = toJsonValue(m_playbackStartTimeTicks); - result["VolumeLevel"] = toJsonValue(m_volumeLevel); - result["Brightness"] = toJsonValue(m_brightness); - result["AspectRatio"] = toJsonValue(m_aspectRatio); - result["PlayMethod"] = toJsonValue(m_playMethod); - result["LiveStreamId"] = toJsonValue(m_liveStreamId); - result["PlaySessionId"] = toJsonValue(m_playSessionId); - result["RepeatMode"] = toJsonValue(m_repeatMode); - result["NowPlayingQueue"] = toJsonValue>>(m_nowPlayingQueue); - result["PlaylistItemId"] = toJsonValue(m_playlistItemId); + result["CanSeek"] = Jellyfin::Support::toJsonValue(m_canSeek); + result["Item"] = Jellyfin::Support::toJsonValue>(m_item); + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + result["SessionId"] = Jellyfin::Support::toJsonValue(m_sessionId); + result["MediaSourceId"] = Jellyfin::Support::toJsonValue(m_mediaSourceId); + result["AudioStreamIndex"] = Jellyfin::Support::toJsonValue(m_audioStreamIndex); + result["SubtitleStreamIndex"] = Jellyfin::Support::toJsonValue(m_subtitleStreamIndex); + result["IsPaused"] = Jellyfin::Support::toJsonValue(m_isPaused); + result["IsMuted"] = Jellyfin::Support::toJsonValue(m_isMuted); + result["PositionTicks"] = Jellyfin::Support::toJsonValue(m_positionTicks); + result["PlaybackStartTimeTicks"] = Jellyfin::Support::toJsonValue(m_playbackStartTimeTicks); + result["VolumeLevel"] = Jellyfin::Support::toJsonValue(m_volumeLevel); + result["Brightness"] = Jellyfin::Support::toJsonValue(m_brightness); + result["AspectRatio"] = Jellyfin::Support::toJsonValue(m_aspectRatio); + result["PlayMethod"] = Jellyfin::Support::toJsonValue(m_playMethod); + result["LiveStreamId"] = Jellyfin::Support::toJsonValue(m_liveStreamId); + result["PlaySessionId"] = Jellyfin::Support::toJsonValue(m_playSessionId); + result["RepeatMode"] = Jellyfin::Support::toJsonValue(m_repeatMode); + result["NowPlayingQueue"] = Jellyfin::Support::toJsonValue>>(m_nowPlayingQueue); + result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); return result; } @@ -191,6 +192,17 @@ void PlaybackProgressInfo::setPlaylistItemId(QString newPlaylistItemId) { m_playlistItemId = newPlaylistItemId; } +} // NS DTO + +namespace Support { + +using PlaybackProgressInfo = Jellyfin::DTO::PlaybackProgressInfo; + +template <> +PlaybackProgressInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return PlaybackProgressInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/playbackstartinfo.cpp b/core/src/DTO/playbackstartinfo.cpp index 6784f0a..22db874 100644 --- a/core/src/DTO/playbackstartinfo.cpp +++ b/core/src/DTO/playbackstartinfo.cpp @@ -32,60 +32,61 @@ namespace Jellyfin { namespace DTO { -PlaybackStartInfo::PlaybackStartInfo(QObject *parent) {} +PlaybackStartInfo::PlaybackStartInfo() {} -PlaybackStartInfo PlaybackStartInfo::fromJson(QJsonObject source) {PlaybackStartInfo instance; - instance->setFromJson(source, false); +PlaybackStartInfo PlaybackStartInfo::fromJson(QJsonObject source) { + PlaybackStartInfo instance; + instance.setFromJson(source); return instance; } void PlaybackStartInfo::setFromJson(QJsonObject source) { - m_canSeek = fromJsonValue(source["CanSeek"]); - m_item = fromJsonValue>(source["Item"]); - m_itemId = fromJsonValue(source["ItemId"]); - m_sessionId = fromJsonValue(source["SessionId"]); - m_mediaSourceId = fromJsonValue(source["MediaSourceId"]); - m_audioStreamIndex = fromJsonValue(source["AudioStreamIndex"]); - m_subtitleStreamIndex = fromJsonValue(source["SubtitleStreamIndex"]); - m_isPaused = fromJsonValue(source["IsPaused"]); - m_isMuted = fromJsonValue(source["IsMuted"]); - m_positionTicks = fromJsonValue(source["PositionTicks"]); - m_playbackStartTimeTicks = fromJsonValue(source["PlaybackStartTimeTicks"]); - m_volumeLevel = fromJsonValue(source["VolumeLevel"]); - m_brightness = fromJsonValue(source["Brightness"]); - m_aspectRatio = fromJsonValue(source["AspectRatio"]); - m_playMethod = fromJsonValue(source["PlayMethod"]); - m_liveStreamId = fromJsonValue(source["LiveStreamId"]); - m_playSessionId = fromJsonValue(source["PlaySessionId"]); - m_repeatMode = fromJsonValue(source["RepeatMode"]); - m_nowPlayingQueue = fromJsonValue>>(source["NowPlayingQueue"]); - m_playlistItemId = fromJsonValue(source["PlaylistItemId"]); + m_canSeek = Jellyfin::Support::fromJsonValue(source["CanSeek"]); + m_item = Jellyfin::Support::fromJsonValue>(source["Item"]); + m_itemId = Jellyfin::Support::fromJsonValue(source["ItemId"]); + m_sessionId = Jellyfin::Support::fromJsonValue(source["SessionId"]); + m_mediaSourceId = Jellyfin::Support::fromJsonValue(source["MediaSourceId"]); + m_audioStreamIndex = Jellyfin::Support::fromJsonValue(source["AudioStreamIndex"]); + m_subtitleStreamIndex = Jellyfin::Support::fromJsonValue(source["SubtitleStreamIndex"]); + m_isPaused = Jellyfin::Support::fromJsonValue(source["IsPaused"]); + m_isMuted = Jellyfin::Support::fromJsonValue(source["IsMuted"]); + m_positionTicks = Jellyfin::Support::fromJsonValue(source["PositionTicks"]); + m_playbackStartTimeTicks = Jellyfin::Support::fromJsonValue(source["PlaybackStartTimeTicks"]); + m_volumeLevel = Jellyfin::Support::fromJsonValue(source["VolumeLevel"]); + m_brightness = Jellyfin::Support::fromJsonValue(source["Brightness"]); + m_aspectRatio = Jellyfin::Support::fromJsonValue(source["AspectRatio"]); + m_playMethod = Jellyfin::Support::fromJsonValue(source["PlayMethod"]); + m_liveStreamId = Jellyfin::Support::fromJsonValue(source["LiveStreamId"]); + m_playSessionId = Jellyfin::Support::fromJsonValue(source["PlaySessionId"]); + m_repeatMode = Jellyfin::Support::fromJsonValue(source["RepeatMode"]); + m_nowPlayingQueue = Jellyfin::Support::fromJsonValue>>(source["NowPlayingQueue"]); + m_playlistItemId = Jellyfin::Support::fromJsonValue(source["PlaylistItemId"]); } QJsonObject PlaybackStartInfo::toJson() { QJsonObject result; - result["CanSeek"] = toJsonValue(m_canSeek); - result["Item"] = toJsonValue>(m_item); - result["ItemId"] = toJsonValue(m_itemId); - result["SessionId"] = toJsonValue(m_sessionId); - result["MediaSourceId"] = toJsonValue(m_mediaSourceId); - result["AudioStreamIndex"] = toJsonValue(m_audioStreamIndex); - result["SubtitleStreamIndex"] = toJsonValue(m_subtitleStreamIndex); - result["IsPaused"] = toJsonValue(m_isPaused); - result["IsMuted"] = toJsonValue(m_isMuted); - result["PositionTicks"] = toJsonValue(m_positionTicks); - result["PlaybackStartTimeTicks"] = toJsonValue(m_playbackStartTimeTicks); - result["VolumeLevel"] = toJsonValue(m_volumeLevel); - result["Brightness"] = toJsonValue(m_brightness); - result["AspectRatio"] = toJsonValue(m_aspectRatio); - result["PlayMethod"] = toJsonValue(m_playMethod); - result["LiveStreamId"] = toJsonValue(m_liveStreamId); - result["PlaySessionId"] = toJsonValue(m_playSessionId); - result["RepeatMode"] = toJsonValue(m_repeatMode); - result["NowPlayingQueue"] = toJsonValue>>(m_nowPlayingQueue); - result["PlaylistItemId"] = toJsonValue(m_playlistItemId); + result["CanSeek"] = Jellyfin::Support::toJsonValue(m_canSeek); + result["Item"] = Jellyfin::Support::toJsonValue>(m_item); + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + result["SessionId"] = Jellyfin::Support::toJsonValue(m_sessionId); + result["MediaSourceId"] = Jellyfin::Support::toJsonValue(m_mediaSourceId); + result["AudioStreamIndex"] = Jellyfin::Support::toJsonValue(m_audioStreamIndex); + result["SubtitleStreamIndex"] = Jellyfin::Support::toJsonValue(m_subtitleStreamIndex); + result["IsPaused"] = Jellyfin::Support::toJsonValue(m_isPaused); + result["IsMuted"] = Jellyfin::Support::toJsonValue(m_isMuted); + result["PositionTicks"] = Jellyfin::Support::toJsonValue(m_positionTicks); + result["PlaybackStartTimeTicks"] = Jellyfin::Support::toJsonValue(m_playbackStartTimeTicks); + result["VolumeLevel"] = Jellyfin::Support::toJsonValue(m_volumeLevel); + result["Brightness"] = Jellyfin::Support::toJsonValue(m_brightness); + result["AspectRatio"] = Jellyfin::Support::toJsonValue(m_aspectRatio); + result["PlayMethod"] = Jellyfin::Support::toJsonValue(m_playMethod); + result["LiveStreamId"] = Jellyfin::Support::toJsonValue(m_liveStreamId); + result["PlaySessionId"] = Jellyfin::Support::toJsonValue(m_playSessionId); + result["RepeatMode"] = Jellyfin::Support::toJsonValue(m_repeatMode); + result["NowPlayingQueue"] = Jellyfin::Support::toJsonValue>>(m_nowPlayingQueue); + result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); return result; } @@ -191,6 +192,17 @@ void PlaybackStartInfo::setPlaylistItemId(QString newPlaylistItemId) { m_playlistItemId = newPlaylistItemId; } +} // NS DTO + +namespace Support { + +using PlaybackStartInfo = Jellyfin::DTO::PlaybackStartInfo; + +template <> +PlaybackStartInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return PlaybackStartInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/playbackstopinfo.cpp b/core/src/DTO/playbackstopinfo.cpp index 33a0adf..a6237de 100644 --- a/core/src/DTO/playbackstopinfo.cpp +++ b/core/src/DTO/playbackstopinfo.cpp @@ -32,42 +32,43 @@ namespace Jellyfin { namespace DTO { -PlaybackStopInfo::PlaybackStopInfo(QObject *parent) {} +PlaybackStopInfo::PlaybackStopInfo() {} -PlaybackStopInfo PlaybackStopInfo::fromJson(QJsonObject source) {PlaybackStopInfo instance; - instance->setFromJson(source, false); +PlaybackStopInfo PlaybackStopInfo::fromJson(QJsonObject source) { + PlaybackStopInfo instance; + instance.setFromJson(source); return instance; } void PlaybackStopInfo::setFromJson(QJsonObject source) { - m_item = fromJsonValue>(source["Item"]); - m_itemId = fromJsonValue(source["ItemId"]); - m_sessionId = fromJsonValue(source["SessionId"]); - m_mediaSourceId = fromJsonValue(source["MediaSourceId"]); - m_positionTicks = fromJsonValue(source["PositionTicks"]); - m_liveStreamId = fromJsonValue(source["LiveStreamId"]); - m_playSessionId = fromJsonValue(source["PlaySessionId"]); - m_failed = fromJsonValue(source["Failed"]); - m_nextMediaType = fromJsonValue(source["NextMediaType"]); - m_playlistItemId = fromJsonValue(source["PlaylistItemId"]); - m_nowPlayingQueue = fromJsonValue>>(source["NowPlayingQueue"]); + m_item = Jellyfin::Support::fromJsonValue>(source["Item"]); + m_itemId = Jellyfin::Support::fromJsonValue(source["ItemId"]); + m_sessionId = Jellyfin::Support::fromJsonValue(source["SessionId"]); + m_mediaSourceId = Jellyfin::Support::fromJsonValue(source["MediaSourceId"]); + m_positionTicks = Jellyfin::Support::fromJsonValue(source["PositionTicks"]); + m_liveStreamId = Jellyfin::Support::fromJsonValue(source["LiveStreamId"]); + m_playSessionId = Jellyfin::Support::fromJsonValue(source["PlaySessionId"]); + m_failed = Jellyfin::Support::fromJsonValue(source["Failed"]); + m_nextMediaType = Jellyfin::Support::fromJsonValue(source["NextMediaType"]); + m_playlistItemId = Jellyfin::Support::fromJsonValue(source["PlaylistItemId"]); + m_nowPlayingQueue = Jellyfin::Support::fromJsonValue>>(source["NowPlayingQueue"]); } QJsonObject PlaybackStopInfo::toJson() { QJsonObject result; - result["Item"] = toJsonValue>(m_item); - result["ItemId"] = toJsonValue(m_itemId); - result["SessionId"] = toJsonValue(m_sessionId); - result["MediaSourceId"] = toJsonValue(m_mediaSourceId); - result["PositionTicks"] = toJsonValue(m_positionTicks); - result["LiveStreamId"] = toJsonValue(m_liveStreamId); - result["PlaySessionId"] = toJsonValue(m_playSessionId); - result["Failed"] = toJsonValue(m_failed); - result["NextMediaType"] = toJsonValue(m_nextMediaType); - result["PlaylistItemId"] = toJsonValue(m_playlistItemId); - result["NowPlayingQueue"] = toJsonValue>>(m_nowPlayingQueue); + result["Item"] = Jellyfin::Support::toJsonValue>(m_item); + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + result["SessionId"] = Jellyfin::Support::toJsonValue(m_sessionId); + result["MediaSourceId"] = Jellyfin::Support::toJsonValue(m_mediaSourceId); + result["PositionTicks"] = Jellyfin::Support::toJsonValue(m_positionTicks); + result["LiveStreamId"] = Jellyfin::Support::toJsonValue(m_liveStreamId); + result["PlaySessionId"] = Jellyfin::Support::toJsonValue(m_playSessionId); + result["Failed"] = Jellyfin::Support::toJsonValue(m_failed); + result["NextMediaType"] = Jellyfin::Support::toJsonValue(m_nextMediaType); + result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); + result["NowPlayingQueue"] = Jellyfin::Support::toJsonValue>>(m_nowPlayingQueue); return result; } @@ -128,6 +129,17 @@ void PlaybackStopInfo::setNowPlayingQueue(QList> newNo m_nowPlayingQueue = newNowPlayingQueue; } +} // NS DTO + +namespace Support { + +using PlaybackStopInfo = Jellyfin::DTO::PlaybackStopInfo; + +template <> +PlaybackStopInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return PlaybackStopInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/playcommand.cpp b/core/src/DTO/playcommand.cpp index 59dbc5b..9dce41b 100644 --- a/core/src/DTO/playcommand.cpp +++ b/core/src/DTO/playcommand.cpp @@ -34,5 +34,36 @@ namespace DTO { PlayCommandClass::PlayCommandClass() {} + +} // NS DTO + +namespace Support { + +using PlayCommand = Jellyfin::DTO::PlayCommand; + +template <> +PlayCommand fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return PlayCommand::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("PlayNow")) { + return PlayCommand::PlayNow; + } + if (str == QStringLiteral("PlayNext")) { + return PlayCommand::PlayNext; + } + if (str == QStringLiteral("PlayLast")) { + return PlayCommand::PlayLast; + } + if (str == QStringLiteral("PlayInstantMix")) { + return PlayCommand::PlayInstantMix; + } + if (str == QStringLiteral("PlayShuffle")) { + return PlayCommand::PlayShuffle; + } + + return PlayCommand::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/playerstateinfo.cpp b/core/src/DTO/playerstateinfo.cpp index a70863a..a019c8a 100644 --- a/core/src/DTO/playerstateinfo.cpp +++ b/core/src/DTO/playerstateinfo.cpp @@ -32,40 +32,41 @@ namespace Jellyfin { namespace DTO { -PlayerStateInfo::PlayerStateInfo(QObject *parent) {} +PlayerStateInfo::PlayerStateInfo() {} -PlayerStateInfo PlayerStateInfo::fromJson(QJsonObject source) {PlayerStateInfo instance; - instance->setFromJson(source, false); +PlayerStateInfo PlayerStateInfo::fromJson(QJsonObject source) { + PlayerStateInfo instance; + instance.setFromJson(source); return instance; } void PlayerStateInfo::setFromJson(QJsonObject source) { - m_positionTicks = fromJsonValue(source["PositionTicks"]); - m_canSeek = fromJsonValue(source["CanSeek"]); - m_isPaused = fromJsonValue(source["IsPaused"]); - m_isMuted = fromJsonValue(source["IsMuted"]); - m_volumeLevel = fromJsonValue(source["VolumeLevel"]); - m_audioStreamIndex = fromJsonValue(source["AudioStreamIndex"]); - m_subtitleStreamIndex = fromJsonValue(source["SubtitleStreamIndex"]); - m_mediaSourceId = fromJsonValue(source["MediaSourceId"]); - m_playMethod = fromJsonValue(source["PlayMethod"]); - m_repeatMode = fromJsonValue(source["RepeatMode"]); + m_positionTicks = Jellyfin::Support::fromJsonValue(source["PositionTicks"]); + m_canSeek = Jellyfin::Support::fromJsonValue(source["CanSeek"]); + m_isPaused = Jellyfin::Support::fromJsonValue(source["IsPaused"]); + m_isMuted = Jellyfin::Support::fromJsonValue(source["IsMuted"]); + m_volumeLevel = Jellyfin::Support::fromJsonValue(source["VolumeLevel"]); + m_audioStreamIndex = Jellyfin::Support::fromJsonValue(source["AudioStreamIndex"]); + m_subtitleStreamIndex = Jellyfin::Support::fromJsonValue(source["SubtitleStreamIndex"]); + m_mediaSourceId = Jellyfin::Support::fromJsonValue(source["MediaSourceId"]); + m_playMethod = Jellyfin::Support::fromJsonValue(source["PlayMethod"]); + m_repeatMode = Jellyfin::Support::fromJsonValue(source["RepeatMode"]); } QJsonObject PlayerStateInfo::toJson() { QJsonObject result; - result["PositionTicks"] = toJsonValue(m_positionTicks); - result["CanSeek"] = toJsonValue(m_canSeek); - result["IsPaused"] = toJsonValue(m_isPaused); - result["IsMuted"] = toJsonValue(m_isMuted); - result["VolumeLevel"] = toJsonValue(m_volumeLevel); - result["AudioStreamIndex"] = toJsonValue(m_audioStreamIndex); - result["SubtitleStreamIndex"] = toJsonValue(m_subtitleStreamIndex); - result["MediaSourceId"] = toJsonValue(m_mediaSourceId); - result["PlayMethod"] = toJsonValue(m_playMethod); - result["RepeatMode"] = toJsonValue(m_repeatMode); + result["PositionTicks"] = Jellyfin::Support::toJsonValue(m_positionTicks); + result["CanSeek"] = Jellyfin::Support::toJsonValue(m_canSeek); + result["IsPaused"] = Jellyfin::Support::toJsonValue(m_isPaused); + result["IsMuted"] = Jellyfin::Support::toJsonValue(m_isMuted); + result["VolumeLevel"] = Jellyfin::Support::toJsonValue(m_volumeLevel); + result["AudioStreamIndex"] = Jellyfin::Support::toJsonValue(m_audioStreamIndex); + result["SubtitleStreamIndex"] = Jellyfin::Support::toJsonValue(m_subtitleStreamIndex); + result["MediaSourceId"] = Jellyfin::Support::toJsonValue(m_mediaSourceId); + result["PlayMethod"] = Jellyfin::Support::toJsonValue(m_playMethod); + result["RepeatMode"] = Jellyfin::Support::toJsonValue(m_repeatMode); return result; } @@ -121,6 +122,17 @@ void PlayerStateInfo::setRepeatMode(RepeatMode newRepeatMode) { m_repeatMode = newRepeatMode; } +} // NS DTO + +namespace Support { + +using PlayerStateInfo = Jellyfin::DTO::PlayerStateInfo; + +template <> +PlayerStateInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return PlayerStateInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/playlistcreationresult.cpp b/core/src/DTO/playlistcreationresult.cpp index a715040..47d50e4 100644 --- a/core/src/DTO/playlistcreationresult.cpp +++ b/core/src/DTO/playlistcreationresult.cpp @@ -32,22 +32,23 @@ namespace Jellyfin { namespace DTO { -PlaylistCreationResult::PlaylistCreationResult(QObject *parent) {} +PlaylistCreationResult::PlaylistCreationResult() {} -PlaylistCreationResult PlaylistCreationResult::fromJson(QJsonObject source) {PlaylistCreationResult instance; - instance->setFromJson(source, false); +PlaylistCreationResult PlaylistCreationResult::fromJson(QJsonObject source) { + PlaylistCreationResult instance; + instance.setFromJson(source); return instance; } void PlaylistCreationResult::setFromJson(QJsonObject source) { - m_jellyfinId = fromJsonValue(source["Id"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); } QJsonObject PlaylistCreationResult::toJson() { QJsonObject result; - result["Id"] = toJsonValue(m_jellyfinId); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); return result; } @@ -58,6 +59,17 @@ void PlaylistCreationResult::setJellyfinId(QString newJellyfinId) { m_jellyfinId = newJellyfinId; } +} // NS DTO + +namespace Support { + +using PlaylistCreationResult = Jellyfin::DTO::PlaylistCreationResult; + +template <> +PlaylistCreationResult fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return PlaylistCreationResult::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/playmethod.cpp b/core/src/DTO/playmethod.cpp index 22a7793..c3333c1 100644 --- a/core/src/DTO/playmethod.cpp +++ b/core/src/DTO/playmethod.cpp @@ -34,5 +34,30 @@ namespace DTO { PlayMethodClass::PlayMethodClass() {} + +} // NS DTO + +namespace Support { + +using PlayMethod = Jellyfin::DTO::PlayMethod; + +template <> +PlayMethod fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return PlayMethod::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Transcode")) { + return PlayMethod::Transcode; + } + if (str == QStringLiteral("DirectStream")) { + return PlayMethod::DirectStream; + } + if (str == QStringLiteral("DirectPlay")) { + return PlayMethod::DirectPlay; + } + + return PlayMethod::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/playrequest.cpp b/core/src/DTO/playrequest.cpp index 788b801..02a2c07 100644 --- a/core/src/DTO/playrequest.cpp +++ b/core/src/DTO/playrequest.cpp @@ -32,36 +32,37 @@ namespace Jellyfin { namespace DTO { -PlayRequest::PlayRequest(QObject *parent) {} +PlayRequest::PlayRequest() {} -PlayRequest PlayRequest::fromJson(QJsonObject source) {PlayRequest instance; - instance->setFromJson(source, false); +PlayRequest PlayRequest::fromJson(QJsonObject source) { + PlayRequest instance; + instance.setFromJson(source); return instance; } void PlayRequest::setFromJson(QJsonObject source) { - m_itemIds = fromJsonValue>(source["ItemIds"]); - m_startPositionTicks = fromJsonValue(source["StartPositionTicks"]); - m_playCommand = fromJsonValue(source["PlayCommand"]); - m_controllingUserId = fromJsonValue(source["ControllingUserId"]); - m_subtitleStreamIndex = fromJsonValue(source["SubtitleStreamIndex"]); - m_audioStreamIndex = fromJsonValue(source["AudioStreamIndex"]); - m_mediaSourceId = fromJsonValue(source["MediaSourceId"]); - m_startIndex = fromJsonValue(source["StartIndex"]); + m_itemIds = Jellyfin::Support::fromJsonValue>(source["ItemIds"]); + m_startPositionTicks = Jellyfin::Support::fromJsonValue(source["StartPositionTicks"]); + m_playCommand = Jellyfin::Support::fromJsonValue(source["PlayCommand"]); + m_controllingUserId = Jellyfin::Support::fromJsonValue(source["ControllingUserId"]); + m_subtitleStreamIndex = Jellyfin::Support::fromJsonValue(source["SubtitleStreamIndex"]); + m_audioStreamIndex = Jellyfin::Support::fromJsonValue(source["AudioStreamIndex"]); + m_mediaSourceId = Jellyfin::Support::fromJsonValue(source["MediaSourceId"]); + m_startIndex = Jellyfin::Support::fromJsonValue(source["StartIndex"]); } QJsonObject PlayRequest::toJson() { QJsonObject result; - result["ItemIds"] = toJsonValue>(m_itemIds); - result["StartPositionTicks"] = toJsonValue(m_startPositionTicks); - result["PlayCommand"] = toJsonValue(m_playCommand); - result["ControllingUserId"] = toJsonValue(m_controllingUserId); - result["SubtitleStreamIndex"] = toJsonValue(m_subtitleStreamIndex); - result["AudioStreamIndex"] = toJsonValue(m_audioStreamIndex); - result["MediaSourceId"] = toJsonValue(m_mediaSourceId); - result["StartIndex"] = toJsonValue(m_startIndex); + result["ItemIds"] = Jellyfin::Support::toJsonValue>(m_itemIds); + result["StartPositionTicks"] = Jellyfin::Support::toJsonValue(m_startPositionTicks); + result["PlayCommand"] = Jellyfin::Support::toJsonValue(m_playCommand); + result["ControllingUserId"] = Jellyfin::Support::toJsonValue(m_controllingUserId); + result["SubtitleStreamIndex"] = Jellyfin::Support::toJsonValue(m_subtitleStreamIndex); + result["AudioStreamIndex"] = Jellyfin::Support::toJsonValue(m_audioStreamIndex); + result["MediaSourceId"] = Jellyfin::Support::toJsonValue(m_mediaSourceId); + result["StartIndex"] = Jellyfin::Support::toJsonValue(m_startIndex); return result; } @@ -107,6 +108,17 @@ void PlayRequest::setStartIndex(qint32 newStartIndex) { m_startIndex = newStartIndex; } +} // NS DTO + +namespace Support { + +using PlayRequest = Jellyfin::DTO::PlayRequest; + +template <> +PlayRequest fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return PlayRequest::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/playrequestdto.cpp b/core/src/DTO/playrequestdto.cpp index 153f161..fc16212 100644 --- a/core/src/DTO/playrequestdto.cpp +++ b/core/src/DTO/playrequestdto.cpp @@ -32,26 +32,27 @@ namespace Jellyfin { namespace DTO { -PlayRequestDto::PlayRequestDto(QObject *parent) {} +PlayRequestDto::PlayRequestDto() {} -PlayRequestDto PlayRequestDto::fromJson(QJsonObject source) {PlayRequestDto instance; - instance->setFromJson(source, false); +PlayRequestDto PlayRequestDto::fromJson(QJsonObject source) { + PlayRequestDto instance; + instance.setFromJson(source); return instance; } void PlayRequestDto::setFromJson(QJsonObject source) { - m_playingQueue = fromJsonValue>(source["PlayingQueue"]); - m_playingItemPosition = fromJsonValue(source["PlayingItemPosition"]); - m_startPositionTicks = fromJsonValue(source["StartPositionTicks"]); + m_playingQueue = Jellyfin::Support::fromJsonValue>(source["PlayingQueue"]); + m_playingItemPosition = Jellyfin::Support::fromJsonValue(source["PlayingItemPosition"]); + m_startPositionTicks = Jellyfin::Support::fromJsonValue(source["StartPositionTicks"]); } QJsonObject PlayRequestDto::toJson() { QJsonObject result; - result["PlayingQueue"] = toJsonValue>(m_playingQueue); - result["PlayingItemPosition"] = toJsonValue(m_playingItemPosition); - result["StartPositionTicks"] = toJsonValue(m_startPositionTicks); + result["PlayingQueue"] = Jellyfin::Support::toJsonValue>(m_playingQueue); + result["PlayingItemPosition"] = Jellyfin::Support::toJsonValue(m_playingItemPosition); + result["StartPositionTicks"] = Jellyfin::Support::toJsonValue(m_startPositionTicks); return result; } @@ -72,6 +73,17 @@ void PlayRequestDto::setStartPositionTicks(qint64 newStartPositionTicks) { m_startPositionTicks = newStartPositionTicks; } +} // NS DTO + +namespace Support { + +using PlayRequestDto = Jellyfin::DTO::PlayRequestDto; + +template <> +PlayRequestDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return PlayRequestDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/playstatecommand.cpp b/core/src/DTO/playstatecommand.cpp index 9860fef..9775aff 100644 --- a/core/src/DTO/playstatecommand.cpp +++ b/core/src/DTO/playstatecommand.cpp @@ -34,5 +34,48 @@ namespace DTO { PlaystateCommandClass::PlaystateCommandClass() {} + +} // NS DTO + +namespace Support { + +using PlaystateCommand = Jellyfin::DTO::PlaystateCommand; + +template <> +PlaystateCommand fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return PlaystateCommand::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Stop")) { + return PlaystateCommand::Stop; + } + if (str == QStringLiteral("Pause")) { + return PlaystateCommand::Pause; + } + if (str == QStringLiteral("Unpause")) { + return PlaystateCommand::Unpause; + } + if (str == QStringLiteral("NextTrack")) { + return PlaystateCommand::NextTrack; + } + if (str == QStringLiteral("PreviousTrack")) { + return PlaystateCommand::PreviousTrack; + } + if (str == QStringLiteral("Seek")) { + return PlaystateCommand::Seek; + } + if (str == QStringLiteral("Rewind")) { + return PlaystateCommand::Rewind; + } + if (str == QStringLiteral("FastForward")) { + return PlaystateCommand::FastForward; + } + if (str == QStringLiteral("PlayPause")) { + return PlaystateCommand::PlayPause; + } + + return PlaystateCommand::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/playstaterequest.cpp b/core/src/DTO/playstaterequest.cpp index 92c5af7..5382039 100644 --- a/core/src/DTO/playstaterequest.cpp +++ b/core/src/DTO/playstaterequest.cpp @@ -32,26 +32,27 @@ namespace Jellyfin { namespace DTO { -PlaystateRequest::PlaystateRequest(QObject *parent) {} +PlaystateRequest::PlaystateRequest() {} -PlaystateRequest PlaystateRequest::fromJson(QJsonObject source) {PlaystateRequest instance; - instance->setFromJson(source, false); +PlaystateRequest PlaystateRequest::fromJson(QJsonObject source) { + PlaystateRequest instance; + instance.setFromJson(source); return instance; } void PlaystateRequest::setFromJson(QJsonObject source) { - m_command = fromJsonValue(source["Command"]); - m_seekPositionTicks = fromJsonValue(source["SeekPositionTicks"]); - m_controllingUserId = fromJsonValue(source["ControllingUserId"]); + m_command = Jellyfin::Support::fromJsonValue(source["Command"]); + m_seekPositionTicks = Jellyfin::Support::fromJsonValue(source["SeekPositionTicks"]); + m_controllingUserId = Jellyfin::Support::fromJsonValue(source["ControllingUserId"]); } QJsonObject PlaystateRequest::toJson() { QJsonObject result; - result["Command"] = toJsonValue(m_command); - result["SeekPositionTicks"] = toJsonValue(m_seekPositionTicks); - result["ControllingUserId"] = toJsonValue(m_controllingUserId); + result["Command"] = Jellyfin::Support::toJsonValue(m_command); + result["SeekPositionTicks"] = Jellyfin::Support::toJsonValue(m_seekPositionTicks); + result["ControllingUserId"] = Jellyfin::Support::toJsonValue(m_controllingUserId); return result; } @@ -72,6 +73,17 @@ void PlaystateRequest::setControllingUserId(QString newControllingUserId) { m_controllingUserId = newControllingUserId; } +} // NS DTO + +namespace Support { + +using PlaystateRequest = Jellyfin::DTO::PlaystateRequest; + +template <> +PlaystateRequest fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return PlaystateRequest::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/plugininfo.cpp b/core/src/DTO/plugininfo.cpp index ec9fa03..b6e365c 100644 --- a/core/src/DTO/plugininfo.cpp +++ b/core/src/DTO/plugininfo.cpp @@ -32,36 +32,37 @@ namespace Jellyfin { namespace DTO { -PluginInfo::PluginInfo(QObject *parent) {} +PluginInfo::PluginInfo() {} -PluginInfo PluginInfo::fromJson(QJsonObject source) {PluginInfo instance; - instance->setFromJson(source, false); +PluginInfo PluginInfo::fromJson(QJsonObject source) { + PluginInfo instance; + instance.setFromJson(source); return instance; } void PluginInfo::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_version = fromJsonValue>(source["Version"]); - m_configurationFileName = fromJsonValue(source["ConfigurationFileName"]); - m_description = fromJsonValue(source["Description"]); - m_jellyfinId = fromJsonValue(source["Id"]); - m_canUninstall = fromJsonValue(source["CanUninstall"]); - m_hasImage = fromJsonValue(source["HasImage"]); - m_status = fromJsonValue(source["Status"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_version = Jellyfin::Support::fromJsonValue>(source["Version"]); + m_configurationFileName = Jellyfin::Support::fromJsonValue(source["ConfigurationFileName"]); + m_description = Jellyfin::Support::fromJsonValue(source["Description"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); + m_canUninstall = Jellyfin::Support::fromJsonValue(source["CanUninstall"]); + m_hasImage = Jellyfin::Support::fromJsonValue(source["HasImage"]); + m_status = Jellyfin::Support::fromJsonValue(source["Status"]); } QJsonObject PluginInfo::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Version"] = toJsonValue>(m_version); - result["ConfigurationFileName"] = toJsonValue(m_configurationFileName); - result["Description"] = toJsonValue(m_description); - result["Id"] = toJsonValue(m_jellyfinId); - result["CanUninstall"] = toJsonValue(m_canUninstall); - result["HasImage"] = toJsonValue(m_hasImage); - result["Status"] = toJsonValue(m_status); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Version"] = Jellyfin::Support::toJsonValue>(m_version); + result["ConfigurationFileName"] = Jellyfin::Support::toJsonValue(m_configurationFileName); + result["Description"] = Jellyfin::Support::toJsonValue(m_description); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["CanUninstall"] = Jellyfin::Support::toJsonValue(m_canUninstall); + result["HasImage"] = Jellyfin::Support::toJsonValue(m_hasImage); + result["Status"] = Jellyfin::Support::toJsonValue(m_status); return result; } @@ -107,6 +108,17 @@ void PluginInfo::setStatus(PluginStatus newStatus) { m_status = newStatus; } +} // NS DTO + +namespace Support { + +using PluginInfo = Jellyfin::DTO::PluginInfo; + +template <> +PluginInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return PluginInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/pluginsecurityinfo.cpp b/core/src/DTO/pluginsecurityinfo.cpp index 6afed1e..6ccb238 100644 --- a/core/src/DTO/pluginsecurityinfo.cpp +++ b/core/src/DTO/pluginsecurityinfo.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -PluginSecurityInfo::PluginSecurityInfo(QObject *parent) {} +PluginSecurityInfo::PluginSecurityInfo() {} -PluginSecurityInfo PluginSecurityInfo::fromJson(QJsonObject source) {PluginSecurityInfo instance; - instance->setFromJson(source, false); +PluginSecurityInfo PluginSecurityInfo::fromJson(QJsonObject source) { + PluginSecurityInfo instance; + instance.setFromJson(source); return instance; } void PluginSecurityInfo::setFromJson(QJsonObject source) { - m_supporterKey = fromJsonValue(source["SupporterKey"]); - m_isMbSupporter = fromJsonValue(source["IsMbSupporter"]); + m_supporterKey = Jellyfin::Support::fromJsonValue(source["SupporterKey"]); + m_isMbSupporter = Jellyfin::Support::fromJsonValue(source["IsMbSupporter"]); } QJsonObject PluginSecurityInfo::toJson() { QJsonObject result; - result["SupporterKey"] = toJsonValue(m_supporterKey); - result["IsMbSupporter"] = toJsonValue(m_isMbSupporter); + result["SupporterKey"] = Jellyfin::Support::toJsonValue(m_supporterKey); + result["IsMbSupporter"] = Jellyfin::Support::toJsonValue(m_isMbSupporter); return result; } @@ -65,6 +66,17 @@ void PluginSecurityInfo::setIsMbSupporter(bool newIsMbSupporter) { m_isMbSupporter = newIsMbSupporter; } +} // NS DTO + +namespace Support { + +using PluginSecurityInfo = Jellyfin::DTO::PluginSecurityInfo; + +template <> +PluginSecurityInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return PluginSecurityInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/pluginstatus.cpp b/core/src/DTO/pluginstatus.cpp index ac0681d..777c1bf 100644 --- a/core/src/DTO/pluginstatus.cpp +++ b/core/src/DTO/pluginstatus.cpp @@ -34,5 +34,42 @@ namespace DTO { PluginStatusClass::PluginStatusClass() {} + +} // NS DTO + +namespace Support { + +using PluginStatus = Jellyfin::DTO::PluginStatus; + +template <> +PluginStatus fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return PluginStatus::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Active")) { + return PluginStatus::Active; + } + if (str == QStringLiteral("Restart")) { + return PluginStatus::Restart; + } + if (str == QStringLiteral("Deleted")) { + return PluginStatus::Deleted; + } + if (str == QStringLiteral("Superceded")) { + return PluginStatus::Superceded; + } + if (str == QStringLiteral("Malfunctioned")) { + return PluginStatus::Malfunctioned; + } + if (str == QStringLiteral("NotSupported")) { + return PluginStatus::NotSupported; + } + if (str == QStringLiteral("Disabled")) { + return PluginStatus::Disabled; + } + + return PluginStatus::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/previousitemrequestdto.cpp b/core/src/DTO/previousitemrequestdto.cpp index c04eb61..5012706 100644 --- a/core/src/DTO/previousitemrequestdto.cpp +++ b/core/src/DTO/previousitemrequestdto.cpp @@ -32,22 +32,23 @@ namespace Jellyfin { namespace DTO { -PreviousItemRequestDto::PreviousItemRequestDto(QObject *parent) {} +PreviousItemRequestDto::PreviousItemRequestDto() {} -PreviousItemRequestDto PreviousItemRequestDto::fromJson(QJsonObject source) {PreviousItemRequestDto instance; - instance->setFromJson(source, false); +PreviousItemRequestDto PreviousItemRequestDto::fromJson(QJsonObject source) { + PreviousItemRequestDto instance; + instance.setFromJson(source); return instance; } void PreviousItemRequestDto::setFromJson(QJsonObject source) { - m_playlistItemId = fromJsonValue(source["PlaylistItemId"]); + m_playlistItemId = Jellyfin::Support::fromJsonValue(source["PlaylistItemId"]); } QJsonObject PreviousItemRequestDto::toJson() { QJsonObject result; - result["PlaylistItemId"] = toJsonValue(m_playlistItemId); + result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); return result; } @@ -58,6 +59,17 @@ void PreviousItemRequestDto::setPlaylistItemId(QUuid newPlaylistItemId) { m_playlistItemId = newPlaylistItemId; } +} // NS DTO + +namespace Support { + +using PreviousItemRequestDto = Jellyfin::DTO::PreviousItemRequestDto; + +template <> +PreviousItemRequestDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return PreviousItemRequestDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/problemdetails.cpp b/core/src/DTO/problemdetails.cpp index 4011693..8f4d4b6 100644 --- a/core/src/DTO/problemdetails.cpp +++ b/core/src/DTO/problemdetails.cpp @@ -32,30 +32,31 @@ namespace Jellyfin { namespace DTO { -ProblemDetails::ProblemDetails(QObject *parent) {} +ProblemDetails::ProblemDetails() {} -ProblemDetails ProblemDetails::fromJson(QJsonObject source) {ProblemDetails instance; - instance->setFromJson(source, false); +ProblemDetails ProblemDetails::fromJson(QJsonObject source) { + ProblemDetails instance; + instance.setFromJson(source); return instance; } void ProblemDetails::setFromJson(QJsonObject source) { - m_type = fromJsonValue(source["type"]); - m_title = fromJsonValue(source["title"]); - m_status = fromJsonValue(source["status"]); - m_detail = fromJsonValue(source["detail"]); - m_instance = fromJsonValue(source["instance"]); + m_type = Jellyfin::Support::fromJsonValue(source["type"]); + m_title = Jellyfin::Support::fromJsonValue(source["title"]); + m_status = Jellyfin::Support::fromJsonValue(source["status"]); + m_detail = Jellyfin::Support::fromJsonValue(source["detail"]); + m_instance = Jellyfin::Support::fromJsonValue(source["instance"]); } QJsonObject ProblemDetails::toJson() { QJsonObject result; - result["type"] = toJsonValue(m_type); - result["title"] = toJsonValue(m_title); - result["status"] = toJsonValue(m_status); - result["detail"] = toJsonValue(m_detail); - result["instance"] = toJsonValue(m_instance); + result["type"] = Jellyfin::Support::toJsonValue(m_type); + result["title"] = Jellyfin::Support::toJsonValue(m_title); + result["status"] = Jellyfin::Support::toJsonValue(m_status); + result["detail"] = Jellyfin::Support::toJsonValue(m_detail); + result["instance"] = Jellyfin::Support::toJsonValue(m_instance); return result; } @@ -86,6 +87,17 @@ void ProblemDetails::setInstance(QString newInstance) { m_instance = newInstance; } +} // NS DTO + +namespace Support { + +using ProblemDetails = Jellyfin::DTO::ProblemDetails; + +template <> +ProblemDetails fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ProblemDetails::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/profilecondition.cpp b/core/src/DTO/profilecondition.cpp index d245cdc..260a28d 100644 --- a/core/src/DTO/profilecondition.cpp +++ b/core/src/DTO/profilecondition.cpp @@ -32,28 +32,29 @@ namespace Jellyfin { namespace DTO { -ProfileCondition::ProfileCondition(QObject *parent) {} +ProfileCondition::ProfileCondition() {} -ProfileCondition ProfileCondition::fromJson(QJsonObject source) {ProfileCondition instance; - instance->setFromJson(source, false); +ProfileCondition ProfileCondition::fromJson(QJsonObject source) { + ProfileCondition instance; + instance.setFromJson(source); return instance; } void ProfileCondition::setFromJson(QJsonObject source) { - m_condition = fromJsonValue(source["Condition"]); - m_property = fromJsonValue(source["Property"]); - m_value = fromJsonValue(source["Value"]); - m_isRequired = fromJsonValue(source["IsRequired"]); + m_condition = Jellyfin::Support::fromJsonValue(source["Condition"]); + m_property = Jellyfin::Support::fromJsonValue(source["Property"]); + m_value = Jellyfin::Support::fromJsonValue(source["Value"]); + m_isRequired = Jellyfin::Support::fromJsonValue(source["IsRequired"]); } QJsonObject ProfileCondition::toJson() { QJsonObject result; - result["Condition"] = toJsonValue(m_condition); - result["Property"] = toJsonValue(m_property); - result["Value"] = toJsonValue(m_value); - result["IsRequired"] = toJsonValue(m_isRequired); + result["Condition"] = Jellyfin::Support::toJsonValue(m_condition); + result["Property"] = Jellyfin::Support::toJsonValue(m_property); + result["Value"] = Jellyfin::Support::toJsonValue(m_value); + result["IsRequired"] = Jellyfin::Support::toJsonValue(m_isRequired); return result; } @@ -79,6 +80,17 @@ void ProfileCondition::setIsRequired(bool newIsRequired) { m_isRequired = newIsRequired; } +} // NS DTO + +namespace Support { + +using ProfileCondition = Jellyfin::DTO::ProfileCondition; + +template <> +ProfileCondition fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ProfileCondition::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/profileconditiontype.cpp b/core/src/DTO/profileconditiontype.cpp index 609219f..2bc5473 100644 --- a/core/src/DTO/profileconditiontype.cpp +++ b/core/src/DTO/profileconditiontype.cpp @@ -34,5 +34,36 @@ namespace DTO { ProfileConditionTypeClass::ProfileConditionTypeClass() {} + +} // NS DTO + +namespace Support { + +using ProfileConditionType = Jellyfin::DTO::ProfileConditionType; + +template <> +ProfileConditionType fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return ProfileConditionType::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Equals")) { + return ProfileConditionType::Equals; + } + if (str == QStringLiteral("NotEquals")) { + return ProfileConditionType::NotEquals; + } + if (str == QStringLiteral("LessThanEqual")) { + return ProfileConditionType::LessThanEqual; + } + if (str == QStringLiteral("GreaterThanEqual")) { + return ProfileConditionType::GreaterThanEqual; + } + if (str == QStringLiteral("EqualsAny")) { + return ProfileConditionType::EqualsAny; + } + + return ProfileConditionType::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/profileconditionvalue.cpp b/core/src/DTO/profileconditionvalue.cpp index dd9729e..f5acbfe 100644 --- a/core/src/DTO/profileconditionvalue.cpp +++ b/core/src/DTO/profileconditionvalue.cpp @@ -34,5 +34,90 @@ namespace DTO { ProfileConditionValueClass::ProfileConditionValueClass() {} + +} // NS DTO + +namespace Support { + +using ProfileConditionValue = Jellyfin::DTO::ProfileConditionValue; + +template <> +ProfileConditionValue fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return ProfileConditionValue::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("AudioChannels")) { + return ProfileConditionValue::AudioChannels; + } + if (str == QStringLiteral("AudioBitrate")) { + return ProfileConditionValue::AudioBitrate; + } + if (str == QStringLiteral("AudioProfile")) { + return ProfileConditionValue::AudioProfile; + } + if (str == QStringLiteral("Width")) { + return ProfileConditionValue::Width; + } + if (str == QStringLiteral("Height")) { + return ProfileConditionValue::Height; + } + if (str == QStringLiteral("Has64BitOffsets")) { + return ProfileConditionValue::Has64BitOffsets; + } + if (str == QStringLiteral("PacketLength")) { + return ProfileConditionValue::PacketLength; + } + if (str == QStringLiteral("VideoBitDepth")) { + return ProfileConditionValue::VideoBitDepth; + } + if (str == QStringLiteral("VideoBitrate")) { + return ProfileConditionValue::VideoBitrate; + } + if (str == QStringLiteral("VideoFramerate")) { + return ProfileConditionValue::VideoFramerate; + } + if (str == QStringLiteral("VideoLevel")) { + return ProfileConditionValue::VideoLevel; + } + if (str == QStringLiteral("VideoProfile")) { + return ProfileConditionValue::VideoProfile; + } + if (str == QStringLiteral("VideoTimestamp")) { + return ProfileConditionValue::VideoTimestamp; + } + if (str == QStringLiteral("IsAnamorphic")) { + return ProfileConditionValue::IsAnamorphic; + } + if (str == QStringLiteral("RefFrames")) { + return ProfileConditionValue::RefFrames; + } + if (str == QStringLiteral("NumAudioStreams")) { + return ProfileConditionValue::NumAudioStreams; + } + if (str == QStringLiteral("NumVideoStreams")) { + return ProfileConditionValue::NumVideoStreams; + } + if (str == QStringLiteral("IsSecondaryAudio")) { + return ProfileConditionValue::IsSecondaryAudio; + } + if (str == QStringLiteral("VideoCodecTag")) { + return ProfileConditionValue::VideoCodecTag; + } + if (str == QStringLiteral("IsAvc")) { + return ProfileConditionValue::IsAvc; + } + if (str == QStringLiteral("IsInterlaced")) { + return ProfileConditionValue::IsInterlaced; + } + if (str == QStringLiteral("AudioSampleRate")) { + return ProfileConditionValue::AudioSampleRate; + } + if (str == QStringLiteral("AudioBitDepth")) { + return ProfileConditionValue::AudioBitDepth; + } + + return ProfileConditionValue::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/programaudio.cpp b/core/src/DTO/programaudio.cpp index cb276fe..15506f9 100644 --- a/core/src/DTO/programaudio.cpp +++ b/core/src/DTO/programaudio.cpp @@ -34,5 +34,39 @@ namespace DTO { ProgramAudioClass::ProgramAudioClass() {} + +} // NS DTO + +namespace Support { + +using ProgramAudio = Jellyfin::DTO::ProgramAudio; + +template <> +ProgramAudio fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return ProgramAudio::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Mono")) { + return ProgramAudio::Mono; + } + if (str == QStringLiteral("Stereo")) { + return ProgramAudio::Stereo; + } + if (str == QStringLiteral("Dolby")) { + return ProgramAudio::Dolby; + } + if (str == QStringLiteral("DolbyDigital")) { + return ProgramAudio::DolbyDigital; + } + if (str == QStringLiteral("Thx")) { + return ProgramAudio::Thx; + } + if (str == QStringLiteral("Atmos")) { + return ProgramAudio::Atmos; + } + + return ProgramAudio::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/publicsysteminfo.cpp b/core/src/DTO/publicsysteminfo.cpp index 43f9a96..921ebe4 100644 --- a/core/src/DTO/publicsysteminfo.cpp +++ b/core/src/DTO/publicsysteminfo.cpp @@ -32,34 +32,35 @@ namespace Jellyfin { namespace DTO { -PublicSystemInfo::PublicSystemInfo(QObject *parent) {} +PublicSystemInfo::PublicSystemInfo() {} -PublicSystemInfo PublicSystemInfo::fromJson(QJsonObject source) {PublicSystemInfo instance; - instance->setFromJson(source, false); +PublicSystemInfo PublicSystemInfo::fromJson(QJsonObject source) { + PublicSystemInfo instance; + instance.setFromJson(source); return instance; } void PublicSystemInfo::setFromJson(QJsonObject source) { - m_localAddress = fromJsonValue(source["LocalAddress"]); - m_serverName = fromJsonValue(source["ServerName"]); - m_version = fromJsonValue(source["Version"]); - m_productName = fromJsonValue(source["ProductName"]); - m_operatingSystem = fromJsonValue(source["OperatingSystem"]); - m_jellyfinId = fromJsonValue(source["Id"]); - m_startupWizardCompleted = fromJsonValue(source["StartupWizardCompleted"]); + m_localAddress = Jellyfin::Support::fromJsonValue(source["LocalAddress"]); + m_serverName = Jellyfin::Support::fromJsonValue(source["ServerName"]); + m_version = Jellyfin::Support::fromJsonValue(source["Version"]); + m_productName = Jellyfin::Support::fromJsonValue(source["ProductName"]); + m_operatingSystem = Jellyfin::Support::fromJsonValue(source["OperatingSystem"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); + m_startupWizardCompleted = Jellyfin::Support::fromJsonValue(source["StartupWizardCompleted"]); } QJsonObject PublicSystemInfo::toJson() { QJsonObject result; - result["LocalAddress"] = toJsonValue(m_localAddress); - result["ServerName"] = toJsonValue(m_serverName); - result["Version"] = toJsonValue(m_version); - result["ProductName"] = toJsonValue(m_productName); - result["OperatingSystem"] = toJsonValue(m_operatingSystem); - result["Id"] = toJsonValue(m_jellyfinId); - result["StartupWizardCompleted"] = toJsonValue(m_startupWizardCompleted); + result["LocalAddress"] = Jellyfin::Support::toJsonValue(m_localAddress); + result["ServerName"] = Jellyfin::Support::toJsonValue(m_serverName); + result["Version"] = Jellyfin::Support::toJsonValue(m_version); + result["ProductName"] = Jellyfin::Support::toJsonValue(m_productName); + result["OperatingSystem"] = Jellyfin::Support::toJsonValue(m_operatingSystem); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["StartupWizardCompleted"] = Jellyfin::Support::toJsonValue(m_startupWizardCompleted); return result; } @@ -100,6 +101,17 @@ void PublicSystemInfo::setStartupWizardCompleted(bool newStartupWizardCompleted) m_startupWizardCompleted = newStartupWizardCompleted; } +} // NS DTO + +namespace Support { + +using PublicSystemInfo = Jellyfin::DTO::PublicSystemInfo; + +template <> +PublicSystemInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return PublicSystemInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/queryfilters.cpp b/core/src/DTO/queryfilters.cpp index 4d8d48f..deb5919 100644 --- a/core/src/DTO/queryfilters.cpp +++ b/core/src/DTO/queryfilters.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -QueryFilters::QueryFilters(QObject *parent) {} +QueryFilters::QueryFilters() {} -QueryFilters QueryFilters::fromJson(QJsonObject source) {QueryFilters instance; - instance->setFromJson(source, false); +QueryFilters QueryFilters::fromJson(QJsonObject source) { + QueryFilters instance; + instance.setFromJson(source); return instance; } void QueryFilters::setFromJson(QJsonObject source) { - m_genres = fromJsonValue>>(source["Genres"]); - m_tags = fromJsonValue(source["Tags"]); + m_genres = Jellyfin::Support::fromJsonValue>>(source["Genres"]); + m_tags = Jellyfin::Support::fromJsonValue(source["Tags"]); } QJsonObject QueryFilters::toJson() { QJsonObject result; - result["Genres"] = toJsonValue>>(m_genres); - result["Tags"] = toJsonValue(m_tags); + result["Genres"] = Jellyfin::Support::toJsonValue>>(m_genres); + result["Tags"] = Jellyfin::Support::toJsonValue(m_tags); return result; } @@ -65,6 +66,17 @@ void QueryFilters::setTags(QStringList newTags) { m_tags = newTags; } +} // NS DTO + +namespace Support { + +using QueryFilters = Jellyfin::DTO::QueryFilters; + +template <> +QueryFilters fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return QueryFilters::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/queryfilterslegacy.cpp b/core/src/DTO/queryfilterslegacy.cpp index db93d6d..8a68133 100644 --- a/core/src/DTO/queryfilterslegacy.cpp +++ b/core/src/DTO/queryfilterslegacy.cpp @@ -32,28 +32,29 @@ namespace Jellyfin { namespace DTO { -QueryFiltersLegacy::QueryFiltersLegacy(QObject *parent) {} +QueryFiltersLegacy::QueryFiltersLegacy() {} -QueryFiltersLegacy QueryFiltersLegacy::fromJson(QJsonObject source) {QueryFiltersLegacy instance; - instance->setFromJson(source, false); +QueryFiltersLegacy QueryFiltersLegacy::fromJson(QJsonObject source) { + QueryFiltersLegacy instance; + instance.setFromJson(source); return instance; } void QueryFiltersLegacy::setFromJson(QJsonObject source) { - m_genres = fromJsonValue(source["Genres"]); - m_tags = fromJsonValue(source["Tags"]); - m_officialRatings = fromJsonValue(source["OfficialRatings"]); - m_years = fromJsonValue>(source["Years"]); + m_genres = Jellyfin::Support::fromJsonValue(source["Genres"]); + m_tags = Jellyfin::Support::fromJsonValue(source["Tags"]); + m_officialRatings = Jellyfin::Support::fromJsonValue(source["OfficialRatings"]); + m_years = Jellyfin::Support::fromJsonValue>(source["Years"]); } QJsonObject QueryFiltersLegacy::toJson() { QJsonObject result; - result["Genres"] = toJsonValue(m_genres); - result["Tags"] = toJsonValue(m_tags); - result["OfficialRatings"] = toJsonValue(m_officialRatings); - result["Years"] = toJsonValue>(m_years); + result["Genres"] = Jellyfin::Support::toJsonValue(m_genres); + result["Tags"] = Jellyfin::Support::toJsonValue(m_tags); + result["OfficialRatings"] = Jellyfin::Support::toJsonValue(m_officialRatings); + result["Years"] = Jellyfin::Support::toJsonValue>(m_years); return result; } @@ -79,6 +80,17 @@ void QueryFiltersLegacy::setYears(QList newYears) { m_years = newYears; } +} // NS DTO + +namespace Support { + +using QueryFiltersLegacy = Jellyfin::DTO::QueryFiltersLegacy; + +template <> +QueryFiltersLegacy fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return QueryFiltersLegacy::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/queueitem.cpp b/core/src/DTO/queueitem.cpp index 9392826..4ebc66c 100644 --- a/core/src/DTO/queueitem.cpp +++ b/core/src/DTO/queueitem.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -QueueItem::QueueItem(QObject *parent) {} +QueueItem::QueueItem() {} -QueueItem QueueItem::fromJson(QJsonObject source) {QueueItem instance; - instance->setFromJson(source, false); +QueueItem QueueItem::fromJson(QJsonObject source) { + QueueItem instance; + instance.setFromJson(source); return instance; } void QueueItem::setFromJson(QJsonObject source) { - m_jellyfinId = fromJsonValue(source["Id"]); - m_playlistItemId = fromJsonValue(source["PlaylistItemId"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); + m_playlistItemId = Jellyfin::Support::fromJsonValue(source["PlaylistItemId"]); } QJsonObject QueueItem::toJson() { QJsonObject result; - result["Id"] = toJsonValue(m_jellyfinId); - result["PlaylistItemId"] = toJsonValue(m_playlistItemId); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); return result; } @@ -65,6 +66,17 @@ void QueueItem::setPlaylistItemId(QString newPlaylistItemId) { m_playlistItemId = newPlaylistItemId; } +} // NS DTO + +namespace Support { + +using QueueItem = Jellyfin::DTO::QueueItem; + +template <> +QueueItem fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return QueueItem::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/queuerequestdto.cpp b/core/src/DTO/queuerequestdto.cpp index 34b4668..574664c 100644 --- a/core/src/DTO/queuerequestdto.cpp +++ b/core/src/DTO/queuerequestdto.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -QueueRequestDto::QueueRequestDto(QObject *parent) {} +QueueRequestDto::QueueRequestDto() {} -QueueRequestDto QueueRequestDto::fromJson(QJsonObject source) {QueueRequestDto instance; - instance->setFromJson(source, false); +QueueRequestDto QueueRequestDto::fromJson(QJsonObject source) { + QueueRequestDto instance; + instance.setFromJson(source); return instance; } void QueueRequestDto::setFromJson(QJsonObject source) { - m_itemIds = fromJsonValue>(source["ItemIds"]); - m_mode = fromJsonValue(source["Mode"]); + m_itemIds = Jellyfin::Support::fromJsonValue>(source["ItemIds"]); + m_mode = Jellyfin::Support::fromJsonValue(source["Mode"]); } QJsonObject QueueRequestDto::toJson() { QJsonObject result; - result["ItemIds"] = toJsonValue>(m_itemIds); - result["Mode"] = toJsonValue(m_mode); + result["ItemIds"] = Jellyfin::Support::toJsonValue>(m_itemIds); + result["Mode"] = Jellyfin::Support::toJsonValue(m_mode); return result; } @@ -65,6 +66,17 @@ void QueueRequestDto::setMode(GroupQueueMode newMode) { m_mode = newMode; } +} // NS DTO + +namespace Support { + +using QueueRequestDto = Jellyfin::DTO::QueueRequestDto; + +template <> +QueueRequestDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return QueueRequestDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/quickconnectdto.cpp b/core/src/DTO/quickconnectdto.cpp index 305259b..b48561e 100644 --- a/core/src/DTO/quickconnectdto.cpp +++ b/core/src/DTO/quickconnectdto.cpp @@ -32,22 +32,23 @@ namespace Jellyfin { namespace DTO { -QuickConnectDto::QuickConnectDto(QObject *parent) {} +QuickConnectDto::QuickConnectDto() {} -QuickConnectDto QuickConnectDto::fromJson(QJsonObject source) {QuickConnectDto instance; - instance->setFromJson(source, false); +QuickConnectDto QuickConnectDto::fromJson(QJsonObject source) { + QuickConnectDto instance; + instance.setFromJson(source); return instance; } void QuickConnectDto::setFromJson(QJsonObject source) { - m_token = fromJsonValue(source["Token"]); + m_token = Jellyfin::Support::fromJsonValue(source["Token"]); } QJsonObject QuickConnectDto::toJson() { QJsonObject result; - result["Token"] = toJsonValue(m_token); + result["Token"] = Jellyfin::Support::toJsonValue(m_token); return result; } @@ -58,6 +59,17 @@ void QuickConnectDto::setToken(QString newToken) { m_token = newToken; } +} // NS DTO + +namespace Support { + +using QuickConnectDto = Jellyfin::DTO::QuickConnectDto; + +template <> +QuickConnectDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return QuickConnectDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/quickconnectresult.cpp b/core/src/DTO/quickconnectresult.cpp index 83dc0d0..50ee82a 100644 --- a/core/src/DTO/quickconnectresult.cpp +++ b/core/src/DTO/quickconnectresult.cpp @@ -32,32 +32,33 @@ namespace Jellyfin { namespace DTO { -QuickConnectResult::QuickConnectResult(QObject *parent) {} +QuickConnectResult::QuickConnectResult() {} -QuickConnectResult QuickConnectResult::fromJson(QJsonObject source) {QuickConnectResult instance; - instance->setFromJson(source, false); +QuickConnectResult QuickConnectResult::fromJson(QJsonObject source) { + QuickConnectResult instance; + instance.setFromJson(source); return instance; } void QuickConnectResult::setFromJson(QJsonObject source) { - m_authenticated = fromJsonValue(source["Authenticated"]); - m_secret = fromJsonValue(source["Secret"]); - m_code = fromJsonValue(source["Code"]); - m_authentication = fromJsonValue(source["Authentication"]); - m_error = fromJsonValue(source["Error"]); - m_dateAdded = fromJsonValue(source["DateAdded"]); + m_authenticated = Jellyfin::Support::fromJsonValue(source["Authenticated"]); + m_secret = Jellyfin::Support::fromJsonValue(source["Secret"]); + m_code = Jellyfin::Support::fromJsonValue(source["Code"]); + m_authentication = Jellyfin::Support::fromJsonValue(source["Authentication"]); + m_error = Jellyfin::Support::fromJsonValue(source["Error"]); + m_dateAdded = Jellyfin::Support::fromJsonValue(source["DateAdded"]); } QJsonObject QuickConnectResult::toJson() { QJsonObject result; - result["Authenticated"] = toJsonValue(m_authenticated); - result["Secret"] = toJsonValue(m_secret); - result["Code"] = toJsonValue(m_code); - result["Authentication"] = toJsonValue(m_authentication); - result["Error"] = toJsonValue(m_error); - result["DateAdded"] = toJsonValue(m_dateAdded); + result["Authenticated"] = Jellyfin::Support::toJsonValue(m_authenticated); + result["Secret"] = Jellyfin::Support::toJsonValue(m_secret); + result["Code"] = Jellyfin::Support::toJsonValue(m_code); + result["Authentication"] = Jellyfin::Support::toJsonValue(m_authentication); + result["Error"] = Jellyfin::Support::toJsonValue(m_error); + result["DateAdded"] = Jellyfin::Support::toJsonValue(m_dateAdded); return result; } @@ -93,6 +94,17 @@ void QuickConnectResult::setDateAdded(QDateTime newDateAdded) { m_dateAdded = newDateAdded; } +} // NS DTO + +namespace Support { + +using QuickConnectResult = Jellyfin::DTO::QuickConnectResult; + +template <> +QuickConnectResult fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return QuickConnectResult::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/quickconnectstate.cpp b/core/src/DTO/quickconnectstate.cpp index cdfcfed..df60a6d 100644 --- a/core/src/DTO/quickconnectstate.cpp +++ b/core/src/DTO/quickconnectstate.cpp @@ -34,5 +34,30 @@ namespace DTO { QuickConnectStateClass::QuickConnectStateClass() {} + +} // NS DTO + +namespace Support { + +using QuickConnectState = Jellyfin::DTO::QuickConnectState; + +template <> +QuickConnectState fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return QuickConnectState::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Unavailable")) { + return QuickConnectState::Unavailable; + } + if (str == QStringLiteral("Available")) { + return QuickConnectState::Available; + } + if (str == QStringLiteral("Active")) { + return QuickConnectState::Active; + } + + return QuickConnectState::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/ratingtype.cpp b/core/src/DTO/ratingtype.cpp index 4ddcf94..362baac 100644 --- a/core/src/DTO/ratingtype.cpp +++ b/core/src/DTO/ratingtype.cpp @@ -34,5 +34,27 @@ namespace DTO { RatingTypeClass::RatingTypeClass() {} + +} // NS DTO + +namespace Support { + +using RatingType = Jellyfin::DTO::RatingType; + +template <> +RatingType fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return RatingType::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Score")) { + return RatingType::Score; + } + if (str == QStringLiteral("Likes")) { + return RatingType::Likes; + } + + return RatingType::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/readyrequestdto.cpp b/core/src/DTO/readyrequestdto.cpp index 3e77102..5e146ef 100644 --- a/core/src/DTO/readyrequestdto.cpp +++ b/core/src/DTO/readyrequestdto.cpp @@ -32,28 +32,29 @@ namespace Jellyfin { namespace DTO { -ReadyRequestDto::ReadyRequestDto(QObject *parent) {} +ReadyRequestDto::ReadyRequestDto() {} -ReadyRequestDto ReadyRequestDto::fromJson(QJsonObject source) {ReadyRequestDto instance; - instance->setFromJson(source, false); +ReadyRequestDto ReadyRequestDto::fromJson(QJsonObject source) { + ReadyRequestDto instance; + instance.setFromJson(source); return instance; } void ReadyRequestDto::setFromJson(QJsonObject source) { - m_when = fromJsonValue(source["When"]); - m_positionTicks = fromJsonValue(source["PositionTicks"]); - m_isPlaying = fromJsonValue(source["IsPlaying"]); - m_playlistItemId = fromJsonValue(source["PlaylistItemId"]); + m_when = Jellyfin::Support::fromJsonValue(source["When"]); + m_positionTicks = Jellyfin::Support::fromJsonValue(source["PositionTicks"]); + m_isPlaying = Jellyfin::Support::fromJsonValue(source["IsPlaying"]); + m_playlistItemId = Jellyfin::Support::fromJsonValue(source["PlaylistItemId"]); } QJsonObject ReadyRequestDto::toJson() { QJsonObject result; - result["When"] = toJsonValue(m_when); - result["PositionTicks"] = toJsonValue(m_positionTicks); - result["IsPlaying"] = toJsonValue(m_isPlaying); - result["PlaylistItemId"] = toJsonValue(m_playlistItemId); + result["When"] = Jellyfin::Support::toJsonValue(m_when); + result["PositionTicks"] = Jellyfin::Support::toJsonValue(m_positionTicks); + result["IsPlaying"] = Jellyfin::Support::toJsonValue(m_isPlaying); + result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); return result; } @@ -79,6 +80,17 @@ void ReadyRequestDto::setPlaylistItemId(QUuid newPlaylistItemId) { m_playlistItemId = newPlaylistItemId; } +} // NS DTO + +namespace Support { + +using ReadyRequestDto = Jellyfin::DTO::ReadyRequestDto; + +template <> +ReadyRequestDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ReadyRequestDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/recommendationdto.cpp b/core/src/DTO/recommendationdto.cpp index a0b68c3..16427c8 100644 --- a/core/src/DTO/recommendationdto.cpp +++ b/core/src/DTO/recommendationdto.cpp @@ -32,28 +32,29 @@ namespace Jellyfin { namespace DTO { -RecommendationDto::RecommendationDto(QObject *parent) {} +RecommendationDto::RecommendationDto() {} -RecommendationDto RecommendationDto::fromJson(QJsonObject source) {RecommendationDto instance; - instance->setFromJson(source, false); +RecommendationDto RecommendationDto::fromJson(QJsonObject source) { + RecommendationDto instance; + instance.setFromJson(source); return instance; } void RecommendationDto::setFromJson(QJsonObject source) { - m_items = fromJsonValue>>(source["Items"]); - m_recommendationType = fromJsonValue(source["RecommendationType"]); - m_baselineItemName = fromJsonValue(source["BaselineItemName"]); - m_categoryId = fromJsonValue(source["CategoryId"]); + m_items = Jellyfin::Support::fromJsonValue>>(source["Items"]); + m_recommendationType = Jellyfin::Support::fromJsonValue(source["RecommendationType"]); + m_baselineItemName = Jellyfin::Support::fromJsonValue(source["BaselineItemName"]); + m_categoryId = Jellyfin::Support::fromJsonValue(source["CategoryId"]); } QJsonObject RecommendationDto::toJson() { QJsonObject result; - result["Items"] = toJsonValue>>(m_items); - result["RecommendationType"] = toJsonValue(m_recommendationType); - result["BaselineItemName"] = toJsonValue(m_baselineItemName); - result["CategoryId"] = toJsonValue(m_categoryId); + result["Items"] = Jellyfin::Support::toJsonValue>>(m_items); + result["RecommendationType"] = Jellyfin::Support::toJsonValue(m_recommendationType); + result["BaselineItemName"] = Jellyfin::Support::toJsonValue(m_baselineItemName); + result["CategoryId"] = Jellyfin::Support::toJsonValue(m_categoryId); return result; } @@ -79,6 +80,17 @@ void RecommendationDto::setCategoryId(QUuid newCategoryId) { m_categoryId = newCategoryId; } +} // NS DTO + +namespace Support { + +using RecommendationDto = Jellyfin::DTO::RecommendationDto; + +template <> +RecommendationDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return RecommendationDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/recommendationtype.cpp b/core/src/DTO/recommendationtype.cpp index 02be660..46f855a 100644 --- a/core/src/DTO/recommendationtype.cpp +++ b/core/src/DTO/recommendationtype.cpp @@ -34,5 +34,39 @@ namespace DTO { RecommendationTypeClass::RecommendationTypeClass() {} + +} // NS DTO + +namespace Support { + +using RecommendationType = Jellyfin::DTO::RecommendationType; + +template <> +RecommendationType fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return RecommendationType::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("SimilarToRecentlyPlayed")) { + return RecommendationType::SimilarToRecentlyPlayed; + } + if (str == QStringLiteral("SimilarToLikedItem")) { + return RecommendationType::SimilarToLikedItem; + } + if (str == QStringLiteral("HasDirectorFromRecentlyPlayed")) { + return RecommendationType::HasDirectorFromRecentlyPlayed; + } + if (str == QStringLiteral("HasActorFromRecentlyPlayed")) { + return RecommendationType::HasActorFromRecentlyPlayed; + } + if (str == QStringLiteral("HasLikedDirector")) { + return RecommendationType::HasLikedDirector; + } + if (str == QStringLiteral("HasLikedActor")) { + return RecommendationType::HasLikedActor; + } + + return RecommendationType::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/recordingstatus.cpp b/core/src/DTO/recordingstatus.cpp index 690d05e..a977cc5 100644 --- a/core/src/DTO/recordingstatus.cpp +++ b/core/src/DTO/recordingstatus.cpp @@ -34,5 +34,42 @@ namespace DTO { RecordingStatusClass::RecordingStatusClass() {} + +} // NS DTO + +namespace Support { + +using RecordingStatus = Jellyfin::DTO::RecordingStatus; + +template <> +RecordingStatus fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return RecordingStatus::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("New")) { + return RecordingStatus::New; + } + if (str == QStringLiteral("InProgress")) { + return RecordingStatus::InProgress; + } + if (str == QStringLiteral("Completed")) { + return RecordingStatus::Completed; + } + if (str == QStringLiteral("Cancelled")) { + return RecordingStatus::Cancelled; + } + if (str == QStringLiteral("ConflictedOk")) { + return RecordingStatus::ConflictedOk; + } + if (str == QStringLiteral("ConflictedNotOk")) { + return RecordingStatus::ConflictedNotOk; + } + if (str == QStringLiteral("Error")) { + return RecordingStatus::Error; + } + + return RecordingStatus::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/remoteimageinfo.cpp b/core/src/DTO/remoteimageinfo.cpp index 519360a..17a5f44 100644 --- a/core/src/DTO/remoteimageinfo.cpp +++ b/core/src/DTO/remoteimageinfo.cpp @@ -32,40 +32,41 @@ namespace Jellyfin { namespace DTO { -RemoteImageInfo::RemoteImageInfo(QObject *parent) {} +RemoteImageInfo::RemoteImageInfo() {} -RemoteImageInfo RemoteImageInfo::fromJson(QJsonObject source) {RemoteImageInfo instance; - instance->setFromJson(source, false); +RemoteImageInfo RemoteImageInfo::fromJson(QJsonObject source) { + RemoteImageInfo instance; + instance.setFromJson(source); return instance; } void RemoteImageInfo::setFromJson(QJsonObject source) { - m_providerName = fromJsonValue(source["ProviderName"]); - m_url = fromJsonValue(source["Url"]); - m_thumbnailUrl = fromJsonValue(source["ThumbnailUrl"]); - m_height = fromJsonValue(source["Height"]); - m_width = fromJsonValue(source["Width"]); - m_communityRating = fromJsonValue(source["CommunityRating"]); - m_voteCount = fromJsonValue(source["VoteCount"]); - m_language = fromJsonValue(source["Language"]); - m_type = fromJsonValue(source["Type"]); - m_ratingType = fromJsonValue(source["RatingType"]); + m_providerName = Jellyfin::Support::fromJsonValue(source["ProviderName"]); + m_url = Jellyfin::Support::fromJsonValue(source["Url"]); + m_thumbnailUrl = Jellyfin::Support::fromJsonValue(source["ThumbnailUrl"]); + m_height = Jellyfin::Support::fromJsonValue(source["Height"]); + m_width = Jellyfin::Support::fromJsonValue(source["Width"]); + m_communityRating = Jellyfin::Support::fromJsonValue(source["CommunityRating"]); + m_voteCount = Jellyfin::Support::fromJsonValue(source["VoteCount"]); + m_language = Jellyfin::Support::fromJsonValue(source["Language"]); + m_type = Jellyfin::Support::fromJsonValue(source["Type"]); + m_ratingType = Jellyfin::Support::fromJsonValue(source["RatingType"]); } QJsonObject RemoteImageInfo::toJson() { QJsonObject result; - result["ProviderName"] = toJsonValue(m_providerName); - result["Url"] = toJsonValue(m_url); - result["ThumbnailUrl"] = toJsonValue(m_thumbnailUrl); - result["Height"] = toJsonValue(m_height); - result["Width"] = toJsonValue(m_width); - result["CommunityRating"] = toJsonValue(m_communityRating); - result["VoteCount"] = toJsonValue(m_voteCount); - result["Language"] = toJsonValue(m_language); - result["Type"] = toJsonValue(m_type); - result["RatingType"] = toJsonValue(m_ratingType); + result["ProviderName"] = Jellyfin::Support::toJsonValue(m_providerName); + result["Url"] = Jellyfin::Support::toJsonValue(m_url); + result["ThumbnailUrl"] = Jellyfin::Support::toJsonValue(m_thumbnailUrl); + result["Height"] = Jellyfin::Support::toJsonValue(m_height); + result["Width"] = Jellyfin::Support::toJsonValue(m_width); + result["CommunityRating"] = Jellyfin::Support::toJsonValue(m_communityRating); + result["VoteCount"] = Jellyfin::Support::toJsonValue(m_voteCount); + result["Language"] = Jellyfin::Support::toJsonValue(m_language); + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + result["RatingType"] = Jellyfin::Support::toJsonValue(m_ratingType); return result; } @@ -121,6 +122,17 @@ void RemoteImageInfo::setRatingType(RatingType newRatingType) { m_ratingType = newRatingType; } +} // NS DTO + +namespace Support { + +using RemoteImageInfo = Jellyfin::DTO::RemoteImageInfo; + +template <> +RemoteImageInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return RemoteImageInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/remoteimageresult.cpp b/core/src/DTO/remoteimageresult.cpp index dee7a6f..5d0ba88 100644 --- a/core/src/DTO/remoteimageresult.cpp +++ b/core/src/DTO/remoteimageresult.cpp @@ -32,26 +32,27 @@ namespace Jellyfin { namespace DTO { -RemoteImageResult::RemoteImageResult(QObject *parent) {} +RemoteImageResult::RemoteImageResult() {} -RemoteImageResult RemoteImageResult::fromJson(QJsonObject source) {RemoteImageResult instance; - instance->setFromJson(source, false); +RemoteImageResult RemoteImageResult::fromJson(QJsonObject source) { + RemoteImageResult instance; + instance.setFromJson(source); return instance; } void RemoteImageResult::setFromJson(QJsonObject source) { - m_images = fromJsonValue>>(source["Images"]); - m_totalRecordCount = fromJsonValue(source["TotalRecordCount"]); - m_providers = fromJsonValue(source["Providers"]); + m_images = Jellyfin::Support::fromJsonValue>>(source["Images"]); + m_totalRecordCount = Jellyfin::Support::fromJsonValue(source["TotalRecordCount"]); + m_providers = Jellyfin::Support::fromJsonValue(source["Providers"]); } QJsonObject RemoteImageResult::toJson() { QJsonObject result; - result["Images"] = toJsonValue>>(m_images); - result["TotalRecordCount"] = toJsonValue(m_totalRecordCount); - result["Providers"] = toJsonValue(m_providers); + result["Images"] = Jellyfin::Support::toJsonValue>>(m_images); + result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); + result["Providers"] = Jellyfin::Support::toJsonValue(m_providers); return result; } @@ -72,6 +73,17 @@ void RemoteImageResult::setProviders(QStringList newProviders) { m_providers = newProviders; } +} // NS DTO + +namespace Support { + +using RemoteImageResult = Jellyfin::DTO::RemoteImageResult; + +template <> +RemoteImageResult fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return RemoteImageResult::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/remotesearchresult.cpp b/core/src/DTO/remotesearchresult.cpp index 3f6f3a5..d884c7b 100644 --- a/core/src/DTO/remotesearchresult.cpp +++ b/core/src/DTO/remotesearchresult.cpp @@ -32,44 +32,45 @@ namespace Jellyfin { namespace DTO { -RemoteSearchResult::RemoteSearchResult(QObject *parent) {} +RemoteSearchResult::RemoteSearchResult() {} -RemoteSearchResult RemoteSearchResult::fromJson(QJsonObject source) {RemoteSearchResult instance; - instance->setFromJson(source, false); +RemoteSearchResult RemoteSearchResult::fromJson(QJsonObject source) { + RemoteSearchResult instance; + instance.setFromJson(source); return instance; } void RemoteSearchResult::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_providerIds = fromJsonValue(source["ProviderIds"]); - m_productionYear = fromJsonValue(source["ProductionYear"]); - m_indexNumber = fromJsonValue(source["IndexNumber"]); - m_indexNumberEnd = fromJsonValue(source["IndexNumberEnd"]); - m_parentIndexNumber = fromJsonValue(source["ParentIndexNumber"]); - m_premiereDate = fromJsonValue(source["PremiereDate"]); - m_imageUrl = fromJsonValue(source["ImageUrl"]); - m_searchProviderName = fromJsonValue(source["SearchProviderName"]); - m_overview = fromJsonValue(source["Overview"]); - m_albumArtist = fromJsonValue>(source["AlbumArtist"]); - m_artists = fromJsonValue>>(source["Artists"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_providerIds = Jellyfin::Support::fromJsonValue(source["ProviderIds"]); + m_productionYear = Jellyfin::Support::fromJsonValue(source["ProductionYear"]); + m_indexNumber = Jellyfin::Support::fromJsonValue(source["IndexNumber"]); + m_indexNumberEnd = Jellyfin::Support::fromJsonValue(source["IndexNumberEnd"]); + m_parentIndexNumber = Jellyfin::Support::fromJsonValue(source["ParentIndexNumber"]); + m_premiereDate = Jellyfin::Support::fromJsonValue(source["PremiereDate"]); + m_imageUrl = Jellyfin::Support::fromJsonValue(source["ImageUrl"]); + m_searchProviderName = Jellyfin::Support::fromJsonValue(source["SearchProviderName"]); + m_overview = Jellyfin::Support::fromJsonValue(source["Overview"]); + m_albumArtist = Jellyfin::Support::fromJsonValue>(source["AlbumArtist"]); + m_artists = Jellyfin::Support::fromJsonValue>>(source["Artists"]); } QJsonObject RemoteSearchResult::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["ProviderIds"] = toJsonValue(m_providerIds); - result["ProductionYear"] = toJsonValue(m_productionYear); - result["IndexNumber"] = toJsonValue(m_indexNumber); - result["IndexNumberEnd"] = toJsonValue(m_indexNumberEnd); - result["ParentIndexNumber"] = toJsonValue(m_parentIndexNumber); - result["PremiereDate"] = toJsonValue(m_premiereDate); - result["ImageUrl"] = toJsonValue(m_imageUrl); - result["SearchProviderName"] = toJsonValue(m_searchProviderName); - result["Overview"] = toJsonValue(m_overview); - result["AlbumArtist"] = toJsonValue>(m_albumArtist); - result["Artists"] = toJsonValue>>(m_artists); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); + result["ProductionYear"] = Jellyfin::Support::toJsonValue(m_productionYear); + result["IndexNumber"] = Jellyfin::Support::toJsonValue(m_indexNumber); + result["IndexNumberEnd"] = Jellyfin::Support::toJsonValue(m_indexNumberEnd); + result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue(m_parentIndexNumber); + result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); + result["ImageUrl"] = Jellyfin::Support::toJsonValue(m_imageUrl); + result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); + result["Overview"] = Jellyfin::Support::toJsonValue(m_overview); + result["AlbumArtist"] = Jellyfin::Support::toJsonValue>(m_albumArtist); + result["Artists"] = Jellyfin::Support::toJsonValue>>(m_artists); return result; } @@ -135,6 +136,17 @@ void RemoteSearchResult::setArtists(QList> ne m_artists = newArtists; } +} // NS DTO + +namespace Support { + +using RemoteSearchResult = Jellyfin::DTO::RemoteSearchResult; + +template <> +RemoteSearchResult fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return RemoteSearchResult::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/remotesubtitleinfo.cpp b/core/src/DTO/remotesubtitleinfo.cpp index 3e341c4..44b511a 100644 --- a/core/src/DTO/remotesubtitleinfo.cpp +++ b/core/src/DTO/remotesubtitleinfo.cpp @@ -32,42 +32,43 @@ namespace Jellyfin { namespace DTO { -RemoteSubtitleInfo::RemoteSubtitleInfo(QObject *parent) {} +RemoteSubtitleInfo::RemoteSubtitleInfo() {} -RemoteSubtitleInfo RemoteSubtitleInfo::fromJson(QJsonObject source) {RemoteSubtitleInfo instance; - instance->setFromJson(source, false); +RemoteSubtitleInfo RemoteSubtitleInfo::fromJson(QJsonObject source) { + RemoteSubtitleInfo instance; + instance.setFromJson(source); return instance; } void RemoteSubtitleInfo::setFromJson(QJsonObject source) { - m_threeLetterISOLanguageName = fromJsonValue(source["ThreeLetterISOLanguageName"]); - m_jellyfinId = fromJsonValue(source["Id"]); - m_providerName = fromJsonValue(source["ProviderName"]); - m_name = fromJsonValue(source["Name"]); - m_format = fromJsonValue(source["Format"]); - m_author = fromJsonValue(source["Author"]); - m_comment = fromJsonValue(source["Comment"]); - m_dateCreated = fromJsonValue(source["DateCreated"]); - m_communityRating = fromJsonValue(source["CommunityRating"]); - m_downloadCount = fromJsonValue(source["DownloadCount"]); - m_isHashMatch = fromJsonValue(source["IsHashMatch"]); + m_threeLetterISOLanguageName = Jellyfin::Support::fromJsonValue(source["ThreeLetterISOLanguageName"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); + m_providerName = Jellyfin::Support::fromJsonValue(source["ProviderName"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_format = Jellyfin::Support::fromJsonValue(source["Format"]); + m_author = Jellyfin::Support::fromJsonValue(source["Author"]); + m_comment = Jellyfin::Support::fromJsonValue(source["Comment"]); + m_dateCreated = Jellyfin::Support::fromJsonValue(source["DateCreated"]); + m_communityRating = Jellyfin::Support::fromJsonValue(source["CommunityRating"]); + m_downloadCount = Jellyfin::Support::fromJsonValue(source["DownloadCount"]); + m_isHashMatch = Jellyfin::Support::fromJsonValue(source["IsHashMatch"]); } QJsonObject RemoteSubtitleInfo::toJson() { QJsonObject result; - result["ThreeLetterISOLanguageName"] = toJsonValue(m_threeLetterISOLanguageName); - result["Id"] = toJsonValue(m_jellyfinId); - result["ProviderName"] = toJsonValue(m_providerName); - result["Name"] = toJsonValue(m_name); - result["Format"] = toJsonValue(m_format); - result["Author"] = toJsonValue(m_author); - result["Comment"] = toJsonValue(m_comment); - result["DateCreated"] = toJsonValue(m_dateCreated); - result["CommunityRating"] = toJsonValue(m_communityRating); - result["DownloadCount"] = toJsonValue(m_downloadCount); - result["IsHashMatch"] = toJsonValue(m_isHashMatch); + result["ThreeLetterISOLanguageName"] = Jellyfin::Support::toJsonValue(m_threeLetterISOLanguageName); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["ProviderName"] = Jellyfin::Support::toJsonValue(m_providerName); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Format"] = Jellyfin::Support::toJsonValue(m_format); + result["Author"] = Jellyfin::Support::toJsonValue(m_author); + result["Comment"] = Jellyfin::Support::toJsonValue(m_comment); + result["DateCreated"] = Jellyfin::Support::toJsonValue(m_dateCreated); + result["CommunityRating"] = Jellyfin::Support::toJsonValue(m_communityRating); + result["DownloadCount"] = Jellyfin::Support::toJsonValue(m_downloadCount); + result["IsHashMatch"] = Jellyfin::Support::toJsonValue(m_isHashMatch); return result; } @@ -128,6 +129,17 @@ void RemoteSubtitleInfo::setIsHashMatch(bool newIsHashMatch) { m_isHashMatch = newIsHashMatch; } +} // NS DTO + +namespace Support { + +using RemoteSubtitleInfo = Jellyfin::DTO::RemoteSubtitleInfo; + +template <> +RemoteSubtitleInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return RemoteSubtitleInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/removefromplaylistrequestdto.cpp b/core/src/DTO/removefromplaylistrequestdto.cpp index 6719b45..4f6c4a7 100644 --- a/core/src/DTO/removefromplaylistrequestdto.cpp +++ b/core/src/DTO/removefromplaylistrequestdto.cpp @@ -32,22 +32,23 @@ namespace Jellyfin { namespace DTO { -RemoveFromPlaylistRequestDto::RemoveFromPlaylistRequestDto(QObject *parent) {} +RemoveFromPlaylistRequestDto::RemoveFromPlaylistRequestDto() {} -RemoveFromPlaylistRequestDto RemoveFromPlaylistRequestDto::fromJson(QJsonObject source) {RemoveFromPlaylistRequestDto instance; - instance->setFromJson(source, false); +RemoveFromPlaylistRequestDto RemoveFromPlaylistRequestDto::fromJson(QJsonObject source) { + RemoveFromPlaylistRequestDto instance; + instance.setFromJson(source); return instance; } void RemoveFromPlaylistRequestDto::setFromJson(QJsonObject source) { - m_playlistItemIds = fromJsonValue>(source["PlaylistItemIds"]); + m_playlistItemIds = Jellyfin::Support::fromJsonValue>(source["PlaylistItemIds"]); } QJsonObject RemoveFromPlaylistRequestDto::toJson() { QJsonObject result; - result["PlaylistItemIds"] = toJsonValue>(m_playlistItemIds); + result["PlaylistItemIds"] = Jellyfin::Support::toJsonValue>(m_playlistItemIds); return result; } @@ -58,6 +59,17 @@ void RemoveFromPlaylistRequestDto::setPlaylistItemIds(QList newPlaylistIt m_playlistItemIds = newPlaylistItemIds; } +} // NS DTO + +namespace Support { + +using RemoveFromPlaylistRequestDto = Jellyfin::DTO::RemoveFromPlaylistRequestDto; + +template <> +RemoveFromPlaylistRequestDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return RemoveFromPlaylistRequestDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/repeatmode.cpp b/core/src/DTO/repeatmode.cpp index 595f763..eeaaa52 100644 --- a/core/src/DTO/repeatmode.cpp +++ b/core/src/DTO/repeatmode.cpp @@ -34,5 +34,30 @@ namespace DTO { RepeatModeClass::RepeatModeClass() {} + +} // NS DTO + +namespace Support { + +using RepeatMode = Jellyfin::DTO::RepeatMode; + +template <> +RepeatMode fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return RepeatMode::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("RepeatNone")) { + return RepeatMode::RepeatNone; + } + if (str == QStringLiteral("RepeatAll")) { + return RepeatMode::RepeatAll; + } + if (str == QStringLiteral("RepeatOne")) { + return RepeatMode::RepeatOne; + } + + return RepeatMode::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/repositoryinfo.cpp b/core/src/DTO/repositoryinfo.cpp index 01ed9ae..7045478 100644 --- a/core/src/DTO/repositoryinfo.cpp +++ b/core/src/DTO/repositoryinfo.cpp @@ -32,26 +32,27 @@ namespace Jellyfin { namespace DTO { -RepositoryInfo::RepositoryInfo(QObject *parent) {} +RepositoryInfo::RepositoryInfo() {} -RepositoryInfo RepositoryInfo::fromJson(QJsonObject source) {RepositoryInfo instance; - instance->setFromJson(source, false); +RepositoryInfo RepositoryInfo::fromJson(QJsonObject source) { + RepositoryInfo instance; + instance.setFromJson(source); return instance; } void RepositoryInfo::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_url = fromJsonValue(source["Url"]); - m_enabled = fromJsonValue(source["Enabled"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_url = Jellyfin::Support::fromJsonValue(source["Url"]); + m_enabled = Jellyfin::Support::fromJsonValue(source["Enabled"]); } QJsonObject RepositoryInfo::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Url"] = toJsonValue(m_url); - result["Enabled"] = toJsonValue(m_enabled); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Url"] = Jellyfin::Support::toJsonValue(m_url); + result["Enabled"] = Jellyfin::Support::toJsonValue(m_enabled); return result; } @@ -72,6 +73,17 @@ void RepositoryInfo::setEnabled(bool newEnabled) { m_enabled = newEnabled; } +} // NS DTO + +namespace Support { + +using RepositoryInfo = Jellyfin::DTO::RepositoryInfo; + +template <> +RepositoryInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return RepositoryInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/responseprofile.cpp b/core/src/DTO/responseprofile.cpp index dd761db..ccaacae 100644 --- a/core/src/DTO/responseprofile.cpp +++ b/core/src/DTO/responseprofile.cpp @@ -32,34 +32,35 @@ namespace Jellyfin { namespace DTO { -ResponseProfile::ResponseProfile(QObject *parent) {} +ResponseProfile::ResponseProfile() {} -ResponseProfile ResponseProfile::fromJson(QJsonObject source) {ResponseProfile instance; - instance->setFromJson(source, false); +ResponseProfile ResponseProfile::fromJson(QJsonObject source) { + ResponseProfile instance; + instance.setFromJson(source); return instance; } void ResponseProfile::setFromJson(QJsonObject source) { - m_container = fromJsonValue(source["Container"]); - m_audioCodec = fromJsonValue(source["AudioCodec"]); - m_videoCodec = fromJsonValue(source["VideoCodec"]); - m_type = fromJsonValue(source["Type"]); - m_orgPn = fromJsonValue(source["OrgPn"]); - m_mimeType = fromJsonValue(source["MimeType"]); - m_conditions = fromJsonValue>>(source["Conditions"]); + m_container = Jellyfin::Support::fromJsonValue(source["Container"]); + m_audioCodec = Jellyfin::Support::fromJsonValue(source["AudioCodec"]); + m_videoCodec = Jellyfin::Support::fromJsonValue(source["VideoCodec"]); + m_type = Jellyfin::Support::fromJsonValue(source["Type"]); + m_orgPn = Jellyfin::Support::fromJsonValue(source["OrgPn"]); + m_mimeType = Jellyfin::Support::fromJsonValue(source["MimeType"]); + m_conditions = Jellyfin::Support::fromJsonValue>>(source["Conditions"]); } QJsonObject ResponseProfile::toJson() { QJsonObject result; - result["Container"] = toJsonValue(m_container); - result["AudioCodec"] = toJsonValue(m_audioCodec); - result["VideoCodec"] = toJsonValue(m_videoCodec); - result["Type"] = toJsonValue(m_type); - result["OrgPn"] = toJsonValue(m_orgPn); - result["MimeType"] = toJsonValue(m_mimeType); - result["Conditions"] = toJsonValue>>(m_conditions); + result["Container"] = Jellyfin::Support::toJsonValue(m_container); + result["AudioCodec"] = Jellyfin::Support::toJsonValue(m_audioCodec); + result["VideoCodec"] = Jellyfin::Support::toJsonValue(m_videoCodec); + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + result["OrgPn"] = Jellyfin::Support::toJsonValue(m_orgPn); + result["MimeType"] = Jellyfin::Support::toJsonValue(m_mimeType); + result["Conditions"] = Jellyfin::Support::toJsonValue>>(m_conditions); return result; } @@ -100,6 +101,17 @@ void ResponseProfile::setConditions(QList> newC m_conditions = newConditions; } +} // NS DTO + +namespace Support { + +using ResponseProfile = Jellyfin::DTO::ResponseProfile; + +template <> +ResponseProfile fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ResponseProfile::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/scrolldirection.cpp b/core/src/DTO/scrolldirection.cpp index 893d2fa..f57bd6f 100644 --- a/core/src/DTO/scrolldirection.cpp +++ b/core/src/DTO/scrolldirection.cpp @@ -34,5 +34,27 @@ namespace DTO { ScrollDirectionClass::ScrollDirectionClass() {} + +} // NS DTO + +namespace Support { + +using ScrollDirection = Jellyfin::DTO::ScrollDirection; + +template <> +ScrollDirection fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return ScrollDirection::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Horizontal")) { + return ScrollDirection::Horizontal; + } + if (str == QStringLiteral("Vertical")) { + return ScrollDirection::Vertical; + } + + return ScrollDirection::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/searchhint.cpp b/core/src/DTO/searchhint.cpp index e414c5c..0a54134 100644 --- a/core/src/DTO/searchhint.cpp +++ b/core/src/DTO/searchhint.cpp @@ -32,78 +32,79 @@ namespace Jellyfin { namespace DTO { -SearchHint::SearchHint(QObject *parent) {} +SearchHint::SearchHint() {} -SearchHint SearchHint::fromJson(QJsonObject source) {SearchHint instance; - instance->setFromJson(source, false); +SearchHint SearchHint::fromJson(QJsonObject source) { + SearchHint instance; + instance.setFromJson(source); return instance; } void SearchHint::setFromJson(QJsonObject source) { - m_itemId = fromJsonValue(source["ItemId"]); - m_jellyfinId = fromJsonValue(source["Id"]); - m_name = fromJsonValue(source["Name"]); - m_matchedTerm = fromJsonValue(source["MatchedTerm"]); - m_indexNumber = fromJsonValue(source["IndexNumber"]); - m_productionYear = fromJsonValue(source["ProductionYear"]); - m_parentIndexNumber = fromJsonValue(source["ParentIndexNumber"]); - m_primaryImageTag = fromJsonValue(source["PrimaryImageTag"]); - m_thumbImageTag = fromJsonValue(source["ThumbImageTag"]); - m_thumbImageItemId = fromJsonValue(source["ThumbImageItemId"]); - m_backdropImageTag = fromJsonValue(source["BackdropImageTag"]); - m_backdropImageItemId = fromJsonValue(source["BackdropImageItemId"]); - m_type = fromJsonValue(source["Type"]); - m_isFolder = fromJsonValue(source["IsFolder"]); - m_runTimeTicks = fromJsonValue(source["RunTimeTicks"]); - m_mediaType = fromJsonValue(source["MediaType"]); - m_startDate = fromJsonValue(source["StartDate"]); - m_endDate = fromJsonValue(source["EndDate"]); - m_series = fromJsonValue(source["Series"]); - m_status = fromJsonValue(source["Status"]); - m_album = fromJsonValue(source["Album"]); - m_albumId = fromJsonValue(source["AlbumId"]); - m_albumArtist = fromJsonValue(source["AlbumArtist"]); - m_artists = fromJsonValue(source["Artists"]); - m_songCount = fromJsonValue(source["SongCount"]); - m_episodeCount = fromJsonValue(source["EpisodeCount"]); - m_channelId = fromJsonValue(source["ChannelId"]); - m_channelName = fromJsonValue(source["ChannelName"]); - m_primaryImageAspectRatio = fromJsonValue(source["PrimaryImageAspectRatio"]); + m_itemId = Jellyfin::Support::fromJsonValue(source["ItemId"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_matchedTerm = Jellyfin::Support::fromJsonValue(source["MatchedTerm"]); + m_indexNumber = Jellyfin::Support::fromJsonValue(source["IndexNumber"]); + m_productionYear = Jellyfin::Support::fromJsonValue(source["ProductionYear"]); + m_parentIndexNumber = Jellyfin::Support::fromJsonValue(source["ParentIndexNumber"]); + m_primaryImageTag = Jellyfin::Support::fromJsonValue(source["PrimaryImageTag"]); + m_thumbImageTag = Jellyfin::Support::fromJsonValue(source["ThumbImageTag"]); + m_thumbImageItemId = Jellyfin::Support::fromJsonValue(source["ThumbImageItemId"]); + m_backdropImageTag = Jellyfin::Support::fromJsonValue(source["BackdropImageTag"]); + m_backdropImageItemId = Jellyfin::Support::fromJsonValue(source["BackdropImageItemId"]); + m_type = Jellyfin::Support::fromJsonValue(source["Type"]); + m_isFolder = Jellyfin::Support::fromJsonValue(source["IsFolder"]); + m_runTimeTicks = Jellyfin::Support::fromJsonValue(source["RunTimeTicks"]); + m_mediaType = Jellyfin::Support::fromJsonValue(source["MediaType"]); + m_startDate = Jellyfin::Support::fromJsonValue(source["StartDate"]); + m_endDate = Jellyfin::Support::fromJsonValue(source["EndDate"]); + m_series = Jellyfin::Support::fromJsonValue(source["Series"]); + m_status = Jellyfin::Support::fromJsonValue(source["Status"]); + m_album = Jellyfin::Support::fromJsonValue(source["Album"]); + m_albumId = Jellyfin::Support::fromJsonValue(source["AlbumId"]); + m_albumArtist = Jellyfin::Support::fromJsonValue(source["AlbumArtist"]); + m_artists = Jellyfin::Support::fromJsonValue(source["Artists"]); + m_songCount = Jellyfin::Support::fromJsonValue(source["SongCount"]); + m_episodeCount = Jellyfin::Support::fromJsonValue(source["EpisodeCount"]); + m_channelId = Jellyfin::Support::fromJsonValue(source["ChannelId"]); + m_channelName = Jellyfin::Support::fromJsonValue(source["ChannelName"]); + m_primaryImageAspectRatio = Jellyfin::Support::fromJsonValue(source["PrimaryImageAspectRatio"]); } QJsonObject SearchHint::toJson() { QJsonObject result; - result["ItemId"] = toJsonValue(m_itemId); - result["Id"] = toJsonValue(m_jellyfinId); - result["Name"] = toJsonValue(m_name); - result["MatchedTerm"] = toJsonValue(m_matchedTerm); - result["IndexNumber"] = toJsonValue(m_indexNumber); - result["ProductionYear"] = toJsonValue(m_productionYear); - result["ParentIndexNumber"] = toJsonValue(m_parentIndexNumber); - result["PrimaryImageTag"] = toJsonValue(m_primaryImageTag); - result["ThumbImageTag"] = toJsonValue(m_thumbImageTag); - result["ThumbImageItemId"] = toJsonValue(m_thumbImageItemId); - result["BackdropImageTag"] = toJsonValue(m_backdropImageTag); - result["BackdropImageItemId"] = toJsonValue(m_backdropImageItemId); - result["Type"] = toJsonValue(m_type); - result["IsFolder"] = toJsonValue(m_isFolder); - result["RunTimeTicks"] = toJsonValue(m_runTimeTicks); - result["MediaType"] = toJsonValue(m_mediaType); - result["StartDate"] = toJsonValue(m_startDate); - result["EndDate"] = toJsonValue(m_endDate); - result["Series"] = toJsonValue(m_series); - result["Status"] = toJsonValue(m_status); - result["Album"] = toJsonValue(m_album); - result["AlbumId"] = toJsonValue(m_albumId); - result["AlbumArtist"] = toJsonValue(m_albumArtist); - result["Artists"] = toJsonValue(m_artists); - result["SongCount"] = toJsonValue(m_songCount); - result["EpisodeCount"] = toJsonValue(m_episodeCount); - result["ChannelId"] = toJsonValue(m_channelId); - result["ChannelName"] = toJsonValue(m_channelName); - result["PrimaryImageAspectRatio"] = toJsonValue(m_primaryImageAspectRatio); + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["MatchedTerm"] = Jellyfin::Support::toJsonValue(m_matchedTerm); + result["IndexNumber"] = Jellyfin::Support::toJsonValue(m_indexNumber); + result["ProductionYear"] = Jellyfin::Support::toJsonValue(m_productionYear); + result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue(m_parentIndexNumber); + result["PrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_primaryImageTag); + result["ThumbImageTag"] = Jellyfin::Support::toJsonValue(m_thumbImageTag); + result["ThumbImageItemId"] = Jellyfin::Support::toJsonValue(m_thumbImageItemId); + result["BackdropImageTag"] = Jellyfin::Support::toJsonValue(m_backdropImageTag); + result["BackdropImageItemId"] = Jellyfin::Support::toJsonValue(m_backdropImageItemId); + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + result["IsFolder"] = Jellyfin::Support::toJsonValue(m_isFolder); + result["RunTimeTicks"] = Jellyfin::Support::toJsonValue(m_runTimeTicks); + result["MediaType"] = Jellyfin::Support::toJsonValue(m_mediaType); + result["StartDate"] = Jellyfin::Support::toJsonValue(m_startDate); + result["EndDate"] = Jellyfin::Support::toJsonValue(m_endDate); + result["Series"] = Jellyfin::Support::toJsonValue(m_series); + result["Status"] = Jellyfin::Support::toJsonValue(m_status); + result["Album"] = Jellyfin::Support::toJsonValue(m_album); + result["AlbumId"] = Jellyfin::Support::toJsonValue(m_albumId); + result["AlbumArtist"] = Jellyfin::Support::toJsonValue(m_albumArtist); + result["Artists"] = Jellyfin::Support::toJsonValue(m_artists); + result["SongCount"] = Jellyfin::Support::toJsonValue(m_songCount); + result["EpisodeCount"] = Jellyfin::Support::toJsonValue(m_episodeCount); + result["ChannelId"] = Jellyfin::Support::toJsonValue(m_channelId); + result["ChannelName"] = Jellyfin::Support::toJsonValue(m_channelName); + result["PrimaryImageAspectRatio"] = Jellyfin::Support::toJsonValue(m_primaryImageAspectRatio); return result; } @@ -254,6 +255,17 @@ void SearchHint::setPrimaryImageAspectRatio(double newPrimaryImageAspectRatio) { m_primaryImageAspectRatio = newPrimaryImageAspectRatio; } +} // NS DTO + +namespace Support { + +using SearchHint = Jellyfin::DTO::SearchHint; + +template <> +SearchHint fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return SearchHint::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/searchhintresult.cpp b/core/src/DTO/searchhintresult.cpp index 5c0efaf..51470e0 100644 --- a/core/src/DTO/searchhintresult.cpp +++ b/core/src/DTO/searchhintresult.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -SearchHintResult::SearchHintResult(QObject *parent) {} +SearchHintResult::SearchHintResult() {} -SearchHintResult SearchHintResult::fromJson(QJsonObject source) {SearchHintResult instance; - instance->setFromJson(source, false); +SearchHintResult SearchHintResult::fromJson(QJsonObject source) { + SearchHintResult instance; + instance.setFromJson(source); return instance; } void SearchHintResult::setFromJson(QJsonObject source) { - m_searchHints = fromJsonValue>>(source["SearchHints"]); - m_totalRecordCount = fromJsonValue(source["TotalRecordCount"]); + m_searchHints = Jellyfin::Support::fromJsonValue>>(source["SearchHints"]); + m_totalRecordCount = Jellyfin::Support::fromJsonValue(source["TotalRecordCount"]); } QJsonObject SearchHintResult::toJson() { QJsonObject result; - result["SearchHints"] = toJsonValue>>(m_searchHints); - result["TotalRecordCount"] = toJsonValue(m_totalRecordCount); + result["SearchHints"] = Jellyfin::Support::toJsonValue>>(m_searchHints); + result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); return result; } @@ -65,6 +66,17 @@ void SearchHintResult::setTotalRecordCount(qint32 newTotalRecordCount) { m_totalRecordCount = newTotalRecordCount; } +} // NS DTO + +namespace Support { + +using SearchHintResult = Jellyfin::DTO::SearchHintResult; + +template <> +SearchHintResult fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return SearchHintResult::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/seekrequestdto.cpp b/core/src/DTO/seekrequestdto.cpp index 12d1fd3..1a3d473 100644 --- a/core/src/DTO/seekrequestdto.cpp +++ b/core/src/DTO/seekrequestdto.cpp @@ -32,22 +32,23 @@ namespace Jellyfin { namespace DTO { -SeekRequestDto::SeekRequestDto(QObject *parent) {} +SeekRequestDto::SeekRequestDto() {} -SeekRequestDto SeekRequestDto::fromJson(QJsonObject source) {SeekRequestDto instance; - instance->setFromJson(source, false); +SeekRequestDto SeekRequestDto::fromJson(QJsonObject source) { + SeekRequestDto instance; + instance.setFromJson(source); return instance; } void SeekRequestDto::setFromJson(QJsonObject source) { - m_positionTicks = fromJsonValue(source["PositionTicks"]); + m_positionTicks = Jellyfin::Support::fromJsonValue(source["PositionTicks"]); } QJsonObject SeekRequestDto::toJson() { QJsonObject result; - result["PositionTicks"] = toJsonValue(m_positionTicks); + result["PositionTicks"] = Jellyfin::Support::toJsonValue(m_positionTicks); return result; } @@ -58,6 +59,17 @@ void SeekRequestDto::setPositionTicks(qint64 newPositionTicks) { m_positionTicks = newPositionTicks; } +} // NS DTO + +namespace Support { + +using SeekRequestDto = Jellyfin::DTO::SeekRequestDto; + +template <> +SeekRequestDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return SeekRequestDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/sendcommand.cpp b/core/src/DTO/sendcommand.cpp index 591166e..a99f331 100644 --- a/core/src/DTO/sendcommand.cpp +++ b/core/src/DTO/sendcommand.cpp @@ -32,32 +32,33 @@ namespace Jellyfin { namespace DTO { -SendCommand::SendCommand(QObject *parent) {} +SendCommand::SendCommand() {} -SendCommand SendCommand::fromJson(QJsonObject source) {SendCommand instance; - instance->setFromJson(source, false); +SendCommand SendCommand::fromJson(QJsonObject source) { + SendCommand instance; + instance.setFromJson(source); return instance; } void SendCommand::setFromJson(QJsonObject source) { - m_groupId = fromJsonValue(source["GroupId"]); - m_playlistItemId = fromJsonValue(source["PlaylistItemId"]); - m_when = fromJsonValue(source["When"]); - m_positionTicks = fromJsonValue(source["PositionTicks"]); - m_command = fromJsonValue(source["Command"]); - m_emittedAt = fromJsonValue(source["EmittedAt"]); + m_groupId = Jellyfin::Support::fromJsonValue(source["GroupId"]); + m_playlistItemId = Jellyfin::Support::fromJsonValue(source["PlaylistItemId"]); + m_when = Jellyfin::Support::fromJsonValue(source["When"]); + m_positionTicks = Jellyfin::Support::fromJsonValue(source["PositionTicks"]); + m_command = Jellyfin::Support::fromJsonValue(source["Command"]); + m_emittedAt = Jellyfin::Support::fromJsonValue(source["EmittedAt"]); } QJsonObject SendCommand::toJson() { QJsonObject result; - result["GroupId"] = toJsonValue(m_groupId); - result["PlaylistItemId"] = toJsonValue(m_playlistItemId); - result["When"] = toJsonValue(m_when); - result["PositionTicks"] = toJsonValue(m_positionTicks); - result["Command"] = toJsonValue(m_command); - result["EmittedAt"] = toJsonValue(m_emittedAt); + result["GroupId"] = Jellyfin::Support::toJsonValue(m_groupId); + result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); + result["When"] = Jellyfin::Support::toJsonValue(m_when); + result["PositionTicks"] = Jellyfin::Support::toJsonValue(m_positionTicks); + result["Command"] = Jellyfin::Support::toJsonValue(m_command); + result["EmittedAt"] = Jellyfin::Support::toJsonValue(m_emittedAt); return result; } @@ -93,6 +94,17 @@ void SendCommand::setEmittedAt(QDateTime newEmittedAt) { m_emittedAt = newEmittedAt; } +} // NS DTO + +namespace Support { + +using SendCommand = Jellyfin::DTO::SendCommand; + +template <> +SendCommand fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return SendCommand::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/sendcommandtype.cpp b/core/src/DTO/sendcommandtype.cpp index 38d62ba..655646a 100644 --- a/core/src/DTO/sendcommandtype.cpp +++ b/core/src/DTO/sendcommandtype.cpp @@ -34,5 +34,33 @@ namespace DTO { SendCommandTypeClass::SendCommandTypeClass() {} + +} // NS DTO + +namespace Support { + +using SendCommandType = Jellyfin::DTO::SendCommandType; + +template <> +SendCommandType fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return SendCommandType::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Unpause")) { + return SendCommandType::Unpause; + } + if (str == QStringLiteral("Pause")) { + return SendCommandType::Pause; + } + if (str == QStringLiteral("Stop")) { + return SendCommandType::Stop; + } + if (str == QStringLiteral("Seek")) { + return SendCommandType::Seek; + } + + return SendCommandType::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/seriesinfo.cpp b/core/src/DTO/seriesinfo.cpp index 5943496..a735036 100644 --- a/core/src/DTO/seriesinfo.cpp +++ b/core/src/DTO/seriesinfo.cpp @@ -32,40 +32,41 @@ namespace Jellyfin { namespace DTO { -SeriesInfo::SeriesInfo(QObject *parent) {} +SeriesInfo::SeriesInfo() {} -SeriesInfo SeriesInfo::fromJson(QJsonObject source) {SeriesInfo instance; - instance->setFromJson(source, false); +SeriesInfo SeriesInfo::fromJson(QJsonObject source) { + SeriesInfo instance; + instance.setFromJson(source); return instance; } void SeriesInfo::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_path = fromJsonValue(source["Path"]); - m_metadataLanguage = fromJsonValue(source["MetadataLanguage"]); - m_metadataCountryCode = fromJsonValue(source["MetadataCountryCode"]); - m_providerIds = fromJsonValue(source["ProviderIds"]); - m_year = fromJsonValue(source["Year"]); - m_indexNumber = fromJsonValue(source["IndexNumber"]); - m_parentIndexNumber = fromJsonValue(source["ParentIndexNumber"]); - m_premiereDate = fromJsonValue(source["PremiereDate"]); - m_isAutomated = fromJsonValue(source["IsAutomated"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_path = Jellyfin::Support::fromJsonValue(source["Path"]); + m_metadataLanguage = Jellyfin::Support::fromJsonValue(source["MetadataLanguage"]); + m_metadataCountryCode = Jellyfin::Support::fromJsonValue(source["MetadataCountryCode"]); + m_providerIds = Jellyfin::Support::fromJsonValue(source["ProviderIds"]); + m_year = Jellyfin::Support::fromJsonValue(source["Year"]); + m_indexNumber = Jellyfin::Support::fromJsonValue(source["IndexNumber"]); + m_parentIndexNumber = Jellyfin::Support::fromJsonValue(source["ParentIndexNumber"]); + m_premiereDate = Jellyfin::Support::fromJsonValue(source["PremiereDate"]); + m_isAutomated = Jellyfin::Support::fromJsonValue(source["IsAutomated"]); } QJsonObject SeriesInfo::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Path"] = toJsonValue(m_path); - result["MetadataLanguage"] = toJsonValue(m_metadataLanguage); - result["MetadataCountryCode"] = toJsonValue(m_metadataCountryCode); - result["ProviderIds"] = toJsonValue(m_providerIds); - result["Year"] = toJsonValue(m_year); - result["IndexNumber"] = toJsonValue(m_indexNumber); - result["ParentIndexNumber"] = toJsonValue(m_parentIndexNumber); - result["PremiereDate"] = toJsonValue(m_premiereDate); - result["IsAutomated"] = toJsonValue(m_isAutomated); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); + result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); + result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); + result["Year"] = Jellyfin::Support::toJsonValue(m_year); + result["IndexNumber"] = Jellyfin::Support::toJsonValue(m_indexNumber); + result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue(m_parentIndexNumber); + result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); + result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); return result; } @@ -121,6 +122,17 @@ void SeriesInfo::setIsAutomated(bool newIsAutomated) { m_isAutomated = newIsAutomated; } +} // NS DTO + +namespace Support { + +using SeriesInfo = Jellyfin::DTO::SeriesInfo; + +template <> +SeriesInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return SeriesInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/seriesinforemotesearchquery.cpp b/core/src/DTO/seriesinforemotesearchquery.cpp index fe17845..5e6903c 100644 --- a/core/src/DTO/seriesinforemotesearchquery.cpp +++ b/core/src/DTO/seriesinforemotesearchquery.cpp @@ -32,28 +32,29 @@ namespace Jellyfin { namespace DTO { -SeriesInfoRemoteSearchQuery::SeriesInfoRemoteSearchQuery(QObject *parent) {} +SeriesInfoRemoteSearchQuery::SeriesInfoRemoteSearchQuery() {} -SeriesInfoRemoteSearchQuery SeriesInfoRemoteSearchQuery::fromJson(QJsonObject source) {SeriesInfoRemoteSearchQuery instance; - instance->setFromJson(source, false); +SeriesInfoRemoteSearchQuery SeriesInfoRemoteSearchQuery::fromJson(QJsonObject source) { + SeriesInfoRemoteSearchQuery instance; + instance.setFromJson(source); return instance; } void SeriesInfoRemoteSearchQuery::setFromJson(QJsonObject source) { - m_searchInfo = fromJsonValue>(source["SearchInfo"]); - m_itemId = fromJsonValue(source["ItemId"]); - m_searchProviderName = fromJsonValue(source["SearchProviderName"]); - m_includeDisabledProviders = fromJsonValue(source["IncludeDisabledProviders"]); + m_searchInfo = Jellyfin::Support::fromJsonValue>(source["SearchInfo"]); + m_itemId = Jellyfin::Support::fromJsonValue(source["ItemId"]); + m_searchProviderName = Jellyfin::Support::fromJsonValue(source["SearchProviderName"]); + m_includeDisabledProviders = Jellyfin::Support::fromJsonValue(source["IncludeDisabledProviders"]); } QJsonObject SeriesInfoRemoteSearchQuery::toJson() { QJsonObject result; - result["SearchInfo"] = toJsonValue>(m_searchInfo); - result["ItemId"] = toJsonValue(m_itemId); - result["SearchProviderName"] = toJsonValue(m_searchProviderName); - result["IncludeDisabledProviders"] = toJsonValue(m_includeDisabledProviders); + result["SearchInfo"] = Jellyfin::Support::toJsonValue>(m_searchInfo); + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); + result["IncludeDisabledProviders"] = Jellyfin::Support::toJsonValue(m_includeDisabledProviders); return result; } @@ -79,6 +80,17 @@ void SeriesInfoRemoteSearchQuery::setIncludeDisabledProviders(bool newIncludeDis m_includeDisabledProviders = newIncludeDisabledProviders; } +} // NS DTO + +namespace Support { + +using SeriesInfoRemoteSearchQuery = Jellyfin::DTO::SeriesInfoRemoteSearchQuery; + +template <> +SeriesInfoRemoteSearchQuery fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return SeriesInfoRemoteSearchQuery::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/seriesstatus.cpp b/core/src/DTO/seriesstatus.cpp index 5b4d870..46f3751 100644 --- a/core/src/DTO/seriesstatus.cpp +++ b/core/src/DTO/seriesstatus.cpp @@ -34,5 +34,27 @@ namespace DTO { SeriesStatusClass::SeriesStatusClass() {} + +} // NS DTO + +namespace Support { + +using SeriesStatus = Jellyfin::DTO::SeriesStatus; + +template <> +SeriesStatus fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return SeriesStatus::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Continuing")) { + return SeriesStatus::Continuing; + } + if (str == QStringLiteral("Ended")) { + return SeriesStatus::Ended; + } + + return SeriesStatus::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/seriestimerinfodto.cpp b/core/src/DTO/seriestimerinfodto.cpp index acc78f0..ddeb0cb 100644 --- a/core/src/DTO/seriestimerinfodto.cpp +++ b/core/src/DTO/seriestimerinfodto.cpp @@ -32,90 +32,91 @@ namespace Jellyfin { namespace DTO { -SeriesTimerInfoDto::SeriesTimerInfoDto(QObject *parent) {} +SeriesTimerInfoDto::SeriesTimerInfoDto() {} -SeriesTimerInfoDto SeriesTimerInfoDto::fromJson(QJsonObject source) {SeriesTimerInfoDto instance; - instance->setFromJson(source, false); +SeriesTimerInfoDto SeriesTimerInfoDto::fromJson(QJsonObject source) { + SeriesTimerInfoDto instance; + instance.setFromJson(source); return instance; } void SeriesTimerInfoDto::setFromJson(QJsonObject source) { - m_jellyfinId = fromJsonValue(source["Id"]); - m_type = fromJsonValue(source["Type"]); - m_serverId = fromJsonValue(source["ServerId"]); - m_externalId = fromJsonValue(source["ExternalId"]); - m_channelId = fromJsonValue(source["ChannelId"]); - m_externalChannelId = fromJsonValue(source["ExternalChannelId"]); - m_channelName = fromJsonValue(source["ChannelName"]); - m_channelPrimaryImageTag = fromJsonValue(source["ChannelPrimaryImageTag"]); - m_programId = fromJsonValue(source["ProgramId"]); - m_externalProgramId = fromJsonValue(source["ExternalProgramId"]); - m_name = fromJsonValue(source["Name"]); - m_overview = fromJsonValue(source["Overview"]); - m_startDate = fromJsonValue(source["StartDate"]); - m_endDate = fromJsonValue(source["EndDate"]); - m_serviceName = fromJsonValue(source["ServiceName"]); - m_priority = fromJsonValue(source["Priority"]); - m_prePaddingSeconds = fromJsonValue(source["PrePaddingSeconds"]); - m_postPaddingSeconds = fromJsonValue(source["PostPaddingSeconds"]); - m_isPrePaddingRequired = fromJsonValue(source["IsPrePaddingRequired"]); - m_parentBackdropItemId = fromJsonValue(source["ParentBackdropItemId"]); - m_parentBackdropImageTags = fromJsonValue(source["ParentBackdropImageTags"]); - m_isPostPaddingRequired = fromJsonValue(source["IsPostPaddingRequired"]); - m_keepUntil = fromJsonValue(source["KeepUntil"]); - m_recordAnyTime = fromJsonValue(source["RecordAnyTime"]); - m_skipEpisodesInLibrary = fromJsonValue(source["SkipEpisodesInLibrary"]); - m_recordAnyChannel = fromJsonValue(source["RecordAnyChannel"]); - m_keepUpTo = fromJsonValue(source["KeepUpTo"]); - m_recordNewOnly = fromJsonValue(source["RecordNewOnly"]); - m_days = fromJsonValue>(source["Days"]); - m_dayPattern = fromJsonValue(source["DayPattern"]); - m_imageTags = fromJsonValue(source["ImageTags"]); - m_parentThumbItemId = fromJsonValue(source["ParentThumbItemId"]); - m_parentThumbImageTag = fromJsonValue(source["ParentThumbImageTag"]); - m_parentPrimaryImageItemId = fromJsonValue(source["ParentPrimaryImageItemId"]); - m_parentPrimaryImageTag = fromJsonValue(source["ParentPrimaryImageTag"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); + m_type = Jellyfin::Support::fromJsonValue(source["Type"]); + m_serverId = Jellyfin::Support::fromJsonValue(source["ServerId"]); + m_externalId = Jellyfin::Support::fromJsonValue(source["ExternalId"]); + m_channelId = Jellyfin::Support::fromJsonValue(source["ChannelId"]); + m_externalChannelId = Jellyfin::Support::fromJsonValue(source["ExternalChannelId"]); + m_channelName = Jellyfin::Support::fromJsonValue(source["ChannelName"]); + m_channelPrimaryImageTag = Jellyfin::Support::fromJsonValue(source["ChannelPrimaryImageTag"]); + m_programId = Jellyfin::Support::fromJsonValue(source["ProgramId"]); + m_externalProgramId = Jellyfin::Support::fromJsonValue(source["ExternalProgramId"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_overview = Jellyfin::Support::fromJsonValue(source["Overview"]); + m_startDate = Jellyfin::Support::fromJsonValue(source["StartDate"]); + m_endDate = Jellyfin::Support::fromJsonValue(source["EndDate"]); + m_serviceName = Jellyfin::Support::fromJsonValue(source["ServiceName"]); + m_priority = Jellyfin::Support::fromJsonValue(source["Priority"]); + m_prePaddingSeconds = Jellyfin::Support::fromJsonValue(source["PrePaddingSeconds"]); + m_postPaddingSeconds = Jellyfin::Support::fromJsonValue(source["PostPaddingSeconds"]); + m_isPrePaddingRequired = Jellyfin::Support::fromJsonValue(source["IsPrePaddingRequired"]); + m_parentBackdropItemId = Jellyfin::Support::fromJsonValue(source["ParentBackdropItemId"]); + m_parentBackdropImageTags = Jellyfin::Support::fromJsonValue(source["ParentBackdropImageTags"]); + m_isPostPaddingRequired = Jellyfin::Support::fromJsonValue(source["IsPostPaddingRequired"]); + m_keepUntil = Jellyfin::Support::fromJsonValue(source["KeepUntil"]); + m_recordAnyTime = Jellyfin::Support::fromJsonValue(source["RecordAnyTime"]); + m_skipEpisodesInLibrary = Jellyfin::Support::fromJsonValue(source["SkipEpisodesInLibrary"]); + m_recordAnyChannel = Jellyfin::Support::fromJsonValue(source["RecordAnyChannel"]); + m_keepUpTo = Jellyfin::Support::fromJsonValue(source["KeepUpTo"]); + m_recordNewOnly = Jellyfin::Support::fromJsonValue(source["RecordNewOnly"]); + m_days = Jellyfin::Support::fromJsonValue>(source["Days"]); + m_dayPattern = Jellyfin::Support::fromJsonValue(source["DayPattern"]); + m_imageTags = Jellyfin::Support::fromJsonValue(source["ImageTags"]); + m_parentThumbItemId = Jellyfin::Support::fromJsonValue(source["ParentThumbItemId"]); + m_parentThumbImageTag = Jellyfin::Support::fromJsonValue(source["ParentThumbImageTag"]); + m_parentPrimaryImageItemId = Jellyfin::Support::fromJsonValue(source["ParentPrimaryImageItemId"]); + m_parentPrimaryImageTag = Jellyfin::Support::fromJsonValue(source["ParentPrimaryImageTag"]); } QJsonObject SeriesTimerInfoDto::toJson() { QJsonObject result; - result["Id"] = toJsonValue(m_jellyfinId); - result["Type"] = toJsonValue(m_type); - result["ServerId"] = toJsonValue(m_serverId); - result["ExternalId"] = toJsonValue(m_externalId); - result["ChannelId"] = toJsonValue(m_channelId); - result["ExternalChannelId"] = toJsonValue(m_externalChannelId); - result["ChannelName"] = toJsonValue(m_channelName); - result["ChannelPrimaryImageTag"] = toJsonValue(m_channelPrimaryImageTag); - result["ProgramId"] = toJsonValue(m_programId); - result["ExternalProgramId"] = toJsonValue(m_externalProgramId); - result["Name"] = toJsonValue(m_name); - result["Overview"] = toJsonValue(m_overview); - result["StartDate"] = toJsonValue(m_startDate); - result["EndDate"] = toJsonValue(m_endDate); - result["ServiceName"] = toJsonValue(m_serviceName); - result["Priority"] = toJsonValue(m_priority); - result["PrePaddingSeconds"] = toJsonValue(m_prePaddingSeconds); - result["PostPaddingSeconds"] = toJsonValue(m_postPaddingSeconds); - result["IsPrePaddingRequired"] = toJsonValue(m_isPrePaddingRequired); - result["ParentBackdropItemId"] = toJsonValue(m_parentBackdropItemId); - result["ParentBackdropImageTags"] = toJsonValue(m_parentBackdropImageTags); - result["IsPostPaddingRequired"] = toJsonValue(m_isPostPaddingRequired); - result["KeepUntil"] = toJsonValue(m_keepUntil); - result["RecordAnyTime"] = toJsonValue(m_recordAnyTime); - result["SkipEpisodesInLibrary"] = toJsonValue(m_skipEpisodesInLibrary); - result["RecordAnyChannel"] = toJsonValue(m_recordAnyChannel); - result["KeepUpTo"] = toJsonValue(m_keepUpTo); - result["RecordNewOnly"] = toJsonValue(m_recordNewOnly); - result["Days"] = toJsonValue>(m_days); - result["DayPattern"] = toJsonValue(m_dayPattern); - result["ImageTags"] = toJsonValue(m_imageTags); - result["ParentThumbItemId"] = toJsonValue(m_parentThumbItemId); - result["ParentThumbImageTag"] = toJsonValue(m_parentThumbImageTag); - result["ParentPrimaryImageItemId"] = toJsonValue(m_parentPrimaryImageItemId); - result["ParentPrimaryImageTag"] = toJsonValue(m_parentPrimaryImageTag); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + result["ServerId"] = Jellyfin::Support::toJsonValue(m_serverId); + result["ExternalId"] = Jellyfin::Support::toJsonValue(m_externalId); + result["ChannelId"] = Jellyfin::Support::toJsonValue(m_channelId); + result["ExternalChannelId"] = Jellyfin::Support::toJsonValue(m_externalChannelId); + result["ChannelName"] = Jellyfin::Support::toJsonValue(m_channelName); + result["ChannelPrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_channelPrimaryImageTag); + result["ProgramId"] = Jellyfin::Support::toJsonValue(m_programId); + result["ExternalProgramId"] = Jellyfin::Support::toJsonValue(m_externalProgramId); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Overview"] = Jellyfin::Support::toJsonValue(m_overview); + result["StartDate"] = Jellyfin::Support::toJsonValue(m_startDate); + result["EndDate"] = Jellyfin::Support::toJsonValue(m_endDate); + result["ServiceName"] = Jellyfin::Support::toJsonValue(m_serviceName); + result["Priority"] = Jellyfin::Support::toJsonValue(m_priority); + result["PrePaddingSeconds"] = Jellyfin::Support::toJsonValue(m_prePaddingSeconds); + result["PostPaddingSeconds"] = Jellyfin::Support::toJsonValue(m_postPaddingSeconds); + result["IsPrePaddingRequired"] = Jellyfin::Support::toJsonValue(m_isPrePaddingRequired); + result["ParentBackdropItemId"] = Jellyfin::Support::toJsonValue(m_parentBackdropItemId); + result["ParentBackdropImageTags"] = Jellyfin::Support::toJsonValue(m_parentBackdropImageTags); + result["IsPostPaddingRequired"] = Jellyfin::Support::toJsonValue(m_isPostPaddingRequired); + result["KeepUntil"] = Jellyfin::Support::toJsonValue(m_keepUntil); + result["RecordAnyTime"] = Jellyfin::Support::toJsonValue(m_recordAnyTime); + result["SkipEpisodesInLibrary"] = Jellyfin::Support::toJsonValue(m_skipEpisodesInLibrary); + result["RecordAnyChannel"] = Jellyfin::Support::toJsonValue(m_recordAnyChannel); + result["KeepUpTo"] = Jellyfin::Support::toJsonValue(m_keepUpTo); + result["RecordNewOnly"] = Jellyfin::Support::toJsonValue(m_recordNewOnly); + result["Days"] = Jellyfin::Support::toJsonValue>(m_days); + result["DayPattern"] = Jellyfin::Support::toJsonValue(m_dayPattern); + result["ImageTags"] = Jellyfin::Support::toJsonValue(m_imageTags); + result["ParentThumbItemId"] = Jellyfin::Support::toJsonValue(m_parentThumbItemId); + result["ParentThumbImageTag"] = Jellyfin::Support::toJsonValue(m_parentThumbImageTag); + result["ParentPrimaryImageItemId"] = Jellyfin::Support::toJsonValue(m_parentPrimaryImageItemId); + result["ParentPrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_parentPrimaryImageTag); return result; } @@ -296,6 +297,17 @@ void SeriesTimerInfoDto::setParentPrimaryImageTag(QString newParentPrimaryImageT m_parentPrimaryImageTag = newParentPrimaryImageTag; } +} // NS DTO + +namespace Support { + +using SeriesTimerInfoDto = Jellyfin::DTO::SeriesTimerInfoDto; + +template <> +SeriesTimerInfoDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return SeriesTimerInfoDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/seriestimerinfodtoqueryresult.cpp b/core/src/DTO/seriestimerinfodtoqueryresult.cpp index a33d8b3..613568e 100644 --- a/core/src/DTO/seriestimerinfodtoqueryresult.cpp +++ b/core/src/DTO/seriestimerinfodtoqueryresult.cpp @@ -32,26 +32,27 @@ namespace Jellyfin { namespace DTO { -SeriesTimerInfoDtoQueryResult::SeriesTimerInfoDtoQueryResult(QObject *parent) {} +SeriesTimerInfoDtoQueryResult::SeriesTimerInfoDtoQueryResult() {} -SeriesTimerInfoDtoQueryResult SeriesTimerInfoDtoQueryResult::fromJson(QJsonObject source) {SeriesTimerInfoDtoQueryResult instance; - instance->setFromJson(source, false); +SeriesTimerInfoDtoQueryResult SeriesTimerInfoDtoQueryResult::fromJson(QJsonObject source) { + SeriesTimerInfoDtoQueryResult instance; + instance.setFromJson(source); return instance; } void SeriesTimerInfoDtoQueryResult::setFromJson(QJsonObject source) { - m_items = fromJsonValue>>(source["Items"]); - m_totalRecordCount = fromJsonValue(source["TotalRecordCount"]); - m_startIndex = fromJsonValue(source["StartIndex"]); + m_items = Jellyfin::Support::fromJsonValue>>(source["Items"]); + m_totalRecordCount = Jellyfin::Support::fromJsonValue(source["TotalRecordCount"]); + m_startIndex = Jellyfin::Support::fromJsonValue(source["StartIndex"]); } QJsonObject SeriesTimerInfoDtoQueryResult::toJson() { QJsonObject result; - result["Items"] = toJsonValue>>(m_items); - result["TotalRecordCount"] = toJsonValue(m_totalRecordCount); - result["StartIndex"] = toJsonValue(m_startIndex); + result["Items"] = Jellyfin::Support::toJsonValue>>(m_items); + result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); + result["StartIndex"] = Jellyfin::Support::toJsonValue(m_startIndex); return result; } @@ -72,6 +73,17 @@ void SeriesTimerInfoDtoQueryResult::setStartIndex(qint32 newStartIndex) { m_startIndex = newStartIndex; } +} // NS DTO + +namespace Support { + +using SeriesTimerInfoDtoQueryResult = Jellyfin::DTO::SeriesTimerInfoDtoQueryResult; + +template <> +SeriesTimerInfoDtoQueryResult fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return SeriesTimerInfoDtoQueryResult::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/serverconfiguration.cpp b/core/src/DTO/serverconfiguration.cpp index 8ad2477..6297e6a 100644 --- a/core/src/DTO/serverconfiguration.cpp +++ b/core/src/DTO/serverconfiguration.cpp @@ -32,190 +32,191 @@ namespace Jellyfin { namespace DTO { -ServerConfiguration::ServerConfiguration(QObject *parent) {} +ServerConfiguration::ServerConfiguration() {} -ServerConfiguration ServerConfiguration::fromJson(QJsonObject source) {ServerConfiguration instance; - instance->setFromJson(source, false); +ServerConfiguration ServerConfiguration::fromJson(QJsonObject source) { + ServerConfiguration instance; + instance.setFromJson(source); return instance; } void ServerConfiguration::setFromJson(QJsonObject source) { - m_logFileRetentionDays = fromJsonValue(source["LogFileRetentionDays"]); - m_isStartupWizardCompleted = fromJsonValue(source["IsStartupWizardCompleted"]); - m_cachePath = fromJsonValue(source["CachePath"]); - m_previousVersion = fromJsonValue>(source["PreviousVersion"]); - m_previousVersionStr = fromJsonValue(source["PreviousVersionStr"]); - m_enableUPnP = fromJsonValue(source["EnableUPnP"]); - m_enableMetrics = fromJsonValue(source["EnableMetrics"]); - m_publicPort = fromJsonValue(source["PublicPort"]); - m_uPnPCreateHttpPortMap = fromJsonValue(source["UPnPCreateHttpPortMap"]); - m_uDPPortRange = fromJsonValue(source["UDPPortRange"]); - m_enableIPV6 = fromJsonValue(source["EnableIPV6"]); - m_enableIPV4 = fromJsonValue(source["EnableIPV4"]); - m_enableSSDPTracing = fromJsonValue(source["EnableSSDPTracing"]); - m_sSDPTracingFilter = fromJsonValue(source["SSDPTracingFilter"]); - m_uDPSendCount = fromJsonValue(source["UDPSendCount"]); - m_uDPSendDelay = fromJsonValue(source["UDPSendDelay"]); - m_ignoreVirtualInterfaces = fromJsonValue(source["IgnoreVirtualInterfaces"]); - m_virtualInterfaceNames = fromJsonValue(source["VirtualInterfaceNames"]); - m_gatewayMonitorPeriod = fromJsonValue(source["GatewayMonitorPeriod"]); - m_enableMultiSocketBinding = fromJsonValue(source["EnableMultiSocketBinding"]); - m_trustAllIP6Interfaces = fromJsonValue(source["TrustAllIP6Interfaces"]); - m_hDHomerunPortRange = fromJsonValue(source["HDHomerunPortRange"]); - m_publishedServerUriBySubnet = fromJsonValue(source["PublishedServerUriBySubnet"]); - m_autoDiscoveryTracing = fromJsonValue(source["AutoDiscoveryTracing"]); - m_autoDiscovery = fromJsonValue(source["AutoDiscovery"]); - m_publicHttpsPort = fromJsonValue(source["PublicHttpsPort"]); - m_httpServerPortNumber = fromJsonValue(source["HttpServerPortNumber"]); - m_httpsPortNumber = fromJsonValue(source["HttpsPortNumber"]); - m_enableHttps = fromJsonValue(source["EnableHttps"]); - m_enableNormalizedItemByNameIds = fromJsonValue(source["EnableNormalizedItemByNameIds"]); - m_certificatePath = fromJsonValue(source["CertificatePath"]); - m_certificatePassword = fromJsonValue(source["CertificatePassword"]); - m_isPortAuthorized = fromJsonValue(source["IsPortAuthorized"]); - m_quickConnectAvailable = fromJsonValue(source["QuickConnectAvailable"]); - m_enableRemoteAccess = fromJsonValue(source["EnableRemoteAccess"]); - m_enableCaseSensitiveItemIds = fromJsonValue(source["EnableCaseSensitiveItemIds"]); - m_disableLiveTvChannelUserDataName = fromJsonValue(source["DisableLiveTvChannelUserDataName"]); - m_metadataPath = fromJsonValue(source["MetadataPath"]); - m_metadataNetworkPath = fromJsonValue(source["MetadataNetworkPath"]); - m_preferredMetadataLanguage = fromJsonValue(source["PreferredMetadataLanguage"]); - m_metadataCountryCode = fromJsonValue(source["MetadataCountryCode"]); - m_sortReplaceCharacters = fromJsonValue(source["SortReplaceCharacters"]); - m_sortRemoveCharacters = fromJsonValue(source["SortRemoveCharacters"]); - m_sortRemoveWords = fromJsonValue(source["SortRemoveWords"]); - m_minResumePct = fromJsonValue(source["MinResumePct"]); - m_maxResumePct = fromJsonValue(source["MaxResumePct"]); - m_minResumeDurationSeconds = fromJsonValue(source["MinResumeDurationSeconds"]); - m_minAudiobookResume = fromJsonValue(source["MinAudiobookResume"]); - m_maxAudiobookResume = fromJsonValue(source["MaxAudiobookResume"]); - m_libraryMonitorDelay = fromJsonValue(source["LibraryMonitorDelay"]); - m_enableDashboardResponseCaching = fromJsonValue(source["EnableDashboardResponseCaching"]); - m_imageSavingConvention = fromJsonValue(source["ImageSavingConvention"]); - m_metadataOptions = fromJsonValue>>(source["MetadataOptions"]); - m_skipDeserializationForBasicTypes = fromJsonValue(source["SkipDeserializationForBasicTypes"]); - m_serverName = fromJsonValue(source["ServerName"]); - m_baseUrl = fromJsonValue(source["BaseUrl"]); - m_uICulture = fromJsonValue(source["UICulture"]); - m_saveMetadataHidden = fromJsonValue(source["SaveMetadataHidden"]); - m_contentTypes = fromJsonValue>>(source["ContentTypes"]); - m_remoteClientBitrateLimit = fromJsonValue(source["RemoteClientBitrateLimit"]); - m_enableFolderView = fromJsonValue(source["EnableFolderView"]); - m_enableGroupingIntoCollections = fromJsonValue(source["EnableGroupingIntoCollections"]); - m_displaySpecialsWithinSeasons = fromJsonValue(source["DisplaySpecialsWithinSeasons"]); - m_localNetworkSubnets = fromJsonValue(source["LocalNetworkSubnets"]); - m_localNetworkAddresses = fromJsonValue(source["LocalNetworkAddresses"]); - m_codecsUsed = fromJsonValue(source["CodecsUsed"]); - m_pluginRepositories = fromJsonValue>>(source["PluginRepositories"]); - m_enableExternalContentInSuggestions = fromJsonValue(source["EnableExternalContentInSuggestions"]); - m_requireHttps = fromJsonValue(source["RequireHttps"]); - m_enableNewOmdbSupport = fromJsonValue(source["EnableNewOmdbSupport"]); - m_remoteIPFilter = fromJsonValue(source["RemoteIPFilter"]); - m_isRemoteIPFilterBlacklist = fromJsonValue(source["IsRemoteIPFilterBlacklist"]); - m_imageExtractionTimeoutMs = fromJsonValue(source["ImageExtractionTimeoutMs"]); - m_pathSubstitutions = fromJsonValue>>(source["PathSubstitutions"]); - m_enableSimpleArtistDetection = fromJsonValue(source["EnableSimpleArtistDetection"]); - m_uninstalledPlugins = fromJsonValue(source["UninstalledPlugins"]); - m_enableSlowResponseWarning = fromJsonValue(source["EnableSlowResponseWarning"]); - m_slowResponseThresholdMs = fromJsonValue(source["SlowResponseThresholdMs"]); - m_corsHosts = fromJsonValue(source["CorsHosts"]); - m_knownProxies = fromJsonValue(source["KnownProxies"]); - m_activityLogRetentionDays = fromJsonValue(source["ActivityLogRetentionDays"]); - m_libraryScanFanoutConcurrency = fromJsonValue(source["LibraryScanFanoutConcurrency"]); - m_libraryMetadataRefreshConcurrency = fromJsonValue(source["LibraryMetadataRefreshConcurrency"]); - m_removeOldPlugins = fromJsonValue(source["RemoveOldPlugins"]); - m_disablePluginImages = fromJsonValue(source["DisablePluginImages"]); + m_logFileRetentionDays = Jellyfin::Support::fromJsonValue(source["LogFileRetentionDays"]); + m_isStartupWizardCompleted = Jellyfin::Support::fromJsonValue(source["IsStartupWizardCompleted"]); + m_cachePath = Jellyfin::Support::fromJsonValue(source["CachePath"]); + m_previousVersion = Jellyfin::Support::fromJsonValue>(source["PreviousVersion"]); + m_previousVersionStr = Jellyfin::Support::fromJsonValue(source["PreviousVersionStr"]); + m_enableUPnP = Jellyfin::Support::fromJsonValue(source["EnableUPnP"]); + m_enableMetrics = Jellyfin::Support::fromJsonValue(source["EnableMetrics"]); + m_publicPort = Jellyfin::Support::fromJsonValue(source["PublicPort"]); + m_uPnPCreateHttpPortMap = Jellyfin::Support::fromJsonValue(source["UPnPCreateHttpPortMap"]); + m_uDPPortRange = Jellyfin::Support::fromJsonValue(source["UDPPortRange"]); + m_enableIPV6 = Jellyfin::Support::fromJsonValue(source["EnableIPV6"]); + m_enableIPV4 = Jellyfin::Support::fromJsonValue(source["EnableIPV4"]); + m_enableSSDPTracing = Jellyfin::Support::fromJsonValue(source["EnableSSDPTracing"]); + m_sSDPTracingFilter = Jellyfin::Support::fromJsonValue(source["SSDPTracingFilter"]); + m_uDPSendCount = Jellyfin::Support::fromJsonValue(source["UDPSendCount"]); + m_uDPSendDelay = Jellyfin::Support::fromJsonValue(source["UDPSendDelay"]); + m_ignoreVirtualInterfaces = Jellyfin::Support::fromJsonValue(source["IgnoreVirtualInterfaces"]); + m_virtualInterfaceNames = Jellyfin::Support::fromJsonValue(source["VirtualInterfaceNames"]); + m_gatewayMonitorPeriod = Jellyfin::Support::fromJsonValue(source["GatewayMonitorPeriod"]); + m_enableMultiSocketBinding = Jellyfin::Support::fromJsonValue(source["EnableMultiSocketBinding"]); + m_trustAllIP6Interfaces = Jellyfin::Support::fromJsonValue(source["TrustAllIP6Interfaces"]); + m_hDHomerunPortRange = Jellyfin::Support::fromJsonValue(source["HDHomerunPortRange"]); + m_publishedServerUriBySubnet = Jellyfin::Support::fromJsonValue(source["PublishedServerUriBySubnet"]); + m_autoDiscoveryTracing = Jellyfin::Support::fromJsonValue(source["AutoDiscoveryTracing"]); + m_autoDiscovery = Jellyfin::Support::fromJsonValue(source["AutoDiscovery"]); + m_publicHttpsPort = Jellyfin::Support::fromJsonValue(source["PublicHttpsPort"]); + m_httpServerPortNumber = Jellyfin::Support::fromJsonValue(source["HttpServerPortNumber"]); + m_httpsPortNumber = Jellyfin::Support::fromJsonValue(source["HttpsPortNumber"]); + m_enableHttps = Jellyfin::Support::fromJsonValue(source["EnableHttps"]); + m_enableNormalizedItemByNameIds = Jellyfin::Support::fromJsonValue(source["EnableNormalizedItemByNameIds"]); + m_certificatePath = Jellyfin::Support::fromJsonValue(source["CertificatePath"]); + m_certificatePassword = Jellyfin::Support::fromJsonValue(source["CertificatePassword"]); + m_isPortAuthorized = Jellyfin::Support::fromJsonValue(source["IsPortAuthorized"]); + m_quickConnectAvailable = Jellyfin::Support::fromJsonValue(source["QuickConnectAvailable"]); + m_enableRemoteAccess = Jellyfin::Support::fromJsonValue(source["EnableRemoteAccess"]); + m_enableCaseSensitiveItemIds = Jellyfin::Support::fromJsonValue(source["EnableCaseSensitiveItemIds"]); + m_disableLiveTvChannelUserDataName = Jellyfin::Support::fromJsonValue(source["DisableLiveTvChannelUserDataName"]); + m_metadataPath = Jellyfin::Support::fromJsonValue(source["MetadataPath"]); + m_metadataNetworkPath = Jellyfin::Support::fromJsonValue(source["MetadataNetworkPath"]); + m_preferredMetadataLanguage = Jellyfin::Support::fromJsonValue(source["PreferredMetadataLanguage"]); + m_metadataCountryCode = Jellyfin::Support::fromJsonValue(source["MetadataCountryCode"]); + m_sortReplaceCharacters = Jellyfin::Support::fromJsonValue(source["SortReplaceCharacters"]); + m_sortRemoveCharacters = Jellyfin::Support::fromJsonValue(source["SortRemoveCharacters"]); + m_sortRemoveWords = Jellyfin::Support::fromJsonValue(source["SortRemoveWords"]); + m_minResumePct = Jellyfin::Support::fromJsonValue(source["MinResumePct"]); + m_maxResumePct = Jellyfin::Support::fromJsonValue(source["MaxResumePct"]); + m_minResumeDurationSeconds = Jellyfin::Support::fromJsonValue(source["MinResumeDurationSeconds"]); + m_minAudiobookResume = Jellyfin::Support::fromJsonValue(source["MinAudiobookResume"]); + m_maxAudiobookResume = Jellyfin::Support::fromJsonValue(source["MaxAudiobookResume"]); + m_libraryMonitorDelay = Jellyfin::Support::fromJsonValue(source["LibraryMonitorDelay"]); + m_enableDashboardResponseCaching = Jellyfin::Support::fromJsonValue(source["EnableDashboardResponseCaching"]); + m_imageSavingConvention = Jellyfin::Support::fromJsonValue(source["ImageSavingConvention"]); + m_metadataOptions = Jellyfin::Support::fromJsonValue>>(source["MetadataOptions"]); + m_skipDeserializationForBasicTypes = Jellyfin::Support::fromJsonValue(source["SkipDeserializationForBasicTypes"]); + m_serverName = Jellyfin::Support::fromJsonValue(source["ServerName"]); + m_baseUrl = Jellyfin::Support::fromJsonValue(source["BaseUrl"]); + m_uICulture = Jellyfin::Support::fromJsonValue(source["UICulture"]); + m_saveMetadataHidden = Jellyfin::Support::fromJsonValue(source["SaveMetadataHidden"]); + m_contentTypes = Jellyfin::Support::fromJsonValue>>(source["ContentTypes"]); + m_remoteClientBitrateLimit = Jellyfin::Support::fromJsonValue(source["RemoteClientBitrateLimit"]); + m_enableFolderView = Jellyfin::Support::fromJsonValue(source["EnableFolderView"]); + m_enableGroupingIntoCollections = Jellyfin::Support::fromJsonValue(source["EnableGroupingIntoCollections"]); + m_displaySpecialsWithinSeasons = Jellyfin::Support::fromJsonValue(source["DisplaySpecialsWithinSeasons"]); + m_localNetworkSubnets = Jellyfin::Support::fromJsonValue(source["LocalNetworkSubnets"]); + m_localNetworkAddresses = Jellyfin::Support::fromJsonValue(source["LocalNetworkAddresses"]); + m_codecsUsed = Jellyfin::Support::fromJsonValue(source["CodecsUsed"]); + m_pluginRepositories = Jellyfin::Support::fromJsonValue>>(source["PluginRepositories"]); + m_enableExternalContentInSuggestions = Jellyfin::Support::fromJsonValue(source["EnableExternalContentInSuggestions"]); + m_requireHttps = Jellyfin::Support::fromJsonValue(source["RequireHttps"]); + m_enableNewOmdbSupport = Jellyfin::Support::fromJsonValue(source["EnableNewOmdbSupport"]); + m_remoteIPFilter = Jellyfin::Support::fromJsonValue(source["RemoteIPFilter"]); + m_isRemoteIPFilterBlacklist = Jellyfin::Support::fromJsonValue(source["IsRemoteIPFilterBlacklist"]); + m_imageExtractionTimeoutMs = Jellyfin::Support::fromJsonValue(source["ImageExtractionTimeoutMs"]); + m_pathSubstitutions = Jellyfin::Support::fromJsonValue>>(source["PathSubstitutions"]); + m_enableSimpleArtistDetection = Jellyfin::Support::fromJsonValue(source["EnableSimpleArtistDetection"]); + m_uninstalledPlugins = Jellyfin::Support::fromJsonValue(source["UninstalledPlugins"]); + m_enableSlowResponseWarning = Jellyfin::Support::fromJsonValue(source["EnableSlowResponseWarning"]); + m_slowResponseThresholdMs = Jellyfin::Support::fromJsonValue(source["SlowResponseThresholdMs"]); + m_corsHosts = Jellyfin::Support::fromJsonValue(source["CorsHosts"]); + m_knownProxies = Jellyfin::Support::fromJsonValue(source["KnownProxies"]); + m_activityLogRetentionDays = Jellyfin::Support::fromJsonValue(source["ActivityLogRetentionDays"]); + m_libraryScanFanoutConcurrency = Jellyfin::Support::fromJsonValue(source["LibraryScanFanoutConcurrency"]); + m_libraryMetadataRefreshConcurrency = Jellyfin::Support::fromJsonValue(source["LibraryMetadataRefreshConcurrency"]); + m_removeOldPlugins = Jellyfin::Support::fromJsonValue(source["RemoveOldPlugins"]); + m_disablePluginImages = Jellyfin::Support::fromJsonValue(source["DisablePluginImages"]); } QJsonObject ServerConfiguration::toJson() { QJsonObject result; - result["LogFileRetentionDays"] = toJsonValue(m_logFileRetentionDays); - result["IsStartupWizardCompleted"] = toJsonValue(m_isStartupWizardCompleted); - result["CachePath"] = toJsonValue(m_cachePath); - result["PreviousVersion"] = toJsonValue>(m_previousVersion); - result["PreviousVersionStr"] = toJsonValue(m_previousVersionStr); - result["EnableUPnP"] = toJsonValue(m_enableUPnP); - result["EnableMetrics"] = toJsonValue(m_enableMetrics); - result["PublicPort"] = toJsonValue(m_publicPort); - result["UPnPCreateHttpPortMap"] = toJsonValue(m_uPnPCreateHttpPortMap); - result["UDPPortRange"] = toJsonValue(m_uDPPortRange); - result["EnableIPV6"] = toJsonValue(m_enableIPV6); - result["EnableIPV4"] = toJsonValue(m_enableIPV4); - result["EnableSSDPTracing"] = toJsonValue(m_enableSSDPTracing); - result["SSDPTracingFilter"] = toJsonValue(m_sSDPTracingFilter); - result["UDPSendCount"] = toJsonValue(m_uDPSendCount); - result["UDPSendDelay"] = toJsonValue(m_uDPSendDelay); - result["IgnoreVirtualInterfaces"] = toJsonValue(m_ignoreVirtualInterfaces); - result["VirtualInterfaceNames"] = toJsonValue(m_virtualInterfaceNames); - result["GatewayMonitorPeriod"] = toJsonValue(m_gatewayMonitorPeriod); - result["EnableMultiSocketBinding"] = toJsonValue(m_enableMultiSocketBinding); - result["TrustAllIP6Interfaces"] = toJsonValue(m_trustAllIP6Interfaces); - result["HDHomerunPortRange"] = toJsonValue(m_hDHomerunPortRange); - result["PublishedServerUriBySubnet"] = toJsonValue(m_publishedServerUriBySubnet); - result["AutoDiscoveryTracing"] = toJsonValue(m_autoDiscoveryTracing); - result["AutoDiscovery"] = toJsonValue(m_autoDiscovery); - result["PublicHttpsPort"] = toJsonValue(m_publicHttpsPort); - result["HttpServerPortNumber"] = toJsonValue(m_httpServerPortNumber); - result["HttpsPortNumber"] = toJsonValue(m_httpsPortNumber); - result["EnableHttps"] = toJsonValue(m_enableHttps); - result["EnableNormalizedItemByNameIds"] = toJsonValue(m_enableNormalizedItemByNameIds); - result["CertificatePath"] = toJsonValue(m_certificatePath); - result["CertificatePassword"] = toJsonValue(m_certificatePassword); - result["IsPortAuthorized"] = toJsonValue(m_isPortAuthorized); - result["QuickConnectAvailable"] = toJsonValue(m_quickConnectAvailable); - result["EnableRemoteAccess"] = toJsonValue(m_enableRemoteAccess); - result["EnableCaseSensitiveItemIds"] = toJsonValue(m_enableCaseSensitiveItemIds); - result["DisableLiveTvChannelUserDataName"] = toJsonValue(m_disableLiveTvChannelUserDataName); - result["MetadataPath"] = toJsonValue(m_metadataPath); - result["MetadataNetworkPath"] = toJsonValue(m_metadataNetworkPath); - result["PreferredMetadataLanguage"] = toJsonValue(m_preferredMetadataLanguage); - result["MetadataCountryCode"] = toJsonValue(m_metadataCountryCode); - result["SortReplaceCharacters"] = toJsonValue(m_sortReplaceCharacters); - result["SortRemoveCharacters"] = toJsonValue(m_sortRemoveCharacters); - result["SortRemoveWords"] = toJsonValue(m_sortRemoveWords); - result["MinResumePct"] = toJsonValue(m_minResumePct); - result["MaxResumePct"] = toJsonValue(m_maxResumePct); - result["MinResumeDurationSeconds"] = toJsonValue(m_minResumeDurationSeconds); - result["MinAudiobookResume"] = toJsonValue(m_minAudiobookResume); - result["MaxAudiobookResume"] = toJsonValue(m_maxAudiobookResume); - result["LibraryMonitorDelay"] = toJsonValue(m_libraryMonitorDelay); - result["EnableDashboardResponseCaching"] = toJsonValue(m_enableDashboardResponseCaching); - result["ImageSavingConvention"] = toJsonValue(m_imageSavingConvention); - result["MetadataOptions"] = toJsonValue>>(m_metadataOptions); - result["SkipDeserializationForBasicTypes"] = toJsonValue(m_skipDeserializationForBasicTypes); - result["ServerName"] = toJsonValue(m_serverName); - result["BaseUrl"] = toJsonValue(m_baseUrl); - result["UICulture"] = toJsonValue(m_uICulture); - result["SaveMetadataHidden"] = toJsonValue(m_saveMetadataHidden); - result["ContentTypes"] = toJsonValue>>(m_contentTypes); - result["RemoteClientBitrateLimit"] = toJsonValue(m_remoteClientBitrateLimit); - result["EnableFolderView"] = toJsonValue(m_enableFolderView); - result["EnableGroupingIntoCollections"] = toJsonValue(m_enableGroupingIntoCollections); - result["DisplaySpecialsWithinSeasons"] = toJsonValue(m_displaySpecialsWithinSeasons); - result["LocalNetworkSubnets"] = toJsonValue(m_localNetworkSubnets); - result["LocalNetworkAddresses"] = toJsonValue(m_localNetworkAddresses); - result["CodecsUsed"] = toJsonValue(m_codecsUsed); - result["PluginRepositories"] = toJsonValue>>(m_pluginRepositories); - result["EnableExternalContentInSuggestions"] = toJsonValue(m_enableExternalContentInSuggestions); - result["RequireHttps"] = toJsonValue(m_requireHttps); - result["EnableNewOmdbSupport"] = toJsonValue(m_enableNewOmdbSupport); - result["RemoteIPFilter"] = toJsonValue(m_remoteIPFilter); - result["IsRemoteIPFilterBlacklist"] = toJsonValue(m_isRemoteIPFilterBlacklist); - result["ImageExtractionTimeoutMs"] = toJsonValue(m_imageExtractionTimeoutMs); - result["PathSubstitutions"] = toJsonValue>>(m_pathSubstitutions); - result["EnableSimpleArtistDetection"] = toJsonValue(m_enableSimpleArtistDetection); - result["UninstalledPlugins"] = toJsonValue(m_uninstalledPlugins); - result["EnableSlowResponseWarning"] = toJsonValue(m_enableSlowResponseWarning); - result["SlowResponseThresholdMs"] = toJsonValue(m_slowResponseThresholdMs); - result["CorsHosts"] = toJsonValue(m_corsHosts); - result["KnownProxies"] = toJsonValue(m_knownProxies); - result["ActivityLogRetentionDays"] = toJsonValue(m_activityLogRetentionDays); - result["LibraryScanFanoutConcurrency"] = toJsonValue(m_libraryScanFanoutConcurrency); - result["LibraryMetadataRefreshConcurrency"] = toJsonValue(m_libraryMetadataRefreshConcurrency); - result["RemoveOldPlugins"] = toJsonValue(m_removeOldPlugins); - result["DisablePluginImages"] = toJsonValue(m_disablePluginImages); + result["LogFileRetentionDays"] = Jellyfin::Support::toJsonValue(m_logFileRetentionDays); + result["IsStartupWizardCompleted"] = Jellyfin::Support::toJsonValue(m_isStartupWizardCompleted); + result["CachePath"] = Jellyfin::Support::toJsonValue(m_cachePath); + result["PreviousVersion"] = Jellyfin::Support::toJsonValue>(m_previousVersion); + result["PreviousVersionStr"] = Jellyfin::Support::toJsonValue(m_previousVersionStr); + result["EnableUPnP"] = Jellyfin::Support::toJsonValue(m_enableUPnP); + result["EnableMetrics"] = Jellyfin::Support::toJsonValue(m_enableMetrics); + result["PublicPort"] = Jellyfin::Support::toJsonValue(m_publicPort); + result["UPnPCreateHttpPortMap"] = Jellyfin::Support::toJsonValue(m_uPnPCreateHttpPortMap); + result["UDPPortRange"] = Jellyfin::Support::toJsonValue(m_uDPPortRange); + result["EnableIPV6"] = Jellyfin::Support::toJsonValue(m_enableIPV6); + result["EnableIPV4"] = Jellyfin::Support::toJsonValue(m_enableIPV4); + result["EnableSSDPTracing"] = Jellyfin::Support::toJsonValue(m_enableSSDPTracing); + result["SSDPTracingFilter"] = Jellyfin::Support::toJsonValue(m_sSDPTracingFilter); + result["UDPSendCount"] = Jellyfin::Support::toJsonValue(m_uDPSendCount); + result["UDPSendDelay"] = Jellyfin::Support::toJsonValue(m_uDPSendDelay); + result["IgnoreVirtualInterfaces"] = Jellyfin::Support::toJsonValue(m_ignoreVirtualInterfaces); + result["VirtualInterfaceNames"] = Jellyfin::Support::toJsonValue(m_virtualInterfaceNames); + result["GatewayMonitorPeriod"] = Jellyfin::Support::toJsonValue(m_gatewayMonitorPeriod); + result["EnableMultiSocketBinding"] = Jellyfin::Support::toJsonValue(m_enableMultiSocketBinding); + result["TrustAllIP6Interfaces"] = Jellyfin::Support::toJsonValue(m_trustAllIP6Interfaces); + result["HDHomerunPortRange"] = Jellyfin::Support::toJsonValue(m_hDHomerunPortRange); + result["PublishedServerUriBySubnet"] = Jellyfin::Support::toJsonValue(m_publishedServerUriBySubnet); + result["AutoDiscoveryTracing"] = Jellyfin::Support::toJsonValue(m_autoDiscoveryTracing); + result["AutoDiscovery"] = Jellyfin::Support::toJsonValue(m_autoDiscovery); + result["PublicHttpsPort"] = Jellyfin::Support::toJsonValue(m_publicHttpsPort); + result["HttpServerPortNumber"] = Jellyfin::Support::toJsonValue(m_httpServerPortNumber); + result["HttpsPortNumber"] = Jellyfin::Support::toJsonValue(m_httpsPortNumber); + result["EnableHttps"] = Jellyfin::Support::toJsonValue(m_enableHttps); + result["EnableNormalizedItemByNameIds"] = Jellyfin::Support::toJsonValue(m_enableNormalizedItemByNameIds); + result["CertificatePath"] = Jellyfin::Support::toJsonValue(m_certificatePath); + result["CertificatePassword"] = Jellyfin::Support::toJsonValue(m_certificatePassword); + result["IsPortAuthorized"] = Jellyfin::Support::toJsonValue(m_isPortAuthorized); + result["QuickConnectAvailable"] = Jellyfin::Support::toJsonValue(m_quickConnectAvailable); + result["EnableRemoteAccess"] = Jellyfin::Support::toJsonValue(m_enableRemoteAccess); + result["EnableCaseSensitiveItemIds"] = Jellyfin::Support::toJsonValue(m_enableCaseSensitiveItemIds); + result["DisableLiveTvChannelUserDataName"] = Jellyfin::Support::toJsonValue(m_disableLiveTvChannelUserDataName); + result["MetadataPath"] = Jellyfin::Support::toJsonValue(m_metadataPath); + result["MetadataNetworkPath"] = Jellyfin::Support::toJsonValue(m_metadataNetworkPath); + result["PreferredMetadataLanguage"] = Jellyfin::Support::toJsonValue(m_preferredMetadataLanguage); + result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); + result["SortReplaceCharacters"] = Jellyfin::Support::toJsonValue(m_sortReplaceCharacters); + result["SortRemoveCharacters"] = Jellyfin::Support::toJsonValue(m_sortRemoveCharacters); + result["SortRemoveWords"] = Jellyfin::Support::toJsonValue(m_sortRemoveWords); + result["MinResumePct"] = Jellyfin::Support::toJsonValue(m_minResumePct); + result["MaxResumePct"] = Jellyfin::Support::toJsonValue(m_maxResumePct); + result["MinResumeDurationSeconds"] = Jellyfin::Support::toJsonValue(m_minResumeDurationSeconds); + result["MinAudiobookResume"] = Jellyfin::Support::toJsonValue(m_minAudiobookResume); + result["MaxAudiobookResume"] = Jellyfin::Support::toJsonValue(m_maxAudiobookResume); + result["LibraryMonitorDelay"] = Jellyfin::Support::toJsonValue(m_libraryMonitorDelay); + result["EnableDashboardResponseCaching"] = Jellyfin::Support::toJsonValue(m_enableDashboardResponseCaching); + result["ImageSavingConvention"] = Jellyfin::Support::toJsonValue(m_imageSavingConvention); + result["MetadataOptions"] = Jellyfin::Support::toJsonValue>>(m_metadataOptions); + result["SkipDeserializationForBasicTypes"] = Jellyfin::Support::toJsonValue(m_skipDeserializationForBasicTypes); + result["ServerName"] = Jellyfin::Support::toJsonValue(m_serverName); + result["BaseUrl"] = Jellyfin::Support::toJsonValue(m_baseUrl); + result["UICulture"] = Jellyfin::Support::toJsonValue(m_uICulture); + result["SaveMetadataHidden"] = Jellyfin::Support::toJsonValue(m_saveMetadataHidden); + result["ContentTypes"] = Jellyfin::Support::toJsonValue>>(m_contentTypes); + result["RemoteClientBitrateLimit"] = Jellyfin::Support::toJsonValue(m_remoteClientBitrateLimit); + result["EnableFolderView"] = Jellyfin::Support::toJsonValue(m_enableFolderView); + result["EnableGroupingIntoCollections"] = Jellyfin::Support::toJsonValue(m_enableGroupingIntoCollections); + result["DisplaySpecialsWithinSeasons"] = Jellyfin::Support::toJsonValue(m_displaySpecialsWithinSeasons); + result["LocalNetworkSubnets"] = Jellyfin::Support::toJsonValue(m_localNetworkSubnets); + result["LocalNetworkAddresses"] = Jellyfin::Support::toJsonValue(m_localNetworkAddresses); + result["CodecsUsed"] = Jellyfin::Support::toJsonValue(m_codecsUsed); + result["PluginRepositories"] = Jellyfin::Support::toJsonValue>>(m_pluginRepositories); + result["EnableExternalContentInSuggestions"] = Jellyfin::Support::toJsonValue(m_enableExternalContentInSuggestions); + result["RequireHttps"] = Jellyfin::Support::toJsonValue(m_requireHttps); + result["EnableNewOmdbSupport"] = Jellyfin::Support::toJsonValue(m_enableNewOmdbSupport); + result["RemoteIPFilter"] = Jellyfin::Support::toJsonValue(m_remoteIPFilter); + result["IsRemoteIPFilterBlacklist"] = Jellyfin::Support::toJsonValue(m_isRemoteIPFilterBlacklist); + result["ImageExtractionTimeoutMs"] = Jellyfin::Support::toJsonValue(m_imageExtractionTimeoutMs); + result["PathSubstitutions"] = Jellyfin::Support::toJsonValue>>(m_pathSubstitutions); + result["EnableSimpleArtistDetection"] = Jellyfin::Support::toJsonValue(m_enableSimpleArtistDetection); + result["UninstalledPlugins"] = Jellyfin::Support::toJsonValue(m_uninstalledPlugins); + result["EnableSlowResponseWarning"] = Jellyfin::Support::toJsonValue(m_enableSlowResponseWarning); + result["SlowResponseThresholdMs"] = Jellyfin::Support::toJsonValue(m_slowResponseThresholdMs); + result["CorsHosts"] = Jellyfin::Support::toJsonValue(m_corsHosts); + result["KnownProxies"] = Jellyfin::Support::toJsonValue(m_knownProxies); + result["ActivityLogRetentionDays"] = Jellyfin::Support::toJsonValue(m_activityLogRetentionDays); + result["LibraryScanFanoutConcurrency"] = Jellyfin::Support::toJsonValue(m_libraryScanFanoutConcurrency); + result["LibraryMetadataRefreshConcurrency"] = Jellyfin::Support::toJsonValue(m_libraryMetadataRefreshConcurrency); + result["RemoveOldPlugins"] = Jellyfin::Support::toJsonValue(m_removeOldPlugins); + result["DisablePluginImages"] = Jellyfin::Support::toJsonValue(m_disablePluginImages); return result; } @@ -646,6 +647,17 @@ void ServerConfiguration::setDisablePluginImages(bool newDisablePluginImages) { m_disablePluginImages = newDisablePluginImages; } +} // NS DTO + +namespace Support { + +using ServerConfiguration = Jellyfin::DTO::ServerConfiguration; + +template <> +ServerConfiguration fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ServerConfiguration::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/sessioninfo.cpp b/core/src/DTO/sessioninfo.cpp index 66a740b..fda236a 100644 --- a/core/src/DTO/sessioninfo.cpp +++ b/core/src/DTO/sessioninfo.cpp @@ -32,76 +32,77 @@ namespace Jellyfin { namespace DTO { -SessionInfo::SessionInfo(QObject *parent) {} +SessionInfo::SessionInfo() {} -SessionInfo SessionInfo::fromJson(QJsonObject source) {SessionInfo instance; - instance->setFromJson(source, false); +SessionInfo SessionInfo::fromJson(QJsonObject source) { + SessionInfo instance; + instance.setFromJson(source); return instance; } void SessionInfo::setFromJson(QJsonObject source) { - m_playState = fromJsonValue>(source["PlayState"]); - m_additionalUsers = fromJsonValue>>(source["AdditionalUsers"]); - m_capabilities = fromJsonValue>(source["Capabilities"]); - m_remoteEndPoint = fromJsonValue(source["RemoteEndPoint"]); - m_playableMediaTypes = fromJsonValue(source["PlayableMediaTypes"]); - m_jellyfinId = fromJsonValue(source["Id"]); - m_userId = fromJsonValue(source["UserId"]); - m_userName = fromJsonValue(source["UserName"]); - m_client = fromJsonValue(source["Client"]); - m_lastActivityDate = fromJsonValue(source["LastActivityDate"]); - m_lastPlaybackCheckIn = fromJsonValue(source["LastPlaybackCheckIn"]); - m_deviceName = fromJsonValue(source["DeviceName"]); - m_deviceType = fromJsonValue(source["DeviceType"]); - m_nowPlayingItem = fromJsonValue>(source["NowPlayingItem"]); - m_fullNowPlayingItem = fromJsonValue>(source["FullNowPlayingItem"]); - m_nowViewingItem = fromJsonValue>(source["NowViewingItem"]); - m_deviceId = fromJsonValue(source["DeviceId"]); - m_applicationVersion = fromJsonValue(source["ApplicationVersion"]); - m_transcodingInfo = fromJsonValue>(source["TranscodingInfo"]); - m_isActive = fromJsonValue(source["IsActive"]); - m_supportsMediaControl = fromJsonValue(source["SupportsMediaControl"]); - m_supportsRemoteControl = fromJsonValue(source["SupportsRemoteControl"]); - m_nowPlayingQueue = fromJsonValue>>(source["NowPlayingQueue"]); - m_hasCustomDeviceName = fromJsonValue(source["HasCustomDeviceName"]); - m_playlistItemId = fromJsonValue(source["PlaylistItemId"]); - m_serverId = fromJsonValue(source["ServerId"]); - m_userPrimaryImageTag = fromJsonValue(source["UserPrimaryImageTag"]); - m_supportedCommands = fromJsonValue>(source["SupportedCommands"]); + m_playState = Jellyfin::Support::fromJsonValue>(source["PlayState"]); + m_additionalUsers = Jellyfin::Support::fromJsonValue>>(source["AdditionalUsers"]); + m_capabilities = Jellyfin::Support::fromJsonValue>(source["Capabilities"]); + m_remoteEndPoint = Jellyfin::Support::fromJsonValue(source["RemoteEndPoint"]); + m_playableMediaTypes = Jellyfin::Support::fromJsonValue(source["PlayableMediaTypes"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); + m_userId = Jellyfin::Support::fromJsonValue(source["UserId"]); + m_userName = Jellyfin::Support::fromJsonValue(source["UserName"]); + m_client = Jellyfin::Support::fromJsonValue(source["Client"]); + m_lastActivityDate = Jellyfin::Support::fromJsonValue(source["LastActivityDate"]); + m_lastPlaybackCheckIn = Jellyfin::Support::fromJsonValue(source["LastPlaybackCheckIn"]); + m_deviceName = Jellyfin::Support::fromJsonValue(source["DeviceName"]); + m_deviceType = Jellyfin::Support::fromJsonValue(source["DeviceType"]); + m_nowPlayingItem = Jellyfin::Support::fromJsonValue>(source["NowPlayingItem"]); + m_fullNowPlayingItem = Jellyfin::Support::fromJsonValue>(source["FullNowPlayingItem"]); + m_nowViewingItem = Jellyfin::Support::fromJsonValue>(source["NowViewingItem"]); + m_deviceId = Jellyfin::Support::fromJsonValue(source["DeviceId"]); + m_applicationVersion = Jellyfin::Support::fromJsonValue(source["ApplicationVersion"]); + m_transcodingInfo = Jellyfin::Support::fromJsonValue>(source["TranscodingInfo"]); + m_isActive = Jellyfin::Support::fromJsonValue(source["IsActive"]); + m_supportsMediaControl = Jellyfin::Support::fromJsonValue(source["SupportsMediaControl"]); + m_supportsRemoteControl = Jellyfin::Support::fromJsonValue(source["SupportsRemoteControl"]); + m_nowPlayingQueue = Jellyfin::Support::fromJsonValue>>(source["NowPlayingQueue"]); + m_hasCustomDeviceName = Jellyfin::Support::fromJsonValue(source["HasCustomDeviceName"]); + m_playlistItemId = Jellyfin::Support::fromJsonValue(source["PlaylistItemId"]); + m_serverId = Jellyfin::Support::fromJsonValue(source["ServerId"]); + m_userPrimaryImageTag = Jellyfin::Support::fromJsonValue(source["UserPrimaryImageTag"]); + m_supportedCommands = Jellyfin::Support::fromJsonValue>(source["SupportedCommands"]); } QJsonObject SessionInfo::toJson() { QJsonObject result; - result["PlayState"] = toJsonValue>(m_playState); - result["AdditionalUsers"] = toJsonValue>>(m_additionalUsers); - result["Capabilities"] = toJsonValue>(m_capabilities); - result["RemoteEndPoint"] = toJsonValue(m_remoteEndPoint); - result["PlayableMediaTypes"] = toJsonValue(m_playableMediaTypes); - result["Id"] = toJsonValue(m_jellyfinId); - result["UserId"] = toJsonValue(m_userId); - result["UserName"] = toJsonValue(m_userName); - result["Client"] = toJsonValue(m_client); - result["LastActivityDate"] = toJsonValue(m_lastActivityDate); - result["LastPlaybackCheckIn"] = toJsonValue(m_lastPlaybackCheckIn); - result["DeviceName"] = toJsonValue(m_deviceName); - result["DeviceType"] = toJsonValue(m_deviceType); - result["NowPlayingItem"] = toJsonValue>(m_nowPlayingItem); - result["FullNowPlayingItem"] = toJsonValue>(m_fullNowPlayingItem); - result["NowViewingItem"] = toJsonValue>(m_nowViewingItem); - result["DeviceId"] = toJsonValue(m_deviceId); - result["ApplicationVersion"] = toJsonValue(m_applicationVersion); - result["TranscodingInfo"] = toJsonValue>(m_transcodingInfo); - result["IsActive"] = toJsonValue(m_isActive); - result["SupportsMediaControl"] = toJsonValue(m_supportsMediaControl); - result["SupportsRemoteControl"] = toJsonValue(m_supportsRemoteControl); - result["NowPlayingQueue"] = toJsonValue>>(m_nowPlayingQueue); - result["HasCustomDeviceName"] = toJsonValue(m_hasCustomDeviceName); - result["PlaylistItemId"] = toJsonValue(m_playlistItemId); - result["ServerId"] = toJsonValue(m_serverId); - result["UserPrimaryImageTag"] = toJsonValue(m_userPrimaryImageTag); - result["SupportedCommands"] = toJsonValue>(m_supportedCommands); + result["PlayState"] = Jellyfin::Support::toJsonValue>(m_playState); + result["AdditionalUsers"] = Jellyfin::Support::toJsonValue>>(m_additionalUsers); + result["Capabilities"] = Jellyfin::Support::toJsonValue>(m_capabilities); + result["RemoteEndPoint"] = Jellyfin::Support::toJsonValue(m_remoteEndPoint); + result["PlayableMediaTypes"] = Jellyfin::Support::toJsonValue(m_playableMediaTypes); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); + result["UserName"] = Jellyfin::Support::toJsonValue(m_userName); + result["Client"] = Jellyfin::Support::toJsonValue(m_client); + result["LastActivityDate"] = Jellyfin::Support::toJsonValue(m_lastActivityDate); + result["LastPlaybackCheckIn"] = Jellyfin::Support::toJsonValue(m_lastPlaybackCheckIn); + result["DeviceName"] = Jellyfin::Support::toJsonValue(m_deviceName); + result["DeviceType"] = Jellyfin::Support::toJsonValue(m_deviceType); + result["NowPlayingItem"] = Jellyfin::Support::toJsonValue>(m_nowPlayingItem); + result["FullNowPlayingItem"] = Jellyfin::Support::toJsonValue>(m_fullNowPlayingItem); + result["NowViewingItem"] = Jellyfin::Support::toJsonValue>(m_nowViewingItem); + result["DeviceId"] = Jellyfin::Support::toJsonValue(m_deviceId); + result["ApplicationVersion"] = Jellyfin::Support::toJsonValue(m_applicationVersion); + result["TranscodingInfo"] = Jellyfin::Support::toJsonValue>(m_transcodingInfo); + result["IsActive"] = Jellyfin::Support::toJsonValue(m_isActive); + result["SupportsMediaControl"] = Jellyfin::Support::toJsonValue(m_supportsMediaControl); + result["SupportsRemoteControl"] = Jellyfin::Support::toJsonValue(m_supportsRemoteControl); + result["NowPlayingQueue"] = Jellyfin::Support::toJsonValue>>(m_nowPlayingQueue); + result["HasCustomDeviceName"] = Jellyfin::Support::toJsonValue(m_hasCustomDeviceName); + result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); + result["ServerId"] = Jellyfin::Support::toJsonValue(m_serverId); + result["UserPrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_userPrimaryImageTag); + result["SupportedCommands"] = Jellyfin::Support::toJsonValue>(m_supportedCommands); return result; } @@ -247,6 +248,17 @@ void SessionInfo::setSupportedCommands(QList newSupportedCom m_supportedCommands = newSupportedCommands; } +} // NS DTO + +namespace Support { + +using SessionInfo = Jellyfin::DTO::SessionInfo; + +template <> +SessionInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return SessionInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/sessionuserinfo.cpp b/core/src/DTO/sessionuserinfo.cpp index 81f6474..e388fc9 100644 --- a/core/src/DTO/sessionuserinfo.cpp +++ b/core/src/DTO/sessionuserinfo.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -SessionUserInfo::SessionUserInfo(QObject *parent) {} +SessionUserInfo::SessionUserInfo() {} -SessionUserInfo SessionUserInfo::fromJson(QJsonObject source) {SessionUserInfo instance; - instance->setFromJson(source, false); +SessionUserInfo SessionUserInfo::fromJson(QJsonObject source) { + SessionUserInfo instance; + instance.setFromJson(source); return instance; } void SessionUserInfo::setFromJson(QJsonObject source) { - m_userId = fromJsonValue(source["UserId"]); - m_userName = fromJsonValue(source["UserName"]); + m_userId = Jellyfin::Support::fromJsonValue(source["UserId"]); + m_userName = Jellyfin::Support::fromJsonValue(source["UserName"]); } QJsonObject SessionUserInfo::toJson() { QJsonObject result; - result["UserId"] = toJsonValue(m_userId); - result["UserName"] = toJsonValue(m_userName); + result["UserId"] = Jellyfin::Support::toJsonValue(m_userId); + result["UserName"] = Jellyfin::Support::toJsonValue(m_userName); return result; } @@ -65,6 +66,17 @@ void SessionUserInfo::setUserName(QString newUserName) { m_userName = newUserName; } +} // NS DTO + +namespace Support { + +using SessionUserInfo = Jellyfin::DTO::SessionUserInfo; + +template <> +SessionUserInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return SessionUserInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/setchannelmappingdto.cpp b/core/src/DTO/setchannelmappingdto.cpp index 8dfbe3f..eee6f36 100644 --- a/core/src/DTO/setchannelmappingdto.cpp +++ b/core/src/DTO/setchannelmappingdto.cpp @@ -32,26 +32,27 @@ namespace Jellyfin { namespace DTO { -SetChannelMappingDto::SetChannelMappingDto(QObject *parent) {} +SetChannelMappingDto::SetChannelMappingDto() {} -SetChannelMappingDto SetChannelMappingDto::fromJson(QJsonObject source) {SetChannelMappingDto instance; - instance->setFromJson(source, false); +SetChannelMappingDto SetChannelMappingDto::fromJson(QJsonObject source) { + SetChannelMappingDto instance; + instance.setFromJson(source); return instance; } void SetChannelMappingDto::setFromJson(QJsonObject source) { - m_providerId = fromJsonValue(source["ProviderId"]); - m_tunerChannelId = fromJsonValue(source["TunerChannelId"]); - m_providerChannelId = fromJsonValue(source["ProviderChannelId"]); + m_providerId = Jellyfin::Support::fromJsonValue(source["ProviderId"]); + m_tunerChannelId = Jellyfin::Support::fromJsonValue(source["TunerChannelId"]); + m_providerChannelId = Jellyfin::Support::fromJsonValue(source["ProviderChannelId"]); } QJsonObject SetChannelMappingDto::toJson() { QJsonObject result; - result["ProviderId"] = toJsonValue(m_providerId); - result["TunerChannelId"] = toJsonValue(m_tunerChannelId); - result["ProviderChannelId"] = toJsonValue(m_providerChannelId); + result["ProviderId"] = Jellyfin::Support::toJsonValue(m_providerId); + result["TunerChannelId"] = Jellyfin::Support::toJsonValue(m_tunerChannelId); + result["ProviderChannelId"] = Jellyfin::Support::toJsonValue(m_providerChannelId); return result; } @@ -72,6 +73,17 @@ void SetChannelMappingDto::setProviderChannelId(QString newProviderChannelId) { m_providerChannelId = newProviderChannelId; } +} // NS DTO + +namespace Support { + +using SetChannelMappingDto = Jellyfin::DTO::SetChannelMappingDto; + +template <> +SetChannelMappingDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return SetChannelMappingDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/setplaylistitemrequestdto.cpp b/core/src/DTO/setplaylistitemrequestdto.cpp index d48ec1b..a242aa8 100644 --- a/core/src/DTO/setplaylistitemrequestdto.cpp +++ b/core/src/DTO/setplaylistitemrequestdto.cpp @@ -32,22 +32,23 @@ namespace Jellyfin { namespace DTO { -SetPlaylistItemRequestDto::SetPlaylistItemRequestDto(QObject *parent) {} +SetPlaylistItemRequestDto::SetPlaylistItemRequestDto() {} -SetPlaylistItemRequestDto SetPlaylistItemRequestDto::fromJson(QJsonObject source) {SetPlaylistItemRequestDto instance; - instance->setFromJson(source, false); +SetPlaylistItemRequestDto SetPlaylistItemRequestDto::fromJson(QJsonObject source) { + SetPlaylistItemRequestDto instance; + instance.setFromJson(source); return instance; } void SetPlaylistItemRequestDto::setFromJson(QJsonObject source) { - m_playlistItemId = fromJsonValue(source["PlaylistItemId"]); + m_playlistItemId = Jellyfin::Support::fromJsonValue(source["PlaylistItemId"]); } QJsonObject SetPlaylistItemRequestDto::toJson() { QJsonObject result; - result["PlaylistItemId"] = toJsonValue(m_playlistItemId); + result["PlaylistItemId"] = Jellyfin::Support::toJsonValue(m_playlistItemId); return result; } @@ -58,6 +59,17 @@ void SetPlaylistItemRequestDto::setPlaylistItemId(QUuid newPlaylistItemId) { m_playlistItemId = newPlaylistItemId; } +} // NS DTO + +namespace Support { + +using SetPlaylistItemRequestDto = Jellyfin::DTO::SetPlaylistItemRequestDto; + +template <> +SetPlaylistItemRequestDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return SetPlaylistItemRequestDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/setrepeatmoderequestdto.cpp b/core/src/DTO/setrepeatmoderequestdto.cpp index 3de03c8..c0f3788 100644 --- a/core/src/DTO/setrepeatmoderequestdto.cpp +++ b/core/src/DTO/setrepeatmoderequestdto.cpp @@ -32,22 +32,23 @@ namespace Jellyfin { namespace DTO { -SetRepeatModeRequestDto::SetRepeatModeRequestDto(QObject *parent) {} +SetRepeatModeRequestDto::SetRepeatModeRequestDto() {} -SetRepeatModeRequestDto SetRepeatModeRequestDto::fromJson(QJsonObject source) {SetRepeatModeRequestDto instance; - instance->setFromJson(source, false); +SetRepeatModeRequestDto SetRepeatModeRequestDto::fromJson(QJsonObject source) { + SetRepeatModeRequestDto instance; + instance.setFromJson(source); return instance; } void SetRepeatModeRequestDto::setFromJson(QJsonObject source) { - m_mode = fromJsonValue(source["Mode"]); + m_mode = Jellyfin::Support::fromJsonValue(source["Mode"]); } QJsonObject SetRepeatModeRequestDto::toJson() { QJsonObject result; - result["Mode"] = toJsonValue(m_mode); + result["Mode"] = Jellyfin::Support::toJsonValue(m_mode); return result; } @@ -58,6 +59,17 @@ void SetRepeatModeRequestDto::setMode(GroupRepeatMode newMode) { m_mode = newMode; } +} // NS DTO + +namespace Support { + +using SetRepeatModeRequestDto = Jellyfin::DTO::SetRepeatModeRequestDto; + +template <> +SetRepeatModeRequestDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return SetRepeatModeRequestDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/setshufflemoderequestdto.cpp b/core/src/DTO/setshufflemoderequestdto.cpp index 5285bfe..8d9eb3d 100644 --- a/core/src/DTO/setshufflemoderequestdto.cpp +++ b/core/src/DTO/setshufflemoderequestdto.cpp @@ -32,22 +32,23 @@ namespace Jellyfin { namespace DTO { -SetShuffleModeRequestDto::SetShuffleModeRequestDto(QObject *parent) {} +SetShuffleModeRequestDto::SetShuffleModeRequestDto() {} -SetShuffleModeRequestDto SetShuffleModeRequestDto::fromJson(QJsonObject source) {SetShuffleModeRequestDto instance; - instance->setFromJson(source, false); +SetShuffleModeRequestDto SetShuffleModeRequestDto::fromJson(QJsonObject source) { + SetShuffleModeRequestDto instance; + instance.setFromJson(source); return instance; } void SetShuffleModeRequestDto::setFromJson(QJsonObject source) { - m_mode = fromJsonValue(source["Mode"]); + m_mode = Jellyfin::Support::fromJsonValue(source["Mode"]); } QJsonObject SetShuffleModeRequestDto::toJson() { QJsonObject result; - result["Mode"] = toJsonValue(m_mode); + result["Mode"] = Jellyfin::Support::toJsonValue(m_mode); return result; } @@ -58,6 +59,17 @@ void SetShuffleModeRequestDto::setMode(GroupShuffleMode newMode) { m_mode = newMode; } +} // NS DTO + +namespace Support { + +using SetShuffleModeRequestDto = Jellyfin::DTO::SetShuffleModeRequestDto; + +template <> +SetShuffleModeRequestDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return SetShuffleModeRequestDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/songinfo.cpp b/core/src/DTO/songinfo.cpp index d28ffa9..a4d1b67 100644 --- a/core/src/DTO/songinfo.cpp +++ b/core/src/DTO/songinfo.cpp @@ -32,46 +32,47 @@ namespace Jellyfin { namespace DTO { -SongInfo::SongInfo(QObject *parent) {} +SongInfo::SongInfo() {} -SongInfo SongInfo::fromJson(QJsonObject source) {SongInfo instance; - instance->setFromJson(source, false); +SongInfo SongInfo::fromJson(QJsonObject source) { + SongInfo instance; + instance.setFromJson(source); return instance; } void SongInfo::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_path = fromJsonValue(source["Path"]); - m_metadataLanguage = fromJsonValue(source["MetadataLanguage"]); - m_metadataCountryCode = fromJsonValue(source["MetadataCountryCode"]); - m_providerIds = fromJsonValue(source["ProviderIds"]); - m_year = fromJsonValue(source["Year"]); - m_indexNumber = fromJsonValue(source["IndexNumber"]); - m_parentIndexNumber = fromJsonValue(source["ParentIndexNumber"]); - m_premiereDate = fromJsonValue(source["PremiereDate"]); - m_isAutomated = fromJsonValue(source["IsAutomated"]); - m_albumArtists = fromJsonValue(source["AlbumArtists"]); - m_album = fromJsonValue(source["Album"]); - m_artists = fromJsonValue(source["Artists"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_path = Jellyfin::Support::fromJsonValue(source["Path"]); + m_metadataLanguage = Jellyfin::Support::fromJsonValue(source["MetadataLanguage"]); + m_metadataCountryCode = Jellyfin::Support::fromJsonValue(source["MetadataCountryCode"]); + m_providerIds = Jellyfin::Support::fromJsonValue(source["ProviderIds"]); + m_year = Jellyfin::Support::fromJsonValue(source["Year"]); + m_indexNumber = Jellyfin::Support::fromJsonValue(source["IndexNumber"]); + m_parentIndexNumber = Jellyfin::Support::fromJsonValue(source["ParentIndexNumber"]); + m_premiereDate = Jellyfin::Support::fromJsonValue(source["PremiereDate"]); + m_isAutomated = Jellyfin::Support::fromJsonValue(source["IsAutomated"]); + m_albumArtists = Jellyfin::Support::fromJsonValue(source["AlbumArtists"]); + m_album = Jellyfin::Support::fromJsonValue(source["Album"]); + m_artists = Jellyfin::Support::fromJsonValue(source["Artists"]); } QJsonObject SongInfo::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Path"] = toJsonValue(m_path); - result["MetadataLanguage"] = toJsonValue(m_metadataLanguage); - result["MetadataCountryCode"] = toJsonValue(m_metadataCountryCode); - result["ProviderIds"] = toJsonValue(m_providerIds); - result["Year"] = toJsonValue(m_year); - result["IndexNumber"] = toJsonValue(m_indexNumber); - result["ParentIndexNumber"] = toJsonValue(m_parentIndexNumber); - result["PremiereDate"] = toJsonValue(m_premiereDate); - result["IsAutomated"] = toJsonValue(m_isAutomated); - result["AlbumArtists"] = toJsonValue(m_albumArtists); - result["Album"] = toJsonValue(m_album); - result["Artists"] = toJsonValue(m_artists); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); + result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); + result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); + result["Year"] = Jellyfin::Support::toJsonValue(m_year); + result["IndexNumber"] = Jellyfin::Support::toJsonValue(m_indexNumber); + result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue(m_parentIndexNumber); + result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); + result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); + result["AlbumArtists"] = Jellyfin::Support::toJsonValue(m_albumArtists); + result["Album"] = Jellyfin::Support::toJsonValue(m_album); + result["Artists"] = Jellyfin::Support::toJsonValue(m_artists); return result; } @@ -142,6 +143,17 @@ void SongInfo::setArtists(QStringList newArtists) { m_artists = newArtists; } +} // NS DTO + +namespace Support { + +using SongInfo = Jellyfin::DTO::SongInfo; + +template <> +SongInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return SongInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/sortorder.cpp b/core/src/DTO/sortorder.cpp index 036f27f..2d7b2a2 100644 --- a/core/src/DTO/sortorder.cpp +++ b/core/src/DTO/sortorder.cpp @@ -34,5 +34,27 @@ namespace DTO { SortOrderClass::SortOrderClass() {} + +} // NS DTO + +namespace Support { + +using SortOrder = Jellyfin::DTO::SortOrder; + +template <> +SortOrder fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return SortOrder::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Ascending")) { + return SortOrder::Ascending; + } + if (str == QStringLiteral("Descending")) { + return SortOrder::Descending; + } + + return SortOrder::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/specialviewoptiondto.cpp b/core/src/DTO/specialviewoptiondto.cpp index bb39a0f..1f98d15 100644 --- a/core/src/DTO/specialviewoptiondto.cpp +++ b/core/src/DTO/specialviewoptiondto.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -SpecialViewOptionDto::SpecialViewOptionDto(QObject *parent) {} +SpecialViewOptionDto::SpecialViewOptionDto() {} -SpecialViewOptionDto SpecialViewOptionDto::fromJson(QJsonObject source) {SpecialViewOptionDto instance; - instance->setFromJson(source, false); +SpecialViewOptionDto SpecialViewOptionDto::fromJson(QJsonObject source) { + SpecialViewOptionDto instance; + instance.setFromJson(source); return instance; } void SpecialViewOptionDto::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_jellyfinId = fromJsonValue(source["Id"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); } QJsonObject SpecialViewOptionDto::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Id"] = toJsonValue(m_jellyfinId); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); return result; } @@ -65,6 +66,17 @@ void SpecialViewOptionDto::setJellyfinId(QString newJellyfinId) { m_jellyfinId = newJellyfinId; } +} // NS DTO + +namespace Support { + +using SpecialViewOptionDto = Jellyfin::DTO::SpecialViewOptionDto; + +template <> +SpecialViewOptionDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return SpecialViewOptionDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/startupconfigurationdto.cpp b/core/src/DTO/startupconfigurationdto.cpp index 2f4d0f3..a8398e5 100644 --- a/core/src/DTO/startupconfigurationdto.cpp +++ b/core/src/DTO/startupconfigurationdto.cpp @@ -32,26 +32,27 @@ namespace Jellyfin { namespace DTO { -StartupConfigurationDto::StartupConfigurationDto(QObject *parent) {} +StartupConfigurationDto::StartupConfigurationDto() {} -StartupConfigurationDto StartupConfigurationDto::fromJson(QJsonObject source) {StartupConfigurationDto instance; - instance->setFromJson(source, false); +StartupConfigurationDto StartupConfigurationDto::fromJson(QJsonObject source) { + StartupConfigurationDto instance; + instance.setFromJson(source); return instance; } void StartupConfigurationDto::setFromJson(QJsonObject source) { - m_uICulture = fromJsonValue(source["UICulture"]); - m_metadataCountryCode = fromJsonValue(source["MetadataCountryCode"]); - m_preferredMetadataLanguage = fromJsonValue(source["PreferredMetadataLanguage"]); + m_uICulture = Jellyfin::Support::fromJsonValue(source["UICulture"]); + m_metadataCountryCode = Jellyfin::Support::fromJsonValue(source["MetadataCountryCode"]); + m_preferredMetadataLanguage = Jellyfin::Support::fromJsonValue(source["PreferredMetadataLanguage"]); } QJsonObject StartupConfigurationDto::toJson() { QJsonObject result; - result["UICulture"] = toJsonValue(m_uICulture); - result["MetadataCountryCode"] = toJsonValue(m_metadataCountryCode); - result["PreferredMetadataLanguage"] = toJsonValue(m_preferredMetadataLanguage); + result["UICulture"] = Jellyfin::Support::toJsonValue(m_uICulture); + result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); + result["PreferredMetadataLanguage"] = Jellyfin::Support::toJsonValue(m_preferredMetadataLanguage); return result; } @@ -72,6 +73,17 @@ void StartupConfigurationDto::setPreferredMetadataLanguage(QString newPreferredM m_preferredMetadataLanguage = newPreferredMetadataLanguage; } +} // NS DTO + +namespace Support { + +using StartupConfigurationDto = Jellyfin::DTO::StartupConfigurationDto; + +template <> +StartupConfigurationDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return StartupConfigurationDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/startupremoteaccessdto.cpp b/core/src/DTO/startupremoteaccessdto.cpp index 614d9da..5dc70fa 100644 --- a/core/src/DTO/startupremoteaccessdto.cpp +++ b/core/src/DTO/startupremoteaccessdto.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -StartupRemoteAccessDto::StartupRemoteAccessDto(QObject *parent) {} +StartupRemoteAccessDto::StartupRemoteAccessDto() {} -StartupRemoteAccessDto StartupRemoteAccessDto::fromJson(QJsonObject source) {StartupRemoteAccessDto instance; - instance->setFromJson(source, false); +StartupRemoteAccessDto StartupRemoteAccessDto::fromJson(QJsonObject source) { + StartupRemoteAccessDto instance; + instance.setFromJson(source); return instance; } void StartupRemoteAccessDto::setFromJson(QJsonObject source) { - m_enableRemoteAccess = fromJsonValue(source["EnableRemoteAccess"]); - m_enableAutomaticPortMapping = fromJsonValue(source["EnableAutomaticPortMapping"]); + m_enableRemoteAccess = Jellyfin::Support::fromJsonValue(source["EnableRemoteAccess"]); + m_enableAutomaticPortMapping = Jellyfin::Support::fromJsonValue(source["EnableAutomaticPortMapping"]); } QJsonObject StartupRemoteAccessDto::toJson() { QJsonObject result; - result["EnableRemoteAccess"] = toJsonValue(m_enableRemoteAccess); - result["EnableAutomaticPortMapping"] = toJsonValue(m_enableAutomaticPortMapping); + result["EnableRemoteAccess"] = Jellyfin::Support::toJsonValue(m_enableRemoteAccess); + result["EnableAutomaticPortMapping"] = Jellyfin::Support::toJsonValue(m_enableAutomaticPortMapping); return result; } @@ -65,6 +66,17 @@ void StartupRemoteAccessDto::setEnableAutomaticPortMapping(bool newEnableAutomat m_enableAutomaticPortMapping = newEnableAutomaticPortMapping; } +} // NS DTO + +namespace Support { + +using StartupRemoteAccessDto = Jellyfin::DTO::StartupRemoteAccessDto; + +template <> +StartupRemoteAccessDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return StartupRemoteAccessDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/startupuserdto.cpp b/core/src/DTO/startupuserdto.cpp index 3fbcd19..dc5eb2e 100644 --- a/core/src/DTO/startupuserdto.cpp +++ b/core/src/DTO/startupuserdto.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -StartupUserDto::StartupUserDto(QObject *parent) {} +StartupUserDto::StartupUserDto() {} -StartupUserDto StartupUserDto::fromJson(QJsonObject source) {StartupUserDto instance; - instance->setFromJson(source, false); +StartupUserDto StartupUserDto::fromJson(QJsonObject source) { + StartupUserDto instance; + instance.setFromJson(source); return instance; } void StartupUserDto::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_password = fromJsonValue(source["Password"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_password = Jellyfin::Support::fromJsonValue(source["Password"]); } QJsonObject StartupUserDto::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Password"] = toJsonValue(m_password); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Password"] = Jellyfin::Support::toJsonValue(m_password); return result; } @@ -65,6 +66,17 @@ void StartupUserDto::setPassword(QString newPassword) { m_password = newPassword; } +} // NS DTO + +namespace Support { + +using StartupUserDto = Jellyfin::DTO::StartupUserDto; + +template <> +StartupUserDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return StartupUserDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/subtitledeliverymethod.cpp b/core/src/DTO/subtitledeliverymethod.cpp index 6d9857d..94f5d7a 100644 --- a/core/src/DTO/subtitledeliverymethod.cpp +++ b/core/src/DTO/subtitledeliverymethod.cpp @@ -34,5 +34,33 @@ namespace DTO { SubtitleDeliveryMethodClass::SubtitleDeliveryMethodClass() {} + +} // NS DTO + +namespace Support { + +using SubtitleDeliveryMethod = Jellyfin::DTO::SubtitleDeliveryMethod; + +template <> +SubtitleDeliveryMethod fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return SubtitleDeliveryMethod::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Encode")) { + return SubtitleDeliveryMethod::Encode; + } + if (str == QStringLiteral("Embed")) { + return SubtitleDeliveryMethod::Embed; + } + if (str == QStringLiteral("External")) { + return SubtitleDeliveryMethod::External; + } + if (str == QStringLiteral("Hls")) { + return SubtitleDeliveryMethod::Hls; + } + + return SubtitleDeliveryMethod::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/subtitleplaybackmode.cpp b/core/src/DTO/subtitleplaybackmode.cpp index a50592c..3cbd26a 100644 --- a/core/src/DTO/subtitleplaybackmode.cpp +++ b/core/src/DTO/subtitleplaybackmode.cpp @@ -34,5 +34,36 @@ namespace DTO { SubtitlePlaybackModeClass::SubtitlePlaybackModeClass() {} + +} // NS DTO + +namespace Support { + +using SubtitlePlaybackMode = Jellyfin::DTO::SubtitlePlaybackMode; + +template <> +SubtitlePlaybackMode fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return SubtitlePlaybackMode::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Default")) { + return SubtitlePlaybackMode::Default; + } + if (str == QStringLiteral("Always")) { + return SubtitlePlaybackMode::Always; + } + if (str == QStringLiteral("OnlyForced")) { + return SubtitlePlaybackMode::OnlyForced; + } + if (str == QStringLiteral("None")) { + return SubtitlePlaybackMode::None; + } + if (str == QStringLiteral("Smart")) { + return SubtitlePlaybackMode::Smart; + } + + return SubtitlePlaybackMode::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/subtitleprofile.cpp b/core/src/DTO/subtitleprofile.cpp index 7eb43fb..361f16a 100644 --- a/core/src/DTO/subtitleprofile.cpp +++ b/core/src/DTO/subtitleprofile.cpp @@ -32,30 +32,31 @@ namespace Jellyfin { namespace DTO { -SubtitleProfile::SubtitleProfile(QObject *parent) {} +SubtitleProfile::SubtitleProfile() {} -SubtitleProfile SubtitleProfile::fromJson(QJsonObject source) {SubtitleProfile instance; - instance->setFromJson(source, false); +SubtitleProfile SubtitleProfile::fromJson(QJsonObject source) { + SubtitleProfile instance; + instance.setFromJson(source); return instance; } void SubtitleProfile::setFromJson(QJsonObject source) { - m_format = fromJsonValue(source["Format"]); - m_method = fromJsonValue(source["Method"]); - m_didlMode = fromJsonValue(source["DidlMode"]); - m_language = fromJsonValue(source["Language"]); - m_container = fromJsonValue(source["Container"]); + m_format = Jellyfin::Support::fromJsonValue(source["Format"]); + m_method = Jellyfin::Support::fromJsonValue(source["Method"]); + m_didlMode = Jellyfin::Support::fromJsonValue(source["DidlMode"]); + m_language = Jellyfin::Support::fromJsonValue(source["Language"]); + m_container = Jellyfin::Support::fromJsonValue(source["Container"]); } QJsonObject SubtitleProfile::toJson() { QJsonObject result; - result["Format"] = toJsonValue(m_format); - result["Method"] = toJsonValue(m_method); - result["DidlMode"] = toJsonValue(m_didlMode); - result["Language"] = toJsonValue(m_language); - result["Container"] = toJsonValue(m_container); + result["Format"] = Jellyfin::Support::toJsonValue(m_format); + result["Method"] = Jellyfin::Support::toJsonValue(m_method); + result["DidlMode"] = Jellyfin::Support::toJsonValue(m_didlMode); + result["Language"] = Jellyfin::Support::toJsonValue(m_language); + result["Container"] = Jellyfin::Support::toJsonValue(m_container); return result; } @@ -86,6 +87,17 @@ void SubtitleProfile::setContainer(QString newContainer) { m_container = newContainer; } +} // NS DTO + +namespace Support { + +using SubtitleProfile = Jellyfin::DTO::SubtitleProfile; + +template <> +SubtitleProfile fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return SubtitleProfile::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/syncplayuseraccesstype.cpp b/core/src/DTO/syncplayuseraccesstype.cpp index ca5852f..772d2d7 100644 --- a/core/src/DTO/syncplayuseraccesstype.cpp +++ b/core/src/DTO/syncplayuseraccesstype.cpp @@ -34,5 +34,30 @@ namespace DTO { SyncPlayUserAccessTypeClass::SyncPlayUserAccessTypeClass() {} + +} // NS DTO + +namespace Support { + +using SyncPlayUserAccessType = Jellyfin::DTO::SyncPlayUserAccessType; + +template <> +SyncPlayUserAccessType fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return SyncPlayUserAccessType::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("CreateAndJoinGroups")) { + return SyncPlayUserAccessType::CreateAndJoinGroups; + } + if (str == QStringLiteral("JoinGroups")) { + return SyncPlayUserAccessType::JoinGroups; + } + if (str == QStringLiteral("None")) { + return SyncPlayUserAccessType::None; + } + + return SyncPlayUserAccessType::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/systeminfo.cpp b/core/src/DTO/systeminfo.cpp index de8f45e..cfa5d8a 100644 --- a/core/src/DTO/systeminfo.cpp +++ b/core/src/DTO/systeminfo.cpp @@ -32,72 +32,73 @@ namespace Jellyfin { namespace DTO { -SystemInfo::SystemInfo(QObject *parent) {} +SystemInfo::SystemInfo() {} -SystemInfo SystemInfo::fromJson(QJsonObject source) {SystemInfo instance; - instance->setFromJson(source, false); +SystemInfo SystemInfo::fromJson(QJsonObject source) { + SystemInfo instance; + instance.setFromJson(source); return instance; } void SystemInfo::setFromJson(QJsonObject source) { - m_localAddress = fromJsonValue(source["LocalAddress"]); - m_serverName = fromJsonValue(source["ServerName"]); - m_version = fromJsonValue(source["Version"]); - m_productName = fromJsonValue(source["ProductName"]); - m_operatingSystem = fromJsonValue(source["OperatingSystem"]); - m_jellyfinId = fromJsonValue(source["Id"]); - m_startupWizardCompleted = fromJsonValue(source["StartupWizardCompleted"]); - m_operatingSystemDisplayName = fromJsonValue(source["OperatingSystemDisplayName"]); - m_packageName = fromJsonValue(source["PackageName"]); - m_hasPendingRestart = fromJsonValue(source["HasPendingRestart"]); - m_isShuttingDown = fromJsonValue(source["IsShuttingDown"]); - m_supportsLibraryMonitor = fromJsonValue(source["SupportsLibraryMonitor"]); - m_webSocketPortNumber = fromJsonValue(source["WebSocketPortNumber"]); - m_completedInstallations = fromJsonValue>>(source["CompletedInstallations"]); - m_canSelfRestart = fromJsonValue(source["CanSelfRestart"]); - m_canLaunchWebBrowser = fromJsonValue(source["CanLaunchWebBrowser"]); - m_programDataPath = fromJsonValue(source["ProgramDataPath"]); - m_webPath = fromJsonValue(source["WebPath"]); - m_itemsByNamePath = fromJsonValue(source["ItemsByNamePath"]); - m_cachePath = fromJsonValue(source["CachePath"]); - m_logPath = fromJsonValue(source["LogPath"]); - m_internalMetadataPath = fromJsonValue(source["InternalMetadataPath"]); - m_transcodingTempPath = fromJsonValue(source["TranscodingTempPath"]); - m_hasUpdateAvailable = fromJsonValue(source["HasUpdateAvailable"]); - m_encoderLocation = fromJsonValue(source["EncoderLocation"]); - m_systemArchitecture = fromJsonValue(source["SystemArchitecture"]); + m_localAddress = Jellyfin::Support::fromJsonValue(source["LocalAddress"]); + m_serverName = Jellyfin::Support::fromJsonValue(source["ServerName"]); + m_version = Jellyfin::Support::fromJsonValue(source["Version"]); + m_productName = Jellyfin::Support::fromJsonValue(source["ProductName"]); + m_operatingSystem = Jellyfin::Support::fromJsonValue(source["OperatingSystem"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); + m_startupWizardCompleted = Jellyfin::Support::fromJsonValue(source["StartupWizardCompleted"]); + m_operatingSystemDisplayName = Jellyfin::Support::fromJsonValue(source["OperatingSystemDisplayName"]); + m_packageName = Jellyfin::Support::fromJsonValue(source["PackageName"]); + m_hasPendingRestart = Jellyfin::Support::fromJsonValue(source["HasPendingRestart"]); + m_isShuttingDown = Jellyfin::Support::fromJsonValue(source["IsShuttingDown"]); + m_supportsLibraryMonitor = Jellyfin::Support::fromJsonValue(source["SupportsLibraryMonitor"]); + m_webSocketPortNumber = Jellyfin::Support::fromJsonValue(source["WebSocketPortNumber"]); + m_completedInstallations = Jellyfin::Support::fromJsonValue>>(source["CompletedInstallations"]); + m_canSelfRestart = Jellyfin::Support::fromJsonValue(source["CanSelfRestart"]); + m_canLaunchWebBrowser = Jellyfin::Support::fromJsonValue(source["CanLaunchWebBrowser"]); + m_programDataPath = Jellyfin::Support::fromJsonValue(source["ProgramDataPath"]); + m_webPath = Jellyfin::Support::fromJsonValue(source["WebPath"]); + m_itemsByNamePath = Jellyfin::Support::fromJsonValue(source["ItemsByNamePath"]); + m_cachePath = Jellyfin::Support::fromJsonValue(source["CachePath"]); + m_logPath = Jellyfin::Support::fromJsonValue(source["LogPath"]); + m_internalMetadataPath = Jellyfin::Support::fromJsonValue(source["InternalMetadataPath"]); + m_transcodingTempPath = Jellyfin::Support::fromJsonValue(source["TranscodingTempPath"]); + m_hasUpdateAvailable = Jellyfin::Support::fromJsonValue(source["HasUpdateAvailable"]); + m_encoderLocation = Jellyfin::Support::fromJsonValue(source["EncoderLocation"]); + m_systemArchitecture = Jellyfin::Support::fromJsonValue(source["SystemArchitecture"]); } QJsonObject SystemInfo::toJson() { QJsonObject result; - result["LocalAddress"] = toJsonValue(m_localAddress); - result["ServerName"] = toJsonValue(m_serverName); - result["Version"] = toJsonValue(m_version); - result["ProductName"] = toJsonValue(m_productName); - result["OperatingSystem"] = toJsonValue(m_operatingSystem); - result["Id"] = toJsonValue(m_jellyfinId); - result["StartupWizardCompleted"] = toJsonValue(m_startupWizardCompleted); - result["OperatingSystemDisplayName"] = toJsonValue(m_operatingSystemDisplayName); - result["PackageName"] = toJsonValue(m_packageName); - result["HasPendingRestart"] = toJsonValue(m_hasPendingRestart); - result["IsShuttingDown"] = toJsonValue(m_isShuttingDown); - result["SupportsLibraryMonitor"] = toJsonValue(m_supportsLibraryMonitor); - result["WebSocketPortNumber"] = toJsonValue(m_webSocketPortNumber); - result["CompletedInstallations"] = toJsonValue>>(m_completedInstallations); - result["CanSelfRestart"] = toJsonValue(m_canSelfRestart); - result["CanLaunchWebBrowser"] = toJsonValue(m_canLaunchWebBrowser); - result["ProgramDataPath"] = toJsonValue(m_programDataPath); - result["WebPath"] = toJsonValue(m_webPath); - result["ItemsByNamePath"] = toJsonValue(m_itemsByNamePath); - result["CachePath"] = toJsonValue(m_cachePath); - result["LogPath"] = toJsonValue(m_logPath); - result["InternalMetadataPath"] = toJsonValue(m_internalMetadataPath); - result["TranscodingTempPath"] = toJsonValue(m_transcodingTempPath); - result["HasUpdateAvailable"] = toJsonValue(m_hasUpdateAvailable); - result["EncoderLocation"] = toJsonValue(m_encoderLocation); - result["SystemArchitecture"] = toJsonValue(m_systemArchitecture); + result["LocalAddress"] = Jellyfin::Support::toJsonValue(m_localAddress); + result["ServerName"] = Jellyfin::Support::toJsonValue(m_serverName); + result["Version"] = Jellyfin::Support::toJsonValue(m_version); + result["ProductName"] = Jellyfin::Support::toJsonValue(m_productName); + result["OperatingSystem"] = Jellyfin::Support::toJsonValue(m_operatingSystem); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["StartupWizardCompleted"] = Jellyfin::Support::toJsonValue(m_startupWizardCompleted); + result["OperatingSystemDisplayName"] = Jellyfin::Support::toJsonValue(m_operatingSystemDisplayName); + result["PackageName"] = Jellyfin::Support::toJsonValue(m_packageName); + result["HasPendingRestart"] = Jellyfin::Support::toJsonValue(m_hasPendingRestart); + result["IsShuttingDown"] = Jellyfin::Support::toJsonValue(m_isShuttingDown); + result["SupportsLibraryMonitor"] = Jellyfin::Support::toJsonValue(m_supportsLibraryMonitor); + result["WebSocketPortNumber"] = Jellyfin::Support::toJsonValue(m_webSocketPortNumber); + result["CompletedInstallations"] = Jellyfin::Support::toJsonValue>>(m_completedInstallations); + result["CanSelfRestart"] = Jellyfin::Support::toJsonValue(m_canSelfRestart); + result["CanLaunchWebBrowser"] = Jellyfin::Support::toJsonValue(m_canLaunchWebBrowser); + result["ProgramDataPath"] = Jellyfin::Support::toJsonValue(m_programDataPath); + result["WebPath"] = Jellyfin::Support::toJsonValue(m_webPath); + result["ItemsByNamePath"] = Jellyfin::Support::toJsonValue(m_itemsByNamePath); + result["CachePath"] = Jellyfin::Support::toJsonValue(m_cachePath); + result["LogPath"] = Jellyfin::Support::toJsonValue(m_logPath); + result["InternalMetadataPath"] = Jellyfin::Support::toJsonValue(m_internalMetadataPath); + result["TranscodingTempPath"] = Jellyfin::Support::toJsonValue(m_transcodingTempPath); + result["HasUpdateAvailable"] = Jellyfin::Support::toJsonValue(m_hasUpdateAvailable); + result["EncoderLocation"] = Jellyfin::Support::toJsonValue(m_encoderLocation); + result["SystemArchitecture"] = Jellyfin::Support::toJsonValue(m_systemArchitecture); return result; } @@ -233,6 +234,17 @@ void SystemInfo::setSystemArchitecture(Architecture newSystemArchitecture) { m_systemArchitecture = newSystemArchitecture; } +} // NS DTO + +namespace Support { + +using SystemInfo = Jellyfin::DTO::SystemInfo; + +template <> +SystemInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return SystemInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/taskcompletionstatus.cpp b/core/src/DTO/taskcompletionstatus.cpp index 5ba4083..c60c8f8 100644 --- a/core/src/DTO/taskcompletionstatus.cpp +++ b/core/src/DTO/taskcompletionstatus.cpp @@ -34,5 +34,33 @@ namespace DTO { TaskCompletionStatusClass::TaskCompletionStatusClass() {} + +} // NS DTO + +namespace Support { + +using TaskCompletionStatus = Jellyfin::DTO::TaskCompletionStatus; + +template <> +TaskCompletionStatus fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return TaskCompletionStatus::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Completed")) { + return TaskCompletionStatus::Completed; + } + if (str == QStringLiteral("Failed")) { + return TaskCompletionStatus::Failed; + } + if (str == QStringLiteral("Cancelled")) { + return TaskCompletionStatus::Cancelled; + } + if (str == QStringLiteral("Aborted")) { + return TaskCompletionStatus::Aborted; + } + + return TaskCompletionStatus::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/taskinfo.cpp b/core/src/DTO/taskinfo.cpp index e3e4267..b5d3e94 100644 --- a/core/src/DTO/taskinfo.cpp +++ b/core/src/DTO/taskinfo.cpp @@ -32,40 +32,41 @@ namespace Jellyfin { namespace DTO { -TaskInfo::TaskInfo(QObject *parent) {} +TaskInfo::TaskInfo() {} -TaskInfo TaskInfo::fromJson(QJsonObject source) {TaskInfo instance; - instance->setFromJson(source, false); +TaskInfo TaskInfo::fromJson(QJsonObject source) { + TaskInfo instance; + instance.setFromJson(source); return instance; } void TaskInfo::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_state = fromJsonValue(source["State"]); - m_currentProgressPercentage = fromJsonValue(source["CurrentProgressPercentage"]); - m_jellyfinId = fromJsonValue(source["Id"]); - m_lastExecutionResult = fromJsonValue>(source["LastExecutionResult"]); - m_triggers = fromJsonValue>>(source["Triggers"]); - m_description = fromJsonValue(source["Description"]); - m_category = fromJsonValue(source["Category"]); - m_isHidden = fromJsonValue(source["IsHidden"]); - m_key = fromJsonValue(source["Key"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_state = Jellyfin::Support::fromJsonValue(source["State"]); + m_currentProgressPercentage = Jellyfin::Support::fromJsonValue(source["CurrentProgressPercentage"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); + m_lastExecutionResult = Jellyfin::Support::fromJsonValue>(source["LastExecutionResult"]); + m_triggers = Jellyfin::Support::fromJsonValue>>(source["Triggers"]); + m_description = Jellyfin::Support::fromJsonValue(source["Description"]); + m_category = Jellyfin::Support::fromJsonValue(source["Category"]); + m_isHidden = Jellyfin::Support::fromJsonValue(source["IsHidden"]); + m_key = Jellyfin::Support::fromJsonValue(source["Key"]); } QJsonObject TaskInfo::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["State"] = toJsonValue(m_state); - result["CurrentProgressPercentage"] = toJsonValue(m_currentProgressPercentage); - result["Id"] = toJsonValue(m_jellyfinId); - result["LastExecutionResult"] = toJsonValue>(m_lastExecutionResult); - result["Triggers"] = toJsonValue>>(m_triggers); - result["Description"] = toJsonValue(m_description); - result["Category"] = toJsonValue(m_category); - result["IsHidden"] = toJsonValue(m_isHidden); - result["Key"] = toJsonValue(m_key); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["State"] = Jellyfin::Support::toJsonValue(m_state); + result["CurrentProgressPercentage"] = Jellyfin::Support::toJsonValue(m_currentProgressPercentage); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["LastExecutionResult"] = Jellyfin::Support::toJsonValue>(m_lastExecutionResult); + result["Triggers"] = Jellyfin::Support::toJsonValue>>(m_triggers); + result["Description"] = Jellyfin::Support::toJsonValue(m_description); + result["Category"] = Jellyfin::Support::toJsonValue(m_category); + result["IsHidden"] = Jellyfin::Support::toJsonValue(m_isHidden); + result["Key"] = Jellyfin::Support::toJsonValue(m_key); return result; } @@ -121,6 +122,17 @@ void TaskInfo::setKey(QString newKey) { m_key = newKey; } +} // NS DTO + +namespace Support { + +using TaskInfo = Jellyfin::DTO::TaskInfo; + +template <> +TaskInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return TaskInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/taskresult.cpp b/core/src/DTO/taskresult.cpp index d9ffc0d..c10793c 100644 --- a/core/src/DTO/taskresult.cpp +++ b/core/src/DTO/taskresult.cpp @@ -32,36 +32,37 @@ namespace Jellyfin { namespace DTO { -TaskResult::TaskResult(QObject *parent) {} +TaskResult::TaskResult() {} -TaskResult TaskResult::fromJson(QJsonObject source) {TaskResult instance; - instance->setFromJson(source, false); +TaskResult TaskResult::fromJson(QJsonObject source) { + TaskResult instance; + instance.setFromJson(source); return instance; } void TaskResult::setFromJson(QJsonObject source) { - m_startTimeUtc = fromJsonValue(source["StartTimeUtc"]); - m_endTimeUtc = fromJsonValue(source["EndTimeUtc"]); - m_status = fromJsonValue(source["Status"]); - m_name = fromJsonValue(source["Name"]); - m_key = fromJsonValue(source["Key"]); - m_jellyfinId = fromJsonValue(source["Id"]); - m_errorMessage = fromJsonValue(source["ErrorMessage"]); - m_longErrorMessage = fromJsonValue(source["LongErrorMessage"]); + m_startTimeUtc = Jellyfin::Support::fromJsonValue(source["StartTimeUtc"]); + m_endTimeUtc = Jellyfin::Support::fromJsonValue(source["EndTimeUtc"]); + m_status = Jellyfin::Support::fromJsonValue(source["Status"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_key = Jellyfin::Support::fromJsonValue(source["Key"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); + m_errorMessage = Jellyfin::Support::fromJsonValue(source["ErrorMessage"]); + m_longErrorMessage = Jellyfin::Support::fromJsonValue(source["LongErrorMessage"]); } QJsonObject TaskResult::toJson() { QJsonObject result; - result["StartTimeUtc"] = toJsonValue(m_startTimeUtc); - result["EndTimeUtc"] = toJsonValue(m_endTimeUtc); - result["Status"] = toJsonValue(m_status); - result["Name"] = toJsonValue(m_name); - result["Key"] = toJsonValue(m_key); - result["Id"] = toJsonValue(m_jellyfinId); - result["ErrorMessage"] = toJsonValue(m_errorMessage); - result["LongErrorMessage"] = toJsonValue(m_longErrorMessage); + result["StartTimeUtc"] = Jellyfin::Support::toJsonValue(m_startTimeUtc); + result["EndTimeUtc"] = Jellyfin::Support::toJsonValue(m_endTimeUtc); + result["Status"] = Jellyfin::Support::toJsonValue(m_status); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Key"] = Jellyfin::Support::toJsonValue(m_key); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["ErrorMessage"] = Jellyfin::Support::toJsonValue(m_errorMessage); + result["LongErrorMessage"] = Jellyfin::Support::toJsonValue(m_longErrorMessage); return result; } @@ -107,6 +108,17 @@ void TaskResult::setLongErrorMessage(QString newLongErrorMessage) { m_longErrorMessage = newLongErrorMessage; } +} // NS DTO + +namespace Support { + +using TaskResult = Jellyfin::DTO::TaskResult; + +template <> +TaskResult fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return TaskResult::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/taskstate.cpp b/core/src/DTO/taskstate.cpp index f85fb18..5648a38 100644 --- a/core/src/DTO/taskstate.cpp +++ b/core/src/DTO/taskstate.cpp @@ -34,5 +34,30 @@ namespace DTO { TaskStateClass::TaskStateClass() {} + +} // NS DTO + +namespace Support { + +using TaskState = Jellyfin::DTO::TaskState; + +template <> +TaskState fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return TaskState::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Idle")) { + return TaskState::Idle; + } + if (str == QStringLiteral("Cancelling")) { + return TaskState::Cancelling; + } + if (str == QStringLiteral("Running")) { + return TaskState::Running; + } + + return TaskState::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/tasktriggerinfo.cpp b/core/src/DTO/tasktriggerinfo.cpp index bb122dc..f97e0ae 100644 --- a/core/src/DTO/tasktriggerinfo.cpp +++ b/core/src/DTO/tasktriggerinfo.cpp @@ -32,30 +32,31 @@ namespace Jellyfin { namespace DTO { -TaskTriggerInfo::TaskTriggerInfo(QObject *parent) {} +TaskTriggerInfo::TaskTriggerInfo() {} -TaskTriggerInfo TaskTriggerInfo::fromJson(QJsonObject source) {TaskTriggerInfo instance; - instance->setFromJson(source, false); +TaskTriggerInfo TaskTriggerInfo::fromJson(QJsonObject source) { + TaskTriggerInfo instance; + instance.setFromJson(source); return instance; } void TaskTriggerInfo::setFromJson(QJsonObject source) { - m_type = fromJsonValue(source["Type"]); - m_timeOfDayTicks = fromJsonValue(source["TimeOfDayTicks"]); - m_intervalTicks = fromJsonValue(source["IntervalTicks"]); - m_dayOfWeek = fromJsonValue(source["DayOfWeek"]); - m_maxRuntimeTicks = fromJsonValue(source["MaxRuntimeTicks"]); + m_type = Jellyfin::Support::fromJsonValue(source["Type"]); + m_timeOfDayTicks = Jellyfin::Support::fromJsonValue(source["TimeOfDayTicks"]); + m_intervalTicks = Jellyfin::Support::fromJsonValue(source["IntervalTicks"]); + m_dayOfWeek = Jellyfin::Support::fromJsonValue(source["DayOfWeek"]); + m_maxRuntimeTicks = Jellyfin::Support::fromJsonValue(source["MaxRuntimeTicks"]); } QJsonObject TaskTriggerInfo::toJson() { QJsonObject result; - result["Type"] = toJsonValue(m_type); - result["TimeOfDayTicks"] = toJsonValue(m_timeOfDayTicks); - result["IntervalTicks"] = toJsonValue(m_intervalTicks); - result["DayOfWeek"] = toJsonValue(m_dayOfWeek); - result["MaxRuntimeTicks"] = toJsonValue(m_maxRuntimeTicks); + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + result["TimeOfDayTicks"] = Jellyfin::Support::toJsonValue(m_timeOfDayTicks); + result["IntervalTicks"] = Jellyfin::Support::toJsonValue(m_intervalTicks); + result["DayOfWeek"] = Jellyfin::Support::toJsonValue(m_dayOfWeek); + result["MaxRuntimeTicks"] = Jellyfin::Support::toJsonValue(m_maxRuntimeTicks); return result; } @@ -86,6 +87,17 @@ void TaskTriggerInfo::setMaxRuntimeTicks(qint64 newMaxRuntimeTicks) { m_maxRuntimeTicks = newMaxRuntimeTicks; } +} // NS DTO + +namespace Support { + +using TaskTriggerInfo = Jellyfin::DTO::TaskTriggerInfo; + +template <> +TaskTriggerInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return TaskTriggerInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/thememediaresult.cpp b/core/src/DTO/thememediaresult.cpp index 222c07c..47ceeb3 100644 --- a/core/src/DTO/thememediaresult.cpp +++ b/core/src/DTO/thememediaresult.cpp @@ -32,28 +32,29 @@ namespace Jellyfin { namespace DTO { -ThemeMediaResult::ThemeMediaResult(QObject *parent) {} +ThemeMediaResult::ThemeMediaResult() {} -ThemeMediaResult ThemeMediaResult::fromJson(QJsonObject source) {ThemeMediaResult instance; - instance->setFromJson(source, false); +ThemeMediaResult ThemeMediaResult::fromJson(QJsonObject source) { + ThemeMediaResult instance; + instance.setFromJson(source); return instance; } void ThemeMediaResult::setFromJson(QJsonObject source) { - m_items = fromJsonValue>>(source["Items"]); - m_totalRecordCount = fromJsonValue(source["TotalRecordCount"]); - m_startIndex = fromJsonValue(source["StartIndex"]); - m_ownerId = fromJsonValue(source["OwnerId"]); + m_items = Jellyfin::Support::fromJsonValue>>(source["Items"]); + m_totalRecordCount = Jellyfin::Support::fromJsonValue(source["TotalRecordCount"]); + m_startIndex = Jellyfin::Support::fromJsonValue(source["StartIndex"]); + m_ownerId = Jellyfin::Support::fromJsonValue(source["OwnerId"]); } QJsonObject ThemeMediaResult::toJson() { QJsonObject result; - result["Items"] = toJsonValue>>(m_items); - result["TotalRecordCount"] = toJsonValue(m_totalRecordCount); - result["StartIndex"] = toJsonValue(m_startIndex); - result["OwnerId"] = toJsonValue(m_ownerId); + result["Items"] = Jellyfin::Support::toJsonValue>>(m_items); + result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); + result["StartIndex"] = Jellyfin::Support::toJsonValue(m_startIndex); + result["OwnerId"] = Jellyfin::Support::toJsonValue(m_ownerId); return result; } @@ -79,6 +80,17 @@ void ThemeMediaResult::setOwnerId(QUuid newOwnerId) { m_ownerId = newOwnerId; } +} // NS DTO + +namespace Support { + +using ThemeMediaResult = Jellyfin::DTO::ThemeMediaResult; + +template <> +ThemeMediaResult fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ThemeMediaResult::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/timereventinfo.cpp b/core/src/DTO/timereventinfo.cpp index 3477444..74f5dea 100644 --- a/core/src/DTO/timereventinfo.cpp +++ b/core/src/DTO/timereventinfo.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -TimerEventInfo::TimerEventInfo(QObject *parent) {} +TimerEventInfo::TimerEventInfo() {} -TimerEventInfo TimerEventInfo::fromJson(QJsonObject source) {TimerEventInfo instance; - instance->setFromJson(source, false); +TimerEventInfo TimerEventInfo::fromJson(QJsonObject source) { + TimerEventInfo instance; + instance.setFromJson(source); return instance; } void TimerEventInfo::setFromJson(QJsonObject source) { - m_jellyfinId = fromJsonValue(source["Id"]); - m_programId = fromJsonValue(source["ProgramId"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); + m_programId = Jellyfin::Support::fromJsonValue(source["ProgramId"]); } QJsonObject TimerEventInfo::toJson() { QJsonObject result; - result["Id"] = toJsonValue(m_jellyfinId); - result["ProgramId"] = toJsonValue(m_programId); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["ProgramId"] = Jellyfin::Support::toJsonValue(m_programId); return result; } @@ -65,6 +66,17 @@ void TimerEventInfo::setProgramId(QUuid newProgramId) { m_programId = newProgramId; } +} // NS DTO + +namespace Support { + +using TimerEventInfo = Jellyfin::DTO::TimerEventInfo; + +template <> +TimerEventInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return TimerEventInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/timerinfodto.cpp b/core/src/DTO/timerinfodto.cpp index 824098b..e7dfb0c 100644 --- a/core/src/DTO/timerinfodto.cpp +++ b/core/src/DTO/timerinfodto.cpp @@ -32,76 +32,77 @@ namespace Jellyfin { namespace DTO { -TimerInfoDto::TimerInfoDto(QObject *parent) {} +TimerInfoDto::TimerInfoDto() {} -TimerInfoDto TimerInfoDto::fromJson(QJsonObject source) {TimerInfoDto instance; - instance->setFromJson(source, false); +TimerInfoDto TimerInfoDto::fromJson(QJsonObject source) { + TimerInfoDto instance; + instance.setFromJson(source); return instance; } void TimerInfoDto::setFromJson(QJsonObject source) { - m_jellyfinId = fromJsonValue(source["Id"]); - m_type = fromJsonValue(source["Type"]); - m_serverId = fromJsonValue(source["ServerId"]); - m_externalId = fromJsonValue(source["ExternalId"]); - m_channelId = fromJsonValue(source["ChannelId"]); - m_externalChannelId = fromJsonValue(source["ExternalChannelId"]); - m_channelName = fromJsonValue(source["ChannelName"]); - m_channelPrimaryImageTag = fromJsonValue(source["ChannelPrimaryImageTag"]); - m_programId = fromJsonValue(source["ProgramId"]); - m_externalProgramId = fromJsonValue(source["ExternalProgramId"]); - m_name = fromJsonValue(source["Name"]); - m_overview = fromJsonValue(source["Overview"]); - m_startDate = fromJsonValue(source["StartDate"]); - m_endDate = fromJsonValue(source["EndDate"]); - m_serviceName = fromJsonValue(source["ServiceName"]); - m_priority = fromJsonValue(source["Priority"]); - m_prePaddingSeconds = fromJsonValue(source["PrePaddingSeconds"]); - m_postPaddingSeconds = fromJsonValue(source["PostPaddingSeconds"]); - m_isPrePaddingRequired = fromJsonValue(source["IsPrePaddingRequired"]); - m_parentBackdropItemId = fromJsonValue(source["ParentBackdropItemId"]); - m_parentBackdropImageTags = fromJsonValue(source["ParentBackdropImageTags"]); - m_isPostPaddingRequired = fromJsonValue(source["IsPostPaddingRequired"]); - m_keepUntil = fromJsonValue(source["KeepUntil"]); - m_status = fromJsonValue(source["Status"]); - m_seriesTimerId = fromJsonValue(source["SeriesTimerId"]); - m_externalSeriesTimerId = fromJsonValue(source["ExternalSeriesTimerId"]); - m_runTimeTicks = fromJsonValue(source["RunTimeTicks"]); - m_programInfo = fromJsonValue>(source["ProgramInfo"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); + m_type = Jellyfin::Support::fromJsonValue(source["Type"]); + m_serverId = Jellyfin::Support::fromJsonValue(source["ServerId"]); + m_externalId = Jellyfin::Support::fromJsonValue(source["ExternalId"]); + m_channelId = Jellyfin::Support::fromJsonValue(source["ChannelId"]); + m_externalChannelId = Jellyfin::Support::fromJsonValue(source["ExternalChannelId"]); + m_channelName = Jellyfin::Support::fromJsonValue(source["ChannelName"]); + m_channelPrimaryImageTag = Jellyfin::Support::fromJsonValue(source["ChannelPrimaryImageTag"]); + m_programId = Jellyfin::Support::fromJsonValue(source["ProgramId"]); + m_externalProgramId = Jellyfin::Support::fromJsonValue(source["ExternalProgramId"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_overview = Jellyfin::Support::fromJsonValue(source["Overview"]); + m_startDate = Jellyfin::Support::fromJsonValue(source["StartDate"]); + m_endDate = Jellyfin::Support::fromJsonValue(source["EndDate"]); + m_serviceName = Jellyfin::Support::fromJsonValue(source["ServiceName"]); + m_priority = Jellyfin::Support::fromJsonValue(source["Priority"]); + m_prePaddingSeconds = Jellyfin::Support::fromJsonValue(source["PrePaddingSeconds"]); + m_postPaddingSeconds = Jellyfin::Support::fromJsonValue(source["PostPaddingSeconds"]); + m_isPrePaddingRequired = Jellyfin::Support::fromJsonValue(source["IsPrePaddingRequired"]); + m_parentBackdropItemId = Jellyfin::Support::fromJsonValue(source["ParentBackdropItemId"]); + m_parentBackdropImageTags = Jellyfin::Support::fromJsonValue(source["ParentBackdropImageTags"]); + m_isPostPaddingRequired = Jellyfin::Support::fromJsonValue(source["IsPostPaddingRequired"]); + m_keepUntil = Jellyfin::Support::fromJsonValue(source["KeepUntil"]); + m_status = Jellyfin::Support::fromJsonValue(source["Status"]); + m_seriesTimerId = Jellyfin::Support::fromJsonValue(source["SeriesTimerId"]); + m_externalSeriesTimerId = Jellyfin::Support::fromJsonValue(source["ExternalSeriesTimerId"]); + m_runTimeTicks = Jellyfin::Support::fromJsonValue(source["RunTimeTicks"]); + m_programInfo = Jellyfin::Support::fromJsonValue>(source["ProgramInfo"]); } QJsonObject TimerInfoDto::toJson() { QJsonObject result; - result["Id"] = toJsonValue(m_jellyfinId); - result["Type"] = toJsonValue(m_type); - result["ServerId"] = toJsonValue(m_serverId); - result["ExternalId"] = toJsonValue(m_externalId); - result["ChannelId"] = toJsonValue(m_channelId); - result["ExternalChannelId"] = toJsonValue(m_externalChannelId); - result["ChannelName"] = toJsonValue(m_channelName); - result["ChannelPrimaryImageTag"] = toJsonValue(m_channelPrimaryImageTag); - result["ProgramId"] = toJsonValue(m_programId); - result["ExternalProgramId"] = toJsonValue(m_externalProgramId); - result["Name"] = toJsonValue(m_name); - result["Overview"] = toJsonValue(m_overview); - result["StartDate"] = toJsonValue(m_startDate); - result["EndDate"] = toJsonValue(m_endDate); - result["ServiceName"] = toJsonValue(m_serviceName); - result["Priority"] = toJsonValue(m_priority); - result["PrePaddingSeconds"] = toJsonValue(m_prePaddingSeconds); - result["PostPaddingSeconds"] = toJsonValue(m_postPaddingSeconds); - result["IsPrePaddingRequired"] = toJsonValue(m_isPrePaddingRequired); - result["ParentBackdropItemId"] = toJsonValue(m_parentBackdropItemId); - result["ParentBackdropImageTags"] = toJsonValue(m_parentBackdropImageTags); - result["IsPostPaddingRequired"] = toJsonValue(m_isPostPaddingRequired); - result["KeepUntil"] = toJsonValue(m_keepUntil); - result["Status"] = toJsonValue(m_status); - result["SeriesTimerId"] = toJsonValue(m_seriesTimerId); - result["ExternalSeriesTimerId"] = toJsonValue(m_externalSeriesTimerId); - result["RunTimeTicks"] = toJsonValue(m_runTimeTicks); - result["ProgramInfo"] = toJsonValue>(m_programInfo); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + result["ServerId"] = Jellyfin::Support::toJsonValue(m_serverId); + result["ExternalId"] = Jellyfin::Support::toJsonValue(m_externalId); + result["ChannelId"] = Jellyfin::Support::toJsonValue(m_channelId); + result["ExternalChannelId"] = Jellyfin::Support::toJsonValue(m_externalChannelId); + result["ChannelName"] = Jellyfin::Support::toJsonValue(m_channelName); + result["ChannelPrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_channelPrimaryImageTag); + result["ProgramId"] = Jellyfin::Support::toJsonValue(m_programId); + result["ExternalProgramId"] = Jellyfin::Support::toJsonValue(m_externalProgramId); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Overview"] = Jellyfin::Support::toJsonValue(m_overview); + result["StartDate"] = Jellyfin::Support::toJsonValue(m_startDate); + result["EndDate"] = Jellyfin::Support::toJsonValue(m_endDate); + result["ServiceName"] = Jellyfin::Support::toJsonValue(m_serviceName); + result["Priority"] = Jellyfin::Support::toJsonValue(m_priority); + result["PrePaddingSeconds"] = Jellyfin::Support::toJsonValue(m_prePaddingSeconds); + result["PostPaddingSeconds"] = Jellyfin::Support::toJsonValue(m_postPaddingSeconds); + result["IsPrePaddingRequired"] = Jellyfin::Support::toJsonValue(m_isPrePaddingRequired); + result["ParentBackdropItemId"] = Jellyfin::Support::toJsonValue(m_parentBackdropItemId); + result["ParentBackdropImageTags"] = Jellyfin::Support::toJsonValue(m_parentBackdropImageTags); + result["IsPostPaddingRequired"] = Jellyfin::Support::toJsonValue(m_isPostPaddingRequired); + result["KeepUntil"] = Jellyfin::Support::toJsonValue(m_keepUntil); + result["Status"] = Jellyfin::Support::toJsonValue(m_status); + result["SeriesTimerId"] = Jellyfin::Support::toJsonValue(m_seriesTimerId); + result["ExternalSeriesTimerId"] = Jellyfin::Support::toJsonValue(m_externalSeriesTimerId); + result["RunTimeTicks"] = Jellyfin::Support::toJsonValue(m_runTimeTicks); + result["ProgramInfo"] = Jellyfin::Support::toJsonValue>(m_programInfo); return result; } @@ -247,6 +248,17 @@ void TimerInfoDto::setProgramInfo(QSharedPointer newProgramInfo) { m_programInfo = newProgramInfo; } +} // NS DTO + +namespace Support { + +using TimerInfoDto = Jellyfin::DTO::TimerInfoDto; + +template <> +TimerInfoDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return TimerInfoDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/timerinfodtoqueryresult.cpp b/core/src/DTO/timerinfodtoqueryresult.cpp index ab7c1a2..b9b1ad1 100644 --- a/core/src/DTO/timerinfodtoqueryresult.cpp +++ b/core/src/DTO/timerinfodtoqueryresult.cpp @@ -32,26 +32,27 @@ namespace Jellyfin { namespace DTO { -TimerInfoDtoQueryResult::TimerInfoDtoQueryResult(QObject *parent) {} +TimerInfoDtoQueryResult::TimerInfoDtoQueryResult() {} -TimerInfoDtoQueryResult TimerInfoDtoQueryResult::fromJson(QJsonObject source) {TimerInfoDtoQueryResult instance; - instance->setFromJson(source, false); +TimerInfoDtoQueryResult TimerInfoDtoQueryResult::fromJson(QJsonObject source) { + TimerInfoDtoQueryResult instance; + instance.setFromJson(source); return instance; } void TimerInfoDtoQueryResult::setFromJson(QJsonObject source) { - m_items = fromJsonValue>>(source["Items"]); - m_totalRecordCount = fromJsonValue(source["TotalRecordCount"]); - m_startIndex = fromJsonValue(source["StartIndex"]); + m_items = Jellyfin::Support::fromJsonValue>>(source["Items"]); + m_totalRecordCount = Jellyfin::Support::fromJsonValue(source["TotalRecordCount"]); + m_startIndex = Jellyfin::Support::fromJsonValue(source["StartIndex"]); } QJsonObject TimerInfoDtoQueryResult::toJson() { QJsonObject result; - result["Items"] = toJsonValue>>(m_items); - result["TotalRecordCount"] = toJsonValue(m_totalRecordCount); - result["StartIndex"] = toJsonValue(m_startIndex); + result["Items"] = Jellyfin::Support::toJsonValue>>(m_items); + result["TotalRecordCount"] = Jellyfin::Support::toJsonValue(m_totalRecordCount); + result["StartIndex"] = Jellyfin::Support::toJsonValue(m_startIndex); return result; } @@ -72,6 +73,17 @@ void TimerInfoDtoQueryResult::setStartIndex(qint32 newStartIndex) { m_startIndex = newStartIndex; } +} // NS DTO + +namespace Support { + +using TimerInfoDtoQueryResult = Jellyfin::DTO::TimerInfoDtoQueryResult; + +template <> +TimerInfoDtoQueryResult fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return TimerInfoDtoQueryResult::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/trailerinfo.cpp b/core/src/DTO/trailerinfo.cpp index a4816f7..c059e0e 100644 --- a/core/src/DTO/trailerinfo.cpp +++ b/core/src/DTO/trailerinfo.cpp @@ -32,40 +32,41 @@ namespace Jellyfin { namespace DTO { -TrailerInfo::TrailerInfo(QObject *parent) {} +TrailerInfo::TrailerInfo() {} -TrailerInfo TrailerInfo::fromJson(QJsonObject source) {TrailerInfo instance; - instance->setFromJson(source, false); +TrailerInfo TrailerInfo::fromJson(QJsonObject source) { + TrailerInfo instance; + instance.setFromJson(source); return instance; } void TrailerInfo::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_path = fromJsonValue(source["Path"]); - m_metadataLanguage = fromJsonValue(source["MetadataLanguage"]); - m_metadataCountryCode = fromJsonValue(source["MetadataCountryCode"]); - m_providerIds = fromJsonValue(source["ProviderIds"]); - m_year = fromJsonValue(source["Year"]); - m_indexNumber = fromJsonValue(source["IndexNumber"]); - m_parentIndexNumber = fromJsonValue(source["ParentIndexNumber"]); - m_premiereDate = fromJsonValue(source["PremiereDate"]); - m_isAutomated = fromJsonValue(source["IsAutomated"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_path = Jellyfin::Support::fromJsonValue(source["Path"]); + m_metadataLanguage = Jellyfin::Support::fromJsonValue(source["MetadataLanguage"]); + m_metadataCountryCode = Jellyfin::Support::fromJsonValue(source["MetadataCountryCode"]); + m_providerIds = Jellyfin::Support::fromJsonValue(source["ProviderIds"]); + m_year = Jellyfin::Support::fromJsonValue(source["Year"]); + m_indexNumber = Jellyfin::Support::fromJsonValue(source["IndexNumber"]); + m_parentIndexNumber = Jellyfin::Support::fromJsonValue(source["ParentIndexNumber"]); + m_premiereDate = Jellyfin::Support::fromJsonValue(source["PremiereDate"]); + m_isAutomated = Jellyfin::Support::fromJsonValue(source["IsAutomated"]); } QJsonObject TrailerInfo::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Path"] = toJsonValue(m_path); - result["MetadataLanguage"] = toJsonValue(m_metadataLanguage); - result["MetadataCountryCode"] = toJsonValue(m_metadataCountryCode); - result["ProviderIds"] = toJsonValue(m_providerIds); - result["Year"] = toJsonValue(m_year); - result["IndexNumber"] = toJsonValue(m_indexNumber); - result["ParentIndexNumber"] = toJsonValue(m_parentIndexNumber); - result["PremiereDate"] = toJsonValue(m_premiereDate); - result["IsAutomated"] = toJsonValue(m_isAutomated); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + result["MetadataLanguage"] = Jellyfin::Support::toJsonValue(m_metadataLanguage); + result["MetadataCountryCode"] = Jellyfin::Support::toJsonValue(m_metadataCountryCode); + result["ProviderIds"] = Jellyfin::Support::toJsonValue(m_providerIds); + result["Year"] = Jellyfin::Support::toJsonValue(m_year); + result["IndexNumber"] = Jellyfin::Support::toJsonValue(m_indexNumber); + result["ParentIndexNumber"] = Jellyfin::Support::toJsonValue(m_parentIndexNumber); + result["PremiereDate"] = Jellyfin::Support::toJsonValue(m_premiereDate); + result["IsAutomated"] = Jellyfin::Support::toJsonValue(m_isAutomated); return result; } @@ -121,6 +122,17 @@ void TrailerInfo::setIsAutomated(bool newIsAutomated) { m_isAutomated = newIsAutomated; } +} // NS DTO + +namespace Support { + +using TrailerInfo = Jellyfin::DTO::TrailerInfo; + +template <> +TrailerInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return TrailerInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/trailerinforemotesearchquery.cpp b/core/src/DTO/trailerinforemotesearchquery.cpp index eaff722..c138cc7 100644 --- a/core/src/DTO/trailerinforemotesearchquery.cpp +++ b/core/src/DTO/trailerinforemotesearchquery.cpp @@ -32,28 +32,29 @@ namespace Jellyfin { namespace DTO { -TrailerInfoRemoteSearchQuery::TrailerInfoRemoteSearchQuery(QObject *parent) {} +TrailerInfoRemoteSearchQuery::TrailerInfoRemoteSearchQuery() {} -TrailerInfoRemoteSearchQuery TrailerInfoRemoteSearchQuery::fromJson(QJsonObject source) {TrailerInfoRemoteSearchQuery instance; - instance->setFromJson(source, false); +TrailerInfoRemoteSearchQuery TrailerInfoRemoteSearchQuery::fromJson(QJsonObject source) { + TrailerInfoRemoteSearchQuery instance; + instance.setFromJson(source); return instance; } void TrailerInfoRemoteSearchQuery::setFromJson(QJsonObject source) { - m_searchInfo = fromJsonValue>(source["SearchInfo"]); - m_itemId = fromJsonValue(source["ItemId"]); - m_searchProviderName = fromJsonValue(source["SearchProviderName"]); - m_includeDisabledProviders = fromJsonValue(source["IncludeDisabledProviders"]); + m_searchInfo = Jellyfin::Support::fromJsonValue>(source["SearchInfo"]); + m_itemId = Jellyfin::Support::fromJsonValue(source["ItemId"]); + m_searchProviderName = Jellyfin::Support::fromJsonValue(source["SearchProviderName"]); + m_includeDisabledProviders = Jellyfin::Support::fromJsonValue(source["IncludeDisabledProviders"]); } QJsonObject TrailerInfoRemoteSearchQuery::toJson() { QJsonObject result; - result["SearchInfo"] = toJsonValue>(m_searchInfo); - result["ItemId"] = toJsonValue(m_itemId); - result["SearchProviderName"] = toJsonValue(m_searchProviderName); - result["IncludeDisabledProviders"] = toJsonValue(m_includeDisabledProviders); + result["SearchInfo"] = Jellyfin::Support::toJsonValue>(m_searchInfo); + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + result["SearchProviderName"] = Jellyfin::Support::toJsonValue(m_searchProviderName); + result["IncludeDisabledProviders"] = Jellyfin::Support::toJsonValue(m_includeDisabledProviders); return result; } @@ -79,6 +80,17 @@ void TrailerInfoRemoteSearchQuery::setIncludeDisabledProviders(bool newIncludeDi m_includeDisabledProviders = newIncludeDisabledProviders; } +} // NS DTO + +namespace Support { + +using TrailerInfoRemoteSearchQuery = Jellyfin::DTO::TrailerInfoRemoteSearchQuery; + +template <> +TrailerInfoRemoteSearchQuery fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return TrailerInfoRemoteSearchQuery::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/transcodereason.cpp b/core/src/DTO/transcodereason.cpp index 0faccfc..d2c5803 100644 --- a/core/src/DTO/transcodereason.cpp +++ b/core/src/DTO/transcodereason.cpp @@ -34,5 +34,90 @@ namespace DTO { TranscodeReasonClass::TranscodeReasonClass() {} + +} // NS DTO + +namespace Support { + +using TranscodeReason = Jellyfin::DTO::TranscodeReason; + +template <> +TranscodeReason fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return TranscodeReason::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("ContainerNotSupported")) { + return TranscodeReason::ContainerNotSupported; + } + if (str == QStringLiteral("VideoCodecNotSupported")) { + return TranscodeReason::VideoCodecNotSupported; + } + if (str == QStringLiteral("AudioCodecNotSupported")) { + return TranscodeReason::AudioCodecNotSupported; + } + if (str == QStringLiteral("ContainerBitrateExceedsLimit")) { + return TranscodeReason::ContainerBitrateExceedsLimit; + } + if (str == QStringLiteral("AudioBitrateNotSupported")) { + return TranscodeReason::AudioBitrateNotSupported; + } + if (str == QStringLiteral("AudioChannelsNotSupported")) { + return TranscodeReason::AudioChannelsNotSupported; + } + if (str == QStringLiteral("VideoResolutionNotSupported")) { + return TranscodeReason::VideoResolutionNotSupported; + } + if (str == QStringLiteral("UnknownVideoStreamInfo")) { + return TranscodeReason::UnknownVideoStreamInfo; + } + if (str == QStringLiteral("UnknownAudioStreamInfo")) { + return TranscodeReason::UnknownAudioStreamInfo; + } + if (str == QStringLiteral("AudioProfileNotSupported")) { + return TranscodeReason::AudioProfileNotSupported; + } + if (str == QStringLiteral("AudioSampleRateNotSupported")) { + return TranscodeReason::AudioSampleRateNotSupported; + } + if (str == QStringLiteral("AnamorphicVideoNotSupported")) { + return TranscodeReason::AnamorphicVideoNotSupported; + } + if (str == QStringLiteral("InterlacedVideoNotSupported")) { + return TranscodeReason::InterlacedVideoNotSupported; + } + if (str == QStringLiteral("SecondaryAudioNotSupported")) { + return TranscodeReason::SecondaryAudioNotSupported; + } + if (str == QStringLiteral("RefFramesNotSupported")) { + return TranscodeReason::RefFramesNotSupported; + } + if (str == QStringLiteral("VideoBitDepthNotSupported")) { + return TranscodeReason::VideoBitDepthNotSupported; + } + if (str == QStringLiteral("VideoBitrateNotSupported")) { + return TranscodeReason::VideoBitrateNotSupported; + } + if (str == QStringLiteral("VideoFramerateNotSupported")) { + return TranscodeReason::VideoFramerateNotSupported; + } + if (str == QStringLiteral("VideoLevelNotSupported")) { + return TranscodeReason::VideoLevelNotSupported; + } + if (str == QStringLiteral("VideoProfileNotSupported")) { + return TranscodeReason::VideoProfileNotSupported; + } + if (str == QStringLiteral("AudioBitDepthNotSupported")) { + return TranscodeReason::AudioBitDepthNotSupported; + } + if (str == QStringLiteral("SubtitleCodecNotSupported")) { + return TranscodeReason::SubtitleCodecNotSupported; + } + if (str == QStringLiteral("DirectPlayError")) { + return TranscodeReason::DirectPlayError; + } + + return TranscodeReason::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/transcodeseekinfo.cpp b/core/src/DTO/transcodeseekinfo.cpp index 38e07a2..daaf607 100644 --- a/core/src/DTO/transcodeseekinfo.cpp +++ b/core/src/DTO/transcodeseekinfo.cpp @@ -34,5 +34,27 @@ namespace DTO { TranscodeSeekInfoClass::TranscodeSeekInfoClass() {} + +} // NS DTO + +namespace Support { + +using TranscodeSeekInfo = Jellyfin::DTO::TranscodeSeekInfo; + +template <> +TranscodeSeekInfo fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return TranscodeSeekInfo::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Auto")) { + return TranscodeSeekInfo::Auto; + } + if (str == QStringLiteral("Bytes")) { + return TranscodeSeekInfo::Bytes; + } + + return TranscodeSeekInfo::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/transcodinginfo.cpp b/core/src/DTO/transcodinginfo.cpp index 191eb72..ddcda2b 100644 --- a/core/src/DTO/transcodinginfo.cpp +++ b/core/src/DTO/transcodinginfo.cpp @@ -32,44 +32,45 @@ namespace Jellyfin { namespace DTO { -TranscodingInfo::TranscodingInfo(QObject *parent) {} +TranscodingInfo::TranscodingInfo() {} -TranscodingInfo TranscodingInfo::fromJson(QJsonObject source) {TranscodingInfo instance; - instance->setFromJson(source, false); +TranscodingInfo TranscodingInfo::fromJson(QJsonObject source) { + TranscodingInfo instance; + instance.setFromJson(source); return instance; } void TranscodingInfo::setFromJson(QJsonObject source) { - m_audioCodec = fromJsonValue(source["AudioCodec"]); - m_videoCodec = fromJsonValue(source["VideoCodec"]); - m_container = fromJsonValue(source["Container"]); - m_isVideoDirect = fromJsonValue(source["IsVideoDirect"]); - m_isAudioDirect = fromJsonValue(source["IsAudioDirect"]); - m_bitrate = fromJsonValue(source["Bitrate"]); - m_framerate = fromJsonValue(source["Framerate"]); - m_completionPercentage = fromJsonValue(source["CompletionPercentage"]); - m_width = fromJsonValue(source["Width"]); - m_height = fromJsonValue(source["Height"]); - m_audioChannels = fromJsonValue(source["AudioChannels"]); - m_transcodeReasons = fromJsonValue>(source["TranscodeReasons"]); + m_audioCodec = Jellyfin::Support::fromJsonValue(source["AudioCodec"]); + m_videoCodec = Jellyfin::Support::fromJsonValue(source["VideoCodec"]); + m_container = Jellyfin::Support::fromJsonValue(source["Container"]); + m_isVideoDirect = Jellyfin::Support::fromJsonValue(source["IsVideoDirect"]); + m_isAudioDirect = Jellyfin::Support::fromJsonValue(source["IsAudioDirect"]); + m_bitrate = Jellyfin::Support::fromJsonValue(source["Bitrate"]); + m_framerate = Jellyfin::Support::fromJsonValue(source["Framerate"]); + m_completionPercentage = Jellyfin::Support::fromJsonValue(source["CompletionPercentage"]); + m_width = Jellyfin::Support::fromJsonValue(source["Width"]); + m_height = Jellyfin::Support::fromJsonValue(source["Height"]); + m_audioChannels = Jellyfin::Support::fromJsonValue(source["AudioChannels"]); + m_transcodeReasons = Jellyfin::Support::fromJsonValue>(source["TranscodeReasons"]); } QJsonObject TranscodingInfo::toJson() { QJsonObject result; - result["AudioCodec"] = toJsonValue(m_audioCodec); - result["VideoCodec"] = toJsonValue(m_videoCodec); - result["Container"] = toJsonValue(m_container); - result["IsVideoDirect"] = toJsonValue(m_isVideoDirect); - result["IsAudioDirect"] = toJsonValue(m_isAudioDirect); - result["Bitrate"] = toJsonValue(m_bitrate); - result["Framerate"] = toJsonValue(m_framerate); - result["CompletionPercentage"] = toJsonValue(m_completionPercentage); - result["Width"] = toJsonValue(m_width); - result["Height"] = toJsonValue(m_height); - result["AudioChannels"] = toJsonValue(m_audioChannels); - result["TranscodeReasons"] = toJsonValue>(m_transcodeReasons); + result["AudioCodec"] = Jellyfin::Support::toJsonValue(m_audioCodec); + result["VideoCodec"] = Jellyfin::Support::toJsonValue(m_videoCodec); + result["Container"] = Jellyfin::Support::toJsonValue(m_container); + result["IsVideoDirect"] = Jellyfin::Support::toJsonValue(m_isVideoDirect); + result["IsAudioDirect"] = Jellyfin::Support::toJsonValue(m_isAudioDirect); + result["Bitrate"] = Jellyfin::Support::toJsonValue(m_bitrate); + result["Framerate"] = Jellyfin::Support::toJsonValue(m_framerate); + result["CompletionPercentage"] = Jellyfin::Support::toJsonValue(m_completionPercentage); + result["Width"] = Jellyfin::Support::toJsonValue(m_width); + result["Height"] = Jellyfin::Support::toJsonValue(m_height); + result["AudioChannels"] = Jellyfin::Support::toJsonValue(m_audioChannels); + result["TranscodeReasons"] = Jellyfin::Support::toJsonValue>(m_transcodeReasons); return result; } @@ -135,6 +136,17 @@ void TranscodingInfo::setTranscodeReasons(QList newTranscodeRea m_transcodeReasons = newTranscodeReasons; } +} // NS DTO + +namespace Support { + +using TranscodingInfo = Jellyfin::DTO::TranscodingInfo; + +template <> +TranscodingInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return TranscodingInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/transcodingprofile.cpp b/core/src/DTO/transcodingprofile.cpp index 642262d..49400df 100644 --- a/core/src/DTO/transcodingprofile.cpp +++ b/core/src/DTO/transcodingprofile.cpp @@ -32,50 +32,51 @@ namespace Jellyfin { namespace DTO { -TranscodingProfile::TranscodingProfile(QObject *parent) {} +TranscodingProfile::TranscodingProfile() {} -TranscodingProfile TranscodingProfile::fromJson(QJsonObject source) {TranscodingProfile instance; - instance->setFromJson(source, false); +TranscodingProfile TranscodingProfile::fromJson(QJsonObject source) { + TranscodingProfile instance; + instance.setFromJson(source); return instance; } void TranscodingProfile::setFromJson(QJsonObject source) { - m_container = fromJsonValue(source["Container"]); - m_type = fromJsonValue(source["Type"]); - m_videoCodec = fromJsonValue(source["VideoCodec"]); - m_audioCodec = fromJsonValue(source["AudioCodec"]); - m_protocol = fromJsonValue(source["Protocol"]); - m_estimateContentLength = fromJsonValue(source["EstimateContentLength"]); - m_enableMpegtsM2TsMode = fromJsonValue(source["EnableMpegtsM2TsMode"]); - m_transcodeSeekInfo = fromJsonValue(source["TranscodeSeekInfo"]); - m_copyTimestamps = fromJsonValue(source["CopyTimestamps"]); - m_context = fromJsonValue(source["Context"]); - m_enableSubtitlesInManifest = fromJsonValue(source["EnableSubtitlesInManifest"]); - m_maxAudioChannels = fromJsonValue(source["MaxAudioChannels"]); - m_minSegments = fromJsonValue(source["MinSegments"]); - m_segmentLength = fromJsonValue(source["SegmentLength"]); - m_breakOnNonKeyFrames = fromJsonValue(source["BreakOnNonKeyFrames"]); + m_container = Jellyfin::Support::fromJsonValue(source["Container"]); + m_type = Jellyfin::Support::fromJsonValue(source["Type"]); + m_videoCodec = Jellyfin::Support::fromJsonValue(source["VideoCodec"]); + m_audioCodec = Jellyfin::Support::fromJsonValue(source["AudioCodec"]); + m_protocol = Jellyfin::Support::fromJsonValue(source["Protocol"]); + m_estimateContentLength = Jellyfin::Support::fromJsonValue(source["EstimateContentLength"]); + m_enableMpegtsM2TsMode = Jellyfin::Support::fromJsonValue(source["EnableMpegtsM2TsMode"]); + m_transcodeSeekInfo = Jellyfin::Support::fromJsonValue(source["TranscodeSeekInfo"]); + m_copyTimestamps = Jellyfin::Support::fromJsonValue(source["CopyTimestamps"]); + m_context = Jellyfin::Support::fromJsonValue(source["Context"]); + m_enableSubtitlesInManifest = Jellyfin::Support::fromJsonValue(source["EnableSubtitlesInManifest"]); + m_maxAudioChannels = Jellyfin::Support::fromJsonValue(source["MaxAudioChannels"]); + m_minSegments = Jellyfin::Support::fromJsonValue(source["MinSegments"]); + m_segmentLength = Jellyfin::Support::fromJsonValue(source["SegmentLength"]); + m_breakOnNonKeyFrames = Jellyfin::Support::fromJsonValue(source["BreakOnNonKeyFrames"]); } QJsonObject TranscodingProfile::toJson() { QJsonObject result; - result["Container"] = toJsonValue(m_container); - result["Type"] = toJsonValue(m_type); - result["VideoCodec"] = toJsonValue(m_videoCodec); - result["AudioCodec"] = toJsonValue(m_audioCodec); - result["Protocol"] = toJsonValue(m_protocol); - result["EstimateContentLength"] = toJsonValue(m_estimateContentLength); - result["EnableMpegtsM2TsMode"] = toJsonValue(m_enableMpegtsM2TsMode); - result["TranscodeSeekInfo"] = toJsonValue(m_transcodeSeekInfo); - result["CopyTimestamps"] = toJsonValue(m_copyTimestamps); - result["Context"] = toJsonValue(m_context); - result["EnableSubtitlesInManifest"] = toJsonValue(m_enableSubtitlesInManifest); - result["MaxAudioChannels"] = toJsonValue(m_maxAudioChannels); - result["MinSegments"] = toJsonValue(m_minSegments); - result["SegmentLength"] = toJsonValue(m_segmentLength); - result["BreakOnNonKeyFrames"] = toJsonValue(m_breakOnNonKeyFrames); + result["Container"] = Jellyfin::Support::toJsonValue(m_container); + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + result["VideoCodec"] = Jellyfin::Support::toJsonValue(m_videoCodec); + result["AudioCodec"] = Jellyfin::Support::toJsonValue(m_audioCodec); + result["Protocol"] = Jellyfin::Support::toJsonValue(m_protocol); + result["EstimateContentLength"] = Jellyfin::Support::toJsonValue(m_estimateContentLength); + result["EnableMpegtsM2TsMode"] = Jellyfin::Support::toJsonValue(m_enableMpegtsM2TsMode); + result["TranscodeSeekInfo"] = Jellyfin::Support::toJsonValue(m_transcodeSeekInfo); + result["CopyTimestamps"] = Jellyfin::Support::toJsonValue(m_copyTimestamps); + result["Context"] = Jellyfin::Support::toJsonValue(m_context); + result["EnableSubtitlesInManifest"] = Jellyfin::Support::toJsonValue(m_enableSubtitlesInManifest); + result["MaxAudioChannels"] = Jellyfin::Support::toJsonValue(m_maxAudioChannels); + result["MinSegments"] = Jellyfin::Support::toJsonValue(m_minSegments); + result["SegmentLength"] = Jellyfin::Support::toJsonValue(m_segmentLength); + result["BreakOnNonKeyFrames"] = Jellyfin::Support::toJsonValue(m_breakOnNonKeyFrames); return result; } @@ -156,6 +157,17 @@ void TranscodingProfile::setBreakOnNonKeyFrames(bool newBreakOnNonKeyFrames) { m_breakOnNonKeyFrames = newBreakOnNonKeyFrames; } +} // NS DTO + +namespace Support { + +using TranscodingProfile = Jellyfin::DTO::TranscodingProfile; + +template <> +TranscodingProfile fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return TranscodingProfile::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/transportstreamtimestamp.cpp b/core/src/DTO/transportstreamtimestamp.cpp index 4771191..33a2529 100644 --- a/core/src/DTO/transportstreamtimestamp.cpp +++ b/core/src/DTO/transportstreamtimestamp.cpp @@ -34,5 +34,30 @@ namespace DTO { TransportStreamTimestampClass::TransportStreamTimestampClass() {} + +} // NS DTO + +namespace Support { + +using TransportStreamTimestamp = Jellyfin::DTO::TransportStreamTimestamp; + +template <> +TransportStreamTimestamp fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return TransportStreamTimestamp::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("None")) { + return TransportStreamTimestamp::None; + } + if (str == QStringLiteral("Zero")) { + return TransportStreamTimestamp::Zero; + } + if (str == QStringLiteral("Valid")) { + return TransportStreamTimestamp::Valid; + } + + return TransportStreamTimestamp::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/tunerchannelmapping.cpp b/core/src/DTO/tunerchannelmapping.cpp index 24c5aeb..df00b8a 100644 --- a/core/src/DTO/tunerchannelmapping.cpp +++ b/core/src/DTO/tunerchannelmapping.cpp @@ -32,28 +32,29 @@ namespace Jellyfin { namespace DTO { -TunerChannelMapping::TunerChannelMapping(QObject *parent) {} +TunerChannelMapping::TunerChannelMapping() {} -TunerChannelMapping TunerChannelMapping::fromJson(QJsonObject source) {TunerChannelMapping instance; - instance->setFromJson(source, false); +TunerChannelMapping TunerChannelMapping::fromJson(QJsonObject source) { + TunerChannelMapping instance; + instance.setFromJson(source); return instance; } void TunerChannelMapping::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_providerChannelName = fromJsonValue(source["ProviderChannelName"]); - m_providerChannelId = fromJsonValue(source["ProviderChannelId"]); - m_jellyfinId = fromJsonValue(source["Id"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_providerChannelName = Jellyfin::Support::fromJsonValue(source["ProviderChannelName"]); + m_providerChannelId = Jellyfin::Support::fromJsonValue(source["ProviderChannelId"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); } QJsonObject TunerChannelMapping::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["ProviderChannelName"] = toJsonValue(m_providerChannelName); - result["ProviderChannelId"] = toJsonValue(m_providerChannelId); - result["Id"] = toJsonValue(m_jellyfinId); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["ProviderChannelName"] = Jellyfin::Support::toJsonValue(m_providerChannelName); + result["ProviderChannelId"] = Jellyfin::Support::toJsonValue(m_providerChannelId); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); return result; } @@ -79,6 +80,17 @@ void TunerChannelMapping::setJellyfinId(QString newJellyfinId) { m_jellyfinId = newJellyfinId; } +} // NS DTO + +namespace Support { + +using TunerChannelMapping = Jellyfin::DTO::TunerChannelMapping; + +template <> +TunerChannelMapping fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return TunerChannelMapping::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/tunerhostinfo.cpp b/core/src/DTO/tunerhostinfo.cpp index d08029d..05118a5 100644 --- a/core/src/DTO/tunerhostinfo.cpp +++ b/core/src/DTO/tunerhostinfo.cpp @@ -32,42 +32,43 @@ namespace Jellyfin { namespace DTO { -TunerHostInfo::TunerHostInfo(QObject *parent) {} +TunerHostInfo::TunerHostInfo() {} -TunerHostInfo TunerHostInfo::fromJson(QJsonObject source) {TunerHostInfo instance; - instance->setFromJson(source, false); +TunerHostInfo TunerHostInfo::fromJson(QJsonObject source) { + TunerHostInfo instance; + instance.setFromJson(source); return instance; } void TunerHostInfo::setFromJson(QJsonObject source) { - m_jellyfinId = fromJsonValue(source["Id"]); - m_url = fromJsonValue(source["Url"]); - m_type = fromJsonValue(source["Type"]); - m_deviceId = fromJsonValue(source["DeviceId"]); - m_friendlyName = fromJsonValue(source["FriendlyName"]); - m_importFavoritesOnly = fromJsonValue(source["ImportFavoritesOnly"]); - m_allowHWTranscoding = fromJsonValue(source["AllowHWTranscoding"]); - m_enableStreamLooping = fromJsonValue(source["EnableStreamLooping"]); - m_source = fromJsonValue(source["Source"]); - m_tunerCount = fromJsonValue(source["TunerCount"]); - m_userAgent = fromJsonValue(source["UserAgent"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); + m_url = Jellyfin::Support::fromJsonValue(source["Url"]); + m_type = Jellyfin::Support::fromJsonValue(source["Type"]); + m_deviceId = Jellyfin::Support::fromJsonValue(source["DeviceId"]); + m_friendlyName = Jellyfin::Support::fromJsonValue(source["FriendlyName"]); + m_importFavoritesOnly = Jellyfin::Support::fromJsonValue(source["ImportFavoritesOnly"]); + m_allowHWTranscoding = Jellyfin::Support::fromJsonValue(source["AllowHWTranscoding"]); + m_enableStreamLooping = Jellyfin::Support::fromJsonValue(source["EnableStreamLooping"]); + m_source = Jellyfin::Support::fromJsonValue(source["Source"]); + m_tunerCount = Jellyfin::Support::fromJsonValue(source["TunerCount"]); + m_userAgent = Jellyfin::Support::fromJsonValue(source["UserAgent"]); } QJsonObject TunerHostInfo::toJson() { QJsonObject result; - result["Id"] = toJsonValue(m_jellyfinId); - result["Url"] = toJsonValue(m_url); - result["Type"] = toJsonValue(m_type); - result["DeviceId"] = toJsonValue(m_deviceId); - result["FriendlyName"] = toJsonValue(m_friendlyName); - result["ImportFavoritesOnly"] = toJsonValue(m_importFavoritesOnly); - result["AllowHWTranscoding"] = toJsonValue(m_allowHWTranscoding); - result["EnableStreamLooping"] = toJsonValue(m_enableStreamLooping); - result["Source"] = toJsonValue(m_source); - result["TunerCount"] = toJsonValue(m_tunerCount); - result["UserAgent"] = toJsonValue(m_userAgent); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["Url"] = Jellyfin::Support::toJsonValue(m_url); + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + result["DeviceId"] = Jellyfin::Support::toJsonValue(m_deviceId); + result["FriendlyName"] = Jellyfin::Support::toJsonValue(m_friendlyName); + result["ImportFavoritesOnly"] = Jellyfin::Support::toJsonValue(m_importFavoritesOnly); + result["AllowHWTranscoding"] = Jellyfin::Support::toJsonValue(m_allowHWTranscoding); + result["EnableStreamLooping"] = Jellyfin::Support::toJsonValue(m_enableStreamLooping); + result["Source"] = Jellyfin::Support::toJsonValue(m_source); + result["TunerCount"] = Jellyfin::Support::toJsonValue(m_tunerCount); + result["UserAgent"] = Jellyfin::Support::toJsonValue(m_userAgent); return result; } @@ -128,6 +129,17 @@ void TunerHostInfo::setUserAgent(QString newUserAgent) { m_userAgent = newUserAgent; } +} // NS DTO + +namespace Support { + +using TunerHostInfo = Jellyfin::DTO::TunerHostInfo; + +template <> +TunerHostInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return TunerHostInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/typeoptions.cpp b/core/src/DTO/typeoptions.cpp index 2d7b2e2..9513e85 100644 --- a/core/src/DTO/typeoptions.cpp +++ b/core/src/DTO/typeoptions.cpp @@ -32,32 +32,33 @@ namespace Jellyfin { namespace DTO { -TypeOptions::TypeOptions(QObject *parent) {} +TypeOptions::TypeOptions() {} -TypeOptions TypeOptions::fromJson(QJsonObject source) {TypeOptions instance; - instance->setFromJson(source, false); +TypeOptions TypeOptions::fromJson(QJsonObject source) { + TypeOptions instance; + instance.setFromJson(source); return instance; } void TypeOptions::setFromJson(QJsonObject source) { - m_type = fromJsonValue(source["Type"]); - m_metadataFetchers = fromJsonValue(source["MetadataFetchers"]); - m_metadataFetcherOrder = fromJsonValue(source["MetadataFetcherOrder"]); - m_imageFetchers = fromJsonValue(source["ImageFetchers"]); - m_imageFetcherOrder = fromJsonValue(source["ImageFetcherOrder"]); - m_imageOptions = fromJsonValue>>(source["ImageOptions"]); + m_type = Jellyfin::Support::fromJsonValue(source["Type"]); + m_metadataFetchers = Jellyfin::Support::fromJsonValue(source["MetadataFetchers"]); + m_metadataFetcherOrder = Jellyfin::Support::fromJsonValue(source["MetadataFetcherOrder"]); + m_imageFetchers = Jellyfin::Support::fromJsonValue(source["ImageFetchers"]); + m_imageFetcherOrder = Jellyfin::Support::fromJsonValue(source["ImageFetcherOrder"]); + m_imageOptions = Jellyfin::Support::fromJsonValue>>(source["ImageOptions"]); } QJsonObject TypeOptions::toJson() { QJsonObject result; - result["Type"] = toJsonValue(m_type); - result["MetadataFetchers"] = toJsonValue(m_metadataFetchers); - result["MetadataFetcherOrder"] = toJsonValue(m_metadataFetcherOrder); - result["ImageFetchers"] = toJsonValue(m_imageFetchers); - result["ImageFetcherOrder"] = toJsonValue(m_imageFetcherOrder); - result["ImageOptions"] = toJsonValue>>(m_imageOptions); + result["Type"] = Jellyfin::Support::toJsonValue(m_type); + result["MetadataFetchers"] = Jellyfin::Support::toJsonValue(m_metadataFetchers); + result["MetadataFetcherOrder"] = Jellyfin::Support::toJsonValue(m_metadataFetcherOrder); + result["ImageFetchers"] = Jellyfin::Support::toJsonValue(m_imageFetchers); + result["ImageFetcherOrder"] = Jellyfin::Support::toJsonValue(m_imageFetcherOrder); + result["ImageOptions"] = Jellyfin::Support::toJsonValue>>(m_imageOptions); return result; } @@ -93,6 +94,17 @@ void TypeOptions::setImageOptions(QList> newImageOpt m_imageOptions = newImageOptions; } +} // NS DTO + +namespace Support { + +using TypeOptions = Jellyfin::DTO::TypeOptions; + +template <> +TypeOptions fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return TypeOptions::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/unrateditem.cpp b/core/src/DTO/unrateditem.cpp index 533e1fe..6ba2558 100644 --- a/core/src/DTO/unrateditem.cpp +++ b/core/src/DTO/unrateditem.cpp @@ -34,5 +34,48 @@ namespace DTO { UnratedItemClass::UnratedItemClass() {} + +} // NS DTO + +namespace Support { + +using UnratedItem = Jellyfin::DTO::UnratedItem; + +template <> +UnratedItem fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return UnratedItem::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("Movie")) { + return UnratedItem::Movie; + } + if (str == QStringLiteral("Trailer")) { + return UnratedItem::Trailer; + } + if (str == QStringLiteral("Series")) { + return UnratedItem::Series; + } + if (str == QStringLiteral("Music")) { + return UnratedItem::Music; + } + if (str == QStringLiteral("Book")) { + return UnratedItem::Book; + } + if (str == QStringLiteral("LiveTvChannel")) { + return UnratedItem::LiveTvChannel; + } + if (str == QStringLiteral("LiveTvProgram")) { + return UnratedItem::LiveTvProgram; + } + if (str == QStringLiteral("ChannelContent")) { + return UnratedItem::ChannelContent; + } + if (str == QStringLiteral("Other")) { + return UnratedItem::Other; + } + + return UnratedItem::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/updatelibraryoptionsdto.cpp b/core/src/DTO/updatelibraryoptionsdto.cpp index a31fb02..16887d4 100644 --- a/core/src/DTO/updatelibraryoptionsdto.cpp +++ b/core/src/DTO/updatelibraryoptionsdto.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -UpdateLibraryOptionsDto::UpdateLibraryOptionsDto(QObject *parent) {} +UpdateLibraryOptionsDto::UpdateLibraryOptionsDto() {} -UpdateLibraryOptionsDto UpdateLibraryOptionsDto::fromJson(QJsonObject source) {UpdateLibraryOptionsDto instance; - instance->setFromJson(source, false); +UpdateLibraryOptionsDto UpdateLibraryOptionsDto::fromJson(QJsonObject source) { + UpdateLibraryOptionsDto instance; + instance.setFromJson(source); return instance; } void UpdateLibraryOptionsDto::setFromJson(QJsonObject source) { - m_jellyfinId = fromJsonValue(source["Id"]); - m_libraryOptions = fromJsonValue>(source["LibraryOptions"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); + m_libraryOptions = Jellyfin::Support::fromJsonValue>(source["LibraryOptions"]); } QJsonObject UpdateLibraryOptionsDto::toJson() { QJsonObject result; - result["Id"] = toJsonValue(m_jellyfinId); - result["LibraryOptions"] = toJsonValue>(m_libraryOptions); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["LibraryOptions"] = Jellyfin::Support::toJsonValue>(m_libraryOptions); return result; } @@ -65,6 +66,17 @@ void UpdateLibraryOptionsDto::setLibraryOptions(QSharedPointer n m_libraryOptions = newLibraryOptions; } +} // NS DTO + +namespace Support { + +using UpdateLibraryOptionsDto = Jellyfin::DTO::UpdateLibraryOptionsDto; + +template <> +UpdateLibraryOptionsDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return UpdateLibraryOptionsDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/updateusereasypassword.cpp b/core/src/DTO/updateusereasypassword.cpp index f287e68..135d460 100644 --- a/core/src/DTO/updateusereasypassword.cpp +++ b/core/src/DTO/updateusereasypassword.cpp @@ -32,26 +32,27 @@ namespace Jellyfin { namespace DTO { -UpdateUserEasyPassword::UpdateUserEasyPassword(QObject *parent) {} +UpdateUserEasyPassword::UpdateUserEasyPassword() {} -UpdateUserEasyPassword UpdateUserEasyPassword::fromJson(QJsonObject source) {UpdateUserEasyPassword instance; - instance->setFromJson(source, false); +UpdateUserEasyPassword UpdateUserEasyPassword::fromJson(QJsonObject source) { + UpdateUserEasyPassword instance; + instance.setFromJson(source); return instance; } void UpdateUserEasyPassword::setFromJson(QJsonObject source) { - m_newPassword = fromJsonValue(source["NewPassword"]); - m_newPw = fromJsonValue(source["NewPw"]); - m_resetPassword = fromJsonValue(source["ResetPassword"]); + m_newPassword = Jellyfin::Support::fromJsonValue(source["NewPassword"]); + m_newPw = Jellyfin::Support::fromJsonValue(source["NewPw"]); + m_resetPassword = Jellyfin::Support::fromJsonValue(source["ResetPassword"]); } QJsonObject UpdateUserEasyPassword::toJson() { QJsonObject result; - result["NewPassword"] = toJsonValue(m_newPassword); - result["NewPw"] = toJsonValue(m_newPw); - result["ResetPassword"] = toJsonValue(m_resetPassword); + result["NewPassword"] = Jellyfin::Support::toJsonValue(m_newPassword); + result["NewPw"] = Jellyfin::Support::toJsonValue(m_newPw); + result["ResetPassword"] = Jellyfin::Support::toJsonValue(m_resetPassword); return result; } @@ -72,6 +73,17 @@ void UpdateUserEasyPassword::setResetPassword(bool newResetPassword) { m_resetPassword = newResetPassword; } +} // NS DTO + +namespace Support { + +using UpdateUserEasyPassword = Jellyfin::DTO::UpdateUserEasyPassword; + +template <> +UpdateUserEasyPassword fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return UpdateUserEasyPassword::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/updateuserpassword.cpp b/core/src/DTO/updateuserpassword.cpp index 479542d..377597f 100644 --- a/core/src/DTO/updateuserpassword.cpp +++ b/core/src/DTO/updateuserpassword.cpp @@ -32,28 +32,29 @@ namespace Jellyfin { namespace DTO { -UpdateUserPassword::UpdateUserPassword(QObject *parent) {} +UpdateUserPassword::UpdateUserPassword() {} -UpdateUserPassword UpdateUserPassword::fromJson(QJsonObject source) {UpdateUserPassword instance; - instance->setFromJson(source, false); +UpdateUserPassword UpdateUserPassword::fromJson(QJsonObject source) { + UpdateUserPassword instance; + instance.setFromJson(source); return instance; } void UpdateUserPassword::setFromJson(QJsonObject source) { - m_currentPassword = fromJsonValue(source["CurrentPassword"]); - m_currentPw = fromJsonValue(source["CurrentPw"]); - m_newPw = fromJsonValue(source["NewPw"]); - m_resetPassword = fromJsonValue(source["ResetPassword"]); + m_currentPassword = Jellyfin::Support::fromJsonValue(source["CurrentPassword"]); + m_currentPw = Jellyfin::Support::fromJsonValue(source["CurrentPw"]); + m_newPw = Jellyfin::Support::fromJsonValue(source["NewPw"]); + m_resetPassword = Jellyfin::Support::fromJsonValue(source["ResetPassword"]); } QJsonObject UpdateUserPassword::toJson() { QJsonObject result; - result["CurrentPassword"] = toJsonValue(m_currentPassword); - result["CurrentPw"] = toJsonValue(m_currentPw); - result["NewPw"] = toJsonValue(m_newPw); - result["ResetPassword"] = toJsonValue(m_resetPassword); + result["CurrentPassword"] = Jellyfin::Support::toJsonValue(m_currentPassword); + result["CurrentPw"] = Jellyfin::Support::toJsonValue(m_currentPw); + result["NewPw"] = Jellyfin::Support::toJsonValue(m_newPw); + result["ResetPassword"] = Jellyfin::Support::toJsonValue(m_resetPassword); return result; } @@ -79,6 +80,17 @@ void UpdateUserPassword::setResetPassword(bool newResetPassword) { m_resetPassword = newResetPassword; } +} // NS DTO + +namespace Support { + +using UpdateUserPassword = Jellyfin::DTO::UpdateUserPassword; + +template <> +UpdateUserPassword fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return UpdateUserPassword::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/uploadsubtitledto.cpp b/core/src/DTO/uploadsubtitledto.cpp index c4a365b..5dca02f 100644 --- a/core/src/DTO/uploadsubtitledto.cpp +++ b/core/src/DTO/uploadsubtitledto.cpp @@ -32,28 +32,29 @@ namespace Jellyfin { namespace DTO { -UploadSubtitleDto::UploadSubtitleDto(QObject *parent) {} +UploadSubtitleDto::UploadSubtitleDto() {} -UploadSubtitleDto UploadSubtitleDto::fromJson(QJsonObject source) {UploadSubtitleDto instance; - instance->setFromJson(source, false); +UploadSubtitleDto UploadSubtitleDto::fromJson(QJsonObject source) { + UploadSubtitleDto instance; + instance.setFromJson(source); return instance; } void UploadSubtitleDto::setFromJson(QJsonObject source) { - m_language = fromJsonValue(source["Language"]); - m_format = fromJsonValue(source["Format"]); - m_isForced = fromJsonValue(source["IsForced"]); - m_data = fromJsonValue(source["Data"]); + m_language = Jellyfin::Support::fromJsonValue(source["Language"]); + m_format = Jellyfin::Support::fromJsonValue(source["Format"]); + m_isForced = Jellyfin::Support::fromJsonValue(source["IsForced"]); + m_data = Jellyfin::Support::fromJsonValue(source["Data"]); } QJsonObject UploadSubtitleDto::toJson() { QJsonObject result; - result["Language"] = toJsonValue(m_language); - result["Format"] = toJsonValue(m_format); - result["IsForced"] = toJsonValue(m_isForced); - result["Data"] = toJsonValue(m_data); + result["Language"] = Jellyfin::Support::toJsonValue(m_language); + result["Format"] = Jellyfin::Support::toJsonValue(m_format); + result["IsForced"] = Jellyfin::Support::toJsonValue(m_isForced); + result["Data"] = Jellyfin::Support::toJsonValue(m_data); return result; } @@ -79,6 +80,17 @@ void UploadSubtitleDto::setData(QString newData) { m_data = newData; } +} // NS DTO + +namespace Support { + +using UploadSubtitleDto = Jellyfin::DTO::UploadSubtitleDto; + +template <> +UploadSubtitleDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return UploadSubtitleDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/user.cpp b/core/src/DTO/user.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/core/src/DTO/userconfiguration.cpp b/core/src/DTO/userconfiguration.cpp index 61addd8..a955585 100644 --- a/core/src/DTO/userconfiguration.cpp +++ b/core/src/DTO/userconfiguration.cpp @@ -32,50 +32,51 @@ namespace Jellyfin { namespace DTO { -UserConfiguration::UserConfiguration(QObject *parent) {} +UserConfiguration::UserConfiguration() {} -UserConfiguration UserConfiguration::fromJson(QJsonObject source) {UserConfiguration instance; - instance->setFromJson(source, false); +UserConfiguration UserConfiguration::fromJson(QJsonObject source) { + UserConfiguration instance; + instance.setFromJson(source); return instance; } void UserConfiguration::setFromJson(QJsonObject source) { - m_audioLanguagePreference = fromJsonValue(source["AudioLanguagePreference"]); - m_playDefaultAudioTrack = fromJsonValue(source["PlayDefaultAudioTrack"]); - m_subtitleLanguagePreference = fromJsonValue(source["SubtitleLanguagePreference"]); - m_displayMissingEpisodes = fromJsonValue(source["DisplayMissingEpisodes"]); - m_groupedFolders = fromJsonValue(source["GroupedFolders"]); - m_subtitleMode = fromJsonValue(source["SubtitleMode"]); - m_displayCollectionsView = fromJsonValue(source["DisplayCollectionsView"]); - m_enableLocalPassword = fromJsonValue(source["EnableLocalPassword"]); - m_orderedViews = fromJsonValue(source["OrderedViews"]); - m_latestItemsExcludes = fromJsonValue(source["LatestItemsExcludes"]); - m_myMediaExcludes = fromJsonValue(source["MyMediaExcludes"]); - m_hidePlayedInLatest = fromJsonValue(source["HidePlayedInLatest"]); - m_rememberAudioSelections = fromJsonValue(source["RememberAudioSelections"]); - m_rememberSubtitleSelections = fromJsonValue(source["RememberSubtitleSelections"]); - m_enableNextEpisodeAutoPlay = fromJsonValue(source["EnableNextEpisodeAutoPlay"]); + m_audioLanguagePreference = Jellyfin::Support::fromJsonValue(source["AudioLanguagePreference"]); + m_playDefaultAudioTrack = Jellyfin::Support::fromJsonValue(source["PlayDefaultAudioTrack"]); + m_subtitleLanguagePreference = Jellyfin::Support::fromJsonValue(source["SubtitleLanguagePreference"]); + m_displayMissingEpisodes = Jellyfin::Support::fromJsonValue(source["DisplayMissingEpisodes"]); + m_groupedFolders = Jellyfin::Support::fromJsonValue(source["GroupedFolders"]); + m_subtitleMode = Jellyfin::Support::fromJsonValue(source["SubtitleMode"]); + m_displayCollectionsView = Jellyfin::Support::fromJsonValue(source["DisplayCollectionsView"]); + m_enableLocalPassword = Jellyfin::Support::fromJsonValue(source["EnableLocalPassword"]); + m_orderedViews = Jellyfin::Support::fromJsonValue(source["OrderedViews"]); + m_latestItemsExcludes = Jellyfin::Support::fromJsonValue(source["LatestItemsExcludes"]); + m_myMediaExcludes = Jellyfin::Support::fromJsonValue(source["MyMediaExcludes"]); + m_hidePlayedInLatest = Jellyfin::Support::fromJsonValue(source["HidePlayedInLatest"]); + m_rememberAudioSelections = Jellyfin::Support::fromJsonValue(source["RememberAudioSelections"]); + m_rememberSubtitleSelections = Jellyfin::Support::fromJsonValue(source["RememberSubtitleSelections"]); + m_enableNextEpisodeAutoPlay = Jellyfin::Support::fromJsonValue(source["EnableNextEpisodeAutoPlay"]); } QJsonObject UserConfiguration::toJson() { QJsonObject result; - result["AudioLanguagePreference"] = toJsonValue(m_audioLanguagePreference); - result["PlayDefaultAudioTrack"] = toJsonValue(m_playDefaultAudioTrack); - result["SubtitleLanguagePreference"] = toJsonValue(m_subtitleLanguagePreference); - result["DisplayMissingEpisodes"] = toJsonValue(m_displayMissingEpisodes); - result["GroupedFolders"] = toJsonValue(m_groupedFolders); - result["SubtitleMode"] = toJsonValue(m_subtitleMode); - result["DisplayCollectionsView"] = toJsonValue(m_displayCollectionsView); - result["EnableLocalPassword"] = toJsonValue(m_enableLocalPassword); - result["OrderedViews"] = toJsonValue(m_orderedViews); - result["LatestItemsExcludes"] = toJsonValue(m_latestItemsExcludes); - result["MyMediaExcludes"] = toJsonValue(m_myMediaExcludes); - result["HidePlayedInLatest"] = toJsonValue(m_hidePlayedInLatest); - result["RememberAudioSelections"] = toJsonValue(m_rememberAudioSelections); - result["RememberSubtitleSelections"] = toJsonValue(m_rememberSubtitleSelections); - result["EnableNextEpisodeAutoPlay"] = toJsonValue(m_enableNextEpisodeAutoPlay); + result["AudioLanguagePreference"] = Jellyfin::Support::toJsonValue(m_audioLanguagePreference); + result["PlayDefaultAudioTrack"] = Jellyfin::Support::toJsonValue(m_playDefaultAudioTrack); + result["SubtitleLanguagePreference"] = Jellyfin::Support::toJsonValue(m_subtitleLanguagePreference); + result["DisplayMissingEpisodes"] = Jellyfin::Support::toJsonValue(m_displayMissingEpisodes); + result["GroupedFolders"] = Jellyfin::Support::toJsonValue(m_groupedFolders); + result["SubtitleMode"] = Jellyfin::Support::toJsonValue(m_subtitleMode); + result["DisplayCollectionsView"] = Jellyfin::Support::toJsonValue(m_displayCollectionsView); + result["EnableLocalPassword"] = Jellyfin::Support::toJsonValue(m_enableLocalPassword); + result["OrderedViews"] = Jellyfin::Support::toJsonValue(m_orderedViews); + result["LatestItemsExcludes"] = Jellyfin::Support::toJsonValue(m_latestItemsExcludes); + result["MyMediaExcludes"] = Jellyfin::Support::toJsonValue(m_myMediaExcludes); + result["HidePlayedInLatest"] = Jellyfin::Support::toJsonValue(m_hidePlayedInLatest); + result["RememberAudioSelections"] = Jellyfin::Support::toJsonValue(m_rememberAudioSelections); + result["RememberSubtitleSelections"] = Jellyfin::Support::toJsonValue(m_rememberSubtitleSelections); + result["EnableNextEpisodeAutoPlay"] = Jellyfin::Support::toJsonValue(m_enableNextEpisodeAutoPlay); return result; } @@ -156,6 +157,17 @@ void UserConfiguration::setEnableNextEpisodeAutoPlay(bool newEnableNextEpisodeAu m_enableNextEpisodeAutoPlay = newEnableNextEpisodeAutoPlay; } +} // NS DTO + +namespace Support { + +using UserConfiguration = Jellyfin::DTO::UserConfiguration; + +template <> +UserConfiguration fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return UserConfiguration::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/userdata.cpp b/core/src/DTO/userdata.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/core/src/DTO/userdto.cpp b/core/src/DTO/userdto.cpp index 27f6131..b7b8f6e 100644 --- a/core/src/DTO/userdto.cpp +++ b/core/src/DTO/userdto.cpp @@ -32,48 +32,49 @@ namespace Jellyfin { namespace DTO { -UserDto::UserDto(QObject *parent) {} +UserDto::UserDto() {} -UserDto UserDto::fromJson(QJsonObject source) {UserDto instance; - instance->setFromJson(source, false); +UserDto UserDto::fromJson(QJsonObject source) { + UserDto instance; + instance.setFromJson(source); return instance; } void UserDto::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_serverId = fromJsonValue(source["ServerId"]); - m_serverName = fromJsonValue(source["ServerName"]); - m_jellyfinId = fromJsonValue(source["Id"]); - m_primaryImageTag = fromJsonValue(source["PrimaryImageTag"]); - m_hasPassword = fromJsonValue(source["HasPassword"]); - m_hasConfiguredPassword = fromJsonValue(source["HasConfiguredPassword"]); - m_hasConfiguredEasyPassword = fromJsonValue(source["HasConfiguredEasyPassword"]); - m_enableAutoLogin = fromJsonValue(source["EnableAutoLogin"]); - m_lastLoginDate = fromJsonValue(source["LastLoginDate"]); - m_lastActivityDate = fromJsonValue(source["LastActivityDate"]); - m_configuration = fromJsonValue>(source["Configuration"]); - m_policy = fromJsonValue>(source["Policy"]); - m_primaryImageAspectRatio = fromJsonValue(source["PrimaryImageAspectRatio"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_serverId = Jellyfin::Support::fromJsonValue(source["ServerId"]); + m_serverName = Jellyfin::Support::fromJsonValue(source["ServerName"]); + m_jellyfinId = Jellyfin::Support::fromJsonValue(source["Id"]); + m_primaryImageTag = Jellyfin::Support::fromJsonValue(source["PrimaryImageTag"]); + m_hasPassword = Jellyfin::Support::fromJsonValue(source["HasPassword"]); + m_hasConfiguredPassword = Jellyfin::Support::fromJsonValue(source["HasConfiguredPassword"]); + m_hasConfiguredEasyPassword = Jellyfin::Support::fromJsonValue(source["HasConfiguredEasyPassword"]); + m_enableAutoLogin = Jellyfin::Support::fromJsonValue(source["EnableAutoLogin"]); + m_lastLoginDate = Jellyfin::Support::fromJsonValue(source["LastLoginDate"]); + m_lastActivityDate = Jellyfin::Support::fromJsonValue(source["LastActivityDate"]); + m_configuration = Jellyfin::Support::fromJsonValue>(source["Configuration"]); + m_policy = Jellyfin::Support::fromJsonValue>(source["Policy"]); + m_primaryImageAspectRatio = Jellyfin::Support::fromJsonValue(source["PrimaryImageAspectRatio"]); } QJsonObject UserDto::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["ServerId"] = toJsonValue(m_serverId); - result["ServerName"] = toJsonValue(m_serverName); - result["Id"] = toJsonValue(m_jellyfinId); - result["PrimaryImageTag"] = toJsonValue(m_primaryImageTag); - result["HasPassword"] = toJsonValue(m_hasPassword); - result["HasConfiguredPassword"] = toJsonValue(m_hasConfiguredPassword); - result["HasConfiguredEasyPassword"] = toJsonValue(m_hasConfiguredEasyPassword); - result["EnableAutoLogin"] = toJsonValue(m_enableAutoLogin); - result["LastLoginDate"] = toJsonValue(m_lastLoginDate); - result["LastActivityDate"] = toJsonValue(m_lastActivityDate); - result["Configuration"] = toJsonValue>(m_configuration); - result["Policy"] = toJsonValue>(m_policy); - result["PrimaryImageAspectRatio"] = toJsonValue(m_primaryImageAspectRatio); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["ServerId"] = Jellyfin::Support::toJsonValue(m_serverId); + result["ServerName"] = Jellyfin::Support::toJsonValue(m_serverName); + result["Id"] = Jellyfin::Support::toJsonValue(m_jellyfinId); + result["PrimaryImageTag"] = Jellyfin::Support::toJsonValue(m_primaryImageTag); + result["HasPassword"] = Jellyfin::Support::toJsonValue(m_hasPassword); + result["HasConfiguredPassword"] = Jellyfin::Support::toJsonValue(m_hasConfiguredPassword); + result["HasConfiguredEasyPassword"] = Jellyfin::Support::toJsonValue(m_hasConfiguredEasyPassword); + result["EnableAutoLogin"] = Jellyfin::Support::toJsonValue(m_enableAutoLogin); + result["LastLoginDate"] = Jellyfin::Support::toJsonValue(m_lastLoginDate); + result["LastActivityDate"] = Jellyfin::Support::toJsonValue(m_lastActivityDate); + result["Configuration"] = Jellyfin::Support::toJsonValue>(m_configuration); + result["Policy"] = Jellyfin::Support::toJsonValue>(m_policy); + result["PrimaryImageAspectRatio"] = Jellyfin::Support::toJsonValue(m_primaryImageAspectRatio); return result; } @@ -149,6 +150,17 @@ void UserDto::setPrimaryImageAspectRatio(double newPrimaryImageAspectRatio) { m_primaryImageAspectRatio = newPrimaryImageAspectRatio; } +} // NS DTO + +namespace Support { + +using UserDto = Jellyfin::DTO::UserDto; + +template <> +UserDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return UserDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/useritemdatadto.cpp b/core/src/DTO/useritemdatadto.cpp index a0e1630..8d4f23a 100644 --- a/core/src/DTO/useritemdatadto.cpp +++ b/core/src/DTO/useritemdatadto.cpp @@ -32,42 +32,43 @@ namespace Jellyfin { namespace DTO { -UserItemDataDto::UserItemDataDto(QObject *parent) {} +UserItemDataDto::UserItemDataDto() {} -UserItemDataDto UserItemDataDto::fromJson(QJsonObject source) {UserItemDataDto instance; - instance->setFromJson(source, false); +UserItemDataDto UserItemDataDto::fromJson(QJsonObject source) { + UserItemDataDto instance; + instance.setFromJson(source); return instance; } void UserItemDataDto::setFromJson(QJsonObject source) { - m_rating = fromJsonValue(source["Rating"]); - m_playedPercentage = fromJsonValue(source["PlayedPercentage"]); - m_unplayedItemCount = fromJsonValue(source["UnplayedItemCount"]); - m_playbackPositionTicks = fromJsonValue(source["PlaybackPositionTicks"]); - m_playCount = fromJsonValue(source["PlayCount"]); - m_isFavorite = fromJsonValue(source["IsFavorite"]); - m_likes = fromJsonValue(source["Likes"]); - m_lastPlayedDate = fromJsonValue(source["LastPlayedDate"]); - m_played = fromJsonValue(source["Played"]); - m_key = fromJsonValue(source["Key"]); - m_itemId = fromJsonValue(source["ItemId"]); + m_rating = Jellyfin::Support::fromJsonValue(source["Rating"]); + m_playedPercentage = Jellyfin::Support::fromJsonValue(source["PlayedPercentage"]); + m_unplayedItemCount = Jellyfin::Support::fromJsonValue(source["UnplayedItemCount"]); + m_playbackPositionTicks = Jellyfin::Support::fromJsonValue(source["PlaybackPositionTicks"]); + m_playCount = Jellyfin::Support::fromJsonValue(source["PlayCount"]); + m_isFavorite = Jellyfin::Support::fromJsonValue(source["IsFavorite"]); + m_likes = Jellyfin::Support::fromJsonValue(source["Likes"]); + m_lastPlayedDate = Jellyfin::Support::fromJsonValue(source["LastPlayedDate"]); + m_played = Jellyfin::Support::fromJsonValue(source["Played"]); + m_key = Jellyfin::Support::fromJsonValue(source["Key"]); + m_itemId = Jellyfin::Support::fromJsonValue(source["ItemId"]); } QJsonObject UserItemDataDto::toJson() { QJsonObject result; - result["Rating"] = toJsonValue(m_rating); - result["PlayedPercentage"] = toJsonValue(m_playedPercentage); - result["UnplayedItemCount"] = toJsonValue(m_unplayedItemCount); - result["PlaybackPositionTicks"] = toJsonValue(m_playbackPositionTicks); - result["PlayCount"] = toJsonValue(m_playCount); - result["IsFavorite"] = toJsonValue(m_isFavorite); - result["Likes"] = toJsonValue(m_likes); - result["LastPlayedDate"] = toJsonValue(m_lastPlayedDate); - result["Played"] = toJsonValue(m_played); - result["Key"] = toJsonValue(m_key); - result["ItemId"] = toJsonValue(m_itemId); + result["Rating"] = Jellyfin::Support::toJsonValue(m_rating); + result["PlayedPercentage"] = Jellyfin::Support::toJsonValue(m_playedPercentage); + result["UnplayedItemCount"] = Jellyfin::Support::toJsonValue(m_unplayedItemCount); + result["PlaybackPositionTicks"] = Jellyfin::Support::toJsonValue(m_playbackPositionTicks); + result["PlayCount"] = Jellyfin::Support::toJsonValue(m_playCount); + result["IsFavorite"] = Jellyfin::Support::toJsonValue(m_isFavorite); + result["Likes"] = Jellyfin::Support::toJsonValue(m_likes); + result["LastPlayedDate"] = Jellyfin::Support::toJsonValue(m_lastPlayedDate); + result["Played"] = Jellyfin::Support::toJsonValue(m_played); + result["Key"] = Jellyfin::Support::toJsonValue(m_key); + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); return result; } @@ -128,6 +129,17 @@ void UserItemDataDto::setItemId(QString newItemId) { m_itemId = newItemId; } +} // NS DTO + +namespace Support { + +using UserItemDataDto = Jellyfin::DTO::UserItemDataDto; + +template <> +UserItemDataDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return UserItemDataDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/userpolicy.cpp b/core/src/DTO/userpolicy.cpp index 8071bdc..e34d208 100644 --- a/core/src/DTO/userpolicy.cpp +++ b/core/src/DTO/userpolicy.cpp @@ -32,98 +32,99 @@ namespace Jellyfin { namespace DTO { -UserPolicy::UserPolicy(QObject *parent) {} +UserPolicy::UserPolicy() {} -UserPolicy UserPolicy::fromJson(QJsonObject source) {UserPolicy instance; - instance->setFromJson(source, false); +UserPolicy UserPolicy::fromJson(QJsonObject source) { + UserPolicy instance; + instance.setFromJson(source); return instance; } void UserPolicy::setFromJson(QJsonObject source) { - m_isAdministrator = fromJsonValue(source["IsAdministrator"]); - m_isHidden = fromJsonValue(source["IsHidden"]); - m_isDisabled = fromJsonValue(source["IsDisabled"]); - m_maxParentalRating = fromJsonValue(source["MaxParentalRating"]); - m_blockedTags = fromJsonValue(source["BlockedTags"]); - m_enableUserPreferenceAccess = fromJsonValue(source["EnableUserPreferenceAccess"]); - m_accessSchedules = fromJsonValue>>(source["AccessSchedules"]); - m_blockUnratedItems = fromJsonValue>(source["BlockUnratedItems"]); - m_enableRemoteControlOfOtherUsers = fromJsonValue(source["EnableRemoteControlOfOtherUsers"]); - m_enableSharedDeviceControl = fromJsonValue(source["EnableSharedDeviceControl"]); - m_enableRemoteAccess = fromJsonValue(source["EnableRemoteAccess"]); - m_enableLiveTvManagement = fromJsonValue(source["EnableLiveTvManagement"]); - m_enableLiveTvAccess = fromJsonValue(source["EnableLiveTvAccess"]); - m_enableMediaPlayback = fromJsonValue(source["EnableMediaPlayback"]); - m_enableAudioPlaybackTranscoding = fromJsonValue(source["EnableAudioPlaybackTranscoding"]); - m_enableVideoPlaybackTranscoding = fromJsonValue(source["EnableVideoPlaybackTranscoding"]); - m_enablePlaybackRemuxing = fromJsonValue(source["EnablePlaybackRemuxing"]); - m_forceRemoteSourceTranscoding = fromJsonValue(source["ForceRemoteSourceTranscoding"]); - m_enableContentDeletion = fromJsonValue(source["EnableContentDeletion"]); - m_enableContentDeletionFromFolders = fromJsonValue(source["EnableContentDeletionFromFolders"]); - m_enableContentDownloading = fromJsonValue(source["EnableContentDownloading"]); - m_enableSyncTranscoding = fromJsonValue(source["EnableSyncTranscoding"]); - m_enableMediaConversion = fromJsonValue(source["EnableMediaConversion"]); - m_enabledDevices = fromJsonValue(source["EnabledDevices"]); - m_enableAllDevices = fromJsonValue(source["EnableAllDevices"]); - m_enabledChannels = fromJsonValue>(source["EnabledChannels"]); - m_enableAllChannels = fromJsonValue(source["EnableAllChannels"]); - m_enabledFolders = fromJsonValue>(source["EnabledFolders"]); - m_enableAllFolders = fromJsonValue(source["EnableAllFolders"]); - m_invalidLoginAttemptCount = fromJsonValue(source["InvalidLoginAttemptCount"]); - m_loginAttemptsBeforeLockout = fromJsonValue(source["LoginAttemptsBeforeLockout"]); - m_maxActiveSessions = fromJsonValue(source["MaxActiveSessions"]); - m_enablePublicSharing = fromJsonValue(source["EnablePublicSharing"]); - m_blockedMediaFolders = fromJsonValue>(source["BlockedMediaFolders"]); - m_blockedChannels = fromJsonValue>(source["BlockedChannels"]); - m_remoteClientBitrateLimit = fromJsonValue(source["RemoteClientBitrateLimit"]); - m_authenticationProviderId = fromJsonValue(source["AuthenticationProviderId"]); - m_passwordResetProviderId = fromJsonValue(source["PasswordResetProviderId"]); - m_syncPlayAccess = fromJsonValue(source["SyncPlayAccess"]); + m_isAdministrator = Jellyfin::Support::fromJsonValue(source["IsAdministrator"]); + m_isHidden = Jellyfin::Support::fromJsonValue(source["IsHidden"]); + m_isDisabled = Jellyfin::Support::fromJsonValue(source["IsDisabled"]); + m_maxParentalRating = Jellyfin::Support::fromJsonValue(source["MaxParentalRating"]); + m_blockedTags = Jellyfin::Support::fromJsonValue(source["BlockedTags"]); + m_enableUserPreferenceAccess = Jellyfin::Support::fromJsonValue(source["EnableUserPreferenceAccess"]); + m_accessSchedules = Jellyfin::Support::fromJsonValue>>(source["AccessSchedules"]); + m_blockUnratedItems = Jellyfin::Support::fromJsonValue>(source["BlockUnratedItems"]); + m_enableRemoteControlOfOtherUsers = Jellyfin::Support::fromJsonValue(source["EnableRemoteControlOfOtherUsers"]); + m_enableSharedDeviceControl = Jellyfin::Support::fromJsonValue(source["EnableSharedDeviceControl"]); + m_enableRemoteAccess = Jellyfin::Support::fromJsonValue(source["EnableRemoteAccess"]); + m_enableLiveTvManagement = Jellyfin::Support::fromJsonValue(source["EnableLiveTvManagement"]); + m_enableLiveTvAccess = Jellyfin::Support::fromJsonValue(source["EnableLiveTvAccess"]); + m_enableMediaPlayback = Jellyfin::Support::fromJsonValue(source["EnableMediaPlayback"]); + m_enableAudioPlaybackTranscoding = Jellyfin::Support::fromJsonValue(source["EnableAudioPlaybackTranscoding"]); + m_enableVideoPlaybackTranscoding = Jellyfin::Support::fromJsonValue(source["EnableVideoPlaybackTranscoding"]); + m_enablePlaybackRemuxing = Jellyfin::Support::fromJsonValue(source["EnablePlaybackRemuxing"]); + m_forceRemoteSourceTranscoding = Jellyfin::Support::fromJsonValue(source["ForceRemoteSourceTranscoding"]); + m_enableContentDeletion = Jellyfin::Support::fromJsonValue(source["EnableContentDeletion"]); + m_enableContentDeletionFromFolders = Jellyfin::Support::fromJsonValue(source["EnableContentDeletionFromFolders"]); + m_enableContentDownloading = Jellyfin::Support::fromJsonValue(source["EnableContentDownloading"]); + m_enableSyncTranscoding = Jellyfin::Support::fromJsonValue(source["EnableSyncTranscoding"]); + m_enableMediaConversion = Jellyfin::Support::fromJsonValue(source["EnableMediaConversion"]); + m_enabledDevices = Jellyfin::Support::fromJsonValue(source["EnabledDevices"]); + m_enableAllDevices = Jellyfin::Support::fromJsonValue(source["EnableAllDevices"]); + m_enabledChannels = Jellyfin::Support::fromJsonValue>(source["EnabledChannels"]); + m_enableAllChannels = Jellyfin::Support::fromJsonValue(source["EnableAllChannels"]); + m_enabledFolders = Jellyfin::Support::fromJsonValue>(source["EnabledFolders"]); + m_enableAllFolders = Jellyfin::Support::fromJsonValue(source["EnableAllFolders"]); + m_invalidLoginAttemptCount = Jellyfin::Support::fromJsonValue(source["InvalidLoginAttemptCount"]); + m_loginAttemptsBeforeLockout = Jellyfin::Support::fromJsonValue(source["LoginAttemptsBeforeLockout"]); + m_maxActiveSessions = Jellyfin::Support::fromJsonValue(source["MaxActiveSessions"]); + m_enablePublicSharing = Jellyfin::Support::fromJsonValue(source["EnablePublicSharing"]); + m_blockedMediaFolders = Jellyfin::Support::fromJsonValue>(source["BlockedMediaFolders"]); + m_blockedChannels = Jellyfin::Support::fromJsonValue>(source["BlockedChannels"]); + m_remoteClientBitrateLimit = Jellyfin::Support::fromJsonValue(source["RemoteClientBitrateLimit"]); + m_authenticationProviderId = Jellyfin::Support::fromJsonValue(source["AuthenticationProviderId"]); + m_passwordResetProviderId = Jellyfin::Support::fromJsonValue(source["PasswordResetProviderId"]); + m_syncPlayAccess = Jellyfin::Support::fromJsonValue(source["SyncPlayAccess"]); } QJsonObject UserPolicy::toJson() { QJsonObject result; - result["IsAdministrator"] = toJsonValue(m_isAdministrator); - result["IsHidden"] = toJsonValue(m_isHidden); - result["IsDisabled"] = toJsonValue(m_isDisabled); - result["MaxParentalRating"] = toJsonValue(m_maxParentalRating); - result["BlockedTags"] = toJsonValue(m_blockedTags); - result["EnableUserPreferenceAccess"] = toJsonValue(m_enableUserPreferenceAccess); - result["AccessSchedules"] = toJsonValue>>(m_accessSchedules); - result["BlockUnratedItems"] = toJsonValue>(m_blockUnratedItems); - result["EnableRemoteControlOfOtherUsers"] = toJsonValue(m_enableRemoteControlOfOtherUsers); - result["EnableSharedDeviceControl"] = toJsonValue(m_enableSharedDeviceControl); - result["EnableRemoteAccess"] = toJsonValue(m_enableRemoteAccess); - result["EnableLiveTvManagement"] = toJsonValue(m_enableLiveTvManagement); - result["EnableLiveTvAccess"] = toJsonValue(m_enableLiveTvAccess); - result["EnableMediaPlayback"] = toJsonValue(m_enableMediaPlayback); - result["EnableAudioPlaybackTranscoding"] = toJsonValue(m_enableAudioPlaybackTranscoding); - result["EnableVideoPlaybackTranscoding"] = toJsonValue(m_enableVideoPlaybackTranscoding); - result["EnablePlaybackRemuxing"] = toJsonValue(m_enablePlaybackRemuxing); - result["ForceRemoteSourceTranscoding"] = toJsonValue(m_forceRemoteSourceTranscoding); - result["EnableContentDeletion"] = toJsonValue(m_enableContentDeletion); - result["EnableContentDeletionFromFolders"] = toJsonValue(m_enableContentDeletionFromFolders); - result["EnableContentDownloading"] = toJsonValue(m_enableContentDownloading); - result["EnableSyncTranscoding"] = toJsonValue(m_enableSyncTranscoding); - result["EnableMediaConversion"] = toJsonValue(m_enableMediaConversion); - result["EnabledDevices"] = toJsonValue(m_enabledDevices); - result["EnableAllDevices"] = toJsonValue(m_enableAllDevices); - result["EnabledChannels"] = toJsonValue>(m_enabledChannels); - result["EnableAllChannels"] = toJsonValue(m_enableAllChannels); - result["EnabledFolders"] = toJsonValue>(m_enabledFolders); - result["EnableAllFolders"] = toJsonValue(m_enableAllFolders); - result["InvalidLoginAttemptCount"] = toJsonValue(m_invalidLoginAttemptCount); - result["LoginAttemptsBeforeLockout"] = toJsonValue(m_loginAttemptsBeforeLockout); - result["MaxActiveSessions"] = toJsonValue(m_maxActiveSessions); - result["EnablePublicSharing"] = toJsonValue(m_enablePublicSharing); - result["BlockedMediaFolders"] = toJsonValue>(m_blockedMediaFolders); - result["BlockedChannels"] = toJsonValue>(m_blockedChannels); - result["RemoteClientBitrateLimit"] = toJsonValue(m_remoteClientBitrateLimit); - result["AuthenticationProviderId"] = toJsonValue(m_authenticationProviderId); - result["PasswordResetProviderId"] = toJsonValue(m_passwordResetProviderId); - result["SyncPlayAccess"] = toJsonValue(m_syncPlayAccess); + result["IsAdministrator"] = Jellyfin::Support::toJsonValue(m_isAdministrator); + result["IsHidden"] = Jellyfin::Support::toJsonValue(m_isHidden); + result["IsDisabled"] = Jellyfin::Support::toJsonValue(m_isDisabled); + result["MaxParentalRating"] = Jellyfin::Support::toJsonValue(m_maxParentalRating); + result["BlockedTags"] = Jellyfin::Support::toJsonValue(m_blockedTags); + result["EnableUserPreferenceAccess"] = Jellyfin::Support::toJsonValue(m_enableUserPreferenceAccess); + result["AccessSchedules"] = Jellyfin::Support::toJsonValue>>(m_accessSchedules); + result["BlockUnratedItems"] = Jellyfin::Support::toJsonValue>(m_blockUnratedItems); + result["EnableRemoteControlOfOtherUsers"] = Jellyfin::Support::toJsonValue(m_enableRemoteControlOfOtherUsers); + result["EnableSharedDeviceControl"] = Jellyfin::Support::toJsonValue(m_enableSharedDeviceControl); + result["EnableRemoteAccess"] = Jellyfin::Support::toJsonValue(m_enableRemoteAccess); + result["EnableLiveTvManagement"] = Jellyfin::Support::toJsonValue(m_enableLiveTvManagement); + result["EnableLiveTvAccess"] = Jellyfin::Support::toJsonValue(m_enableLiveTvAccess); + result["EnableMediaPlayback"] = Jellyfin::Support::toJsonValue(m_enableMediaPlayback); + result["EnableAudioPlaybackTranscoding"] = Jellyfin::Support::toJsonValue(m_enableAudioPlaybackTranscoding); + result["EnableVideoPlaybackTranscoding"] = Jellyfin::Support::toJsonValue(m_enableVideoPlaybackTranscoding); + result["EnablePlaybackRemuxing"] = Jellyfin::Support::toJsonValue(m_enablePlaybackRemuxing); + result["ForceRemoteSourceTranscoding"] = Jellyfin::Support::toJsonValue(m_forceRemoteSourceTranscoding); + result["EnableContentDeletion"] = Jellyfin::Support::toJsonValue(m_enableContentDeletion); + result["EnableContentDeletionFromFolders"] = Jellyfin::Support::toJsonValue(m_enableContentDeletionFromFolders); + result["EnableContentDownloading"] = Jellyfin::Support::toJsonValue(m_enableContentDownloading); + result["EnableSyncTranscoding"] = Jellyfin::Support::toJsonValue(m_enableSyncTranscoding); + result["EnableMediaConversion"] = Jellyfin::Support::toJsonValue(m_enableMediaConversion); + result["EnabledDevices"] = Jellyfin::Support::toJsonValue(m_enabledDevices); + result["EnableAllDevices"] = Jellyfin::Support::toJsonValue(m_enableAllDevices); + result["EnabledChannels"] = Jellyfin::Support::toJsonValue>(m_enabledChannels); + result["EnableAllChannels"] = Jellyfin::Support::toJsonValue(m_enableAllChannels); + result["EnabledFolders"] = Jellyfin::Support::toJsonValue>(m_enabledFolders); + result["EnableAllFolders"] = Jellyfin::Support::toJsonValue(m_enableAllFolders); + result["InvalidLoginAttemptCount"] = Jellyfin::Support::toJsonValue(m_invalidLoginAttemptCount); + result["LoginAttemptsBeforeLockout"] = Jellyfin::Support::toJsonValue(m_loginAttemptsBeforeLockout); + result["MaxActiveSessions"] = Jellyfin::Support::toJsonValue(m_maxActiveSessions); + result["EnablePublicSharing"] = Jellyfin::Support::toJsonValue(m_enablePublicSharing); + result["BlockedMediaFolders"] = Jellyfin::Support::toJsonValue>(m_blockedMediaFolders); + result["BlockedChannels"] = Jellyfin::Support::toJsonValue>(m_blockedChannels); + result["RemoteClientBitrateLimit"] = Jellyfin::Support::toJsonValue(m_remoteClientBitrateLimit); + result["AuthenticationProviderId"] = Jellyfin::Support::toJsonValue(m_authenticationProviderId); + result["PasswordResetProviderId"] = Jellyfin::Support::toJsonValue(m_passwordResetProviderId); + result["SyncPlayAccess"] = Jellyfin::Support::toJsonValue(m_syncPlayAccess); return result; } @@ -324,6 +325,17 @@ void UserPolicy::setSyncPlayAccess(SyncPlayUserAccessType newSyncPlayAccess) { m_syncPlayAccess = newSyncPlayAccess; } +} // NS DTO + +namespace Support { + +using UserPolicy = Jellyfin::DTO::UserPolicy; + +template <> +UserPolicy fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return UserPolicy::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/utctimeresponse.cpp b/core/src/DTO/utctimeresponse.cpp index 7906509..9d7d54c 100644 --- a/core/src/DTO/utctimeresponse.cpp +++ b/core/src/DTO/utctimeresponse.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -UtcTimeResponse::UtcTimeResponse(QObject *parent) {} +UtcTimeResponse::UtcTimeResponse() {} -UtcTimeResponse UtcTimeResponse::fromJson(QJsonObject source) {UtcTimeResponse instance; - instance->setFromJson(source, false); +UtcTimeResponse UtcTimeResponse::fromJson(QJsonObject source) { + UtcTimeResponse instance; + instance.setFromJson(source); return instance; } void UtcTimeResponse::setFromJson(QJsonObject source) { - m_requestReceptionTime = fromJsonValue(source["RequestReceptionTime"]); - m_responseTransmissionTime = fromJsonValue(source["ResponseTransmissionTime"]); + m_requestReceptionTime = Jellyfin::Support::fromJsonValue(source["RequestReceptionTime"]); + m_responseTransmissionTime = Jellyfin::Support::fromJsonValue(source["ResponseTransmissionTime"]); } QJsonObject UtcTimeResponse::toJson() { QJsonObject result; - result["RequestReceptionTime"] = toJsonValue(m_requestReceptionTime); - result["ResponseTransmissionTime"] = toJsonValue(m_responseTransmissionTime); + result["RequestReceptionTime"] = Jellyfin::Support::toJsonValue(m_requestReceptionTime); + result["ResponseTransmissionTime"] = Jellyfin::Support::toJsonValue(m_responseTransmissionTime); return result; } @@ -65,6 +66,17 @@ void UtcTimeResponse::setResponseTransmissionTime(QDateTime newResponseTransmiss m_responseTransmissionTime = newResponseTransmissionTime; } +} // NS DTO + +namespace Support { + +using UtcTimeResponse = Jellyfin::DTO::UtcTimeResponse; + +template <> +UtcTimeResponse fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return UtcTimeResponse::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/validatepathdto.cpp b/core/src/DTO/validatepathdto.cpp index 68f6faa..49deedd 100644 --- a/core/src/DTO/validatepathdto.cpp +++ b/core/src/DTO/validatepathdto.cpp @@ -32,26 +32,27 @@ namespace Jellyfin { namespace DTO { -ValidatePathDto::ValidatePathDto(QObject *parent) {} +ValidatePathDto::ValidatePathDto() {} -ValidatePathDto ValidatePathDto::fromJson(QJsonObject source) {ValidatePathDto instance; - instance->setFromJson(source, false); +ValidatePathDto ValidatePathDto::fromJson(QJsonObject source) { + ValidatePathDto instance; + instance.setFromJson(source); return instance; } void ValidatePathDto::setFromJson(QJsonObject source) { - m_validateWritable = fromJsonValue(source["ValidateWritable"]); - m_path = fromJsonValue(source["Path"]); - m_isFile = fromJsonValue(source["IsFile"]); + m_validateWritable = Jellyfin::Support::fromJsonValue(source["ValidateWritable"]); + m_path = Jellyfin::Support::fromJsonValue(source["Path"]); + m_isFile = Jellyfin::Support::fromJsonValue(source["IsFile"]); } QJsonObject ValidatePathDto::toJson() { QJsonObject result; - result["ValidateWritable"] = toJsonValue(m_validateWritable); - result["Path"] = toJsonValue(m_path); - result["IsFile"] = toJsonValue(m_isFile); + result["ValidateWritable"] = Jellyfin::Support::toJsonValue(m_validateWritable); + result["Path"] = Jellyfin::Support::toJsonValue(m_path); + result["IsFile"] = Jellyfin::Support::toJsonValue(m_isFile); return result; } @@ -72,6 +73,17 @@ void ValidatePathDto::setIsFile(bool newIsFile) { m_isFile = newIsFile; } +} // NS DTO + +namespace Support { + +using ValidatePathDto = Jellyfin::DTO::ValidatePathDto; + +template <> +ValidatePathDto fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return ValidatePathDto::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/version.cpp b/core/src/DTO/version.cpp index 6c6833a..527ca0c 100644 --- a/core/src/DTO/version.cpp +++ b/core/src/DTO/version.cpp @@ -32,32 +32,33 @@ namespace Jellyfin { namespace DTO { -Version::Version(QObject *parent) {} +Version::Version() {} -Version Version::fromJson(QJsonObject source) {Version instance; - instance->setFromJson(source, false); +Version Version::fromJson(QJsonObject source) { + Version instance; + instance.setFromJson(source); return instance; } void Version::setFromJson(QJsonObject source) { - m_major = fromJsonValue(source["Major"]); - m_minor = fromJsonValue(source["Minor"]); - m_build = fromJsonValue(source["Build"]); - m_revision = fromJsonValue(source["Revision"]); - m_majorRevision = fromJsonValue(source["MajorRevision"]); - m_minorRevision = fromJsonValue(source["MinorRevision"]); + m_major = Jellyfin::Support::fromJsonValue(source["Major"]); + m_minor = Jellyfin::Support::fromJsonValue(source["Minor"]); + m_build = Jellyfin::Support::fromJsonValue(source["Build"]); + m_revision = Jellyfin::Support::fromJsonValue(source["Revision"]); + m_majorRevision = Jellyfin::Support::fromJsonValue(source["MajorRevision"]); + m_minorRevision = Jellyfin::Support::fromJsonValue(source["MinorRevision"]); } QJsonObject Version::toJson() { QJsonObject result; - result["Major"] = toJsonValue(m_major); - result["Minor"] = toJsonValue(m_minor); - result["Build"] = toJsonValue(m_build); - result["Revision"] = toJsonValue(m_revision); - result["MajorRevision"] = toJsonValue(m_majorRevision); - result["MinorRevision"] = toJsonValue(m_minorRevision); + result["Major"] = Jellyfin::Support::toJsonValue(m_major); + result["Minor"] = Jellyfin::Support::toJsonValue(m_minor); + result["Build"] = Jellyfin::Support::toJsonValue(m_build); + result["Revision"] = Jellyfin::Support::toJsonValue(m_revision); + result["MajorRevision"] = Jellyfin::Support::toJsonValue(m_majorRevision); + result["MinorRevision"] = Jellyfin::Support::toJsonValue(m_minorRevision); return result; } @@ -93,6 +94,17 @@ void Version::setMinorRevision(qint32 newMinorRevision) { m_minorRevision = newMinorRevision; } +} // NS DTO + +namespace Support { + +using Version = Jellyfin::DTO::Version; + +template <> +Version fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return Version::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/versioninfo.cpp b/core/src/DTO/versioninfo.cpp index 7662ab0..b40dc75 100644 --- a/core/src/DTO/versioninfo.cpp +++ b/core/src/DTO/versioninfo.cpp @@ -32,38 +32,39 @@ namespace Jellyfin { namespace DTO { -VersionInfo::VersionInfo(QObject *parent) {} +VersionInfo::VersionInfo() {} -VersionInfo VersionInfo::fromJson(QJsonObject source) {VersionInfo instance; - instance->setFromJson(source, false); +VersionInfo VersionInfo::fromJson(QJsonObject source) { + VersionInfo instance; + instance.setFromJson(source); return instance; } void VersionInfo::setFromJson(QJsonObject source) { - m_version = fromJsonValue(source["version"]); - m_versionNumber = fromJsonValue>(source["VersionNumber"]); - m_changelog = fromJsonValue(source["changelog"]); - m_targetAbi = fromJsonValue(source["targetAbi"]); - m_sourceUrl = fromJsonValue(source["sourceUrl"]); - m_checksum = fromJsonValue(source["checksum"]); - m_timestamp = fromJsonValue(source["timestamp"]); - m_repositoryName = fromJsonValue(source["repositoryName"]); - m_repositoryUrl = fromJsonValue(source["repositoryUrl"]); + m_version = Jellyfin::Support::fromJsonValue(source["version"]); + m_versionNumber = Jellyfin::Support::fromJsonValue>(source["VersionNumber"]); + m_changelog = Jellyfin::Support::fromJsonValue(source["changelog"]); + m_targetAbi = Jellyfin::Support::fromJsonValue(source["targetAbi"]); + m_sourceUrl = Jellyfin::Support::fromJsonValue(source["sourceUrl"]); + m_checksum = Jellyfin::Support::fromJsonValue(source["checksum"]); + m_timestamp = Jellyfin::Support::fromJsonValue(source["timestamp"]); + m_repositoryName = Jellyfin::Support::fromJsonValue(source["repositoryName"]); + m_repositoryUrl = Jellyfin::Support::fromJsonValue(source["repositoryUrl"]); } QJsonObject VersionInfo::toJson() { QJsonObject result; - result["version"] = toJsonValue(m_version); - result["VersionNumber"] = toJsonValue>(m_versionNumber); - result["changelog"] = toJsonValue(m_changelog); - result["targetAbi"] = toJsonValue(m_targetAbi); - result["sourceUrl"] = toJsonValue(m_sourceUrl); - result["checksum"] = toJsonValue(m_checksum); - result["timestamp"] = toJsonValue(m_timestamp); - result["repositoryName"] = toJsonValue(m_repositoryName); - result["repositoryUrl"] = toJsonValue(m_repositoryUrl); + result["version"] = Jellyfin::Support::toJsonValue(m_version); + result["VersionNumber"] = Jellyfin::Support::toJsonValue>(m_versionNumber); + result["changelog"] = Jellyfin::Support::toJsonValue(m_changelog); + result["targetAbi"] = Jellyfin::Support::toJsonValue(m_targetAbi); + result["sourceUrl"] = Jellyfin::Support::toJsonValue(m_sourceUrl); + result["checksum"] = Jellyfin::Support::toJsonValue(m_checksum); + result["timestamp"] = Jellyfin::Support::toJsonValue(m_timestamp); + result["repositoryName"] = Jellyfin::Support::toJsonValue(m_repositoryName); + result["repositoryUrl"] = Jellyfin::Support::toJsonValue(m_repositoryUrl); return result; } @@ -114,6 +115,17 @@ void VersionInfo::setRepositoryUrl(QString newRepositoryUrl) { m_repositoryUrl = newRepositoryUrl; } +} // NS DTO + +namespace Support { + +using VersionInfo = Jellyfin::DTO::VersionInfo; + +template <> +VersionInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return VersionInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/video3dformat.cpp b/core/src/DTO/video3dformat.cpp index d476d71..aa3de2d 100644 --- a/core/src/DTO/video3dformat.cpp +++ b/core/src/DTO/video3dformat.cpp @@ -34,5 +34,36 @@ namespace DTO { Video3DFormatClass::Video3DFormatClass() {} + +} // NS DTO + +namespace Support { + +using Video3DFormat = Jellyfin::DTO::Video3DFormat; + +template <> +Video3DFormat fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return Video3DFormat::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("HalfSideBySide")) { + return Video3DFormat::HalfSideBySide; + } + if (str == QStringLiteral("FullSideBySide")) { + return Video3DFormat::FullSideBySide; + } + if (str == QStringLiteral("FullTopAndBottom")) { + return Video3DFormat::FullTopAndBottom; + } + if (str == QStringLiteral("HalfTopAndBottom")) { + return Video3DFormat::HalfTopAndBottom; + } + if (str == QStringLiteral("MVC")) { + return Video3DFormat::MVC; + } + + return Video3DFormat::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/videotype.cpp b/core/src/DTO/videotype.cpp index 2527786..d9b78ba 100644 --- a/core/src/DTO/videotype.cpp +++ b/core/src/DTO/videotype.cpp @@ -34,5 +34,33 @@ namespace DTO { VideoTypeClass::VideoTypeClass() {} + +} // NS DTO + +namespace Support { + +using VideoType = Jellyfin::DTO::VideoType; + +template <> +VideoType fromJsonValue(const QJsonValue &source) { + if (!source.isString()) return VideoType::EnumNotSet; + + QString str = source.toString(); + if (str == QStringLiteral("VideoFile")) { + return VideoType::VideoFile; + } + if (str == QStringLiteral("Iso")) { + return VideoType::Iso; + } + if (str == QStringLiteral("Dvd")) { + return VideoType::Dvd; + } + if (str == QStringLiteral("BluRay")) { + return VideoType::BluRay; + } + + return VideoType::EnumNotSet; +} + } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/virtualfolderinfo.cpp b/core/src/DTO/virtualfolderinfo.cpp index d83c644..568b9e8 100644 --- a/core/src/DTO/virtualfolderinfo.cpp +++ b/core/src/DTO/virtualfolderinfo.cpp @@ -32,36 +32,37 @@ namespace Jellyfin { namespace DTO { -VirtualFolderInfo::VirtualFolderInfo(QObject *parent) {} +VirtualFolderInfo::VirtualFolderInfo() {} -VirtualFolderInfo VirtualFolderInfo::fromJson(QJsonObject source) {VirtualFolderInfo instance; - instance->setFromJson(source, false); +VirtualFolderInfo VirtualFolderInfo::fromJson(QJsonObject source) { + VirtualFolderInfo instance; + instance.setFromJson(source); return instance; } void VirtualFolderInfo::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_locations = fromJsonValue(source["Locations"]); - m_collectionType = fromJsonValue(source["CollectionType"]); - m_libraryOptions = fromJsonValue>(source["LibraryOptions"]); - m_itemId = fromJsonValue(source["ItemId"]); - m_primaryImageItemId = fromJsonValue(source["PrimaryImageItemId"]); - m_refreshProgress = fromJsonValue(source["RefreshProgress"]); - m_refreshStatus = fromJsonValue(source["RefreshStatus"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_locations = Jellyfin::Support::fromJsonValue(source["Locations"]); + m_collectionType = Jellyfin::Support::fromJsonValue(source["CollectionType"]); + m_libraryOptions = Jellyfin::Support::fromJsonValue>(source["LibraryOptions"]); + m_itemId = Jellyfin::Support::fromJsonValue(source["ItemId"]); + m_primaryImageItemId = Jellyfin::Support::fromJsonValue(source["PrimaryImageItemId"]); + m_refreshProgress = Jellyfin::Support::fromJsonValue(source["RefreshProgress"]); + m_refreshStatus = Jellyfin::Support::fromJsonValue(source["RefreshStatus"]); } QJsonObject VirtualFolderInfo::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Locations"] = toJsonValue(m_locations); - result["CollectionType"] = toJsonValue(m_collectionType); - result["LibraryOptions"] = toJsonValue>(m_libraryOptions); - result["ItemId"] = toJsonValue(m_itemId); - result["PrimaryImageItemId"] = toJsonValue(m_primaryImageItemId); - result["RefreshProgress"] = toJsonValue(m_refreshProgress); - result["RefreshStatus"] = toJsonValue(m_refreshStatus); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Locations"] = Jellyfin::Support::toJsonValue(m_locations); + result["CollectionType"] = Jellyfin::Support::toJsonValue(m_collectionType); + result["LibraryOptions"] = Jellyfin::Support::toJsonValue>(m_libraryOptions); + result["ItemId"] = Jellyfin::Support::toJsonValue(m_itemId); + result["PrimaryImageItemId"] = Jellyfin::Support::toJsonValue(m_primaryImageItemId); + result["RefreshProgress"] = Jellyfin::Support::toJsonValue(m_refreshProgress); + result["RefreshStatus"] = Jellyfin::Support::toJsonValue(m_refreshStatus); return result; } @@ -107,6 +108,17 @@ void VirtualFolderInfo::setRefreshStatus(QString newRefreshStatus) { m_refreshStatus = newRefreshStatus; } +} // NS DTO + +namespace Support { + +using VirtualFolderInfo = Jellyfin::DTO::VirtualFolderInfo; + +template <> +VirtualFolderInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return VirtualFolderInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/wakeonlaninfo.cpp b/core/src/DTO/wakeonlaninfo.cpp index 25cd8bd..ff6f85a 100644 --- a/core/src/DTO/wakeonlaninfo.cpp +++ b/core/src/DTO/wakeonlaninfo.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -WakeOnLanInfo::WakeOnLanInfo(QObject *parent) {} +WakeOnLanInfo::WakeOnLanInfo() {} -WakeOnLanInfo WakeOnLanInfo::fromJson(QJsonObject source) {WakeOnLanInfo instance; - instance->setFromJson(source, false); +WakeOnLanInfo WakeOnLanInfo::fromJson(QJsonObject source) { + WakeOnLanInfo instance; + instance.setFromJson(source); return instance; } void WakeOnLanInfo::setFromJson(QJsonObject source) { - m_macAddress = fromJsonValue(source["MacAddress"]); - m_port = fromJsonValue(source["Port"]); + m_macAddress = Jellyfin::Support::fromJsonValue(source["MacAddress"]); + m_port = Jellyfin::Support::fromJsonValue(source["Port"]); } QJsonObject WakeOnLanInfo::toJson() { QJsonObject result; - result["MacAddress"] = toJsonValue(m_macAddress); - result["Port"] = toJsonValue(m_port); + result["MacAddress"] = Jellyfin::Support::toJsonValue(m_macAddress); + result["Port"] = Jellyfin::Support::toJsonValue(m_port); return result; } @@ -65,6 +66,17 @@ void WakeOnLanInfo::setPort(qint32 newPort) { m_port = newPort; } +} // NS DTO + +namespace Support { + +using WakeOnLanInfo = Jellyfin::DTO::WakeOnLanInfo; + +template <> +WakeOnLanInfo fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return WakeOnLanInfo::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/DTO/xmlattribute.cpp b/core/src/DTO/xmlattribute.cpp index b086577..b7c3ae9 100644 --- a/core/src/DTO/xmlattribute.cpp +++ b/core/src/DTO/xmlattribute.cpp @@ -32,24 +32,25 @@ namespace Jellyfin { namespace DTO { -XmlAttribute::XmlAttribute(QObject *parent) {} +XmlAttribute::XmlAttribute() {} -XmlAttribute XmlAttribute::fromJson(QJsonObject source) {XmlAttribute instance; - instance->setFromJson(source, false); +XmlAttribute XmlAttribute::fromJson(QJsonObject source) { + XmlAttribute instance; + instance.setFromJson(source); return instance; } void XmlAttribute::setFromJson(QJsonObject source) { - m_name = fromJsonValue(source["Name"]); - m_value = fromJsonValue(source["Value"]); + m_name = Jellyfin::Support::fromJsonValue(source["Name"]); + m_value = Jellyfin::Support::fromJsonValue(source["Value"]); } QJsonObject XmlAttribute::toJson() { QJsonObject result; - result["Name"] = toJsonValue(m_name); - result["Value"] = toJsonValue(m_value); + result["Name"] = Jellyfin::Support::toJsonValue(m_name); + result["Value"] = Jellyfin::Support::toJsonValue(m_value); return result; } @@ -65,6 +66,17 @@ void XmlAttribute::setValue(QString newValue) { m_value = newValue; } +} // NS DTO + +namespace Support { + +using XmlAttribute = Jellyfin::DTO::XmlAttribute; + +template <> +XmlAttribute fromJsonValue(const QJsonValue &source) { + if (!source.isObject()) throw new ParseException("Expected JSON Object"); + return XmlAttribute::fromJson(source.toObject()); +} } // NS Jellyfin } // NS DTO diff --git a/core/src/apimodel.cpp b/core/src/apimodel.cpp index 1893105..3aa820b 100644 --- a/core/src/apimodel.cpp +++ b/core/src/apimodel.cpp @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include "JellyfinQt/apimodel.h" -#include "JellyfinQt/DTO/item.h" +#include "JellyfinQt/DTO/baseitemdto.h" #include "JellyfinQt/DTO/useritemdatadto.h" #include "JellyfinQt/DTO/userdto.h" @@ -380,18 +380,18 @@ ItemModel::ItemModel(QString path, bool hasRecordFields, bool replaceUser, QObje void ItemModel::onUserDataChanged(const QString &itemId, DTO::UserData *userData) { int i = 0; - for (Item *val: m_array) { + /*for (DTO::BaseItemDto *val: m_array) { if (val->userData() != nullptr && val->jellyfinId() == itemId) { QModelIndex cell = this->index(i); // val->userData()->onUpdated(userData); this->dataChanged(cell, cell); } i++; - } + }*/ } void ItemModel::addQueryParameters(QUrlQuery &query) { - ApiModel::addQueryParameters(query); + ApiModel::addQueryParameters(query); if (!m_parentId.isEmpty()) { query.addQueryItem("ParentId", m_parentId); } diff --git a/core/src/model/item.cpp b/core/src/model/item.cpp new file mode 100644 index 0000000..3870609 --- /dev/null +++ b/core/src/model/item.cpp @@ -0,0 +1,10 @@ +#include "JellyfinQt/model/item.h" + +namespace Jellyfin { +namespace Model { + +Item::Item(QObject *parent) + : QObject(parent) {} + +} +} diff --git a/core/src/playbackmanager.cpp b/core/src/playbackmanager.cpp index 55defbf..8614e52 100644 --- a/core/src/playbackmanager.cpp +++ b/core/src/playbackmanager.cpp @@ -34,7 +34,7 @@ namespace DTO { PlaybackManager::PlaybackManager(QObject *parent) : QObject(parent), m_mediaPlayer1(new QMediaPlayer(this)), m_mediaPlayer2(new QMediaPlayer(this)), - m_item(new RemoteItem(this)){ + m_item(new Model::Item(this)){ // Set up connections. swapMediaPlayer(); m_updateTimer.setInterval(10000); // 10 seconds @@ -43,16 +43,18 @@ PlaybackManager::PlaybackManager(QObject *parent) } void PlaybackManager::setApiClient(ApiClient *apiClient) { - m_item->setApiClient(apiClient); + //m_item->setApiClient(apiClient); } -void PlaybackManager::fetchStreamUrl(const Item *item, bool autoOpen, const FetchCallback &callback) { +void PlaybackManager::fetchStreamUrl(const Model::Item *item, bool autoOpen, const FetchCallback &callback) { if (item == nullptr || m_apiClient == nullptr) { qDebug() << "Item or apiClient not set"; + return; } + QString itemId(Support::uuidToString(item->jellyfinId())); m_resumePosition = 0; if (m_resumePlayback && !item->property("userData").isNull()) { - UserData* userData = m_item->data()->userData(); + QSharedPointer userData = m_item->data()->userData(); if (userData != nullptr) { m_resumePosition = userData->playbackPositionTicks(); } @@ -62,15 +64,15 @@ void PlaybackManager::fetchStreamUrl(const Item *item, bool autoOpen, const Fetc params.addQueryItem("StartTimeTicks", QString::number(m_resumePosition)); params.addQueryItem("IsPlayback", "true"); params.addQueryItem("AutoOpenLiveStream", autoOpen? "true" : "false"); - params.addQueryItem("MediaSourceId", item->jellyfinId()); + params.addQueryItem("MediaSourceId", itemId); params.addQueryItem("SubtitleStreamIndex", QString::number(m_subtitleIndex)); params.addQueryItem("AudioStreamIndex", QString::number(m_audioIndex)); QJsonObject root; root["DeviceProfile"] = m_apiClient->playbackDeviceProfile(); - QNetworkReply *rep = m_apiClient->post("/Items/" + item->jellyfinId() + "/PlaybackInfo", QJsonDocument(root), params); - connect(rep, &QNetworkReply::finished, this, [this, rep, callback]() { + QNetworkReply *rep = m_apiClient->post("/Items/" + itemId + "/PlaybackInfo", QJsonDocument(root), params); + connect(rep, &QNetworkReply::finished, this, [this, rep, callback, itemId]() { QJsonObject root = QJsonDocument::fromJson(rep->readAll()).object(); this->m_playSessionId = root["PlaySessionId"].toString(); qDebug() << "Session id: " << this->m_playSessionId; @@ -93,7 +95,7 @@ void PlaybackManager::fetchStreamUrl(const Item *item, bool autoOpen, const Fetc } else if (m_item->data()->mediaType() == "Video") { mediaType = "Videos"; } - QString streamUrl = this->m_apiClient->baseUrl() + "/" + mediaType + "/" + m_item->jellyfinId() + "/stream." + QString streamUrl = this->m_apiClient->baseUrl() + "/" + mediaType + "/" + itemId + "/stream." + firstMediaSource["Container"].toString() + "?" + query.toString(QUrl::EncodeReserved); callback(QUrl(streamUrl), DirectPlay); } else if (firstMediaSource["SupportsTranscoding"].toBool() && !firstMediaSource["TranscodingUrl"].isNull()) { @@ -111,9 +113,9 @@ void PlaybackManager::fetchStreamUrl(const Item *item, bool autoOpen, const Fetc }); } -void PlaybackManager::fetchAndSetStreamUrl(const Item *item) { +void PlaybackManager::fetchAndSetStreamUrl(const Model::Item *item) { fetchStreamUrl(item, m_autoOpen, [this, item](QUrl &&url, PlayMethod playbackMethod) { - if (m_item->data() == item) { + if (m_item == item) { setStreamUrl(url.toString()); m_playMethod = playbackMethod; emit playMethodChanged(m_playMethod); @@ -124,11 +126,11 @@ void PlaybackManager::fetchAndSetStreamUrl(const Item *item) { } -void PlaybackManager::setItem(Item *newItem) { +void PlaybackManager::setItem(Model::Item *newItem) { if (m_mediaPlayer != nullptr) m_mediaPlayer->stop(); - this->m_item->setData(newItem); - emit itemChanged(newItem); + this->m_item = newItem; + //emit itemChanged(newItem); if (m_apiClient == nullptr) { qWarning() << "apiClient is not set on this MediaSource instance! Aborting."; @@ -137,13 +139,7 @@ void PlaybackManager::setItem(Item *newItem) { // Deinitialize the streamUrl setStreamUrl(""); if (newItem != nullptr) { - if (m_item->status() == RemoteDataBase::Ready) { - fetchAndSetStreamUrl(m_item->data()); - } else { - connect(m_item, &RemoteDataBase::ready, [this]() -> void { - fetchAndSetStreamUrl(m_item->data()); - }); - } + fetchAndSetStreamUrl(newItem); } } @@ -214,17 +210,17 @@ void PlaybackManager::updatePlaybackInfo() { } void PlaybackManager::playItem(const QString &itemId) { - RemoteItem *newItem = new RemoteItem(itemId, m_apiClient, this); + Q_UNUSED(itemId) + Q_UNIMPLEMENTED(); + /*RemoteItem *newItem = new RemoteItem(itemId, m_apiClient, this); ItemModel *queue = new UserItemModel(this); setQueue(queue); - connect(newItem, &RemoteItem::ready, this, [this, queue, newItem](){ - QString parentId = newItem->data()->parentId(); - queue->setParentId(parentId); - queue->setLimit(10000); - queue->setApiClient(m_apiClient); - queue->reload(); - setItem(newItem->data()); - }); + QString parentId = newItem->data()->parentId(); + queue->setParentId(parentId); + queue->setLimit(10000); + queue->setApiClient(m_apiClient); + queue->reload(); + setItem(newItem->data()); connect(queue, &BaseApiModel::ready, this, [this, queue, newItem]() { for (int i = 0; i < queue->size(); i++) { if (queue->at(i)->jellyfinId() == newItem->jellyfinId()) { @@ -233,7 +229,7 @@ void PlaybackManager::playItem(const QString &itemId) { break; } } - }); + });*/ setPlaybackState(QMediaPlayer::PlayingState); } @@ -242,7 +238,7 @@ void PlaybackManager::playItemInList(ItemModel *playlist, int itemIdx) { setQueue(playlist); m_queueIndex = itemIdx; emit queueIndexChanged(m_queueIndex); - setItem(playlist->at(itemIdx)); + //setItem(playlist->at(itemIdx)); } void PlaybackManager::next() { @@ -261,7 +257,7 @@ void PlaybackManager::postPlaybackInfo(PlaybackInfoType type) { qWarning() << "Item is null. Not posting playback info"; return; } - root["ItemId"] = m_item->jellyfinId(); + root["ItemId"] = Support::uuidToString(m_item->jellyfinId()); root["SessionId"] = m_playSessionId; switch(type) { @@ -328,11 +324,11 @@ void PlaybackManager::swapMediaPlayer() { connect(m_mediaPlayer, SIGNAL(error(QMediaPlayer::error)), this, SLOT(mediaPlayerError(QmediaPlayer::error))); } -Item *PlaybackManager::nextItem() { +Model::Item *PlaybackManager::nextItem() { if (m_queue == nullptr) return nullptr; // TODO: shuffle etc. if (m_queueIndex < m_queue->size()) { - return m_queue->at(m_queueIndex + 1); + //return m_queue->at(m_queueIndex + 1); } return nullptr; } @@ -353,13 +349,7 @@ void PlaybackManager::componentComplete() { if (m_apiClient == nullptr) qWarning() << "No ApiClient set for PlaybackManager"; m_qmlIsParsingComponent = false; if (m_item != nullptr) { - if (m_item->status() == RemoteItem::Ready) { - fetchAndSetStreamUrl(m_item->data()); - } else { - connect(m_item, &RemoteItem::ready, [this]() -> void { - fetchAndSetStreamUrl(m_item->data()); - }); - } + fetchAndSetStreamUrl(m_item); } } diff --git a/core/src/remotedata.cpp b/core/src/remotedata.cpp index 47309eb..8e53ed4 100644 --- a/core/src/remotedata.cpp +++ b/core/src/remotedata.cpp @@ -286,19 +286,19 @@ void RemoteDataBase::reload() { } -RemoteItem::RemoteItem(QObject *parent) +/*RemoteItem::RemoteItem(QObject *parent) : RemoteData(parent) { } RemoteItem::RemoteItem(QString itemId, ApiClient *apiClient, QObject *parent) - : RemoteData(parent) { - m_data = new BaseItemDto(this); + : RemoteData(parent) {*/ + /*m_data = new BaseItemDto(this); m_data->setJellyfinId(itemId); m_apiClient = apiClient; - connect(m_data, &BaseItemDto::jellyfinIdChanged, this, &RemoteItem::jellyfinIdChanged); -} + connect(m_data, &BaseItemDto::jellyfinIdChanged, this, &RemoteItem::jellyfinIdChanged);*/ +//} void registerRemoteTypes(const char *uri) { - qmlRegisterUncreatableType(uri, 1, 0, "JellyfinItem", "Please use RemoteItem instead"); - qmlRegisterType(uri, 1, 0, "JellyfinItem"); + //qmlRegisterUncreatableType(uri, 1, 0, "JellyfinItem", "Please use RemoteItem instead"); + //qmlRegisterType(uri, 1, 0, "JellyfinItem"); } } // NS Jellyfin diff --git a/core/src/support/jsonconv.cpp b/core/src/support/jsonconv.cpp new file mode 100644 index 0000000..b2ed1e9 --- /dev/null +++ b/core/src/support/jsonconv.cpp @@ -0,0 +1,108 @@ +#include "JellyfinQt/support/jsonconv.h" + +namespace Jellyfin { +namespace Support { + + +QString uuidToString(const QUuid &source) { + QString str = source.toString(); + // Convert {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} (length: 38) + // to xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (lenght: 32) + return QString(str.mid(1, 8) + str.mid(10, 4) + str.mid(15, 4) + str.mid(20, 4) + str.mid(25 + 12)); +} +QUuid stringToUuid(const QString &source) { + if (source.size() != 32) throw new ParseException("Error while trying to parse JSON value as QUid: invalid length"); + // Convert xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (length: 32) + // to {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} (length: 38) + QString qtParseableString; + qtParseableString.reserve(38); + qtParseableString += QStringLiteral("{") + + source.mid(0, 8) + + QStringLiteral("-") + + source.mid(8, 4) + + QStringLiteral("-") + + source.mid(12, 4) + + QStringLiteral("-") + + source.mid(16, 4) + + QStringLiteral("-") + + source.mid(20, 12) + + QStringLiteral("}"); + return QUuid(qtParseableString); +} + +// Trivial converters for built-in classes and simple types + +// int +template <> +int fromJsonValue(const QJsonValue &source) { + if (!source.isDouble()) throw new ParseException("Error while trying to parse JSON value as integer: not an integer"); + return source.toInt(); +} + +template <> +QJsonValue toJsonValue(const int &source) { + return QJsonValue(source); +} + +// bool +template <> +bool fromJsonValue(const QJsonValue &source) { + if (!source.isBool()) throw new ParseException("Error while trying to parse JSON value as boolean: not a boolean"); + return source.toBool(); +} + +template <> +QJsonValue toJsonValue(const bool &source) { + return QJsonValue(source); +} + +// QString +template <> +QString fromJsonValue(const QJsonValue &source) { + if (!source.isString()) throw new ParseException("Error while trying to parse JSON value as string: not a string"); + return source.toString(); +} + +template <> +QJsonValue toJsonValue(const QString &source) { + return QJsonValue(source); +} + +// Double +template <> +double fromJsonValue(const QJsonValue &source) { + if (!source.isDouble()) throw new ParseException("Error while trying to parse JSON value as integer: not a double"); + return source.toDouble(); +} + +template <> +QJsonValue toJsonValue(const double &source) { + return QJsonValue(source); +} + +// QDateTime +template <> +QDateTime fromJsonValue(const QJsonValue &source) { + if (!source.isString()) throw new ParseException("Error while trying to parse JSON value as DateTime: not a string"); + return QDateTime::fromString(source.toString(), Qt::ISODateWithMs); +} + +template <> +QJsonValue toJsonValue(const QDateTime &source) { + return QJsonValue(source.toString(Qt::ISODateWithMs)); +} + +// QUuid +template <> +QUuid fromJsonValue(const QJsonValue &source) { + if (!source.isString()) throw new ParseException("Error while trying to parse JSON value as QUuid: not a string"); + return stringToUuid(source.toString()); +} + +template <> +QJsonValue toJsonValue(const QUuid &source) { + return uuidToString(source); +} + +} // NS Support +} // NS Jellyfin diff --git a/core/src/websocket.cpp b/core/src/websocket.cpp index 9e494a7..451f1ec 100644 --- a/core/src/websocket.cpp +++ b/core/src/websocket.cpp @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include "JellyfinQt/websocket.h" -#include +#include namespace Jellyfin { WebSocket::WebSocket(ApiClient *client) @@ -105,9 +105,8 @@ void WebSocket::textMessageReceived(const QString &message) { } QJsonArray userDataList = data2["UserDataList"].toArray(); for (QJsonValue val: userDataList) { - UserData* userData = UserItemDataDto::fromJSON(val.toObject(), this); - m_apiClient->onUserDataChanged(userData->itemId(), userData); - userData->deleteLater(); + UserItemDataDto userData = UserItemDataDto::fromJson(val.toObject()); + //m_apiClient->onUserDataChanged(userData->itemId(), userData); } }