interreality.org [VOS]
[Home] [About]
[Screenshots]
[Download]
[News]
[Community]
[Documentation] [Manual]
[Bugs & Requests] [Wiki]

/home/tetron/hack/vos/libs/vos/vos/localsite.hh

Go to the documentation of this file.
00001 // XXX needs LGPL
00002 
00003 #ifndef _LOCALSITE_HH_
00004 #define _LOCALSITE_HH_
00005 
00006 #include <vos/vos/localvobject.hh>
00007 #include <vos/vos/siteextension.hh>
00008 #include <vos/vos/remotesite.hh>
00009 
00010 namespace VOS {
00011 
00012 /** @class LocalSite localsite.hh vos/vos/localsite.hh
00013     @ingroup libvos
00014 
00015     Extension of LocalVobject implementing server-side functionality
00016     to Site-specific functions: responding to requests to create and
00017     rename vobjects on the site and allowing a remote site to inquire
00018     as to what its current Identity is on this site.
00019 */
00020 class VOS_API LocalSite : public LocalVobject
00021 {
00022 public:
00023     LocalSite(VobjectBase* superobject);
00024     void createVobjectHandler(Message* m);
00025     void getCurrentIdentityHandler(Message* m);
00026     void renameVobjectHandler(Message* m);
00027 };
00028 
00029     class VOS_API LocalSiteExtension : public SiteExtension
00030     {
00031     private:
00032         boost::mutex antiSpoofMap_mutex;
00033         std::map<std::string, std::string> antiSpoofMap;
00034         Site* site;
00035         bool clientOnlyMode;
00036 
00037     protected:
00038         VUtil::URL url;
00039 
00040     public:
00041         LocalSiteExtension();
00042 
00043         virtual ~LocalSiteExtension() { }
00044 
00045         /** Sets the mapping from a received anti-spoof ID to the one
00046             that was sent to that site.
00047             @param recv the anti-spoof ID received from a remote site
00048             @param sent the anti-spoof ID sent to a remote site
00049         */
00050         void setAntiSpoofIDMapping(const std::string& recv, const std::string& sent);
00051 
00052         /** @return the mapping from the received anti-spoof ID to the
00053             one that was sent to that site.
00054             @param recv the anti-spoof ID received from a remote site
00055         */
00056         const std::string& getAntiSpoofIDMapping(const std::string& recv);
00057 
00058         /** Handler for core:spoof-check messages */
00059         void spoofCheckHandler(Message* m);
00060 
00061         /** Handler for core:error messages. */
00062         void errorMsgHandler(Message* m);
00063 
00064         virtual void siteExtensionAttachedTo(Site* st);
00065 
00066         /** @return the site this extension is attached to */
00067         VUtil::vRef<Site> getSite() const { return VUtil::vRef<Site>(site, true); }
00068 
00069         /** Set client-only mode
00070             @bug client-only mode currently doesn't do anything.  This might be
00071             removed in the future.
00072         */
00073         void setClientOnlyMode(bool com) { clientOnlyMode = com; }
00074 
00075         /** Get client-only mode
00076             @bug client-only mode currently doesn't do anything.  This might be
00077             removed in the future.
00078         */
00079         bool getClientOnlyMode() { return clientOnlyMode; }
00080 
00081         /** Add a remote site that we're peered with.
00082             @param rs the RemoteSocketSiteExtension object
00083             representing the connection to the remote site
00084          */
00085         virtual void addRemoteSite(VOS::RemoteSiteExtension* rs) = 0;
00086 
00087         /** Remove a remote site that we're peered with.
00088             @param rs the RemoteSocketSiteExtension object
00089             representing the connection to the remote site
00090          */
00091         virtual void removeRemoteSite(VOS::RemoteSiteExtension* rs) = 0;
00092     };
00093 }
00094 
00095 #endif