Annotation of /trunk/indra/newview/llpanelgroupnotices.cpp
Parent Directory
|
Revision Log
Revision 137 - (view) (download)
| 1 : | mjm | 135 | /** |
| 2 : | * @file llpanelgroupnotices.cpp | ||
| 3 : | * @brief A panel to display group notices. | ||
| 4 : | * | ||
| 5 : | * $LicenseInfo:firstyear=2006&license=viewergpl$ | ||
| 6 : | * | ||
| 7 : | mjm | 137 | * Copyright (c) 2006-2010, Linden Research, Inc. |
| 8 : | mjm | 135 | * |
| 9 : | * Second Life Viewer Source Code | ||
| 10 : | * The source code in this file ("Source Code") is provided by Linden Lab | ||
| 11 : | * to you under the terms of the GNU General Public License, version 2.0 | ||
| 12 : | * ("GPL"), unless you have obtained a separate licensing agreement | ||
| 13 : | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
| 14 : | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
| 15 : | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
| 16 : | * | ||
| 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 | ||
| 19 : | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
| 20 : | * online at | ||
| 21 : | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
| 22 : | * | ||
| 23 : | * By copying, modifying or distributing this software, you acknowledge | ||
| 24 : | * that you have read and understood your obligations described above, | ||
| 25 : | * and agree to abide by those obligations. | ||
| 26 : | * | ||
| 27 : | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
| 28 : | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
| 29 : | * COMPLETENESS OR PERFORMANCE. | ||
| 30 : | * $/LicenseInfo$ | ||
| 31 : | */ | ||
| 32 : | |||
| 33 : | #include "llviewerprecompiledheaders.h" | ||
| 34 : | |||
| 35 : | #include "llpanelgroupnotices.h" | ||
| 36 : | |||
| 37 : | #include "llview.h" | ||
| 38 : | |||
| 39 : | #include "llinventory.h" | ||
| 40 : | #include "llviewerinventory.h" | ||
| 41 : | #include "llinventorymodel.h" | ||
| 42 : | #include "llinventoryview.h" | ||
| 43 : | #include "llagent.h" | ||
| 44 : | #include "lltooldraganddrop.h" | ||
| 45 : | |||
| 46 : | #include "lllineeditor.h" | ||
| 47 : | #include "lltexteditor.h" | ||
| 48 : | #include "llbutton.h" | ||
| 49 : | #include "lliconctrl.h" | ||
| 50 : | #include "llcheckboxctrl.h" | ||
| 51 : | #include "llscrolllistctrl.h" | ||
| 52 : | #include "lltextbox.h" | ||
| 53 : | |||
| 54 : | #include "roles_constants.h" | ||
| 55 : | #include "llviewerwindow.h" | ||
| 56 : | #include "llviewercontrol.h" | ||
| 57 : | #include "llviewermessage.h" | ||
| 58 : | #include "llnotifications.h" | ||
| 59 : | |||
| 60 : | const S32 NOTICE_DATE_STRING_SIZE = 30; | ||
| 61 : | |||
| 62 : | ///////////////////////// | ||
| 63 : | // LLPanelGroupNotices // | ||
| 64 : | ///////////////////////// | ||
| 65 : | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 66 : | // Class LLDropTarget | ||
| 67 : | // | ||
| 68 : | // This handy class is a simple way to drop something on another | ||
| 69 : | // view. It handles drop events, always setting itself to the size of | ||
| 70 : | // its parent. | ||
| 71 : | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 72 : | class LLGroupDropTarget : public LLView | ||
| 73 : | { | ||
| 74 : | public: | ||
| 75 : | LLGroupDropTarget(const std::string& name, const LLRect& rect, LLPanelGroupNotices* panel, const LLUUID& group_id); | ||
| 76 : | ~LLGroupDropTarget() {}; | ||
| 77 : | |||
| 78 : | void doDrop(EDragAndDropType cargo_type, void* cargo_data); | ||
| 79 : | |||
| 80 : | // | ||
| 81 : | // LLView functionality | ||
| 82 : | virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, | ||
| 83 : | EDragAndDropType cargo_type, | ||
| 84 : | void* cargo_data, | ||
| 85 : | EAcceptance* accept, | ||
| 86 : | std::string& tooltip_msg); | ||
| 87 : | protected: | ||
| 88 : | LLPanelGroupNotices* mGroupNoticesPanel; | ||
| 89 : | LLUUID mGroupID; | ||
| 90 : | }; | ||
| 91 : | |||
| 92 : | LLGroupDropTarget::LLGroupDropTarget(const std::string& name, const LLRect& rect, | ||
| 93 : | LLPanelGroupNotices* panel, const LLUUID& group_id) : | ||
| 94 : | LLView(name, rect, NOT_MOUSE_OPAQUE, FOLLOWS_ALL), | ||
| 95 : | mGroupNoticesPanel(panel), | ||
| 96 : | mGroupID(group_id) | ||
| 97 : | { | ||
| 98 : | } | ||
| 99 : | |||
| 100 : | void LLGroupDropTarget::doDrop(EDragAndDropType cargo_type, void* cargo_data) | ||
| 101 : | { | ||
| 102 : | llinfos << "LLGroupDropTarget::doDrop()" << llendl; | ||
| 103 : | } | ||
| 104 : | |||
| 105 : | BOOL LLGroupDropTarget::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, | ||
| 106 : | EDragAndDropType cargo_type, | ||
| 107 : | void* cargo_data, | ||
| 108 : | EAcceptance* accept, | ||
| 109 : | std::string& tooltip_msg) | ||
| 110 : | { | ||
| 111 : | BOOL handled = FALSE; | ||
| 112 : | |||
| 113 : | if (!gAgent.hasPowerInGroup(mGroupID,GP_NOTICES_SEND)) | ||
| 114 : | { | ||
| 115 : | *accept = ACCEPT_NO; | ||
| 116 : | return TRUE; | ||
| 117 : | } | ||
| 118 : | |||
| 119 : | if(getParent()) | ||
| 120 : | { | ||
| 121 : | // check if inside | ||
| 122 : | //LLRect parent_rect = mParentView->getRect(); | ||
| 123 : | //getRect().set(0, parent_rect.getHeight(), parent_rect.getWidth(), 0); | ||
| 124 : | handled = TRUE; | ||
| 125 : | |||
| 126 : | // check the type | ||
| 127 : | switch(cargo_type) | ||
| 128 : | { | ||
| 129 : | case DAD_TEXTURE: | ||
| 130 : | case DAD_SOUND: | ||
| 131 : | case DAD_LANDMARK: | ||
| 132 : | case DAD_SCRIPT: | ||
| 133 : | case DAD_OBJECT: | ||
| 134 : | case DAD_NOTECARD: | ||
| 135 : | case DAD_CLOTHING: | ||
| 136 : | case DAD_BODYPART: | ||
| 137 : | case DAD_ANIMATION: | ||
| 138 : | case DAD_GESTURE: | ||
| 139 : | { | ||
| 140 : | LLViewerInventoryItem* inv_item = (LLViewerInventoryItem*)cargo_data; | ||
| 141 : | if(gInventory.getItem(inv_item->getUUID()) | ||
| 142 : | && LLToolDragAndDrop::isInventoryGroupGiveAcceptable(inv_item)) | ||
| 143 : | { | ||
| 144 : | // *TODO: get multiple object transfers working | ||
| 145 : | *accept = ACCEPT_YES_COPY_SINGLE; | ||
| 146 : | if(drop) | ||
| 147 : | { | ||
| 148 : | mGroupNoticesPanel->setItem(inv_item); | ||
| 149 : | } | ||
| 150 : | } | ||
| 151 : | else | ||
| 152 : | { | ||
| 153 : | // It's not in the user's inventory (it's probably | ||
| 154 : | // in an object's contents), so disallow dragging | ||
| 155 : | // it here. You can't give something you don't | ||
| 156 : | // yet have. | ||
| 157 : | *accept = ACCEPT_NO; | ||
| 158 : | } | ||
| 159 : | break; | ||
| 160 : | } | ||
| 161 : | case DAD_CATEGORY: | ||
| 162 : | case DAD_CALLINGCARD: | ||
| 163 : | default: | ||
| 164 : | *accept = ACCEPT_NO; | ||
| 165 : | break; | ||
| 166 : | } | ||
| 167 : | } | ||
| 168 : | return handled; | ||
| 169 : | } | ||
| 170 : | |||
| 171 : | //----------------------------------------------------------------------------- | ||
| 172 : | // LLPanelGroupNotices | ||
| 173 : | //----------------------------------------------------------------------------- | ||
| 174 : | LLPanelGroupNotices::LLPanelGroupNotices(const std::string& name, | ||
| 175 : | const LLUUID& group_id) : | ||
| 176 : | LLPanelGroupTab(name,group_id), | ||
| 177 : | mInventoryItem(NULL), | ||
| 178 : | mInventoryOffer(NULL) | ||
| 179 : | { | ||
| 180 : | sInstances[group_id] = this; | ||
| 181 : | } | ||
| 182 : | |||
| 183 : | LLPanelGroupNotices::~LLPanelGroupNotices() | ||
| 184 : | { | ||
| 185 : | sInstances.erase(mGroupID); | ||
| 186 : | |||
| 187 : | if (mInventoryOffer) | ||
| 188 : | { | ||
| 189 : | // Cancel the inventory offer. | ||
| 190 : | mInventoryOffer->forceResponse(IOR_DECLINE); | ||
| 191 : | |||
| 192 : | mInventoryOffer = NULL; | ||
| 193 : | } | ||
| 194 : | } | ||
| 195 : | |||
| 196 : | // static | ||
| 197 : | void* LLPanelGroupNotices::createTab(void* data) | ||
| 198 : | { | ||
| 199 : | LLUUID* group_id = static_cast<LLUUID*>(data); | ||
| 200 : | return new LLPanelGroupNotices("panel group notices", *group_id); | ||
| 201 : | } | ||
| 202 : | |||
| 203 : | BOOL LLPanelGroupNotices::isVisibleByAgent(LLAgent* agentp) | ||
| 204 : | { | ||
| 205 : | return mAllowEdit && | ||
| 206 : | agentp->hasPowerInGroup(mGroupID, GP_NOTICES_SEND | GP_NOTICES_RECEIVE); | ||
| 207 : | } | ||
| 208 : | |||
| 209 : | BOOL LLPanelGroupNotices::postBuild() | ||
| 210 : | { | ||
| 211 : | bool recurse = true; | ||
| 212 : | |||
| 213 : | mNoticesList = getChild<LLScrollListCtrl>("notice_list",recurse); | ||
| 214 : | mNoticesList->setCommitOnSelectionChange(TRUE); | ||
| 215 : | mNoticesList->setCommitCallback(onSelectNotice); | ||
| 216 : | mNoticesList->setCallbackUserData(this); | ||
| 217 : | |||
| 218 : | mBtnNewMessage = getChild<LLButton>("create_new_notice",recurse); | ||
| 219 : | mBtnNewMessage->setClickedCallback(onClickNewMessage); | ||
| 220 : | mBtnNewMessage->setCallbackUserData(this); | ||
| 221 : | mBtnNewMessage->setEnabled(gAgent.hasPowerInGroup(mGroupID, GP_NOTICES_SEND)); | ||
| 222 : | |||
| 223 : | mBtnGetPastNotices = getChild<LLButton>("refresh_notices",recurse); | ||
| 224 : | mBtnGetPastNotices->setClickedCallback(onClickRefreshNotices); | ||
| 225 : | mBtnGetPastNotices->setCallbackUserData(this); | ||
| 226 : | |||
| 227 : | // Create | ||
| 228 : | mCreateSubject = getChild<LLLineEditor>("create_subject",recurse); | ||
| 229 : | mCreateMessage = getChild<LLTextEditor>("create_message",recurse); | ||
| 230 : | |||
| 231 : | mCreateInventoryName = getChild<LLLineEditor>("create_inventory_name",recurse); | ||
| 232 : | mCreateInventoryName->setTabStop(FALSE); | ||
| 233 : | mCreateInventoryName->setEnabled(FALSE); | ||
| 234 : | |||
| 235 : | mCreateInventoryIcon = getChild<LLIconCtrl>("create_inv_icon",recurse); | ||
| 236 : | mCreateInventoryIcon->setVisible(FALSE); | ||
| 237 : | |||
| 238 : | mBtnSendMessage = getChild<LLButton>("send_notice",recurse); | ||
| 239 : | mBtnSendMessage->setClickedCallback(onClickSendMessage); | ||
| 240 : | mBtnSendMessage->setCallbackUserData(this); | ||
| 241 : | |||
| 242 : | mBtnRemoveAttachment = getChild<LLButton>("remove_attachment",recurse); | ||
| 243 : | mBtnRemoveAttachment->setClickedCallback(onClickRemoveAttachment); | ||
| 244 : | mBtnRemoveAttachment->setCallbackUserData(this); | ||
| 245 : | mBtnRemoveAttachment->setEnabled(FALSE); | ||
| 246 : | |||
| 247 : | // View | ||
| 248 : | mViewSubject = getChild<LLLineEditor>("view_subject",recurse); | ||
| 249 : | mViewMessage = getChild<LLTextEditor>("view_message",recurse); | ||
| 250 : | |||
| 251 : | mViewInventoryName = getChild<LLLineEditor>("view_inventory_name",recurse); | ||
| 252 : | mViewInventoryName->setTabStop(FALSE); | ||
| 253 : | mViewInventoryName->setEnabled(FALSE); | ||
| 254 : | |||
| 255 : | mViewInventoryIcon = getChild<LLIconCtrl>("view_inv_icon",recurse); | ||
| 256 : | mViewInventoryIcon->setVisible(FALSE); | ||
| 257 : | |||
| 258 : | mBtnOpenAttachment = getChild<LLButton>("open_attachment",recurse); | ||
| 259 : | mBtnOpenAttachment->setClickedCallback(onClickOpenAttachment); | ||
| 260 : | mBtnOpenAttachment->setCallbackUserData(this); | ||
| 261 : | |||
| 262 : | mNoNoticesStr = getString("no_notices_text"); | ||
| 263 : | |||
| 264 : | mPanelCreateNotice = getChild<LLPanel>("panel_create_new_notice",recurse); | ||
| 265 : | mPanelViewNotice = getChild<LLPanel>("panel_view_past_notice",recurse); | ||
| 266 : | |||
| 267 : | // Must be in front of all other UI elements. | ||
| 268 : | LLPanel* dtv = getChild<LLPanel>("drop_target",recurse); | ||
| 269 : | LLGroupDropTarget* target = new LLGroupDropTarget("drop_target", | ||
| 270 : | dtv->getRect(), | ||
| 271 : | this, mGroupID); | ||
| 272 : | target->setEnabled(TRUE); | ||
| 273 : | target->setToolTip(dtv->getToolTip()); | ||
| 274 : | |||
| 275 : | mPanelCreateNotice->addChild(target); | ||
| 276 : | mPanelCreateNotice->removeChild(dtv, TRUE); | ||
| 277 : | |||
| 278 : | arrangeNoticeView(VIEW_PAST_NOTICE); | ||
| 279 : | |||
| 280 : | return LLPanelGroupTab::postBuild(); | ||
| 281 : | } | ||
| 282 : | |||
| 283 : | void LLPanelGroupNotices::activate() | ||
| 284 : | { | ||
| 285 : | BOOL can_send = gAgent.hasPowerInGroup(mGroupID,GP_NOTICES_SEND); | ||
| 286 : | BOOL can_receive = gAgent.hasPowerInGroup(mGroupID,GP_NOTICES_RECEIVE); | ||
| 287 : | |||
| 288 : | mPanelViewNotice->setEnabled(can_receive); | ||
| 289 : | mPanelCreateNotice->setEnabled(can_send); | ||
| 290 : | |||
| 291 : | // Always disabled to stop direct editing of attachment names | ||
| 292 : | mCreateInventoryName->setEnabled(FALSE); | ||
| 293 : | mViewInventoryName->setEnabled(FALSE); | ||
| 294 : | |||
| 295 : | // If we can receive notices, grab them right away. | ||
| 296 : | if (can_receive) | ||
| 297 : | { | ||
| 298 : | onClickRefreshNotices(this); | ||
| 299 : | } | ||
| 300 : | } | ||
| 301 : | |||
| 302 : | void LLPanelGroupNotices::setItem(LLPointer<LLInventoryItem> inv_item) | ||
| 303 : | { | ||
| 304 : | mInventoryItem = inv_item; | ||
| 305 : | |||
| 306 : | BOOL item_is_multi = FALSE; | ||
| 307 : | if ( inv_item->getFlags() & LLInventoryItem::II_FLAGS_OBJECT_HAS_MULTIPLE_ITEMS ) | ||
| 308 : | { | ||
| 309 : | item_is_multi = TRUE; | ||
| 310 : | }; | ||
| 311 : | |||
| 312 : | std::string icon_name = get_item_icon_name(inv_item->getType(), | ||
| 313 : | inv_item->getInventoryType(), | ||
| 314 : | inv_item->getFlags(), | ||
| 315 : | item_is_multi ); | ||
| 316 : | |||
| 317 : | mCreateInventoryIcon->setImage(icon_name); | ||
| 318 : | mCreateInventoryIcon->setVisible(TRUE); | ||
| 319 : | |||
| 320 : | std::stringstream ss; | ||
| 321 : | ss << " " << mInventoryItem->getName(); | ||
| 322 : | |||
| 323 : | mCreateInventoryName->setText(ss.str()); | ||
| 324 : | mBtnRemoveAttachment->setEnabled(TRUE); | ||
| 325 : | } | ||
| 326 : | |||
| 327 : | void LLPanelGroupNotices::onClickRemoveAttachment(void* data) | ||
| 328 : | { | ||
| 329 : | LLPanelGroupNotices* self = (LLPanelGroupNotices*)data; | ||
| 330 : | self->mInventoryItem = NULL; | ||
| 331 : | self->mCreateInventoryName->clear(); | ||
| 332 : | self->mCreateInventoryIcon->setVisible(FALSE); | ||
| 333 : | self->mBtnRemoveAttachment->setEnabled(FALSE); | ||
| 334 : | } | ||
| 335 : | |||
| 336 : | //static | ||
| 337 : | void LLPanelGroupNotices::onClickOpenAttachment(void* data) | ||
| 338 : | { | ||
| 339 : | LLPanelGroupNotices* self = (LLPanelGroupNotices*)data; | ||
| 340 : | |||
| 341 : | self->mInventoryOffer->forceResponse(IOR_ACCEPT); | ||
| 342 : | self->mInventoryOffer = NULL; | ||
| 343 : | self->mBtnOpenAttachment->setEnabled(FALSE); | ||
| 344 : | } | ||
| 345 : | |||
| 346 : | void LLPanelGroupNotices::onClickSendMessage(void* data) | ||
| 347 : | { | ||
| 348 : | LLPanelGroupNotices* self = (LLPanelGroupNotices*)data; | ||
| 349 : | |||
| 350 : | if (self->mCreateSubject->getText().empty()) | ||
| 351 : | { | ||
| 352 : | // Must supply a subject | ||
| 353 : | LLNotifications::instance().add("MustSpecifyGroupNoticeSubject"); | ||
| 354 : | return; | ||
| 355 : | } | ||
| 356 : | send_group_notice( | ||
| 357 : | self->mGroupID, | ||
| 358 : | self->mCreateSubject->getText(), | ||
| 359 : | self->mCreateMessage->getText(), | ||
| 360 : | self->mInventoryItem); | ||
| 361 : | |||
| 362 : | self->mCreateMessage->clear(); | ||
| 363 : | self->mCreateSubject->clear(); | ||
| 364 : | onClickRemoveAttachment(data); | ||
| 365 : | |||
| 366 : | self->arrangeNoticeView(VIEW_PAST_NOTICE); | ||
| 367 : | onClickRefreshNotices(self); | ||
| 368 : | |||
| 369 : | } | ||
| 370 : | |||
| 371 : | //static | ||
| 372 : | void LLPanelGroupNotices::onClickNewMessage(void* data) | ||
| 373 : | { | ||
| 374 : | LLPanelGroupNotices* self = (LLPanelGroupNotices*)data; | ||
| 375 : | |||
| 376 : | self->arrangeNoticeView(CREATE_NEW_NOTICE); | ||
| 377 : | |||
| 378 : | if (self->mInventoryOffer) | ||
| 379 : | { | ||
| 380 : | self->mInventoryOffer->forceResponse(IOR_DECLINE); | ||
| 381 : | self->mInventoryOffer = NULL; | ||
| 382 : | } | ||
| 383 : | |||
| 384 : | self->mCreateSubject->clear(); | ||
| 385 : | self->mCreateMessage->clear(); | ||
| 386 : | if (self->mInventoryItem) onClickRemoveAttachment(self); | ||
| 387 : | self->mNoticesList->deselectAllItems(TRUE); // TRUE == don't commit on chnage | ||
| 388 : | } | ||
| 389 : | |||
| 390 : | void LLPanelGroupNotices::onClickRefreshNotices(void* data) | ||
| 391 : | { | ||
| 392 : | lldebugs << "LLPanelGroupNotices::onClickGetPastNotices" << llendl; | ||
| 393 : | LLPanelGroupNotices* self = (LLPanelGroupNotices*)data; | ||
| 394 : | |||
| 395 : | self->mNoticesList->deleteAllItems(); | ||
| 396 : | |||
| 397 : | LLMessageSystem* msg = gMessageSystem; | ||
| 398 : | msg->newMessage("GroupNoticesListRequest"); | ||
| 399 : | msg->nextBlock("AgentData"); | ||
| 400 : | msg->addUUID("AgentID",gAgent.getID()); | ||
| 401 : | msg->addUUID("SessionID",gAgent.getSessionID()); | ||
| 402 : | msg->nextBlock("Data"); | ||
| 403 : | msg->addUUID("GroupID",self->mGroupID); | ||
| 404 : | gAgent.sendReliableMessage(); | ||
| 405 : | } | ||
| 406 : | |||
| 407 : | //static | ||
| 408 : | std::map<LLUUID,LLPanelGroupNotices*> LLPanelGroupNotices::sInstances; | ||
| 409 : | |||
| 410 : | // static | ||
| 411 : | void LLPanelGroupNotices::processGroupNoticesListReply(LLMessageSystem* msg, void** data) | ||
| 412 : | { | ||
| 413 : | LLUUID group_id; | ||
| 414 : | msg->getUUID("AgentData", "GroupID", group_id); | ||
| 415 : | |||
| 416 : | std::map<LLUUID,LLPanelGroupNotices*>::iterator it = sInstances.find(group_id); | ||
| 417 : | if (it == sInstances.end()) | ||
| 418 : | { | ||
| 419 : | llinfos << "Group Panel Notices " << group_id << " no longer in existence." | ||
| 420 : | << llendl; | ||
| 421 : | return; | ||
| 422 : | } | ||
| 423 : | |||
| 424 : | LLPanelGroupNotices* selfp = it->second; | ||
| 425 : | if(!selfp) | ||
| 426 : | { | ||
| 427 : | llinfos << "Group Panel Notices " << group_id << " no longer in existence." | ||
| 428 : | << llendl; | ||
| 429 : | return; | ||
| 430 : | } | ||
| 431 : | |||
| 432 : | selfp->processNotices(msg); | ||
| 433 : | } | ||
| 434 : | |||
| 435 : | void LLPanelGroupNotices::processNotices(LLMessageSystem* msg) | ||
| 436 : | { | ||
| 437 : | LLUUID id; | ||
| 438 : | std::string subj; | ||
| 439 : | std::string name; | ||
| 440 : | U32 timestamp; | ||
| 441 : | BOOL has_attachment; | ||
| 442 : | U8 asset_type; | ||
| 443 : | |||
| 444 : | S32 i=0; | ||
| 445 : | S32 count = msg->getNumberOfBlocks("Data"); | ||
| 446 : | for (;i<count;++i) | ||
| 447 : | { | ||
| 448 : | msg->getUUID("Data","NoticeID",id,i); | ||
| 449 : | if (1 == count && id.isNull()) | ||
| 450 : | { | ||
| 451 : | // Only one entry, the dummy entry. | ||
| 452 : | mNoticesList->addCommentText(mNoNoticesStr); | ||
| 453 : | mNoticesList->setEnabled(FALSE); | ||
| 454 : | return; | ||
| 455 : | } | ||
| 456 : | |||
| 457 : | msg->getString("Data","Subject",subj,i); | ||
| 458 : | msg->getString("Data","FromName",name,i); | ||
| 459 : | msg->getBOOL("Data","HasAttachment",has_attachment,i); | ||
| 460 : | msg->getU8("Data","AssetType",asset_type,i); | ||
| 461 : | msg->getU32("Data","Timestamp",timestamp,i); | ||
| 462 : | time_t t = timestamp; | ||
| 463 : | |||
| 464 : | LLSD row; | ||
| 465 : | row["id"] = id; | ||
| 466 : | |||
| 467 : | row["columns"][0]["column"] = "icon"; | ||
| 468 : | if (has_attachment) | ||
| 469 : | { | ||
| 470 : | std::string icon_name = get_item_icon_name( | ||
| 471 : | (LLAssetType::EType)asset_type, | ||
| 472 : | LLInventoryType::IT_NONE,FALSE, FALSE); | ||
| 473 : | row["columns"][0]["type"] = "icon"; | ||
| 474 : | row["columns"][0]["value"] = icon_name; | ||
| 475 : | } | ||
| 476 : | |||
| 477 : | row["columns"][1]["column"] = "subject"; | ||
| 478 : | row["columns"][1]["value"] = subj; | ||
| 479 : | |||
| 480 : | row["columns"][2]["column"] = "from"; | ||
| 481 : | row["columns"][2]["value"] = name; | ||
| 482 : | |||
| 483 : | std::string buffer; | ||
| 484 : | timeToFormattedString(t, gSavedSettings.getString("ShortDateFormat"), buffer); | ||
| 485 : | row["columns"][3]["column"] = "date"; | ||
| 486 : | row["columns"][3]["value"] = buffer; | ||
| 487 : | |||
| 488 : | buffer = llformat( "%u", timestamp); | ||
| 489 : | row["columns"][4]["column"] = "sort"; | ||
| 490 : | row["columns"][4]["value"] = buffer; | ||
| 491 : | |||
| 492 : | mNoticesList->addElement(row, ADD_BOTTOM); | ||
| 493 : | } | ||
| 494 : | |||
| 495 : | mNoticesList->sortItems(); | ||
| 496 : | } | ||
| 497 : | |||
| 498 : | void LLPanelGroupNotices::onSelectNotice(LLUICtrl* ctrl, void* data) | ||
| 499 : | { | ||
| 500 : | LLPanelGroupNotices* self = (LLPanelGroupNotices*)data; | ||
| 501 : | |||
| 502 : | if(!self) return; | ||
| 503 : | LLScrollListItem* item = self->mNoticesList->getFirstSelected(); | ||
| 504 : | if (!item) return; | ||
| 505 : | |||
| 506 : | LLMessageSystem* msg = gMessageSystem; | ||
| 507 : | msg->newMessage("GroupNoticeRequest"); | ||
| 508 : | msg->nextBlock("AgentData"); | ||
| 509 : | msg->addUUID("AgentID",gAgent.getID()); | ||
| 510 : | msg->addUUID("SessionID",gAgent.getSessionID()); | ||
| 511 : | msg->nextBlock("Data"); | ||
| 512 : | msg->addUUID("GroupNoticeID",item->getUUID()); | ||
| 513 : | gAgent.sendReliableMessage(); | ||
| 514 : | |||
| 515 : | lldebugs << "Item " << item->getUUID() << " selected." << llendl; | ||
| 516 : | } | ||
| 517 : | |||
| 518 : | void LLPanelGroupNotices::showNotice(const std::string& subject, | ||
| 519 : | const std::string& message, | ||
| 520 : | const bool& has_inventory, | ||
| 521 : | const std::string& inventory_name, | ||
| 522 : | LLOfferInfo* inventory_offer) | ||
| 523 : | { | ||
| 524 : | arrangeNoticeView(VIEW_PAST_NOTICE); | ||
| 525 : | |||
| 526 : | if(mViewSubject) mViewSubject->setText(subject); | ||
| 527 : | if(mViewMessage) mViewMessage->setText(message); | ||
| 528 : | |||
| 529 : | if (mInventoryOffer) | ||
| 530 : | { | ||
| 531 : | // Cancel the inventory offer for the previously viewed notice | ||
| 532 : | mInventoryOffer->forceResponse(IOR_DECLINE); | ||
| 533 : | mInventoryOffer = NULL; | ||
| 534 : | } | ||
| 535 : | |||
| 536 : | if (inventory_offer) | ||
| 537 : | { | ||
| 538 : | mInventoryOffer = inventory_offer; | ||
| 539 : | |||
| 540 : | std::string icon_name = get_item_icon_name(mInventoryOffer->mType, | ||
| 541 : | LLInventoryType::IT_TEXTURE, | ||
| 542 : | 0, FALSE); | ||
| 543 : | |||
| 544 : | mViewInventoryIcon->setImage(icon_name); | ||
| 545 : | mViewInventoryIcon->setVisible(TRUE); | ||
| 546 : | |||
| 547 : | std::stringstream ss; | ||
| 548 : | ss << " " << inventory_name; | ||
| 549 : | |||
| 550 : | mViewInventoryName->setText(ss.str()); | ||
| 551 : | mBtnOpenAttachment->setEnabled(TRUE); | ||
| 552 : | } | ||
| 553 : | else | ||
| 554 : | { | ||
| 555 : | mViewInventoryName->clear(); | ||
| 556 : | mViewInventoryIcon->setVisible(FALSE); | ||
| 557 : | mBtnOpenAttachment->setEnabled(FALSE); | ||
| 558 : | } | ||
| 559 : | } | ||
| 560 : | |||
| 561 : | void LLPanelGroupNotices::arrangeNoticeView(ENoticeView view_type) | ||
| 562 : | { | ||
| 563 : | if (CREATE_NEW_NOTICE == view_type) | ||
| 564 : | { | ||
| 565 : | mPanelCreateNotice->setVisible(TRUE); | ||
| 566 : | mPanelViewNotice->setVisible(FALSE); | ||
| 567 : | } | ||
| 568 : | else | ||
| 569 : | { | ||
| 570 : | mPanelCreateNotice->setVisible(FALSE); | ||
| 571 : | mPanelViewNotice->setVisible(TRUE); | ||
| 572 : | mBtnOpenAttachment->setEnabled(FALSE); | ||
| 573 : | } | ||
| 574 : | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

