aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llpanelgroupvoting.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llpanelgroupvoting.cpp')
-rw-r--r--linden/indra/newview/llpanelgroupvoting.cpp226
1 files changed, 166 insertions, 60 deletions
diff --git a/linden/indra/newview/llpanelgroupvoting.cpp b/linden/indra/newview/llpanelgroupvoting.cpp
index 09fa254..b78d5c2 100644
--- a/linden/indra/newview/llpanelgroupvoting.cpp
+++ b/linden/indra/newview/llpanelgroupvoting.cpp
@@ -12,12 +12,12 @@
12 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of 13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or 14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlife.com/developers/opensource/gplv2 15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 * 16 *
17 * There are special exceptions to the terms and conditions of the GPL as 17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception 18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or 19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlife.com/developers/opensource/flossexception 20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 * 21 *
22 * By copying, modifying or distributing this software, you acknowledge 22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above, 23 * that you have read and understood your obligations described above,
@@ -42,11 +42,13 @@
42#include "llpanelgroupvoting.h" 42#include "llpanelgroupvoting.h"
43#include "llnamelistctrl.h" 43#include "llnamelistctrl.h"
44#include "llbutton.h" 44#include "llbutton.h"
45#include "llnotify.h"
45 46
46#include "llagent.h" 47#include "llagent.h"
47#include "llfocusmgr.h" 48#include "llfocusmgr.h"
48#include "llviewercontrol.h" 49#include "llviewercontrol.h"
49#include "llviewerwindow.h" 50#include "llviewerwindow.h"
51#include "llviewerregion.h"
50 52
51class LLPanelGroupVoting::impl 53class LLPanelGroupVoting::impl
52{ 54{
@@ -299,7 +301,8 @@ void LLPanelGroupVoting::impl::setEnableVoteProposal()
299 LLScrollListCell * proposal_cell = item->getColumn(1); 301 LLScrollListCell * proposal_cell = item->getColumn(1);
300 if ( proposal_cell ) 302 if ( proposal_cell )
301 { 303 {
302 mProposalText->setText(proposal_cell->getText()); //proposal text 304 //proposal text
305 mProposalText->setText(proposal_cell->getValue().asString());
303 } 306 }
304 else 307 else
305 { // Something's wrong... should have some text 308 { // Something's wrong... should have some text
@@ -309,7 +312,8 @@ void LLPanelGroupVoting::impl::setEnableVoteProposal()
309 proposal_cell = item->getColumn(2); 312 proposal_cell = item->getColumn(2);
310 if (proposal_cell) 313 if (proposal_cell)
311 { 314 {
312 mEndDate->setText(proposal_cell->getText()); //end date 315 //end date
316 mEndDate->setText(proposal_cell->getValue().asString());
313 } 317 }
314 else 318 else
315 { // Something's wrong... should have some text 319 { // Something's wrong... should have some text
@@ -320,7 +324,8 @@ void LLPanelGroupVoting::impl::setEnableVoteProposal()
320 proposal_cell = item->getColumn(3); 324 proposal_cell = item->getColumn(3);
321 if (proposal_cell) 325 if (proposal_cell)
322 { 326 {
323 already_voted = proposal_cell->getText(); //already voted 327 //already voted
328 already_voted = proposal_cell->getValue().asString();
324 } 329 }
325 else 330 else
326 { // Something's wrong... should have some text 331 { // Something's wrong... should have some text
@@ -330,7 +335,8 @@ void LLPanelGroupVoting::impl::setEnableVoteProposal()
330 proposal_cell = item->getColumn(5); 335 proposal_cell = item->getColumn(5);
331 if (proposal_cell) 336 if (proposal_cell)
332 { 337 {
333 mStartDate->setText(proposal_cell->getText()); //start date 338 //start date
339 mStartDate->setText(proposal_cell->getValue().asString());
334 } 340 }
335 else 341 else
336 { // Something's wrong... should have some text 342 { // Something's wrong... should have some text
@@ -340,14 +346,17 @@ void LLPanelGroupVoting::impl::setEnableVoteProposal()
340 proposal_cell = item->getColumn(6); 346 proposal_cell = item->getColumn(6);
341 if (proposal_cell) 347 if (proposal_cell)
342 { 348 {
343 vote_cast = proposal_cell->getText(); // Vote Cast 349 // Vote Cast
350 vote_cast = proposal_cell->getValue().asString();
344 } 351 }
345 352
346 // col 8: Vote Initiator 353 // col 8: Vote Initiator
347 proposal_cell = item->getColumn(8); 354 proposal_cell = item->getColumn(8);
348 if (proposal_cell) 355 if (proposal_cell)
349 { 356 {
350 mQuorum->set((F32)atoi(proposal_cell->getText().c_str())); //quorum 357 //quorum
358 mQuorum->set(
359 (F32)atoi(proposal_cell->getValue().asString().c_str()));
351 } 360 }
352 else 361 else
353 { 362 {
@@ -358,7 +367,9 @@ void LLPanelGroupVoting::impl::setEnableVoteProposal()
358 proposal_cell = item->getColumn(9); 367 proposal_cell = item->getColumn(9);
359 if (proposal_cell) 368 if (proposal_cell)
360 { 369 {
361 majority = (F32)atof(proposal_cell->getText().c_str()); //majority 370 //majority
371 majority =
372 (F32)atof(proposal_cell->getValue().asString().c_str());
362 } 373 }
363 374
364 if(majority == 0.0f) 375 if(majority == 0.0f)
@@ -540,7 +551,7 @@ void LLPanelGroupVoting::impl::setEnableHistoryItem()
540 const LLScrollListCell *cell = item->getColumn(5); 551 const LLScrollListCell *cell = item->getColumn(5);
541 if (cell) 552 if (cell)
542 { 553 {
543 mVoteHistoryText->setText(cell->getText()); 554 mVoteHistoryText->setText(cell->getValue().asString());
544 } 555 }
545 else 556 else
546 { // Something's wrong... 557 { // Something's wrong...
@@ -593,6 +604,78 @@ void LLPanelGroupVoting::impl::sendGroupProposalsRequest(const LLUUID& group_id)
593 gAgent.sendReliableMessage(); 604 gAgent.sendReliableMessage();
594} 605}
595 606
607void LLPanelGroupVoting::handleResponse(void *userdata, ResponseType response, bool success)
608{
609 impl* self = (impl*)userdata;
610 if ( self )
611 {
612 //refresh the proposals now that we've hit no
613 self->sendGroupProposalsRequest(self->mGroupID);
614
615 if (response == BALLOT)
616 {
617 LLString::format_map_t args;
618
619 if (success)
620 {
621 args["[MESSAGE]"] = self->mPanel.childGetText("vote_recorded");
622 }
623 else
624 {
625 args["[MESSAGE]"] = self->mPanel.childGetText("vote_previously_recorded");
626 }
627
628 LLNotifyBox::showXml("SystemMessage", args);
629
630 self->sendGroupVoteHistoryRequest(self->mGroupID);
631 }
632 self->setEnableListProposals();
633 }
634}
635
636class LLStartGroupVoteResponder : public LLHTTPClient::Responder
637{
638public:
639 LLStartGroupVoteResponder(void *userdata) : mUserData(userdata) {};
640 //If we get back a normal response, handle it here
641 virtual void result(const LLSD& content)
642 {
643 //Ack'd the proposal initialization, now let's finish up.
644 LLPanelGroupVoting::handleResponse(mUserData,LLPanelGroupVoting::START_VOTE);
645 }
646
647 //If we get back an error (not found, etc...), handle it here
648 virtual void error(U32 status, const std::string& reason)
649 {
650 llinfos << "LLPanelGroupVotingResponder::error "
651 << status << ": " << reason << llendl;
652 }
653private:
654 void *mUserData;
655};
656
657class LLGroupProposalBallotResponder : public LLHTTPClient::Responder
658{
659public:
660 LLGroupProposalBallotResponder(void *userdata) : mUserData(userdata) {};
661 //If we get back a normal response, handle it here
662 virtual void result(const LLSD& content)
663 {
664 //Ack'd the proposal initialization, now let's finish up.
665
666 LLPanelGroupVoting::handleResponse(mUserData,LLPanelGroupVoting::BALLOT,content["voted"].asBoolean());
667 }
668
669 //If we get back an error (not found, etc...), handle it here
670 virtual void error(U32 status, const std::string& reason)
671 {
672 llinfos << "LLPanelGroupVotingResponder::error "
673 << status << ": " << reason << llendl;
674 }
675private:
676 void *mUserData;
677};
678
596void LLPanelGroupVoting::impl::sendStartGroupProposal() 679void LLPanelGroupVoting::impl::sendStartGroupProposal()
597{ 680{
598 if ( !gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_START) ) 681 if ( !gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_START) )
@@ -616,41 +699,88 @@ void LLPanelGroupVoting::impl::sendStartGroupProposal()
616 699
617 S32 quorum = llfloor(mQuorum->get()); 700 S32 quorum = llfloor(mQuorum->get());
618 701
619 LLMessageSystem *msg = gMessageSystem; 702 //*************************************Conversion to capability
703 LLSD body;
620 704
621 msg->newMessageFast(_PREHASH_StartGroupProposal); 705 std::string url = gAgent.getRegion()->getCapability("StartGroupProposal");
622 msg->nextBlockFast(_PREHASH_AgentData);
623 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
624 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() );
625 706
626 msg->nextBlockFast(_PREHASH_ProposalData); 707 if (!url.empty())
627 msg->addUUIDFast(_PREHASH_GroupID, mGroupID); 708 {
628 msg->addF32Fast(_PREHASH_Majority, majority ); 709 body["agent-id"] = gAgent.getID();
629 msg->addS32Fast(_PREHASH_Quorum, quorum ); 710 body["session-id"] = gAgent.getSessionID();
630 msg->addS32Fast(_PREHASH_Duration, duration_seconds );
631 msg->addStringFast(_PREHASH_ProposalText, mProposalText->getText().c_str());
632 711
633 gAgent.sendReliableMessage(); 712 body["group-id"] = mGroupID;
713 body["majority"] = majority;
714 body["quorum"] = quorum;
715 body["duration"] = duration_seconds;
716 body["proposal-text"] = mProposalText->getText();
717
718 LLHTTPClient::post(url, body, new LLStartGroupVoteResponder((void*)this));
719 }
720 else
721 { //DEPRECATED!!!!!!! This is a fallback just in case our backend cap is not there. Delete this block ASAP!
722 LLMessageSystem *msg = gMessageSystem;
723
724 msg->newMessageFast(_PREHASH_StartGroupProposal);
725 msg->nextBlockFast(_PREHASH_AgentData);
726 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
727 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() );
728
729 msg->nextBlockFast(_PREHASH_ProposalData);
730 msg->addUUIDFast(_PREHASH_GroupID, mGroupID);
731 msg->addF32Fast(_PREHASH_Majority, majority );
732 msg->addS32Fast(_PREHASH_Quorum, quorum );
733 msg->addS32Fast(_PREHASH_Duration, duration_seconds );
734 msg->addStringFast(_PREHASH_ProposalText, mProposalText->getText().c_str());
735
736 gAgent.sendReliableMessage();
737
738 //This code was moved from the callers to here as part of deprecation.
739 sendGroupProposalsRequest(mGroupID);
740 setEnableListProposals();
741 }
634} 742}
635 743
636void LLPanelGroupVoting::impl::sendGroupProposalBallot(const char* vote) 744void LLPanelGroupVoting::impl::sendGroupProposalBallot(const char* vote)
637{ 745{
638 if ( !gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_VOTE) ) 746 if ( !gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_VOTE) )
639 return; 747 return;
748
749 LLSD body;
640 750
641 LLMessageSystem *msg = gMessageSystem; 751 std::string url = gAgent.getRegion()->getCapability("GroupProposalBallot");
642 752
643 msg->newMessageFast(_PREHASH_GroupProposalBallot); 753 if (!url.empty())
644 msg->nextBlockFast(_PREHASH_AgentData); 754 {
645 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() ); 755 body["agent-id"] = gAgent.getID();
646 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() ); 756 body["session-id"] = gAgent.getSessionID();
757 body["proposal-id"] = mProposalID;
758 body["group-id"] = mGroupID;
759 body["vote"] = vote;
760
761 LLHTTPClient::post(url, body, new LLGroupProposalBallotResponder((void*)this));
762 }
763 else
764 { //DEPRECATED!!!!!!! This is a fallback just in case our backend cap is not there. Delete this block ASAP!
765 LLMessageSystem *msg = gMessageSystem;
647 766
648 msg->nextBlockFast(_PREHASH_ProposalData); 767 msg->newMessageFast(_PREHASH_GroupProposalBallot);
649 msg->addUUIDFast(_PREHASH_ProposalID, mProposalID); 768 msg->nextBlockFast(_PREHASH_AgentData);
650 msg->addUUIDFast(_PREHASH_GroupID, mGroupID); 769 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
651 msg->addStringFast(_PREHASH_VoteCast, vote); 770 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() );
652 771
653 gAgent.sendReliableMessage(); 772 msg->nextBlockFast(_PREHASH_ProposalData);
773 msg->addUUIDFast(_PREHASH_ProposalID, mProposalID);
774 msg->addUUIDFast(_PREHASH_GroupID, mGroupID);
775 msg->addStringFast(_PREHASH_VoteCast, vote);
776
777 gAgent.sendReliableMessage();
778
779 //This code was moved from the callers to here as part of deprecation.
780 sendGroupProposalsRequest(mGroupID);
781 sendGroupVoteHistoryRequest(mGroupID);
782 setEnableListProposals();
783 }
654} 784}
655 785
656void LLPanelGroupVoting::impl::sendGroupVoteHistoryRequest(const LLUUID& group_id) 786void LLPanelGroupVoting::impl::sendGroupVoteHistoryRequest(const LLUUID& group_id)
@@ -711,18 +841,12 @@ void LLPanelGroupVoting::impl::addPendingActiveScrollListItem(unsigned int curre
711 841
712void LLPanelGroupVoting::impl::addNoActiveScrollListItem(EAddPosition pos) 842void LLPanelGroupVoting::impl::addNoActiveScrollListItem(EAddPosition pos)
713{ 843{
714 LLSD row; 844 mProposals->addCommentText("There are currently no active proposals", pos);
715 row["columns"][0]["value"] = "There are currently no active proposals";
716 row["columns"][0]["font"] = "SANSSERIF_SMALL";
717 mProposals->addElement(row, pos);
718} 845}
719 846
720void LLPanelGroupVoting::impl::addNoHistoryScrollListItem(EAddPosition pos) 847void LLPanelGroupVoting::impl::addNoHistoryScrollListItem(EAddPosition pos)
721{ 848{
722 LLSD row; 849 mVotesHistory->addCommentText("There are currently no archived proposals", pos);
723 row["columns"][0]["value"] = "There are currently no archived proposals";
724 row["columns"][0]["font"] = "SANSSERIF_SMALL";
725 mVotesHistory->addElement(row, pos);
726} 850}
727 851
728void LLPanelGroupVoting::impl::addPendingHistoryScrollListItem(unsigned int current, 852void LLPanelGroupVoting::impl::addPendingHistoryScrollListItem(unsigned int current,
@@ -1102,11 +1226,6 @@ void LLPanelGroupVoting::impl::onClickYes(void *userdata)
1102 { 1226 {
1103 self->mPanel.childSetText("proposal_instructions", self->mPanel.childGetText("proposals_submit_yes_txt")); 1227 self->mPanel.childSetText("proposal_instructions", self->mPanel.childGetText("proposals_submit_yes_txt"));
1104 self->sendGroupProposalBallot("Yes"); 1228 self->sendGroupProposalBallot("Yes");
1105
1106 //refresh the proposals now that we've hit yes
1107 self->sendGroupProposalsRequest(self->mGroupID);
1108 self->sendGroupVoteHistoryRequest(self->mGroupID);
1109 self->setEnableListProposals();
1110 } 1229 }
1111} 1230}
1112 1231
@@ -1119,11 +1238,6 @@ void LLPanelGroupVoting::impl::onClickNo(void *userdata)
1119 { 1238 {
1120 self->mPanel.childSetText("proposal_instructions", self->mPanel.childGetText("proposals_submit_no_txt")); 1239 self->mPanel.childSetText("proposal_instructions", self->mPanel.childGetText("proposals_submit_no_txt"));
1121 self->sendGroupProposalBallot("No"); 1240 self->sendGroupProposalBallot("No");
1122
1123 //refresh the proposals now that we've hit no
1124 self->sendGroupProposalsRequest(self->mGroupID);
1125 self->sendGroupVoteHistoryRequest(self->mGroupID);
1126 self->setEnableListProposals();
1127 } 1241 }
1128} 1242}
1129 1243
@@ -1136,18 +1250,14 @@ void LLPanelGroupVoting::impl::onClickAbstain(void *userdata)
1136 { 1250 {
1137 self->mPanel.childSetText("proposal_instructions", self->mPanel.childGetText("proposals_submit_abstain_txt")); 1251 self->mPanel.childSetText("proposal_instructions", self->mPanel.childGetText("proposals_submit_abstain_txt"));
1138 self->sendGroupProposalBallot("Abstain"); 1252 self->sendGroupProposalBallot("Abstain");
1139
1140 //refresh the proposals now that we've hit abstain
1141 self->sendGroupProposalsRequest(self->mGroupID);
1142 self->sendGroupVoteHistoryRequest(self->mGroupID);
1143 self->setEnableListProposals();
1144 } 1253 }
1145} 1254}
1146 1255
1256
1147//static 1257//static
1148void LLPanelGroupVoting::impl::onClickSubmitProposal(void *userdata) 1258void LLPanelGroupVoting::impl::onClickSubmitProposal(void *userdata)
1149{ 1259{
1150 gFocusMgr.setKeyboardFocus(NULL, NULL); 1260 gFocusMgr.setKeyboardFocus(NULL);
1151 impl* self = (impl*)userdata; 1261 impl* self = (impl*)userdata;
1152 1262
1153 if ( self && self->mProposalText ) 1263 if ( self && self->mProposalText )
@@ -1165,10 +1275,6 @@ void LLPanelGroupVoting::impl::onClickSubmitProposal(void *userdata)
1165 1275
1166 self->mPanel.childSetText("proposal_instructions", self->mPanel.childGetText("proposals_submit_new_txt")); 1276 self->mPanel.childSetText("proposal_instructions", self->mPanel.childGetText("proposals_submit_new_txt"));
1167 self->sendStartGroupProposal(); 1277 self->sendStartGroupProposal();
1168
1169 //refresh the proposals now that we've submitted a new one
1170 self->sendGroupProposalsRequest(self->mGroupID);
1171 self->setEnableListProposals();
1172 } 1278 }
1173} 1279}
1174 1280