00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _MISC_SERVICES_HH_
00024 #define _MISC_SERVICES_HH_
00025
00026 #if defined(_WIN32) && defined(_MSC_VER)
00027 # ifdef MISC_EXPORTS
00028 # define MISC_API __declspec(dllexport)
00029 # else
00030 # define MISC_API __declspec(dllimport)
00031 # endif
00032 #else
00033 # define MISC_API
00034 #endif
00035
00036 #include <vos/corelibs/vos/vos.hh>
00037 #include <vos/metaobjects/property/property.hh>
00038 #include <servicediscovery/servicedirectory.hh>
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 class MISC_API Services : public virtual MetaObject
00075 {
00076
00077
00078 protected:
00079 PropertyAccessControl* accessControl;
00080 static Services* defaultServiceDir;
00081 static std::string serviceDirURL;
00082 std::map<int, LSD::ServiceAdvertismentListener*> queries;
00083
00084 public:
00085
00086
00087 Services(MetaObject* superobject);
00088
00089
00090 virtual ~Services();
00091
00092
00093 virtual const std::string getType();
00094
00095
00096 static void registerExtenders();
00097
00098
00099 virtual void setPropertyAccessControl(PropertyAccessControl* ac);
00100
00101
00102 virtual PropertyAccessControl* getPropertyAccessControl();
00103
00104
00105
00106 static Services* getDefaultServicesDir();
00107 static void setDefaultServiceDir(const std::string& url);
00108 static void registerServiceWithDefault(Vobject* service, const std::string& title, const std::string& desc = "");
00109
00110 virtual void registerService(Vobject* service, const std::string& title, const std::string& desc = "");
00111
00112 virtual int query(const std::string& typepattern,
00113 const std::string& titlepattern,
00114 const std::string& descpattern,
00115 const std::string& urlpattern,
00116 LSD::ServiceAdvertismentListener* cb) = 0;
00117 virtual void endQuery(int q) = 0;
00118 };
00119
00120 class ServiceListenerSiteWrapper;
00121
00122
00123 class LocalServices : public virtual Services,
00124 public virtual ChildChangeListener
00125 {
00126 public:
00127
00128
00129 LocalServices(MetaObject* superobject);
00130
00131
00132 ~LocalServices();
00133
00134
00135 virtual void initialize(PropertyAccessControl* ac);
00136
00137
00138
00139
00140
00141
00142 virtual void initialize();
00143
00144
00145 static MetaObject* new_LocalServices(MetaObject* superobject, const std::string& type);
00146
00147 virtual void notifyChildInserted(VobjectEvent& event);
00148
00149 virtual void notifyChildReplaced(VobjectEvent& event);
00150
00151 virtual void notifyChildRemoved(VobjectEvent& event);
00152
00153
00154 virtual int query(const std::string& typepattern,
00155 const std::string& titlepattern,
00156 const std::string& descpattern,
00157 const std::string& urlpattern,
00158 LSD::ServiceAdvertismentListener* cb);
00159
00160
00161 virtual void endQuery(int q);
00162
00163 virtual void handleQuery(Message* m);
00164 virtual void handleEndQuery(Message* m);
00165
00166 friend class ServiceListenerSiteWrapper;
00167 };
00168
00169
00170 class RemoteServices : public virtual Services
00171 {
00172 public:
00173
00174
00175 RemoteServices(MetaObject* superobject);
00176
00177
00178 virtual ~RemoteServices();
00179
00180
00181 static MetaObject* new_RemoteServices(MetaObject* superobject, const std::string& type);
00182
00183 virtual int query(const std::string& typepattern,
00184 const std::string& titlepattern,
00185 const std::string& descpattern,
00186 const std::string& urlpattern,
00187 LSD::ServiceAdvertismentListener* cb);
00188
00189 virtual void endQuery(int q);
00190
00191 virtual void handleAdvertisement(Message* m);
00192 };
00193
00194 class ServiceListenerSiteWrapper : public LSD::ServiceAdvertismentListener,
00195 public virtual ObjectExciseListener
00196 {
00197 private:
00198 LocalServices* services;
00199 Site* site;
00200 std::string nonce;
00201 int queryID;
00202 public:
00203 ServiceListenerSiteWrapper(LocalServices* sv, Site* st, const std::string& n);
00204 virtual ~ServiceListenerSiteWrapper();
00205 virtual void notifyNewService(int id, const LSD::Service& s);
00206 virtual void notifyObjectExcise(RefCounted* rc);
00207 virtual void setQueryID(int r) { queryID = r; }
00208 };
00209
00210 #endif // #ifdef _SERVICES_HH_
00211