aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llpanelmoney.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llpanelmoney.cpp483
1 files changed, 0 insertions, 483 deletions
diff --git a/linden/indra/newview/llpanelmoney.cpp b/linden/indra/newview/llpanelmoney.cpp
deleted file mode 100644
index 1dcd544..0000000
--- a/linden/indra/newview/llpanelmoney.cpp
+++ /dev/null
@@ -1,483 +0,0 @@
1/**
2 * @file llpanelmoney.cpp
3 * @author James Cook
4 * @brief Panels for Account History floater
5 *
6 * Copyright (c) 2003-2007, Linden Research, Inc.
7 *
8 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement
11 * ("Other License"), formally executed by you and Linden Lab. Terms of
12 * the GPL can be found in doc/GPL-license.txt in this distribution, or
13 * online at http://secondlife.com/developers/opensource/gplv2
14 *
15 * There are special exceptions to the terms and conditions of the GPL as
16 * it is applied to this Source Code. View the full text of the exception
17 * in the file doc/FLOSS-exception.txt in this software distribution, or
18 * online at http://secondlife.com/developers/opensource/flossexception
19 *
20 * By copying, modifying or distributing this software, you acknowledge
21 * that you have read and understood your obligations described above,
22 * and agree to abide by those obligations.
23 *
24 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
25 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
26 * COMPLETENESS OR PERFORMANCE.
27 */
28
29#include "llviewerprecompiledheaders.h"
30
31#include "llpanelmoney.h"
32
33#include "llfontgl.h"
34#include "message.h"
35#include "lltransactiontypes.h"
36
37#include "llpanel.h"
38#include "llbutton.h"
39#include "llviewercontrol.h"
40#include "llstatusbar.h"
41#include "lluiconstants.h"
42#include "llvieweruictrlfactory.h"
43#include "viewer.h"
44
45// XUI:translate
46const char LOADING_STRING[] = "Computing...";
47
48S32 LLPanelAccount::sCurrentInterval = 0;
49
50//---------------------------------------------------------------------------
51// LLPanelAccount - the base class for all account panels
52//---------------------------------------------------------------------------
53
54// Construct with a dummy rectangle because tab containers will
55// resize their panels. Thus, merely need to make sure the follow
56// flags are correctly set.
57LLPanelAccount::LLPanelAccount(const LLUUID& request_id, S32 interval_days, S32 max_interval, const std::string& filename)
58: LLPanel("account_panel"),
59 mRequestID( request_id ),
60 mDataRequested( FALSE ),
61 mIntervalDays( interval_days ),
62 mMaxInterval( max_interval )
63{
64 sCurrentInterval = 0;
65
66 gUICtrlFactory->buildPanel(this, filename);
67
68 childSetText("editor", LOADING_STRING);
69
70 childSetAction("earlier_btn", onClickEarlier, this);
71 childSetAction("later_btn", onClickLater, this);
72}
73
74
75// public virtual
76void LLPanelAccount::draw()
77{
78 if (!mDataRequested || (mDisplayedInterval != sCurrentInterval) )
79 {
80 sendRequest();
81 refreshPanel();
82 mDisplayedInterval = sCurrentInterval;
83 mDataRequested = TRUE;
84 }
85
86 LLPanel::draw();
87}
88
89void LLPanelAccount::refreshPanel()
90{
91 // Used by some panels that have buttons and some that don't (so no warnings)
92 if (hasChild("earlier_btn"))
93 {
94 childSetEnabled("earlier_btn", sCurrentInterval < mMaxInterval);
95 }
96 if (hasChild("later_btn"))
97 {
98 childSetEnabled("later_btn", sCurrentInterval > 0);
99 }
100}
101
102// static
103void LLPanelAccount::onClickEarlier(void *userdata)
104{
105 LLPanelAccount* self = (LLPanelAccount*)userdata;
106 if (!self) return;
107
108 if (self->sCurrentInterval < self->mMaxInterval)
109 {
110 self->childSetText("editor", LOADING_STRING);
111 self->sCurrentInterval++;
112 self->refreshPanel();
113 self->setDataRequested(FALSE);
114 }
115}
116
117// static
118void LLPanelAccount::onClickLater(void *userdata)
119{
120 LLPanelAccount* self = (LLPanelAccount*)userdata;
121 if (!self) return;
122
123 if (self->sCurrentInterval > 0)
124 {
125 self->childSetText("editor", LOADING_STRING);
126 self->sCurrentInterval--;
127 self->refreshPanel();
128 self->setDataRequested(FALSE);
129 }
130}
131
132
133//---------------------------------------------------------------------------
134// LLPanelAccountPlanning - the first, default view of money
135//---------------------------------------------------------------------------
136LLPanelAccountPlanning::LLPanelAccountPlanning(const LLUUID& request_id)
137: LLPanelAccount(request_id, SUMMARY_INTERVAL, SUMMARY_MAX, "panel_account_planning.xml")
138{
139 childSetText("editor", LOADING_STRING);
140}
141
142// virtual
143void LLPanelAccountPlanning::sendRequest()
144{
145 LLMessageSystem* msg = gMessageSystem;
146
147 msg->newMessageFast(_PREHASH_MoneySummaryRequest);
148 msg->nextBlockFast(_PREHASH_AgentData);
149 msg->addUUIDFast(_PREHASH_AgentID, agent_get_id() );
150 msg->addUUIDFast(_PREHASH_SessionID, agent_get_session_id() );
151 msg->nextBlockFast(_PREHASH_MoneyData);
152 msg->addUUIDFast(_PREHASH_RequestID, mRequestID );
153 msg->addS32Fast(_PREHASH_IntervalDays, mIntervalDays );
154 msg->addS32Fast(_PREHASH_CurrentInterval, 0 );
155
156 agent_send_reliable_message();
157
158 childSetText("editor", LOADING_STRING);
159}
160
161// virtual
162void LLPanelAccountPlanning::processReply(LLMessageSystem* msg, void** data)
163{
164 char line[MAX_STRING];
165 LLString text;
166
167 char start_date[MAX_STRING];
168 char last_stipend_date[MAX_STRING];
169 char next_stipend_date[MAX_STRING];
170 S32 interval_days;
171 S32 current_interval;
172 S32 balance;
173 S32 total_credits;
174 S32 total_debits;
175 S32 cur_object_tax;
176 S32 cur_light_tax;
177 S32 cur_land_tax;
178 S32 cur_group_tax;
179 S32 cur_parcel_dir_fee;
180 S32 cur_total_tax;
181 S32 proj_object_tax;
182 S32 proj_light_tax;
183 S32 proj_land_tax;
184 S32 proj_group_tax;
185 S32 proj_parcel_dir_fee;
186 S32 proj_total_tax;
187 S32 stipend;
188
189 msg->getS32("MoneyData", "IntervalDays", interval_days );
190 msg->getS32("MoneyData", "CurrentInterval", current_interval );
191 msg->getS32("MoneyData", "Balance", balance );
192 msg->getS32("MoneyData", "TotalCredits", total_credits );
193 msg->getS32("MoneyData", "TotalDebits", total_debits );
194 msg->getS32("MoneyData", "ObjectTaxCurrent", cur_object_tax );
195 msg->getS32("MoneyData", "LightTaxCurrent", cur_light_tax );
196 msg->getS32("MoneyData", "LandTaxCurrent", cur_land_tax );
197 msg->getS32("MoneyData", "GroupTaxCurrent", cur_group_tax );
198 msg->getS32("MoneyData", "ParcelDirFeeCurrent", cur_parcel_dir_fee );
199 msg->getS32("MoneyData", "ObjectTaxEstimate", proj_object_tax );
200 msg->getS32("MoneyData", "LightTaxEstimate", proj_light_tax );
201 msg->getS32("MoneyData", "LandTaxEstimate", proj_land_tax );
202 msg->getS32("MoneyData", "GroupTaxEstimate", proj_group_tax );
203 msg->getS32("MoneyData", "ParcelDirFeeEstimate", proj_parcel_dir_fee );
204 msg->getS32("MoneyData", "StipendEstimate", stipend );
205
206 msg->getString("MoneyData", "StartDate", MAX_STRING, start_date);
207 msg->getString("MoneyData", "LastTaxDate", MAX_STRING, last_stipend_date);
208 msg->getString("MoneyData", "TaxDate", MAX_STRING, next_stipend_date);
209
210 cur_total_tax = cur_object_tax + cur_light_tax + cur_land_tax + cur_group_tax + cur_parcel_dir_fee;
211 proj_total_tax = proj_object_tax + proj_light_tax + proj_land_tax + proj_group_tax + proj_parcel_dir_fee;
212
213 if (interval_days != mIntervalDays || current_interval != sCurrentInterval)
214 {
215 llinfos << "Out of date summary packet " << interval_days << " "
216 << current_interval << llendl;
217 return;
218 }
219
220 // *NOTE: actually use the balance from the status bar, so the two
221 // match. This should not be necessary because the simulator no
222 // longer buffers transaction. If status bar balance is zero,
223 // assume this is because we haven't received the first balance
224 // yet, and trust the database.
225 if (0 != gStatusBar->getBalance())
226 {
227 balance = gStatusBar->getBalance();
228 }
229
230 sprintf(line, "Summary for this week, beginning on %s\n", start_date);
231 text.append(line);
232
233 if (current_interval == 0)
234 {
235 text.append(1, '\n');
236
237 sprintf(line, "Your next stipend day is %s\n\n", next_stipend_date);
238 text.append(line);
239 sprintf(line, "%-24sL$%6d\n", "Balance", balance );
240 text.append(line);
241
242 text.append(1, '\n');
243 }
244
245 sprintf(line, "%-24s %6d\n", "Credits", total_credits);
246 text.append(line);
247
248 sprintf(line, "%-24s %6d\n", "Debits", total_debits);
249 text.append(line);
250
251 sprintf(line, "%-24s %6d\n", "Total Change", total_credits + total_debits);
252 text.append(line);
253
254 if (current_interval == 0)
255 {
256 text.append(1, '\n');
257
258 text.append(1, '\n');
259
260 sprintf(line, "%-24s %6d\n", "Estimated Stipend", stipend );
261 text.append(line);
262
263 // Generate projected "wealth tax" based on current balance, projected stipend/bonus
264 }
265 else
266 {
267 text.append(1, '\n');
268 text.append(1, '\n');
269
270 sprintf(line, "%-24s %6d\n", "Parcel Directory Fee", cur_parcel_dir_fee);
271 text.append(line);
272 }
273
274 childSetText("editor", text);
275}
276
277
278//---------------------------------------------------------------------------
279// LLPanelAccountDetails
280//---------------------------------------------------------------------------
281LLPanelAccountDetails::LLPanelAccountDetails(const LLUUID& request_id)
282: LLPanelAccount(request_id,
283 DETAILS_INTERVAL,
284 DETAILS_MAX,
285 "panel_account_details.xml")
286{
287 childSetText("editor", LOADING_STRING);
288}
289
290// virtual
291void LLPanelAccountDetails::sendRequest()
292{
293 LLMessageSystem* msg = gMessageSystem;
294
295 msg->newMessageFast(_PREHASH_MoneyDetailsRequest);
296 msg->nextBlockFast(_PREHASH_AgentData);
297 msg->addUUIDFast(_PREHASH_AgentID, agent_get_id() );
298 msg->addUUIDFast(_PREHASH_SessionID, agent_get_session_id() );
299 msg->nextBlockFast(_PREHASH_MoneyData);
300 msg->addUUIDFast(_PREHASH_RequestID, mRequestID );
301 msg->addS32Fast(_PREHASH_IntervalDays, mIntervalDays );
302 msg->addS32Fast(_PREHASH_CurrentInterval, sCurrentInterval );
303
304 agent_send_reliable_message();
305}
306
307// virtual
308void LLPanelAccountDetails::processReply(LLMessageSystem* msg, void** data)
309{
310 char line[MAX_STRING];
311 LLString text;
312
313 char start_date[MAX_STRING];
314 S32 interval_days;
315 S32 current_interval;
316
317 msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_IntervalDays, interval_days );
318 msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_CurrentInterval, current_interval );
319 msg->getStringFast(_PREHASH_MoneyData, _PREHASH_StartDate, MAX_STRING, start_date);
320
321 if (interval_days != mIntervalDays || current_interval != sCurrentInterval)
322 {
323 llinfos << "Out of date details packet " << interval_days << " "
324 << current_interval << llendl;
325 return;
326 }
327
328 sprintf(line, "%s\n\n", start_date);
329 text.append(line);
330
331 S32 total_amount = 0;
332 S32 transactions = msg->getNumberOfBlocksFast(_PREHASH_HistoryData);
333 for(S32 i = 0; i < transactions; i++)
334 {
335 S32 amount = 0;
336 char desc[MAX_STRING];
337
338 msg->getStringFast(_PREHASH_HistoryData, _PREHASH_Description, MAX_STRING, desc, i );
339 msg->getS32Fast(_PREHASH_HistoryData, _PREHASH_Amount, amount, i);
340
341 if (amount != 0)
342 {
343 sprintf(line, "%-24s %6d\n", desc, amount );
344 text.append(line);
345 }
346 else
347 {
348 // skip it
349 }
350
351 total_amount += amount;
352 }
353
354 text.append(1, '\n');
355
356 sprintf(line, "%-24s %6d\n", "Total", total_amount );
357 text.append(line);
358
359 childSetText("editor", text);
360}
361
362//---------------------------------------------------------------------------
363// LLPanelAccountTransactions
364//---------------------------------------------------------------------------
365LLPanelAccountTransactions::LLPanelAccountTransactions(const LLUUID& request_id)
366: LLPanelAccount(request_id,
367 TRANSACTIONS_INTERVAL,
368 TRANSACTIONS_MAX,
369 "panel_account_transactions.xml")
370{
371 childSetText("editor", LOADING_STRING);
372}
373
374// virtual
375void LLPanelAccountTransactions::sendRequest()
376{
377 LLMessageSystem* msg = gMessageSystem;
378
379 msg->newMessageFast(_PREHASH_MoneyTransactionsRequest);
380 msg->nextBlockFast(_PREHASH_AgentData);
381 msg->addUUIDFast(_PREHASH_AgentID, agent_get_id() );
382 msg->addUUIDFast(_PREHASH_SessionID, agent_get_session_id() );
383 msg->nextBlockFast(_PREHASH_MoneyData);
384 msg->addUUIDFast(_PREHASH_RequestID, mRequestID );
385 msg->addS32Fast(_PREHASH_IntervalDays, mIntervalDays );
386 msg->addS32Fast(_PREHASH_CurrentInterval, sCurrentInterval );
387
388 agent_send_reliable_message();
389
390 childSetText("editor", LOADING_STRING);
391}
392
393// virtual
394void LLPanelAccountTransactions::processReply(LLMessageSystem* msg, void** data)
395{
396 char line[MAX_STRING];
397 LLSD value = childGetValue("editor");
398 std::string text = value.asString();
399
400 char start_date[MAX_STRING];
401 S32 interval_days;
402 S32 current_interval;
403
404 msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_IntervalDays, interval_days );
405 msg->getS32Fast(_PREHASH_MoneyData, _PREHASH_CurrentInterval, current_interval );
406 msg->getStringFast(_PREHASH_MoneyData, _PREHASH_StartDate, MAX_STRING, start_date);
407
408 if (interval_days != mIntervalDays || current_interval != sCurrentInterval)
409 {
410 llinfos << "Out of date details packet " << interval_days << " "
411 << current_interval << llendl;
412 return;
413 }
414
415 // If this is the first packet, clear the text, don't append.
416 // Start with the date.
417 if (text == LOADING_STRING)
418 {
419 text.clear();
420
421 sprintf(line, "%s\n\n", start_date);
422 text.append(line);
423 }
424
425 S32 transactions = msg->getNumberOfBlocksFast(_PREHASH_HistoryData);
426 if (transactions == 0)
427 {
428 text.append("(none)");
429 }
430 else
431 {
432 for(S32 i = 0; i < transactions; i++)
433 {
434 const S32 SHORT_STRING = 64;
435 char time[SHORT_STRING];
436 S32 type = 0;
437 S32 amount = 0;
438 char user[SHORT_STRING];
439 char item[SHORT_STRING];
440
441 msg->getStringFast(_PREHASH_HistoryData, _PREHASH_Time, SHORT_STRING, time, i);
442 msg->getStringFast(_PREHASH_HistoryData, _PREHASH_User, SHORT_STRING, user, i );
443 msg->getS32Fast(_PREHASH_HistoryData, _PREHASH_Type, type, i);
444 msg->getStringFast(_PREHASH_HistoryData, _PREHASH_Item, SHORT_STRING, item, i );
445 msg->getS32Fast(_PREHASH_HistoryData, _PREHASH_Amount, amount, i);
446
447 if (amount != 0)
448 {
449 char* verb;
450
451 switch(type)
452 {
453 case TRANS_OBJECT_SALE:
454 verb = "bought";
455 break;
456 case TRANS_GIFT:
457 verb = "paid you";
458 break;
459 case TRANS_PAY_OBJECT:
460 verb = "paid into";
461 break;
462 case TRANS_LAND_PASS_SALE:
463 verb = "bought pass to";
464 break;
465 case TRANS_EVENT_FEE:
466 verb = "paid fee for event";
467 break;
468 case TRANS_EVENT_PRIZE:
469 verb = "paid prize for event";
470 break;
471 default:
472 verb = "";
473 break;
474 }
475
476 sprintf(line, "%s %6d - %s %s %s\n", time, amount, user, verb, item);
477 text.append(line);
478 }
479 }
480 }
481
482 childSetText("editor", text);
483}