diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llpanelgroupvoting.cpp | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/llpanelgroupvoting.cpp')
-rw-r--r-- | linden/indra/newview/llpanelgroupvoting.cpp | 1385 |
1 files changed, 1385 insertions, 0 deletions
diff --git a/linden/indra/newview/llpanelgroupvoting.cpp b/linden/indra/newview/llpanelgroupvoting.cpp new file mode 100644 index 0000000..1be6bf0 --- /dev/null +++ b/linden/indra/newview/llpanelgroupvoting.cpp | |||
@@ -0,0 +1,1385 @@ | |||
1 | /** | ||
2 | * @file llpanelgroupvoting.h | ||
3 | * @brief LLPanelGroupVoting class definition. | ||
4 | * | ||
5 | * Copyright (c) 2003-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #include "llviewerprecompiledheaders.h" | ||
29 | |||
30 | #include "roles_constants.h" | ||
31 | |||
32 | #include "lllineeditor.h" | ||
33 | #include "lltextbox.h" | ||
34 | #include "lltexteditor.h" | ||
35 | #include "llscrolllistctrl.h" | ||
36 | #include "llradiogroup.h" | ||
37 | #include "llspinctrl.h" | ||
38 | #include "llpanelgroupvoting.h" | ||
39 | #include "llnamelistctrl.h" | ||
40 | #include "llbutton.h" | ||
41 | |||
42 | #include "llagent.h" | ||
43 | #include "llfocusmgr.h" | ||
44 | #include "llviewercontrol.h" | ||
45 | #include "llviewerwindow.h" | ||
46 | |||
47 | class LLPanelGroupVoting::impl | ||
48 | { | ||
49 | public: | ||
50 | impl(const LLUUID& group_id); | ||
51 | ~impl(); | ||
52 | |||
53 | static void onClickCreateProposal(void* userdata); | ||
54 | static void onClickYes(void *userdata); | ||
55 | static void onClickNo(void *userdata); | ||
56 | static void onClickAbstain(void *userdata); | ||
57 | static void onClickSubmitProposal(void *userdata); | ||
58 | static void onClickCancelProposal(void *userdata); | ||
59 | static void onClickViewProposalList(void *userdata); | ||
60 | static void onClickViewProposalItem(void *userdata); | ||
61 | static void onDoubleClickProposal(void *userdata); | ||
62 | |||
63 | static void onDoubleClickHistoryItem(void *userdata); | ||
64 | static void onClickViewHistoryItem(void *userdata); | ||
65 | static void onClickViewHistoryList(void *userdata); | ||
66 | |||
67 | void sendGroupProposalsRequest(const LLUUID& group_id); | ||
68 | void sendStartGroupProposal(); | ||
69 | void sendGroupProposalBallot(const char* vote); | ||
70 | void sendGroupVoteHistoryRequest(const LLUUID& group_id); | ||
71 | |||
72 | void setEnableCreateProposal(); | ||
73 | void setEnableVoteProposal(); | ||
74 | void setEnableListProposals(); | ||
75 | void setEnableHistoryItem(); | ||
76 | void setEnableHistoryList(); | ||
77 | |||
78 | void updateQuorumText(); | ||
79 | void addPendingActiveScrollListItem(LLFontGL* font, | ||
80 | unsigned int current, | ||
81 | unsigned int expected, | ||
82 | EAddPosition pos); | ||
83 | void addPendingHistoryScrollListItem(LLFontGL* font, | ||
84 | unsigned int current, | ||
85 | unsigned int expected, | ||
86 | EAddPosition pos); | ||
87 | void addNoActiveScrollListItem(LLFontGL* font, EAddPosition pos); | ||
88 | void addNoHistoryScrollListItem(LLFontGL* font, EAddPosition pos); | ||
89 | |||
90 | |||
91 | static void processGroupActiveProposalItemReply(LLMessageSystem* msg, | ||
92 | void** data); | ||
93 | static void processGroupVoteHistoryItemReply(LLMessageSystem* msg, | ||
94 | void** data); | ||
95 | |||
96 | public: | ||
97 | LLUUID mGroupID; | ||
98 | LLUUID mProposalID; | ||
99 | |||
100 | LLTextBox *mQuorumText; | ||
101 | LLSpinCtrl *mQuorum; | ||
102 | LLTextBox *mQuorumLbl; | ||
103 | LLSpinCtrl *mDuration; | ||
104 | LLTextBox *mDurationLbl; | ||
105 | LLTextBox *mDurationText; | ||
106 | LLRadioGroup *mMajority; | ||
107 | LLTextBox *mMajorityLbl; | ||
108 | LLTextBox *mInstructions; | ||
109 | LLTextBox *mProposalHeader; | ||
110 | LLTextBox *mProposalLbl; | ||
111 | LLTextBox *mStartLbl; | ||
112 | LLTextBox *mEndLbl; | ||
113 | LLTextBox *mStartDate; | ||
114 | LLTextBox *mEndDate; | ||
115 | |||
116 | LLButton *mBtnYes; | ||
117 | LLButton *mBtnNo; | ||
118 | LLButton *mBtnAbstain; | ||
119 | |||
120 | LLScrollListCtrl *mProposals; | ||
121 | LLTextEditor *mProposalText; | ||
122 | LLButton *mBtnCreateProposal; | ||
123 | LLButton *mBtnSubmitProposal; | ||
124 | LLButton *mBtnCancelProposal; | ||
125 | LLButton *mBtnViewProposalList; | ||
126 | LLButton *mBtnViewProposalItem; | ||
127 | |||
128 | LLScrollListCtrl *mVotesHistory; | ||
129 | LLTextBox *mVotesHistoryLbl; | ||
130 | LLTextEditor *mVoteHistoryText; | ||
131 | LLTextBox *mVoteHistoryTextLbl; | ||
132 | LLButton *mBtnViewHistoryList; | ||
133 | LLButton *mBtnViewHistoryItem; | ||
134 | |||
135 | std::string mViewProposalHeaderText; | ||
136 | std::string mCreateProposalHeaderText; | ||
137 | std::string mVoteProposalHeaderText; | ||
138 | std::string mEmptyProposalText; | ||
139 | |||
140 | int mNumGroupMembers; | ||
141 | |||
142 | std::vector<LLScrollListItem*> mActiveReceived; | ||
143 | std::vector<LLScrollListItem*> mHistoryReceived; | ||
144 | |||
145 | int mProposalColumnWidths[10]; | ||
146 | int mHistoryColumnWidths[10]; | ||
147 | |||
148 | LLUUID mProposalTransID; | ||
149 | LLUUID mHistoryTransID; | ||
150 | |||
151 | static std::map<LLUUID, LLPanelGroupVoting::impl*> sGroupIDs; | ||
152 | }; | ||
153 | |||
154 | //**************************************** | ||
155 | //** LLPanelGroupVoting::impl Functions ** | ||
156 | //**************************************** | ||
157 | |||
158 | LLPanelGroupVoting::impl::impl(const LLUUID& group_id) | ||
159 | { | ||
160 | mGroupID = group_id; | ||
161 | |||
162 | mNumGroupMembers = 0; | ||
163 | |||
164 | mProposalTransID = LLUUID::null; | ||
165 | mHistoryTransID = LLUUID::null; | ||
166 | |||
167 | mProposalColumnWidths[0] = -1; | ||
168 | mProposalColumnWidths[1] = 210; | ||
169 | mProposalColumnWidths[2] = 120; | ||
170 | mProposalColumnWidths[3] = -1; | ||
171 | mProposalColumnWidths[4] = 30; | ||
172 | for (int index = 5; index < 10; index++) | ||
173 | { | ||
174 | mProposalColumnWidths[index] = -1; | ||
175 | } | ||
176 | |||
177 | mHistoryColumnWidths[0] = -1; | ||
178 | mHistoryColumnWidths[1] = 210; // vote text sans non-printable | ||
179 | mHistoryColumnWidths[2] = 120; | ||
180 | mHistoryColumnWidths[3] = -1; | ||
181 | mHistoryColumnWidths[4] = -1; | ||
182 | mHistoryColumnWidths[5] = -1; // full vote text | ||
183 | |||
184 | //problem what if someone has both the group floater open and the finder | ||
185 | //open to the same group? Some maps that map group ids to panels | ||
186 | //will then only be working for the last panel for a given group id :( | ||
187 | sGroupIDs[group_id] = this; | ||
188 | |||
189 | mQuorumText = NULL; | ||
190 | mQuorum = NULL; | ||
191 | mQuorumLbl = NULL; | ||
192 | mDuration = NULL; | ||
193 | mDurationLbl = NULL; | ||
194 | mDurationText = NULL; | ||
195 | mMajority = NULL; | ||
196 | mMajorityLbl = NULL; | ||
197 | mInstructions = NULL; | ||
198 | mProposalHeader = NULL; | ||
199 | mProposalLbl = NULL; | ||
200 | mStartLbl = NULL; | ||
201 | mEndLbl = NULL; | ||
202 | mStartDate = NULL; | ||
203 | mEndDate = NULL; | ||
204 | |||
205 | mBtnYes = NULL; | ||
206 | mBtnNo = NULL; | ||
207 | mBtnAbstain = NULL; | ||
208 | |||
209 | mProposals = NULL; | ||
210 | mProposalText = NULL; | ||
211 | mBtnCreateProposal = NULL; | ||
212 | mBtnSubmitProposal = NULL; | ||
213 | mBtnViewProposalList = NULL; | ||
214 | mBtnViewProposalItem = NULL; | ||
215 | |||
216 | mVotesHistory = NULL; | ||
217 | mVotesHistoryLbl = NULL; | ||
218 | mVoteHistoryText = NULL; | ||
219 | mVoteHistoryTextLbl = NULL; | ||
220 | mBtnViewHistoryList = NULL; | ||
221 | mBtnViewHistoryItem = NULL; | ||
222 | } | ||
223 | |||
224 | LLPanelGroupVoting::impl::~impl() | ||
225 | { | ||
226 | sGroupIDs.erase(mGroupID); | ||
227 | } | ||
228 | |||
229 | void LLPanelGroupVoting::impl::setEnableListProposals() | ||
230 | { | ||
231 | //we make the assumption here that anyone who has the start | ||
232 | //or vote powers should also have the view powers | ||
233 | |||
234 | /* This power was removed to make group roles simpler | ||
235 | if (!gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_VIEW) && | ||
236 | !gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_VOTE) && | ||
237 | !gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_START) ) | ||
238 | */ | ||
239 | if (!gAgent.isInGroup(mGroupID)) | ||
240 | return; | ||
241 | |||
242 | |||
243 | mProposalHeader->setText(mViewProposalHeaderText); | ||
244 | mInstructions->setText("Double Click on the proposal you would like to vote on or press\n" | ||
245 | "Create Proposal to create a new proposal."); | ||
246 | mProposalLbl->setText("Proposal Voting Ends Voted?"); | ||
247 | mProposals->setVisible(TRUE); | ||
248 | mProposals->setBgSelectedColor(gColors.getColor("ScrollSelectedBGColor")); | ||
249 | mProposalText->setVisible(FALSE); | ||
250 | mBtnYes->setEnabled(FALSE); | ||
251 | mBtnYes->setVisible(FALSE); | ||
252 | mBtnNo->setEnabled(FALSE); | ||
253 | mBtnNo->setVisible(FALSE); | ||
254 | mBtnAbstain->setEnabled(FALSE); | ||
255 | mBtnAbstain->setVisible(FALSE); | ||
256 | mBtnSubmitProposal->setEnabled(FALSE); | ||
257 | mBtnSubmitProposal->setVisible(FALSE); | ||
258 | mBtnCancelProposal->setEnabled(FALSE); | ||
259 | mBtnCancelProposal->setVisible(FALSE); | ||
260 | |||
261 | mBtnViewProposalItem->setEnabled(TRUE); | ||
262 | mBtnViewProposalItem->setVisible(TRUE); | ||
263 | |||
264 | mBtnViewProposalList->setEnabled(FALSE); | ||
265 | mBtnViewProposalList->setVisible(FALSE); | ||
266 | |||
267 | mQuorumLbl->setVisible(FALSE); | ||
268 | mQuorum->setEnabled(FALSE); | ||
269 | mQuorum->setVisible(FALSE); | ||
270 | mQuorumText->setVisible(FALSE); | ||
271 | |||
272 | mDurationLbl->setVisible(FALSE); | ||
273 | mDuration->setEnabled(FALSE); | ||
274 | mDuration->setVisible(FALSE); | ||
275 | mDurationText->setVisible(FALSE); | ||
276 | |||
277 | mMajorityLbl->setVisible(FALSE); | ||
278 | mMajority->setEnabled(FALSE); | ||
279 | mMajority->setVisible(FALSE); | ||
280 | mStartLbl->setVisible(FALSE); | ||
281 | mStartDate->setVisible(FALSE); | ||
282 | mEndLbl->setVisible(FALSE); | ||
283 | mEndDate->setVisible(FALSE); | ||
284 | |||
285 | //check to see if the agent can create proposals when enabling the | ||
286 | //create proposal button | ||
287 | BOOL can_create = gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_START); | ||
288 | |||
289 | mBtnCreateProposal->setEnabled(can_create); | ||
290 | mBtnCreateProposal->setVisible(can_create); | ||
291 | } | ||
292 | |||
293 | void LLPanelGroupVoting::impl::setEnableVoteProposal() | ||
294 | { | ||
295 | if (!gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_VOTE)) | ||
296 | return; | ||
297 | |||
298 | LLScrollListItem *item = mProposals->getFirstSelected(); | ||
299 | if (item) | ||
300 | { | ||
301 | std::string already_voted; | ||
302 | std::string vote_cast; | ||
303 | |||
304 | mProposalID = item->getUUID(); | ||
305 | // col 0: index id | ||
306 | mProposalText->setText(item->getColumn(1)->getText()); //proposal text | ||
307 | mEndDate->setText(item->getColumn(2)->getText()); //end date | ||
308 | // col 3: Vote Type | ||
309 | already_voted = item->getColumn(4)->getText(); //already voted | ||
310 | mStartDate->setText(item->getColumn(5)->getText()); //start date | ||
311 | vote_cast = item->getColumn(6)->getText(); // Vote Cast | ||
312 | // col 7: Vote Initiator | ||
313 | mQuorum->set((F32)atoi(item->getColumn(8)->getText().c_str())); //quorum | ||
314 | F32 majority = (F32)atof(item->getColumn(9)->getText().c_str()); //majority | ||
315 | |||
316 | if(majority == 0.0f) | ||
317 | { // Select the Simple Majority | ||
318 | mMajority->setSelectedIndex(0); | ||
319 | } | ||
320 | else if (majority == 1.0f) | ||
321 | { | ||
322 | //Select Unanimous | ||
323 | mMajority->setSelectedIndex(2); | ||
324 | } | ||
325 | else | ||
326 | { | ||
327 | //Select 2/3 Majority | ||
328 | mMajority->setSelectedIndex(1); | ||
329 | } | ||
330 | |||
331 | if (already_voted == "Yes") | ||
332 | { | ||
333 | char message[MAX_STRING]; | ||
334 | sprintf(message, "You have voted: %s ", vote_cast.c_str()); | ||
335 | mInstructions->setText(message); | ||
336 | |||
337 | mBtnYes->setEnabled(FALSE); | ||
338 | mBtnNo->setEnabled(FALSE); | ||
339 | mBtnAbstain->setEnabled(FALSE); | ||
340 | } | ||
341 | else | ||
342 | { | ||
343 | mInstructions->setText("Press the Yes or No button to vote on the proposal, \n" | ||
344 | "or choose to Abstain voting on this proposal."); | ||
345 | |||
346 | mBtnYes->setEnabled(TRUE); | ||
347 | mBtnNo->setEnabled(TRUE); | ||
348 | mBtnAbstain->setEnabled(TRUE); | ||
349 | } | ||
350 | |||
351 | mProposalHeader->setText(mVoteProposalHeaderText); | ||
352 | mProposalLbl->setText("Proposal Description"); | ||
353 | mProposals->setVisible(FALSE); | ||
354 | mProposalText->setEnabled(FALSE); | ||
355 | mProposalText->setVisible(TRUE); | ||
356 | mBtnYes->setVisible(TRUE); | ||
357 | mBtnNo->setVisible(TRUE); | ||
358 | mBtnAbstain->setVisible(TRUE); | ||
359 | mBtnSubmitProposal->setEnabled(FALSE); | ||
360 | mBtnSubmitProposal->setVisible(FALSE); | ||
361 | mBtnCreateProposal->setEnabled(FALSE); | ||
362 | mBtnCreateProposal->setVisible(FALSE); | ||
363 | mBtnCancelProposal->setEnabled(FALSE); | ||
364 | mBtnCancelProposal->setVisible(FALSE); | ||
365 | |||
366 | mBtnViewProposalItem->setEnabled(FALSE); | ||
367 | mBtnViewProposalItem->setVisible(FALSE); | ||
368 | |||
369 | mBtnViewProposalList->setEnabled(TRUE); | ||
370 | mBtnViewProposalList->setVisible(TRUE); | ||
371 | |||
372 | mQuorumLbl->setVisible(TRUE); | ||
373 | mQuorum->setEnabled(FALSE); | ||
374 | mQuorum->setVisible(TRUE); | ||
375 | mQuorumText->setVisible(TRUE); | ||
376 | |||
377 | mDurationLbl->setVisible(FALSE); | ||
378 | mDuration->setEnabled(FALSE); | ||
379 | mDuration->setVisible(FALSE); | ||
380 | mDurationText->setVisible(FALSE); | ||
381 | |||
382 | mMajorityLbl->setVisible(TRUE); | ||
383 | mMajority->setEnabled(FALSE); | ||
384 | mMajority->setVisible(TRUE); | ||
385 | mStartLbl->setVisible(TRUE); | ||
386 | mStartDate->setVisible(TRUE); | ||
387 | mEndLbl->setVisible(TRUE); | ||
388 | mEndDate->setVisible(TRUE); | ||
389 | } | ||
390 | } | ||
391 | |||
392 | void LLPanelGroupVoting::impl::setEnableCreateProposal() | ||
393 | { | ||
394 | if ( !gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_START) ) | ||
395 | return; | ||
396 | |||
397 | mProposalHeader->setText(mCreateProposalHeaderText); | ||
398 | mInstructions->setText("Type the Proposal Description for the new proposal. You can change the\nQuorum, Duration and Majority required to pass the proposal."); | ||
399 | mProposalLbl->setText("Proposal Description"); | ||
400 | mProposals->setVisible(FALSE); | ||
401 | mProposalText->setEnabled(TRUE); | ||
402 | mProposalText->setVisible(TRUE); | ||
403 | mProposalText->setText(""); | ||
404 | mBtnYes->setEnabled(FALSE); | ||
405 | mBtnYes->setVisible(FALSE); | ||
406 | mBtnNo->setEnabled(FALSE); | ||
407 | mBtnNo->setVisible(FALSE); | ||
408 | mBtnAbstain->setEnabled(FALSE); | ||
409 | mBtnAbstain->setVisible(FALSE); | ||
410 | mBtnSubmitProposal->setEnabled(TRUE); | ||
411 | mBtnSubmitProposal->setVisible(TRUE); | ||
412 | mBtnCancelProposal->setEnabled(TRUE); | ||
413 | mBtnCancelProposal->setVisible(TRUE); | ||
414 | mBtnCreateProposal->setEnabled(FALSE); | ||
415 | mBtnCreateProposal->setVisible(FALSE); | ||
416 | |||
417 | mBtnViewProposalItem->setEnabled(FALSE); | ||
418 | mBtnViewProposalItem->setVisible(FALSE); | ||
419 | |||
420 | mBtnViewProposalList->setEnabled(FALSE); | ||
421 | mBtnViewProposalList->setVisible(FALSE); | ||
422 | |||
423 | mQuorumLbl->setVisible(TRUE); | ||
424 | mQuorum->setEnabled(TRUE); | ||
425 | mQuorum->setVisible(TRUE); | ||
426 | mQuorumText->setVisible(TRUE); | ||
427 | |||
428 | mDurationLbl->setVisible(TRUE); | ||
429 | mDuration->setEnabled(TRUE); | ||
430 | mDuration->setVisible(TRUE); | ||
431 | mDurationText->setVisible(TRUE); | ||
432 | |||
433 | mMajorityLbl->setVisible(TRUE); | ||
434 | mMajority->setEnabled(TRUE); | ||
435 | mMajority->setVisible(TRUE); | ||
436 | mStartLbl->setVisible(FALSE); | ||
437 | mStartDate->setVisible(FALSE); | ||
438 | mEndLbl->setVisible(FALSE); | ||
439 | mEndDate->setVisible(FALSE); | ||
440 | |||
441 | if (mQuorum->get() == 0) | ||
442 | { | ||
443 | mQuorum->set((F32)mNumGroupMembers); | ||
444 | } | ||
445 | mQuorum->setMaxValue((F32)mNumGroupMembers); | ||
446 | } | ||
447 | |||
448 | void LLPanelGroupVoting::impl::setEnableHistoryList() | ||
449 | { | ||
450 | //we make the assumption here that anyone who has the start | ||
451 | //or vote powers should also have the view powers | ||
452 | |||
453 | /* This power was removed to make group roles simpler | ||
454 | if (!gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_VIEW) && | ||
455 | !gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_VOTE) && | ||
456 | !gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_START) ) | ||
457 | return; | ||
458 | */ | ||
459 | if (!gAgent.isInGroup(mGroupID)) | ||
460 | return; | ||
461 | |||
462 | mVotesHistoryLbl->setVisible(TRUE); | ||
463 | mVotesHistory->setVisible(TRUE); | ||
464 | mVotesHistory->setEnabled(TRUE); | ||
465 | |||
466 | mVoteHistoryTextLbl->setVisible(FALSE); | ||
467 | mVoteHistoryText->setVisible(FALSE); | ||
468 | mBtnViewHistoryList->setVisible(FALSE); | ||
469 | |||
470 | mBtnViewHistoryItem->setVisible(TRUE); | ||
471 | mBtnViewHistoryItem->setEnabled(TRUE); | ||
472 | } | ||
473 | |||
474 | void LLPanelGroupVoting::impl::setEnableHistoryItem() | ||
475 | { | ||
476 | //we make the assumption here that anyone who has the start | ||
477 | //or vote powers should also have the view powers | ||
478 | |||
479 | /* This power was removed to make group roles simpler | ||
480 | if (!gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_VIEW) && | ||
481 | !gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_VOTE) && | ||
482 | !gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_START) ) | ||
483 | return; | ||
484 | */ | ||
485 | |||
486 | if (!gAgent.isInGroup(mGroupID)) | ||
487 | return; | ||
488 | |||
489 | LLScrollListItem *item = mVotesHistory->getFirstSelected(); | ||
490 | // Get full text, not stripped version. | ||
491 | const LLScrollListCell *cell = item->getColumn(5); | ||
492 | mVoteHistoryText->setText(cell->getText()); | ||
493 | |||
494 | mVotesHistoryLbl->setVisible(FALSE); | ||
495 | mVotesHistory->setVisible(FALSE); | ||
496 | |||
497 | mVoteHistoryTextLbl->setVisible(TRUE); | ||
498 | mVoteHistoryText->setVisible(TRUE); | ||
499 | mVoteHistoryText->setEnabled(FALSE); | ||
500 | |||
501 | mBtnViewHistoryList->setVisible(TRUE); | ||
502 | mBtnViewHistoryList->setEnabled(TRUE); | ||
503 | mBtnViewHistoryItem->setVisible(FALSE); | ||
504 | } | ||
505 | |||
506 | void LLPanelGroupVoting::impl::sendGroupProposalsRequest(const LLUUID& group_id) | ||
507 | { | ||
508 | //we make the assumption here that anyone who has the start | ||
509 | //or vote powers should also have the view powers | ||
510 | |||
511 | /* This power was removed to make group roles simpler | ||
512 | if (!gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_VIEW) && | ||
513 | !gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_VOTE) && | ||
514 | !gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_START) ) | ||
515 | return; | ||
516 | */ | ||
517 | if ( !gAgent.isInGroup(mGroupID) ) | ||
518 | return; | ||
519 | |||
520 | mProposalTransID.generate(); | ||
521 | mProposals->deleteAllItems(); //this should delete all the objects | ||
522 | mActiveReceived.clear(); | ||
523 | |||
524 | //fill in some text so the user will at least know that | ||
525 | //we're pining the server in high latency situations | ||
526 | LLFontGL* font = LLFontGL::sSansSerifSmall; | ||
527 | addPendingActiveScrollListItem(font, 0, 0, ADD_BOTTOM); | ||
528 | mProposals->setCanSelect(FALSE); | ||
529 | |||
530 | LLMessageSystem *msg = gMessageSystem; | ||
531 | msg->newMessageFast(_PREHASH_GroupActiveProposalsRequest); | ||
532 | msg->nextBlockFast(_PREHASH_AgentData); | ||
533 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() ); | ||
534 | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() ); | ||
535 | msg->nextBlockFast(_PREHASH_GroupData); | ||
536 | msg->addUUIDFast(_PREHASH_GroupID, group_id ); | ||
537 | msg->nextBlockFast(_PREHASH_TransactionData); | ||
538 | msg->addUUIDFast(_PREHASH_TransactionID, mProposalTransID); | ||
539 | gAgent.sendReliableMessage(); | ||
540 | } | ||
541 | |||
542 | void LLPanelGroupVoting::impl::sendStartGroupProposal() | ||
543 | { | ||
544 | if ( !gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_START) ) | ||
545 | return; | ||
546 | |||
547 | F32 majority = 0.f; | ||
548 | S32 duration_seconds = (S32)mDuration->get()*24*60*60; // duration days * 24hours/day * 60min/hr * 60sec/min | ||
549 | |||
550 | switch (mMajority->getSelectedIndex()) | ||
551 | { | ||
552 | case 0: // Simple Majority | ||
553 | majority = 0.f; | ||
554 | break; | ||
555 | case 1: // 2/3 Majority | ||
556 | majority = 2.f/3.f; | ||
557 | break; | ||
558 | case 2: // Unanimous | ||
559 | majority = 1.0f; | ||
560 | break; | ||
561 | } | ||
562 | |||
563 | S32 quorum = llfloor(mQuorum->get()); | ||
564 | |||
565 | LLMessageSystem *msg = gMessageSystem; | ||
566 | |||
567 | msg->newMessageFast(_PREHASH_StartGroupProposal); | ||
568 | msg->nextBlockFast(_PREHASH_AgentData); | ||
569 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() ); | ||
570 | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() ); | ||
571 | |||
572 | msg->nextBlockFast(_PREHASH_ProposalData); | ||
573 | msg->addUUIDFast(_PREHASH_GroupID, mGroupID); | ||
574 | msg->addF32Fast(_PREHASH_Majority, majority ); | ||
575 | msg->addS32Fast(_PREHASH_Quorum, quorum ); | ||
576 | msg->addS32Fast(_PREHASH_Duration, duration_seconds ); | ||
577 | msg->addStringFast(_PREHASH_ProposalText, mProposalText->getText().c_str()); | ||
578 | |||
579 | gAgent.sendReliableMessage(); | ||
580 | } | ||
581 | |||
582 | void LLPanelGroupVoting::impl::sendGroupProposalBallot(const char* vote) | ||
583 | { | ||
584 | if ( !gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_VOTE) ) | ||
585 | return; | ||
586 | |||
587 | LLMessageSystem *msg = gMessageSystem; | ||
588 | |||
589 | msg->newMessageFast(_PREHASH_GroupProposalBallot); | ||
590 | msg->nextBlockFast(_PREHASH_AgentData); | ||
591 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() ); | ||
592 | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() ); | ||
593 | |||
594 | msg->nextBlockFast(_PREHASH_ProposalData); | ||
595 | msg->addUUIDFast(_PREHASH_ProposalID, mProposalID); | ||
596 | msg->addUUIDFast(_PREHASH_GroupID, mGroupID); | ||
597 | msg->addStringFast(_PREHASH_VoteCast, vote); | ||
598 | |||
599 | gAgent.sendReliableMessage(); | ||
600 | } | ||
601 | |||
602 | void LLPanelGroupVoting::impl::sendGroupVoteHistoryRequest(const LLUUID& group_id) | ||
603 | { | ||
604 | //we make the assumption here that anyone who has the start | ||
605 | //or vote powers should also have the view powers | ||
606 | |||
607 | /* This power was removed to make group roles simpler | ||
608 | if (mAwaitingFirstHistoryItem || | ||
609 | (!gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_VIEW) && | ||
610 | !gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_VOTE) && | ||
611 | !gAgent.hasPowerInGroup(mGroupID, GP_PROPOSAL_START)) ) | ||
612 | return; | ||
613 | */ | ||
614 | |||
615 | if (!gAgent.isInGroup(mGroupID)) | ||
616 | return; | ||
617 | |||
618 | mVotesHistory->deleteAllItems(); | ||
619 | mHistoryTransID.generate(); | ||
620 | mHistoryReceived.clear(); | ||
621 | |||
622 | //add some text so the user knows we're doing something | ||
623 | LLFontGL* font = LLFontGL::sSansSerifSmall; | ||
624 | addPendingHistoryScrollListItem(font, 0, 0, ADD_BOTTOM); | ||
625 | mVotesHistory->setCanSelect(FALSE); | ||
626 | |||
627 | LLMessageSystem *msg = gMessageSystem; | ||
628 | msg->newMessageFast(_PREHASH_GroupVoteHistoryRequest); | ||
629 | msg->nextBlockFast(_PREHASH_AgentData); | ||
630 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() ); | ||
631 | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() ); | ||
632 | msg->nextBlockFast(_PREHASH_GroupData); | ||
633 | msg->addUUIDFast(_PREHASH_GroupID, group_id ); | ||
634 | msg->nextBlockFast(_PREHASH_TransactionData); | ||
635 | msg->addUUIDFast(_PREHASH_TransactionID, mHistoryTransID); | ||
636 | gAgent.sendReliableMessage(); | ||
637 | } | ||
638 | |||
639 | void LLPanelGroupVoting::impl::updateQuorumText() | ||
640 | { | ||
641 | if ( mQuorumText ) | ||
642 | { | ||
643 | //update the quorum count | ||
644 | char quorum_text[MAX_STRING]; | ||
645 | sprintf(quorum_text, | ||
646 | " out of %d members must vote", | ||
647 | mNumGroupMembers); | ||
648 | mQuorumText->setText(quorum_text); | ||
649 | } | ||
650 | } | ||
651 | |||
652 | void LLPanelGroupVoting::impl::addPendingActiveScrollListItem(LLFontGL* font, | ||
653 | unsigned int current, | ||
654 | unsigned int expected, | ||
655 | EAddPosition pos) | ||
656 | { | ||
657 | LLScrollListItem* row = new LLScrollListItem( TRUE, NULL, LLUUID::null); | ||
658 | if (!row) return; | ||
659 | |||
660 | std::stringstream pending; | ||
661 | pending << "Retrieving active proposals (" | ||
662 | << current | ||
663 | << "\\" << expected << ")"; | ||
664 | row->addColumn(pending.str(), font); | ||
665 | |||
666 | mProposals->addItem(row, pos); | ||
667 | } | ||
668 | |||
669 | void LLPanelGroupVoting::impl::addNoActiveScrollListItem(LLFontGL* font, | ||
670 | EAddPosition pos) | ||
671 | { | ||
672 | LLScrollListItem* row = new LLScrollListItem( TRUE, NULL, LLUUID::null); | ||
673 | if (!row) return; | ||
674 | |||
675 | row->addColumn("There are currently no active proposals", font); | ||
676 | mProposals->addItem(row, pos); | ||
677 | } | ||
678 | |||
679 | void LLPanelGroupVoting::impl::addNoHistoryScrollListItem(LLFontGL* font, | ||
680 | EAddPosition pos) | ||
681 | { | ||
682 | LLScrollListItem* row = new LLScrollListItem( TRUE, NULL, LLUUID::null); | ||
683 | if (!row) return; | ||
684 | |||
685 | row->addColumn("There are currently no archived proposals", font); | ||
686 | mVotesHistory->addItem(row, pos); | ||
687 | } | ||
688 | |||
689 | void LLPanelGroupVoting::impl::addPendingHistoryScrollListItem(LLFontGL* font, | ||
690 | unsigned int current, | ||
691 | unsigned int expected, | ||
692 | EAddPosition pos) | ||
693 | { | ||
694 | LLScrollListItem* row = new LLScrollListItem( TRUE, NULL, LLUUID::null); | ||
695 | if (!row) return; | ||
696 | |||
697 | std::stringstream pending; | ||
698 | pending << "Retrieving archived proposals (" | ||
699 | << current | ||
700 | << "\\" << expected << ")"; | ||
701 | row->addColumn(pending.str(), font); | ||
702 | |||
703 | mVotesHistory->addItem(row, pos); | ||
704 | } | ||
705 | |||
706 | |||
707 | //static | ||
708 | std::map<LLUUID, LLPanelGroupVoting::impl*> LLPanelGroupVoting::impl::sGroupIDs; | ||
709 | |||
710 | //static | ||
711 | void LLPanelGroupVoting::impl::processGroupActiveProposalItemReply(LLMessageSystem *msg, void**) | ||
712 | { | ||
713 | LLUUID agent_id; | ||
714 | msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id ); | ||
715 | if (gAgent.getID() != agent_id) | ||
716 | { | ||
717 | llwarns << "Got active group proposals reply for another agent!" | ||
718 | << " Probably a userserver bug!" << llendl; | ||
719 | return; | ||
720 | } | ||
721 | |||
722 | LLUUID group_id; | ||
723 | LLUUID trans_id; | ||
724 | msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_GroupID, group_id ); | ||
725 | impl* self = get_if_there(sGroupIDs, group_id, (impl*) NULL); | ||
726 | if (!self) | ||
727 | { | ||
728 | return; | ||
729 | } | ||
730 | |||
731 | msg->getUUIDFast(_PREHASH_TransactionData, | ||
732 | _PREHASH_TransactionID, | ||
733 | trans_id); | ||
734 | |||
735 | if ( self->mProposalTransID != trans_id ) return; | ||
736 | |||
737 | |||
738 | U32 num_expected; | ||
739 | const S32 MAX_STRING_NUM_LEN = 20; | ||
740 | char item_num_string[DB_TERSE_DATETIME_BUF_SIZE]; | ||
741 | char proposal_text[DB_VOTE_TEXT_BUF_SIZE]; | ||
742 | char vote_cast[DB_VOTE_RESULT_BUF_SIZE]; | ||
743 | char start_datetime[DB_DATETIME_BUF_SIZE]; | ||
744 | char end_datetime[DB_DATETIME_BUF_SIZE]; | ||
745 | char vote_type[DB_VOTE_TYPE_BUF_SIZE]; | ||
746 | char majority_text[MAX_STRING_NUM_LEN]; | ||
747 | char quorum_text[MAX_STRING_NUM_LEN]; | ||
748 | char vote_initiator_string[UUID_STR_LENGTH]; | ||
749 | |||
750 | LLUUID vote_id; | ||
751 | LLUUID vote_initiator; | ||
752 | |||
753 | F32 majority; | ||
754 | S32 quorum; | ||
755 | BOOL already_voted; | ||
756 | LLFontGL* font = LLFontGL::sSansSerifSmall; | ||
757 | S32 num_proposals = msg->getNumberOfBlocksFast(_PREHASH_ProposalData); | ||
758 | |||
759 | msg->getU32Fast(_PREHASH_TransactionData, | ||
760 | _PREHASH_TotalNumItems, | ||
761 | num_expected); | ||
762 | |||
763 | //the first item should be indicative that we | ||
764 | //are currently receiving information or have it all | ||
765 | self->mProposals->deleteSingleItem(0); | ||
766 | |||
767 | for (int i = 0; i < num_proposals; i++) | ||
768 | { | ||
769 | msg->getStringFast(_PREHASH_ProposalData, _PREHASH_TerseDateID, DB_TERSE_DATETIME_BUF_SIZE, item_num_string, i ); | ||
770 | msg->getUUIDFast(_PREHASH_ProposalData, _PREHASH_VoteID, vote_id, i ); | ||
771 | msg->getStringFast(_PREHASH_ProposalData, _PREHASH_StartDateTime, DB_DATETIME_BUF_SIZE, start_datetime, i ); | ||
772 | msg->getStringFast(_PREHASH_ProposalData, _PREHASH_EndDateTime, DB_DATETIME_BUF_SIZE, end_datetime, i ); | ||
773 | msg->getUUIDFast(_PREHASH_ProposalData, _PREHASH_VoteInitiator, vote_initiator, i ); | ||
774 | msg->getBOOLFast(_PREHASH_ProposalData,_PREHASH_AlreadyVoted, already_voted, i ); | ||
775 | msg->getStringFast(_PREHASH_ProposalData,_PREHASH_VoteCast, DB_VOTE_RESULT_BUF_SIZE, vote_cast, i ); | ||
776 | msg->getStringFast(_PREHASH_ProposalData, _PREHASH_ProposalText, DB_VOTE_TEXT_BUF_SIZE, proposal_text, i ); | ||
777 | msg->getF32Fast(_PREHASH_ProposalData, _PREHASH_Majority, majority, i ); | ||
778 | msg->getS32Fast(_PREHASH_ProposalData, _PREHASH_Quorum, quorum, i ); | ||
779 | |||
780 | vote_initiator.toString(vote_initiator_string); | ||
781 | sprintf(majority_text, "%f", majority); | ||
782 | sprintf(quorum_text, "%i", quorum); | ||
783 | |||
784 | LLScrollListItem *row = new LLScrollListItem( TRUE, NULL, vote_id ); | ||
785 | if (!row) return; | ||
786 | S32 index = 0; | ||
787 | |||
788 | row->addColumn(item_num_string, font, self->mProposalColumnWidths[index++]); // Use less readable datatime for sorting... | ||
789 | row->addColumn(proposal_text, font, self->mProposalColumnWidths[index++]); | ||
790 | row->addColumn(end_datetime, font, self->mProposalColumnWidths[index++]); | ||
791 | row->addColumn(vote_type, font, self->mProposalColumnWidths[index++]); | ||
792 | row->addColumn(already_voted ? "Yes" : "No", font, self->mProposalColumnWidths[index++]); | ||
793 | row->addColumn(start_datetime, font, self->mProposalColumnWidths[index++]); | ||
794 | row->addColumn(vote_cast, font, self->mProposalColumnWidths[index++]); | ||
795 | row->addColumn(vote_initiator_string, font, self->mProposalColumnWidths[index++]); | ||
796 | row->addColumn(quorum_text, font, self->mProposalColumnWidths[index++]); | ||
797 | row->addColumn(majority_text, font, self->mProposalColumnWidths[index++]); | ||
798 | self->mActiveReceived.push_back(row); | ||
799 | } | ||
800 | |||
801 | int received = self->mActiveReceived.size(); | ||
802 | if ( num_expected == 0 ) | ||
803 | { | ||
804 | //we are expecting 0 items, put up a message indicating tehre are | ||
805 | //no active proposals and make the scroll list unselectable | ||
806 | self->addNoActiveScrollListItem(font, ADD_BOTTOM); | ||
807 | self->mProposals->setCanSelect(FALSE); | ||
808 | } | ||
809 | else if ( (U32)received != num_expected ) | ||
810 | { | ||
811 | self->addPendingActiveScrollListItem(font, | ||
812 | received, | ||
813 | num_expected, | ||
814 | ADD_BOTTOM); | ||
815 | self->mProposals->setCanSelect(FALSE); | ||
816 | } | ||
817 | else | ||
818 | { | ||
819 | //all done display all of the items | ||
820 | std::vector<LLScrollListItem*>::iterator it = self->mActiveReceived.begin(); | ||
821 | std::vector<LLScrollListItem*>::iterator end = self->mActiveReceived.end(); | ||
822 | |||
823 | for (; it != end; it++) | ||
824 | { | ||
825 | self->mProposals->addItem((*it), ADD_SORTED); | ||
826 | } | ||
827 | |||
828 | self->mProposals->setCanSelect(TRUE); | ||
829 | } | ||
830 | } | ||
831 | |||
832 | //static | ||
833 | void LLPanelGroupVoting::impl::processGroupVoteHistoryItemReply(LLMessageSystem *msg, void**) | ||
834 | { | ||
835 | LLFontGL *font = LLFontGL::sSansSerifSmall; | ||
836 | LLUUID agent_id; | ||
837 | msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id ); | ||
838 | if (gAgent.getID() != agent_id) | ||
839 | { | ||
840 | llwarns << "Got group voting history reply for another agent!" | ||
841 | << " Probably a userserver bug!" << llendl; | ||
842 | return; | ||
843 | } | ||
844 | |||
845 | LLUUID group_id; | ||
846 | msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_GroupID, group_id ); | ||
847 | impl* self = sGroupIDs[group_id]; | ||
848 | if (!self) | ||
849 | { | ||
850 | return; | ||
851 | } | ||
852 | |||
853 | LLUUID trans_id; | ||
854 | U32 num_expected; | ||
855 | |||
856 | msg->getU32Fast(_PREHASH_TransactionData, | ||
857 | _PREHASH_TotalNumItems, | ||
858 | num_expected); | ||
859 | msg->getUUIDFast(_PREHASH_TransactionData, | ||
860 | _PREHASH_TransactionID, | ||
861 | trans_id); | ||
862 | |||
863 | if ( self->mHistoryTransID != trans_id ) return; | ||
864 | |||
865 | //the first item should be some text | ||
866 | //explaining that we are attempting to receive information | ||
867 | //or are currently receiving information, so we should clear out | ||
868 | //the first line | ||
869 | self->mVotesHistory->deleteSingleItem(0); | ||
870 | |||
871 | if ( num_expected == 0 ) | ||
872 | { | ||
873 | //we are expecting 0 items, put up a message indicating tehre are | ||
874 | //no active proposals and make the scroll list unselectable | ||
875 | self->addNoHistoryScrollListItem(font, ADD_BOTTOM); | ||
876 | self->mVotesHistory->setCanSelect(FALSE); | ||
877 | |||
878 | return; | ||
879 | } | ||
880 | |||
881 | const S32 ITEM_NUM_MAX_BUF_LEN = 15; | ||
882 | char item_num_string[ITEM_NUM_MAX_BUF_LEN]; | ||
883 | char proposal_text[DB_VOTE_TEXT_BUF_SIZE]; | ||
884 | char vote_result[MAX_STRING]; | ||
885 | char start_datetime[DB_DATETIME_BUF_SIZE]; | ||
886 | char end_datetime[DB_DATETIME_BUF_SIZE]; | ||
887 | char vote_type[DB_VOTE_TYPE_BUF_SIZE]; | ||
888 | |||
889 | LLString vote_text; | ||
890 | LLUUID vote_id; | ||
891 | LLUUID vote_initiator; | ||
892 | LLUUID winner_id; | ||
893 | |||
894 | F32 majority; | ||
895 | S32 quorum; | ||
896 | |||
897 | msg->getStringFast(_PREHASH_HistoryItemData, _PREHASH_TerseDateID, ITEM_NUM_MAX_BUF_LEN, item_num_string ); | ||
898 | msg->getUUIDFast(_PREHASH_HistoryItemData, _PREHASH_VoteID, vote_id ); | ||
899 | msg->getStringFast(_PREHASH_HistoryItemData, _PREHASH_StartDateTime, DB_DATETIME_BUF_SIZE, start_datetime ); | ||
900 | msg->getStringFast(_PREHASH_HistoryItemData, _PREHASH_EndDateTime, DB_DATETIME_BUF_SIZE, end_datetime ); | ||
901 | msg->getUUIDFast(_PREHASH_HistoryItemData, _PREHASH_VoteInitiator, vote_initiator); | ||
902 | msg->getStringFast(_PREHASH_HistoryItemData, _PREHASH_VoteType, DB_VOTE_TYPE_BUF_SIZE, vote_type); | ||
903 | msg->getStringFast(_PREHASH_HistoryItemData,_PREHASH_VoteResult, DB_VOTE_RESULT_BUF_SIZE, vote_result); | ||
904 | msg->getStringFast(_PREHASH_HistoryItemData, _PREHASH_ProposalText, DB_VOTE_TEXT_BUF_SIZE, proposal_text ); | ||
905 | msg->getF32Fast(_PREHASH_HistoryItemData, _PREHASH_Majority, majority); | ||
906 | msg->getS32Fast(_PREHASH_HistoryItemData, _PREHASH_Quorum, quorum); | ||
907 | |||
908 | S32 vote_items = msg->getNumberOfBlocksFast(_PREHASH_VoteItem); | ||
909 | |||
910 | if (vote_items > 0) | ||
911 | { | ||
912 | if (!strcmp(vote_type, "Proposal")) | ||
913 | { | ||
914 | LLScrollListItem *row = new LLScrollListItem( TRUE, NULL, vote_id ); | ||
915 | if (!row) return; | ||
916 | row->addColumn(item_num_string, font, self->mHistoryColumnWidths[0]); | ||
917 | |||
918 | vote_text.assign(proposal_text); | ||
919 | vote_text.append("\n\n--\n"); | ||
920 | if (!strcmp(vote_result, "Success")) | ||
921 | { | ||
922 | vote_text.append("Proposal PASSED."); | ||
923 | } | ||
924 | else | ||
925 | { | ||
926 | vote_text.append("Proposal FAILED."); | ||
927 | } | ||
928 | vote_text.append(" Votes->\n"); | ||
929 | |||
930 | char vote_result[DB_VOTE_RESULT_BUF_SIZE]; | ||
931 | char result_msg[MAX_STRING]; | ||
932 | S32 num_votes; | ||
933 | |||
934 | for (S32 i = 0; i < vote_items; ++i) | ||
935 | { | ||
936 | msg->getStringFast(_PREHASH_VoteItem, _PREHASH_VoteCast, DB_VOTE_RESULT_BUF_SIZE, vote_result, i); | ||
937 | msg->getS32Fast(_PREHASH_VoteItem, _PREHASH_NumVotes, num_votes, i); | ||
938 | sprintf(result_msg, | ||
939 | " %s: %d\n", | ||
940 | vote_result, | ||
941 | num_votes); | ||
942 | vote_text.append(result_msg); | ||
943 | } | ||
944 | |||
945 | vote_text.append("\n"); | ||
946 | |||
947 | LLString vote_text_stripped = vote_text; | ||
948 | LLString::stripNonprintable(vote_text_stripped); | ||
949 | |||
950 | row->addColumn(vote_text_stripped, font, self->mHistoryColumnWidths[1]); | ||
951 | row->addColumn(end_datetime, font, self->mHistoryColumnWidths[2]); | ||
952 | row->addColumn(vote_type, font, self->mHistoryColumnWidths[3]); | ||
953 | row->addColumn(vote_result, font, self->mHistoryColumnWidths[4]); | ||
954 | row->addColumn(vote_text, font, self->mHistoryColumnWidths[5]); | ||
955 | |||
956 | self->mHistoryReceived.push_back(row); | ||
957 | } //end if proposal | ||
958 | } //end if vote_items > 0 | ||
959 | |||
960 | int received = self->mHistoryReceived.size(); | ||
961 | if ( (U32)received != num_expected ) | ||
962 | { | ||
963 | self->addPendingHistoryScrollListItem(font, | ||
964 | received, | ||
965 | num_expected, | ||
966 | ADD_BOTTOM); | ||
967 | self->mVotesHistory->setCanSelect(FALSE); | ||
968 | } | ||
969 | else | ||
970 | { | ||
971 | //all done display all of the items | ||
972 | std::vector<LLScrollListItem*>::iterator it = self->mHistoryReceived.begin(); | ||
973 | std::vector<LLScrollListItem*>::iterator end = self->mHistoryReceived.end(); | ||
974 | |||
975 | for (; it != end; it++) | ||
976 | { | ||
977 | self->mVotesHistory->addItem((*it), ADD_SORTED); | ||
978 | } | ||
979 | |||
980 | self->mVotesHistory->setCanSelect(TRUE); | ||
981 | } | ||
982 | } | ||
983 | |||
984 | //static | ||
985 | void LLPanelGroupVoting::impl::onClickCreateProposal(void* userdata) | ||
986 | { | ||
987 | impl* self = (impl*)userdata; | ||
988 | if ( self ) self->setEnableCreateProposal(); | ||
989 | } | ||
990 | |||
991 | //static | ||
992 | void LLPanelGroupVoting::impl::onClickYes(void *userdata) | ||
993 | { | ||
994 | LLPanelGroupVoting::impl* self = (LLPanelGroupVoting::impl*)userdata; | ||
995 | |||
996 | if ( self && self->mInstructions ) | ||
997 | { | ||
998 | self->mInstructions->setText("Submitting Yes to proposal..."); | ||
999 | self->sendGroupProposalBallot("Yes"); | ||
1000 | |||
1001 | //refresh the proposals now that we've hit yes | ||
1002 | self->sendGroupProposalsRequest(self->mGroupID); | ||
1003 | self->sendGroupVoteHistoryRequest(self->mGroupID); | ||
1004 | self->setEnableListProposals(); | ||
1005 | } | ||
1006 | } | ||
1007 | |||
1008 | //static | ||
1009 | void LLPanelGroupVoting::impl::onClickNo(void *userdata) | ||
1010 | { | ||
1011 | LLPanelGroupVoting::impl* self = (LLPanelGroupVoting::impl*)userdata; | ||
1012 | |||
1013 | if ( self && self->mInstructions ) | ||
1014 | { | ||
1015 | self->mInstructions->setText("Submitting No to proposal..."); | ||
1016 | self->sendGroupProposalBallot("No"); | ||
1017 | |||
1018 | //refresh the proposals now that we've hit no | ||
1019 | self->sendGroupProposalsRequest(self->mGroupID); | ||
1020 | self->sendGroupVoteHistoryRequest(self->mGroupID); | ||
1021 | self->setEnableListProposals(); | ||
1022 | } | ||
1023 | } | ||
1024 | |||
1025 | //static | ||
1026 | void LLPanelGroupVoting::impl::onClickAbstain(void *userdata) | ||
1027 | { | ||
1028 | impl* self = (LLPanelGroupVoting::impl*) userdata; | ||
1029 | |||
1030 | if ( self && self->mInstructions ) | ||
1031 | { | ||
1032 | self->mInstructions->setText("Submitting Abstention to proposal..."); | ||
1033 | self->sendGroupProposalBallot("Abstain"); | ||
1034 | |||
1035 | //refresh the proposals now that we've hit abstain | ||
1036 | self->sendGroupProposalsRequest(self->mGroupID); | ||
1037 | self->sendGroupVoteHistoryRequest(self->mGroupID); | ||
1038 | self->setEnableListProposals(); | ||
1039 | } | ||
1040 | } | ||
1041 | |||
1042 | //static | ||
1043 | void LLPanelGroupVoting::impl::onClickSubmitProposal(void *userdata) | ||
1044 | { | ||
1045 | gFocusMgr.setKeyboardFocus(NULL, NULL); | ||
1046 | impl* self = (impl*)userdata; | ||
1047 | |||
1048 | if ( self && self->mInstructions && self->mProposalText ) | ||
1049 | { | ||
1050 | //check to see if the proposal has any text for some form of | ||
1051 | //"validation" | ||
1052 | if ( self->mProposalText->getText().empty() ) | ||
1053 | { | ||
1054 | //throw up an error dialog | ||
1055 | LLString::format_map_t args; | ||
1056 | args["[MESSAGE]"] = self->mEmptyProposalText; | ||
1057 | gViewerWindow->alertXml("GenericAlert", args); | ||
1058 | return; | ||
1059 | } | ||
1060 | |||
1061 | self->mInstructions->setText("Submitting new Proposal..."); | ||
1062 | self->sendStartGroupProposal(); | ||
1063 | |||
1064 | //refresh the proposals now that we've submitted a new one | ||
1065 | self->sendGroupProposalsRequest(self->mGroupID); | ||
1066 | self->setEnableListProposals(); | ||
1067 | } | ||
1068 | } | ||
1069 | |||
1070 | //static | ||
1071 | void LLPanelGroupVoting::impl::onClickCancelProposal(void* userdata) | ||
1072 | { | ||
1073 | impl* self = (impl*)userdata; | ||
1074 | |||
1075 | if ( self ) | ||
1076 | { | ||
1077 | self->setEnableListProposals(); | ||
1078 | } | ||
1079 | } | ||
1080 | |||
1081 | //static | ||
1082 | void LLPanelGroupVoting::impl::onClickViewProposalList(void *userdata) | ||
1083 | { | ||
1084 | impl* self = (LLPanelGroupVoting::impl*)userdata; | ||
1085 | |||
1086 | if ( self ) self->setEnableListProposals(); | ||
1087 | } | ||
1088 | |||
1089 | //static | ||
1090 | void LLPanelGroupVoting::impl::onClickViewProposalItem(void *userdata) | ||
1091 | { | ||
1092 | impl* self = (LLPanelGroupVoting::impl*)userdata; | ||
1093 | |||
1094 | if ( self && self->mProposals ) | ||
1095 | { | ||
1096 | if (self->mProposals->getFirstSelected() != NULL) | ||
1097 | { | ||
1098 | self->setEnableVoteProposal(); | ||
1099 | } | ||
1100 | else | ||
1101 | { | ||
1102 | gViewerWindow->alertXml("SelectProposalToView"); | ||
1103 | } | ||
1104 | } | ||
1105 | } | ||
1106 | |||
1107 | //static | ||
1108 | void LLPanelGroupVoting::impl::onDoubleClickProposal(void *userdata) | ||
1109 | { | ||
1110 | impl* self = (impl*)userdata; | ||
1111 | if ( self && self->mProposals->getFirstSelected() != NULL ) | ||
1112 | { | ||
1113 | self->setEnableVoteProposal(); | ||
1114 | } | ||
1115 | } | ||
1116 | |||
1117 | //static | ||
1118 | void LLPanelGroupVoting::impl::onDoubleClickHistoryItem(void *userdata) | ||
1119 | { | ||
1120 | impl* self = (impl*)userdata; | ||
1121 | if ( self && self->mVotesHistory->getFirstSelected() != NULL ) | ||
1122 | { | ||
1123 | self->setEnableHistoryItem(); | ||
1124 | } | ||
1125 | } | ||
1126 | |||
1127 | //static | ||
1128 | void LLPanelGroupVoting::impl::onClickViewHistoryItem(void *userdata) | ||
1129 | { | ||
1130 | impl* self = (impl*)userdata; | ||
1131 | |||
1132 | if (self->mVotesHistory->getFirstSelected() != NULL) | ||
1133 | { | ||
1134 | self->setEnableHistoryItem(); | ||
1135 | } | ||
1136 | else | ||
1137 | { | ||
1138 | gViewerWindow->alertXml("SelectHistoryItemToView"); | ||
1139 | } | ||
1140 | } | ||
1141 | |||
1142 | //static | ||
1143 | void LLPanelGroupVoting::impl::onClickViewHistoryList(void *userdata) | ||
1144 | { | ||
1145 | impl* self = (impl*)userdata; | ||
1146 | |||
1147 | if ( self) self->setEnableHistoryList(); | ||
1148 | } | ||
1149 | |||
1150 | //********************************** | ||
1151 | //** LLPanelGroupVoting Functions ** | ||
1152 | //********************************** | ||
1153 | |||
1154 | // static | ||
1155 | void* LLPanelGroupVoting::createTab(void* data) | ||
1156 | { | ||
1157 | LLUUID* group_id = static_cast<LLUUID*>(data); | ||
1158 | return new LLPanelGroupVoting("panel group voting", *group_id); | ||
1159 | } | ||
1160 | |||
1161 | LLPanelGroupVoting::LLPanelGroupVoting(const std::string& name, | ||
1162 | const LLUUID& group_id) | ||
1163 | : LLPanelGroupTab(name, group_id) | ||
1164 | { | ||
1165 | mImpl = new impl(group_id); | ||
1166 | } | ||
1167 | |||
1168 | LLPanelGroupVoting::~LLPanelGroupVoting() | ||
1169 | { | ||
1170 | delete mImpl; | ||
1171 | } | ||
1172 | |||
1173 | BOOL LLPanelGroupVoting::isVisibleByAgent(LLAgent* agentp) | ||
1174 | { | ||
1175 | //if they are in the group, the panel is viewable | ||
1176 | return mAllowEdit && agentp->isInGroup(mGroupID); | ||
1177 | } | ||
1178 | |||
1179 | BOOL LLPanelGroupVoting::postBuild() | ||
1180 | { | ||
1181 | bool recurse = true; | ||
1182 | |||
1183 | mImpl->mQuorumText = (LLTextBox*) getChildByName("quorum_text", recurse); | ||
1184 | mImpl->mDurationText = (LLTextBox*) getChildByName("duration_text", | ||
1185 | recurse); | ||
1186 | mImpl->mQuorum = (LLSpinCtrl*) getChildByName("quorum", recurse); | ||
1187 | mImpl->mQuorumLbl = (LLTextBox*) getChildByName("quorum_lbl", recurse); | ||
1188 | mImpl->mDuration = (LLSpinCtrl*) getChildByName("duration", recurse); | ||
1189 | mImpl->mDurationLbl = (LLTextBox*) getChildByName("duration_lbl", recurse); | ||
1190 | mImpl->mMajority = (LLRadioGroup*) getChildByName("majority", recurse); | ||
1191 | mImpl->mMajorityLbl = (LLTextBox*) getChildByName("majority_lbl", recurse); | ||
1192 | mImpl->mInstructions = (LLTextBox*) getChildByName("proposal_instructions", | ||
1193 | recurse); | ||
1194 | mImpl->mProposalHeader = (LLTextBox*) getChildByName("proposal_header", | ||
1195 | recurse); | ||
1196 | |||
1197 | mImpl->mProposalLbl = (LLTextBox*) getChildByName("proposal_lbl", recurse); | ||
1198 | mImpl->mStartLbl = (LLTextBox*) getChildByName("start_lbl", recurse); | ||
1199 | mImpl->mEndLbl = (LLTextBox*) getChildByName("end_lbl", recurse); | ||
1200 | mImpl->mStartDate = (LLTextBox*) getChildByName("start_date", recurse); | ||
1201 | mImpl->mEndDate = (LLTextBox*) getChildByName("end_date", recurse); | ||
1202 | |||
1203 | mImpl->mBtnYes = (LLButton*) getChildByName("btn_yes", recurse); | ||
1204 | mImpl->mBtnNo = (LLButton*) getChildByName("btn_no", recurse); | ||
1205 | mImpl->mBtnAbstain = (LLButton*) getChildByName("btn_abstain", recurse); | ||
1206 | |||
1207 | mImpl->mProposals = | ||
1208 | (LLScrollListCtrl*) getChildByName("proposals", recurse); | ||
1209 | mImpl->mProposalText = | ||
1210 | (LLTextEditor*) getChildByName("proposal_text", recurse); | ||
1211 | |||
1212 | mImpl->mBtnCreateProposal = (LLButton*) getChildByName("btn_proposal", | ||
1213 | recurse); | ||
1214 | mImpl->mBtnSubmitProposal = (LLButton*) getChildByName("btn_submit", | ||
1215 | recurse); | ||
1216 | mImpl->mBtnCancelProposal = (LLButton*) getChildByName("btn_cancel", | ||
1217 | recurse); | ||
1218 | |||
1219 | mImpl->mBtnViewProposalList = | ||
1220 | (LLButton*) getChildByName("btn_view_proposal_list", recurse); | ||
1221 | mImpl->mBtnViewProposalItem = | ||
1222 | (LLButton*) getChildByName("btn_view_proposal_item", recurse); | ||
1223 | |||
1224 | mImpl->mVotesHistory = (LLScrollListCtrl*)getChildByName("history_list", | ||
1225 | recurse); | ||
1226 | mImpl->mVotesHistoryLbl = (LLTextBox*) getChildByName("history_list_lbl", | ||
1227 | recurse); | ||
1228 | mImpl->mVoteHistoryText = (LLTextEditor*) getChildByName("vote_text", | ||
1229 | recurse); | ||
1230 | mImpl->mVoteHistoryTextLbl = (LLTextBox*) getChildByName("vote_text_lbl", | ||
1231 | recurse); | ||
1232 | |||
1233 | mImpl->mBtnViewHistoryList = | ||
1234 | (LLButton*)getChildByName("btn_view_history_list", recurse); | ||
1235 | mImpl->mBtnViewHistoryItem = | ||
1236 | (LLButton*)getChildByName("btn_view_history_item", recurse); | ||
1237 | |||
1238 | LLTextBox *txt = (LLTextBox*) getChildByName("proposals_header_view_txt", | ||
1239 | recurse); | ||
1240 | if (txt) | ||
1241 | { | ||
1242 | mImpl->mViewProposalHeaderText = txt->getText(); | ||
1243 | removeChild(txt); | ||
1244 | } | ||
1245 | |||
1246 | txt = (LLTextBox*) getChildByName("proposals_header_create_txt", recurse); | ||
1247 | if (txt) | ||
1248 | { | ||
1249 | mImpl->mCreateProposalHeaderText = txt->getText(); | ||
1250 | removeChild(txt); | ||
1251 | } | ||
1252 | |||
1253 | txt = (LLTextBox*) getChildByName("proposals_header_vote_txt", recurse); | ||
1254 | if (txt) | ||
1255 | { | ||
1256 | mImpl->mVoteProposalHeaderText = txt->getText(); | ||
1257 | removeChild(txt); | ||
1258 | } | ||
1259 | |||
1260 | txt = (LLTextBox*) getChildByName("empty_proposal_txt", recurse); | ||
1261 | if (txt) | ||
1262 | { | ||
1263 | mImpl->mEmptyProposalText = txt->getText(); | ||
1264 | removeChild(txt); | ||
1265 | } | ||
1266 | |||
1267 | mImpl->updateQuorumText(); | ||
1268 | |||
1269 | bool success = (mImpl->mQuorumText && | ||
1270 | mImpl->mDurationText && | ||
1271 | mImpl->mQuorum && | ||
1272 | mImpl->mQuorumLbl && | ||
1273 | mImpl->mDuration && | ||
1274 | mImpl->mDurationLbl && | ||
1275 | mImpl->mMajority && | ||
1276 | mImpl->mMajorityLbl && | ||
1277 | mImpl->mInstructions && | ||
1278 | mImpl->mProposalHeader && | ||
1279 | mImpl->mProposalLbl && | ||
1280 | mImpl->mStartLbl && | ||
1281 | mImpl->mEndLbl && | ||
1282 | mImpl->mStartDate && | ||
1283 | mImpl->mEndDate && | ||
1284 | mImpl->mBtnYes && | ||
1285 | mImpl->mBtnNo && | ||
1286 | mImpl->mBtnAbstain && | ||
1287 | mImpl->mProposals && | ||
1288 | mImpl->mProposalText && | ||
1289 | mImpl->mBtnCreateProposal && | ||
1290 | mImpl->mBtnSubmitProposal && | ||
1291 | mImpl->mBtnCancelProposal && | ||
1292 | mImpl->mBtnViewProposalList && | ||
1293 | mImpl->mBtnViewProposalItem && | ||
1294 | mImpl->mVotesHistory && | ||
1295 | mImpl->mVotesHistoryLbl && | ||
1296 | mImpl->mVoteHistoryText && | ||
1297 | mImpl->mVoteHistoryTextLbl && | ||
1298 | mImpl->mBtnViewHistoryList && | ||
1299 | mImpl->mBtnViewHistoryItem ); | ||
1300 | |||
1301 | //associate callbacks | ||
1302 | if ( success ) | ||
1303 | { | ||
1304 | mImpl->mProposals->setDoubleClickCallback(impl::onDoubleClickProposal); | ||
1305 | mImpl->mProposals->setCallbackUserData(mImpl); | ||
1306 | |||
1307 | mImpl->mVotesHistory->setDoubleClickCallback(impl::onDoubleClickHistoryItem); | ||
1308 | mImpl->mVotesHistory->setCallbackUserData(mImpl); | ||
1309 | |||
1310 | mImpl->mBtnAbstain->setClickedCallback(impl::onClickAbstain); | ||
1311 | mImpl->mBtnAbstain->setCallbackUserData(mImpl); | ||
1312 | |||
1313 | mImpl->mBtnNo->setClickedCallback(impl::onClickNo); | ||
1314 | mImpl->mBtnNo->setCallbackUserData(mImpl); | ||
1315 | |||
1316 | mImpl->mBtnYes->setClickedCallback(impl::onClickYes); | ||
1317 | mImpl->mBtnYes->setCallbackUserData(mImpl); | ||
1318 | |||
1319 | mImpl->mBtnCreateProposal->setClickedCallback(impl::onClickCreateProposal); | ||
1320 | mImpl->mBtnCreateProposal->setCallbackUserData(mImpl); | ||
1321 | |||
1322 | mImpl->mBtnSubmitProposal->setClickedCallback(impl::onClickSubmitProposal); | ||
1323 | mImpl->mBtnSubmitProposal->setCallbackUserData(mImpl); | ||
1324 | |||
1325 | mImpl->mBtnCancelProposal->setClickedCallback(impl::onClickCancelProposal); | ||
1326 | mImpl->mBtnCancelProposal->setCallbackUserData(mImpl); | ||
1327 | |||
1328 | mImpl->mBtnViewProposalList->setClickedCallback(impl::onClickViewProposalList); | ||
1329 | mImpl->mBtnViewProposalList->setCallbackUserData(mImpl); | ||
1330 | |||
1331 | mImpl->mBtnViewProposalItem->setClickedCallback(impl::onClickViewProposalItem); | ||
1332 | mImpl->mBtnViewProposalItem->setCallbackUserData(mImpl); | ||
1333 | |||
1334 | mImpl->mBtnViewHistoryList->setClickedCallback(impl::onClickViewHistoryList); | ||
1335 | mImpl->mBtnViewHistoryList->setCallbackUserData(mImpl); | ||
1336 | |||
1337 | mImpl->mBtnViewHistoryItem->setClickedCallback(impl::onClickViewHistoryItem); | ||
1338 | mImpl->mBtnViewHistoryItem->setCallbackUserData(mImpl); | ||
1339 | |||
1340 | gMessageSystem->setHandlerFuncFast(_PREHASH_GroupActiveProposalItemReply, | ||
1341 | impl::processGroupActiveProposalItemReply); | ||
1342 | gMessageSystem->setHandlerFuncFast(_PREHASH_GroupVoteHistoryItemReply, | ||
1343 | impl::processGroupVoteHistoryItemReply); | ||
1344 | } | ||
1345 | |||
1346 | return success && LLPanelGroupTab::postBuild(); | ||
1347 | } | ||
1348 | |||
1349 | |||
1350 | void LLPanelGroupVoting::activate() | ||
1351 | { | ||
1352 | gGroupMgr->sendGroupPropertiesRequest(mGroupID); | ||
1353 | update(GC_ALL); | ||
1354 | |||
1355 | mImpl->setEnableListProposals(); | ||
1356 | mImpl->setEnableHistoryList(); | ||
1357 | } | ||
1358 | |||
1359 | bool LLPanelGroupVoting::needsApply(LLString& mesg) | ||
1360 | { | ||
1361 | return false; | ||
1362 | } | ||
1363 | |||
1364 | bool LLPanelGroupVoting::apply(LLString& mesg) | ||
1365 | { | ||
1366 | return true; | ||
1367 | } | ||
1368 | |||
1369 | void LLPanelGroupVoting::update(LLGroupChange gc) | ||
1370 | { | ||
1371 | LLGroupMgrGroupData* group_datap = NULL; | ||
1372 | group_datap = gGroupMgr->getGroupData(mGroupID); | ||
1373 | |||
1374 | if ( group_datap ) | ||
1375 | { | ||
1376 | S32 num_group_members = group_datap->mMemberCount; | ||
1377 | mImpl->mNumGroupMembers = num_group_members; | ||
1378 | |||
1379 | mImpl->updateQuorumText(); | ||
1380 | } | ||
1381 | |||
1382 | mImpl->sendGroupProposalsRequest(mGroupID); | ||
1383 | mImpl->sendGroupVoteHistoryRequest(mGroupID); | ||
1384 | } | ||
1385 | |||