00001
00032 #include "llviewerprecompiledheaders.h"
00033 #include "lleventinfo.h"
00034
00035 #include "viewer.h"
00036 #include "lluuid.h"
00037 #include "message.h"
00038
00039 LLEventInfo::cat_map LLEventInfo::sCategories;
00040
00041 LLEventInfo::LLEventInfo(F32 global_x, F32 global_y,
00042 const char* name,
00043 U32 id,
00044 S32 unix_time,
00045 U32 event_flags)
00046 : mName( name ),
00047 mID( id ),
00048 mPosGlobal( global_x, global_y, 40.0 ),
00049 mUnixTime( unix_time ),
00050 mEventFlags(event_flags),
00051 mSelected( FALSE )
00052 {
00053 struct tm* timep;
00054
00055
00056 timep = utc_to_pacific_time(unix_time, gPacificDaylightTime);
00057
00058 S32 display_hour = timep->tm_hour % 12;
00059 if (display_hour == 0) display_hour = 12;
00060
00061 mTimeStr = llformat("% 2d/% 2d % 2d:%02d %s",
00062 timep->tm_mon+1,
00063 timep->tm_year-100,
00064 display_hour,
00065 timep->tm_min,
00066 (timep->tm_hour < 12 ? "AM" : "PM") );
00067 }
00068
00069
00070 void LLEventInfo::unpack(LLMessageSystem *msg)
00071 {
00072 const U32 MAX_DESC_LENGTH = 1024;
00073
00074 U32 event_id;
00075 msg->getU32("EventData", "EventID", event_id);
00076 mID = event_id;
00077
00078 char buffer[MAX_DESC_LENGTH];
00079 msg->getString("EventData", "Name", MAX_DESC_LENGTH, buffer);
00080 mName = buffer;
00081
00082 msg->getString("EventData", "Category", MAX_DESC_LENGTH, buffer);
00083 mCategoryStr = buffer;
00084
00085 msg->getString("EventData", "Date", MAX_DESC_LENGTH, buffer);
00086
00087
00088 mTimeStr = buffer;
00089
00090 U32 duration;
00091 msg->getU32("EventData","Duration",duration);
00092 mDuration = duration;
00093
00094 msg->getU32("EventData", "DateUTC", mUnixTime);
00095
00096 msg->getString("EventData", "Desc", MAX_DESC_LENGTH, buffer);
00097 mDesc = buffer;
00098
00099 msg->getString("EventData", "Creator", MAX_DESC_LENGTH, buffer);
00100 mRunByID = LLUUID(buffer);
00101
00102 U32 foo;
00103 msg->getU32("EventData", "Cover", foo);
00104
00105 mHasCover = foo ? TRUE : FALSE;
00106 if (mHasCover)
00107 {
00108 U32 cover;
00109 msg->getU32("EventData", "Amount", cover);
00110 mCover = cover;
00111 }
00112
00113 char sim_name[256];
00114 msg->getString("EventData", "SimName", 256, sim_name);
00115 mSimName.assign(sim_name);
00116
00117 msg->getVector3d("EventData", "GlobalPos", mPosGlobal);
00118
00119
00120 U32 event_flags;
00121 msg->getU32("EventData", "EventFlags", event_flags);
00122 mEventFlags = event_flags;
00123 }
00124
00125
00126 void LLEventInfo::loadCategories(LLUserAuth::options_t event_options)
00127 {
00128 LLUserAuth::options_t::iterator resp_it;
00129 for (resp_it = event_options.begin();
00130 resp_it != event_options.end();
00131 ++resp_it)
00132 {
00133 const LLUserAuth::response_t& response = *resp_it;
00134
00135 LLUserAuth::response_t::const_iterator option_it;
00136
00137 S32 cat_id = 0;
00138 option_it = response.find("category_id");
00139 if (option_it != response.end())
00140 {
00141 cat_id = atoi(option_it->second.c_str());
00142 }
00143 else
00144 {
00145 continue;
00146 }
00147
00148
00149 option_it = response.find("category_name");
00150 if (option_it != response.end())
00151 {
00152 LLEventInfo::sCategories[cat_id] = option_it->second;
00153 }
00154
00155 }
00156
00157 }