FeedBase.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #include "main.h"
  2. #include "FeedBase.h"
  3. #include <assert.h>
  4. void FeedBase::dependent_regViewer(api_dependentviewer *viewer, int add)
  5. {
  6. if (viewer)
  7. {
  8. if (add)
  9. {
  10. //if (!viewers.contains(viewer))
  11. if(viewers.end() == std::find(viewers.begin(), viewers.end(), viewer))
  12. {
  13. viewers.push_back(viewer);
  14. }
  15. }
  16. else
  17. {
  18. //viewers.eraseObject(viewer);
  19. auto it = std::find(viewers.begin(), viewers.end(), viewer);
  20. if (it != viewers.end())
  21. {
  22. viewers.erase(it);
  23. }
  24. }
  25. }
  26. }
  27. void *FeedBase::dependent_getInterface(const GUID *classguid)
  28. {
  29. HANDLEGETINTERFACE(svc_textFeed);
  30. return NULL;
  31. }
  32. api_dependent *FeedBase::getDependencyPtr()
  33. {
  34. return static_cast<api_dependent *>(this);
  35. }
  36. void FeedBase::CallViewers( const wchar_t *feedid, const wchar_t *text, size_t length )
  37. {
  38. for ( api_dependentviewer *l_viewer : viewers )
  39. l_viewer->dependentViewer_callback( static_cast<api_dependent *>( this ), svc_textFeed::depend_getClassGuid(), DependentCB::DEPCB_EVENT, Event_TEXTCHANGE, (intptr_t)feedid, (void *)text, length );
  40. }
  41. #ifdef CBCLASS
  42. #undef CBCLASS
  43. #endif
  44. #define CBCLASS FeedBase
  45. START_MULTIPATCH;
  46. START_PATCH(DependentPatch)
  47. M_VCB(DependentPatch, api_dependent, API_DEPENDENT_REGVIEWER, dependent_regViewer);
  48. M_CB(DependentPatch, api_dependent, API_DEPENDENT_GETINTERFACE, dependent_getInterface);
  49. NEXT_PATCH(TextFeedPatch)
  50. M_CB(TextFeedPatch, svc_textFeed, SVCTEXTFEED_HASFEED, hasFeed);
  51. M_CB(TextFeedPatch, svc_textFeed, SVCTEXTFEED_GETFEEDTEXT, getFeedText);
  52. M_CB(TextFeedPatch, svc_textFeed, SVCTEXTFEED_GETFEEDDESC, getFeedDescription);
  53. M_CB(TextFeedPatch, svc_textFeed, SVCTEXTFEED_GETDEPENDENCYPTR, getDependencyPtr);
  54. END_PATCH
  55. END_MULTIPATCH;
  56. #undef CBCLASS