aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llgroupnotify.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2009-04-30 13:04:20 -0500
committerJacek Antonelli2009-04-30 13:07:16 -0500
commitca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e (patch)
tree8348301d0ac44a524f1819b777686bf086907d76 /linden/indra/newview/llgroupnotify.cpp
parentSecond Life viewer sources 1.22.11 (diff)
downloadmeta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.zip
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.gz
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.bz2
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.xz
Second Life viewer sources 1.23.0-RC
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llgroupnotify.cpp160
1 files changed, 82 insertions, 78 deletions
diff --git a/linden/indra/newview/llgroupnotify.cpp b/linden/indra/newview/llgroupnotify.cpp
index dd851f5..5358699 100644
--- a/linden/indra/newview/llgroupnotify.cpp
+++ b/linden/indra/newview/llgroupnotify.cpp
@@ -17,7 +17,8 @@
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://secondlifegrid.net/programs/open_source/licensing/flossexception 20 * online at
21 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 * 22 *
22 * By copying, modifying or distributing this software, you acknowledge 23 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above, 24 * that you have read and understood your obligations described above,
@@ -57,46 +58,10 @@ const F32 ANIMATION_TIME = 0.333f;
57 58
58S32 LLGroupNotifyBox::sGroupNotifyBoxCount = 0; 59S32 LLGroupNotifyBox::sGroupNotifyBoxCount = 0;
59 60
61
60//--------------------------------------------------------------------------- 62//---------------------------------------------------------------------------
61// LLGroupNotifyBox 63// LLGroupNotifyBox
62//--------------------------------------------------------------------------- 64//---------------------------------------------------------------------------
63
64static std::string g_formatted_time(const time_t& the_time)
65{
66 char buffer[30]; /*Flawfinder: ignore*/
67 time_t t = the_time;
68 if (!t) time(&t);
69 LLStringUtil::copy(buffer, ctime(&t), 30);
70 buffer[24] = '\0';
71 return std::string(buffer);
72}
73
74// static
75LLGroupNotifyBox* LLGroupNotifyBox::show(const std::string& subject,
76 const std::string& message,
77 const std::string& from_name,
78 const LLUUID& group_id,
79 const U32& t,
80 const bool& has_inventory,
81 const std::string& inventory_name,
82 LLOfferInfo* inventory_offer)
83{
84 // Get the group data
85 LLGroupData group_data;
86 if (!gAgent.getGroupData(group_id,group_data))
87 {
88 llwarns << "Group notice for unknown group: " << group_id << llendl;
89 return NULL;
90 }
91
92 LLGroupNotifyBox* self;
93 self = new LLGroupNotifyBox(subject, message, from_name, group_id, group_data.mInsigniaID, group_data.mName,t,has_inventory,inventory_name,inventory_offer);
94 gNotifyBoxView->addChild(self);
95
96 // TODO: play a sound
97 return self;
98}
99
100bool is_openable(LLAssetType::EType type) 65bool is_openable(LLAssetType::EType type)
101{ 66{
102 switch(type) 67 switch(type)
@@ -114,48 +79,47 @@ bool is_openable(LLAssetType::EType type)
114} 79}
115 80
116LLGroupNotifyBox::LLGroupNotifyBox(const std::string& subject, 81LLGroupNotifyBox::LLGroupNotifyBox(const std::string& subject,
117 const std::string& message, 82 const std::string& message,
118 const std::string& from_name, 83 const std::string& from_name,
119 const LLUUID& group_id, 84 const LLUUID& group_id,
120 const LLUUID& group_insignia, 85 const LLUUID& group_insignia,
121 const std::string& group_name, 86 const std::string& group_name,
122 const U32& t, 87 const LLDate& time_stamp,
123 const bool& has_inventory, 88 const bool& has_inventory,
124 const std::string& inventory_name, 89 const std::string& inventory_name,
125 LLOfferInfo* inventory_offer) 90 const LLSD& inventory_offer)
126: LLPanel(std::string("groupnotify"), LLGroupNotifyBox::getGroupNotifyRect(), BORDER_YES), 91: LLPanel("groupnotify", LLGroupNotifyBox::getGroupNotifyRect(), BORDER_YES),
127 mAnimating(TRUE), 92 mAnimating(TRUE),
128 mTimer(), 93 mTimer(),
129 mGroupID(group_id), 94 mGroupID(group_id),
130 mHasInventory(has_inventory), 95 mHasInventory(has_inventory),
131 mInventoryOffer(inventory_offer) 96 mInventoryOffer(NULL)
132{ 97{
133 setFocusRoot(TRUE); 98 const S32 VPAD = 2;
99 const S32 TOP = getRect().getHeight() - 32; // Get past the top menu bar
100 const S32 BOTTOM_PAD = VPAD * 2;
101 const S32 BTN_TOP = BOTTOM_PAD + BTN_HEIGHT + VPAD;
102 const S32 RIGHT = getRect().getWidth() - HPAD - HPAD;
103 const S32 LINE_HEIGHT = 16;
104
105 const S32 LABEL_WIDTH = 64;
106 const S32 ICON_WIDTH = 64;
134 107
135 time_t timestamp = (time_t)t;
136 108
137 std::string time_buf = g_formatted_time(timestamp); 109 if (mHasInventory)
110 {
111 mInventoryOffer = new LLOfferInfo(inventory_offer);
112 }
138 113
114 setFocusRoot(TRUE);
139 setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT); 115 setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT);
140 setBackgroundVisible(TRUE); 116 setBackgroundVisible(TRUE);
141 setBackgroundOpaque(TRUE); 117 setBackgroundOpaque(TRUE);
142
143 // TODO: add a color for group notices
144 setBackgroundColor( gColors.getColor("GroupNotifyBoxColor") ); 118 setBackgroundColor( gColors.getColor("GroupNotifyBoxColor") );
145 119
146 LLIconCtrl* icon; 120 LLIconCtrl* icon;
147 LLTextEditor* text; 121 LLTextEditor* text;
148 122
149 const S32 VPAD = 2;
150 const S32 TOP = getRect().getHeight() - 32; // Get past the top menu bar
151 const S32 BOTTOM_PAD = VPAD * 2;
152 const S32 BTN_TOP = BOTTOM_PAD + BTN_HEIGHT + VPAD;
153 const S32 RIGHT = getRect().getWidth() - HPAD - HPAD;
154 const S32 LINE_HEIGHT = 16;
155
156 const S32 LABEL_WIDTH = 64;
157 const S32 ICON_WIDTH = 64;
158
159 S32 y = TOP; 123 S32 y = TOP;
160 S32 x = HPAD + HPAD; 124 S32 x = HPAD + HPAD;
161 125
@@ -173,9 +137,8 @@ LLGroupNotifyBox::LLGroupNotifyBox(const std::string& subject,
173 } 137 }
174 }; 138 };
175 139
176
177 // Title 140 // Title
178 addChild(new NoticeText(std::string("title"),LLRect(x,y,RIGHT - HPAD,y - LINE_HEIGHT),std::string("Group Notice"),LLFontGL::sSansSerifHuge)); 141 addChild(new NoticeText(std::string("title"),LLRect(x,y,RIGHT - HPAD,y - LINE_HEIGHT),std::string("Group Notice"),LLFontGL::getFontSansSerifHuge()));
179 142
180 y -= llfloor(1.5f*LINE_HEIGHT); 143 y -= llfloor(1.5f*LINE_HEIGHT);
181 144
@@ -184,7 +147,7 @@ LLGroupNotifyBox::LLGroupNotifyBox(const std::string& subject,
184 std::stringstream from; 147 std::stringstream from;
185 from << "Sent by " << from_name << ", " << group_name; 148 from << "Sent by " << from_name << ", " << group_name;
186 149
187 addChild(new NoticeText(std::string("group"),LLRect(x,y,RIGHT - HPAD,y - LINE_HEIGHT),from.str(),LLFontGL::sSansSerif)); 150 addChild(new NoticeText(std::string("group"),LLRect(x,y,RIGHT - HPAD,y - LINE_HEIGHT),from.str(),LLFontGL::getFontSansSerif()));
188 151
189 y -= (LINE_HEIGHT + VPAD); 152 y -= (LINE_HEIGHT + VPAD);
190 x = HPAD + HPAD; 153 x = HPAD + HPAD;
@@ -214,18 +177,18 @@ LLGroupNotifyBox::LLGroupNotifyBox(const std::string& subject,
214 LLRect(x, y, RIGHT, box_bottom), 177 LLRect(x, y, RIGHT, box_bottom),
215 DB_GROUP_NOTICE_MSG_STR_LEN, 178 DB_GROUP_NOTICE_MSG_STR_LEN,
216 LLStringUtil::null, 179 LLStringUtil::null,
217 LLFontGL::sSansSerif, 180 LLFontGL::getFontSansSerif(),
218 FALSE); 181 FALSE);
219 182
220 static const LLStyleSP headerstyle(new LLStyle(true,LLColor4::black,"SansSerifBig")); 183 static const LLStyleSP headerstyle(new LLStyle(true,LLColor4::black,"SansSerifBig"));
221 static const LLStyleSP datestyle(new LLStyle(true,LLColor4::black,"serif")); 184 static const LLStyleSP datestyle(new LLStyle(true,LLColor4::black,"serif"));
222 185
223 text->appendStyledText(subject,false,false,&headerstyle); 186 text->appendStyledText(subject + "\n",false,false,headerstyle);
224 text->appendStyledText(time_buf,false,false,&datestyle); 187 text->appendStyledText(time_stamp.asRFC1123(),false,false,datestyle);
225 // Sadly, our LLTextEditor can't handle both styled and unstyled text 188 // Sadly, our LLTextEditor can't handle both styled and unstyled text
226 // at the same time. Hence this space must be styled. JC 189 // at the same time. Hence this space must be styled. JC
227 text->appendColoredText(std::string(" "),false,false,LLColor4::grey4); 190 text->appendColoredText(std::string(" "),false,false,LLColor4::grey4);
228 text->appendColoredText(message,false,false,LLColor4::grey4); 191 text->appendColoredText(std::string("\n\n") + message,false,false,LLColor4::grey4);
229 192
230 LLColor4 semi_transparent(1.0f,1.0f,1.0f,0.8f); 193 LLColor4 semi_transparent(1.0f,1.0f,1.0f,0.8f);
231 text->setCursor(0,0); 194 text->setCursor(0,0);
@@ -246,7 +209,7 @@ LLGroupNotifyBox::LLGroupNotifyBox(const std::string& subject,
246 209
247 if (mHasInventory) 210 if (mHasInventory)
248 { 211 {
249 addChild(new NoticeText(std::string("subjecttitle"),LLRect(x,y,x + LABEL_WIDTH,y - LINE_HEIGHT),std::string("Attached: "),LLFontGL::sSansSerif)); 212 addChild(new NoticeText(std::string("subjecttitle"),LLRect(x,y,x + LABEL_WIDTH,y - LINE_HEIGHT),std::string("Attached: "),LLFontGL::getFontSansSerif()));
250 213
251 LLUIImagePtr item_icon = get_item_icon(mInventoryOffer->mType, 214 LLUIImagePtr item_icon = get_item_icon(mInventoryOffer->mType,
252 LLInventoryType::IT_TEXTURE, 215 LLInventoryType::IT_TEXTURE,
@@ -257,7 +220,7 @@ LLGroupNotifyBox::LLGroupNotifyBox(const std::string& subject,
257 220
258 std::stringstream ss; 221 std::stringstream ss;
259 ss << " " << inventory_name; 222 ss << " " << inventory_name;
260 LLTextBox *line = new LLTextBox(std::string("object_name"),LLRect(x,y,RIGHT - HPAD,y - LINE_HEIGHT),ss.str(),LLFontGL::sSansSerif); 223 LLTextBox *line = new LLTextBox(std::string("object_name"),LLRect(x,y,RIGHT - HPAD,y - LINE_HEIGHT),ss.str(),LLFontGL::getFontSansSerif());
261 line->setEnabled(FALSE); 224 line->setEnabled(FALSE);
262 line->setBorderVisible(TRUE); 225 line->setBorderVisible(TRUE);
263 line->setDisabledColor(LLColor4::blue4); 226 line->setDisabledColor(LLColor4::blue4);
@@ -281,7 +244,7 @@ LLGroupNotifyBox::LLGroupNotifyBox(const std::string& subject,
281 LLStringUtil::null, 244 LLStringUtil::null,
282 onClickNext, 245 onClickNext,
283 this, 246 this,
284 LLFontGL::sSansSerif); 247 LLFontGL::getFontSansSerif());
285 btn->setToolTip(std::string("Next")); // *TODO: Translate 248 btn->setToolTip(std::string("Next")); // *TODO: Translate
286 btn->setScaleImage(TRUE); 249 btn->setScaleImage(TRUE);
287 addChild(btn); 250 addChild(btn);
@@ -313,7 +276,7 @@ LLGroupNotifyBox::LLGroupNotifyBox(const std::string& subject,
313 btn->setToolTip(std::string("View past notices or opt-out of receiving these messages here.")); // TODO: Translate 276 btn->setToolTip(std::string("View past notices or opt-out of receiving these messages here.")); // TODO: Translate
314 addChild(btn, -1); 277 addChild(btn, -1);
315 278
316 if (mHasInventory && mInventoryOffer) 279 if (mHasInventory)
317 { 280 {
318 x += wide_btn_width + HPAD; 281 x += wide_btn_width + HPAD;
319 282
@@ -395,13 +358,53 @@ void LLGroupNotifyBox::close()
395 // Then we need to send the inventory declined message 358 // Then we need to send the inventory declined message
396 if(mHasInventory) 359 if(mHasInventory)
397 { 360 {
398 inventory_offer_callback(IOR_DECLINE , mInventoryOffer); 361 mInventoryOffer->forceResponse(IOR_DECLINE);
362 mInventoryOffer = NULL;
363 mHasInventory = FALSE;
399 } 364 }
400 gNotifyBoxView->removeChild(this); 365 gNotifyBoxView->removeChild(this);
401 366
402 die(); 367 die();
403} 368}
404 369
370//static
371void LLGroupNotifyBox::initClass()
372{
373 LLNotificationChannel::buildChannel("Group Notifications", "Visible", LLNotificationFilters::filterBy<std::string>(&LLNotification::getType, "groupnotify"));
374 LLNotifications::instance().getChannel("Group Notifications")->connectChanged(&LLGroupNotifyBox::onNewNotification);
375}
376
377//static
378bool LLGroupNotifyBox::onNewNotification(const LLSD& notify)
379{
380 LLNotificationPtr notification = LLNotifications::instance().find(notify["id"].asUUID());
381
382 if (notification)
383 {
384 const LLSD& payload = notification->getPayload();
385 // Get the group data
386 LLGroupData group_data;
387 if (!gAgent.getGroupData(payload["group_id"].asUUID(),group_data))
388 {
389 llwarns << "Group notice for unkown group: " << payload["group_id"].asUUID() << llendl;
390 return false;
391 }
392
393 LLGroupNotifyBox* self;
394 self = new LLGroupNotifyBox(payload["subject"].asString(),
395 payload["message"].asString(),
396 payload["sender_name"].asString(),
397 payload["group_id"].asUUID(),
398 group_data.mInsigniaID,
399 group_data.mName,
400 notification->getDate(),
401 payload["inventory_offer"].isDefined(),
402 payload["inventory_name"].asString(),
403 payload["inventory_offer"]);
404 gNotifyBoxView->addChild(self);
405 }
406 return false;
407}
405 408
406void LLGroupNotifyBox::moveToBack() 409void LLGroupNotifyBox::moveToBack()
407{ 410{
@@ -465,10 +468,11 @@ void LLGroupNotifyBox::onClickSaveInventory(void* data)
465{ 468{
466 LLGroupNotifyBox* self = (LLGroupNotifyBox*)data; 469 LLGroupNotifyBox* self = (LLGroupNotifyBox*)data;
467 470
468 inventory_offer_callback( IOR_ACCEPT , self->mInventoryOffer); 471 self->mInventoryOffer->forceResponse(IOR_ACCEPT);
469 472
470 // inventory_offer_callback will delete the offer, so make sure we aren't still pointing to it.
471 self->mInventoryOffer = NULL; 473 self->mInventoryOffer = NULL;
474 self->mHasInventory = FALSE;
475
472 // Each item can only be received once, so disable the button. 476 // Each item can only be received once, so disable the button.
473 self->mSaveInventoryBtn->setEnabled(FALSE); 477 self->mSaveInventoryBtn->setEnabled(FALSE);
474} 478}