svc_redir.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef _SVC_REDIR_H
  2. #define _SVC_REDIR_H
  3. #include <bfc/dispatch.h>
  4. #include <api/service/services.h>
  5. /* Domains:
  6. "Filename"
  7. "Url"
  8. */
  9. // if you want to redirect a string easily, look at RedirString in
  10. // bfc/util/redirstr.h
  11. class svc_redirect : public Dispatchable
  12. {
  13. public:
  14. static FOURCC getServiceType() { return WaSvc::REDIRECT; }
  15. int isMine(const wchar_t *str, const wchar_t *domain);
  16. int redirect(const wchar_t *orig_str, const wchar_t *domain, wchar_t *buf, int buflen);
  17. protected:
  18. enum {
  19. ISMINE=100,
  20. REDIRECT=200,
  21. };
  22. };
  23. inline int svc_redirect::isMine(const wchar_t *str, const wchar_t *domain) {
  24. return _call(ISMINE, 0, str, domain);
  25. }
  26. inline int svc_redirect::redirect(const wchar_t *orig_str, const wchar_t *domain, wchar_t *buf, int buflen) {
  27. return _call(REDIRECT, 0, orig_str, domain, buf, buflen);
  28. }
  29. class svc_redirectI : public svc_redirect {
  30. public:
  31. virtual int isMine(const wchar_t *str, const wchar_t *domain)=0;
  32. virtual int redirect(const wchar_t *orig_str, const wchar_t *domain, wchar_t *buf, int buflen)=0;
  33. protected:
  34. RECVS_DISPATCH;
  35. };
  36. #include <api/service/svc_enum.h>
  37. class RedirectEnum : public SvcEnumT<svc_redirect> {
  38. public:
  39. RedirectEnum(const wchar_t *filename, const wchar_t *domain=L"Filename") :
  40. fn(filename), dom(domain) {
  41. }
  42. virtual int testService(svc_redirect *svc) {
  43. if (svc->isMine(fn, dom)) return 1;
  44. return 0;
  45. }
  46. private:
  47. const wchar_t *fn, *dom;
  48. };
  49. #endif