feedwatch.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #include <precomp.h>
  2. #pragma warning(disable:4355)
  3. //<?#include "<class data="implementationheader"/>"
  4. #include "feedwatch.h"
  5. //?>
  6. #include <api/skin/feeds/TextFeedEnum.h>
  7. FeedWatcher::FWDV::FWDV(FeedWatcher *_parent) : parent(_parent) { }
  8. int FeedWatcher::FWDV::viewer_onItemDeleted(ifc_dependent *item) {
  9. return parent->fwdv_onItemDeleted(item);
  10. }
  11. int FeedWatcher::FWDV::viewer_onEvent(ifc_dependent *item, const GUID *classguid, int event, intptr_t param, void *ptr, size_t ptrlen) {
  12. return parent->fwdv_onEvent(item, event, param, ptr, ptrlen);
  13. }
  14. FeedWatcher::FeedWatcher() :
  15. registered_syscb(0), textfeed(NULL), fwdv(this)
  16. {
  17. }
  18. FeedWatcher::~FeedWatcher() {
  19. releaseFeed();
  20. if (registered_syscb) {
  21. WASABI_API_SYSCB->syscb_deregisterCallback(static_cast<SvcCallbackI*>(this));
  22. DebugStringW(L"unreg syscb");
  23. }
  24. }
  25. int FeedWatcher::setFeed(const wchar_t *feedid)
  26. {
  27. if (!registered_syscb++) WASABI_API_SYSCB->syscb_registerCallback(static_cast<SvcCallbackI*>(this));
  28. releaseFeed();
  29. feed_id = feedid;
  30. if (!feed_id.isempty()) textfeed = TextFeedEnum(feed_id).getFirst();
  31. if (textfeed != NULL) {
  32. fwdv.viewer_addViewItem(textfeed->getDependencyPtr());
  33. feedwatcher_onSetFeed(textfeed);
  34. //CUT if (first_cb) feedwatcher_onFeedChange(textfeed->getFeedText(feed_id));
  35. }
  36. return 1;
  37. }
  38. void FeedWatcher::releaseFeed() {
  39. if (textfeed) {
  40. fwdv.viewer_delViewItem(textfeed->getDependencyPtr());
  41. feed_id = L"";
  42. SvcEnum::release(textfeed);
  43. textfeed = NULL;
  44. }
  45. }
  46. const wchar_t *FeedWatcher::getFeedId() {
  47. return feed_id;
  48. }
  49. int FeedWatcher::fwdv_onItemDeleted(ifc_dependent *item) {
  50. textfeed = NULL;
  51. // send text change msg? dunno for sure
  52. return 1;
  53. }
  54. int FeedWatcher::fwdv_onEvent(ifc_dependent *item, int event, intptr_t param2, void *ptr, size_t ptrlen) {
  55. if (textfeed && item == textfeed->getDependencyPtr()
  56. && event == svc_textFeed::Event_TEXTCHANGE
  57. && WCSCASEEQLSAFE((const wchar_t *)param2, feed_id)) {
  58. feedwatcher_onFeedChange((const wchar_t *)ptr);
  59. return 1;
  60. }
  61. return 0;
  62. }
  63. void FeedWatcher::svccb_onSvcRegister(FOURCC type, waServiceFactory *svc) {
  64. // brand new feed and we don't have one, try to register it
  65. //CUT __asm int 3;
  66. if (type == WaSvc::TEXTFEED && textfeed == NULL) {
  67. if (!feed_id.isempty()) {
  68. setFeed(feed_id);
  69. }
  70. }
  71. }