Skip to content

Commit

Permalink
jsonrpc: force media item refresh after changing an item's details (f…
Browse files Browse the repository at this point in the history
…ixes #13173)
  • Loading branch information
Montellese committed Oct 12, 2012
1 parent 0ff0d2e commit cb3bcfc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions xbmc/interfaces/json-rpc/AudioLibrary.cpp
Expand Up @@ -390,6 +390,7 @@ JSONRPC_STATUS CAudioLibrary::SetArtistDetails(const CStdString &method, ITransp
if (musicdatabase.SetArtistInfo(id, artist) <= 0)
return InternalError;

CJSONRPCUtils::NotifyItemUpdated();
return ACK;
}

Expand Down Expand Up @@ -432,6 +433,7 @@ JSONRPC_STATUS CAudioLibrary::SetAlbumDetails(const CStdString &method, ITranspo
if (musicdatabase.SetAlbumInfo(id, album, songs) <= 0)
return InternalError;

CJSONRPCUtils::NotifyItemUpdated();
return ACK;
}

Expand Down Expand Up @@ -481,6 +483,7 @@ JSONRPC_STATUS CAudioLibrary::SetSongDetails(const CStdString &method, ITranspor
if (musicdatabase.UpdateSong(song, id) <= 0)
return InternalError;

CJSONRPCUtils::NotifyItemUpdated();
return ACK;
}

Expand Down
12 changes: 12 additions & 0 deletions xbmc/interfaces/json-rpc/JSONRPCUtils.h
Expand Up @@ -21,6 +21,9 @@

#include "IClient.h"
#include "ITransportLayer.h"
#include "FileItem.h"
#include "GUIUserMessages.h"
#include "guilib/GUIWindowManager.h"
#include "interfaces/IAnnouncer.h"
#include "utils/StdString.h"
#include "utils/Variant.h"
Expand Down Expand Up @@ -155,4 +158,13 @@ namespace JSONRPC

return ReadData;
}

class CJSONRPCUtils
{
public:
static inline void NotifyItemUpdated()
{
g_windowManager.SendThreadMessage(CGUIMessage(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_UPDATE, g_windowManager.GetActiveWindow()));

This comment has been minimized.

Copy link
@pieh

pieh Oct 14, 2012

Contributor

Isn't it a little heavy and shouldn't we send GUI_MSG_UPDATE_ITEM to update single item? Worst case scenario, addon that updates each item's details (f.e. logo downloader) that will update details of f.e. 500 movies (will cause xbmc to 500 times update directory if we happen to be in media window)

This comment has been minimized.

Copy link
@Montellese

Montellese Oct 14, 2012

Author Member

Please read the discussion in the PR which covers this.

}
};
}
6 changes: 6 additions & 0 deletions xbmc/interfaces/json-rpc/VideoLibrary.cpp
Expand Up @@ -507,6 +507,7 @@ JSONRPC_STATUS CVideoLibrary::SetMovieDetails(const CStdString &method, ITranspo
videodatabase.SetPlayCount(CFileItem(infos), newPlaycount, infos.m_lastPlayed.IsValid() ? infos.m_lastPlayed : CDateTime::GetCurrentDateTime());
}

CJSONRPCUtils::NotifyItemUpdated();
return ACK;
}

Expand Down Expand Up @@ -544,6 +545,7 @@ JSONRPC_STATUS CVideoLibrary::SetTVShowDetails(const CStdString &method, ITransp
videodatabase.SetPlayCount(CFileItem(infos), newPlaycount, infos.m_lastPlayed.IsValid() ? infos.m_lastPlayed : CDateTime::GetCurrentDateTime());
}

CJSONRPCUtils::NotifyItemUpdated();
return ACK;
}

Expand Down Expand Up @@ -589,6 +591,7 @@ JSONRPC_STATUS CVideoLibrary::SetEpisodeDetails(const CStdString &method, ITrans
videodatabase.SetPlayCount(CFileItem(infos), newPlaycount, infos.m_lastPlayed.IsValid() ? infos.m_lastPlayed : CDateTime::GetCurrentDateTime());
}

CJSONRPCUtils::NotifyItemUpdated();
return ACK;
}

Expand Down Expand Up @@ -627,6 +630,7 @@ JSONRPC_STATUS CVideoLibrary::SetMusicVideoDetails(const CStdString &method, ITr
videodatabase.SetPlayCount(CFileItem(infos), newPlaycount, infos.m_lastPlayed.IsValid() ? infos.m_lastPlayed : CDateTime::GetCurrentDateTime());
}

CJSONRPCUtils::NotifyItemUpdated();
return ACK;
}

Expand Down Expand Up @@ -860,6 +864,8 @@ JSONRPC_STATUS CVideoLibrary::RemoveVideo(const CVariant &parameterObject)
videodatabase.DeleteEpisode((int)parameterObject["episodeid"].asInteger());
else if (parameterObject.isMember("musicvideoid"))
videodatabase.DeleteMusicVideo((int)parameterObject["musicvideoid"].asInteger());

CJSONRPCUtils::NotifyItemUpdated();
return ACK;
}

Expand Down

0 comments on commit cb3bcfc

Please sign in to comment.