00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "llfloater.h"
00013 #include "llfloaterreporter.h"
00014 #include "lluuid.h"
00015 #include "lltimer.h"
00016 #include "llchat.h"
00017 #include "viewer.h"
00018
00019 #include <time.h>
00020 #include <map>
00021
00022 class LLFloaterAvatarList;
00023
00027 enum ACCOUNT_TYPE
00028 {
00029 ACCOUNT_RESIDENT,
00030 ACCOUNT_TRIAL,
00031 ACCOUNT_CHARTER_MEMBER,
00032 ACCOUNT_EMPLOYEE,
00033 ACCOUNT_CUSTOM
00034 };
00035
00039 enum PAYMENT_TYPE
00040 {
00041 PAYMENT_NONE,
00042 PAYMENT_ON_FILE,
00043 PAYMENT_USED,
00044 PAYMENT_LINDEN
00045 };
00046
00047
00055 enum ACTIVITY_TYPE
00056 {
00057 ACTIVITY_NONE,
00058 ACTIVITY_MOVING,
00059 ACTIVITY_GESTURING,
00060 ACTIVITY_SOUND,
00061 ACTIVITY_REZZING,
00062 ACTIVITY_PARTICLES,
00063 ACTIVITY_TYPING,
00064 ACTIVITY_NEW,
00065 ACTIVITY_DEAD
00066 };
00067
00068 enum DATA_STATUS
00069 {
00070 DATA_UNKNOWN,
00071 DATA_REQUESTING,
00072 DATA_ERROR,
00073 DATA_RETRIEVED
00074 };
00075
00079 enum e_coloring_type
00080 {
00081 CT_NONE,
00082 CT_DISTANCE,
00083 CT_AGE,
00084 CT_SCORE,
00085 CT_PAYMENT
00086 };
00087
00094 template <class T>
00095 class LLAvatarListDatum
00096 {
00097 public:
00098 LLAvatarListDatum()
00099 {
00100 mMaxPending = 32;
00101
00102 mRetryDelay = 0.0f;
00103 mRequestDelay = 1.0f;
00104 mFirstRequestTimeout = 16.0f;
00105 mMaxRequestTimeout = 8192.0f;
00106
00107 mRequestTimer.start();
00108 mRequestDelayTimer.start();
00109 mStatus = DATA_UNKNOWN;
00110
00111 }
00112
00124 BOOL retryNeeded()
00125 {
00126 switch(mStatus)
00127 {
00128 case DATA_UNKNOWN:
00129 case DATA_REQUESTING:
00130 case DATA_ERROR:
00131
00132 if ( mPending >= mMaxPending )
00133 {
00134 return FALSE;
00135 }
00136
00137
00138 if ( mRequestDelayTimer.getElapsedTimeF32() < mRequestDelay )
00139 {
00140 return FALSE;
00141 }
00142
00143
00144 return ( mRequestTimer.getElapsedTimeF32() > mRetryDelay );
00145 case DATA_RETRIEVED:
00146 return FALSE;
00147 }
00148
00149 return FALSE;
00150 }
00151
00155 void requestStarted()
00156 {
00157
00158 if ( mStatus != DATA_REQUESTING )
00159 {
00160 mPending++;
00161
00162 }
00163
00164 mStatus = DATA_REQUESTING;
00165
00166 if ( mRetryDelay == 0 )
00167 {
00168 mRetryDelay = mFirstRequestTimeout;
00169 }
00170 else
00171 {
00172 if ( mRetryDelay < mMaxRequestTimeout )
00173 {
00174 mRetryDelay *= 2;
00175 }
00176 }
00177
00178 mRequestTimer.start();
00179 mRequestDelayTimer.start();
00180 }
00181
00186 BOOL requestIfNeeded()
00187 {
00188 BOOL ret = retryNeeded();
00189 if ( ret )
00190 {
00191 requestStarted();
00192 }
00193
00194 return ret;
00195 }
00196
00200 DATA_STATUS getStatus()
00201 {
00202 if ( mStatus == DATA_REQUESTING
00203 && mRequestTimer.getElapsedTimeF32() > mRetryDelay )
00204 {
00205 mStatus = DATA_ERROR;
00206
00207
00208 mPending--;
00209 }
00210
00211 return mStatus;
00212 }
00213
00214 T& getValue()
00215 {
00216 return mValue;
00217 }
00218
00219 void setValue(T val)
00220 {
00221 if ( mStatus != DATA_RETRIEVED )
00222 {
00223 mPending--;
00224 }
00225
00226 mValue = val;
00227 mStatus = DATA_RETRIEVED;
00228 }
00229
00230 void setRequestDelay(F32 delay)
00231 {
00232 mRequestDelay = delay;
00233 }
00234
00235 void setMaxPending(U32 count)
00236 {
00237 mMaxPending = count;
00238 }
00239 private:
00240 friend class LLFloaterAvatarList;
00241 T mValue;
00242
00243 DATA_STATUS mStatus;
00244
00245
00249 F32 mRetryDelay;
00250
00254 F32 mFirstRequestTimeout;
00255
00261 F32 mMaxRequestTimeout;
00262
00266 LLTimer mRequestTimer;
00267
00268
00269
00273 static LLTimer mRequestDelayTimer;
00274
00278 static U32 mPending;
00279
00280
00284 F32 mRequestDelay;
00285
00289 U32 mMaxPending;
00290 };
00291
00292 template <class T> LLTimer LLAvatarListDatum<T>::mRequestDelayTimer;
00293 template <class T> U32 LLAvatarListDatum<T>::mPending = 0;
00294
00295
00296
00297
00298
00302 struct LLAvListTrustNetScore
00303 {
00304 F32 Score;
00305 LLString Type;
00306
00307 LLAvListTrustNetScore(LLString type = "<uninitialized>", F32 score = 0.0f);
00308 };
00309
00313 struct LLAvatarInfo
00314 {
00315 PAYMENT_TYPE Payment;
00316 ACCOUNT_TYPE Account;
00317 struct tm BirthDate;
00318
00319 LLAvatarInfo();
00320 LLAvatarInfo(PAYMENT_TYPE payment, ACCOUNT_TYPE account, struct tm birth);
00321 S32 getAge();
00322 };
00323
00329 struct LLMiscDBInfo
00330 {
00331 LLString data;
00332
00333 LLMiscDBInfo(LLString d)
00334 {
00335 data = d;
00336 }
00337
00338 LLMiscDBInfo()
00339 {
00340 data = "";
00341 }
00342 };
00343
00344
00353 class LLAvatarListEntry {
00354 public:
00355
00356
00364 LLAvatarListEntry(const LLUUID& id = LLUUID::null, const LLString &name = "", const LLVector3d &position = LLVector3d::zero, BOOL isLinden = FALSE) :
00365 mID(id), mName(name), mPosition(position), mMarked(FALSE), mFocused(FALSE), mIsLinden(isLinden), mActivityType(ACTIVITY_NEW), mAccountTitle(""),
00366 mUpdateTimer(), mActivityTimer(), mFrame(0)
00367 {
00368 mTrustNetScore.setRequestDelay(0.1f);
00369 mTrustNetScore.setMaxPending(8);
00370 mFrame = gFrameCount;
00371 }
00372
00377 void setPosition(LLVector3d position);
00378
00379 LLVector3d getPosition();
00380
00387 U32 getEntryAgeFrames();
00388
00392 F32 getEntryAgeSeconds();
00393
00397 LLString getName();
00398
00399 void setName(LLString name);
00400
00401 LLUUID getID();
00402
00403 void setID(LLUUID id);
00404
00408 BOOL getIsLinden();
00409
00414 void setAccountCustomTitle(LLString &title);
00415
00419 LLString getAccountCustomTitle();
00420
00427 void setActivity(ACTIVITY_TYPE activity);
00428
00432 ACTIVITY_TYPE getActivity();
00433
00437 void setFocus(BOOL value) { mFocused = value; }
00438
00439 BOOL isFocused() { return mFocused; }
00440
00441
00442 BOOL isMarked();
00443
00448 BOOL isDead();
00449
00450 void toggleMark();
00451 private:
00452 friend class LLFloaterAvatarList;
00453
00454 LLUUID mID;
00455 LLString mName;
00456 LLVector3d mPosition;
00457 BOOL mMarked;
00458 BOOL mFocused;
00459 BOOL mIsLinden;
00460
00461 ACTIVITY_TYPE mActivityType;
00462
00463 LLString mAccountTitle;
00464
00465 LLAvatarListDatum<LLAvListTrustNetScore> mTrustNetScore;
00466 LLAvatarListDatum<LLAvatarInfo> mAvatarInfo;
00467 LLAvatarListDatum<LLMiscDBInfo> mMiscInfo;
00468
00472 LLTimer mUpdateTimer;
00473
00477 LLTimer mActivityTimer;
00478
00482 U32 mFrame;
00483 };
00484
00485
00498 class LLFloaterAvatarList : public LLFloater
00499 {
00500 public:
00505 LLFloaterAvatarList();
00506 ~LLFloaterAvatarList();
00507
00508 void show();
00509
00513 virtual void onClose(bool app_quitting) { setVisible(FALSE); }
00514
00519 static void toggle(void*);
00520
00524 static BOOL visible(void*);
00525
00529 void updateAvatarList();
00530
00534 void refreshAvatarList();
00535
00539 static void processAvatarPropertiesReply(LLMessageSystem *msg, void**);
00540
00545 BOOL avatarIsInList(LLUUID avatar);
00546
00551 LLAvatarListEntry* getAvatarEntry(LLUUID avatar);
00552
00559 void requestTrustNetScore(LLUUID avatar, const LLString name, const LLString type);
00560
00566 void requestMiscInfo(LLUUID avatar, const LLString name);
00567
00574 static BOOL handleIM(LLUUID from_id, const LLString message);
00575
00580 static void processTrustNetReply(char *reply);
00581
00585 LLString getSelectedNames(const LLString& separator = ", ");
00586
00587 private:
00588
00589
00590
00591
00592 enum AVATARS_COLUMN_ORDER
00593 {
00594 LIST_AVATAR_ICON,
00595 LIST_AVATAR_NAME,
00596 LIST_DISTANCE,
00597 LIST_AGE,
00598 LIST_SCORE,
00599 LIST_PAYMENT,
00600 LIST_ACTIVITY
00601 };
00602
00603 typedef void (*avlist_command_t)(const LLUUID &avatar, const LLString &name);
00604
00605 void speakText(S32 channel, EChatType type, LLString text);
00606
00610 void removeFocusFromAll();
00611
00616 void focusOnPrev(BOOL marked_only);
00617
00622 void focusOnNext(BOOL marked_only);
00623
00631
00632
00633 static void onClickProfile(void *userdata);
00634 static void onClickIM(void *userdata);
00635 static void onClickTrack(void *userdata);
00636 static void onClickMark(void *userdata);
00637
00638 static void onClickGohomerMark(void *userdata);
00639 static void onClickGohomerWarn(void *userdata);
00640 static void onClickGohomerEject(void *userdata);
00641 static void onClickGohomerSendAway(void *userdata);
00642 static void onClickGohomerSendHome(void *userdata);
00643 static void onClickGohomerSendHomeByKey(void *userdata);
00644
00645 static void onClickGohomerOff(void *userdata);
00646
00647
00648 static void onClickPrevInList(void *userdata);
00649 static void onClickNextInList(void *userdata);
00650 static void onClickPrevMarked(void *userdata);
00651 static void onClickNextMarked(void *userdata);
00652 static void onClickGetKey(void *userdata);
00653
00654 static void onClickTrustNetRate(void *userdata);
00655 static void onClickTrustNetExplain(void *userdata);
00656 static void onClickTrustNetWebsite(void *userdata);
00657 static void onClickTrustNetGetPassword(void *userdata);
00658 static void onClickTrustNetRenew(void *userdata);
00659
00660 static void onDoubleClick(void *userdata);
00661
00662 static void onClickFreeze(void *userdata);
00663 static void onClickEject(void *userdata);
00664
00665
00666 static void onClickMute(void *userdata);
00667
00668 static void onClickAR(void *userdata);
00669 static void onClickTeleport(void *userdata);
00670 static void onClickEjectFromEstate(void *userdata);
00671
00672 static void callbackFreeze(S32 option, void *userdata);
00673
00674 static void callbackEject(S32 option, void *userdata);
00675
00676 static void callbackMute(S32 option, void *userdata);
00677
00678 static void callbackAR(void *userdata);
00679 static void callbackEjectFromEstate(S32 option, void *userdata);
00680
00681 void doCommand(avlist_command_t cmd);
00682
00689 void expireAvatarList();
00690
00695 void luskwoodCommand(LLString cmd);
00696
00702 static void handleLuskwoodDialog(S32 option, void* data);
00703
00709 static void handleLuskwoodGohomerOffDialog(S32 option, void* data);
00710
00715 void processARQueue();
00716 private:
00720 LLScrollListCtrl* mAvatarList;
00721 std::map<LLUUID, LLAvatarListEntry> mAvatars;
00722
00726 std::queue<LLUUID> mARQueue;
00727
00733 std::queue<LLFloaterReporter*> mARReporterQueue;
00734
00740 S32 mARLastFrame;
00741
00742
00747 void sendAvatarPropertiesRequest(LLUUID avid);
00748
00749 void checkTrackingStatus();
00750
00756
00757 LLColor4 getAvatarColor(LLAvatarListEntry *ent, F32 distance, e_coloring_type type);
00758
00765 static void replaceVars(LLString &str, LLUUID avatar, const LLString& name);
00766
00767
00768 BOOL mTracking;
00769 BOOL mTrackByLocation;
00770 LLUUID mTrackedAvatar;
00771
00775 LLTimer mDataRequestTimer;
00776
00780 LLTimer mTrustNetTimer;
00781
00785 LLString mLuskwoodCommand;
00786
00790 LLUUID mFocusedAvatar;
00791
00792 };
00793
00799 extern LLFloaterAvatarList* gFloaterAvatarList;