gloox
1.0
|
00001 /* 00002 Copyright (c) 2007-2009 by Jakob Schroeter <js@camaya.net> 00003 This file is part of the gloox library. http://camaya.net/gloox 00004 00005 This software is distributed under a license. The full license 00006 agreement can be found in the file LICENSE in this distribution. 00007 This software may not be copied, modified, sold or distributed 00008 other than expressed in the named license agreement. 00009 00010 This software is distributed without any warranty. 00011 */ 00012 00013 #ifndef PUBSUB_H__ 00014 #define PUBSUB_H__ 00015 00016 #include <map> 00017 #include <string> 00018 00019 #include "gloox.h" 00020 #include "jid.h" 00021 00022 namespace gloox 00023 { 00027 namespace PubSub 00028 { 00029 00030 class Item; 00031 00035 enum NodeType 00036 { 00037 NodeLeaf, 00039 NodeCollection, 00042 NodeInvalid 00043 }; 00044 00048 enum AffiliationType 00049 { 00050 AffiliationNone, 00051 AffiliationPublisher, 00052 AffiliationOwner, 00053 AffiliationOutcast, 00054 AffiliationInvalid 00055 }; 00056 00060 enum SubscriptionType 00061 { 00062 SubscriptionNone, 00064 SubscriptionSubscribed, 00067 SubscriptionPending, 00071 SubscriptionUnconfigured, 00075 SubscriptionInvalid 00076 }; 00077 00081 enum EventType 00082 { 00083 EventCollection, 00084 EventConfigure, 00085 EventDelete, 00086 EventItems, 00087 EventItemsRetract, 00088 EventPurge, 00089 EventSubscription, 00090 EventUnknown 00091 }; 00092 00096 enum SubscriptionObject 00097 { 00098 SubscriptionNodes, 00099 SubscriptionItems 00100 }; 00101 00105 enum AccessModel 00106 { 00107 AccessOpen, 00111 AccessPresence, 00114 AccessRoster, 00117 AccessAuthorize, 00119 AccessWhitelist, 00126 AccessDefault 00128 }; 00129 00133 enum PubSubFeature 00134 { 00135 FeatureCollections = 1, 00136 FeatureConfigNode = 1<<1, 00137 FeatureCreateAndConfig = 1<<2, 00139 FeatureCreateNodes = 1<<3, 00140 FeatureDeleteAny = 1<<4, 00142 FeatureDeleteNodes = 1<<5, 00143 FeatureGetPending = 1<<6, 00145 FeatureInstantNodes = 1<<7, 00146 FeatureItemIDs = 1<<8, 00147 FeatureLeasedSubscription = 1<<9, 00148 FeatureManageSubscriptions = 1<<10, 00149 FeatureMetaData = 1<<11, 00150 FeatureModifyAffiliations = 1<<12, 00151 FeatureMultiCollection = 1<<13, 00153 FeatureMultiSubscribe = 1<<14, 00155 FeaturePutcastAffiliation = 1<<15, 00156 FeaturePersistentItems = 1<<16, 00157 FeaturePresenceNotifications = 1<<17, 00159 FeaturePublish = 1<<18, 00161 FeaturePublisherAffiliation = 1<<19, 00162 FeaturePurgeNodes = 1<<20, 00163 FeatureRetractItems = 1<<21, 00164 FeatureRetrieveAffiliations = 1<<22, 00166 FeatureRetrieveDefault = 1<<23, 00168 FeatureRetrieveItems = 1<<24, 00169 FeatureRetrieveSubscriptions = 1<<25, 00171 FeatureSubscribe = 1<<26, 00172 FeatureSubscriptionOptions = 1<<27, 00174 FeatureSubscriptionNotifs = 1<<28, 00175 FeatureUnknown = 1<<29 00176 }; 00177 00178 // [Persistent - Notification] 00179 /* Publisher MUST include an <item/> element, which MAY be empty or contain a payload; if item ID is not provided by publisher, it MUST be generated by pubsub service */ 00180 00181 // [Persistent - Payload] 00182 /* Publisher MUST include an <item/> element that contains the payload; if item ID is not provided by publisher, it MUST be generated by pubsub service */ 00183 00184 // [Transient - Notification] 00185 /* Publisher MUST NOT include an <item/> element (therefore item ID is neither provided nor generated) but the notification will include an empty <items/> element */ 00186 00187 // [Transient - Payload] 00188 /* Publisher MUST include an <item/> element that contains the payload, but the item ID is OPTIONAL */ 00189 00193 struct Subscriber 00194 { 00195 Subscriber( const JID& _jid, 00196 SubscriptionType _type, 00197 const std::string& _subid = EmptyString) 00198 : jid( _jid ), type( _type ), subid( _subid ) {} 00199 JID jid; 00200 SubscriptionType type; 00201 std::string subid; 00202 }; 00203 00207 struct Affiliate 00208 { 00209 Affiliate( const JID& _jid, AffiliationType _type ) 00210 : jid( _jid ), type( _type ) {} 00211 JID jid; 00212 AffiliationType type; 00213 }; 00214 00215 typedef std::list<Subscriber> SubscriberList; 00216 typedef std::list<Affiliate> AffiliateList; 00217 00222 struct TrackedInfo 00223 { 00224 JID service; 00225 std::string node; 00226 std::string item; 00227 std::string sid; 00228 }; 00229 00233 struct SubscriptionInfo 00234 { 00235 SubscriptionType type; 00236 JID jid; 00237 std::string subid; 00238 }; 00239 00240 typedef std::list<SubscriptionInfo> SubscriptionList; 00241 typedef std::map<std::string, SubscriptionList> SubscriptionMap; 00242 typedef std::map<std::string, AffiliationType> AffiliationMap; 00243 typedef std::list<Item*> ItemList; 00244 00245 } 00246 00247 } 00248 00249 #endif // PUBSUB_H__