MLDBCallback.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #pragma once
  2. #include <api/syscb/callbacks/svccb.h>
  3. #include <api/syscb/api_syscb.h>
  4. #include "../ml_local/api_mldb.h"
  5. class MLDBCallback : public SysCallback
  6. {
  7. private:
  8. FOURCC GetEventType()
  9. {
  10. return api_mldb::SYSCALLBACK;
  11. }
  12. int notify(int msg, intptr_t param1, intptr_t param2)
  13. {
  14. const wchar_t *filename = (const wchar_t *)param1;
  15. switch (msg)
  16. {
  17. case api_mldb::MLDB_FILE_ADDED:
  18. OnFileAdded(filename);
  19. return 1;
  20. case api_mldb::MLDB_FILE_REMOVED_PRE:
  21. OnFileRemove_Pre(filename);
  22. return 1;
  23. case api_mldb::MLDB_FILE_REMOVED_POST:
  24. OnFileRemove_Post(filename);
  25. return 1;
  26. case api_mldb::MLDB_FILE_UPDATED:
  27. case api_mldb::MLDB_FILE_UPDATED_EXTERNAL:
  28. OnFileUpdated(filename, (msg == api_mldb::MLDB_FILE_UPDATED));
  29. return 1;
  30. case api_mldb::MLDB_FILE_PLAYED:
  31. OnFilePlayed(filename,
  32. ((api_mldb::played_info *)param2)->played,
  33. ((api_mldb::played_info *)param2)->count);
  34. return 1;
  35. case api_mldb::MLDB_CLEARED:
  36. OnCleared((const wchar_t **)param1, param2);
  37. return 1;
  38. case api_mldb::MLDB_FILE_GET_CLOUD_STATUS:
  39. {
  40. OnGetCloudStatus((const wchar_t *)param1, (HMENU *)param2);
  41. }
  42. return 1;
  43. case api_mldb::MLDB_FILE_PROCESS_CLOUD_STATUS:
  44. OnProcessCloudStatus(param1, (int *)param2);
  45. return 1;
  46. default:
  47. return 0;
  48. }
  49. }
  50. virtual void OnFileAdded(const wchar_t *filename) {}
  51. virtual void OnFileRemove_Pre(const wchar_t *filename) {}
  52. virtual void OnFileRemove_Post(const wchar_t *filename) {}
  53. virtual void OnFileUpdated(const wchar_t *filename, bool from_library) {}
  54. virtual void OnFilePlayed(const wchar_t *filename, time_t played, int count) {}
  55. virtual void OnCleared(const wchar_t **filenames, int count) {}
  56. virtual void OnGetCloudStatus(const wchar_t *filename, HMENU *menu) {}
  57. virtual void OnProcessCloudStatus(int menu_item, int *result) {}
  58. #define CBCLASS MLDBCallback
  59. START_DISPATCH_INLINE;
  60. CB(SYSCALLBACK_GETEVENTTYPE, GetEventType);
  61. CB(SYSCALLBACK_NOTIFY, notify);
  62. END_DISPATCH;
  63. #undef CBCLASS
  64. };