llpanelavatar.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 #include "llpanelavatar.h"
00035 
00036 #include "llclassifiedflags.h"
00037 #include "llfontgl.h"
00038 #include "llcachename.h"
00039 
00040 #include "llavatarconstants.h"
00041 #include "lluiconstants.h"
00042 #include "lltextbox.h"
00043 #include "llviewertexteditor.h"
00044 #include "lltexturectrl.h"
00045 #include "llagent.h"
00046 #include "llviewerwindow.h"
00047 #include "llbutton.h"
00048 #include "llcallingcard.h"
00049 #include "llcheckboxctrl.h"
00050 #include "llfloater.h"
00051 
00052 #include "llfloaterfriends.h"
00053 #include "llfloatergroupinfo.h"
00054 #include "llfloaterworldmap.h"
00055 #include "llfloatermute.h"
00056 #include "llfloateravatarinfo.h"
00057 #include "lliconctrl.h"
00058 #include "llinventoryview.h"
00059 #include "lllineeditor.h"
00060 #include "llnameeditor.h"
00061 #include "llmutelist.h"
00062 #include "llpanelclassified.h"
00063 #include "llpanelpick.h"
00064 #include "llscrolllistctrl.h"
00065 #include "llstatusbar.h"
00066 #include "lltabcontainer.h"
00067 #include "lltabcontainervertical.h"
00068 #include "llimview.h"
00069 #include "lltooldraganddrop.h"
00070 #include "lluiconstants.h"
00071 #include "llvoavatar.h"
00072 #include "llviewermenu.h"               // *FIX: for is_agent_friend()
00073 #include "llviewergenericmessage.h"     // send_generic_message
00074 #include "llviewerobjectlist.h"
00075 #include "llviewerregion.h"
00076 #include "llviewborder.h"
00077 #include "llweb.h"
00078 #include "llinventorymodel.h"
00079 #include "viewer.h"                             // for gUserServer
00080 #include "roles_constants.h"
00081 
00082 #define kArraySize( _kArray ) ( sizeof( (_kArray) ) / sizeof( _kArray[0] ) )
00083 
00084 #include "llvieweruictrlfactory.h"
00085 
00086 // Statics
00087 std::list<LLPanelAvatar*> LLPanelAvatar::sAllPanels;
00088 BOOL LLPanelAvatar::sAllowFirstLife = FALSE;
00089 
00090 extern void handle_lure(const LLUUID& invitee);
00091 extern void handle_pay_by_id(const LLUUID& payee);
00092 
00093 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00094 // Class LLDropTarget
00095 //
00096 // This handy class is a simple way to drop something on another
00097 // view. It handles drop events, always setting itself to the size of
00098 // its parent.
00099 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00100 
00101 class LLDropTarget : public LLView
00102 {
00103 public:
00104         LLDropTarget(const std::string& name, const LLRect& rect, const LLUUID& agent_id);
00105         ~LLDropTarget();
00106 
00107         virtual EWidgetType getWidgetType() const;
00108         virtual LLString getWidgetTag() const;
00109 
00110         void doDrop(EDragAndDropType cargo_type, void* cargo_data);
00111 
00112         //
00113         // LLView functionality
00114         virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
00115                                                                    EDragAndDropType cargo_type,
00116                                                                    void* cargo_data,
00117                                                                    EAcceptance* accept,
00118                                                                    LLString& tooltip_msg);
00119         void setAgentID(const LLUUID &agent_id)         { mAgentID = agent_id; }
00120 protected:
00121         LLUUID mAgentID;
00122 };
00123 
00124 
00125 LLDropTarget::LLDropTarget(const std::string& name, const LLRect& rect,
00126                                                    const LLUUID& agent_id) :
00127         LLView(name, rect, NOT_MOUSE_OPAQUE, FOLLOWS_ALL),
00128         mAgentID(agent_id)
00129 {
00130 }
00131 
00132 LLDropTarget::~LLDropTarget()
00133 {
00134 }
00135 
00136 EWidgetType LLDropTarget::getWidgetType() const
00137 {
00138         return WIDGET_TYPE_DROP_TARGET;
00139 }
00140 
00141 LLString LLDropTarget::getWidgetTag() const
00142 {
00143         return LL_DROP_TARGET_TAG;
00144 }
00145 
00146 void LLDropTarget::doDrop(EDragAndDropType cargo_type, void* cargo_data)
00147 {
00148         llinfos << "LLDropTarget::doDrop()" << llendl;
00149 }
00150 
00151 BOOL LLDropTarget::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
00152                                                                          EDragAndDropType cargo_type,
00153                                                                          void* cargo_data,
00154                                                                          EAcceptance* accept,
00155                                                                          LLString& tooltip_msg)
00156 {
00157         BOOL handled = FALSE;
00158         if(getParent())
00159         {
00160                 // check if inside
00161                 //LLRect parent_rect = mParentView->getRect();
00162                 //mRect.set(0, parent_rect.getHeight(), parent_rect.getWidth(), 0);
00163                 handled = TRUE;
00164 
00165                 // check the type
00166                 switch(cargo_type)
00167                 {
00168                 case DAD_TEXTURE:
00169                 case DAD_SOUND:
00170                 case DAD_LANDMARK:
00171                 case DAD_SCRIPT:
00172                 case DAD_OBJECT:
00173                 case DAD_NOTECARD:
00174                 case DAD_CLOTHING:
00175                 case DAD_BODYPART:
00176                 case DAD_ANIMATION:
00177                 case DAD_GESTURE:
00178                 {
00179                         LLViewerInventoryItem* inv_item = (LLViewerInventoryItem*)cargo_data;
00180                         if(gInventory.getItem(inv_item->getUUID())
00181                                 && LLToolDragAndDrop::isInventoryGiveAcceptable(inv_item))
00182                         {
00183                                 // *TODO: get multiple object transfers working
00184                                 *accept = ACCEPT_YES_COPY_SINGLE;
00185                                 if(drop)
00186                                 {
00187                                         LLToolDragAndDrop::giveInventory(mAgentID, inv_item);
00188                                 }
00189                         }
00190                         else
00191                         {
00192                                 // It's not in the user's inventory (it's probably
00193                                 // in an object's contents), so disallow dragging
00194                                 // it here.  You can't give something you don't
00195                                 // yet have.
00196                                 *accept = ACCEPT_NO;
00197                         }
00198                         break;
00199                 }
00200                 case DAD_CATEGORY:
00201                 {
00202                         LLViewerInventoryCategory* inv_cat = (LLViewerInventoryCategory*)cargo_data;
00203                         if( gInventory.getCategory( inv_cat->getUUID() ) )
00204                         {
00205                                 // *TODO: get multiple object transfers working
00206                                 *accept = ACCEPT_YES_COPY_SINGLE;
00207                                 if(drop)
00208                                 {
00209                                         LLToolDragAndDrop::giveInventoryCategory(mAgentID,
00210                                                                                                                                 inv_cat);
00211                                 }
00212                         }
00213                         else
00214                         {
00215                                 // It's not in the user's inventory (it's probably
00216                                 // in an object's contents), so disallow dragging
00217                                 // it here.  You can't give something you don't
00218                                 // yet have.
00219                                 *accept = ACCEPT_NO;
00220                         }
00221                         break;
00222                 }
00223                 case DAD_CALLINGCARD:
00224                 default:
00225                         *accept = ACCEPT_NO;
00226                         break;
00227                 }
00228         }
00229         return handled;
00230 }
00231 
00232 
00233 //-----------------------------------------------------------------------------
00234 // LLPanelAvatarTab()
00235 //-----------------------------------------------------------------------------
00236 LLPanelAvatarTab::LLPanelAvatarTab(const std::string& name, const LLRect &rect, 
00237                                                                    LLPanelAvatar* panel_avatar)
00238 :       LLPanel(name, rect),
00239         mPanelAvatar(panel_avatar),
00240         mDataRequested(false)
00241 { }
00242 
00243 // virtual
00244 void LLPanelAvatarTab::draw()
00245 {
00246         if (getVisible())
00247         {
00248                 refresh();
00249 
00250                 LLPanel::draw();
00251         }
00252 }
00253 
00254 void LLPanelAvatarTab::sendAvatarProfileRequestIfNeeded(const char* method)
00255 {
00256         if (!mDataRequested)
00257         {
00258                 std::vector<std::string> strings;
00259                 strings.push_back( mPanelAvatar->getAvatarID().asString() );
00260                 send_generic_message(method, strings);
00261                 mDataRequested = true;
00262         }
00263 }
00264 
00265 //-----------------------------------------------------------------------------
00266 // LLPanelAvatarSecondLife()
00267 //-----------------------------------------------------------------------------
00268 LLPanelAvatarSecondLife::LLPanelAvatarSecondLife(const std::string& name, 
00269                                                                                                  const LLRect &rect, 
00270                                                                                                  LLPanelAvatar* panel_avatar ) 
00271 :       LLPanelAvatarTab(name, rect, panel_avatar),
00272         mPartnerID()
00273 {
00274 }
00275 
00276 void LLPanelAvatarSecondLife::refresh()
00277 {
00278         updatePartnerName();
00279 }
00280 
00281 void LLPanelAvatarSecondLife::updatePartnerName()
00282 {
00283         if (mPartnerID.notNull())
00284         {
00285                 char first[128];                /*Flawfinder: ignore*/
00286                 char last[128];         /*Flawfinder: ignore*/
00287                 BOOL found = gCacheName->getName(mPartnerID, first, last);
00288                 if (found)
00289                 {
00290                         childSetTextArg("partner_edit", "[FIRST]", LLString(first));
00291                         childSetTextArg("partner_edit", "[LAST]", LLString(last));
00292                 }
00293         }
00294 }
00295 
00296 //-----------------------------------------------------------------------------
00297 // clearControls()
00298 // Empty the data out of the controls, since we have to wait for new
00299 // data off the network.
00300 //-----------------------------------------------------------------------------
00301 void LLPanelAvatarSecondLife::clearControls()
00302 {
00303         LLTextureCtrl*  image_ctrl = LLUICtrlFactory::getTexturePickerByName(this,"img");
00304         if(image_ctrl)
00305         {
00306                 image_ctrl->setImageAssetID(LLUUID::null);
00307         }
00308         childSetValue("about", "");
00309         childSetValue("born", "");
00310         childSetValue("acct", "");
00311 
00312         childSetTextArg("partner_edit", "[FIRST]", LLString::null);
00313         childSetTextArg("partner_edit", "[LAST]", LLString::null);
00314 
00315         mPartnerID = LLUUID::null;
00316         
00317         LLScrollListCtrl*       group_list = LLUICtrlFactory::getScrollListByName(this,"groups"); 
00318         if(group_list)
00319         {
00320                 group_list->deleteAllItems();
00321         }
00322         LLScrollListCtrl*       ratings_list = LLUICtrlFactory::getScrollListByName(this,"ratings"); 
00323         if(ratings_list)
00324         {
00325                 ratings_list->deleteAllItems();
00326         }
00327 
00328 }
00329 
00330 
00331 //-----------------------------------------------------------------------------
00332 // enableControls()
00333 //-----------------------------------------------------------------------------
00334 void LLPanelAvatarSecondLife::enableControls(BOOL self)
00335 {
00336         childSetEnabled("img", self);
00337         childSetEnabled("about", self);
00338         childSetVisible("allow_publish", self);
00339         childSetEnabled("allow_publish", self);
00340         childSetVisible("?", self);
00341         childSetEnabled("?", self);
00342 
00343         if (!self)
00344         {
00345                 // This is because the LLTextEditor
00346                 // appears to reset the read only background color when
00347                 // setEnable is called, for some reason
00348                 LLTextEditor* about = LLUICtrlFactory::getTextEditorByName(this,"about");
00349                 if (about) about->setReadOnlyBgColor(LLColor4::transparent);
00350         }
00351 }
00352 
00353 
00354 // static
00355 void LLPanelAvatarSecondLife::onClickImage(void *)
00356 { }
00357 
00358 // static
00359 void LLPanelAvatarSecondLife::onDoubleClickGroup(void* data)
00360 {
00361         LLPanelAvatarSecondLife* self = (LLPanelAvatarSecondLife*)data;
00362 
00363         
00364         LLScrollListCtrl*       group_list =  LLUICtrlFactory::getScrollListByName(self,"groups"); 
00365         if(group_list)
00366         {
00367                 LLScrollListItem* item = group_list->getFirstSelected();
00368                 if(item && item->getUUID().notNull())
00369                 {
00370                         llinfos << "Show group info " << item->getUUID() << llendl;
00371 
00372                         LLFloaterGroupInfo::showFromUUID(item->getUUID());
00373                 }
00374         }
00375 }
00376 
00377 // static
00378 void LLPanelAvatarSecondLife::onClickPublishHelp(void *)
00379 {
00380         gViewerWindow->alertXml("ClickPublishHelpAvatar");
00381 }
00382 
00383 // static
00384 void LLPanelAvatarSecondLife::onClickPartnerHelp(void *)
00385 {
00386     gViewerWindow->alertXml("ClickPartnerHelpAvatar", onClickPartnerHelpLoadURL, (void*) NULL);
00387 }
00388 
00389 // static 
00390 void LLPanelAvatarSecondLife::onClickPartnerHelpLoadURL(S32 option, void* userdata)
00391 {
00392   if (option == 0)
00393     LLWeb::loadURL("http://secondlife.com/partner");
00394 }
00395 
00396 
00397 //-----------------------------------------------------------------------------
00398 // LLPanelAvatarFirstLife()
00399 //-----------------------------------------------------------------------------
00400 LLPanelAvatarFirstLife::LLPanelAvatarFirstLife(const std::string& name, 
00401                                                                                            const LLRect &rect, 
00402                                                                                            LLPanelAvatar* panel_avatar ) 
00403 :       LLPanelAvatarTab(name, rect, panel_avatar)
00404 {
00405 }
00406 
00407 
00408 void LLPanelAvatarFirstLife::enableControls(BOOL self)
00409 {
00410         childSetEnabled("img", self);
00411         childSetEnabled("about", self);
00412 }
00413 
00414 //-----------------------------------------------------------------------------
00415 // postBuild
00416 //-----------------------------------------------------------------------------
00417 
00418 BOOL LLPanelAvatarSecondLife::postBuild(void)
00419 {
00420         childSetEnabled("born", FALSE);
00421         childSetEnabled("partner_edit", FALSE);
00422         childSetAction("partner_help",onClickPartnerHelp,this);
00423         
00424         childSetAction("?",onClickPublishHelp,this);
00425         BOOL own_avatar = (getPanelAvatar()->getAvatarID() == gAgent.getID() );
00426         enableControls(own_avatar);
00427 
00428         childSetVisible("About:",LLPanelAvatar::sAllowFirstLife);
00429         childSetVisible("(500 chars)",LLPanelAvatar::sAllowFirstLife);
00430         childSetVisible("about",LLPanelAvatar::sAllowFirstLife);
00431         
00432         childSetVisible("allow_publish",LLPanelAvatar::sAllowFirstLife);
00433         childSetVisible("?",LLPanelAvatar::sAllowFirstLife);
00434 
00435         childSetVisible("online_yes",FALSE);
00436 
00437         // These are cruft but may still exist in some xml files
00438         // TODO: remove the following 2 lines once translators grab these changes
00439         childSetVisible("online_unknown",FALSE);
00440         childSetVisible("online_no",FALSE);
00441 
00442         childSetAction("Find on Map", LLPanelAvatar::onClickTrack, getPanelAvatar());
00443         childSetAction("Instant Message...", LLPanelAvatar::onClickIM, getPanelAvatar());
00444         
00445         childSetAction("Add Friend...", LLPanelAvatar::onClickAddFriend, getPanelAvatar());
00446         childSetAction("Pay...", LLPanelAvatar::onClickPay, getPanelAvatar());
00447         childSetAction("Mute", LLPanelAvatar::onClickMute, getPanelAvatar() );  
00448 
00449         childSetAction("Offer Teleport...", LLPanelAvatar::onClickOfferTeleport, 
00450                 getPanelAvatar() );
00451 
00452         childSetDoubleClickCallback("groups", onDoubleClickGroup, this );
00453 
00454         return TRUE;
00455 }
00456 
00457 BOOL LLPanelAvatarFirstLife::postBuild(void)
00458 {
00459         BOOL own_avatar = (getPanelAvatar()->getAvatarID() == gAgent.getID() );
00460         enableControls(own_avatar);
00461         return TRUE;
00462 }
00463 
00464 BOOL LLPanelAvatarNotes::postBuild(void)
00465 {
00466         childSetCommitCallback("notes edit",onCommitNotes,this);
00467         
00468         LLTextEditor*   te = LLUICtrlFactory::getTextEditorByName(this,"notes edit");
00469         if(te) te->setCommitOnFocusLost(TRUE);
00470         return TRUE;
00471 }
00472 
00473 BOOL LLPanelAvatarWeb::postBuild(void)
00474 {
00475         childSetAction("load",onClickLoad,this);
00476         childSetAction("open",onClickOpen,this);
00477         childSetAction("home",onClickLoad,this);
00478         childSetAction("web_profile_help",onClickWebProfileHelp,this);
00479 
00480         childSetCommitCallback("url_edit",onCommitURL,this);
00481 
00482         childSetControlName("auto_load","AutoLoadWebProfiles");
00483 
00484 #if LL_LIBXUL_ENABLED
00485         mWebBrowser = (LLWebBrowserCtrl*)getChildByName("profile_html");
00486 
00487         // links open in internally 
00488         mWebBrowser->setOpenInExternalBrowser( false );
00489 
00490         // observe browser events
00491         mWebBrowser->addObserver( this );
00492 #endif // LL_LIBXUL_ENABLED
00493 
00494         return TRUE;
00495 }
00496 
00497 BOOL LLPanelAvatarClassified::postBuild(void)
00498 {
00499         childSetAction("New...",onClickNew,NULL);
00500         childSetAction("Delete...",onClickDelete,NULL);
00501         return TRUE;
00502 }
00503 
00504 BOOL LLPanelAvatarPicks::postBuild(void)
00505 {
00506         childSetAction("New...",onClickNew,NULL);
00507         childSetAction("Delete...",onClickDelete,NULL);
00508         return TRUE;
00509 }
00510 
00511 BOOL LLPanelAvatarAdvanced::postBuild()
00512 {
00513         for(size_t ii = 0; ii < kArraySize(mWantToCheck); ++ii)
00514                 mWantToCheck[ii] = NULL;
00515         for(size_t ii = 0; ii < kArraySize(mSkillsCheck); ++ii)
00516                 mSkillsCheck[ii] = NULL;
00517         mWantToCount = (8>kArraySize(mWantToCheck))?kArraySize(mWantToCheck):8;
00518         for(S32 tt=0; tt < mWantToCount; ++tt)
00519         {       
00520                 LLString ctlname = llformat("chk%d", tt);
00521                 mWantToCheck[tt] = LLUICtrlFactory::getCheckBoxByName(this,ctlname);
00522         }       
00523         mSkillsCount = (6>kArraySize(mSkillsCheck))?kArraySize(mSkillsCheck):6;
00524 
00525         for(S32 tt=0; tt < mSkillsCount; ++tt)
00526         {
00527                 //Find the Skills checkboxes and save off thier controls
00528                 LLString ctlname = llformat("schk%d",tt);
00529                 mSkillsCheck[tt] = LLUICtrlFactory::getCheckBoxByName(this,ctlname);
00530         }
00531 
00532         mWantToEdit = LLUICtrlFactory::getLineEditorByName(this,"want_to_edit");
00533         mSkillsEdit = LLUICtrlFactory::getLineEditorByName(this,"skills_edit");
00534         childSetVisible("skills_edit",LLPanelAvatar::sAllowFirstLife);
00535         childSetVisible("want_to_edit",LLPanelAvatar::sAllowFirstLife);
00536 
00537         return TRUE;
00538 }
00539 
00540 //-----------------------------------------------------------------------------
00541 // LLPanelAvatarWeb
00542 //-----------------------------------------------------------------------------
00543 LLPanelAvatarWeb::LLPanelAvatarWeb(const std::string& name, const LLRect& rect, 
00544                                                                    LLPanelAvatar* panel_avatar)
00545 :       LLPanelAvatarTab(name, rect, panel_avatar),
00546         mWebBrowser(NULL)
00547 {
00548 }
00549 
00550 LLPanelAvatarWeb::~LLPanelAvatarWeb()
00551 {
00552 #if LL_LIBXUL_ENABLED
00553         // stop observing browser events
00554         if  ( mWebBrowser )
00555         {
00556                 mWebBrowser->remObserver( this );
00557         };
00558 #endif
00559 }
00560 
00561 void LLPanelAvatarWeb::enableControls(BOOL self)
00562 {       
00563         childSetEnabled("url_edit",self);
00564         childSetVisible("status_text",!self);
00565 }
00566 
00567 void LLPanelAvatarWeb::setWebURL(std::string url)
00568 {
00569         bool changed_url = (mURL != url);
00570 
00571         mURL = url;
00572         bool have_url = !mURL.empty();
00573         
00574         childSetText("url_edit",mURL);
00575 
00576         childSetEnabled("load",have_url);
00577         childSetEnabled("open",have_url);
00578 
00579         childSetVisible("home",false);
00580         childSetVisible("load",true);
00581 
00582         if (have_url
00583                 && gSavedSettings.getBOOL("AutoLoadWebProfiles"))
00584         {
00585                 if (changed_url)
00586                 {
00587                         load();
00588                 }
00589         }
00590         else
00591         {
00592                 childSetVisible("profile_html",false);
00593         }
00594         
00595 #if !LL_LIBXUL_ENABLED
00596         childSetVisible("load",false);
00597         childSetVisible("profile_html",false);
00598         childSetVisible("status_text",false);
00599 #endif
00600 
00601 }
00602 
00603 // static
00604 void LLPanelAvatarWeb::onCommitURL(LLUICtrl* ctrl, void* data)
00605 {
00606         LLPanelAvatarWeb* self = (LLPanelAvatarWeb*)data;
00607 
00608         if (!self) return;
00609         
00610         self->load( self->childGetText("url_edit") );
00611 }
00612 
00613 // static
00614 void LLPanelAvatarWeb::onClickWebProfileHelp(void *)
00615 {
00616 #if LL_LIBXUL_ENABLED
00617         gViewerWindow->alertXml("ClickWebProfileHelpAvatar");
00618 #else
00619         gViewerWindow->alertXml("ClickWebProfileNoWebHelpAvatar");
00620 #endif
00621 }
00622 
00623 void LLPanelAvatarWeb::load(std::string url)
00624 {
00625         bool have_url = (!url.empty());
00626 
00627 #if LL_LIBXUL_ENABLED
00628         if (have_url)
00629         {
00630                 llinfos << "Loading " << url << llendl;
00631                 mWebBrowser->navigateTo( url );
00632         }
00633 
00634         // If we have_url then we loaded so use the home button
00635         // Or if the url in address bar is not the home url show the home button.
00636         bool use_home = (have_url
00637                                          || url != mURL);
00638                                          
00639         childSetVisible("profile_html",have_url);
00640         childSetVisible("load",!use_home);      
00641         childSetVisible("home",use_home);
00642 
00643         childSetEnabled("load",!use_home);
00644         childSetEnabled("home",use_home);
00645         childSetEnabled("open",have_url);
00646         
00647 #else
00648         childSetEnabled("open",have_url);
00649 #endif
00650 }
00651 
00652 void LLPanelAvatarWeb::load()
00653 {
00654         load(mURL);
00655 }
00656 
00657 // static
00658 void LLPanelAvatarWeb::onClickLoad(void* data)
00659 {
00660         LLPanelAvatarWeb* self = (LLPanelAvatarWeb*)data;
00661 
00662         if (!self) return;
00663         
00664         self->load();
00665 }
00666 
00667 // static
00668 void LLPanelAvatarWeb::onClickOpen(void* data)
00669 {
00670         LLPanelAvatarWeb* self = (LLPanelAvatarWeb*)data;
00671 
00672         if (!self) return;
00673 
00674         std::string url = self->childGetText("url_edit");
00675         if (!url.empty())
00676         {
00677                 LLWeb::loadURLExternal(url);
00678         }
00679 }
00680 
00681 #if LL_LIBXUL_ENABLED
00682 void LLPanelAvatarWeb::onStatusTextChange( const EventType& eventIn )
00683 {
00684         childSetText("status_text", eventIn.getStringValue() );
00685 }
00686 
00687 void LLPanelAvatarWeb::onLocationChange( const EventType& eventIn )
00688 {
00689         childSetText("url_edit", eventIn.getStringValue() );
00690 }
00691 #endif
00692 
00693 
00694 //-----------------------------------------------------------------------------
00695 // LLPanelAvatarAdvanced
00696 //-----------------------------------------------------------------------------
00697 LLPanelAvatarAdvanced::LLPanelAvatarAdvanced(const std::string& name, 
00698                                                                                          const LLRect& rect, 
00699                                                                                          LLPanelAvatar* panel_avatar)
00700 :       LLPanelAvatarTab(name, rect, panel_avatar),
00701         mWantToCount(0),
00702         mSkillsCount(0),
00703         mWantToEdit( NULL ),
00704         mSkillsEdit( NULL )
00705 {
00706 }
00707 
00708 void LLPanelAvatarAdvanced::enableControls(BOOL self)
00709 {
00710         S32 t;
00711         for(t=0;t<mWantToCount;t++)
00712         {
00713                 if(mWantToCheck[t])mWantToCheck[t]->setEnabled(self);
00714         }
00715         for(t=0;t<mSkillsCount;t++)
00716         {
00717                 if(mSkillsCheck[t])mSkillsCheck[t]->setEnabled(self);
00718         }
00719 
00720         if (mWantToEdit) mWantToEdit->setEnabled(self);
00721         if (mSkillsEdit) mSkillsEdit->setEnabled(self);
00722         childSetEnabled("languages_edit",self);
00723 
00724         if (!self)
00725         {
00726                 // This is because the LLTextEditor
00727                 // appears to reset the read only background color when
00728                 // setEnable is called, for some reason
00729                 if (mWantToEdit) mWantToEdit->setReadOnlyBgColor(LLColor4::transparent);
00730                 if (mSkillsEdit) mSkillsEdit->setReadOnlyBgColor(LLColor4::transparent);
00731                 LLLineEditor* languages_edit = (LLLineEditor*)getChildByName("languages_edit");
00732                 languages_edit->setReadOnlyBgColor(LLColor4::transparent);
00733         }
00734 }
00735 
00736 void LLPanelAvatarAdvanced::setWantSkills(U32 want_to_mask, const std::string& want_to_text,
00737                                                                                   U32 skills_mask, const std::string& skills_text,
00738                                                                                   const std::string& languages_text)
00739 {
00740         for(int id =0;id<mWantToCount;id++)
00741         {
00742                 mWantToCheck[id]->set( want_to_mask & 1<<id );
00743         }
00744         for(int id =0;id<mSkillsCount;id++)
00745         {
00746                 mSkillsCheck[id]->set( skills_mask & 1<<id );
00747         }
00748         if (mWantToEdit && mSkillsEdit)
00749         {
00750                 mWantToEdit->setText( want_to_text );
00751                 mSkillsEdit->setText( skills_text );
00752         }
00753 
00754         childSetText("languages_edit",languages_text);
00755 }
00756 
00757 void LLPanelAvatarAdvanced::getWantSkills(U32* want_to_mask, std::string& want_to_text,
00758                                                                                   U32* skills_mask, std::string& skills_text,
00759                                                                                   std::string& languages_text)
00760 {
00761         if (want_to_mask)
00762         {
00763                 *want_to_mask = 0;
00764                 for(int t=0;t<mWantToCount;t++)
00765                 {
00766                         if(mWantToCheck[t]->get())
00767                                 *want_to_mask |= 1<<t;
00768                 }
00769         }
00770         if (skills_mask)
00771         {
00772                 *skills_mask = 0;
00773                 for(int t=0;t<mSkillsCount;t++)
00774                 {
00775                         if(mSkillsCheck[t]->get())
00776                                 *skills_mask |= 1<<t;
00777                 }
00778         }
00779         if (mWantToEdit)
00780         {
00781                 want_to_text = mWantToEdit->getText();
00782         }
00783 
00784         if (mSkillsEdit)
00785         {
00786                 skills_text = mSkillsEdit->getText();
00787         }
00788 
00789         languages_text = childGetText("languages_edit");
00790 }       
00791 
00792 //-----------------------------------------------------------------------------
00793 // LLPanelAvatarNotes()
00794 //-----------------------------------------------------------------------------
00795 LLPanelAvatarNotes::LLPanelAvatarNotes(const std::string& name, const LLRect& rect, LLPanelAvatar* panel_avatar)
00796 :       LLPanelAvatarTab(name, rect, panel_avatar)
00797 {
00798 }
00799 
00800 void LLPanelAvatarNotes::refresh()
00801 {
00802         sendAvatarProfileRequestIfNeeded("avatarnotesrequest");
00803 }
00804 
00805 void LLPanelAvatarNotes::clearControls()
00806 {
00807         childSetText("notes edit", childGetText("Loading"));
00808         childSetEnabled("notes edit", false);
00809 }
00810 
00811 // static
00812 void LLPanelAvatarNotes::onCommitNotes(LLUICtrl*, void* userdata)
00813 {
00814         LLPanelAvatarNotes* self = (LLPanelAvatarNotes*)userdata;
00815 
00816         self->getPanelAvatar()->sendAvatarNotesUpdate();
00817 }
00818 
00819 
00820 //-----------------------------------------------------------------------------
00821 // LLPanelAvatarClassified()
00822 //-----------------------------------------------------------------------------
00823 LLPanelAvatarClassified::LLPanelAvatarClassified(const LLString& name, const LLRect& rect,
00824                                                                            LLPanelAvatar* panel_avatar)
00825 :       LLPanelAvatarTab(name, rect, panel_avatar)
00826 {
00827 }
00828 
00829 
00830 void LLPanelAvatarClassified::refresh()
00831 {
00832         BOOL self = (gAgent.getID() == getPanelAvatar()->getAvatarID());
00833         
00834         LLTabContainerCommon* tabs = LLUICtrlFactory::getTabContainerByName(this,"classified tab");
00835         
00836         S32 tab_count = tabs ? tabs->getTabCount() : 0;
00837 
00838         bool allow_new = tab_count < MAX_CLASSIFIEDS;
00839         bool allow_delete = (tab_count > 0);
00840         bool show_help = (tab_count == 0);
00841 
00842         // *HACK: Don't allow making new classifieds from inside the directory.
00843         // The logic for save/don't save when closing is too hairy, and the 
00844         // directory is conceptually read-only. JC
00845         bool in_directory = false;
00846         LLView* view = this;
00847         while (view)
00848         {
00849                 if (view->getName() == "directory")
00850                 {
00851                         in_directory = true;
00852                         break;
00853                 }
00854                 view = view->getParent();
00855         }
00856         childSetEnabled("New...", self && !in_directory && allow_new);
00857         childSetVisible("New...", !in_directory);
00858         childSetEnabled("Delete...", self && !in_directory && allow_delete);
00859         childSetVisible("Delete...", !in_directory);
00860         childSetVisible("classified tab",!show_help);
00861 
00862         sendAvatarProfileRequestIfNeeded("avatarclassifiedsrequest");
00863 }
00864 
00865 
00866 BOOL LLPanelAvatarClassified::canClose()
00867 {
00868         LLTabContainerCommon* tabs = LLViewerUICtrlFactory::getTabContainerByName(this, "classified tab");
00869         for (S32 i = 0; i < tabs->getTabCount(); i++)
00870         {
00871                 LLPanelClassified* panel = (LLPanelClassified*)tabs->getPanelByIndex(i);
00872                 if (!panel->canClose())
00873                 {
00874                         return FALSE;
00875                 }
00876         }
00877         return TRUE;
00878 }
00879 
00880 BOOL LLPanelAvatarClassified::titleIsValid()
00881 {
00882         LLTabContainerCommon* tabs = LLViewerUICtrlFactory::getTabContainerByName(this, "classified tab");
00883         if ( tabs )
00884         {
00885                 LLPanelClassified* panel = (LLPanelClassified*)tabs->getCurrentPanel();
00886                 if ( panel )
00887                 {
00888                         if ( ! panel->titleIsValid() )
00889                         {
00890                                 return FALSE;
00891                         };
00892                 };
00893         };
00894 
00895         return TRUE;
00896 }
00897 
00898 void LLPanelAvatarClassified::apply()
00899 {
00900         LLTabContainerCommon* tabs = LLViewerUICtrlFactory::getTabContainerByName(this, "classified tab");
00901         for (S32 i = 0; i < tabs->getTabCount(); i++)
00902         {
00903                 LLPanelClassified* panel = (LLPanelClassified*)tabs->getPanelByIndex(i);
00904                 panel->apply();
00905         }
00906 }
00907 
00908 
00909 void LLPanelAvatarClassified::deleteClassifiedPanels()
00910 {
00911         LLTabContainerCommon* tabs = LLViewerUICtrlFactory::getTabContainerByName(this,"classified tab");
00912         if (tabs)
00913         {
00914                 tabs->deleteAllTabs();
00915         }
00916 
00917         childSetVisible("New...", false);
00918         childSetVisible("Delete...", false);
00919         childSetVisible("loading_text", true);
00920 }
00921 
00922 
00923 void LLPanelAvatarClassified::processAvatarClassifiedReply(LLMessageSystem* msg, void**)
00924 {
00925         S32 block = 0;
00926         S32 block_count = 0;
00927         LLUUID classified_id;
00928         char classified_name[DB_PICK_NAME_SIZE];                /*Flawfinder: ignore*/
00929         LLPanelClassified* panel_classified = NULL;
00930 
00931         LLTabContainerCommon* tabs = LLViewerUICtrlFactory::getTabContainerByName(this,"classified tab");
00932 
00933         // Don't remove old panels.  We need to be able to process multiple
00934         // packets for people who have lots of classifieds. JC
00935 
00936         block_count = msg->getNumberOfBlocksFast(_PREHASH_Data);
00937         for (block = 0; block < block_count; block++)
00938         {
00939                 msg->getUUIDFast(_PREHASH_Data, _PREHASH_ClassifiedID, classified_id, block);
00940                 msg->getStringFast(_PREHASH_Data, _PREHASH_Name, DB_PICK_NAME_SIZE, classified_name, block);
00941 
00942                 panel_classified = new LLPanelClassified(FALSE);
00943 
00944                 panel_classified->setClassifiedID(classified_id);
00945 
00946                 // This will request data from the server when the pick is first drawn.
00947                 panel_classified->markForServerRequest();
00948 
00949                 // The button should automatically truncate long names for us
00950                 if(tabs)
00951                 {
00952                         tabs->addTabPanel(panel_classified, classified_name);
00953                 }
00954         }
00955 
00956         // Make sure somebody is highlighted.  This works even if there
00957         // are no tabs in the container.
00958         if(tabs)
00959         {
00960                 tabs->selectFirstTab();
00961         }
00962 
00963         childSetVisible("New...", true);
00964         childSetVisible("Delete...", true);
00965         childSetVisible("loading_text", false);
00966 }
00967 
00968 
00969 // Create a new classified panel.  It will automatically handle generating
00970 // its own id when it's time to save.
00971 // static
00972 void LLPanelAvatarClassified::onClickNew(void* data)
00973 {
00974         LLPanelAvatarClassified* self = (LLPanelAvatarClassified*)data;
00975 
00976         gViewerWindow->alertXml("AddClassified",callbackNew,self);
00977                 
00978 }
00979 
00980 // static
00981 void LLPanelAvatarClassified::callbackNew(S32 option, void* data)
00982 {
00983         LLPanelAvatarClassified* self = (LLPanelAvatarClassified*)data;
00984 
00985         if (0 == option)
00986         {
00987                 LLPanelClassified* panel_classified = new LLPanelClassified(FALSE);
00988                 panel_classified->initNewClassified();
00989                 LLTabContainerCommon*   tabs = LLViewerUICtrlFactory::getTabContainerByName(self,"classified tab");
00990                 if(tabs)
00991                 {
00992                         tabs->addTabPanel(panel_classified, panel_classified->getClassifiedName());
00993                         tabs->selectLastTab();
00994                 }
00995         }
00996 }
00997 
00998 
00999 // static
01000 void LLPanelAvatarClassified::onClickDelete(void* data)
01001 {
01002         LLPanelAvatarClassified* self = (LLPanelAvatarClassified*)data;
01003 
01004         LLTabContainerCommon*   tabs = LLViewerUICtrlFactory::getTabContainerByName(self,"classified tab");
01005         LLPanelClassified* panel_classified = NULL;
01006         if(tabs)
01007         {
01008                 panel_classified = (LLPanelClassified*)tabs->getCurrentPanel();
01009         }
01010         if (!panel_classified) return;
01011 
01012         LLStringBase<char>::format_map_t args;
01013         args["[NAME]"] = panel_classified->getClassifiedName();
01014         gViewerWindow->alertXml("DeleteClassified", args, callbackDelete, self);
01015                 
01016 }
01017 
01018 
01019 // static
01020 void LLPanelAvatarClassified::callbackDelete(S32 option, void* data)
01021 {
01022         LLPanelAvatarClassified* self = (LLPanelAvatarClassified*)data;
01023         LLTabContainerCommon*   tabs = LLViewerUICtrlFactory::getTabContainerByName(self,"classified tab");
01024         LLPanelClassified* panel_classified=NULL;
01025         if(tabs)
01026         {
01027                 panel_classified = (LLPanelClassified*)tabs->getCurrentPanel();
01028         }
01029         
01030         LLMessageSystem* msg = gMessageSystem;
01031 
01032         if (!panel_classified) return;
01033 
01034         if (0 == option)
01035         {
01036                 msg->newMessageFast(_PREHASH_ClassifiedDelete);
01037                 msg->nextBlockFast(_PREHASH_AgentData);
01038                 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
01039                 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
01040                 msg->nextBlockFast(_PREHASH_Data);
01041                 msg->addUUIDFast(_PREHASH_ClassifiedID, panel_classified->getClassifiedID());
01042                 gAgent.sendReliableMessage();
01043 
01044                 if(tabs)
01045                 {
01046                         tabs->removeTabPanel(panel_classified);
01047                 }
01048                 delete panel_classified;
01049                 panel_classified = NULL;
01050         }
01051 }
01052 
01053 
01054 //-----------------------------------------------------------------------------
01055 // LLPanelAvatarPicks()
01056 //-----------------------------------------------------------------------------
01057 LLPanelAvatarPicks::LLPanelAvatarPicks(const std::string& name, 
01058                                                                            const LLRect& rect,
01059                                                                            LLPanelAvatar* panel_avatar)
01060 :       LLPanelAvatarTab(name, rect, panel_avatar)
01061 {
01062 }
01063 
01064 
01065 void LLPanelAvatarPicks::refresh()
01066 {
01067         BOOL self = (gAgent.getID() == getPanelAvatar()->getAvatarID());
01068 
01069         LLTabContainerCommon*   tabs = LLViewerUICtrlFactory::getTabContainerByName(this,"picks tab");
01070         S32 tab_count = tabs ? tabs->getTabCount() : 0;
01071         BOOL allow_new = (tab_count < MAX_AVATAR_PICKS);
01072         BOOL allow_delete = (tab_count > 0);
01073 
01074         childSetEnabled("New...",self && allow_new);
01075         childSetEnabled("Delete...",self && allow_delete);
01076 
01077         sendAvatarProfileRequestIfNeeded("avatarpicksrequest");
01078 }
01079 
01080 
01081 void LLPanelAvatarPicks::deletePickPanels()
01082 {
01083         LLTabContainerCommon* tabs = LLUICtrlFactory::getTabContainerByName(this,"picks tab");
01084         if(tabs)
01085         {
01086                 tabs->deleteAllTabs();
01087         }
01088 
01089         childSetVisible("New...", false);
01090         childSetVisible("Delete...", false);
01091         childSetVisible("loading_text", true);
01092 }
01093 
01094 void LLPanelAvatarPicks::processAvatarPicksReply(LLMessageSystem* msg, void**)
01095 {
01096         S32 block = 0;
01097         S32 block_count = 0;
01098         LLUUID pick_id;
01099         char pick_name[DB_PICK_NAME_SIZE];              /*Flawfinder: ignore*/
01100         LLPanelPick* panel_pick = NULL;
01101 
01102         LLTabContainerCommon* tabs =  LLUICtrlFactory::getTabContainerByName(this,"picks tab");
01103 
01104         // Clear out all the old panels.  We'll replace them with the correct
01105         // number of new panels.
01106         deletePickPanels();
01107 
01108         // The database needs to know for which user to look up picks.
01109         LLUUID avatar_id = getPanelAvatar()->getAvatarID();
01110         
01111         block_count = msg->getNumberOfBlocks("Data");
01112         for (block = 0; block < block_count; block++)
01113         {
01114                 msg->getUUID("Data", "PickID", pick_id, block);
01115                 msg->getString("Data", "PickName", DB_PICK_NAME_SIZE, pick_name, block);
01116 
01117                 panel_pick = new LLPanelPick(FALSE);
01118 
01119                 panel_pick->setPickID(pick_id, avatar_id);
01120 
01121                 // This will request data from the server when the pick is first
01122                 // drawn.
01123                 panel_pick->markForServerRequest();
01124 
01125                 // The button should automatically truncate long names for us
01126                 if(tabs)
01127                 {
01128                         tabs->addTabPanel(panel_pick, pick_name);
01129                 }
01130         }
01131 
01132         // Make sure somebody is highlighted.  This works even if there
01133         // are no tabs in the container.
01134         if(tabs)
01135         {
01136                 tabs->selectFirstTab();
01137         }
01138 
01139         childSetVisible("New...", true);
01140         childSetVisible("Delete...", true);
01141         childSetVisible("loading_text", false);
01142 }
01143 
01144 
01145 // Create a new pick panel.  It will automatically handle generating
01146 // its own id when it's time to save.
01147 // static
01148 void LLPanelAvatarPicks::onClickNew(void* data)
01149 {
01150         LLPanelAvatarPicks* self = (LLPanelAvatarPicks*)data;
01151         LLPanelPick* panel_pick = new LLPanelPick(FALSE);
01152         LLTabContainerCommon* tabs =  LLUICtrlFactory::getTabContainerByName(self,"picks tab");
01153 
01154         panel_pick->initNewPick();
01155         if(tabs)
01156         {
01157                 tabs->addTabPanel(panel_pick, panel_pick->getPickName());
01158                 tabs->selectLastTab();
01159         }
01160 }
01161 
01162 
01163 // static
01164 void LLPanelAvatarPicks::onClickDelete(void* data)
01165 {
01166         LLPanelAvatarPicks* self = (LLPanelAvatarPicks*)data;
01167         LLTabContainerCommon* tabs =  LLUICtrlFactory::getTabContainerByName(self,"picks tab");
01168         LLPanelPick* panel_pick = tabs?(LLPanelPick*)tabs->getCurrentPanel():NULL;
01169 
01170         if (!panel_pick) return;
01171 
01172         LLString::format_map_t args;
01173         args["[PICK]"] = panel_pick->getPickName();
01174 
01175         gViewerWindow->alertXml("DeleteAvatarPick", args,
01176                 callbackDelete,
01177                 self);
01178 }
01179 
01180 
01181 // static
01182 void LLPanelAvatarPicks::callbackDelete(S32 option, void* data)
01183 {
01184         LLPanelAvatarPicks* self = (LLPanelAvatarPicks*)data;
01185         LLTabContainerCommon* tabs = LLUICtrlFactory::getTabContainerByName(self,"picks tab");
01186         LLPanelPick* panel_pick = tabs?(LLPanelPick*)tabs->getCurrentPanel():NULL;
01187         LLMessageSystem* msg = gMessageSystem;
01188 
01189         if (!panel_pick) return;
01190 
01191         if (0 == option)
01192         {
01193                 // If the viewer has a hacked god-mode, then this call will
01194                 // fail.
01195                 if(gAgent.isGodlike())
01196                 {
01197                         msg->newMessage("PickGodDelete");                       
01198                         msg->nextBlock("AgentData");
01199                         msg->addUUID("AgentID", gAgent.getID());
01200                         msg->addUUID("SessionID", gAgent.getSessionID());
01201                         msg->nextBlock("Data");
01202                         msg->addUUID("PickID", panel_pick->getPickID());
01203                         // *HACK: We need to send the pick's creator id to accomplish
01204                         // the delete, and we don't use the query id for anything. JC
01205                         msg->addUUID( "QueryID", panel_pick->getPickCreatorID() );
01206                 }
01207                 else
01208                 {
01209                         msg->newMessage("PickDelete");
01210                         msg->nextBlock("AgentData");
01211                         msg->addUUID("AgentID", gAgent.getID());
01212                         msg->addUUID("SessionID", gAgent.getSessionID());
01213                         msg->nextBlock("Data");
01214                         msg->addUUID("PickID", panel_pick->getPickID());
01215                 }
01216                 gAgent.sendReliableMessage();
01217 
01218                 if(tabs)
01219                 {
01220                         tabs->removeTabPanel(panel_pick);
01221                 }
01222                 delete panel_pick;
01223                 panel_pick = NULL;
01224         }
01225 }
01226 
01227 
01228 //-----------------------------------------------------------------------------
01229 // LLPanelAvatar
01230 //-----------------------------------------------------------------------------
01231 LLPanelAvatar::LLPanelAvatar(
01232         const std::string& name,
01233         const LLRect &rect,
01234         BOOL allow_edit)
01235         :
01236         LLPanel(name, rect, FALSE),
01237         mPanelSecondLife(NULL),
01238         mPanelAdvanced(NULL),
01239         mPanelClassified(NULL),
01240         mPanelPicks(NULL),
01241         mPanelNotes(NULL),
01242         mPanelFirstLife(NULL),
01243         mPanelWeb(NULL),
01244         mDropTarget(NULL),
01245         mAvatarID( LLUUID::null ),      // mAvatarID is set with 'setAvatar' or 'setAvatarID'
01246         mHaveProperties(FALSE),
01247         mHaveStatistics(FALSE),
01248         mHaveNotes(false),
01249         mLastNotes(),
01250         mAllowEdit(allow_edit)
01251 {
01252 
01253         sAllPanels.push_back(this);
01254 
01255         LLCallbackMap::map_t factory_map;
01256 
01257         factory_map["2nd Life"] = LLCallbackMap(createPanelAvatarSecondLife, this);
01258         factory_map["WebProfile"] = LLCallbackMap(createPanelAvatarWeb, this);
01259         factory_map["Interests"] = LLCallbackMap(createPanelAvatarInterests, this);
01260         factory_map["Picks"] = LLCallbackMap(createPanelAvatarPicks, this);
01261         factory_map["Classified"] = LLCallbackMap(createPanelAvatarClassified, this);
01262         factory_map["1st Life"] = LLCallbackMap(createPanelAvatarFirstLife, this);
01263         factory_map["My Notes"] = LLCallbackMap(createPanelAvatarNotes, this);
01264         
01265         gUICtrlFactory->buildPanel(this, "panel_avatar.xml", &factory_map);
01266 
01267         selectTab(0);
01268         
01269 
01270 }
01271 
01272 BOOL LLPanelAvatar::postBuild(void)
01273 {
01274         mTab = LLUICtrlFactory::getTabContainerByName(this,"tab");
01275         childSetAction("Kick",onClickKick,this);
01276         childSetAction("Freeze",onClickFreeze, this);
01277         childSetAction("Unfreeze", onClickUnfreeze, this);
01278         childSetAction("csr_btn", onClickCSR, this);
01279         childSetAction("OK", onClickOK, this);
01280         childSetAction("Cancel", onClickCancel, this);
01281 
01282         if(mTab && !sAllowFirstLife)
01283         {
01284                 LLPanel* panel = mTab->getPanelByName("1st Life");
01285                 if (panel) mTab->removeTabPanel(panel);
01286 
01287                 panel = mTab->getPanelByName("WebProfile");
01288                 if (panel) mTab->removeTabPanel(panel);
01289         }
01290         childSetVisible("Kick",FALSE);
01291         childSetEnabled("Kick",FALSE);
01292         childSetVisible("Freeze",FALSE);
01293         childSetEnabled("Freeze",FALSE);
01294         childSetVisible("Unfreeze",FALSE);
01295         childSetEnabled("Unfreeze",FALSE);
01296         childSetVisible("csr_btn", FALSE);
01297         childSetEnabled("csr_btn", FALSE);
01298 
01299         return TRUE;
01300 }
01301 
01302 
01303 LLPanelAvatar::~LLPanelAvatar()
01304 {
01305         sAllPanels.remove(this);
01306 }
01307 
01308 
01309 BOOL LLPanelAvatar::canClose()
01310 {
01311         return mPanelClassified && mPanelClassified->canClose();
01312 }
01313 
01314 void LLPanelAvatar::setAvatar(LLViewerObject *avatarp)
01315 {
01316         // find the avatar and grab the name
01317         LLNameValue *firstname = avatarp->getNVPair("FirstName");
01318         LLNameValue *lastname = avatarp->getNVPair("LastName");
01319 
01320         LLString name;
01321         if (firstname && lastname)
01322         {
01323                 name.assign( firstname->getString() );
01324                 name.append(" ");
01325                 name.append( lastname->getString() );
01326         }
01327         else
01328         {
01329                 name.assign("");
01330         }
01331 
01332         // If we have an avatar pointer, they must be online.
01333         setAvatarID(avatarp->getID(), name, ONLINE_STATUS_YES);
01334 }
01335 
01336 void LLPanelAvatar::setOnlineStatus(EOnlineStatus online_status)
01337 {
01338         // Online status NO could be because they are hidden
01339         // If they are a friend, we may know the truth!
01340         if ((ONLINE_STATUS_YES != online_status)
01341                 && mIsFriend
01342                 && (LLAvatarTracker::instance().isBuddyOnline( mAvatarID )))
01343         {
01344                 online_status = ONLINE_STATUS_YES;
01345         }
01346 
01347         mPanelSecondLife->childSetVisible("online_yes", (online_status == ONLINE_STATUS_YES));
01348 
01349         // Since setOnlineStatus gets called after setAvatarID
01350         // need to make sure that "Offer Teleport" doesn't get set
01351         // to TRUE again for yourself
01352         if (mAvatarID != gAgent.getID())
01353         {
01354                 childSetVisible("Offer Teleport...",TRUE);
01355         }
01356 
01357         BOOL in_prelude = gAgent.inPrelude();
01358         if(gAgent.isGodlike())
01359         {
01360                 childSetEnabled("Offer Teleport...", TRUE);
01361                 childSetToolTip("Offer Teleport...", childGetValue("TeleportGod").asString());
01362         }
01363         else if (in_prelude)
01364         {
01365                 childSetEnabled("Offer Teleport...",FALSE);
01366                 childSetToolTip("Offer Teleport...",childGetValue("TeleportPrelude").asString());
01367         }
01368         else
01369         {
01370                 childSetEnabled("Offer Teleport...", (online_status == ONLINE_STATUS_YES));
01371                 childSetToolTip("Offer Teleport...", childGetValue("TeleportNormal").asString());
01372         }
01373 }
01374 
01375 void LLPanelAvatar::setAvatarID(const LLUUID &avatar_id, const LLString &name,
01376                                                                 EOnlineStatus online_status)
01377 {
01378         if (avatar_id.isNull()) return;
01379 
01380         BOOL avatar_changed = FALSE;
01381         if (avatar_id != mAvatarID)
01382         {
01383                 avatar_changed = TRUE;
01384         }
01385         mAvatarID = avatar_id;
01386 
01387         // Determine if we have their calling card.
01388         mIsFriend = is_agent_friend(mAvatarID); 
01389 
01390         // setOnlineStatus uses mIsFriend
01391         setOnlineStatus(online_status);
01392         
01393         BOOL own_avatar = (mAvatarID == gAgent.getID() );
01394         BOOL avatar_is_friend = LLAvatarTracker::instance().getBuddyInfo(mAvatarID) != NULL;
01395 
01396         mPanelSecondLife->enableControls(own_avatar && mAllowEdit);
01397         mPanelWeb->enableControls(own_avatar && mAllowEdit);
01398         mPanelAdvanced->enableControls(own_avatar && mAllowEdit);
01399         // Teens don't have this.
01400         if (mPanelFirstLife) mPanelFirstLife->enableControls(own_avatar && mAllowEdit);
01401 
01402         LLView *target_view = getChildByName("drop_target_rect", TRUE);
01403         if(target_view)
01404         {
01405                 if (mDropTarget)
01406                 {
01407                         delete mDropTarget;
01408                 }
01409                 mDropTarget = new LLDropTarget("drop target", target_view->getRect(), mAvatarID);
01410                 addChild(mDropTarget);
01411                 mDropTarget->setAgentID(mAvatarID);
01412         }
01413 
01414         LLNameEditor* name_edit = LLViewerUICtrlFactory::getNameEditorByName(this, "name");
01415         if(name_edit)
01416         {
01417                 if (name.empty())
01418                 {
01419                         name_edit->setNameID(avatar_id, FALSE);
01420                 }
01421                 else
01422                 {
01423                         name_edit->setText(name);
01424                 }
01425         }
01426 //      if (avatar_changed)
01427         {
01428                 // While we're waiting for data off the network, clear out the
01429                 // old data.
01430                 mPanelSecondLife->clearControls();
01431 
01432                 mPanelPicks->deletePickPanels();
01433                 mPanelPicks->setDataRequested(false);
01434 
01435                 mPanelClassified->deleteClassifiedPanels();
01436                 mPanelClassified->setDataRequested(false);
01437 
01438                 mPanelNotes->clearControls();
01439                 mPanelNotes->setDataRequested(false);
01440                 mHaveNotes = false;
01441                 mLastNotes.clear();
01442 
01443                 // Request just the first two pages of data.  The picks,
01444                 // classifieds, and notes will be requested when that panel
01445                 // is made visible. JC
01446                 sendAvatarPropertiesRequest();
01447 
01448                 if (own_avatar)
01449                 {
01450                         if (mAllowEdit)
01451                         {
01452                                 // OK button disabled until properties data arrives
01453                                 childSetVisible("OK", true);
01454                                 childSetEnabled("OK", false);
01455                                 childSetVisible("Cancel",TRUE);
01456                                 childSetEnabled("Cancel",TRUE);
01457                         }
01458                         else
01459                         {
01460                                 childSetVisible("OK",FALSE);
01461                                 childSetEnabled("OK",FALSE);
01462                         }
01463                         childSetVisible("Instant Message...",FALSE);
01464                         childSetEnabled("Instant Message...",FALSE);
01465                         childSetVisible("Mute",FALSE);
01466                         childSetEnabled("Mute",FALSE);
01467                         childSetVisible("Offer Teleport...",FALSE);
01468                         childSetEnabled("Offer Teleport...",FALSE);
01469                         childSetVisible("drop target",FALSE);
01470                         childSetEnabled("drop target",FALSE);
01471                         childSetVisible("Find on Map",FALSE);
01472                         childSetEnabled("Find on Map",FALSE);
01473                         childSetVisible("Add Friend...",FALSE);
01474                         childSetEnabled("Add Friend...",FALSE);
01475                         childSetVisible("Pay...",FALSE);
01476                         childSetEnabled("Pay...",FALSE);
01477                 }
01478                 else
01479                 {
01480                         childSetVisible("OK",FALSE);
01481                         childSetEnabled("OK",FALSE);
01482 
01483                         childSetVisible("Cancel",FALSE);
01484                         childSetEnabled("Cancel",FALSE);
01485 
01486                         childSetVisible("Instant Message...",TRUE);
01487                         childSetEnabled("Instant Message...",FALSE);
01488                         childSetVisible("Mute",TRUE);
01489                         childSetEnabled("Mute",FALSE);
01490 
01491                         childSetVisible("drop target",TRUE);
01492                         childSetEnabled("drop target",FALSE);
01493 
01494                         childSetVisible("Find on Map",TRUE);
01495                         // Note: we don't always know online status, so always allow gods to try to track
01496                         BOOL enable_track = gAgent.isGodlike() || is_agent_mappable(mAvatarID);
01497                         childSetEnabled("Find on Map",enable_track);
01498                         if (!mIsFriend)
01499                         {
01500                                 childSetToolTip("Find on Map",childGetValue("ShowOnMapNonFriend").asString());
01501                         }
01502                         else if (ONLINE_STATUS_YES != online_status)
01503                         {
01504                                 childSetToolTip("Find on Map",childGetValue("ShowOnMapFriendOffline").asString());
01505                         }
01506                         else
01507                         {
01508                                 childSetToolTip("Find on Map",childGetValue("ShowOnMapFriendOnline").asString());
01509                         }
01510                         childSetVisible("Add Friend...", true);
01511                         childSetEnabled("Add Friend...", !avatar_is_friend);
01512                         childSetVisible("Pay...",TRUE);
01513                         childSetEnabled("Pay...",FALSE);
01514                 }
01515         }
01516         
01517         BOOL is_god = FALSE;
01518         if (gAgent.isGodlike()) is_god = TRUE;
01519         
01520         childSetVisible("Kick", is_god);
01521         childSetEnabled("Kick", is_god);
01522         childSetVisible("Freeze", is_god);
01523         childSetEnabled("Freeze", is_god);
01524         childSetVisible("Unfreeze", is_god);
01525         childSetEnabled("Unfreeze", is_god);
01526         childSetVisible("csr_btn", is_god);
01527         childSetEnabled("csr_btn", is_god);
01528 }
01529 
01530 
01531 void LLPanelAvatar::resetGroupList()
01532 {
01533         // only get these updates asynchronously via the group floater, which works on the agent only
01534         if (mAvatarID != gAgent.getID())
01535         {
01536                 return;
01537         }
01538                 
01539         if (mPanelSecondLife)
01540         {
01541                 LLScrollListCtrl* group_list = LLUICtrlFactory::getScrollListByName(mPanelSecondLife,"groups");
01542                 if (group_list)
01543                 {
01544                         group_list->deleteAllItems();
01545                         
01546                         S32 count = gAgent.mGroups.count();
01547                         LLUUID id;
01548                         
01549                         for(S32 i = 0; i < count; ++i)
01550                         {
01551                                 LLGroupData group_data = gAgent.mGroups.get(i);
01552                                 id = group_data.mID;
01553                                 std::string group_string;
01554                                 /* Show group title?  DUMMY_POWER for Don Grep
01555                                    if(group_data.mOfficer)
01556                                    {
01557                                    group_string = "Officer of ";
01558                                    }
01559                                    else
01560                                    {
01561                                    group_string = "Member of ";
01562                                    }
01563                                 */
01564 
01565                                 group_string += group_data.mName;
01566 
01567                                 LLSD row;
01568                                 row["columns"][0]["value"] = group_string;
01569                                 row["columns"][0]["font"] = "SANSSERIF_SMALL";
01570                                 row["columns"][0]["width"] = 0;
01571                                 group_list->addElement(row);
01572                         }
01573                         group_list->sortByColumn(0, TRUE);
01574                 }
01575         }
01576 }
01577 
01578 // static
01579 //-----------------------------------------------------------------------------
01580 // onClickIM()
01581 //-----------------------------------------------------------------------------
01582 void LLPanelAvatar::onClickIM(void* userdata)
01583 {
01584         LLPanelAvatar* self = (LLPanelAvatar*) userdata;
01585         gIMMgr->setFloaterOpen(TRUE);
01586 
01587         std::string name;
01588         LLNameEditor* nameedit = LLViewerUICtrlFactory::getNameEditorByName(self->mPanelSecondLife, "name");
01589         if (nameedit) name = nameedit->getText();
01590         gIMMgr->addSession(name, IM_NOTHING_SPECIAL, self->mAvatarID);
01591 }
01592 
01593 
01594 // static
01595 //-----------------------------------------------------------------------------
01596 // onClickTrack()
01597 //-----------------------------------------------------------------------------
01598 void LLPanelAvatar::onClickTrack(void* userdata)
01599 {
01600         LLPanelAvatar* self = (LLPanelAvatar*) userdata;
01601         
01602         if( gFloaterWorldMap )
01603         {
01604                 std::string name;
01605                 LLNameEditor* nameedit = LLViewerUICtrlFactory::getNameEditorByName(self->mPanelSecondLife, "name");
01606                 if (nameedit) name = nameedit->getText();
01607                 gFloaterWorldMap->trackAvatar(self->mAvatarID, name);
01608                 LLFloaterWorldMap::show(NULL, TRUE);
01609         }
01610 }
01611 
01612 
01613 // static
01614 void LLPanelAvatar::onClickAddFriend(void* userdata)
01615 {
01616         LLPanelAvatar* self = (LLPanelAvatar*) userdata;
01617         LLNameEditor* name_edit = LLViewerUICtrlFactory::getNameEditorByName(self->mPanelSecondLife, "name");   
01618         if (name_edit)
01619         {
01620                 LLPanelFriends::requestFriendshipDialog(self->getAvatarID(),
01621                                                                                                   name_edit->getText());
01622         }
01623 }
01624 
01625 //-----------------------------------------------------------------------------
01626 // onClickMute()
01627 //-----------------------------------------------------------------------------
01628 void LLPanelAvatar::onClickMute(void *userdata)
01629 {
01630         LLPanelAvatar* self = (LLPanelAvatar*) userdata;
01631         
01632         LLUUID agent_id = self->getAvatarID();
01633         LLNameEditor* name_edit = LLViewerUICtrlFactory::getNameEditorByName(self->mPanelSecondLife, "name");
01634         
01635         if (name_edit)
01636         {
01637                 std::string agent_name = name_edit->getText();
01638                 gFloaterMute->show();
01639                 
01640                 if (gMuteListp->isMuted(agent_id))
01641                 {
01642                         gFloaterMute->selectMute(agent_id);
01643                 }
01644                 else
01645                 {
01646                         LLMute mute(agent_id, agent_name, LLMute::AGENT);
01647                         gMuteListp->add(mute);
01648                 }
01649         }
01650 }
01651 
01652 
01653 // static
01654 void LLPanelAvatar::onClickOfferTeleport(void *userdata)
01655 {
01656         LLPanelAvatar* self = (LLPanelAvatar*) userdata;
01657 
01658         handle_lure(self->mAvatarID);
01659 }
01660 
01661 
01662 // static
01663 void LLPanelAvatar::onClickPay(void *userdata)
01664 {
01665         LLPanelAvatar* self = (LLPanelAvatar*) userdata;
01666         handle_pay_by_id(self->mAvatarID);
01667 }
01668 
01669 
01670 // static
01671 void LLPanelAvatar::onClickOK(void *userdata)
01672 {
01673         LLPanelAvatar *self = (LLPanelAvatar *)userdata;
01674 
01675         // JC: Only save the data if we actually got the original
01676         // properties.  Otherwise we might save blanks into
01677         // the database.
01678         if (self
01679                 && self->mHaveProperties)
01680         {
01681                 self->sendAvatarPropertiesUpdate();
01682 
01683                 LLTabContainerCommon* tabs = LLUICtrlFactory::getTabContainerByName(self,"tab");
01684                 if ( tabs->getCurrentPanel() != self->mPanelClassified )
01685                 {
01686                         self->mPanelClassified->apply();
01687 
01688                         LLFloaterAvatarInfo *infop = LLFloaterAvatarInfo::getInstance(self->mAvatarID);
01689                         if (infop)
01690                         {
01691                                 infop->close();
01692                         }
01693                 }
01694                 else
01695                 {
01696                         if ( self->mPanelClassified->titleIsValid() )
01697                         {
01698                                 self->mPanelClassified->apply();
01699 
01700                                 LLFloaterAvatarInfo *infop = LLFloaterAvatarInfo::getInstance(self->mAvatarID);
01701                                 if (infop)
01702                                 {
01703                                         infop->close();
01704                                 }
01705                         }
01706                 }
01707         }
01708 }
01709 
01710 // static
01711 void LLPanelAvatar::onClickCancel(void *userdata)
01712 {
01713         LLPanelAvatar *self = (LLPanelAvatar *)userdata;
01714 
01715         if (self)
01716         {
01717                 LLFloaterAvatarInfo *infop;
01718                 if ((infop = LLFloaterAvatarInfo::getInstance(self->mAvatarID)))
01719                 {
01720                         infop->close();
01721                 }
01722                 else
01723                 {
01724                         // We're in the Search directory and are cancelling an edit
01725                         // to our own profile, so reset.
01726                         self->sendAvatarPropertiesRequest();
01727                 }
01728         }
01729 }
01730 
01731 
01732 void LLPanelAvatar::sendAvatarPropertiesRequest()
01733 {
01734         lldebugs << "LLPanelAvatar::sendAvatarPropertiesRequest()" << llendl; 
01735         LLMessageSystem *msg = gMessageSystem;
01736 
01737         msg->newMessageFast(_PREHASH_AvatarPropertiesRequest);
01738         msg->nextBlockFast( _PREHASH_AgentData);
01739         msg->addUUIDFast(   _PREHASH_AgentID, gAgent.getID() );
01740         msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
01741         msg->addUUIDFast(   _PREHASH_AvatarID, mAvatarID);
01742         gAgent.sendReliableMessage();
01743 }
01744 
01745 void LLPanelAvatar::sendAvatarNotesUpdate()
01746 {
01747         std::string notes = mPanelNotes->childGetValue("notes edit").asString();
01748 
01749         if (!mHaveNotes
01750                 && (notes.empty() || notes == childGetText("Loading")))
01751         {
01752                 // no notes from server and no user updates
01753                 return;
01754         }
01755         if (notes == mLastNotes)
01756         {
01757                 // Avatar notes unchanged
01758                 return;
01759         }
01760 
01761         LLMessageSystem *msg = gMessageSystem;
01762 
01763         msg->newMessage("AvatarNotesUpdate");
01764         msg->nextBlock("AgentData");
01765         msg->addUUID("AgentID", gAgent.getID());
01766         msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
01767         msg->nextBlock("Data");
01768         msg->addUUID("TargetID", mAvatarID);
01769         msg->addString("Notes", notes);
01770 
01771         gAgent.sendReliableMessage();
01772 }
01773 
01774 
01775 // static
01776 void LLPanelAvatar::processAvatarPropertiesReply(LLMessageSystem *msg, void**)
01777 {
01778         LLUUID  agent_id;       // your id
01779         LLUUID  avatar_id;      // target of this panel
01780         LLUUID  image_id;
01781         LLUUID  fl_image_id;
01782         LLUUID  partner_id;
01783         char    about_text[DB_USER_ABOUT_BUF_SIZE];             /*Flawfinder: ignore*/
01784         char    fl_about_text[DB_USER_FL_ABOUT_BUF_SIZE];               /*Flawfinder: ignore*/
01785         char    born_on[DB_BORN_BUF_SIZE];              /*Flawfinder: ignore*/
01786         S32             charter_member_size = 0;
01787         BOOL    allow_publish = FALSE;
01788         //BOOL  mature = FALSE;
01789         BOOL    identified = FALSE;
01790         BOOL    transacted = FALSE;
01791         BOOL    online = FALSE;
01792         char    profile_url[DB_USER_PROFILE_URL_BUF_SIZE];              /*Flawfinder: ignore*/
01793 
01794         U32             flags = 0x0;
01795 
01796         //llinfos << "properties packet size " << msg->getReceiveSize() << llendl;
01797 
01798         msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id);
01799         msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AvatarID, avatar_id );
01800 
01801         for (panel_list_t::iterator iter = sAllPanels.begin(); iter != sAllPanels.end(); ++iter)
01802         {
01803                 LLPanelAvatar* self = *iter;
01804                 if (self->mAvatarID != avatar_id)
01805                 {
01806                         continue;
01807                 }
01808                 self->childSetEnabled("Instant Message...",TRUE);
01809                 self->childSetEnabled("Pay...",TRUE);
01810                 self->childSetEnabled("Mute",TRUE);
01811 
01812                 self->childSetEnabled("drop target",TRUE);
01813 
01814                 self->mHaveProperties = TRUE;
01815                 self->enableOKIfReady();
01816 
01817                 msg->getUUIDFast(  _PREHASH_PropertiesData,     _PREHASH_ImageID,               image_id );
01818                 msg->getUUIDFast(  _PREHASH_PropertiesData,     _PREHASH_FLImageID,     fl_image_id );
01819                 msg->getUUIDFast(_PREHASH_PropertiesData, _PREHASH_PartnerID, partner_id);
01820                 msg->getStringFast(_PREHASH_PropertiesData, _PREHASH_AboutText, DB_USER_ABOUT_BUF_SIZE,         about_text );
01821                 msg->getStringFast(_PREHASH_PropertiesData, _PREHASH_FLAboutText,       DB_USER_FL_ABOUT_BUF_SIZE,              fl_about_text );
01822                 msg->getStringFast(_PREHASH_PropertiesData, _PREHASH_BornOn, DB_BORN_BUF_SIZE, born_on);
01823                 msg->getString("PropertiesData","ProfileURL", DB_USER_PROFILE_URL_BUF_SIZE, profile_url);
01824                 msg->getU32Fast(_PREHASH_PropertiesData, _PREHASH_Flags, flags);
01825                 
01826                 identified = (flags & AVATAR_IDENTIFIED);
01827                 transacted = (flags & AVATAR_TRANSACTED);
01828                 allow_publish = (flags & AVATAR_ALLOW_PUBLISH);
01829                 online = (flags & AVATAR_ONLINE);
01830                 
01831                 U8 caption_index = 0;
01832                 LLString caption_text;
01833                 charter_member_size = msg->getSize("PropertiesData", "CharterMember");
01834                 if(1 == charter_member_size)
01835                 {
01836                         msg->getBinaryData("PropertiesData", "CharterMember", &caption_index, 1);
01837                 }
01838                 else if(1 < charter_member_size)
01839                 {
01840                         char caption[MAX_STRING];               /*Flawfinder: ignore*/
01841                         msg->getString("PropertiesData", "CharterMember", MAX_STRING, caption);
01842                         caption_text = caption;
01843                 }
01844                 
01845 
01846                 if(caption_text.empty())
01847                 {
01848                         LLString::format_map_t args;
01849                         caption_text = self->mPanelSecondLife->childGetValue("CaptionTextAcctInfo").asString();
01850                         
01851                         const char* ACCT_TYPE[] = {
01852                                 "AcctTypeResident",
01853                                 "AcctTypeTrial",
01854                                 "AcctTypeCharterMember",
01855                                 "AcctTypeEmployee"
01856                         };
01857                         caption_index = llclamp(caption_index, (U8)0, (U8)(sizeof(ACCT_TYPE)/sizeof(ACCT_TYPE[0])-1));
01858                         args["[ACCTTYPE]"] = self->mPanelSecondLife->childGetValue(ACCT_TYPE[caption_index]).asString();
01859 
01860                         LLString payment_text = " ";
01861                         const S32 DEFAULT_CAPTION_LINDEN_INDEX = 3;
01862                         if(caption_index != DEFAULT_CAPTION_LINDEN_INDEX)
01863                         {                       
01864                                 if(transacted)
01865                                 {
01866                                         payment_text = "PaymentInfoUsed";
01867                                 }
01868                                 else if (identified)
01869                                 {
01870                                         payment_text = "PaymentInfoOnFile";
01871                                 }
01872                                 else
01873                                 {
01874                                         payment_text = "NoPaymentInfoOnFile";
01875                                 }
01876                                 args["[PAYMENTINFO]"] = self->mPanelSecondLife->childGetValue(payment_text).asString();
01877                         }
01878                         else
01879                         {
01880                                 args["[PAYMENTINFO]"] = " ";
01881                         }
01882                         LLString::format(caption_text, args);
01883                 }
01884                 
01885                 self->mPanelSecondLife->childSetValue("acct", caption_text);
01886                 self->mPanelSecondLife->childSetValue("born", born_on);
01887 
01888                 EOnlineStatus online_status = (online) ? ONLINE_STATUS_YES : ONLINE_STATUS_NO;
01889 
01890                 self->setOnlineStatus(online_status);
01891 
01892                 self->mPanelWeb->setWebURL(std::string(profile_url));
01893 
01894                 LLTextureCtrl*  image_ctrl = LLUICtrlFactory::getTexturePickerByName(self->mPanelSecondLife,"img");
01895                 if(image_ctrl)
01896                 {
01897                         image_ctrl->setImageAssetID(image_id);
01898                 }
01899                 self->childSetValue("about", about_text);
01900 
01901                 self->mPanelSecondLife->setPartnerID(partner_id);
01902                 self->mPanelSecondLife->updatePartnerName();
01903 
01904                 if (self->mPanelFirstLife)
01905                 {
01906                         // Teens don't get these
01907                         self->mPanelFirstLife->childSetValue("about", fl_about_text);
01908                         LLTextureCtrl*  image_ctrl = LLUICtrlFactory::getTexturePickerByName(self->mPanelFirstLife,"img");
01909                         if(image_ctrl)
01910                         {
01911                                 image_ctrl->setImageAssetID(fl_image_id);
01912                         }
01913 
01914                         self->mPanelSecondLife->childSetValue("allow_publish", allow_publish);
01915 
01916                 }
01917         }
01918 }
01919 
01920 // static
01921 void LLPanelAvatar::processAvatarInterestsReply(LLMessageSystem *msg, void**)
01922 {
01923         LLUUID  agent_id;       // your id
01924         LLUUID  avatar_id;      // target of this panel
01925 
01926         U32             want_to_mask;
01927         char    want_to_text[DB_USER_WANT_TO_BUF_SIZE];         /*Flawfinder: ignore*/
01928         U32             skills_mask;
01929         char    skills_text[DB_USER_SKILLS_BUF_SIZE];           /*Flawfinder: ignore*/
01930         char    languages_text[DB_USER_SKILLS_BUF_SIZE];                /*Flawfinder: ignore*/
01931 
01932         //llinfos << "properties packet size " << msg->getReceiveSize() << llendl;
01933 
01934         msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id);
01935         msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AvatarID, avatar_id );
01936 
01937         for (panel_list_t::iterator iter = sAllPanels.begin(); iter != sAllPanels.end(); ++iter)
01938         {
01939                 LLPanelAvatar* self = *iter;
01940                 if (self->mAvatarID != avatar_id)
01941                 {
01942                         continue;
01943                 }
01944 
01945                 msg->getU32Fast(   _PREHASH_PropertiesData,     _PREHASH_WantToMask,    want_to_mask );
01946                 msg->getStringFast(_PREHASH_PropertiesData, _PREHASH_WantToText,        DB_USER_WANT_TO_BUF_SIZE,       want_to_text );
01947                 msg->getU32Fast(   _PREHASH_PropertiesData,     _PREHASH_SkillsMask,    skills_mask );
01948                 msg->getStringFast(_PREHASH_PropertiesData, _PREHASH_SkillsText,        DB_USER_SKILLS_BUF_SIZE,        skills_text );
01949                 msg->getString(_PREHASH_PropertiesData, "LanguagesText",        DB_USER_SKILLS_BUF_SIZE,        languages_text );
01950 
01951                 self->mPanelAdvanced->setWantSkills(want_to_mask, want_to_text, skills_mask, skills_text, languages_text);
01952         }
01953 }
01954 
01955 // Separate function because the groups list can be very long, almost
01956 // filling a packet. JC
01957 // static
01958 void LLPanelAvatar::processAvatarGroupsReply(LLMessageSystem *msg, void**)
01959 {
01960         LLUUID  agent_id;       // your id
01961         LLUUID  avatar_id;      // target of this panel
01962         U64             group_powers;
01963         char    group_title[DB_GROUP_TITLE_BUF_SIZE];           /*Flawfinder: ignore*/
01964         LLUUID  group_id;
01965         char    group_name[DB_GROUP_NAME_BUF_SIZE];             /*Flawfinder: ignore*/
01966         LLUUID  group_insignia_id;
01967 
01968         llinfos << "groups packet size " << msg->getReceiveSize() << llendl;
01969 
01970         msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id);
01971         msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AvatarID, avatar_id );
01972 
01973         for (panel_list_t::iterator iter = sAllPanels.begin(); iter != sAllPanels.end(); ++iter)
01974         {
01975                 LLPanelAvatar* self = *iter;
01976                 if (self->mAvatarID != avatar_id)
01977                 {
01978                         continue;
01979                 }
01980                 
01981                 LLScrollListCtrl*       group_list = LLUICtrlFactory::getScrollListByName(self->mPanelSecondLife,"groups"); 
01982 //              if(group_list)
01983 //              {
01984 //                      group_list->deleteAllItems();
01985 //              }
01986                 
01987                 S32 group_count = msg->getNumberOfBlocksFast(_PREHASH_GroupData);
01988                 if (0 == group_count)
01989                 {
01990                         if(group_list) group_list->addSimpleItem("None");
01991                 }
01992                 else
01993                 {
01994                         for(S32 i = 0; i < group_count; ++i)
01995                         {
01996                                 msg->getU64(    _PREHASH_GroupData, "GroupPowers",      group_powers, i );
01997                                 msg->getStringFast(_PREHASH_GroupData, _PREHASH_GroupTitle,     DB_GROUP_TITLE_BUF_SIZE,        group_title, i );
01998                                 msg->getUUIDFast(  _PREHASH_GroupData, _PREHASH_GroupID,                group_id, i);
01999                                 msg->getStringFast(_PREHASH_GroupData, _PREHASH_GroupName,      DB_GROUP_NAME_BUF_SIZE,         group_name, i );
02000                                 msg->getUUIDFast(  _PREHASH_GroupData, _PREHASH_GroupInsigniaID, group_insignia_id, i );
02001 
02002                                 LLString group_string;
02003                                 if (group_id.notNull())
02004                                 {
02005                                         group_string.assign("Member of ");
02006                                         group_string.append(group_name);
02007                                 }
02008                                 else
02009                                 {
02010                                         group_string.assign("");
02011                                 }
02012 
02013                                 // Is this really necessary?  Remove existing entry if it exists.
02014                                 // TODO: clear the whole list when a request for data is made
02015                                 if (group_list)
02016                                 {
02017                                         S32 index = group_list->getItemIndex(group_id);
02018                                         if ( index >= 0 )
02019                                         {
02020                                                 group_list->deleteSingleItem(index);
02021                                         }
02022                                 }
02023 
02024                                 LLSD row;
02025                                 row["id"] = group_id;
02026                                 row["columns"][0]["value"] = group_string;
02027                                 row["columns"][0]["font"] = "SANSSERIF_SMALL";
02028                                 if (group_list)
02029                                 {
02030                                         group_list->addElement(row);
02031                                 }
02032                         }
02033                 }
02034                 if(group_list) group_list->sortByColumn(0, TRUE);
02035         }
02036 }
02037 
02038 // Don't enable the OK button until you actually have the data.
02039 // Otherwise you will write blanks back into the database.
02040 void LLPanelAvatar::enableOKIfReady()
02041 {
02042         if(mHaveProperties && childIsVisible("OK"))
02043         {
02044                 childSetEnabled("OK", TRUE);
02045         }
02046         else
02047         {
02048                 childSetEnabled("OK", FALSE);
02049         }
02050 }
02051 
02052 void LLPanelAvatar::sendAvatarPropertiesUpdate()
02053 {
02054         llinfos << "Sending avatarinfo update" << llendl;
02055         BOOL allow_publish = FALSE;
02056         BOOL mature = FALSE;
02057         if (LLPanelAvatar::sAllowFirstLife)
02058         {
02059                 allow_publish = childGetValue("allow_publish");
02060                 //A profile should never be mature.
02061                 mature = FALSE;
02062         }
02063         U32 want_to_mask = 0x0;
02064         U32 skills_mask = 0x0;
02065         std::string want_to_text;
02066         std::string skills_text;
02067         std::string languages_text;
02068         mPanelAdvanced->getWantSkills(&want_to_mask, want_to_text, &skills_mask, skills_text, languages_text);
02069 
02070         LLUUID first_life_image_id;
02071         LLString first_life_about_text;
02072         if (mPanelFirstLife)
02073         {
02074                 first_life_about_text = mPanelFirstLife->childGetValue("about").asString();
02075                 LLTextureCtrl*  image_ctrl = LLUICtrlFactory::getTexturePickerByName(mPanelFirstLife,"img");
02076                 if(image_ctrl)
02077                 {
02078                         first_life_image_id = image_ctrl->getImageAssetID();
02079                 }
02080         }
02081 
02082         LLString about_text = mPanelSecondLife->childGetValue("about").asString();
02083 
02084         LLMessageSystem *msg = gMessageSystem;
02085 
02086         msg->newMessageFast(_PREHASH_AvatarPropertiesUpdate);
02087         msg->nextBlockFast(_PREHASH_AgentData);
02088         msg->addUUIDFast(       _PREHASH_AgentID,               gAgent.getID() );
02089         msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() );
02090         msg->nextBlockFast(_PREHASH_PropertiesData);
02091         
02092         LLTextureCtrl*  image_ctrl = LLUICtrlFactory::getTexturePickerByName(mPanelSecondLife,"img");
02093         if(image_ctrl)
02094         {
02095                 msg->addUUIDFast(       _PREHASH_ImageID,       image_ctrl->getImageAssetID());
02096         }
02097         else
02098         {
02099                 msg->addUUIDFast(       _PREHASH_ImageID,       LLUUID::null);
02100         }
02101 //      msg->addUUIDFast(       _PREHASH_ImageID,               mPanelSecondLife->mimage_ctrl->getImageAssetID()        );
02102         msg->addUUIDFast(       _PREHASH_FLImageID,             first_life_image_id);
02103         msg->addStringFast(     _PREHASH_AboutText,             about_text);
02104         msg->addStringFast(     _PREHASH_FLAboutText,   first_life_about_text);
02105 
02106         msg->addBOOL("AllowPublish", allow_publish);
02107         msg->addBOOL("MaturePublish", mature);
02108         msg->addString("ProfileURL", mPanelWeb->childGetText("url_edit"));
02109         gAgent.sendReliableMessage();
02110 
02111         msg->newMessage("AvatarInterestsUpdate");
02112         msg->nextBlockFast(_PREHASH_AgentData);
02113         msg->addUUIDFast(       _PREHASH_AgentID,               gAgent.getID() );
02114         msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() );
02115         msg->nextBlockFast(_PREHASH_PropertiesData);
02116         msg->addU32Fast(        _PREHASH_WantToMask,    want_to_mask);
02117         msg->addStringFast(     _PREHASH_WantToText,    want_to_text);
02118         msg->addU32Fast(        _PREHASH_SkillsMask,    skills_mask);
02119         msg->addStringFast(     _PREHASH_SkillsText,    skills_text);
02120         msg->addString( "LanguagesText",                        languages_text);
02121         gAgent.sendReliableMessage();
02122 }
02123 
02124 void LLPanelAvatar::selectTab(S32 tabnum)
02125 {
02126         if(mTab)
02127         {
02128                 mTab->selectTab(tabnum);
02129         }
02130 }
02131 
02132 void LLPanelAvatar::selectTabByName(std::string tab_name)
02133 {
02134         if (mTab)
02135         {
02136                 if (tab_name.empty())
02137                 {
02138                         mTab->selectFirstTab();
02139                 }
02140                 else
02141                 {
02142                         mTab->selectTabByName(tab_name);
02143                 }
02144         }
02145 }
02146 
02147 
02148 void LLPanelAvatar::processAvatarNotesReply(LLMessageSystem *msg, void**)
02149 {
02150         // extract the agent id
02151         LLUUID agent_id;
02152         msg->getUUID("AgentData", "AgentID", agent_id);
02153 
02154         LLUUID target_id;
02155         msg->getUUID("Data", "TargetID", target_id);
02156 
02157         // look up all panels which have this avatar
02158         for (panel_list_t::iterator iter = sAllPanels.begin(); iter != sAllPanels.end(); ++iter)
02159         {
02160                 LLPanelAvatar* self = *iter;
02161                 if (self->mAvatarID != target_id)
02162                 {
02163                         continue;
02164                 }
02165 
02166                 char text[DB_USER_NOTE_SIZE];           /*Flawfinder: ignore*/
02167                 msg->getString("Data", "Notes", DB_USER_NOTE_SIZE, text);
02168                 self->childSetValue("notes edit", text);
02169                 self->childSetEnabled("notes edit", true);
02170                 self->mHaveNotes = true;
02171                 self->mLastNotes = text;
02172         }
02173 }
02174 
02175 
02176 void LLPanelAvatar::processAvatarClassifiedReply(LLMessageSystem *msg, void** userdata)
02177 {
02178         LLUUID agent_id;
02179         LLUUID target_id;
02180 
02181         msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id);
02182         msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_TargetID, target_id);
02183 
02184         // look up all panels which have this avatar target
02185         for (panel_list_t::iterator iter = sAllPanels.begin(); iter != sAllPanels.end(); ++iter)
02186         {
02187                 LLPanelAvatar* self = *iter;
02188                 if (self->mAvatarID != target_id)
02189                 {
02190                         continue;
02191                 }
02192 
02193                 self->mPanelClassified->processAvatarClassifiedReply(msg, userdata);
02194         }
02195 }
02196 
02197 void LLPanelAvatar::processAvatarPicksReply(LLMessageSystem *msg, void** userdata)
02198 {
02199         LLUUID agent_id;
02200         LLUUID target_id;
02201 
02202         msg->getUUID("AgentData", "AgentID", agent_id);
02203         msg->getUUID("AgentData", "TargetID", target_id);
02204 
02205         // look up all panels which have this avatar target
02206         for (panel_list_t::iterator iter = sAllPanels.begin(); iter != sAllPanels.end(); ++iter)
02207         {
02208                 LLPanelAvatar* self = *iter;
02209                 if (self->mAvatarID != target_id)
02210                 {
02211                         continue;
02212                 }
02213 
02214                 self->mPanelPicks->processAvatarPicksReply(msg, userdata);
02215         }
02216 }
02217 
02218 // static
02219 void LLPanelAvatar::onClickKick(void* userdata)
02220 {
02221         LLPanelAvatar* self = (LLPanelAvatar*) userdata;
02222 
02223         S32 left, top;
02224         gFloaterView->getNewFloaterPosition(&left, &top);
02225         LLRect rect(left, top, left+400, top-300);
02226 
02227         gViewerWindow->alertXmlEditText("KickUser", LLString::format_map_t(),
02228                                                                         NULL, NULL,
02229                                                                         LLPanelAvatar::finishKick, self);
02230 }
02231 
02232 // static
02233 void LLPanelAvatar::finishKick(S32 option, const LLString& text, void* userdata)
02234 {
02235         LLPanelAvatar* self = (LLPanelAvatar*) userdata;
02236 
02237         if (option == 0)
02238         {
02239                 LLMessageSystem* msg = gMessageSystem;
02240 
02241                 msg->newMessageFast(_PREHASH_GodKickUser);
02242                 msg->nextBlockFast(_PREHASH_UserInfo);
02243                 msg->addUUIDFast(_PREHASH_GodID,                gAgent.getID() );
02244                 msg->addUUIDFast(_PREHASH_GodSessionID, gAgent.getSessionID());
02245                 msg->addUUIDFast(_PREHASH_AgentID,   self->mAvatarID );
02246                 msg->addU32("KickFlags", KICK_FLAGS_DEFAULT );
02247                 msg->addStringFast(_PREHASH_Reason,    text );
02248                 gAgent.sendReliableMessage();
02249         }
02250 }
02251 
02252 // static
02253 void LLPanelAvatar::onClickFreeze(void* userdata)
02254 {
02255         gViewerWindow->alertXmlEditText("FreezeUser", LLString::format_map_t(),
02256                                                                         NULL, NULL,
02257                                                                         LLPanelAvatar::finishFreeze, userdata);
02258 }
02259 
02260 // static
02261 void LLPanelAvatar::finishFreeze(S32 option, const LLString& text, void* userdata)
02262 {
02263         LLPanelAvatar* self = (LLPanelAvatar*) userdata;
02264 
02265         if (option == 0)
02266         {
02267                 LLMessageSystem* msg = gMessageSystem;
02268 
02269                 msg->newMessageFast(_PREHASH_GodKickUser);
02270                 msg->nextBlockFast(_PREHASH_UserInfo);
02271                 msg->addUUIDFast(_PREHASH_GodID,                gAgent.getID() );
02272                 msg->addUUIDFast(_PREHASH_GodSessionID, gAgent.getSessionID());
02273                 msg->addUUIDFast(_PREHASH_AgentID,   self->mAvatarID );
02274                 msg->addU32("KickFlags", KICK_FLAGS_FREEZE );
02275                 msg->addStringFast(_PREHASH_Reason,    text );
02276                 gAgent.sendReliableMessage();
02277         }
02278 }
02279 
02280 // static
02281 void LLPanelAvatar::onClickUnfreeze(void* userdata)
02282 {
02283         gViewerWindow->alertXmlEditText("UnFreezeUser", LLString::format_map_t(),
02284                                                                         NULL, NULL,
02285                                                                         LLPanelAvatar::finishUnfreeze, userdata);
02286 }
02287 
02288 // static
02289 void LLPanelAvatar::finishUnfreeze(S32 option, const LLString& text, void* userdata)
02290 {
02291         LLPanelAvatar* self = (LLPanelAvatar*) userdata;
02292 
02293         if (option == 0)
02294         {
02295                 LLMessageSystem* msg = gMessageSystem;
02296 
02297                 msg->newMessageFast(_PREHASH_GodKickUser);
02298                 msg->nextBlockFast(_PREHASH_UserInfo);
02299                 msg->addUUIDFast(_PREHASH_GodID,                gAgent.getID() );
02300                 msg->addUUIDFast(_PREHASH_GodSessionID, gAgent.getSessionID());
02301                 msg->addUUIDFast(_PREHASH_AgentID,   self->mAvatarID );
02302                 msg->addU32("KickFlags", KICK_FLAGS_UNFREEZE );
02303                 msg->addStringFast(_PREHASH_Reason,    text );
02304                 gAgent.sendReliableMessage();
02305         }
02306 }
02307 
02308 // static
02309 void LLPanelAvatar::onClickCSR(void* userdata)
02310 {
02311         LLPanelAvatar* self = (LLPanelAvatar*)userdata;
02312         if (!self) return;
02313         
02314         LLNameEditor* name_edit = LLViewerUICtrlFactory::getNameEditorByName(self, "name");
02315         if (!name_edit) return;
02316 
02317         LLString name = name_edit->getText();
02318         if (name.empty()) return;
02319         
02320         LLString url = "http://csr.lindenlab.com/agent/";
02321         
02322         // slow and stupid, but it's late
02323         S32 len = name.length();
02324         for (S32 i = 0; i < len; i++)
02325         {
02326                 if (name[i] == ' ')
02327                 {
02328                         url += "%20";
02329                 }
02330                 else
02331                 {
02332                         url += name[i];
02333                 }
02334         }
02335         
02336         LLWeb::loadURL(url);
02337 }
02338 
02339 
02340 void*   LLPanelAvatar::createPanelAvatarSecondLife(void* data)
02341 {
02342         LLPanelAvatar* self = (LLPanelAvatar*)data;
02343         self->mPanelSecondLife = new LLPanelAvatarSecondLife("2nd Life",LLRect(),self);
02344         return self->mPanelSecondLife;
02345 }
02346 
02347 void*   LLPanelAvatar::createPanelAvatarWeb(void*       data)
02348 {
02349         LLPanelAvatar* self = (LLPanelAvatar*)data;
02350         self->mPanelWeb = new LLPanelAvatarWeb("Web",LLRect(),self);
02351         return self->mPanelWeb;
02352 }
02353 
02354 void*   LLPanelAvatar::createPanelAvatarInterests(void* data)
02355 {
02356         LLPanelAvatar* self = (LLPanelAvatar*)data;
02357         self->mPanelAdvanced = new LLPanelAvatarAdvanced("Interests",LLRect(),self);
02358         return self->mPanelAdvanced;
02359 }
02360 
02361 
02362 void*   LLPanelAvatar::createPanelAvatarPicks(void*     data)
02363 {
02364         LLPanelAvatar* self = (LLPanelAvatar*)data;
02365         self->mPanelPicks = new LLPanelAvatarPicks("Picks",LLRect(),self);
02366         return self->mPanelPicks;
02367 }
02368 
02369 void*   LLPanelAvatar::createPanelAvatarClassified(void* data)
02370 {
02371         LLPanelAvatar* self = (LLPanelAvatar*)data;
02372         self->mPanelClassified = new LLPanelAvatarClassified("Classified",LLRect(),self);
02373         return self->mPanelClassified;
02374 }
02375 
02376 void*   LLPanelAvatar::createPanelAvatarFirstLife(void* data)
02377 {
02378         LLPanelAvatar* self = (LLPanelAvatar*)data;
02379         self->mPanelFirstLife = new LLPanelAvatarFirstLife("1st Life", LLRect(), self);
02380         return self->mPanelFirstLife;
02381 }
02382 
02383 void*   LLPanelAvatar::createPanelAvatarNotes(void*     data)
02384 {
02385         LLPanelAvatar* self = (LLPanelAvatar*)data;
02386         self->mPanelNotes = new LLPanelAvatarNotes("My Notes",LLRect(),self);
02387         return self->mPanelNotes;
02388 }

Generated on Thu Jul 1 06:08:56 2010 for Second Life Viewer by  doxygen 1.4.7