Permalink
Browse files

Merge pull request #4877 from anaconda/python-onclean

[python] Monitor: add onCleanStarted/onCleanFinished callbacks.
  • Loading branch information...
2 parents ce9b5d9 + 67a002d commit 21c69ba28431b6afd7f169a1f9ae298b8a609a2d @MartijnKaijser MartijnKaijser committed Aug 2, 2014
View
2 addons/xbmc.python/addon.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<addon id="xbmc.python" version="2.16.0" provider-name="Team XBMC">
+<addon id="xbmc.python" version="2.17.0" provider-name="Team XBMC">
<backwards-compatibility abi="2.1.0"/>
<requires>
<import addon="xbmc.core" version="0.1.0"/>
View
20 xbmc/interfaces/legacy/Monitor.h
@@ -56,6 +56,8 @@ namespace XBMCAddon
invokeCallback(new CallbackFunction<Monitor,const String>(this,&Monitor::onScanFinished,library));
invokeCallback(new CallbackFunction<Monitor,const String>(this,&Monitor::onDatabaseUpdated,library));
}
+ inline void OnCleanStarted(const String &library) { XBMC_TRACE; invokeCallback(new CallbackFunction<Monitor,const String>(this,&Monitor::onCleanStarted,library)); }
+ inline void OnCleanFinished(const String &library) { XBMC_TRACE; invokeCallback(new CallbackFunction<Monitor,const String>(this,&Monitor::onCleanFinished,library)); }
inline void OnAbortRequested() { XBMC_TRACE; invokeCallback(new CallbackFunction<Monitor>(this,&Monitor::onAbortRequested)); }
inline void OnNotification(const String &sender, const String &method, const String &data) { XBMC_TRACE; invokeCallback(new CallbackFunction<Monitor,const String,const String,const String>(this,&Monitor::onNotification,sender,method,data)); }
@@ -126,6 +128,24 @@ namespace XBMCAddon
virtual void onDatabaseUpdated(const String database) { XBMC_TRACE; }
/**
+ * onCleanStarted(library) -- onCleanStarted method.\n
+ * \n
+ * library : video/music as string\n
+ * \n
+ * Will be called when library clean has started and return video or music to indicate which library is being cleaned\n
+ */
+ virtual void onCleanStarted(const String library) { XBMC_TRACE; }
+
+ /**
+ * onCleanFinished(library) -- onCleanFinished method.\n
+ * \n
+ * library : video/music as string\n
+ * \n
+ * Will be called when library clean has ended and return video or music to indicate which library has been cleaned\n
+ */
+ virtual void onCleanFinished(const String library) { XBMC_TRACE; }
+
+ /**
* onAbortRequested() -- onAbortRequested method.\n
* \n
* Will be called when XBMC requests Abort\n
View
2 xbmc/interfaces/python/PythonSwig.cpp.template
@@ -824,7 +824,7 @@ namespace PythonBindings
// constants
PyModule_AddStringConstant(module, (char*)"__author__", (char*)"Team XBMC <http://xbmc.org>");
PyModule_AddStringConstant(module, (char*)"__date__", (char*)"${new Date().toString()}");
- PyModule_AddStringConstant(module, (char*)"__version__", (char*)"2.16.0");
+ PyModule_AddStringConstant(module, (char*)"__version__", (char*)"2.17.0");
PyModule_AddStringConstant(module, (char*)"__credits__", (char*)"Team XBMC");
PyModule_AddStringConstant(module, (char*)"__platform__", (char*)"ALL");
View
30 xbmc/interfaces/python/XBPython.cpp
@@ -94,13 +94,21 @@ void XBPython::Announce(AnnouncementFlag flag, const char *sender, const char *m
OnScanFinished("video");
else if (strcmp(message, "OnScanStarted") == 0)
OnScanStarted("video");
+ else if (strcmp(message, "OnCleanStarted") == 0)
+ OnCleanStarted("video");
+ else if (strcmp(message, "OnCleanFinished") == 0)
+ OnCleanFinished("video");
}
else if (flag & AudioLibrary)
{
if (strcmp(message, "OnScanFinished") == 0)
OnScanFinished("music");
else if (strcmp(message, "OnScanStarted") == 0)
OnScanStarted("music");
+ else if (strcmp(message, "OnCleanStarted") == 0)
+ OnCleanStarted("music");
+ else if (strcmp(message, "OnCleanFinished") == 0)
+ OnCleanFinished("music");
}
else if (flag & GUI)
{
@@ -350,6 +358,28 @@ void XBPython::OnScanFinished(const std::string &library)
}
}
+void XBPython::OnCleanStarted(const std::string &library)
+{
+ XBMC_TRACE;
+ LOCK_AND_COPY(std::vector<XBMCAddon::xbmc::Monitor*>,tmp,m_vecMonitorCallbackList);
+ for (MonitorCallbackList::iterator it = tmp.begin(); (it != tmp.end()); ++it)
+ {
+ if (CHECK_FOR_ENTRY(m_vecMonitorCallbackList,(*it)))
+ (*it)->OnCleanStarted(library);
+ }
+}
+
+void XBPython::OnCleanFinished(const std::string &library)
+{
+ XBMC_TRACE;
+ LOCK_AND_COPY(std::vector<XBMCAddon::xbmc::Monitor*>,tmp,m_vecMonitorCallbackList);
+ for (MonitorCallbackList::iterator it = tmp.begin(); (it != tmp.end()); ++it)
+ {
+ if (CHECK_FOR_ENTRY(m_vecMonitorCallbackList,(*it)))
+ (*it)->OnCleanFinished(library);
+ }
+}
+
void XBPython::OnAbortRequested(const std::string &ID)
{
XBMC_TRACE;
View
2 xbmc/interfaces/python/XBPython.h
@@ -87,6 +87,8 @@ class XBPython :
void OnDPMSDeactivated();
void OnScanStarted(const std::string &library);
void OnScanFinished(const std::string &library);
+ void OnCleanStarted(const std::string &library);
+ void OnCleanFinished(const std::string &library);
void OnAbortRequested(const std::string &ID="");
void OnNotification(const std::string &sender, const std::string &method, const std::string &data);

0 comments on commit 21c69ba

Please sign in to comment.