00001
00032 #ifndef LL_LLCALLINGCARD_H
00033 #define LL_LLCALLINGCARD_H
00034
00035 #include <map>
00036 #include <set>
00037 #include <string>
00038 #include <vector>
00039 #include "lluserrelations.h"
00040 #include "lluuid.h"
00041 #include "v3dmath.h"
00042
00043
00044
00045 class LLMessageSystem;
00046 class LLTrackingData;
00047 class LLFriendObserver
00048 {
00049 public:
00050
00051
00052
00053 enum
00054 {
00055 NONE = 0,
00056 ADD = 1,
00057 REMOVE = 2,
00058 ONLINE = 4,
00059 POWERS = 8,
00060 ALL = 0xffffffff
00061 };
00062 virtual ~LLFriendObserver() {}
00063 virtual void changed(U32 mask) = 0;
00064 };
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 class LLRelationshipFunctor
00077 {
00078 public:
00079 virtual ~LLRelationshipFunctor() {}
00080 virtual bool operator()(const LLUUID& buddy_id, LLRelationship* buddy) = 0;
00081 };
00082
00083
00084 class LLAvatarTracker
00085 {
00086 public:
00087 static LLAvatarTracker& instance() { return sInstance; }
00088
00089 void track(const LLUUID& avatar_id, const std::string& name);
00090 void untrack(const LLUUID& avatar_id);
00091 bool isTrackedAgentValid() { return mTrackedAgentValid; }
00092 void setTrackedAgentValid(bool valid) { mTrackedAgentValid = valid; }
00093 void findAgent();
00094
00095
00096 void setTrackedCoarseLocation(const LLVector3d& global_pos);
00097
00098
00099 bool haveTrackingInfo();
00100 void getDegreesAndDist(F32& rot, F64& horiz_dist, F64& vert_dist);
00101 LLVector3d getGlobalPos();
00102
00103
00104 const LLString& getName();
00105
00106
00107 const LLUUID& getAvatarID();
00108
00109
00110
00111
00112
00113
00114
00115 typedef std::map<LLUUID, LLRelationship*> buddy_map_t;
00116
00117 S32 addBuddyList(const buddy_map_t& buddies);
00118
00119 void copyBuddyList(buddy_map_t& buddies) const;
00120
00121
00122 void terminateBuddy(const LLUUID& id);
00123
00124
00125 const LLRelationship* getBuddyInfo(const LLUUID& id) const;
00126
00127
00128 void setBuddyOnline(const LLUUID& id, bool is_online);
00129 bool isBuddyOnline(const LLUUID& id) const;
00130
00131
00132 void setBuddyEmpowered(const LLUUID& id, bool is_empowered);
00133 bool isBuddyEmpowered(const LLUUID& id) const;
00134
00135
00136 void empowerList(const buddy_map_t& list, bool grant);
00137 void empower(const LLUUID& id, bool grant);
00138
00139
00140 void registerCallbacks(LLMessageSystem* msg);
00141
00142
00143
00144
00145 void addObserver(LLFriendObserver* observer);
00146 void removeObserver(LLFriendObserver* observer);
00147 void notifyObservers();
00148
00149
00150
00151 void applyFunctor(LLRelationshipFunctor& f);
00152
00153 static void formFriendship(const LLUUID& friend_id);
00154
00155 protected:
00156 void deleteTrackingData();
00157 void agentFound(const LLUUID& prey,
00158 const LLVector3d& estimated_global_pos);
00159
00160
00161 static void processAgentFound(LLMessageSystem* msg, void**);
00162 static void processOnlineNotification(LLMessageSystem* msg, void**);
00163 static void processOfflineNotification(LLMessageSystem* msg, void**);
00164
00165 static void processTerminateFriendship(LLMessageSystem* msg, void**);
00166 static void processChangeUserRights(LLMessageSystem* msg, void**);
00167
00168 void processNotify(LLMessageSystem* msg, bool online);
00169 void processChange(LLMessageSystem* msg);
00170
00171 protected:
00172 static LLAvatarTracker sInstance;
00173 LLTrackingData* mTrackingData;
00174 bool mTrackedAgentValid;
00175 U32 mModifyMask;
00176
00177
00178
00179 buddy_map_t mBuddyInfo;
00180
00181 typedef std::vector<LLFriendObserver*> observer_list_t;
00182 observer_list_t mObservers;
00183
00184 private:
00185
00186 LLAvatarTracker(const LLAvatarTracker&);
00187 bool operator==(const LLAvatarTracker&);
00188
00189 public:
00190
00191 LLAvatarTracker();
00192 ~LLAvatarTracker();
00193 };
00194
00195
00196 class LLCollectProxyBuddies : public LLRelationshipFunctor
00197 {
00198 public:
00199 LLCollectProxyBuddies() {}
00200 virtual ~LLCollectProxyBuddies() {}
00201 virtual bool operator()(const LLUUID& buddy_id, LLRelationship* buddy);
00202 typedef std::set<LLUUID> buddy_list_t;
00203 buddy_list_t mProxy;
00204 };
00205
00206
00207 class LLCollectMappableBuddies : public LLRelationshipFunctor
00208 {
00209 public:
00210 LLCollectMappableBuddies() {}
00211 virtual ~LLCollectMappableBuddies() {}
00212 virtual bool operator()(const LLUUID& buddy_id, LLRelationship* buddy);
00213 typedef std::map<std::string, LLUUID, LLDictionaryLess> buddy_map_t;
00214 buddy_map_t mMappable;
00215 char mFirst[DB_FIRST_NAME_BUF_SIZE];
00216 char mLast[DB_LAST_NAME_BUF_SIZE];
00217 };
00218
00219
00220 class LLCollectOnlineBuddies : public LLRelationshipFunctor
00221 {
00222 public:
00223 LLCollectOnlineBuddies() {}
00224 virtual ~LLCollectOnlineBuddies() {}
00225 virtual bool operator()(const LLUUID& buddy_id, LLRelationship* buddy);
00226 typedef std::map<std::string, LLUUID, LLDictionaryLess> buddy_map_t;
00227 buddy_map_t mOnline;
00228 char mFirst[DB_FIRST_NAME_BUF_SIZE];
00229 char mLast[DB_LAST_NAME_BUF_SIZE];
00230 };
00231
00232
00233
00234 class LLCollectAllBuddies : public LLRelationshipFunctor
00235 {
00236 public:
00237 LLCollectAllBuddies() {}
00238 virtual ~LLCollectAllBuddies() {}
00239 virtual bool operator()(const LLUUID& buddy_id, LLRelationship* buddy);
00240 typedef std::map<std::string, LLUUID, LLDictionaryLess> buddy_map_t;
00241 buddy_map_t mOnline;
00242 buddy_map_t mOffline;
00243 char mFirst[DB_FIRST_NAME_BUF_SIZE];
00244 char mLast[DB_LAST_NAME_BUF_SIZE];
00245 };
00246
00247 #endif // LL_LLCALLINGCARD_H