svc_itemmgr.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #ifndef _SVC_ITEMMGR_H
  2. #define _SVC_ITEMMGR_H
  3. #include <bfc/dispatch.h>
  4. #include <api/service/services.h>
  5. class NOVTABLE svc_itemMgr : public Dispatchable {
  6. public:
  7. static FOURCC getServiceType() { return WaSvc::ITEMMANAGER; }
  8. int isMine(const char *playstring) { return _call(ISMINE, 0, playstring); }
  9. int optimizePlaystring(char *playstring) {
  10. return _call(OPTIMIZEPLAYSTRING, 0, playstring);
  11. }
  12. int createInitialName(const char *playstring, char *buf, int buflen) {
  13. return _call(CREATEINITIALNAME, 0, playstring, buf, buflen);
  14. }
  15. int optimizeFileData(const char *playstring, const char *fieldname, int datatype, char *data, int datalen) {
  16. return _call(OPTIMIZEFILEDATA, -1, playstring, fieldname, datatype, data, datalen);
  17. }
  18. int onDatabaseAdd(const char *playstring) {
  19. return _call(ONDATABASEADD, 0, playstring);
  20. }
  21. int onDatabaseDel(const char *playstring) {
  22. return _call(ONDATABASEDEL, 0, playstring);
  23. }
  24. //return 1 if changed
  25. int onTitleChange(const char *playstring, const char *newtitle) {
  26. return _call(ONTITLECHANGE, 0, playstring, newtitle);
  27. }
  28. int onTitle2Change(const char *playstring, const char *newtitle) {
  29. return _call(ONTITLE2CHANGE, 0, playstring, newtitle);
  30. }
  31. void onNextFile(const char *playstring) {
  32. _voidcall(ONNEXTFILE, playstring);
  33. }
  34. void onFileComplete(const char *playstring) {
  35. _voidcall(ONFILECOMPLETE, playstring);
  36. }
  37. int wantScanData(const char *playstring) {
  38. return _call(WANTSCANDATA, 1, playstring);
  39. }
  40. int getSortOrder() {
  41. return _call(GETSORTORDER, 0);
  42. }
  43. enum {
  44. ISMINE=100,
  45. OPTIMIZEPLAYSTRING=200,
  46. OPTIMIZEFILEDATA=211, //210 retired
  47. CREATEINITIALNAME=300,
  48. ONDATABASEADD=400,
  49. ONDATABASEDEL=401,
  50. ONTITLECHANGE=600,
  51. ONTITLE2CHANGE=601,
  52. ONNEXTFILE=700,
  53. ONFILECOMPLETE=800,
  54. WANTSCANDATA=900,
  55. GETSORTORDER=1000,
  56. };
  57. };
  58. // derive from this one
  59. class NOVTABLE svc_itemMgrI : public svc_itemMgr {
  60. public:
  61. virtual int isMine(const char *playstring)=0;
  62. virtual int optimizePlaystring(char *playstring) { return 0; }
  63. virtual int createInitialName(const char *playstring, char *buf, int buflen) { return 0; }
  64. virtual int optimizeFileData(const char *playstring, const char *fieldname, int datatype, char *data, int datalen) { return -1; }
  65. virtual int onDatabaseAdd(const char *playstring) { return 0; }
  66. virtual int onDatabaseDel(const char *playstring) { return 0; }
  67. virtual int onTitleChange(const char *playstring, const char *newtitle) { return 0; }
  68. virtual int onTitle2Change(const char *playstring, const char *newtitle) { return 0; }
  69. virtual void onNextFile(const char *playstring) { }
  70. virtual void onFileComplete(const char *playstring) { }
  71. virtual int wantScanData(const char *playstring) { return 1; }
  72. virtual int getSortOrder() { return 0; }
  73. protected:
  74. RECVS_DISPATCH;
  75. };
  76. #include <bfc/named.h>
  77. #include <api/service/svc_enum.h>
  78. class ItemMgrEnum : private Named, public SvcEnumT<svc_itemMgr> {
  79. public:
  80. ItemMgrEnum(const char *ps) : Named(ps) { }
  81. void setPlaystring(const char *ps) { Named::setName(ps); }
  82. protected:
  83. virtual int testService(svc_itemMgr *svc) {
  84. return svc->isMine(getName());
  85. }
  86. };
  87. #include <api/service/servicei.h>
  88. template <class T>
  89. class ItemMgrCreator : public waServiceFactoryTSingle<svc_itemMgr, T> { };
  90. #endif