Skip to content

Commit

Permalink
rpc: add OnScanStarted/Finished notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
alcoheca committed Nov 6, 2012
1 parent 108c19c commit 97ecfbf
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 13 deletions.
36 changes: 36 additions & 0 deletions xbmc/interfaces/json-rpc/ServiceDescription.h
Original file line number Diff line number Diff line change
Expand Up @@ -3267,6 +3267,24 @@ namespace JSONRPC
"],"
"\"returns\": null"
"}",
"\"AudioLibrary.OnCleanStarted\": {"
"\"type\": \"notification\","
"\"description\": \"An audio library clean operation has started.\","
"\"params\": ["
"{ \"name\": \"sender\", \"type\": \"string\", \"required\": true },"
"{ \"name\": \"data\", \"type\": \"null\", \"required\": true }"
"],"
"\"returns\": null"
"}",
"\"AudioLibrary.OnCleanFinished\": {"
"\"type\": \"notification\","
"\"description\": \"The audio library has been cleaned.\","
"\"params\": ["
"{ \"name\": \"sender\", \"type\": \"string\", \"required\": true },"
"{ \"name\": \"data\", \"type\": \"null\", \"required\": true }"
"],"
"\"returns\": null"
"}",
"\"VideoLibrary.OnUpdate\": {"
"\"type\": \"notification\","
"\"description\": \"A video item has been updated.\","
Expand Down Expand Up @@ -3314,6 +3332,24 @@ namespace JSONRPC
"],"
"\"returns\": null"
"}",
"\"VideoLibrary.OnCleanStarted\": {"
"\"type\": \"notification\","
"\"description\": \"A video library clean operation has started.\","
"\"params\": ["
"{ \"name\": \"sender\", \"type\": \"string\", \"required\": true },"
"{ \"name\": \"data\", \"type\": \"null\", \"required\": true }"
"],"
"\"returns\": null"
"}",
"\"VideoLibrary.OnCleanFinished\": {"
"\"type\": \"notification\","
"\"description\": \"The video library has been cleaned.\","
"\"params\": ["
"{ \"name\": \"sender\", \"type\": \"string\", \"required\": true },"
"{ \"name\": \"data\", \"type\": \"null\", \"required\": true }"
"],"
"\"returns\": null"
"}",
"\"System.OnQuit\": {"
"\"type\": \"notification\","
"\"description\": \"XBMC will be closed.\","
Expand Down
38 changes: 37 additions & 1 deletion xbmc/interfaces/json-rpc/notifications.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,24 @@
],
"returns": null
},
"AudioLibrary.OnCleanStarted": {
"type": "notification",
"description": "An audio library clean operation has started.",
"params": [
{ "name": "sender", "type": "string", "required": true },
{ "name": "data", "type": "null", "required": true }
],
"returns": null
},
"AudioLibrary.OnCleanFinished": {
"type": "notification",
"description": "The audio library has been cleaned.",
"params": [
{ "name": "sender", "type": "string", "required": true },
{ "name": "data", "type": "null", "required": true }
],
"returns": null
},
"VideoLibrary.OnUpdate": {
"type": "notification",
"description": "A video item has been updated.",
Expand Down Expand Up @@ -203,6 +221,24 @@
],
"returns": null
},
"VideoLibrary.OnCleanStarted": {
"type": "notification",
"description": "A video library clean operation has started.",
"params": [
{ "name": "sender", "type": "string", "required": true },
{ "name": "data", "type": "null", "required": true }
],
"returns": null
},
"VideoLibrary.OnCleanFinished": {
"type": "notification",
"description": "The video library has been cleaned.",
"params": [
{ "name": "sender", "type": "string", "required": true },
{ "name": "data", "type": "null", "required": true }
],
"returns": null
},
"System.OnQuit": {
"type": "notification",
"description": "XBMC will be closed.",
Expand Down Expand Up @@ -286,4 +322,4 @@
],
"returns": null
}
}
}
32 changes: 20 additions & 12 deletions xbmc/music/MusicDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2178,8 +2178,10 @@ int CMusicDatabase::Cleanup(CGUIDialogProgress *pDlgProgress)
if (NULL == m_pDB.get()) return ERROR_DATABASE;
if (NULL == m_pDS.get()) return ERROR_DATABASE;

int ret = ERROR_OK;
unsigned int time = XbmcThreads::SystemClockMillis();
CLog::Log(LOGNOTICE, "%s: Starting musicdatabase cleanup ..", __FUNCTION__);
ANNOUNCEMENT::CAnnouncementManager::Announce(ANNOUNCEMENT::AudioLibrary, "xbmc", "OnCleanStarted");

// first cleanup any songs with invalid paths
if (pDlgProgress)
Expand All @@ -2194,8 +2196,8 @@ int CMusicDatabase::Cleanup(CGUIDialogProgress *pDlgProgress)
}
if (!CleanupSongs())
{
RollbackTransaction();
return ERROR_REORG_SONGS;
ret = ERROR_REORG_SONGS;
goto error;
}
// then the albums that are not linked to a song or to albuminfo, or whose path is removed
if (pDlgProgress)
Expand All @@ -2206,8 +2208,8 @@ int CMusicDatabase::Cleanup(CGUIDialogProgress *pDlgProgress)
}
if (!CleanupAlbums())
{
RollbackTransaction();
return ERROR_REORG_ALBUM;
ret = ERROR_REORG_ALBUM;
goto error;
}
// now the paths
if (pDlgProgress)
Expand All @@ -2218,8 +2220,8 @@ int CMusicDatabase::Cleanup(CGUIDialogProgress *pDlgProgress)
}
if (!CleanupPaths())
{
RollbackTransaction();
return ERROR_REORG_PATH;
ret = ERROR_REORG_PATH;
goto error;
}
// and finally artists + genres
if (pDlgProgress)
Expand All @@ -2230,8 +2232,8 @@ int CMusicDatabase::Cleanup(CGUIDialogProgress *pDlgProgress)
}
if (!CleanupArtists())
{
RollbackTransaction();
return ERROR_REORG_ARTIST;
ret = ERROR_REORG_ARTIST;
goto error;
}
if (pDlgProgress)
{
Expand All @@ -2241,8 +2243,8 @@ int CMusicDatabase::Cleanup(CGUIDialogProgress *pDlgProgress)
}
if (!CleanupGenres())
{
RollbackTransaction();
return ERROR_REORG_GENRE;
ret = ERROR_REORG_GENRE;
goto error;
}
// commit transaction
if (pDlgProgress)
Expand All @@ -2253,8 +2255,8 @@ int CMusicDatabase::Cleanup(CGUIDialogProgress *pDlgProgress)
}
if (!CommitTransaction())
{
RollbackTransaction();
return ERROR_WRITING_CHANGES;
ret = ERROR_WRITING_CHANGES;
goto error;
}
// and compress the database
if (pDlgProgress)
Expand All @@ -2265,12 +2267,18 @@ int CMusicDatabase::Cleanup(CGUIDialogProgress *pDlgProgress)
}
time = XbmcThreads::SystemClockMillis() - time;
CLog::Log(LOGNOTICE, "%s: Cleaning musicdatabase done. Operation took %s", __FUNCTION__, StringUtils::SecondsToTimeString(time / 1000).c_str());
ANNOUNCEMENT::CAnnouncementManager::Announce(ANNOUNCEMENT::AudioLibrary, "xbmc", "OnCleanFinished");

if (!Compress(false))
{
return ERROR_COMPRESSING;
}
return ERROR_OK;

error:
RollbackTransaction();
ANNOUNCEMENT::CAnnouncementManager::Announce(ANNOUNCEMENT::AudioLibrary, "xbmc", "OnCleanFinished");
return ret;
}

void CMusicDatabase::DeleteAlbumInfo()
Expand Down
5 changes: 5 additions & 0 deletions xbmc/video/VideoDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7687,6 +7687,7 @@ void CVideoDatabase::CleanDatabase(CGUIDialogProgressBarHandle* handle, const se

unsigned int time = XbmcThreads::SystemClockMillis();
CLog::Log(LOGNOTICE, "%s: Starting videodatabase cleanup ..", __FUNCTION__);
ANNOUNCEMENT::CAnnouncementManager::Announce(ANNOUNCEMENT::VideoLibrary, "xbmc", "OnCleanStarted");

BeginTransaction();

Expand All @@ -7697,6 +7698,7 @@ void CVideoDatabase::CleanDatabase(CGUIDialogProgressBarHandle* handle, const se
if (paths->size() == 0)
{
RollbackTransaction();
ANNOUNCEMENT::CAnnouncementManager::Announce(ANNOUNCEMENT::VideoLibrary, "xbmc", "OnCleanFinished");
return;
}

Expand Down Expand Up @@ -7781,6 +7783,7 @@ void CVideoDatabase::CleanDatabase(CGUIDialogProgressBarHandle* handle, const se
{
progress->Close();
m_pDS->close();
ANNOUNCEMENT::CAnnouncementManager::Announce(ANNOUNCEMENT::VideoLibrary, "xbmc", "OnCleanFinished");
return;
}
}
Expand Down Expand Up @@ -8075,6 +8078,8 @@ void CVideoDatabase::CleanDatabase(CGUIDialogProgressBarHandle* handle, const se
}
if (progress)
progress->Close();

ANNOUNCEMENT::CAnnouncementManager::Announce(ANNOUNCEMENT::VideoLibrary, "xbmc", "OnCleanFinished");
}

void CVideoDatabase::DumpToDummyFiles(const CStdString &path)
Expand Down

0 comments on commit 97ecfbf

Please sign in to comment.