llpanelgrouplandmoney.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 #include "llpanelgrouplandmoney.h"
00035 
00036 #include "lluiconstants.h"
00037 #include "roles_constants.h"
00038 
00039 #include "llparcel.h"
00040 #include "llqueryflags.h"
00041 
00042 #include "llagent.h"
00043 #include "lliconctrl.h"
00044 #include "lllineeditor.h"
00045 #include "llscrolllistctrl.h"
00046 #include "lltextbox.h"
00047 #include "lltabcontainer.h"
00048 #include "lltransactiontypes.h"
00049 #include "llvieweruictrlfactory.h"
00050 
00051 #include "llstatusbar.h"
00052 #include "llfloaterworldmap.h"
00053 #include "llviewermessage.h"
00054 
00056 
00057 class LLGroupMoneyTabEventHandler
00058 {
00059 public:
00060         LLGroupMoneyTabEventHandler(LLButton* earlier_button,
00061                                                                 LLButton* later_button,
00062                                                                 LLTextEditor* text_editor,
00063                                                                 LLTabContainerCommon* tab_containerp,
00064                                                                 LLPanel* panelp,
00065                                                                 const LLString& loading_text,
00066                                                                 const LLUUID& group_id,
00067                                                                 S32 interval_length_days,
00068                                                                 S32 max_interval_days);
00069         virtual ~LLGroupMoneyTabEventHandler();
00070 
00071         virtual void requestData(LLMessageSystem* msg);
00072         virtual void processReply(LLMessageSystem* msg, void** data);
00073 
00074         virtual void onClickEarlier();
00075         virtual void onClickLater();
00076         virtual void onClickTab();
00077 
00078         static void clickEarlierCallback(void* data);
00079         static void clickLaterCallback(void* data);
00080         static void clickTabCallback(void* user_data, bool from_click);
00081 
00082         static LLMap<LLUUID, LLGroupMoneyTabEventHandler*> sInstanceIDs;
00083         static std::map<LLPanel*, LLGroupMoneyTabEventHandler*> sTabsToHandlers;
00084 protected:
00085         class impl;
00086         impl* mImplementationp;
00087 };
00088 
00089 class LLGroupMoneyDetailsTabEventHandler : public LLGroupMoneyTabEventHandler
00090 {
00091 public:
00092         LLGroupMoneyDetailsTabEventHandler(LLButton* earlier_buttonp,
00093                                                                            LLButton* later_buttonp,
00094                                                                            LLTextEditor* text_editorp,
00095                                                                            LLTabContainerCommon* tab_containerp,
00096                                                                            LLPanel* panelp,
00097                                                                            const LLString& loading_text,
00098                                                                            const LLUUID& group_id);
00099         virtual ~LLGroupMoneyDetailsTabEventHandler();
00100 
00101         virtual void requestData(LLMessageSystem* msg);
00102         virtual void processReply(LLMessageSystem* msg, void** data);
00103 };
00104 
00105 
00106 class LLGroupMoneySalesTabEventHandler : public LLGroupMoneyTabEventHandler
00107 {
00108 public:
00109         LLGroupMoneySalesTabEventHandler(LLButton* earlier_buttonp,
00110                                                                          LLButton* later_buttonp,
00111                                                                          LLTextEditor* text_editorp,
00112                                                                          LLTabContainerCommon* tab_containerp,
00113                                                                          LLPanel* panelp,
00114                                                                          const LLString& loading_text,
00115                                                                          const LLUUID& group_id);
00116         virtual ~LLGroupMoneySalesTabEventHandler();
00117 
00118         virtual void requestData(LLMessageSystem* msg);
00119         virtual void processReply(LLMessageSystem* msg, void** data);
00120 };
00121 
00122 class LLGroupMoneyPlanningTabEventHandler : public LLGroupMoneyTabEventHandler
00123 {
00124 public:
00125         LLGroupMoneyPlanningTabEventHandler(LLTextEditor* text_editor,
00126                                                                                 LLTabContainerCommon* tab_containerp,
00127                                                                                 LLPanel* panelp,
00128                                                                                 const LLString& loading_text,
00129                                                                                 const LLUUID& group_id);
00130         virtual ~LLGroupMoneyPlanningTabEventHandler();
00131 
00132         virtual void requestData(LLMessageSystem* msg);
00133         virtual void processReply(LLMessageSystem* msg, void** data);
00134 };
00135 
00137 
00138 class LLPanelGroupLandMoney::impl
00139 {
00140 public:
00141         impl(LLPanelGroupLandMoney& panel, const LLUUID& group_id); //constructor
00142         virtual ~impl();
00143 
00144         void requestGroupLandInfo();
00145 
00146         int getStoredContribution();
00147         void setYourContributionTextField(int contrib);
00148         void setYourMaxContributionTextBox(int max);
00149 
00150         virtual void onMapButton();
00151         virtual bool applyContribution();
00152         virtual void processGroupLand(LLMessageSystem* msg);
00153 
00154         static void mapCallback(void* data);
00155         static void contributionCommitCallback(LLUICtrl* ctrl, void* userdata);
00156         static void contributionKeystrokeCallback(LLLineEditor* caller, void* userdata);
00157 
00158 //member variables
00159 public:
00160         LLPanelGroupLandMoney& mPanel;
00161         
00162         LLTextBox* mGroupOverLimitTextp;
00163         LLIconCtrl* mGroupOverLimitIconp;
00164 
00165         LLLineEditor* mYourContributionEditorp;
00166 
00167         LLButton* mMapButtonp;
00168 
00169         LLGroupMoneyTabEventHandler* mMoneyDetailsTabEHp;
00170         LLGroupMoneyTabEventHandler* mMoneyPlanningTabEHp;
00171         LLGroupMoneyTabEventHandler* mMoneySalesTabEHp;
00172 
00173         LLScrollListCtrl* mGroupParcelsp;
00174 
00175         LLUUID mGroupID;
00176         LLUUID mTransID;
00177 
00178         bool mBeenActivated;
00179         bool mNeedsSendGroupLandRequest;
00180         bool mNeedsApply;
00181 
00182         std::string mCantViewParcelsText;
00183         std::string mCantViewAccountsText;
00184 };
00185 
00186 //*******************************************
00187 //** LLPanelGroupLandMoney::impl Functions **
00188 //*******************************************
00189 LLPanelGroupLandMoney::impl::impl(LLPanelGroupLandMoney& panel, const LLUUID& group_id)
00190         : mPanel(panel),
00191           mGroupID(group_id)
00192 {
00193         mTransID = LLUUID::null;
00194 
00195         mBeenActivated = false;
00196         mNeedsSendGroupLandRequest = true;
00197         mNeedsApply = false;
00198 
00199         mYourContributionEditorp = NULL;
00200         mMapButtonp = NULL;
00201         mGroupParcelsp = NULL;
00202         mGroupOverLimitTextp = NULL;
00203         mGroupOverLimitIconp = NULL;
00204 
00205         mMoneySalesTabEHp    = NULL;
00206         mMoneyPlanningTabEHp = NULL;
00207         mMoneyDetailsTabEHp  = NULL;
00208 }
00209 
00210 LLPanelGroupLandMoney::impl::~impl()
00211 {
00212         if ( mMoneySalesTabEHp ) delete mMoneySalesTabEHp;
00213         if ( mMoneyDetailsTabEHp ) delete mMoneyDetailsTabEHp;
00214         if ( mMoneyPlanningTabEHp ) delete mMoneyPlanningTabEHp;
00215 }
00216 
00217 void LLPanelGroupLandMoney::impl::requestGroupLandInfo()
00218 {
00219         U32 query_flags = DFQ_GROUP_OWNED;
00220 
00221         mTransID.generate();
00222         mGroupParcelsp->deleteAllItems();
00223 
00224         send_places_query(mGroupID, mTransID, "", query_flags, LLParcel::C_ANY, "");
00225 }
00226 
00227 void LLPanelGroupLandMoney::impl::onMapButton()
00228 {
00229         LLScrollListItem* itemp;
00230         itemp = mGroupParcelsp->getFirstSelected();
00231         if (!itemp) return;
00232 
00233         const LLScrollListCell* cellp;
00234         // name
00235         // location
00236         // area
00237         cellp = itemp->getColumn(3);    // hidden
00238 
00239         F32 global_x = 0.f;
00240         F32 global_y = 0.f;
00241         sscanf(cellp->getText().c_str(), "%f %f", &global_x, &global_y);
00242 
00243         // Hack: Use the agent's z-height
00244         F64 global_z = gAgent.getPositionGlobal().mdV[VZ];
00245 
00246         LLVector3d pos_global(global_x, global_y, global_z);
00247         gFloaterWorldMap->trackLocation(pos_global);
00248 
00249         LLFloaterWorldMap::show(NULL, TRUE);
00250 }
00251 
00252 bool LLPanelGroupLandMoney::impl::applyContribution()
00253 {
00254         // calculate max donation, which is sum of available and current.
00255         S32 your_contribution = 0;
00256         S32 sqm_avail;
00257 
00258         your_contribution = getStoredContribution();
00259         sqm_avail = your_contribution;
00260         
00261         if(gStatusBar)
00262         {
00263                 sqm_avail += gStatusBar->getSquareMetersLeft();
00264         }
00265 
00266         // get new contribution and compare to available
00267         S32 new_contribution = atoi(mYourContributionEditorp->getText().c_str());
00268 
00269         if( new_contribution != your_contribution &&
00270                 new_contribution >= 0 && 
00271             new_contribution <= sqm_avail )
00272         {
00273                 // update group info and server
00274                 if(!gAgent.setGroupContribution(mGroupID, new_contribution))
00275                 {
00276                         // should never happen...
00277                         llwarns << "Unable to set contribution." << llendl;
00278                         return false;
00279                 }
00280         }
00281         else
00282         {
00283                 //TODO: throw up some error message here and return?  right now we just
00284                 //fail silently and force the previous value  -jwolk
00285                 new_contribution =  your_contribution;
00286         }
00287 
00288         //set your contribution
00289         setYourContributionTextField(new_contribution);
00290 
00291         return true;
00292 }
00293 
00294 // Retrieves the land contribution for this agent that is currently
00295 // stored in the database, NOT what is currently entered in the text field
00296 int LLPanelGroupLandMoney::impl::getStoredContribution()
00297 {
00298         LLGroupData group_data;
00299 
00300         group_data.mContribution = 0;
00301         gAgent.getGroupData(mGroupID, group_data);
00302 
00303         return group_data.mContribution;
00304 }
00305 
00306 // Fills in the text field with the contribution, contrib
00307 void LLPanelGroupLandMoney::impl::setYourContributionTextField(int contrib)
00308 {
00309         LLString buffer = llformat("%d", contrib);
00310 
00311         if ( mYourContributionEditorp )
00312         {
00313                 mYourContributionEditorp->setText(buffer);
00314                 mYourContributionEditorp->draw();
00315         }
00316 }
00317 
00318 void LLPanelGroupLandMoney::impl::setYourMaxContributionTextBox(int max)
00319 {
00320         mPanel.childSetTextArg("your_contribution_max_value", "[AMOUNT]", llformat("%d", max));
00321 }
00322 
00323 //static
00324 void LLPanelGroupLandMoney::impl::mapCallback(void* data)
00325 {
00326         LLPanelGroupLandMoney::impl* selfp = (LLPanelGroupLandMoney::impl*) data;
00327 
00328         if ( selfp ) selfp->onMapButton();
00329 }
00330 
00331 void LLPanelGroupLandMoney::impl::contributionCommitCallback(LLUICtrl* ctrl, 
00332                                                                                                                          void* userdata)
00333 {
00334         LLPanelGroupLandMoney* tabp    = (LLPanelGroupLandMoney*) userdata;
00335         LLLineEditor*          editorp = (LLLineEditor*) ctrl;
00336 
00337         if ( tabp && editorp )
00338         {
00339                 impl* self = tabp->mImplementationp;
00340                 int your_contribution = 0;
00341                 int new_contribution = 0;
00342 
00343                 new_contribution= atoi(editorp->getText().c_str());
00344                 your_contribution = self->getStoredContribution();
00345 
00346                 //reset their junk data to be "good" data to us
00347                 self->setYourContributionTextField(new_contribution);
00348 
00349                 //check to see if they're contribution text has changed
00350                 self->mNeedsApply = new_contribution != your_contribution;
00351                 tabp->notifyObservers();
00352         }
00353 }
00354 
00355 void LLPanelGroupLandMoney::impl::contributionKeystrokeCallback(LLLineEditor* caller,
00356                                                                                                                                 void* userdata)
00357 {
00358         impl::contributionCommitCallback(caller, userdata);
00359 }
00360 
00361 //static
00362 void LLPanelGroupLandMoney::impl::processGroupLand(LLMessageSystem* msg)
00363 {
00364         S32 count = msg->getNumberOfBlocks("QueryData");
00365         if(count > 0)
00366         {
00367                 S32 first_block = 0;
00368 
00369                 LLUUID owner_id;
00370                 LLUUID trans_id;
00371 
00372                 msg->getUUID("QueryData", "OwnerID", owner_id, 0);
00373                 msg->getUUID("TransactionData", "TransactionID", trans_id);
00374 
00375                 if(owner_id.isNull())
00376                 {
00377                         // special block which has total contribution
00378                         ++first_block;
00379                         
00380                         S32 total_contribution;
00381                         msg->getS32("QueryData", "ActualArea", total_contribution, 0);
00382                         mPanel.childSetTextArg("total_contributed_land_value", "[AREA]", llformat("%d", total_contribution));
00383 
00384                         S32 committed;
00385                         msg->getS32("QueryData", "BillableArea", committed, 0);
00386                         mPanel.childSetTextArg("total_land_in_use_value", "[AREA]", llformat("%d", committed));
00387                         
00388                         S32 available = total_contribution - committed;
00389                         mPanel.childSetTextArg("land_available_value", "[AREA]", llformat("%d", available));
00390 
00391                         if ( mGroupOverLimitTextp && mGroupOverLimitIconp )
00392                         {
00393                                 mGroupOverLimitIconp->setVisible(available < 0);
00394                                 mGroupOverLimitTextp->setVisible(available < 0);
00395                         }
00396                 }
00397 
00398                 if ( trans_id != mTransID ) return;
00399                 // This power was removed to make group roles simpler
00400                 //if ( !gAgent.hasPowerInGroup(mGroupID, GP_LAND_VIEW_OWNED) ) return;
00401                 if (!gAgent.isInGroup(mGroupID)) return;
00402 
00403                 //we updated more than just the available area special block
00404                 if ( count > 1)
00405                 {
00406                         mMapButtonp->setEnabled(TRUE);
00407                 }
00408 
00409                 char name[MAX_STRING];          /*Flawfinder: ignore*/
00410                 char desc[MAX_STRING];          /*Flawfinder: ignore*/
00411                 S32 actual_area;
00412                 S32 billable_area;
00413                 U8 flags;
00414                 F32 global_x;
00415                 F32 global_y;
00416                 char sim_name[MAX_STRING];              /*Flawfinder: ignore*/
00417                 for(S32 i = first_block; i < count; ++i)
00418                 {
00419                         msg->getUUID("QueryData", "OwnerID", owner_id, i);
00420                         msg->getString("QueryData", "Name", MAX_STRING, name, i);
00421                         msg->getString("QueryData", "Desc", MAX_STRING, desc, i);
00422                         msg->getS32("QueryData", "ActualArea", actual_area, i);
00423                         msg->getS32("QueryData", "BillableArea", billable_area, i);
00424                         msg->getU8("QueryData", "Flags", flags, i);
00425                         msg->getF32("QueryData", "GlobalX", global_x, i);
00426                         msg->getF32("QueryData", "GlobalY", global_y, i);
00427                         msg->getString("QueryData", "SimName", MAX_STRING, sim_name, i);
00428 
00429                         S32 region_x = llround(global_x) % REGION_WIDTH_UNITS;
00430                         S32 region_y = llround(global_y) % REGION_WIDTH_UNITS;
00431                         char location[MAX_STRING];              /*Flawfinder: ignore*/
00432                         snprintf(location, MAX_STRING, "%s (%d, %d)", sim_name, region_x, region_y);                    /* Flawfinder: ignore */
00433                         char area[MAX_STRING];          /*Flawfinder: ignore*/
00434                         if(billable_area == actual_area)
00435                         {
00436                                 snprintf(area, MAX_STRING, "%d", billable_area);                        /* Flawfinder: ignore */
00437                         }
00438                         else
00439                         {
00440                                 snprintf(area, MAX_STRING, "%d / %d", billable_area, actual_area);                      /* Flawfinder: ignore */
00441                         }
00442                         char hidden[MAX_STRING];                /*Flawfinder: ignore*/
00443                         snprintf(hidden, MAX_STRING, "%f %f", global_x, global_y);                      /* Flawfinder: ignore */
00444 
00445                         LLSD row;
00446 
00447                         row["columns"][0]["column"] = "name";
00448                         row["columns"][0]["value"] = name;
00449                         row["columns"][0]["font"] = "SANSSERIFSMALL";
00450 
00451                         row["columns"][1]["column"] = "location";
00452                         row["columns"][1]["value"] = location;
00453                         row["columns"][1]["font"] = "SANSSERIFSMALL";
00454                         
00455                         row["columns"][2]["column"] = "area";
00456                         row["columns"][2]["value"] = area;
00457                         row["columns"][2]["font"] = "SANSSERIFSMALL";
00458                         
00459                         row["columns"][3]["column"] = "hidden";
00460                         row["columns"][3]["value"] = hidden;
00461                         
00462                         mGroupParcelsp->addElement(row, ADD_SORTED);
00463                 }
00464         }
00465 }
00466 
00467 //*************************************
00468 //** LLPanelGroupLandMoney Functions **
00469 //*************************************
00470 
00471 //static 
00472 void* LLPanelGroupLandMoney::createTab(void* data)
00473 {
00474         LLUUID* group_id = static_cast<LLUUID*>(data);
00475         return new LLPanelGroupLandMoney("panel group land money", *group_id);
00476 }
00477 
00478 //static
00479 LLMap<LLUUID, LLPanelGroupLandMoney*> LLPanelGroupLandMoney::sGroupIDs;
00480 
00481 LLPanelGroupLandMoney::LLPanelGroupLandMoney(const std::string& name, 
00482                                                                                          const LLUUID& group_id) :
00483         LLPanelGroupTab(name, group_id) 
00484 {
00485         mImplementationp = new impl(*this, group_id);
00486 
00487         //problem what if someone has both the group floater open and the finder
00488         //open to the same group?  Some maps that map group ids to panels
00489         //will then only be working for the last panel for a given group id :(
00490         LLPanelGroupLandMoney::sGroupIDs.addData(group_id, this);
00491 }
00492 
00493 LLPanelGroupLandMoney::~LLPanelGroupLandMoney()
00494 {
00495         delete mImplementationp;
00496         LLPanelGroupLandMoney::sGroupIDs.removeData(mGroupID);
00497 }
00498 
00499 void LLPanelGroupLandMoney::activate()
00500 {
00501         if ( !mImplementationp->mBeenActivated )
00502         {
00503                 //select the first tab
00504                 LLTabContainerCommon* tabp = (LLTabContainerCommon*) getChildByName("group_money_tab_container");
00505 
00506                 if ( tabp )
00507                 {
00508                         tabp->selectFirstTab();
00509                         mImplementationp->mBeenActivated = true;
00510                 }
00511 
00512                 //fill in the max contribution
00513 
00514                 //This calculation is unfortunately based on
00515                 //the status bar's concept of how much land the user has
00516                 //which can change dynamically if the user buys new land, gives
00517                 //more land to a group, etc.
00518                 //A race condition can occur if we want to update the UI's
00519                 //concept of the user's max contribution before the status
00520                 //bar has been updated from a change in the user's group contribution.
00521 
00522                 //Since the max contribution should not change solely on changing
00523                 //a user's group contribution, (it would only change through
00524                 //purchasing of new land) this code is placed here
00525                 //and only updated once to prevent the race condition
00526                 //at the price of having stale data.
00527                 //We need to have the status bar have observers
00528                 //or find better way of distributing up to date land data. - jwolk
00529                 S32 max_avail = mImplementationp->getStoredContribution();
00530                 if(gStatusBar)
00531                 {
00532                         max_avail += gStatusBar->getSquareMetersLeft();
00533                 }
00534                 mImplementationp->setYourMaxContributionTextBox(max_avail);
00535         }
00536 
00537         update(GC_ALL);
00538 }
00539 
00540 void LLPanelGroupLandMoney::update(LLGroupChange gc)
00541 {
00542         if (gc != GC_ALL) return;  //Don't update if it's the wrong panel!
00543 
00544         LLTabContainerCommon* tabp = (LLTabContainerCommon*) getChildByName("group_money_tab_container");
00545 
00546         if ( tabp )
00547         {
00548                 LLPanel* panelp;
00549                 LLGroupMoneyTabEventHandler* eh;
00550 
00551                 panelp = tabp->getCurrentPanel();
00552 
00553                 //now pull the event handler associated with that L$ tab
00554                 if ( panelp )
00555                 {
00556                         eh = get_if_there(LLGroupMoneyTabEventHandler::sTabsToHandlers,
00557                                                           panelp,
00558                                                           (LLGroupMoneyTabEventHandler*)NULL);
00559                         if ( eh ) eh->onClickTab();
00560                 }
00561         }
00562 
00563         mImplementationp->requestGroupLandInfo();
00564         mImplementationp->setYourContributionTextField(mImplementationp->getStoredContribution());
00565 }
00566 
00567 bool LLPanelGroupLandMoney::needsApply(LLString& mesg)
00568 {
00569         return mImplementationp->mNeedsApply;
00570 }
00571 
00572 bool LLPanelGroupLandMoney::apply(LLString& mesg)
00573 {
00574         if (!mImplementationp->applyContribution() )
00575         {
00576                 mesg.assign(getUIString("land_contrib_error")); 
00577                 return false;
00578         }
00579 
00580         mImplementationp->mNeedsApply = false;
00581         notifyObservers();
00582 
00583         return true;
00584 }
00585 
00586 void LLPanelGroupLandMoney::cancel()
00587 {
00588         //set the contribution back to the "stored value"
00589         mImplementationp->setYourContributionTextField(mImplementationp->getStoredContribution());
00590 
00591         mImplementationp->mNeedsApply = false;
00592         notifyObservers();
00593 }
00594 
00595 
00596 BOOL LLPanelGroupLandMoney::postBuild()
00597 {
00598         /* This power was removed to make group roles simpler
00599         bool has_parcel_view     = gAgent.hasPowerInGroup(mGroupID,
00600                                                                                                           GP_LAND_VIEW_OWNED);
00601         bool has_accounting_view = gAgent.hasPowerInGroup(mGroupID,
00602                                                                                                           GP_ACCOUNTING_VIEW);
00603         */
00604         
00605         bool can_view = gAgent.isInGroup(mGroupID);
00606 
00607         mImplementationp->mGroupOverLimitIconp = 
00608                 (LLIconCtrl*) getChildByName("group_over_limit_icon");
00609         mImplementationp->mGroupOverLimitTextp = 
00610                 (LLTextBox*) getChildByName("group_over_limit_text");
00611 
00612         mImplementationp->mYourContributionEditorp 
00613                 = (LLLineEditor*) getChildByName("your_contribution_line_editor");
00614         if ( mImplementationp->mYourContributionEditorp )
00615         {
00616                 LLLineEditor* editor = mImplementationp->mYourContributionEditorp;
00617 
00618             editor->setCommitCallback(mImplementationp->contributionCommitCallback);
00619                 editor->setKeystrokeCallback(mImplementationp->contributionKeystrokeCallback);
00620                 editor->setCallbackUserData(this);
00621         }
00622 
00623         mImplementationp->mMapButtonp = (LLButton*) getChildByName("map_button");
00624 
00625         mImplementationp->mGroupParcelsp = 
00626                 (LLScrollListCtrl*) getChildByName("group_parcel_list");
00627 
00628         LLTextBox *no_permsp = 
00629                 (LLTextBox*) getChildByName("cant_view_group_land_text");
00630         if ( no_permsp )
00631         {
00632                 mImplementationp->mCantViewParcelsText = no_permsp->getText();
00633                 removeChild(no_permsp, TRUE);
00634         }
00635 
00636         no_permsp = (LLTextBox*) getChildByName("cant_view_group_accounting_text");
00637         if ( no_permsp )
00638         {
00639                 mImplementationp->mCantViewAccountsText = no_permsp->getText();
00640                 removeChild(no_permsp, TRUE);
00641         }
00642 
00643         
00644         if ( mImplementationp->mMapButtonp )
00645         {
00646                 mImplementationp->mMapButtonp->setClickedCallback(LLPanelGroupLandMoney::impl::mapCallback, mImplementationp);
00647         }
00648 
00649         if ( mImplementationp->mGroupOverLimitTextp )
00650         {
00651                 mImplementationp->mGroupOverLimitTextp->setVisible(FALSE);
00652         }
00653 
00654         if ( mImplementationp->mGroupOverLimitIconp )
00655         {
00656                 mImplementationp->mGroupOverLimitIconp->setVisible(FALSE);
00657         }
00658 
00659         if ( mImplementationp->mMapButtonp )
00660         {
00661                 mImplementationp->mMapButtonp->setEnabled(FALSE);
00662         }
00663 
00664         if ( !can_view )
00665         {
00666                 if ( mImplementationp->mGroupParcelsp )
00667                 {
00668                         mImplementationp->mGroupParcelsp->addSimpleItem(
00669                                                         mImplementationp->mCantViewParcelsText);
00670                         mImplementationp->mGroupParcelsp->setEnabled(FALSE);
00671                 }
00672         }
00673 
00674 
00675 
00676         LLButton* earlierp, *laterp;
00677         LLTextEditor* textp;
00678         LLPanel* panelp;
00679 
00680         LLTabContainerCommon* tabcp = (LLTabContainerCommon*) 
00681                 getChildByName("group_money_tab_container", true);
00682 
00683         if ( !can_view )
00684         {
00685                 if ( tabcp )
00686                 {
00687                         S32 i;
00688                         S32 tab_count = tabcp->getTabCount();
00689 
00690                         for (i = tab_count - 1; i >=0; --i)
00691                         {
00692                                 tabcp->enableTabButton(i, false);
00693                         }
00694                 }
00695         }
00696 
00697         LLString loading_text = childGetText("loading_txt");
00698         
00699         //pull out the widgets for the L$ details tab
00700         earlierp = (LLButton*) getChildByName("earlier_details_button", true);
00701         laterp = (LLButton*) getChildByName("later_details_button", true);
00702         textp = (LLTextEditor*) getChildByName("group_money_details_text", true);
00703         panelp = (LLPanel*) getChildByName("group_money_details_tab", true);
00704 
00705         if ( !can_view )
00706         {
00707                 textp->setText(mImplementationp->mCantViewAccountsText);
00708         }
00709         else
00710         {
00711                 mImplementationp->mMoneyDetailsTabEHp = 
00712                         new LLGroupMoneyDetailsTabEventHandler(earlierp,
00713                                                                                                    laterp,
00714                                                                                                    textp,
00715                                                                                                    tabcp,
00716                                                                                                    panelp,
00717                                                                                                    loading_text,
00718                                                                                                    mGroupID);
00719         }
00720 
00721         textp = (LLTextEditor*) getChildByName("group_money_planning_text", true);
00722         panelp = (LLPanel*) getChildByName("group_money_planning_tab", true);
00723 
00724         if ( !can_view )
00725         {
00726                 textp->setText(mImplementationp->mCantViewAccountsText);
00727         }
00728         else
00729         {
00730                 mImplementationp->mMoneyPlanningTabEHp = 
00731                         new LLGroupMoneyPlanningTabEventHandler(textp,
00732                                                                                                         tabcp,
00733                                                                                                         panelp,
00734                                                                                                         loading_text,
00735                                                                                                         mGroupID);
00736         }
00737 
00738         //pull out the widgets for the L$ sales tab
00739         earlierp = (LLButton*) getChildByName("earlier_sales_button", true);
00740         laterp = (LLButton*) getChildByName("later_sales_button", true);
00741         textp = (LLTextEditor*) getChildByName("group_money_sales_text", true);
00742         panelp = (LLPanel*) getChildByName("group_money_sales_tab", true);
00743 
00744         if ( !can_view )
00745         {
00746                 textp->setText(mImplementationp->mCantViewAccountsText);
00747         }
00748         else
00749         {
00750                 mImplementationp->mMoneySalesTabEHp = 
00751                         new LLGroupMoneySalesTabEventHandler(earlierp,
00752                                                                                                  laterp,
00753                                                                                                  textp,
00754                                                                                                  tabcp,
00755                                                                                                  panelp,
00756                                                                                                  loading_text,
00757                                                                                                  mGroupID);
00758         }
00759 
00760         return LLPanelGroupTab::postBuild();
00761 }
00762 
00763 BOOL LLPanelGroupLandMoney::isVisibleByAgent(LLAgent* agentp)
00764 {
00765         return mAllowEdit && agentp->isInGroup(mGroupID);
00766 }
00767 
00768 void LLPanelGroupLandMoney::processPlacesReply(LLMessageSystem* msg, void**)
00769 {
00770         LLUUID group_id;
00771         msg->getUUID("AgentData", "QueryID", group_id);
00772 
00773         LLPanelGroupLandMoney* selfp = sGroupIDs.getIfThere(group_id);
00774         if(!selfp)
00775         {
00776                 llinfos << "Group Panel Land L$ " << group_id << " no longer in existence."
00777                                 << llendl;
00778                 return;
00779         }
00780 
00781         selfp->mImplementationp->processGroupLand(msg);
00782 }
00783 
00784 //*************************************************
00785 //** LLGroupMoneyTabEventHandler::impl Functions **
00786 //*************************************************
00787 
00788 class LLGroupMoneyTabEventHandler::impl
00789 {
00790 public:
00791         impl(LLButton* earlier_buttonp,
00792                  LLButton* later_buttonp,
00793                  LLTextEditor* text_editorp,
00794                  LLPanel* tabpanelp,
00795                  const LLString& loading_text,
00796                  const LLUUID& group_id,
00797                  S32 interval_length_days,
00798                  S32 max_interval_days);
00799         ~impl();
00800 
00801         bool getCanClickLater();
00802         bool getCanClickEarlier();
00803 
00804         void updateButtons();
00805 
00806 //member variables
00807 public:
00808         LLUUID mGroupID;
00809         LLUUID mPanelID;
00810 
00811         LLPanel* mTabPanelp;
00812 
00813         int mIntervalLength;
00814         int mMaxInterval;
00815         int mCurrentInterval;
00816 
00817         LLTextEditor* mTextEditorp;
00818         LLButton*     mEarlierButtonp;
00819         LLButton*     mLaterButtonp;
00820 
00821         LLString mLoadingText;
00822 };
00823 
00824 LLGroupMoneyTabEventHandler::impl::impl(LLButton* earlier_buttonp,
00825                                                                                 LLButton* later_buttonp,
00826                                                                                 LLTextEditor* text_editorp,
00827                                                                                 LLPanel* tabpanelp,
00828                                                                                 const LLString& loading_text,
00829                                                                                 const LLUUID& group_id,
00830                                                                                 S32 interval_length_days,
00831                                                                                 S32 max_interval_days)
00832 {
00833         mGroupID = group_id;
00834         mPanelID.generate();
00835 
00836         mIntervalLength = interval_length_days;
00837         mMaxInterval = max_interval_days;
00838         mCurrentInterval = 0;
00839 
00840         mTextEditorp = text_editorp;
00841         mEarlierButtonp = earlier_buttonp;
00842         mLaterButtonp = later_buttonp;
00843         mTabPanelp = tabpanelp;
00844 
00845         mLoadingText = loading_text;
00846 }
00847 
00848 LLGroupMoneyTabEventHandler::impl::~impl()
00849 {
00850 }
00851 
00852 bool LLGroupMoneyTabEventHandler::impl::getCanClickEarlier()
00853 {
00854         return (mCurrentInterval < mMaxInterval);
00855 }
00856 
00857 bool LLGroupMoneyTabEventHandler::impl::getCanClickLater()
00858 {
00859         return ( mCurrentInterval > 0 );
00860 }
00861 
00862 void LLGroupMoneyTabEventHandler::impl::updateButtons()
00863 {
00864         if ( mEarlierButtonp )
00865         {
00866                 mEarlierButtonp->setEnabled(getCanClickEarlier());
00867         }
00868         if ( mLaterButtonp )
00869         {
00870                 mLaterButtonp->setEnabled(getCanClickLater());
00871         }
00872 }
00873 
00874 //*******************************************
00875 //** LLGroupMoneyTabEventHandler Functions **
00876 //*******************************************
00877 
00878 LLMap<LLUUID, LLGroupMoneyTabEventHandler*> LLGroupMoneyTabEventHandler::sInstanceIDs;
00879 std::map<LLPanel*, LLGroupMoneyTabEventHandler*> LLGroupMoneyTabEventHandler::sTabsToHandlers;
00880 
00881 LLGroupMoneyTabEventHandler::LLGroupMoneyTabEventHandler(LLButton* earlier_buttonp,
00882                                                                                                                  LLButton* later_buttonp,
00883                                                                                                                  LLTextEditor* text_editorp,
00884                                                                                                                  LLTabContainerCommon* tab_containerp,
00885                                                                                                                  LLPanel* panelp,
00886                                                                                                                  const LLString& loading_text,
00887                                                                                                                  const LLUUID& group_id,
00888                                                                                                                  S32 interval_length_days,
00889                                                                                                                  S32 max_interval_days)
00890 {
00891         mImplementationp = new impl(earlier_buttonp,
00892                                                                 later_buttonp,
00893                                                                 text_editorp,
00894                                                                 panelp,
00895                                                                 loading_text,
00896                                                                 group_id,
00897                                                                 interval_length_days,
00898                                                                 max_interval_days);
00899 
00900         if ( earlier_buttonp )
00901         {
00902                 earlier_buttonp->setClickedCallback(clickEarlierCallback, this);
00903         }
00904 
00905         if ( later_buttonp )
00906         {
00907                 later_buttonp->setClickedCallback(clickLaterCallback, this);
00908         }
00909 
00910         mImplementationp->updateButtons();
00911 
00912         if ( tab_containerp && panelp )
00913         {
00914                 tab_containerp->setTabChangeCallback(panelp, clickTabCallback);
00915                 tab_containerp->setTabUserData(panelp, this);
00916         }
00917 
00918         sInstanceIDs.addData(mImplementationp->mPanelID, this);
00919         sTabsToHandlers[panelp] = this;
00920 }
00921 
00922 LLGroupMoneyTabEventHandler::~LLGroupMoneyTabEventHandler()
00923 {
00924         sInstanceIDs.removeData(mImplementationp->mPanelID);
00925         sTabsToHandlers.erase(mImplementationp->mTabPanelp);
00926 
00927         delete mImplementationp;
00928 }
00929 
00930 
00931 void LLGroupMoneyTabEventHandler::onClickTab()
00932 {
00933         requestData(gMessageSystem);
00934 }
00935 
00936 void LLGroupMoneyTabEventHandler::requestData(LLMessageSystem* msg)
00937 {
00938         //do nothing
00939 }
00940 
00941 void LLGroupMoneyTabEventHandler::processReply(LLMessageSystem* msg, void** data)
00942 {
00943         //do nothing
00944 }
00945 
00946 void LLGroupMoneyTabEventHandler::onClickEarlier()
00947 {
00948         if ( mImplementationp->mTextEditorp) 
00949         {
00950                 mImplementationp->mTextEditorp->setText(mImplementationp->mLoadingText);
00951         }
00952         mImplementationp->mCurrentInterval++;
00953 
00954         mImplementationp->updateButtons();
00955 
00956         requestData(gMessageSystem);
00957 }
00958 
00959 void LLGroupMoneyTabEventHandler::onClickLater()
00960 {
00961         if ( mImplementationp->mTextEditorp )
00962         {
00963                 mImplementationp->mTextEditorp->setText(mImplementationp->mLoadingText);
00964         }
00965         mImplementationp->mCurrentInterval--;
00966 
00967         mImplementationp->updateButtons();
00968 
00969         requestData(gMessageSystem);
00970 }
00971 
00972 //static
00973 void LLGroupMoneyTabEventHandler::clickEarlierCallback(void* data)
00974 {
00975         LLGroupMoneyTabEventHandler* selfp = (LLGroupMoneyTabEventHandler*) data;
00976 
00977         if ( selfp ) selfp->onClickEarlier();
00978 }
00979 
00980 //static
00981 void LLGroupMoneyTabEventHandler::clickLaterCallback(void* data)
00982 {
00983         LLGroupMoneyTabEventHandler* selfp = (LLGroupMoneyTabEventHandler*) data;
00984         if ( selfp ) selfp->onClickLater();
00985 }
00986 
00987 //static
00988 void LLGroupMoneyTabEventHandler::clickTabCallback(void* data, bool from_click)
00989 {
00990         LLGroupMoneyTabEventHandler* selfp = (LLGroupMoneyTabEventHandler*) data;
00991         if ( selfp ) selfp->onClickTab();
00992 }
00993 
00994 //**************************************************
00995 //** LLGroupMoneyDetailsTabEventHandler Functions **
00996 //**************************************************
00997 
00998 LLGroupMoneyDetailsTabEventHandler::LLGroupMoneyDetailsTabEventHandler(LLButton* earlier_buttonp,
00999                                                                                                                                            LLButton* later_buttonp,
01000                                                                                                                                            LLTextEditor* text_editorp,
01001                                                                                                                                            LLTabContainerCommon* tab_containerp,
01002                                                                                                                                            LLPanel* panelp,
01003                                                                                                                                            const LLString& loading_text,
01004                                                                                                                                            const LLUUID& group_id)
01005         : LLGroupMoneyTabEventHandler(earlier_buttonp,
01006                                                                   later_buttonp,
01007                                                                   text_editorp,
01008                                                                   tab_containerp,
01009                                                                   panelp,
01010                                                                   loading_text,
01011                                                                   group_id,
01012                                                                   SUMMARY_INTERVAL,
01013                                                                   SUMMARY_MAX)
01014 {
01015 }
01016 
01017 LLGroupMoneyDetailsTabEventHandler::~LLGroupMoneyDetailsTabEventHandler()
01018 {
01019 }
01020 
01021 void LLGroupMoneyDetailsTabEventHandler::requestData(LLMessageSystem* msg)
01022 {
01023         msg->newMessageFast(_PREHASH_GroupAccountDetailsRequest);
01024         msg->nextBlockFast(_PREHASH_AgentData);
01025         msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
01026         msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() );
01027         msg->addUUIDFast(_PREHASH_GroupID,  mImplementationp->mGroupID );
01028         msg->nextBlockFast(_PREHASH_MoneyData);
01029         msg->addUUIDFast(_PREHASH_RequestID, mImplementationp->mPanelID );
01030         msg->addS32Fast(_PREHASH_IntervalDays, mImplementationp->mIntervalLength );
01031         msg->addS32Fast(_PREHASH_CurrentInterval, mImplementationp->mCurrentInterval);
01032 
01033         gAgent.sendReliableMessage();
01034 
01035         if ( mImplementationp->mTextEditorp )
01036         {
01037                 mImplementationp->mTextEditorp->setText(mImplementationp->mLoadingText);
01038         }
01039 
01040         LLGroupMoneyTabEventHandler::requestData(msg);
01041 }
01042 
01043 void LLGroupMoneyDetailsTabEventHandler::processReply(LLMessageSystem* msg, 
01044                                                                                                           void** data)
01045 {
01046         LLUUID group_id;
01047         msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_GroupID, group_id );
01048         if (mImplementationp->mGroupID != group_id) 
01049         {
01050                 llwarns << "Group Account details not for this group!" << llendl;
01051                 return;
01052         }
01053 
01054         char line[MAX_STRING];          /*Flawfinder: ignore*/
01055         LLString text;
01056 
01057         char start_date[MAX_STRING];            /*Flawfinder: ignore*/
01058         S32 interval_days;
01059         S32 current_interval;
01060 
01061         msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_IntervalDays, interval_days );
01062         msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_CurrentInterval, current_interval );
01063         msg->getStringFast(_PREHASH_MoneyData, _PREHASH_StartDate, MAX_STRING, start_date);
01064 
01065         if ( interval_days != mImplementationp->mIntervalLength || 
01066                  current_interval != mImplementationp->mCurrentInterval )
01067         {
01068                 llinfos << "Out of date details packet " << interval_days << " " 
01069                         << current_interval << llendl;
01070                 return;
01071         }
01072 
01073         snprintf(line, MAX_STRING,  "%s\n\n", start_date);                      /* Flawfinder: ignore */
01074         text.append(line);
01075 
01076         S32 total_amount = 0;
01077         S32 transactions = msg->getNumberOfBlocksFast(_PREHASH_HistoryData);
01078         for(S32 i = 0; i < transactions; i++)
01079         {
01080                 S32                     amount = 0;
01081                 char            desc[MAX_STRING];               /*Flawfinder: ignore*/
01082 
01083                 msg->getStringFast(_PREHASH_HistoryData, _PREHASH_Description,  MAX_STRING, desc, i );
01084                 msg->getS32Fast(_PREHASH_HistoryData, _PREHASH_Amount,          amount, i);
01085 
01086                 if (amount != 0)
01087                 {
01088                         snprintf(line, MAX_STRING, "%-24s %6d\n", desc, amount );                       /* Flawfinder: ignore */
01089                         text.append(line);
01090                 }
01091                 else
01092                 {
01093                         // skip it
01094                 }
01095 
01096                 total_amount += amount;
01097         }
01098 
01099         text.append(1, '\n');
01100 
01101         snprintf(line, MAX_STRING, "%-24s %6d\n", "Total", total_amount );                      /* Flawfinder: ignore */
01102         text.append(line);
01103 
01104         if ( mImplementationp->mTextEditorp )
01105         {
01106                 mImplementationp->mTextEditorp->setText(text);
01107         }
01108 }
01109 
01110 //static
01111 void LLPanelGroupLandMoney::processGroupAccountDetailsReply(LLMessageSystem* msg, 
01112                                                                                                                         void** data)
01113 {
01114         LLUUID agent_id;
01115         msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id );
01116         if (gAgent.getID() != agent_id)
01117         {
01118                 llwarns << "Got group L$ history reply for another agent!"
01119                         << " Probably a userserver bug!" << llendl;
01120                 return;
01121         }
01122 
01123         LLUUID request_id;
01124         msg->getUUIDFast(_PREHASH_MoneyData, _PREHASH_RequestID, request_id );
01125         LLGroupMoneyTabEventHandler* selfp = LLGroupMoneyTabEventHandler::sInstanceIDs.getIfThere(request_id);
01126         if (!selfp)
01127         {
01128                 llwarns << "GroupAccountDetails recieved for non-existent group panel." << llendl;
01129                 return;
01130         }
01131 
01132         selfp->processReply(msg, data);
01133 }
01134 
01135 //************************************************
01136 //** LLGroupMoneySalesTabEventHandler Functions **
01137 //************************************************
01138 
01139 LLGroupMoneySalesTabEventHandler::LLGroupMoneySalesTabEventHandler(LLButton* earlier_buttonp,
01140                                                                                                                                    LLButton* later_buttonp,
01141                                                                                                                                    LLTextEditor* text_editorp,
01142                                                                                                                                    LLTabContainerCommon* tab_containerp,
01143                                                                                                                                    LLPanel* panelp,
01144                                                                                                                                    const LLString& loading_text,
01145                                                                                                                                    const LLUUID& group_id)
01146         : LLGroupMoneyTabEventHandler(earlier_buttonp,
01147                                                                   later_buttonp,
01148                                                                   text_editorp,
01149                                                                   tab_containerp,
01150                                                                   panelp,
01151                                                                   loading_text,
01152                                                                   group_id,
01153                                                                   SUMMARY_INTERVAL,
01154                                                                   SUMMARY_MAX)
01155 {
01156 }
01157 
01158 LLGroupMoneySalesTabEventHandler::~LLGroupMoneySalesTabEventHandler()
01159 {
01160 }
01161 
01162 void LLGroupMoneySalesTabEventHandler::requestData(LLMessageSystem* msg)
01163 {
01164         msg->newMessageFast(_PREHASH_GroupAccountTransactionsRequest);
01165         msg->nextBlockFast(_PREHASH_AgentData);
01166         msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
01167         msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() );
01168         msg->addUUIDFast(_PREHASH_GroupID, mImplementationp->mGroupID );
01169         msg->nextBlockFast(_PREHASH_MoneyData);
01170         msg->addUUIDFast(_PREHASH_RequestID, mImplementationp->mPanelID );
01171         msg->addS32Fast(_PREHASH_IntervalDays, mImplementationp->mIntervalLength );
01172         msg->addS32Fast(_PREHASH_CurrentInterval, mImplementationp->mCurrentInterval);
01173 
01174         gAgent.sendReliableMessage();
01175 
01176         if ( mImplementationp->mTextEditorp )
01177         {
01178                 mImplementationp->mTextEditorp->setText(mImplementationp->mLoadingText);
01179         }
01180 
01181         LLGroupMoneyTabEventHandler::requestData(msg);
01182 }
01183 
01184 void LLGroupMoneySalesTabEventHandler::processReply(LLMessageSystem* msg, 
01185                                                                                                         void** data)
01186 {
01187         LLUUID group_id;
01188         msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_GroupID, group_id );
01189         if (mImplementationp->mGroupID != group_id) 
01190         {
01191                 llwarns << "Group Account Transactions not for this group!" << llendl;
01192                 return;
01193         }
01194 
01195         char line[MAX_STRING];          /*Flawfinder: ignore*/
01196         std::string text = mImplementationp->mTextEditorp->getText();
01197 
01198         char start_date[MAX_STRING];            /*Flawfinder: ignore*/
01199         S32 interval_days;
01200         S32 current_interval;
01201 
01202         msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_IntervalDays, interval_days );
01203         msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_CurrentInterval, current_interval );
01204         msg->getStringFast(_PREHASH_MoneyData, _PREHASH_StartDate, MAX_STRING, start_date);
01205 
01206         if (interval_days != mImplementationp->mIntervalLength ||
01207             current_interval != mImplementationp->mCurrentInterval)
01208         {
01209                 llinfos << "Out of date details packet " << interval_days << " " 
01210                         << current_interval << llendl;
01211                 return;
01212         }
01213 
01214         // If this is the first packet, clear the text, don't append.
01215         // Start with the date.
01216         if (text == mImplementationp->mLoadingText)
01217         {
01218                 text.clear();
01219 
01220                 snprintf(line, MAX_STRING, "%s\n\n", start_date);                       /* Flawfinder: ignore */
01221                 text.append(line);
01222         }
01223 
01224         S32 transactions = msg->getNumberOfBlocksFast(_PREHASH_HistoryData);
01225         if (transactions == 0)
01226         {
01227                 text.append("(none)");
01228         }
01229         else
01230         {
01231                 for(S32 i = 0; i < transactions; i++)
01232                 {
01233                         const S32 SHORT_STRING = 64;
01234                         char            time[SHORT_STRING];             /*Flawfinder: ignore*/
01235                         S32                     type = 0;
01236                         S32                     amount = 0;
01237                         char            user[SHORT_STRING];             /*Flawfinder: ignore*/
01238                         char            item[SHORT_STRING];             /*Flawfinder: ignore*/
01239 
01240                         msg->getStringFast(_PREHASH_HistoryData, _PREHASH_Time,         SHORT_STRING, time, i);
01241                         msg->getStringFast(_PREHASH_HistoryData, _PREHASH_User,         SHORT_STRING, user, i );
01242                         msg->getS32Fast(_PREHASH_HistoryData, _PREHASH_Type,            type, i);
01243                         msg->getStringFast(_PREHASH_HistoryData, _PREHASH_Item,         SHORT_STRING, item, i );
01244                         msg->getS32Fast(_PREHASH_HistoryData, _PREHASH_Amount,  amount, i);
01245 
01246                         if (amount != 0)
01247                         {
01248                                 char* verb;
01249 
01250                                 switch(type)
01251                                 {
01252                                 case TRANS_OBJECT_SALE:
01253                                         verb = "bought";
01254                                         break;
01255                                 case TRANS_GIFT:
01256                                         verb = "paid you";
01257                                         break;
01258                                 case TRANS_PAY_OBJECT:
01259                                         verb = "paid into";
01260                                         break;
01261                                 case TRANS_LAND_PASS_SALE:
01262                                         verb = "bought pass to";
01263                                         break;
01264                                 case TRANS_EVENT_FEE:
01265                                         verb = "paid fee for event";
01266                                         break;
01267                                 case TRANS_EVENT_PRIZE:
01268                                         verb = "paid prize for event";
01269                                         break;
01270                                 default:
01271                                         verb = "";
01272                                         break;
01273                                 }
01274 
01275                                 snprintf(line, sizeof(line), "%s %6d - %s %s %s\n", time, amount, user, verb, item);                    /* Flawfinder: ignore */
01276                                 text.append(line);
01277                         }
01278                 }
01279         }
01280 
01281         if ( mImplementationp->mTextEditorp)
01282         {
01283                 mImplementationp->mTextEditorp->setText(text);
01284         }
01285 }
01286 
01287 //static
01288 void LLPanelGroupLandMoney::processGroupAccountTransactionsReply(LLMessageSystem* msg, 
01289                                                                                                                                  void** data)
01290 {
01291         LLUUID agent_id;
01292         msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id );
01293         if (gAgent.getID() != agent_id)
01294         {
01295                 llwarns << "Got group L$ history reply for another agent!"
01296                         << " Probably a userserver bug!" << llendl;
01297                 return;
01298         }
01299 
01300         LLUUID request_id;
01301         msg->getUUIDFast(_PREHASH_MoneyData, _PREHASH_RequestID, request_id );
01302 
01303         LLGroupMoneyTabEventHandler* self;
01304 
01305         self = LLGroupMoneyTabEventHandler::sInstanceIDs.getIfThere(request_id);
01306         if (!self)
01307         {
01308                 llwarns << "GroupAccountTransactions recieved for non-existent group panel." << llendl;
01309                 return;
01310         }
01311 
01312         self->processReply(msg, data);
01313 }
01314 
01315 //***************************************************
01316 //** LLGroupMoneyPlanningTabEventHandler Functions **
01317 //***************************************************
01318 
01319 LLGroupMoneyPlanningTabEventHandler::LLGroupMoneyPlanningTabEventHandler(LLTextEditor* text_editorp,
01320                                                                                                                                                  LLTabContainerCommon* tab_containerp,
01321                                                                                                                                                  LLPanel* panelp,
01322                                                                                                                                                  const LLString& loading_text,
01323                                                                                                                                                  const LLUUID& group_id)
01324         : LLGroupMoneyTabEventHandler(NULL,
01325                                                                   NULL,
01326                                                                   text_editorp,
01327                                                                   tab_containerp,
01328                                                                   panelp,
01329                                                                   loading_text,
01330                                                                   group_id,
01331                                                                   SUMMARY_INTERVAL,
01332                                                                   SUMMARY_MAX)
01333 {
01334 }
01335 
01336 LLGroupMoneyPlanningTabEventHandler::~LLGroupMoneyPlanningTabEventHandler()
01337 {
01338 }
01339 
01340 void LLGroupMoneyPlanningTabEventHandler::requestData(LLMessageSystem* msg)
01341 {
01342         msg->newMessageFast(_PREHASH_GroupAccountSummaryRequest);
01343         msg->nextBlockFast(_PREHASH_AgentData);
01344         msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
01345         msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() );
01346         msg->addUUIDFast(_PREHASH_GroupID, mImplementationp->mGroupID );
01347         msg->nextBlockFast(_PREHASH_MoneyData);
01348         msg->addUUIDFast(_PREHASH_RequestID, mImplementationp->mPanelID );
01349         msg->addS32Fast(_PREHASH_IntervalDays, mImplementationp->mIntervalLength);
01350         msg->addS32Fast(_PREHASH_CurrentInterval, 0); //planning has 0 interval
01351 
01352         gAgent.sendReliableMessage();
01353 
01354         if ( mImplementationp->mTextEditorp )
01355         {
01356                 mImplementationp->mTextEditorp->setText(mImplementationp->mLoadingText);
01357         }
01358 
01359         LLGroupMoneyTabEventHandler::requestData(msg);
01360 }
01361 
01362 void LLGroupMoneyPlanningTabEventHandler::processReply(LLMessageSystem* msg, 
01363                                                                                                                         void** data)
01364 {
01365         LLUUID group_id;
01366         msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_GroupID, group_id );
01367         if (mImplementationp->mGroupID != group_id) 
01368         {
01369                 llwarns << "Group Account Summary received not for this group!" << llendl;
01370                 return;
01371         }
01372 
01373         char line[MAX_STRING];          /*Flawfinder: ignore*/
01374         LLString text;
01375 
01376         char start_date[MAX_STRING];            /*Flawfinder: ignore*/
01377         char last_stipend_date[MAX_STRING];             /*Flawfinder: ignore*/
01378         char next_stipend_date[MAX_STRING];             /*Flawfinder: ignore*/
01379         S32 interval_days;
01380         S32 current_interval;
01381         S32 balance;
01382         S32 total_credits;
01383         S32 total_debits;
01384         S32 cur_object_tax;
01385         S32 cur_light_tax;
01386         S32 cur_land_tax;
01387         S32 cur_group_tax;
01388         S32 cur_parcel_dir_fee;
01389         S32 cur_total_tax;
01390         S32 proj_object_tax;
01391         S32 proj_light_tax;
01392         S32 proj_land_tax;
01393         S32 proj_group_tax;
01394         S32 proj_parcel_dir_fee;
01395         S32 proj_total_tax;
01396         S32     non_exempt_members;
01397 
01398         msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_IntervalDays, interval_days );
01399         msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_CurrentInterval, current_interval );
01400         msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_Balance, balance );
01401         msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_TotalCredits, total_credits );
01402         msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_TotalDebits, total_debits );
01403         msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_ObjectTaxCurrent, cur_object_tax );
01404         msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_LightTaxCurrent, cur_light_tax );
01405         msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_LandTaxCurrent, cur_land_tax );
01406         msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_GroupTaxCurrent, cur_group_tax );
01407         msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_ParcelDirFeeCurrent, cur_parcel_dir_fee );
01408         msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_ObjectTaxEstimate, proj_object_tax );
01409         msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_LightTaxEstimate, proj_light_tax );
01410         msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_LandTaxEstimate, proj_land_tax );
01411         msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_GroupTaxEstimate, proj_group_tax );
01412         msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_ParcelDirFeeEstimate, proj_parcel_dir_fee );
01413         msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_NonExemptMembers, non_exempt_members );
01414 
01415         msg->getStringFast(_PREHASH_MoneyData, _PREHASH_StartDate, MAX_STRING, start_date);
01416         msg->getStringFast(_PREHASH_MoneyData, _PREHASH_LastTaxDate, MAX_STRING, last_stipend_date);
01417         msg->getStringFast(_PREHASH_MoneyData, _PREHASH_TaxDate, MAX_STRING, next_stipend_date);
01418 
01419         cur_total_tax = cur_object_tax + cur_light_tax + cur_land_tax + cur_group_tax +  cur_parcel_dir_fee;
01420         proj_total_tax = proj_object_tax + proj_light_tax + proj_land_tax + proj_group_tax + proj_parcel_dir_fee;
01421 
01422         if (interval_days != mImplementationp->mIntervalLength || 
01423                 current_interval != mImplementationp->mCurrentInterval)
01424         {
01425                 llinfos << "Out of date summary packet " << interval_days << " " 
01426                         << current_interval << llendl;
01427                 return;
01428         }
01429 
01430         snprintf(line, MAX_STRING, "Summary for this week, beginning on %s\n", start_date);                     /* Flawfinder: ignore */
01431         text.append(line);
01432 
01433         if (current_interval == 0)
01434         {
01435                 snprintf(line, MAX_STRING, "The next stipend day is %s\n\n", next_stipend_date);                        /* Flawfinder: ignore */
01436                 text.append(line);
01437                 snprintf(line, MAX_STRING, "%-24sL$%6d\n", "Balance", balance );                        /* Flawfinder: ignore */
01438                 text.append(line);
01439 
01440                 text.append(1, '\n');
01441         }
01442 
01443         snprintf(line, MAX_STRING,  "                      Group       Individual Share\n");                    /* Flawfinder: ignore */
01444         text.append(line);
01445         snprintf(line, MAX_STRING,     "%-24s %6d      %6d \n", "Credits", total_credits, (S32)floor((F32)total_credits/(F32)non_exempt_members));                      /* Flawfinder: ignore */
01446         text.append(line);
01447         snprintf(line, MAX_STRING,     "%-24s %6d      %6d \n", "Debits", total_debits,  (S32)floor((F32)total_debits/(F32)non_exempt_members));                        /* Flawfinder: ignore */
01448         text.append(line);
01449         snprintf(line, MAX_STRING,     "%-24s %6d      %6d \n", "Total", total_credits + total_debits,  (S32)floor((F32)(total_credits + total_debits)/(F32)non_exempt_members));                       /* Flawfinder: ignore */
01450         text.append(line);
01451 
01452         if ( mImplementationp->mTextEditorp )
01453         {
01454                 mImplementationp->mTextEditorp->setText(text);
01455         }
01456 }
01457 
01458 //static
01459 void LLPanelGroupLandMoney::processGroupAccountSummaryReply(LLMessageSystem* msg, 
01460                                                                                                                         void** data)
01461 {
01462         LLUUID agent_id;
01463         msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id );
01464         if (gAgent.getID() != agent_id)
01465         {
01466                 llwarns << "Got group L$ history reply for another agent!"
01467                         << " Probably a userserver bug!" << llendl;
01468                 return;
01469         }
01470 
01471         LLUUID request_id;
01472         msg->getUUIDFast(_PREHASH_MoneyData, _PREHASH_RequestID, request_id );
01473 
01474         LLGroupMoneyTabEventHandler* self;
01475 
01476         self = LLGroupMoneyTabEventHandler::sInstanceIDs.getIfThere(request_id);
01477         if (!self)
01478         {
01479                 llwarns << "GroupAccountSummary recieved for non-existent group L$ planning tab." << llendl;
01480                 return;
01481         }
01482 
01483         self->processReply(msg, data);
01484 }

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