00001
00032 #include "llviewerprecompiledheaders.h"
00033
00034 #include "roles_constants.h"
00035
00036 #include "lllineeditor.h"
00037 #include "lltextbox.h"
00038 #include "lltexteditor.h"
00039 #include "llscrolllistctrl.h"
00040 #include "llradiogroup.h"
00041 #include "llspinctrl.h"
00042 #include "llpanelgroupvoting.h"
00043 #include "llnamelistctrl.h"
00044 #include "llbutton.h"
00045
00046 #include "llagent.h"
00047 #include "llfocusmgr.h"
00048 #include "llviewercontrol.h"
00049 #include "llviewerwindow.h"
00050
00051 class LLPanelGroupVoting::impl
00052 {
00053 public:
00054 impl(LLPanelGroupVoting& panel, const LLUUID& group_id);
00055 ~impl();
00056
00057 static void onClickCreateProposal(void* userdata);
00058 static void onClickYes(void *userdata);
00059 static void onClickNo(void *userdata);
00060 static void onClickAbstain(void *userdata);
00061 static void onClickSubmitProposal(void *userdata);
00062 static void onClickCancelProposal(void *userdata);
00063 static void onClickViewProposalList(void *userdata);
00064 static void onClickViewProposalItem(void *userdata);
00065 static void onDoubleClickProposal(void *userdata);
00066
00067 static void onDoubleClickHistoryItem(void *userdata);
00068 static void onClickViewHistoryItem(void *userdata);
00069 static void onClickViewHistoryList(void *userdata);
00070
00071 void sendGroupProposalsRequest(const LLUUID& group_id);
00072 void sendStartGroupProposal();
00073 void sendGroupProposalBallot(const char* vote);
00074 void sendGroupVoteHistoryRequest(const LLUUID& group_id);
00075
00076 void setEnableCreateProposal();
00077 void setEnableVoteProposal();
00078 void setEnableListProposals();
00079 void setEnableHistoryItem();
00080 void setEnableHistoryList();
00081
00082 void updateQuorumText();
00083 void addPendingActiveScrollListItem(unsigned int current,
00084 unsigned int expected,
00085 EAddPosition pos);
00086 void addPendingHistoryScrollListItem(unsigned int current,
00087 unsigned int expected,
00088 EAddPosition pos);
00089 void addNoActiveScrollListItem(EAddPosition pos);
00090 void addNoHistoryScrollListItem(EAddPosition pos);
00091
00092
00093 static void processGroupActiveProposalItemReply(LLMessageSystem* msg,
00094 void** data);
00095 static void processGroupVoteHistoryItemReply(LLMessageSystem* msg,
00096 void** data);
00097
00098 public:
00099 LLUUID mGroupID;
00100 LLUUID mProposalID;
00101
00102 LLPanelGroupVoting& mPanel;
00103
00104 LLSpinCtrl *mQuorum;
00105 LLTextBox *mQuorumLbl;
00106 LLSpinCtrl *mDuration;
00107 LLTextBox *mDurationLbl;
00108 LLTextBox *mDurationText;
00109 LLRadioGroup *mMajority;
00110 LLTextBox *mMajorityLbl;
00111 LLTextBox *mStartLbl;
00112 LLTextBox *mEndLbl;
00113 LLTextBox *mStartDate;
00114 LLTextBox *mEndDate;
00115
00116 LLButton *mBtnYes;
00117 LLButton *mBtnNo;
00118 LLButton *mBtnAbstain;
00119
00120 LLScrollListCtrl *mProposals;
00121 LLTextEditor *mProposalText;
00122 LLButton *mBtnCreateProposal;
00123 LLButton *mBtnSubmitProposal;
00124 LLButton *mBtnCancelProposal;
00125 LLButton *mBtnViewProposalList;
00126 LLButton *mBtnViewProposalItem;
00127
00128 LLScrollListCtrl *mVotesHistory;
00129 LLTextBox *mVotesHistoryLbl;
00130 LLTextEditor *mVoteHistoryText;
00131 LLTextBox *mVoteHistoryTextLbl;
00132 LLButton *mBtnViewHistoryList;
00133 LLButton *mBtnViewHistoryItem;
00134
00135 int mNumGroupMembers;
00136
00137 std::vector<LLSD> mActiveReceived;
00138 std::vector<LLSD> mHistoryReceived;
00139
00140 int mProposalColumnWidths[10];
00141 int mHistoryColumnWidths[10];
00142
00143 LLUUID mProposalTransID;
00144 LLUUID mHistoryTransID;
00145
00146 static std::map<LLUUID, LLPanelGroupVoting::impl*> sGroupIDs;
00147 };
00148
00149
00150
00151
00152
00153 LLPanelGroupVoting::impl::impl(LLPanelGroupVoting& panel, const LLUUID& group_id)
00154 : mPanel(panel),
00155 mGroupID(group_id)
00156 {
00157
00158 mNumGroupMembers = 0;
00159
00160 mProposalTransID = LLUUID::null;
00161 mHistoryTransID = LLUUID::null;
00162
00163 mProposalColumnWidths[0] = -1;
00164 mProposalColumnWidths[1] = 210;
00165 mProposalColumnWidths[2] = 120;
00166 mProposalColumnWidths[3] = -1;
00167 mProposalColumnWidths[4] = 30;
00168 for (int index = 5; index < 10; index++)
00169 {
00170 mProposalColumnWidths[index] = -1;
00171 }
00172
00173 mHistoryColumnWidths[0] = -1;
00174 mHistoryColumnWidths[1] = 210;
00175 mHistoryColumnWidths[2] = 120;
00176 mHistoryColumnWidths[3] = -1;
00177 mHistoryColumnWidths[4] = -1;
00178 mHistoryColumnWidths[5] = -1;
00179
00180
00181
00182
00183 sGroupIDs[group_id] = this;
00184
00185 mQuorum = NULL;
00186 mQuorumLbl = NULL;
00187 mDuration = NULL;
00188 mDurationLbl = NULL;
00189 mDurationText = NULL;
00190 mMajority = NULL;
00191 mMajorityLbl = NULL;
00192 mStartLbl = NULL;
00193 mEndLbl = NULL;
00194 mStartDate = NULL;
00195 mEndDate = NULL;
00196
00197 mBtnYes = NULL;
00198 mBtnNo = NULL;
00199 mBtnAbstain = NULL;
00200
00201 mProposals = NULL;
00202 mProposalText = NULL;
00203 mBtnCreateProposal = NULL;
00204 mBtnSubmitProposal = NULL;
00205 mBtnViewProposalList = NULL;
00206 mBtnViewProposalItem = NULL;
00207
00208 mVotesHistory = NULL;
00209 mVotesHistoryLbl = NULL;
00210 mVoteHistoryText = NULL;
00211 mVoteHistoryTextLbl = NULL;
00212 mBtnViewHistoryList = NULL;
00213 mBtnViewHistoryItem = NULL;
00214 }
00215
00216 LLPanelGroupVoting::impl::~impl()
00217 {
00218 sGroupIDs.erase(mGroupID);
00219 }
00220
00221 void LLPanelGroupVoting::impl::setEnableListProposals()
00222 {
00223
00224
00225
00226
00227
00228
00229
00230
00231 if (!gAgent.isInGroup(mGroupID))
00232 return;
00233
00234
00235 mPanel.childSetText("proposal_header", mPanel.childGetText("proposals_header_view_txt"));
00236 mPanel.childSetText("proposal_instructions", mPanel.childGetText("proposals_header_view_inst"));
00237 mPanel.childSetVisible("proposal_lbl", FALSE);
00238 mPanel.childSetVisible("proposal_voting_lbl", TRUE);
00239 mProposals->setVisible(TRUE);
00240 mProposals->setBgSelectedColor(gColors.getColor("ScrollSelectedBGColor"));
00241 mProposalText->setVisible(FALSE);
00242 mBtnYes->setEnabled(FALSE);
00243 mBtnYes->setVisible(FALSE);
00244 mBtnNo->setEnabled(FALSE);
00245 mBtnNo->setVisible(FALSE);
00246 mBtnAbstain->setEnabled(FALSE);
00247 mBtnAbstain->setVisible(FALSE);
00248 mBtnSubmitProposal->setEnabled(FALSE);
00249 mBtnSubmitProposal->setVisible(FALSE);
00250 mBtnCancelProposal->setEnabled(FALSE);
00251 mBtnCancelProposal->setVisible(FALSE);
00252
00253 mBtnViewProposalItem->setEnabled(TRUE);
00254 mBtnViewProposalItem->setVisible(TRUE);
00255
00256 mBtnViewProposalList->setEnabled(FALSE);
00257 mBtnViewProposalList->setVisible(FALSE);
00258
00259 mQuorumLbl->setVisible(FALSE);
00260 mQuorum->setEnabled(FALSE);
00261 mQuorum->setVisible(FALSE);
00262 mPanel.childSetVisible("quorum_text", FALSE);
00263
00264 mDurationLbl->setVisible(FALSE);
00265 mDuration->setEnabled(FALSE);
00266 mDuration->setVisible(FALSE);
00267 mDurationText->setVisible(FALSE);
00268
00269 mMajorityLbl->setVisible(FALSE);
00270 mMajority->setEnabled(FALSE);
00271 mMajority->setVisible(FALSE);
00272 mStartLbl->setVisible(FALSE);
00273 mStartDate->setVisible(FALSE);
00274 mEndLbl->setVisible(FALSE);
00275 mEndDate->setVisible(FALSE);
00276
00277
00278
00279 BOOL can_create = gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_START);
00280
00281 mBtnCreateProposal->setEnabled(can_create);
00282 mBtnCreateProposal->setVisible(can_create);
00283 }
00284
00285 void LLPanelGroupVoting::impl::setEnableVoteProposal()
00286 {
00287 if (!gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_VOTE))
00288 return;
00289
00290 LLScrollListItem *item = mProposals->getFirstSelected();
00291 if (item)
00292 {
00293 std::string already_voted;
00294 std::string vote_cast;
00295
00296 mProposalID = item->getUUID();
00297
00298
00299 LLScrollListCell * proposal_cell = item->getColumn(1);
00300 if ( proposal_cell )
00301 {
00302 mProposalText->setText(proposal_cell->getText());
00303 }
00304 else
00305 {
00306 mProposalText->setText(LLString());
00307 }
00308
00309 proposal_cell = item->getColumn(2);
00310 if (proposal_cell)
00311 {
00312 mEndDate->setText(proposal_cell->getText());
00313 }
00314 else
00315 {
00316 mEndDate->setText(LLString());
00317 }
00318
00319
00320 proposal_cell = item->getColumn(3);
00321 if (proposal_cell)
00322 {
00323 already_voted = proposal_cell->getText();
00324 }
00325 else
00326 {
00327 already_voted = "";
00328 }
00329
00330 proposal_cell = item->getColumn(5);
00331 if (proposal_cell)
00332 {
00333 mStartDate->setText(proposal_cell->getText());
00334 }
00335 else
00336 {
00337 mStartDate->setText(LLString());
00338 }
00339
00340 proposal_cell = item->getColumn(6);
00341 if (proposal_cell)
00342 {
00343 vote_cast = proposal_cell->getText();
00344 }
00345
00346
00347 proposal_cell = item->getColumn(8);
00348 if (proposal_cell)
00349 {
00350 mQuorum->set((F32)atoi(proposal_cell->getText().c_str()));
00351 }
00352 else
00353 {
00354 mQuorum->set(0);
00355 }
00356
00357 F32 majority = 0.0f;
00358 proposal_cell = item->getColumn(9);
00359 if (proposal_cell)
00360 {
00361 majority = (F32)atof(proposal_cell->getText().c_str());
00362 }
00363
00364 if(majority == 0.0f)
00365 {
00366 mMajority->setSelectedIndex(0);
00367 }
00368 else if (majority == 1.0f)
00369 {
00370
00371 mMajority->setSelectedIndex(2);
00372 }
00373 else
00374 {
00375
00376 mMajority->setSelectedIndex(1);
00377 }
00378
00379 if (already_voted == "Yes")
00380 {
00381 LLUIString votestr = mPanel.childGetText("proposals_header_voted_inst");
00382 votestr.setArg("[VOTE]", vote_cast);
00383 mPanel.childSetText("proposal_instructions", votestr.getString());
00384
00385 mBtnYes->setEnabled(FALSE);
00386 mBtnNo->setEnabled(FALSE);
00387 mBtnAbstain->setEnabled(FALSE);
00388 }
00389 else
00390 {
00391 mPanel.childSetText("proposal_instructions", mPanel.childGetText("proposals_header_vote_inst"));
00392
00393 mBtnYes->setEnabled(TRUE);
00394 mBtnNo->setEnabled(TRUE);
00395 mBtnAbstain->setEnabled(TRUE);
00396 }
00397
00398 mPanel.childSetText("proposal_header", mPanel.childGetText("proposals_header_vote_txt"));
00399 mPanel.childSetVisible("proposal_lbl", TRUE);
00400 mPanel.childSetVisible("proposal_voting_lbl", FALSE);
00401 mProposals->setVisible(FALSE);
00402 mProposalText->setEnabled(FALSE);
00403 mProposalText->setVisible(TRUE);
00404 mBtnYes->setVisible(TRUE);
00405 mBtnNo->setVisible(TRUE);
00406 mBtnAbstain->setVisible(TRUE);
00407 mBtnSubmitProposal->setEnabled(FALSE);
00408 mBtnSubmitProposal->setVisible(FALSE);
00409 mBtnCreateProposal->setEnabled(FALSE);
00410 mBtnCreateProposal->setVisible(FALSE);
00411 mBtnCancelProposal->setEnabled(FALSE);
00412 mBtnCancelProposal->setVisible(FALSE);
00413
00414 mBtnViewProposalItem->setEnabled(FALSE);
00415 mBtnViewProposalItem->setVisible(FALSE);
00416
00417 mBtnViewProposalList->setEnabled(TRUE);
00418 mBtnViewProposalList->setVisible(TRUE);
00419
00420 mQuorumLbl->setVisible(TRUE);
00421 mQuorum->setEnabled(FALSE);
00422 mQuorum->setVisible(TRUE);
00423 mPanel.childSetVisible("quorum_text", TRUE);
00424
00425 mDurationLbl->setVisible(FALSE);
00426 mDuration->setEnabled(FALSE);
00427 mDuration->setVisible(FALSE);
00428 mDurationText->setVisible(FALSE);
00429
00430 mMajorityLbl->setVisible(TRUE);
00431 mMajority->setEnabled(FALSE);
00432 mMajority->setVisible(TRUE);
00433 mStartLbl->setVisible(TRUE);
00434 mStartDate->setVisible(TRUE);
00435 mEndLbl->setVisible(TRUE);
00436 mEndDate->setVisible(TRUE);
00437 }
00438 }
00439
00440 void LLPanelGroupVoting::impl::setEnableCreateProposal()
00441 {
00442 if ( !gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_START) )
00443 return;
00444
00445 mPanel.childSetText("proposal_header", mPanel.childGetText("proposals_header_create_txt"));
00446 mPanel.childSetText("proposal_instructions", mPanel.childGetText("proposals_header_create_inst"));
00447 mPanel.childSetVisible("proposal_lbl", TRUE);
00448 mPanel.childSetVisible("proposal_voting_lbl", FALSE);
00449 mProposals->setVisible(FALSE);
00450 mProposalText->setEnabled(TRUE);
00451 mProposalText->setVisible(TRUE);
00452 mProposalText->setText(LLString::null);
00453 mBtnYes->setEnabled(FALSE);
00454 mBtnYes->setVisible(FALSE);
00455 mBtnNo->setEnabled(FALSE);
00456 mBtnNo->setVisible(FALSE);
00457 mBtnAbstain->setEnabled(FALSE);
00458 mBtnAbstain->setVisible(FALSE);
00459 mBtnSubmitProposal->setEnabled(TRUE);
00460 mBtnSubmitProposal->setVisible(TRUE);
00461 mBtnCancelProposal->setEnabled(TRUE);
00462 mBtnCancelProposal->setVisible(TRUE);
00463 mBtnCreateProposal->setEnabled(FALSE);
00464 mBtnCreateProposal->setVisible(FALSE);
00465
00466 mBtnViewProposalItem->setEnabled(FALSE);
00467 mBtnViewProposalItem->setVisible(FALSE);
00468
00469 mBtnViewProposalList->setEnabled(FALSE);
00470 mBtnViewProposalList->setVisible(FALSE);
00471
00472 mQuorumLbl->setVisible(TRUE);
00473 mQuorum->setEnabled(TRUE);
00474 mQuorum->setVisible(TRUE);
00475 mPanel.childSetVisible("quorum_text", TRUE);
00476
00477 mDurationLbl->setVisible(TRUE);
00478 mDuration->setEnabled(TRUE);
00479 mDuration->setVisible(TRUE);
00480 mDurationText->setVisible(TRUE);
00481
00482 mMajorityLbl->setVisible(TRUE);
00483 mMajority->setEnabled(TRUE);
00484 mMajority->setVisible(TRUE);
00485 mStartLbl->setVisible(FALSE);
00486 mStartDate->setVisible(FALSE);
00487 mEndLbl->setVisible(FALSE);
00488 mEndDate->setVisible(FALSE);
00489
00490 if (mQuorum->get() == 0)
00491 {
00492 mQuorum->set((F32)mNumGroupMembers);
00493 }
00494 mQuorum->setMaxValue((F32)mNumGroupMembers);
00495 }
00496
00497 void LLPanelGroupVoting::impl::setEnableHistoryList()
00498 {
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508 if (!gAgent.isInGroup(mGroupID))
00509 return;
00510
00511 mVotesHistoryLbl->setVisible(TRUE);
00512 mVotesHistory->setVisible(TRUE);
00513 mVotesHistory->setEnabled(TRUE);
00514
00515 mVoteHistoryTextLbl->setVisible(FALSE);
00516 mVoteHistoryText->setVisible(FALSE);
00517 mBtnViewHistoryList->setVisible(FALSE);
00518
00519 mBtnViewHistoryItem->setVisible(TRUE);
00520 mBtnViewHistoryItem->setEnabled(TRUE);
00521 }
00522
00523 void LLPanelGroupVoting::impl::setEnableHistoryItem()
00524 {
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535 if (!gAgent.isInGroup(mGroupID))
00536 return;
00537
00538 LLScrollListItem *item = mVotesHistory->getFirstSelected();
00539
00540 const LLScrollListCell *cell = item->getColumn(5);
00541 if (cell)
00542 {
00543 mVoteHistoryText->setText(cell->getText());
00544 }
00545 else
00546 {
00547 mVoteHistoryText->setText(LLString());
00548 }
00549 mVotesHistoryLbl->setVisible(FALSE);
00550 mVotesHistory->setVisible(FALSE);
00551
00552 mVoteHistoryTextLbl->setVisible(TRUE);
00553 mVoteHistoryText->setVisible(TRUE);
00554 mVoteHistoryText->setEnabled(FALSE);
00555
00556 mBtnViewHistoryList->setVisible(TRUE);
00557 mBtnViewHistoryList->setEnabled(TRUE);
00558 mBtnViewHistoryItem->setVisible(FALSE);
00559 }
00560
00561 void LLPanelGroupVoting::impl::sendGroupProposalsRequest(const LLUUID& group_id)
00562 {
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572 if ( !gAgent.isInGroup(mGroupID) )
00573 return;
00574
00575 mProposalTransID.generate();
00576 mProposals->deleteAllItems();
00577 mActiveReceived.clear();
00578
00579
00580
00581 addPendingActiveScrollListItem(0, 0, ADD_BOTTOM);
00582 mProposals->setCanSelect(FALSE);
00583
00584 LLMessageSystem *msg = gMessageSystem;
00585 msg->newMessageFast(_PREHASH_GroupActiveProposalsRequest);
00586 msg->nextBlockFast(_PREHASH_AgentData);
00587 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
00588 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() );
00589 msg->nextBlockFast(_PREHASH_GroupData);
00590 msg->addUUIDFast(_PREHASH_GroupID, group_id );
00591 msg->nextBlockFast(_PREHASH_TransactionData);
00592 msg->addUUIDFast(_PREHASH_TransactionID, mProposalTransID);
00593 gAgent.sendReliableMessage();
00594 }
00595
00596 void LLPanelGroupVoting::impl::sendStartGroupProposal()
00597 {
00598 if ( !gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_START) )
00599 return;
00600
00601 F32 majority = 0.f;
00602 S32 duration_seconds = (S32)mDuration->get()*24*60*60;
00603
00604 switch (mMajority->getSelectedIndex())
00605 {
00606 case 0:
00607 majority = 0.f;
00608 break;
00609 case 1:
00610 majority = 2.f/3.f;
00611 break;
00612 case 2:
00613 majority = 1.0f;
00614 break;
00615 }
00616
00617 S32 quorum = llfloor(mQuorum->get());
00618
00619 LLMessageSystem *msg = gMessageSystem;
00620
00621 msg->newMessageFast(_PREHASH_StartGroupProposal);
00622 msg->nextBlockFast(_PREHASH_AgentData);
00623 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
00624 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() );
00625
00626 msg->nextBlockFast(_PREHASH_ProposalData);
00627 msg->addUUIDFast(_PREHASH_GroupID, mGroupID);
00628 msg->addF32Fast(_PREHASH_Majority, majority );
00629 msg->addS32Fast(_PREHASH_Quorum, quorum );
00630 msg->addS32Fast(_PREHASH_Duration, duration_seconds );
00631 msg->addStringFast(_PREHASH_ProposalText, mProposalText->getText().c_str());
00632
00633 gAgent.sendReliableMessage();
00634 }
00635
00636 void LLPanelGroupVoting::impl::sendGroupProposalBallot(const char* vote)
00637 {
00638 if ( !gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_VOTE) )
00639 return;
00640
00641 LLMessageSystem *msg = gMessageSystem;
00642
00643 msg->newMessageFast(_PREHASH_GroupProposalBallot);
00644 msg->nextBlockFast(_PREHASH_AgentData);
00645 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
00646 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() );
00647
00648 msg->nextBlockFast(_PREHASH_ProposalData);
00649 msg->addUUIDFast(_PREHASH_ProposalID, mProposalID);
00650 msg->addUUIDFast(_PREHASH_GroupID, mGroupID);
00651 msg->addStringFast(_PREHASH_VoteCast, vote);
00652
00653 gAgent.sendReliableMessage();
00654 }
00655
00656 void LLPanelGroupVoting::impl::sendGroupVoteHistoryRequest(const LLUUID& group_id)
00657 {
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669 if (!gAgent.isInGroup(mGroupID))
00670 return;
00671
00672 mVotesHistory->deleteAllItems();
00673 mHistoryTransID.generate();
00674 mHistoryReceived.clear();
00675
00676
00677 addPendingHistoryScrollListItem(0, 0, ADD_BOTTOM);
00678 mVotesHistory->setCanSelect(FALSE);
00679
00680 LLMessageSystem *msg = gMessageSystem;
00681 msg->newMessageFast(_PREHASH_GroupVoteHistoryRequest);
00682 msg->nextBlockFast(_PREHASH_AgentData);
00683 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
00684 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() );
00685 msg->nextBlockFast(_PREHASH_GroupData);
00686 msg->addUUIDFast(_PREHASH_GroupID, group_id );
00687 msg->nextBlockFast(_PREHASH_TransactionData);
00688 msg->addUUIDFast(_PREHASH_TransactionID, mHistoryTransID);
00689 gAgent.sendReliableMessage();
00690 }
00691
00692 void LLPanelGroupVoting::impl::updateQuorumText()
00693 {
00694 mPanel.childSetTextArg("quorum_text", "[MEMBERS]", llformat("%d", mNumGroupMembers));
00695 }
00696
00697 void LLPanelGroupVoting::impl::addPendingActiveScrollListItem(unsigned int current,
00698 unsigned int expected,
00699 EAddPosition pos)
00700 {
00701 std::stringstream pending;
00702 pending << "Retrieving active proposals ("
00703 << current
00704 << "\\" << expected << ")";
00705
00706 LLSD row;
00707 row["columns"][0]["value"] = pending.str();
00708 row["columns"][0]["font"] = "SANSSERIF_SMALL";
00709 mProposals->addElement(row, pos);
00710 }
00711
00712 void LLPanelGroupVoting::impl::addNoActiveScrollListItem(EAddPosition pos)
00713 {
00714 LLSD row;
00715 row["columns"][0]["value"] = "There are currently no active proposals";
00716 row["columns"][0]["font"] = "SANSSERIF_SMALL";
00717 mProposals->addElement(row, pos);
00718 }
00719
00720 void LLPanelGroupVoting::impl::addNoHistoryScrollListItem(EAddPosition pos)
00721 {
00722 LLSD row;
00723 row["columns"][0]["value"] = "There are currently no archived proposals";
00724 row["columns"][0]["font"] = "SANSSERIF_SMALL";
00725 mVotesHistory->addElement(row, pos);
00726 }
00727
00728 void LLPanelGroupVoting::impl::addPendingHistoryScrollListItem(unsigned int current,
00729 unsigned int expected,
00730 EAddPosition pos)
00731 {
00732 std::stringstream pending;
00733 pending << "Retrieving archived proposals ("
00734 << current
00735 << "\\" << expected << ")";
00736
00737 LLSD row;
00738 row["columns"][0]["value"] = pending.str();
00739 row["columns"][0]["font"] = "SANSSERIF_SMALL";
00740
00741 mVotesHistory->addElement(row, pos);
00742 }
00743
00744
00745
00746 std::map<LLUUID, LLPanelGroupVoting::impl*> LLPanelGroupVoting::impl::sGroupIDs;
00747
00748
00749 void LLPanelGroupVoting::impl::processGroupActiveProposalItemReply(LLMessageSystem *msg, void**)
00750 {
00751 LLUUID agent_id;
00752 msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id );
00753 if (gAgent.getID() != agent_id)
00754 {
00755 llwarns << "Got active group proposals reply for another agent!"
00756 << " Probably a userserver bug!" << llendl;
00757 return;
00758 }
00759
00760 LLUUID group_id;
00761 LLUUID trans_id;
00762 msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_GroupID, group_id );
00763 impl* self = get_if_there(sGroupIDs, group_id, (impl*) NULL);
00764 if (!self)
00765 {
00766 return;
00767 }
00768
00769 msg->getUUIDFast(_PREHASH_TransactionData,
00770 _PREHASH_TransactionID,
00771 trans_id);
00772
00773 if ( self->mProposalTransID != trans_id ) return;
00774
00775
00776 U32 num_expected;
00777 const S32 MAX_STRING_NUM_LEN = 20;
00778 char item_num_string[DB_TERSE_DATETIME_BUF_SIZE];
00779 char proposal_text[DB_VOTE_TEXT_BUF_SIZE];
00780 char vote_cast[DB_VOTE_RESULT_BUF_SIZE];
00781 char start_datetime[DB_DATETIME_BUF_SIZE];
00782 char end_datetime[DB_DATETIME_BUF_SIZE];
00783 char vote_type[DB_VOTE_TYPE_BUF_SIZE];
00784 char majority_text[MAX_STRING_NUM_LEN];
00785 char quorum_text[MAX_STRING_NUM_LEN];
00786 char vote_initiator_string[UUID_STR_LENGTH];
00787
00788 LLUUID vote_id;
00789 LLUUID vote_initiator;
00790
00791 F32 majority;
00792 S32 quorum;
00793 BOOL already_voted;
00794 S32 num_proposals = msg->getNumberOfBlocksFast(_PREHASH_ProposalData);
00795
00796 msg->getU32Fast(_PREHASH_TransactionData,
00797 _PREHASH_TotalNumItems,
00798 num_expected);
00799
00800
00801
00802 self->mProposals->deleteAllItems();
00803
00804 self->mProposals->clearColumns();
00805
00806 for (int i = 0; i < num_proposals; i++)
00807 {
00808 msg->getStringFast(_PREHASH_ProposalData, _PREHASH_TerseDateID, DB_TERSE_DATETIME_BUF_SIZE, item_num_string, i );
00809 msg->getUUIDFast(_PREHASH_ProposalData, _PREHASH_VoteID, vote_id, i );
00810 msg->getStringFast(_PREHASH_ProposalData, _PREHASH_StartDateTime, DB_DATETIME_BUF_SIZE, start_datetime, i );
00811 msg->getStringFast(_PREHASH_ProposalData, _PREHASH_EndDateTime, DB_DATETIME_BUF_SIZE, end_datetime, i );
00812 msg->getUUIDFast(_PREHASH_ProposalData, _PREHASH_VoteInitiator, vote_initiator, i );
00813 msg->getBOOLFast(_PREHASH_ProposalData,_PREHASH_AlreadyVoted, already_voted, i );
00814 msg->getStringFast(_PREHASH_ProposalData,_PREHASH_VoteCast, DB_VOTE_RESULT_BUF_SIZE, vote_cast, i );
00815 msg->getStringFast(_PREHASH_ProposalData, _PREHASH_ProposalText, DB_VOTE_TEXT_BUF_SIZE, proposal_text, i );
00816 msg->getF32Fast(_PREHASH_ProposalData, _PREHASH_Majority, majority, i );
00817 msg->getS32Fast(_PREHASH_ProposalData, _PREHASH_Quorum, quorum, i );
00818
00819 vote_initiator.toString(vote_initiator_string);
00820 snprintf(majority_text, MAX_STRING_NUM_LEN, "%f", majority);
00821 snprintf(quorum_text, MAX_STRING_NUM_LEN, "%i", quorum);
00822
00823 LLSD row;
00824 S32 index = 0;
00825 row["id"] = vote_id;
00826 row["columns"][0]["column"] = "item_num";
00827 row["columns"][0]["value"] = item_num_string;
00828 row["columns"][0]["font"] = "SANSSERIF_SMALL";
00829 row["columns"][0]["width"] = self->mProposalColumnWidths[index++];
00830
00831 row["columns"][1]["column"] = "proposal_text";
00832 row["columns"][1]["value"] = proposal_text;
00833 row["columns"][1]["font"] = "SANSSERIF_SMALL";
00834 row["columns"][1]["width"] = self->mProposalColumnWidths[index++];
00835
00836 row["columns"][2]["column"] = "end_datetime";
00837 row["columns"][2]["value"] = end_datetime;
00838 row["columns"][2]["font"] = "SANSSERIF_SMALL";
00839 row["columns"][2]["width"] = self->mProposalColumnWidths[index++];
00840
00841 row["columns"][3]["column"] = "vote_type";
00842 row["columns"][3]["value"] = vote_type;
00843 row["columns"][3]["font"] = "SANSSERIF_SMALL";
00844 row["columns"][3]["width"] = self->mProposalColumnWidths[index++];
00845
00846 row["columns"][4]["column"] = "already_voted";
00847 row["columns"][4]["value"] = already_voted ? "Yes" : "No";
00848 row["columns"][4]["font"] = "SANSSERIF_SMALL";
00849 row["columns"][4]["width"] = self->mProposalColumnWidths[index++];
00850
00851 row["columns"][5]["column"] = "start_datetime";
00852 row["columns"][5]["value"] = start_datetime;
00853 row["columns"][5]["font"] = "SANSSERIF_SMALL";
00854 row["columns"][5]["width"] = self->mProposalColumnWidths[index++];
00855
00856 row["columns"][6]["column"] = "vote_cast";
00857 row["columns"][6]["value"] = vote_cast;
00858 row["columns"][6]["font"] = "SANSSERIF_SMALL";
00859 row["columns"][6]["width"] = self->mProposalColumnWidths[index++];
00860
00861 row["columns"][7]["column"] = "vote_initator_string";
00862 row["columns"][7]["value"] = vote_initiator_string;
00863 row["columns"][7]["font"] = "SANSSERIF_SMALL";
00864 row["columns"][7]["width"] = self->mProposalColumnWidths[index++];
00865
00866 row["columns"][8]["column"] = "quorum_text";
00867 row["columns"][8]["value"] = quorum_text;
00868 row["columns"][8]["font"] = "SANSSERIF_SMALL";
00869 row["columns"][8]["width"] = self->mProposalColumnWidths[index++];
00870
00871 row["columns"][9]["column"] = "majority_text";
00872 row["columns"][9]["value"] = majority_text;
00873 row["columns"][9]["font"] = "SANSSERIF_SMALL";
00874 row["columns"][9]["width"] = self->mProposalColumnWidths[index++];
00875
00876 self->mActiveReceived.push_back(row);
00877 }
00878
00879 int received = self->mActiveReceived.size();
00880 if ( num_expected == 0 )
00881 {
00882
00883
00884 self->addNoActiveScrollListItem(ADD_BOTTOM);
00885 self->mProposals->setCanSelect(FALSE);
00886 }
00887 else if ( (U32)received != num_expected )
00888 {
00889 self->addPendingActiveScrollListItem(received,
00890 num_expected,
00891 ADD_BOTTOM);
00892 self->mProposals->setCanSelect(FALSE);
00893 }
00894 else
00895 {
00896
00897 std::vector<LLSD>::iterator it = self->mActiveReceived.begin();
00898 std::vector<LLSD>::iterator end = self->mActiveReceived.end();
00899
00900 for (; it != end; it++)
00901 {
00902 self->mProposals->addElement((*it), ADD_SORTED);
00903 }
00904
00905 self->mProposals->setCanSelect(TRUE);
00906 }
00907 }
00908
00909
00910 void LLPanelGroupVoting::impl::processGroupVoteHistoryItemReply(LLMessageSystem *msg, void**)
00911 {
00912 LLUUID agent_id;
00913 msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id );
00914 if (gAgent.getID() != agent_id)
00915 {
00916 llwarns << "Got group voting history reply for another agent!"
00917 << " Probably a userserver bug!" << llendl;
00918 return;
00919 }
00920
00921 LLUUID group_id;
00922 msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_GroupID, group_id );
00923 impl* self = sGroupIDs[group_id];
00924 if (!self)
00925 {
00926 return;
00927 }
00928
00929 LLUUID trans_id;
00930 U32 num_expected;
00931
00932 msg->getU32Fast(_PREHASH_TransactionData,
00933 _PREHASH_TotalNumItems,
00934 num_expected);
00935 msg->getUUIDFast(_PREHASH_TransactionData,
00936 _PREHASH_TransactionID,
00937 trans_id);
00938
00939 if ( self->mHistoryTransID != trans_id ) return;
00940
00941
00942
00943
00944
00945 self->mVotesHistory->deleteAllItems();
00946
00947 self->mVotesHistory->clearColumns();
00948
00949 if ( num_expected == 0 )
00950 {
00951
00952
00953 self->addNoHistoryScrollListItem(ADD_BOTTOM);
00954 self->mVotesHistory->setCanSelect(FALSE);
00955
00956 return;
00957 }
00958
00959 const S32 ITEM_NUM_MAX_BUF_LEN = 15;
00960 char item_num_string[ITEM_NUM_MAX_BUF_LEN];
00961 char proposal_text[DB_VOTE_TEXT_BUF_SIZE];
00962 char vote_result[MAX_STRING];
00963 char start_datetime[DB_DATETIME_BUF_SIZE];
00964 char end_datetime[DB_DATETIME_BUF_SIZE];
00965 char vote_type[DB_VOTE_TYPE_BUF_SIZE];
00966
00967 LLString vote_text;
00968 LLUUID vote_id;
00969 LLUUID vote_initiator;
00970 LLUUID winner_id;
00971
00972 F32 majority;
00973 S32 quorum;
00974
00975 msg->getStringFast(_PREHASH_HistoryItemData, _PREHASH_TerseDateID, ITEM_NUM_MAX_BUF_LEN, item_num_string );
00976 msg->getUUIDFast(_PREHASH_HistoryItemData, _PREHASH_VoteID, vote_id );
00977 msg->getStringFast(_PREHASH_HistoryItemData, _PREHASH_StartDateTime, DB_DATETIME_BUF_SIZE, start_datetime );
00978 msg->getStringFast(_PREHASH_HistoryItemData, _PREHASH_EndDateTime, DB_DATETIME_BUF_SIZE, end_datetime );
00979 msg->getUUIDFast(_PREHASH_HistoryItemData, _PREHASH_VoteInitiator, vote_initiator);
00980 msg->getStringFast(_PREHASH_HistoryItemData, _PREHASH_VoteType, DB_VOTE_TYPE_BUF_SIZE, vote_type);
00981 msg->getStringFast(_PREHASH_HistoryItemData,_PREHASH_VoteResult, DB_VOTE_RESULT_BUF_SIZE, vote_result);
00982 msg->getStringFast(_PREHASH_HistoryItemData, _PREHASH_ProposalText, DB_VOTE_TEXT_BUF_SIZE, proposal_text );
00983 msg->getF32Fast(_PREHASH_HistoryItemData, _PREHASH_Majority, majority);
00984 msg->getS32Fast(_PREHASH_HistoryItemData, _PREHASH_Quorum, quorum);
00985
00986 S32 vote_items = msg->getNumberOfBlocksFast(_PREHASH_VoteItem);
00987
00988 if (vote_items > 0)
00989 {
00990 if (!strcmp(vote_type, "Proposal"))
00991 {
00992 LLSD row;
00993 row["id"] = vote_id;
00994
00995 S32 index = 0;
00996 row["columns"][0]["column"] = "item_num";
00997 row["columns"][0]["value"] = item_num_string;
00998 row["columns"][0]["font"] = "SANSSERIF_SMALL";
00999 row["columns"][0]["width"] = self->mHistoryColumnWidths[index++];
01000
01001 vote_text.assign(proposal_text);
01002 vote_text.append("\n\n--\n");
01003 if (!strcmp(vote_result, "Success"))
01004 {
01005 vote_text.append("Proposal PASSED.");
01006 }
01007 else
01008 {
01009 vote_text.append("Proposal FAILED.");
01010 }
01011 vote_text.append(" Votes->\n");
01012
01013 char vote_result[DB_VOTE_RESULT_BUF_SIZE];
01014 char result_msg[MAX_STRING];
01015 S32 num_votes;
01016
01017 for (S32 i = 0; i < vote_items; ++i)
01018 {
01019 msg->getStringFast(_PREHASH_VoteItem, _PREHASH_VoteCast, DB_VOTE_RESULT_BUF_SIZE, vote_result, i);
01020 msg->getS32Fast(_PREHASH_VoteItem, _PREHASH_NumVotes, num_votes, i);
01021 snprintf(result_msg, MAX_STRING,
01022 " %s: %d\n",
01023 vote_result,
01024 num_votes);
01025 vote_text.append(result_msg);
01026 }
01027
01028 vote_text.append("\n");
01029
01030 LLString vote_text_stripped = vote_text;
01031 LLString::stripNonprintable(vote_text_stripped);
01032
01033 row["columns"][1]["column"] = "vote_text_stripped";
01034 row["columns"][1]["value"] = vote_text_stripped;
01035 row["columns"][1]["font"] = "SANSSERIF_SMALL";
01036 row["columns"][1]["width"] = self->mHistoryColumnWidths[index++];
01037
01038 row["columns"][2]["column"] = "end_datetime";
01039 row["columns"][2]["value"] = end_datetime;
01040 row["columns"][2]["font"] = "SANSSERIF_SMALL";
01041 row["columns"][2]["width"] = self->mHistoryColumnWidths[index++];
01042
01043 row["columns"][3]["column"] = "vote_type";
01044 row["columns"][3]["value"] = vote_type;
01045 row["columns"][3]["font"] = "SANSSERIF_SMALL";
01046 row["columns"][3]["width"] = self->mHistoryColumnWidths[index++];
01047
01048 row["columns"][4]["column"] = "vote_result";
01049 row["columns"][4]["value"] = vote_result;
01050 row["columns"][4]["font"] = "SANSSERIF_SMALL";
01051 row["columns"][4]["width"] = self->mHistoryColumnWidths[index++];
01052
01053 row["columns"][5]["column"] = "vote_text";
01054 row["columns"][5]["value"] = vote_text;
01055 row["columns"][5]["font"] = "SANSSERIF_SMALL";
01056 row["columns"][5]["width"] = self->mHistoryColumnWidths[index++];
01057
01058
01059
01060
01061
01062
01063
01064 self->mHistoryReceived.push_back(row);
01065 }
01066 }
01067
01068 int received = self->mHistoryReceived.size();
01069 if ( (U32)received != num_expected )
01070 {
01071 self->addPendingHistoryScrollListItem(received,
01072 num_expected,
01073 ADD_BOTTOM);
01074 self->mVotesHistory->setCanSelect(FALSE);
01075 }
01076 else
01077 {
01078
01079 std::vector<LLSD>::iterator it = self->mHistoryReceived.begin();
01080 std::vector<LLSD>::iterator end = self->mHistoryReceived.end();
01081
01082 for (; it != end; it++)
01083 {
01084 self->mVotesHistory->addElement((*it), ADD_SORTED);
01085 }
01086
01087 self->mVotesHistory->setCanSelect(TRUE);
01088 }
01089 }
01090
01091
01092 void LLPanelGroupVoting::impl::onClickCreateProposal(void* userdata)
01093 {
01094 impl* self = (impl*)userdata;
01095 if ( self ) self->setEnableCreateProposal();
01096 }
01097
01098
01099 void LLPanelGroupVoting::impl::onClickYes(void *userdata)
01100 {
01101 LLPanelGroupVoting::impl* self = (LLPanelGroupVoting::impl*)userdata;
01102
01103 if ( self )
01104 {
01105 self->mPanel.childSetText("proposal_instructions", self->mPanel.childGetText("proposals_submit_yes_txt"));
01106 self->sendGroupProposalBallot("Yes");
01107
01108
01109 self->sendGroupProposalsRequest(self->mGroupID);
01110 self->sendGroupVoteHistoryRequest(self->mGroupID);
01111 self->setEnableListProposals();
01112 }
01113 }
01114
01115
01116 void LLPanelGroupVoting::impl::onClickNo(void *userdata)
01117 {
01118 LLPanelGroupVoting::impl* self = (LLPanelGroupVoting::impl*)userdata;
01119
01120 if ( self )
01121 {
01122 self->mPanel.childSetText("proposal_instructions", self->mPanel.childGetText("proposals_submit_no_txt"));
01123 self->sendGroupProposalBallot("No");
01124
01125
01126 self->sendGroupProposalsRequest(self->mGroupID);
01127 self->sendGroupVoteHistoryRequest(self->mGroupID);
01128 self->setEnableListProposals();
01129 }
01130 }
01131
01132
01133 void LLPanelGroupVoting::impl::onClickAbstain(void *userdata)
01134 {
01135 impl* self = (LLPanelGroupVoting::impl*) userdata;
01136
01137 if ( self )
01138 {
01139 self->mPanel.childSetText("proposal_instructions", self->mPanel.childGetText("proposals_submit_abstain_txt"));
01140 self->sendGroupProposalBallot("Abstain");
01141
01142
01143 self->sendGroupProposalsRequest(self->mGroupID);
01144 self->sendGroupVoteHistoryRequest(self->mGroupID);
01145 self->setEnableListProposals();
01146 }
01147 }
01148
01149
01150 void LLPanelGroupVoting::impl::onClickSubmitProposal(void *userdata)
01151 {
01152 gFocusMgr.setKeyboardFocus(NULL, NULL);
01153 impl* self = (impl*)userdata;
01154
01155 if ( self && self->mProposalText )
01156 {
01157
01158
01159 if ( self->mProposalText->getText().empty() )
01160 {
01161
01162 LLString::format_map_t args;
01163 args["[MESSAGE]"] = self->mPanel.childGetText("empty_proposal_txt");
01164 gViewerWindow->alertXml("GenericAlert", args);
01165 return;
01166 }
01167
01168 self->mPanel.childSetText("proposal_instructions", self->mPanel.childGetText("proposals_submit_new_txt"));
01169 self->sendStartGroupProposal();
01170
01171
01172 self->sendGroupProposalsRequest(self->mGroupID);
01173 self->setEnableListProposals();
01174 }
01175 }
01176
01177
01178 void LLPanelGroupVoting::impl::onClickCancelProposal(void* userdata)
01179 {
01180 impl* self = (impl*)userdata;
01181
01182 if ( self )
01183 {
01184 self->setEnableListProposals();
01185 }
01186 }
01187
01188
01189 void LLPanelGroupVoting::impl::onClickViewProposalList(void *userdata)
01190 {
01191 impl* self = (LLPanelGroupVoting::impl*)userdata;
01192
01193 if ( self ) self->setEnableListProposals();
01194 }
01195
01196
01197 void LLPanelGroupVoting::impl::onClickViewProposalItem(void *userdata)
01198 {
01199 impl* self = (LLPanelGroupVoting::impl*)userdata;
01200
01201 if ( self && self->mProposals )
01202 {
01203 LLScrollListItem * proposal = self->mProposals->getFirstSelected();
01204
01205 if (proposal && proposal->getColumn(2))
01206 {
01207 self->setEnableVoteProposal();
01208 }
01209 else
01210 {
01211 gViewerWindow->alertXml("SelectProposalToView");
01212 }
01213 }
01214 }
01215
01216
01217 void LLPanelGroupVoting::impl::onDoubleClickProposal(void *userdata)
01218 {
01219 impl* self = (impl*)userdata;
01220 if ( self && self->mProposals->getFirstSelected() != NULL )
01221 {
01222 self->setEnableVoteProposal();
01223 }
01224 }
01225
01226
01227 void LLPanelGroupVoting::impl::onDoubleClickHistoryItem(void *userdata)
01228 {
01229 impl* self = (impl*)userdata;
01230 if ( self && self->mVotesHistory->getFirstSelected() != NULL )
01231 {
01232 self->setEnableHistoryItem();
01233 }
01234 }
01235
01236
01237 void LLPanelGroupVoting::impl::onClickViewHistoryItem(void *userdata)
01238 {
01239 impl* self = (impl*)userdata;
01240
01241 if ( self && self->mVotesHistory )
01242 {
01243 LLScrollListItem * historic = self->mVotesHistory->getFirstSelected();
01244
01245 if (historic && historic->getColumn(2))
01246 {
01247 self->setEnableHistoryItem();
01248 }
01249 else
01250 {
01251 gViewerWindow->alertXml("SelectHistoryItemToView");
01252 }
01253 }
01254 }
01255
01256
01257 void LLPanelGroupVoting::impl::onClickViewHistoryList(void *userdata)
01258 {
01259 impl* self = (impl*)userdata;
01260
01261 if ( self) self->setEnableHistoryList();
01262 }
01263
01264
01265
01266
01267
01268
01269 void* LLPanelGroupVoting::createTab(void* data)
01270 {
01271 LLUUID* group_id = static_cast<LLUUID*>(data);
01272 return new LLPanelGroupVoting("panel group voting", *group_id);
01273 }
01274
01275 LLPanelGroupVoting::LLPanelGroupVoting(const std::string& name,
01276 const LLUUID& group_id)
01277 : LLPanelGroupTab(name, group_id)
01278 {
01279 mImpl = new impl(*this, group_id);
01280 }
01281
01282 LLPanelGroupVoting::~LLPanelGroupVoting()
01283 {
01284 delete mImpl;
01285 }
01286
01287 BOOL LLPanelGroupVoting::isVisibleByAgent(LLAgent* agentp)
01288 {
01289
01290 return mAllowEdit && agentp->isInGroup(mGroupID);
01291 }
01292
01293 BOOL LLPanelGroupVoting::postBuild()
01294 {
01295 bool recurse = true;
01296
01297 mImpl->mDurationText = (LLTextBox*) getChildByName("duration_text",
01298 recurse);
01299 mImpl->mQuorum = (LLSpinCtrl*) getChildByName("quorum", recurse);
01300 mImpl->mQuorumLbl = (LLTextBox*) getChildByName("quorum_lbl", recurse);
01301 mImpl->mDuration = (LLSpinCtrl*) getChildByName("duration", recurse);
01302 mImpl->mDurationLbl = (LLTextBox*) getChildByName("duration_lbl", recurse);
01303 mImpl->mMajority = (LLRadioGroup*) getChildByName("majority", recurse);
01304 mImpl->mMajorityLbl = (LLTextBox*) getChildByName("majority_lbl", recurse);
01305
01306 mImpl->mStartLbl = (LLTextBox*) getChildByName("start_lbl", recurse);
01307 mImpl->mEndLbl = (LLTextBox*) getChildByName("end_lbl", recurse);
01308 mImpl->mStartDate = (LLTextBox*) getChildByName("start_date", recurse);
01309 mImpl->mEndDate = (LLTextBox*) getChildByName("end_date", recurse);
01310
01311 mImpl->mBtnYes = (LLButton*) getChildByName("btn_yes", recurse);
01312 mImpl->mBtnNo = (LLButton*) getChildByName("btn_no", recurse);
01313 mImpl->mBtnAbstain = (LLButton*) getChildByName("btn_abstain", recurse);
01314
01315 mImpl->mProposals =
01316 (LLScrollListCtrl*) getChildByName("proposals", recurse);
01317 mImpl->mProposalText =
01318 (LLTextEditor*) getChildByName("proposal_text", recurse);
01319
01320 mImpl->mBtnCreateProposal = (LLButton*) getChildByName("btn_proposal",
01321 recurse);
01322 mImpl->mBtnSubmitProposal = (LLButton*) getChildByName("btn_submit",
01323 recurse);
01324 mImpl->mBtnCancelProposal = (LLButton*) getChildByName("btn_cancel",
01325 recurse);
01326
01327 mImpl->mBtnViewProposalList =
01328 (LLButton*) getChildByName("btn_view_proposal_list", recurse);
01329 mImpl->mBtnViewProposalItem =
01330 (LLButton*) getChildByName("btn_view_proposal_item", recurse);
01331
01332 mImpl->mVotesHistory = (LLScrollListCtrl*)getChildByName("history_list",
01333 recurse);
01334 mImpl->mVotesHistoryLbl = (LLTextBox*) getChildByName("history_list_lbl",
01335 recurse);
01336 mImpl->mVoteHistoryText = (LLTextEditor*) getChildByName("vote_text",
01337 recurse);
01338 mImpl->mVoteHistoryTextLbl = (LLTextBox*) getChildByName("vote_text_lbl",
01339 recurse);
01340
01341 mImpl->mBtnViewHistoryList =
01342 (LLButton*)getChildByName("btn_view_history_list", recurse);
01343 mImpl->mBtnViewHistoryItem =
01344 (LLButton*)getChildByName("btn_view_history_item", recurse);
01345
01346 mImpl->updateQuorumText();
01347
01348 bool success = (mImpl->mDurationText &&
01349 mImpl->mQuorum &&
01350 mImpl->mQuorumLbl &&
01351 mImpl->mDuration &&
01352 mImpl->mDurationLbl &&
01353 mImpl->mMajority &&
01354 mImpl->mMajorityLbl &&
01355 mImpl->mStartLbl &&
01356 mImpl->mEndLbl &&
01357 mImpl->mStartDate &&
01358 mImpl->mEndDate &&
01359 mImpl->mBtnYes &&
01360 mImpl->mBtnNo &&
01361 mImpl->mBtnAbstain &&
01362 mImpl->mProposals &&
01363 mImpl->mProposalText &&
01364 mImpl->mBtnCreateProposal &&
01365 mImpl->mBtnSubmitProposal &&
01366 mImpl->mBtnCancelProposal &&
01367 mImpl->mBtnViewProposalList &&
01368 mImpl->mBtnViewProposalItem &&
01369 mImpl->mVotesHistory &&
01370 mImpl->mVotesHistoryLbl &&
01371 mImpl->mVoteHistoryText &&
01372 mImpl->mVoteHistoryTextLbl &&
01373 mImpl->mBtnViewHistoryList &&
01374 mImpl->mBtnViewHistoryItem );
01375
01376
01377 if ( success )
01378 {
01379 mImpl->mProposals->setDoubleClickCallback(impl::onDoubleClickProposal);
01380 mImpl->mProposals->setCallbackUserData(mImpl);
01381
01382 mImpl->mVotesHistory->setDoubleClickCallback(impl::onDoubleClickHistoryItem);
01383 mImpl->mVotesHistory->setCallbackUserData(mImpl);
01384
01385 mImpl->mBtnAbstain->setClickedCallback(impl::onClickAbstain);
01386 mImpl->mBtnAbstain->setCallbackUserData(mImpl);
01387
01388 mImpl->mBtnNo->setClickedCallback(impl::onClickNo);
01389 mImpl->mBtnNo->setCallbackUserData(mImpl);
01390
01391 mImpl->mBtnYes->setClickedCallback(impl::onClickYes);
01392 mImpl->mBtnYes->setCallbackUserData(mImpl);
01393
01394 mImpl->mBtnCreateProposal->setClickedCallback(impl::onClickCreateProposal);
01395 mImpl->mBtnCreateProposal->setCallbackUserData(mImpl);
01396
01397 mImpl->mBtnSubmitProposal->setClickedCallback(impl::onClickSubmitProposal);
01398 mImpl->mBtnSubmitProposal->setCallbackUserData(mImpl);
01399
01400 mImpl->mBtnCancelProposal->setClickedCallback(impl::onClickCancelProposal);
01401 mImpl->mBtnCancelProposal->setCallbackUserData(mImpl);
01402
01403 mImpl->mBtnViewProposalList->setClickedCallback(impl::onClickViewProposalList);
01404 mImpl->mBtnViewProposalList->setCallbackUserData(mImpl);
01405
01406 mImpl->mBtnViewProposalItem->setClickedCallback(impl::onClickViewProposalItem);
01407 mImpl->mBtnViewProposalItem->setCallbackUserData(mImpl);
01408
01409 mImpl->mBtnViewHistoryList->setClickedCallback(impl::onClickViewHistoryList);
01410 mImpl->mBtnViewHistoryList->setCallbackUserData(mImpl);
01411
01412 mImpl->mBtnViewHistoryItem->setClickedCallback(impl::onClickViewHistoryItem);
01413 mImpl->mBtnViewHistoryItem->setCallbackUserData(mImpl);
01414
01415 gMessageSystem->setHandlerFuncFast(_PREHASH_GroupActiveProposalItemReply,
01416 impl::processGroupActiveProposalItemReply);
01417 gMessageSystem->setHandlerFuncFast(_PREHASH_GroupVoteHistoryItemReply,
01418 impl::processGroupVoteHistoryItemReply);
01419 }
01420
01421 return success && LLPanelGroupTab::postBuild();
01422 }
01423
01424
01425 void LLPanelGroupVoting::activate()
01426 {
01427 gGroupMgr->sendGroupPropertiesRequest(mGroupID);
01428 update(GC_ALL);
01429
01430 mImpl->setEnableListProposals();
01431 mImpl->setEnableHistoryList();
01432 }
01433
01434 bool LLPanelGroupVoting::needsApply(LLString& mesg)
01435 {
01436 return false;
01437 }
01438
01439 bool LLPanelGroupVoting::apply(LLString& mesg)
01440 {
01441 return true;
01442 }
01443
01444 void LLPanelGroupVoting::update(LLGroupChange gc)
01445 {
01446 LLGroupMgrGroupData* group_datap = NULL;
01447 group_datap = gGroupMgr->getGroupData(mGroupID);
01448
01449 if ( group_datap )
01450 {
01451 S32 num_group_members = group_datap->mMemberCount;
01452 mImpl->mNumGroupMembers = num_group_members;
01453
01454 mImpl->updateQuorumText();
01455 }
01456
01457 mImpl->sendGroupProposalsRequest(mGroupID);
01458 mImpl->sendGroupVoteHistoryRequest(mGroupID);
01459 }
01460
01461