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/llpaneldirevents.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/llpaneldirevents.cpp')
-rw-r--r-- | linden/indra/newview/llpaneldirevents.cpp | 302 |
1 files changed, 302 insertions, 0 deletions
diff --git a/linden/indra/newview/llpaneldirevents.cpp b/linden/indra/newview/llpaneldirevents.cpp new file mode 100644 index 0000000..703ee5e --- /dev/null +++ b/linden/indra/newview/llpaneldirevents.cpp | |||
@@ -0,0 +1,302 @@ | |||
1 | /** | ||
2 | * @file llpaneldirevents.cpp | ||
3 | * @brief Events listing in the Find directory. | ||
4 | * | ||
5 | * Copyright (c) 2001-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 "llpaneldirevents.h" | ||
31 | |||
32 | #include <sstream> | ||
33 | |||
34 | // linden library includes | ||
35 | #include "llenum.h" | ||
36 | #include "message.h" | ||
37 | #include "llqueryflags.h" | ||
38 | |||
39 | // viewer project includes | ||
40 | #include "llagent.h" | ||
41 | #include "llviewercontrol.h" | ||
42 | #include "lleventinfo.h" | ||
43 | #include "llpaneldirbrowser.h" | ||
44 | #include "llresmgr.h" | ||
45 | #include "lluiconstants.h" | ||
46 | #include "llpanelevent.h" | ||
47 | #include "viewer.h" | ||
48 | |||
49 | BOOL gDisplayEventHack = FALSE; | ||
50 | |||
51 | LLPanelDirEvents::LLPanelDirEvents(const std::string& name, LLFloaterDirectory* floater) | ||
52 | : LLPanelDirBrowser(name, floater), | ||
53 | mDay(0), | ||
54 | mDoneQuery(FALSE) | ||
55 | { | ||
56 | // more results per page for this | ||
57 | mResultsPerPage = 200; | ||
58 | } | ||
59 | |||
60 | BOOL LLPanelDirEvents::postBuild() | ||
61 | { | ||
62 | LLPanelDirBrowser::postBuild(); | ||
63 | |||
64 | // *HACK: Deal with PST vs. PDT | ||
65 | LLString buffer = llformat("Time (%s)", (gPacificDaylightTime ? "PDT" : "PST")); | ||
66 | childSetValue("desc_btn", buffer); | ||
67 | |||
68 | childSetCommitCallback("date_mode", onDateModeCallback, this); | ||
69 | |||
70 | childSetAction("<<", onBackBtn, this); | ||
71 | childSetAction(">>", onForwardBtn, this); | ||
72 | |||
73 | childSetAction("Today", onClickToday, this); | ||
74 | |||
75 | childSetCommitCallback("mature", onCommitMature, this); | ||
76 | |||
77 | childSetAction("Search", LLPanelDirBrowser::onClickSearchCore, this); | ||
78 | setDefaultBtn("Search"); | ||
79 | |||
80 | childSetAction("Delete", onClickDelete, this); | ||
81 | childDisable("Delete"); | ||
82 | childHide("Delete"); | ||
83 | |||
84 | onDateModeCallback(NULL, this); | ||
85 | |||
86 | mCurrentSortColumn = "time"; | ||
87 | |||
88 | if (!gDisplayEventHack) | ||
89 | { | ||
90 | setDay(0); // for today | ||
91 | //performQuery(); // Temporary change to help DB - Sabin | ||
92 | } | ||
93 | gDisplayEventHack = FALSE; | ||
94 | |||
95 | return TRUE; | ||
96 | } | ||
97 | |||
98 | LLPanelDirEvents::~LLPanelDirEvents() | ||
99 | { | ||
100 | // Children all cleaned up by default view destructor. | ||
101 | } | ||
102 | |||
103 | |||
104 | void LLPanelDirEvents::draw() | ||
105 | { | ||
106 | refresh(); | ||
107 | |||
108 | LLPanelDirBrowser::draw(); | ||
109 | } | ||
110 | |||
111 | void LLPanelDirEvents::refresh() | ||
112 | { | ||
113 | // You only have a choice if you are mature | ||
114 | childSetVisible("incmature", gAgent.mAccess >= SIM_ACCESS_MATURE); | ||
115 | |||
116 | BOOL godlike = gAgent.isGodlike(); | ||
117 | childSetVisible("Delete", godlike); | ||
118 | childSetEnabled("Delete", godlike); | ||
119 | } | ||
120 | |||
121 | |||
122 | void LLPanelDirEvents::setDay(S32 day) | ||
123 | { | ||
124 | mDay = day; | ||
125 | |||
126 | // Get time UTC | ||
127 | time_t utc_time = time_corrected(); | ||
128 | |||
129 | // Correct for offset | ||
130 | utc_time += day * 24 * 60 * 60; | ||
131 | |||
132 | // There's only one internal tm buffer. | ||
133 | struct tm* internal_time; | ||
134 | |||
135 | // Convert to Pacific, based on server's opinion of whether | ||
136 | // it's daylight savings time there. | ||
137 | internal_time = utc_to_pacific_time(utc_time, gPacificDaylightTime); | ||
138 | |||
139 | LLString buffer = llformat("%d/%d", | ||
140 | 1 + internal_time->tm_mon, // Jan = 0 | ||
141 | internal_time->tm_mday); // 2001 = 101 | ||
142 | childSetValue("date_text", buffer); | ||
143 | } | ||
144 | |||
145 | // virtual | ||
146 | void LLPanelDirEvents::performQuery() | ||
147 | { | ||
148 | // event_id 0 will perform no delete action. | ||
149 | performQueryOrDelete(0); | ||
150 | } | ||
151 | |||
152 | void LLPanelDirEvents::performQueryOrDelete(U32 event_id) | ||
153 | { | ||
154 | S32 relative_day = mDay; | ||
155 | // Update the date field to show the date IN THE SERVER'S | ||
156 | // TIME ZONE, as that is what will be displayed in each event | ||
157 | |||
158 | // Get time UTC | ||
159 | time_t utc_time = time_corrected(); | ||
160 | |||
161 | // Correct for offset | ||
162 | utc_time += relative_day * 24 * 60 * 60; | ||
163 | |||
164 | // There's only one internal tm buffer. | ||
165 | struct tm* internal_time; | ||
166 | |||
167 | // Convert to Pacific, based on server's opinion of whether | ||
168 | // it's daylight savings time there. | ||
169 | internal_time = utc_to_pacific_time(utc_time, gPacificDaylightTime); | ||
170 | |||
171 | LLString buffer = llformat("%d/%d", | ||
172 | 1 + internal_time->tm_mon, // Jan = 0 | ||
173 | internal_time->tm_mday); // 2001 = 101 | ||
174 | childSetValue("date_text", buffer); | ||
175 | |||
176 | // Record the relative day so back and forward buttons | ||
177 | // offset from this day. | ||
178 | mDay = relative_day; | ||
179 | |||
180 | mDoneQuery = TRUE; | ||
181 | |||
182 | setupNewSearch(); | ||
183 | |||
184 | U32 scope = DFQ_DATE_EVENTS; | ||
185 | if ( gAgent.mAccess <= SIM_ACCESS_PG) scope |= DFQ_PG_SIMS_ONLY; | ||
186 | if ( !childGetValue("incmature").asBoolean() ) scope |= DFQ_PG_EVENTS_ONLY; | ||
187 | |||
188 | std::ostringstream params; | ||
189 | |||
190 | // Date mode for the search | ||
191 | if ("current" == childGetValue("date_mode").asString()) | ||
192 | { | ||
193 | params << "u|"; | ||
194 | } | ||
195 | else | ||
196 | { | ||
197 | params << mDay << "|"; | ||
198 | } | ||
199 | |||
200 | // Categories are stored in the database in table indra.event_category | ||
201 | // XML must match. | ||
202 | U32 cat_id = childGetValue("category combo").asInteger(); | ||
203 | |||
204 | params << cat_id << "|"; | ||
205 | params << childGetValue("event_search_text").asString(); | ||
206 | |||
207 | // send the message | ||
208 | if (0 == event_id) | ||
209 | { | ||
210 | sendDirFindQuery(gMessageSystem, mSearchID, params.str().c_str(), scope, mSearchStart); | ||
211 | } | ||
212 | else | ||
213 | { | ||
214 | // This delete will also perform a query. | ||
215 | LLMessageSystem* msg = gMessageSystem; | ||
216 | |||
217 | msg->newMessageFast(_PREHASH_EventGodDelete); | ||
218 | |||
219 | msg->nextBlockFast(_PREHASH_AgentData); | ||
220 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); | ||
221 | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); | ||
222 | |||
223 | msg->nextBlockFast(_PREHASH_EventData); | ||
224 | msg->addU32Fast(_PREHASH_EventID, event_id); | ||
225 | |||
226 | msg->nextBlockFast(_PREHASH_QueryData); | ||
227 | msg->addUUIDFast(_PREHASH_QueryID, mSearchID); | ||
228 | msg->addStringFast(_PREHASH_QueryText, params.str()); | ||
229 | msg->addU32Fast(_PREHASH_QueryFlags, scope); | ||
230 | msg->addS32Fast(_PREHASH_QueryStart, mSearchStart); | ||
231 | gAgent.sendReliableMessage(); | ||
232 | } | ||
233 | } | ||
234 | |||
235 | // static | ||
236 | void LLPanelDirEvents::onDateModeCallback(LLUICtrl* ctrl, void *data) | ||
237 | { | ||
238 | LLPanelDirEvents* self = (LLPanelDirEvents*)data; | ||
239 | if (self->childGetValue("date_mode").asString() == "date") | ||
240 | { | ||
241 | self->childEnable("Today"); | ||
242 | self->childEnable(">>"); | ||
243 | self->childEnable("<<"); | ||
244 | } | ||
245 | else | ||
246 | { | ||
247 | self->childDisable("Today"); | ||
248 | self->childDisable(">>"); | ||
249 | self->childDisable("<<"); | ||
250 | } | ||
251 | } | ||
252 | |||
253 | // static | ||
254 | void LLPanelDirEvents::onClickToday(void *userdata) | ||
255 | { | ||
256 | LLPanelDirEvents *self = (LLPanelDirEvents *)userdata; | ||
257 | self->resetSearchStart(); | ||
258 | self->setDay(0); | ||
259 | self->performQuery(); | ||
260 | } | ||
261 | |||
262 | |||
263 | // static | ||
264 | void LLPanelDirEvents::onBackBtn(void* data) | ||
265 | { | ||
266 | LLPanelDirEvents* self = (LLPanelDirEvents*)data; | ||
267 | self->resetSearchStart(); | ||
268 | self->setDay(self->mDay - 1); | ||
269 | self->performQuery(); | ||
270 | } | ||
271 | |||
272 | |||
273 | // static | ||
274 | void LLPanelDirEvents::onForwardBtn(void* data) | ||
275 | { | ||
276 | LLPanelDirEvents* self = (LLPanelDirEvents*)data; | ||
277 | self->resetSearchStart(); | ||
278 | self->setDay(self->mDay + 1); | ||
279 | self->performQuery(); | ||
280 | } | ||
281 | |||
282 | |||
283 | // static | ||
284 | void LLPanelDirEvents::onCommitMature(LLUICtrl* ctrl, void* data) | ||
285 | { | ||
286 | // just perform another search | ||
287 | onClickSearchCore(data); | ||
288 | } | ||
289 | |||
290 | |||
291 | // static | ||
292 | void LLPanelDirEvents::onClickDelete(void *userdata) | ||
293 | { | ||
294 | LLPanelDirEvents *self = (LLPanelDirEvents *)userdata; | ||
295 | if (!self) return; | ||
296 | |||
297 | U32 event_id; | ||
298 | event_id = self->getSelectedEventID(); | ||
299 | if (!event_id) return; | ||
300 | |||
301 | self->performQueryOrDelete(event_id); | ||
302 | } | ||