diff options
Diffstat (limited to 'Src/Wasabi/api/skin/feeds')
-rw-r--r-- | Src/Wasabi/api/skin/feeds/TextFeedEnum.h | 35 | ||||
-rw-r--r-- | Src/Wasabi/api/skin/feeds/api_textfeed.cpp | 2 | ||||
-rw-r--r-- | Src/Wasabi/api/skin/feeds/api_textfeed.h | 66 | ||||
-rw-r--r-- | Src/Wasabi/api/skin/feeds/ezfeed.h | 27 | ||||
-rw-r--r-- | Src/Wasabi/api/skin/feeds/feedwatch.cpp | 90 | ||||
-rw-r--r-- | Src/Wasabi/api/skin/feeds/feedwatch.h | 54 | ||||
-rw-r--r-- | Src/Wasabi/api/skin/feeds/feedwatcherso.cpp | 136 | ||||
-rw-r--r-- | Src/Wasabi/api/skin/feeds/feedwatcherso.h | 64 | ||||
-rw-r--r-- | Src/Wasabi/api/skin/feeds/textfeed.cpp | 116 | ||||
-rw-r--r-- | Src/Wasabi/api/skin/feeds/textfeed.h | 57 | ||||
-rw-r--r-- | Src/Wasabi/api/skin/feeds/textfeedcb.cpp | 9 | ||||
-rw-r--r-- | Src/Wasabi/api/skin/feeds/textfeedcb.h | 34 |
12 files changed, 690 insertions, 0 deletions
diff --git a/Src/Wasabi/api/skin/feeds/TextFeedEnum.h b/Src/Wasabi/api/skin/feeds/TextFeedEnum.h new file mode 100644 index 00000000..62405cfe --- /dev/null +++ b/Src/Wasabi/api/skin/feeds/TextFeedEnum.h @@ -0,0 +1,35 @@ +#ifndef NULLSOFT_WASABI_TEXTFEEDENUM_H +#define NULLSOFT_WASABI_TEXTFEEDENUM_H + + +#include <bfc/string/StringW.h> +#include <api/skin/feeds/api_textfeed.h> +// see helper class TextFeed + +#include <api/service/servicei.h> +template <class T> +class TextFeedCreatorSingle : public waServiceFactoryTSingle<svc_textFeed, T> +{ +public: + svc_textFeed *getFeed() + { + return getSingleService(); + } +}; + +#include <api/service/svc_enum.h> + +class TextFeedEnum : public SvcEnumT<svc_textFeed> +{ +public: + TextFeedEnum(const wchar_t *_feedid) : feedid(_feedid) {} +protected: + virtual int testService(svc_textFeed *svc) + { + return (svc->hasFeed(feedid)); + } +private: + StringW feedid; +}; + +#endif
\ No newline at end of file diff --git a/Src/Wasabi/api/skin/feeds/api_textfeed.cpp b/Src/Wasabi/api/skin/feeds/api_textfeed.cpp new file mode 100644 index 00000000..d7b3d2f1 --- /dev/null +++ b/Src/Wasabi/api/skin/feeds/api_textfeed.cpp @@ -0,0 +1,2 @@ +#include <precomp.h> +#include "api_textfeed.h"
\ No newline at end of file diff --git a/Src/Wasabi/api/skin/feeds/api_textfeed.h b/Src/Wasabi/api/skin/feeds/api_textfeed.h new file mode 100644 index 00000000..fecde4d4 --- /dev/null +++ b/Src/Wasabi/api/skin/feeds/api_textfeed.h @@ -0,0 +1,66 @@ +#ifndef __WASABI_API_TEXTFEED_H +#define __WASABI_API_TEXTFEED_H + +#include <bfc/dispatch.h> +#include <bfc/platform/types.h> +#include <api/service/services.h> + +class ifc_dependent; + +// {A04E3420-CBA1-4ae1-B3C0-8DE127D2B861} +static const GUID textfeed_dependent_GUID = { 0xa04e3420, 0xcba1, 0x4ae1, { 0xb3, 0xc0, 0x8d, 0xe1, 0x27, 0xd2, 0xb8, 0x61 } }; + +class NOVTABLE svc_textFeed : public Dispatchable +{ +public: + static FOURCC getServiceType() { return WaSvc::TEXTFEED; } + static const GUID *depend_getClassGuid() + { + return &textfeed_dependent_GUID; + } + static const char *getServiceName() { return "Untitled Textfeed"; } + +public: + int hasFeed(const wchar_t *name); + const wchar_t *getFeedText(const wchar_t *name); + const wchar_t *getFeedDescription(const wchar_t *name); + ifc_dependent *getDependencyPtr(); + +public: + enum + { + Event_TEXTCHANGE = 100, // param is const char* to id, ptr points to new text + }; + + DISPATCH_CODES + { + SVCTEXTFEED_HASFEED = 10, + //20,30 retired + SVCTEXTFEED_GETFEEDTEXT = 40, + SVCTEXTFEED_GETFEEDDESC = 45, + SVCTEXTFEED_GETDEPENDENCYPTR = 100, + }; +}; + +inline int svc_textFeed::hasFeed(const wchar_t *name) +{ + return _call(SVCTEXTFEED_HASFEED, 0, name); +} + +inline const wchar_t *svc_textFeed::getFeedText(const wchar_t *name) +{ + return _call(SVCTEXTFEED_GETFEEDTEXT, (const wchar_t *)NULL, name); +} + +inline const wchar_t *svc_textFeed::getFeedDescription(const wchar_t *name) +{ + return _call(SVCTEXTFEED_GETFEEDDESC, (const wchar_t *)NULL, name); +} + +inline ifc_dependent *svc_textFeed::getDependencyPtr() +{ + return _call(SVCTEXTFEED_GETDEPENDENCYPTR, (ifc_dependent*)NULL); +} + + +#endif diff --git a/Src/Wasabi/api/skin/feeds/ezfeed.h b/Src/Wasabi/api/skin/feeds/ezfeed.h new file mode 100644 index 00000000..cc607d10 --- /dev/null +++ b/Src/Wasabi/api/skin/feeds/ezfeed.h @@ -0,0 +1,27 @@ +#ifndef _EZFEED_H +#define _EZFEED_H + +//#include <bfc/wasabi_std.h> +#include <api/service/waservicefactorybase.h> +#include <api/skin/feeds/textfeed.h> + +class EzFeed : public waServiceFactoryBase<svc_textFeed, EzFeed>, public TextFeed +{ +public: + EzFeed() : registered(0) { } + static const char *getServiceName() { return "EzTextFeed"; } + virtual svc_textFeed *newService() { return this; } + virtual int delService(svc_textFeed *service) { return TRUE; } + + virtual int svc_notify(int msg, int param1 = 0, int param2 = 0) + { + if (msg == SvcNotify::ONREGISTERED) registered = 1; + else if (msg == SvcNotify::ONDEREGISTERED) registered = 0; + return 1; + } + +private: + int registered; +}; + +#endif diff --git a/Src/Wasabi/api/skin/feeds/feedwatch.cpp b/Src/Wasabi/api/skin/feeds/feedwatch.cpp new file mode 100644 index 00000000..e200c20e --- /dev/null +++ b/Src/Wasabi/api/skin/feeds/feedwatch.cpp @@ -0,0 +1,90 @@ +#include <precomp.h> +#pragma warning(disable:4355) + +//<?#include "<class data="implementationheader"/>" +#include "feedwatch.h" +//?> + +#include <api/skin/feeds/TextFeedEnum.h> + + +FeedWatcher::FWDV::FWDV(FeedWatcher *_parent) : parent(_parent) { } + +int FeedWatcher::FWDV::viewer_onItemDeleted(ifc_dependent *item) { + return parent->fwdv_onItemDeleted(item); +} + +int FeedWatcher::FWDV::viewer_onEvent(ifc_dependent *item, const GUID *classguid, int event, intptr_t param, void *ptr, size_t ptrlen) { + return parent->fwdv_onEvent(item, event, param, ptr, ptrlen); +} + +FeedWatcher::FeedWatcher() : + registered_syscb(0), textfeed(NULL), fwdv(this) +{ +} + + +FeedWatcher::~FeedWatcher() { + releaseFeed(); + if (registered_syscb) { + WASABI_API_SYSCB->syscb_deregisterCallback(static_cast<SvcCallbackI*>(this)); + DebugStringW(L"unreg syscb"); + } +} + +int FeedWatcher::setFeed(const wchar_t *feedid) +{ + if (!registered_syscb++) WASABI_API_SYSCB->syscb_registerCallback(static_cast<SvcCallbackI*>(this)); + + releaseFeed(); + + feed_id = feedid; + if (!feed_id.isempty()) textfeed = TextFeedEnum(feed_id).getFirst(); + + if (textfeed != NULL) { + fwdv.viewer_addViewItem(textfeed->getDependencyPtr()); + feedwatcher_onSetFeed(textfeed); +//CUT if (first_cb) feedwatcher_onFeedChange(textfeed->getFeedText(feed_id)); + } + + return 1; +} + +void FeedWatcher::releaseFeed() { + if (textfeed) { + fwdv.viewer_delViewItem(textfeed->getDependencyPtr()); + feed_id = L""; + SvcEnum::release(textfeed); + textfeed = NULL; + } +} + +const wchar_t *FeedWatcher::getFeedId() { + return feed_id; +} + +int FeedWatcher::fwdv_onItemDeleted(ifc_dependent *item) { + textfeed = NULL; + // send text change msg? dunno for sure + return 1; +} + +int FeedWatcher::fwdv_onEvent(ifc_dependent *item, int event, intptr_t param2, void *ptr, size_t ptrlen) { + if (textfeed && item == textfeed->getDependencyPtr() + && event == svc_textFeed::Event_TEXTCHANGE + && WCSCASEEQLSAFE((const wchar_t *)param2, feed_id)) { + feedwatcher_onFeedChange((const wchar_t *)ptr); + return 1; + } + return 0; +} + +void FeedWatcher::svccb_onSvcRegister(FOURCC type, waServiceFactory *svc) { + // brand new feed and we don't have one, try to register it +//CUT __asm int 3; + if (type == WaSvc::TEXTFEED && textfeed == NULL) { + if (!feed_id.isempty()) { + setFeed(feed_id); + } + } +}
\ No newline at end of file diff --git a/Src/Wasabi/api/skin/feeds/feedwatch.h b/Src/Wasabi/api/skin/feeds/feedwatch.h new file mode 100644 index 00000000..3e3bd7a2 --- /dev/null +++ b/Src/Wasabi/api/skin/feeds/feedwatch.h @@ -0,0 +1,54 @@ +#ifndef __FEEDWATCH_H +#define __FEEDWATCH_H + +#include <bfc/wasabi_std.h> +#include <api/syscb/callbacks/svccbi.h> +#include "feedwatcherso.h" + +class svc_textFeed; +class ifc_dependent; + + + +class FeedWatcher : private SvcCallbackI, public FeedWatcherScriptObject { +public: + FeedWatcher(); + virtual ~FeedWatcher(); + + int setFeed(const wchar_t *feedid); + void releaseFeed(); + + const wchar_t *getFeedId(); + + virtual void feedwatcher_onSetFeed(svc_textFeed *svc) { } + virtual void feedwatcher_onFeedChange(const wchar_t *data) { } + +protected: + class FWDV : public DependentViewerI +{ +public: + friend class FeedWatcher; + + FWDV(FeedWatcher *parent); + + virtual int viewer_onItemDeleted(ifc_dependent *item); + virtual int viewer_onEvent(ifc_dependent *item, const GUID *classguid, int event, intptr_t param, void *ptr, size_t ptrlen); + + FeedWatcher *parent; +}; + + // catches text feed change events + virtual int fwdv_onItemDeleted(ifc_dependent *item); + virtual int fwdv_onEvent(ifc_dependent *item, int event, intptr_t param2, void *ptr, size_t ptrlen); + +private: + // catches new feeds being registered + virtual void svccb_onSvcRegister(FOURCC type, waServiceFactory *svc); + + int registered_syscb; + StringW feed_id; + svc_textFeed *textfeed; + FWDV fwdv; +}; + +#endif diff --git a/Src/Wasabi/api/skin/feeds/feedwatcherso.cpp b/Src/Wasabi/api/skin/feeds/feedwatcherso.cpp new file mode 100644 index 00000000..af8d5ff0 --- /dev/null +++ b/Src/Wasabi/api/skin/feeds/feedwatcherso.cpp @@ -0,0 +1,136 @@ +// ---------------------------------------------------------------------------- +// Generated by ScriptObjectFactory [Sat Sep 27 01:24:57 2003] +// +// File : +// Class : FeedWatcherScriptObject +// class layer : Automatic Object Scripting +// ---------------------------------------------------------------------------- +#include "precomp.h" + +#include "feedwatch.h" +#include "FeedWatcherSO.h" +// ScriptController Instance +static FeedWatcherScriptController _feedWatcherScriptController;FeedWatcherScriptController *feedWatcherScriptController = &_feedWatcherScriptController; + +// Function Descriptor Table +function_descriptor_struct FeedWatcherScriptController::exportedFunctions[] = { + { L"setFeed", 1, script_setFeed }, + { L"releaseFeed", 0, script_releaseFeed }, + { L"onFeedChange", 1, script_feedwatcher_onFeedChange }, +}; + +// Script Object Methods +FeedWatcherScriptObject::FeedWatcherScriptObject() { + if (!getScriptObject()) return; + feedWatcherScriptObject_init(); +} + +FeedWatcherScriptObject::~FeedWatcherScriptObject() { +} + +void FeedWatcherScriptObject::feedWatcherScriptObject_init() { + // Assign the script interface to this instance. + getScriptObject()->vcpu_setInterface(FeedWatcherGuid, (void *)static_cast<FeedWatcher*>(this)); + // Assign the class name to this instance. + getScriptObject()->vcpu_setClassName(L"FeedWatcher"); + // Assign the controller instance to this script object instance. + getScriptObject()->vcpu_setController(feedWatcherScriptController); +} + +// Script Object Methods + +void FeedWatcherScriptObject::feedwatcher_onFeedChange(const wchar_t *data) { + FeedWatcherScriptController::script_feedwatcher_onFeedChange(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING(data)); +} + +scriptVar /*int */ FeedWatcherScriptController::script_setFeed(SCRIPT_FUNCTION_PARAMS, ScriptObject *_pSO, scriptVar /*const char **/ feedid) { + // Begin all script methods with the init block. + SCRIPT_FUNCTION_INIT; + // Find the proper pointer for the "this" object, _pSO. + FeedWatcher*_pObj = static_cast<FeedWatcher*>(_pSO->vcpu_getInterface(FeedWatcherGuid)); + if (_pObj) { + return MAKE_SCRIPT_INT(_pObj->setFeed(GET_SCRIPT_STRING(feedid))); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar /*void */ FeedWatcherScriptController::script_releaseFeed(SCRIPT_FUNCTION_PARAMS, ScriptObject *_pSO) { + // Begin all script methods with the init block. + SCRIPT_FUNCTION_INIT; + // Find the proper pointer for the "this" object, _pSO. + FeedWatcher*_pObj = static_cast<FeedWatcher*>(_pSO->vcpu_getInterface(FeedWatcherGuid)); + if (_pObj) { + // Then properly call the hosted object; + _pObj->releaseFeed(); + } + RETURN_SCRIPT_VOID; +} + +scriptVar /*void */ FeedWatcherScriptController::script_feedwatcher_onFeedChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *_pSO, scriptVar /*const char **/ data) { + // Begin all script methods with the init block + SCRIPT_FUNCTION_INIT; + // Honnor C++ hooks + PROCESS_HOOKS1(_pSO, feedWatcherScriptController, data); + // If there are no script hooks to execute, we abort here. + SCRIPT_FUNCTION_CHECKABORTEVENT; + // Otherwise we execute the script methods by calling this. + SCRIPT_EXEC_EVENT1(_pSO, data); +} + +// Script Controller + +// This method returns the human readable name of the class in script files. +const wchar_t *FeedWatcherScriptController::getClassName() { + return L"FeedWatcher"; +} + +// This method returns the human readable name of the parent of this class. +const wchar_t *FeedWatcherScriptController::getAncestorClassName() { + return FEEDWATCHER_SCRIPTPARENTCLASS; +} + +// This method returns the controller object for the parent class. +ScriptObjectController *FeedWatcherScriptController::getAncestorController() { + /* XML-Template-TODO : Support inheritance */ + return NULL; +} + +// This method returns the number of methods this class publishes. +int FeedWatcherScriptController::getNumFunctions() { + return sizeof(exportedFunctions) / sizeof(function_descriptor_struct); +} + +// This method returns the block of published function descriptors. +const function_descriptor_struct *FeedWatcherScriptController::getExportedFunctions() { + return exportedFunctions; +} + +// This method returns the GUID assigned to this script class. +GUID FeedWatcherScriptController::getClassGuid() { + return FeedWatcherGuid; +} + +// This method creates and returns a new script class instance. +ScriptObject *FeedWatcherScriptController::instantiate() { + FeedWatcher*_pObj = new FeedWatcher(); + ASSERT(_pObj != NULL); + return _pObj->getScriptObject(); +} + +// This method deletes a given script class instance. +void FeedWatcherScriptController::destroy(ScriptObject *o) { + FeedWatcher*_pObj = static_cast<FeedWatcher*>(o->vcpu_getInterface(FeedWatcherGuid)); + ASSERT(_pObj != NULL); + delete _pObj; +} + +// This method returns an encapsulated interface for the given instance. +void *FeedWatcherScriptController::encapsulate(ScriptObject *o) { + // No automatic encapsulation + return NULL; +} + +// This method frees a previously encapsulated interface. +void FeedWatcherScriptController::deencapsulate(void *o) { +} + diff --git a/Src/Wasabi/api/skin/feeds/feedwatcherso.h b/Src/Wasabi/api/skin/feeds/feedwatcherso.h new file mode 100644 index 00000000..852964fa --- /dev/null +++ b/Src/Wasabi/api/skin/feeds/feedwatcherso.h @@ -0,0 +1,64 @@ +// ---------------------------------------------------------------------------- +// Generated by ScriptObjectFactory [Sat Sep 27 01:24:57 2003] +// +// File : +// Class : FeedWatcherScriptObject +// class layer : Automatic Object Scripting +// ---------------------------------------------------------------------------- + +#ifndef __FEEDWATCHERSCRIPTOBJECT_H +#define __FEEDWATCHERSCRIPTOBJECT_H + + +#include <api/script/objects/rootobj.h> +#include <api/script/objcontroller.h> + +#define FEEDWATCHER_SCRIPTPARENT RootObjectInstance +#define FEEDWATCHER_SCRIPTPARENTCLASS L"Object" + +class svc_textFeed; + +// ---------------------------------------------------------------------------- +// {A5376FA1-4E94-411a-83F6-05EC5EEA5F0A} +static const GUID FeedWatcherGuid = +{ 0xa5376fa1, 0x4e94, 0x411a, { 0x83, 0xf6, 0x5, 0xec, 0x5e, 0xea, 0x5f, 0xa } }; + +// ----------------------------------------------------------------------------- + +class FeedWatcherScriptObject : public FEEDWATCHER_SCRIPTPARENT { +public: + FeedWatcherScriptObject(); + virtual ~FeedWatcherScriptObject(); + + void feedWatcherScriptObject_init(); + +public: + virtual void feedwatcher_onFeedChange(const wchar_t *data); +}; + +// ----------------------------------------------------------------------------- +class FeedWatcherScriptController : public ScriptObjectControllerI { +public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController(); + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + static scriptVar script_setFeed(SCRIPT_FUNCTION_PARAMS, ScriptObject *_pSO, scriptVar feedid); + static scriptVar script_releaseFeed(SCRIPT_FUNCTION_PARAMS, ScriptObject *_pSO); + static scriptVar script_feedwatcher_onFeedChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *_pSO, scriptVar data); + +private:static function_descriptor_struct exportedFunctions[]; +}; + +extern FeedWatcherScriptController *feedWatcherScriptController; +// ---------------------------------------------------------------------------- + +#endif // __FEEDWATCHERSCRIPTOBJECT_H diff --git a/Src/Wasabi/api/skin/feeds/textfeed.cpp b/Src/Wasabi/api/skin/feeds/textfeed.cpp new file mode 100644 index 00000000..feebe097 --- /dev/null +++ b/Src/Wasabi/api/skin/feeds/textfeed.cpp @@ -0,0 +1,116 @@ +#include <precomp.h> +#include "textfeed.h" +#include <bfc/pair.h> + +int TextFeed::registerFeed(const wchar_t *feedid, const wchar_t *initial_text, const wchar_t *description) +{ + //if (feeds.getItem(StringW(feedid))) + // return FALSE; + auto it = feeds.find(feedid); + if (feeds.end() != it) + { + return FALSE; + } + + //std::pair<std::wstring, std::wstring> pair(initial_text, description); + + feeds.insert({ feedid, {initial_text, description} }); + + dependent_sendEvent(svc_textFeed::depend_getClassGuid(), Event_TEXTCHANGE, (intptr_t)feedid, (void*)initial_text, wcslen(initial_text) + 1); + return TRUE; +} + +int TextFeed::sendFeed(const wchar_t *feedid, const wchar_t *text) +{ + //Pair <StringW, StringW> ft(L"", L""); + //if (!feeds.getItem(StringW(feedid), &ft)) + //{ + // //CUT ASSERTALWAYS("hey, you're trying to send a feed you didn't register. stop it."); + // DebugString("TextFeed::sendFeed(), feedid '%s' not registered", feedid); + // return FALSE; + //} + auto it = feeds.find(feedid); + if (feeds.end() == it) + { + return FALSE; + } + + //StringW id(feedid); + //feeds.getItem(id, &ft); + //ft.a = StringW(text); + //feeds.setItem(StringW(feedid), ft); + + auto &ft = feeds[feedid]; + ft.first = text; + + dependent_sendEvent(svc_textFeed::depend_getClassGuid(), Event_TEXTCHANGE, (intptr_t)feedid, (void*)text, wcslen(text) + 1); + return TRUE; +} + +const wchar_t *TextFeed::getFeedText(const wchar_t *name) +{ + //const Pair<StringW, StringW> *ft = feeds.getItemRef(StringW(name)); + //if (ft == NULL) + // return NULL; + //ft->a.getValue(); + + auto it = feeds.find(name); + if (it == feeds.end()) + { + return NULL; + } + auto& ft = it->second; + return ft.first.c_str(); +} + +const wchar_t *TextFeed::getFeedDescription(const wchar_t *name) +{ + //const Pair<StringW, StringW> *ft = feeds.getItemRef(StringW(name)); + //if (ft == NULL) return NULL; + //return ft->b.getValue(); + + auto it = feeds.find(name); + if (it == feeds.end()) + { + return NULL; + } + + auto& ft = it->second; + return ft.second.c_str(); +} + +int TextFeed::hasFeed(const wchar_t *name) +{ + return feeds.count(name); +} + +void TextFeed::dependent_onRegViewer(api_dependentviewer *viewer, int add) +{ + if (add) + { + //for (int i = 0; i < feeds.getNumItems(); i++) + //{ + // StringW a = feeds.enumIndexByPos(i, StringW(L"")); + // Pair<StringW, StringW> sp(L"", L""); + // StringW b = feeds.enumItemByPos(i, sp).a; + // dependent_sendEvent(svc_textFeed::depend_getClassGuid(), Event_TEXTCHANGE, (intptr_t)a.getValue(), (void*)b.getValue(), b.len() + 1, viewer); //send to this viewer only + //} + + for (auto it = feeds.begin(); it != feeds.end(); it++) + { + std::wstring key = it->first; + auto val = it->second; + std::wstring val_first = val.first; + dependent_sendEvent(svc_textFeed::depend_getClassGuid(), Event_TEXTCHANGE, (intptr_t)key.c_str(), (void*)val_first.c_str(), wcslen(val_first.c_str()) + 1, viewer); //send to this viewer only + } + } + + if (add) onRegClient(); + else onDeregClient(); +} + +void *TextFeed::dependent_getInterface(const GUID *classguid) +{ + HANDLEGETINTERFACE(svc_textFeed); + return NULL; +} diff --git a/Src/Wasabi/api/skin/feeds/textfeed.h b/Src/Wasabi/api/skin/feeds/textfeed.h new file mode 100644 index 00000000..1c2d9bc1 --- /dev/null +++ b/Src/Wasabi/api/skin/feeds/textfeed.h @@ -0,0 +1,57 @@ +#ifndef _TEXTFEED_H +#define _TEXTFEED_H + +#include <bfc/common.h> +#include <map> +#include <string> +#include <utility> +#include <bfc/depend.h> +#include <api/service/svcs/svc_textfeed.h> +#include <api/syscb/callbacks/corecbi.h> + +/** + This is the standard helper class for implementing a textfeed. + Be sure to check out class EzFeed in ezfeed.h, which combines this + class with a service factory. +*/ +class TextFeed : public svc_textFeedI, public DependentI +{ +public: +/** + Call this to register your feeds by id. Make the ids unique! + @see sendFeed() + @ret TRUE if succeeded, FALSE on error (i.e. nonunique id) +*/ + int registerFeed(const wchar_t *feedid, const wchar_t *initial_text=L"", const wchar_t *description=L""); + +/** + Call this to send text into a feed. + @see registerFeed() + @ret TRUE if succeeded, FALSE on error (i.e. feedid not registered) +*/ + int sendFeed(const wchar_t *feedid, const wchar_t *text); + +// Gives the most recently sent text on a feed. + virtual const wchar_t *getFeedText(const wchar_t *feedid); + +// Gives a description for the feed (used by accessibility). + virtual const wchar_t *getFeedDescription(const wchar_t *feedid); + +protected: + virtual api_dependent *getDependencyPtr() { return this; } + virtual void dependent_onRegViewer(api_dependentviewer *viewer, int add); + virtual void *dependent_getInterface(const GUID *classguid); + +/** + Called when someone subscribes to this feed. +*/ + virtual void onRegClient() { } + virtual void onDeregClient() { } + + virtual int hasFeed(const wchar_t *name); + +private: + std::map<std::wstring, std::pair<std::wstring, std::wstring> > feeds; +}; + +#endif diff --git a/Src/Wasabi/api/skin/feeds/textfeedcb.cpp b/Src/Wasabi/api/skin/feeds/textfeedcb.cpp new file mode 100644 index 00000000..61542fb3 --- /dev/null +++ b/Src/Wasabi/api/skin/feeds/textfeedcb.cpp @@ -0,0 +1,9 @@ +#include "precomp.h" +#if 0//CUT +#include "textfeedcb.h" + +#define CBCLASS TextFeedCallbackI +START_DISPATCH; + VCB(TEXTFEEDCB_ONRECEIVETEXT, textfeed_onReceiveText); +END_DISPATCH; +#endif diff --git a/Src/Wasabi/api/skin/feeds/textfeedcb.h b/Src/Wasabi/api/skin/feeds/textfeedcb.h new file mode 100644 index 00000000..da8d804a --- /dev/null +++ b/Src/Wasabi/api/skin/feeds/textfeedcb.h @@ -0,0 +1,34 @@ +#error this file is going away +#if 0 +#ifndef __TEXTFEEDCB_H +#define __TEXTFEEDCB_H + +#include "dispatch.h" +#include "../common/common.h" + +class TextFeedCallback : public Dispatchable { + public: + + void textfeed_onReceiveText(const wchar_t *text); + + enum { + TEXTFEEDCB_ONRECEIVETEXT = 10, + }; +}; + +inline void TextFeedCallback::textfeed_onReceiveText(const wchar_t *text) { + _voidcall(TEXTFEEDCB_ONRECEIVETEXT, text); +} + +class TextFeedCallbackI : public TextFeedCallback { + public: + TextFeedCallbackI() {} + virtual ~TextFeedCallbackI() {} + + virtual void textfeed_onReceiveText(const wchar_t *text)=0; + + protected: + RECVS_DISPATCH; +}; +#endif +#endif |