diff options
author | jmarshallnz <jcmarsha@gmail.com> | 2014-03-13 14:23:21 +1300 |
---|---|---|
committer | jmarshallnz <jcmarsha@gmail.com> | 2014-03-13 14:23:21 +1300 |
commit | b3391ee35251597d5d99ea22aae020d833148f9b (patch) | |
tree | 058426f5266b36d49ce47102d8dcd1ae5a4464bc | |
parent | 6888884bfa6ac71e7d05e57792bb2a58187da232 (diff) | |
parent | 8e13e8fdbd79e330f9e25bc60a2cc7c64b3088ea (diff) |
Merge pull request #4405 from Montellese/jsonrpc_fix_datetime_reset
JSON-RPC: fix resetting a datetime property through VideoLibrary.SetFooDetails
-rw-r--r-- | xbmc/interfaces/json-rpc/JSONUtils.h | 23 | ||||
-rw-r--r-- | xbmc/interfaces/json-rpc/VideoLibrary.cpp | 23 |
2 files changed, 29 insertions, 17 deletions
diff --git a/xbmc/interfaces/json-rpc/JSONUtils.h b/xbmc/interfaces/json-rpc/JSONUtils.h index 6565775ef3..5c8165c24d 100644 --- a/xbmc/interfaces/json-rpc/JSONUtils.h +++ b/xbmc/interfaces/json-rpc/JSONUtils.h @@ -23,6 +23,7 @@ #include <stdlib.h> #include "JSONRPCUtils.h" +#include "XBDateTime.h" #include "utils/SortUtils.h" #include "interfaces/IAnnouncer.h" #include "playlists/SmartPlayList.h" @@ -519,6 +520,28 @@ namespace JSONRPC stringArray.push_back(it->asString()); } + static void SetFromDBDate(const CVariant &jsonDate, CDateTime &date) + { + if (!jsonDate.isString()) + return; + + if (jsonDate.empty()) + date.Reset(); + else + date.SetFromDBDate(jsonDate.asString()); + } + + static void SetFromDBDateTime(const CVariant &jsonDate, CDateTime &date) + { + if (!jsonDate.isString()) + return; + + if (jsonDate.empty()) + date.Reset(); + else + date.SetFromDBDateTime(jsonDate.asString()); + } + static bool GetXspFiltering(const CStdString &type, const CVariant &filter, CStdString &xsp) { if (type.empty() || !filter.isObject()) diff --git a/xbmc/interfaces/json-rpc/VideoLibrary.cpp b/xbmc/interfaces/json-rpc/VideoLibrary.cpp index fdb1633716..36578a6b87 100644 --- a/xbmc/interfaces/json-rpc/VideoLibrary.cpp +++ b/xbmc/interfaces/json-rpc/VideoLibrary.cpp @@ -507,7 +507,7 @@ JSONRPC_STATUS CVideoLibrary::SetMovieDetails(const CStdString &method, ITranspo // restore original playcount or the new one won't be announced int newPlaycount = infos.m_playCount; infos.m_playCount = playcount; - videodatabase.SetPlayCount(CFileItem(infos), newPlaycount, infos.m_lastPlayed.IsValid() ? infos.m_lastPlayed : CDateTime::GetCurrentDateTime()); + videodatabase.SetPlayCount(CFileItem(infos), newPlaycount, infos.m_lastPlayed); } UpdateResumePoint(parameterObject, infos, videodatabase); @@ -568,9 +568,6 @@ JSONRPC_STATUS CVideoLibrary::SetTVShowDetails(const CStdString &method, ITransp std::map<int, std::map<std::string, std::string> > seasonArt; videodatabase.GetTvShowSeasonArt(infos.m_iDbId, seasonArt); - int playcount = infos.m_playCount; - CDateTime lastPlayed = infos.m_lastPlayed; - std::set<std::string> removedArtwork; UpdateVideoTag(parameterObject, infos, artwork, removedArtwork); @@ -584,14 +581,6 @@ JSONRPC_STATUS CVideoLibrary::SetTVShowDetails(const CStdString &method, ITransp if (!videodatabase.RemoveArtForItem(infos.m_iDbId, "tvshow", removedArtwork)) return InternalError; - if (playcount != infos.m_playCount || lastPlayed != infos.m_lastPlayed) - { - // restore original playcount or the new one won't be announced - int newPlaycount = infos.m_playCount; - infos.m_playCount = playcount; - videodatabase.SetPlayCount(CFileItem(infos), newPlaycount, infos.m_lastPlayed.IsValid() ? infos.m_lastPlayed : CDateTime::GetCurrentDateTime()); - } - CJSONRPCUtils::NotifyItemUpdated(); return ACK; } @@ -673,7 +662,7 @@ JSONRPC_STATUS CVideoLibrary::SetEpisodeDetails(const CStdString &method, ITrans // restore original playcount or the new one won't be announced int newPlaycount = infos.m_playCount; infos.m_playCount = playcount; - videodatabase.SetPlayCount(CFileItem(infos), newPlaycount, infos.m_lastPlayed.IsValid() ? infos.m_lastPlayed : CDateTime::GetCurrentDateTime()); + videodatabase.SetPlayCount(CFileItem(infos), newPlaycount, infos.m_lastPlayed); } UpdateResumePoint(parameterObject, infos, videodatabase); @@ -723,7 +712,7 @@ JSONRPC_STATUS CVideoLibrary::SetMusicVideoDetails(const CStdString &method, ITr // restore original playcount or the new one won't be announced int newPlaycount = infos.m_playCount; infos.m_playCount = playcount; - videodatabase.SetPlayCount(CFileItem(infos), newPlaycount, infos.m_lastPlayed.IsValid() ? infos.m_lastPlayed : CDateTime::GetCurrentDateTime()); + videodatabase.SetPlayCount(CFileItem(infos), newPlaycount, infos.m_lastPlayed); } UpdateResumePoint(parameterObject, infos, videodatabase); @@ -1023,13 +1012,13 @@ void CVideoLibrary::UpdateVideoTag(const CVariant ¶meterObject, CVideoInfoTa if (ParameterNotNull(parameterObject, "imdbnumber")) details.m_strIMDBNumber = parameterObject["imdbnumber"].asString(); if (ParameterNotNull(parameterObject, "premiered")) - details.m_premiered.SetFromDBDate(parameterObject["premiered"].asString()); + SetFromDBDate(parameterObject["premiered"], details.m_premiered); if (ParameterNotNull(parameterObject, "votes")) details.m_strVotes = parameterObject["votes"].asString(); if (ParameterNotNull(parameterObject, "lastplayed")) - details.m_lastPlayed.SetFromDBDateTime(parameterObject["lastplayed"].asString()); + SetFromDBDateTime(parameterObject["lastplayed"], details.m_lastPlayed); if (ParameterNotNull(parameterObject, "firstaired")) - details.m_firstAired.SetFromDBDateTime(parameterObject["firstaired"].asString()); + SetFromDBDateTime(parameterObject["firstaired"], details.m_firstAired); if (ParameterNotNull(parameterObject, "productioncode")) details.m_strProductionCode = parameterObject["productioncode"].asString(); if (ParameterNotNull(parameterObject, "season")) |