diff options
Diffstat (limited to 'indra/newview')
120 files changed, 3176 insertions, 2864 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 21e491e1b5..0be8b53d41 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -169,6 +169,7 @@ set(viewer_SOURCE_FILES llfloatermute.cpp llfloaternamedesc.cpp llfloaternewim.cpp + llfloaternotificationsconsole.cpp llfloaterobjectiminfo.cpp llfloateropenobject.cpp llfloaterparcel.cpp @@ -570,6 +571,7 @@ set(viewer_HEADER_FILES llfloatermute.h llfloaternamedesc.h llfloaternewim.h + llfloaternotificationsconsole.h llfloaterobjectiminfo.h llfloateropenobject.h llfloaterparcel.h @@ -1091,6 +1093,8 @@ set(viewer_XUI_FILES skins/default/xui/en-us/floater_name_description.xml skins/default/xui/en-us/floater_new_im.xml skins/default/xui/en-us/floater_new_outfit_dialog.xml + skins/default/xui/en-us/floater_notifications_console.xml + skins/default/xui/en-us/floater_notification.xml skins/default/xui/en-us/floater_object_im_info.xml skins/default/xui/en-us/floater_openobject.xml skins/default/xui/en-us/floater_pay_object.xml @@ -1149,6 +1153,7 @@ set(viewer_XUI_FILES skins/default/xui/en-us/menu_slurl.xml skins/default/xui/en-us/menu_viewer.xml skins/default/xui/en-us/mime_types.xml + skins/default/xui/en-us/notifications.xml skins/default/xui/en-us/notify.xml skins/default/xui/en-us/panel_audio_device.xml skins/default/xui/en-us/panel_audio.xml @@ -1177,6 +1182,7 @@ set(viewer_XUI_FILES skins/default/xui/en-us/panel_media_controls.xml skins/default/xui/en-us/panel_media_remote_expanded.xml skins/default/xui/en-us/panel_media_remote.xml + skins/default/xui/en-us/panel_notifications_channel.xml skins/default/xui/en-us/panel_overlaybar.xml skins/default/xui/en-us/panel_place_small.xml skins/default/xui/en-us/panel_place.xml diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 13fc165010..b2f9f0a2ca 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -55,6 +55,17 @@ <real>1.0</real> </array> </map> + <key>AlertedUnsupportedHardware</key> + <map> + <key>Comment</key> + <string>Set if there's unsupported hardware and we've already done a notification.</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> <key>AllowIdleAFK</key> <map> <key>Comment</key> diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 7eca956f7d..55b74abd62 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -583,7 +583,7 @@ void LLAgent::onAppFocusGained() void LLAgent::ageChat() { - if (mAvatarObject) + if (mAvatarObject.notNull()) { // get amount of time since I last chatted F64 elapsed_time = (F64)mAvatarObject->mChatTimer.getElapsedTimeF32(); @@ -600,7 +600,7 @@ void LLAgent::unlockView() { if (getFocusOnAvatar()) { - if (mAvatarObject) + if (mAvatarObject.notNull()) { setFocusGlobal( LLVector3d::zero, mAvatarObject->mID ); } @@ -1017,7 +1017,7 @@ void LLAgent::sendReliableMessage() //----------------------------------------------------------------------------- LLVector3 LLAgent::getVelocity() const { - if (mAvatarObject) + if (mAvatarObject.notNull()) { return mAvatarObject->getVelocity(); } @@ -1038,7 +1038,7 @@ void LLAgent::setPositionAgent(const LLVector3 &pos_agent) llerrs << "setPositionAgent is not a number" << llendl; } - if (!mAvatarObject.isNull() && mAvatarObject->getParent()) + if (mAvatarObject.notNull() && mAvatarObject->getParent()) { LLVector3 pos_agent_sitting; LLVector3d pos_agent_d; @@ -1076,7 +1076,7 @@ void LLAgent::slamLookAt(const LLVector3 &look_at) //----------------------------------------------------------------------------- const LLVector3d &LLAgent::getPositionGlobal() const { - if (!mAvatarObject.isNull() && !mAvatarObject->mDrawable.isNull()) + if (mAvatarObject.notNull() && !mAvatarObject->mDrawable.isNull()) { mPositionGlobal = getPosGlobalFromAgent(mAvatarObject->getRenderPosition()); } @@ -1093,7 +1093,7 @@ const LLVector3d &LLAgent::getPositionGlobal() const //----------------------------------------------------------------------------- const LLVector3 &LLAgent::getPositionAgent() { - if(!mAvatarObject.isNull() && !mAvatarObject->mDrawable.isNull()) + if(mAvatarObject.notNull() && !mAvatarObject->mDrawable.isNull()) { mFrameAgent.setOrigin(mAvatarObject->getRenderPosition()); } @@ -2345,11 +2345,11 @@ void LLAgent::stopAutoPilot(BOOL user_cancel) if (user_cancel && !mAutoPilotBehaviorName.empty()) { if (mAutoPilotBehaviorName == "Sit") - LLNotifyBox::showXml("CancelledSit"); + LLNotifications::instance().add("CancelledSit"); else if (mAutoPilotBehaviorName == "Attach") - LLNotifyBox::showXml("CancelledAttach"); + LLNotifications::instance().add("CancelledAttach"); else - LLNotifyBox::showXml("Cancelled"); + LLNotifications::instance().add("Cancelled"); } } } @@ -2374,7 +2374,7 @@ void LLAgent::autoPilot(F32 *delta_yaw) mAutoPilotTargetGlobal = object->getPositionGlobal(); } - if (!mAvatarObject) + if (mAvatarObject.isNull()) { return; } @@ -2455,7 +2455,7 @@ void LLAgent::autoPilot(F32 *delta_yaw) // If we're flying, handle autopilot points above or below you. if (getFlying() && xy_distance < AUTOPILOT_HEIGHT_ADJUST_DISTANCE) { - if (mAvatarObject) + if (mAvatarObject.notNull()) { F64 current_height = mAvatarObject->getPositionGlobal().mdV[VZ]; F32 delta_z = (F32)(mAutoPilotTargetGlobal.mdV[VZ] - current_height); @@ -2540,7 +2540,7 @@ void LLAgent::propagate(const F32 dt) pitch(PITCH_RATE * (F32) mPitchKey * dt); // handle auto-land behavior - if (mAvatarObject) + if (mAvatarObject.notNull()) { BOOL in_air = mAvatarObject->mInAir; LLVector3 land_vel = getVelocity(); @@ -2591,7 +2591,7 @@ void LLAgent::updateLookAt(const S32 mouse_x, const S32 mouse_y) static LLVector3 last_at_axis; - if ( mAvatarObject.isNull() ) + if (mAvatarObject.isNull()) { return; } @@ -2864,7 +2864,7 @@ void LLAgent::endAnimationUpdateUI() } // Disable mouselook-specific animations - if (mAvatarObject) + if (mAvatarObject.notNull()) { if( mAvatarObject->isAnyAnimationSignaled(AGENT_GUN_AIM_ANIMS, NUM_AGENT_GUN_AIM_ANIMS) ) { @@ -2910,7 +2910,7 @@ void LLAgent::endAnimationUpdateUI() gMorphView->setVisible( FALSE ); } - if (mAvatarObject) + if (mAvatarObject.notNull()) { if(mCustomAnim) { @@ -2953,7 +2953,7 @@ void LLAgent::endAnimationUpdateUI() gIMMgr->setFloaterOpen( FALSE ); gConsole->setVisible( TRUE ); - if (mAvatarObject) + if (mAvatarObject.notNull()) { // Trigger mouselook-specific animations if( mAvatarObject->isAnyAnimationSignaled(AGENT_GUN_HOLD_ANIMS, NUM_AGENT_GUN_HOLD_ANIMS) ) @@ -3014,7 +3014,7 @@ void LLAgent::endAnimationUpdateUI() } // freeze avatar - if (mAvatarObject) + if (mAvatarObject.notNull()) { mPauseRequest = mAvatarObject->requestPause(); } @@ -3048,7 +3048,7 @@ void LLAgent::updateCamera() validateFocusObject(); - if (!mAvatarObject.isNull() && + if (mAvatarObject.notNull() && mAvatarObject->mIsSitting && camera_mode == CAMERA_MODE_MOUSELOOK) { @@ -3162,7 +3162,7 @@ void LLAgent::updateCamera() //Ventrella if ( mCameraMode == CAMERA_MODE_FOLLOW ) { - if ( !mAvatarObject.isNull() ) + if ( mAvatarObject.notNull() ) { //-------------------------------------------------------------------------------- // this is where the avatar's position and rotation are given to followCam, and @@ -3472,7 +3472,7 @@ LLVector3d LLAgent::calcFocusPositionTargetGlobal() { LLVector3d at_axis(1.0, 0.0, 0.0); LLQuaternion agent_rot = mFrameAgent.getQuaternion(); - if (!mAvatarObject.isNull() && mAvatarObject->getParent()) + if (mAvatarObject.notNull() && mAvatarObject->getParent()) { LLViewerObject* root_object = (LLViewerObject*)mAvatarObject->getRoot(); if (!root_object->flagCameraDecoupled()) @@ -3770,7 +3770,7 @@ LLVector3d LLAgent::calcCameraPositionTargetGlobal(BOOL *hit_limit) camera_offset.setVec( local_camera_offset ); camera_position_global = frame_center_global + head_offset + camera_offset; - if (!mAvatarObject.isNull()) + if (mAvatarObject.notNull()) { LLVector3d camera_lag_d; F32 lag_interp = LLCriticalDamp::getInterpolant(CAMERA_LAG_HALF_LIFE); @@ -4001,7 +4001,7 @@ void LLAgent::changeCameraToMouselook(BOOL animate) gSavedSettings.setBOOL("ThirdPersonBtnState", FALSE); gSavedSettings.setBOOL("BuildBtnState", FALSE); - if (mAvatarObject) + if (mAvatarObject.notNull()) { mAvatarObject->stopMotion( ANIM_AGENT_BODY_NOISE ); mAvatarObject->stopMotion( ANIM_AGENT_BREATHE_ROT ); @@ -4089,7 +4089,7 @@ void LLAgent::changeCameraToFollow(BOOL animate) LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset); } - if (mAvatarObject) + if (mAvatarObject.notNull()) { mAvatarObject->mPelvisp->setPosition(LLVector3::zero); mAvatarObject->startMotion( ANIM_AGENT_BODY_NOISE ); @@ -4137,7 +4137,7 @@ void LLAgent::changeCameraToThirdPerson(BOOL animate) mCameraZoomFraction = INITIAL_ZOOM_FRACTION; - if (mAvatarObject) + if (mAvatarObject.notNull()) { if (!mAvatarObject->mIsSitting) { @@ -4183,7 +4183,7 @@ void LLAgent::changeCameraToThirdPerson(BOOL animate) } // Remove any pitch from the avatar - if (!mAvatarObject.isNull() && mAvatarObject->getParent()) + if (mAvatarObject.notNull() && mAvatarObject->getParent()) { LLQuaternion obj_rot = ((LLViewerObject*)mAvatarObject->getParent())->getRenderRotation(); at_axis = LLViewerCamera::getInstance()->getAtAxis(); @@ -4262,7 +4262,7 @@ void LLAgent::changeCameraToCustomizeAvatar(BOOL avatar_animate, BOOL camera_ani LLVOAvatar::onCustomizeStart(); } - if (!mAvatarObject.isNull()) + if (mAvatarObject.notNull()) { if(avatar_animate) { @@ -4362,7 +4362,7 @@ void LLAgent::setFocusGlobal(const LLVector3d& focus, const LLUUID &object_id) { if (focus.isExactlyZero()) { - if (!mAvatarObject.isNull()) + if (mAvatarObject.notNull()) { mFocusTargetGlobal = getPosGlobalFromAgent(mAvatarObject->mHeadp->getWorldPosition()); } @@ -4407,7 +4407,7 @@ void LLAgent::setFocusGlobal(const LLVector3d& focus, const LLUUID &object_id) { if (focus.isExactlyZero()) { - if (!mAvatarObject.isNull()) + if (mAvatarObject.notNull()) { mFocusTargetGlobal = getPosGlobalFromAgent(mAvatarObject->mHeadp->getWorldPosition()); } @@ -4544,7 +4544,7 @@ void LLAgent::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate) if (mCameraMode == CAMERA_MODE_THIRD_PERSON) { LLVector3 at_axis; - if (!mAvatarObject.isNull() && mAvatarObject->getParent()) + if (mAvatarObject.notNull() && mAvatarObject->getParent()) { LLQuaternion obj_rot = ((LLViewerObject*)mAvatarObject->getParent())->getRenderRotation(); at_axis = LLViewerCamera::getInstance()->getAtAxis(); @@ -4611,7 +4611,7 @@ void LLAgent::lookAtLastChat() if (chatter->isAvatar()) { LLVOAvatar *chatter_av = (LLVOAvatar*)chatter; - if (!mAvatarObject.isNull() && chatter_av->mHeadp) + if (mAvatarObject.notNull() && chatter_av->mHeadp) { delta_pos = chatter_av->mHeadp->getWorldPosition() - mAvatarObject->mHeadp->getWorldPosition(); } @@ -4692,7 +4692,7 @@ void LLAgent::setStartPosition( U32 location_id ) LLVector3 agent_pos = getPositionAgent(); LLVector3 agent_look_at = mFrameAgent.getAtAxis(); - if (mAvatarObject) + if (mAvatarObject.notNull()) { // the z height is at the agent's feet agent_pos.mV[VZ] -= 0.5f * mAvatarObject->mBodySize.mV[VZ]; @@ -4853,7 +4853,7 @@ void LLAgent::setTeen(bool teen) void LLAgent::buildFullname(std::string& name) const { - if (mAvatarObject) + if (mAvatarObject.notNull()) { name = mAvatarObject->getFullname(); } @@ -4871,7 +4871,7 @@ void LLAgent::buildFullnameAndTitle(std::string& name) const name.erase(0, name.length()); } - if (mAvatarObject) + if (mAvatarObject.notNull()) { name += mAvatarObject->getFullname(); } @@ -5226,7 +5226,7 @@ void LLAgent::getName(std::string& name) { name.clear(); - if (mAvatarObject) + if (mAvatarObject.notNull()) { LLNameValue *first_nv = mAvatarObject->getNVPair("FirstName"); LLNameValue *last_nv = mAvatarObject->getNVPair("LastName"); @@ -6726,7 +6726,7 @@ void LLAgent::onInitialWearableAssetArrived( LLWearable* wearable, void* userdat void LLAgent::recoverMissingWearable( EWearableType type ) { // Try to recover by replacing missing wearable with a new one. - LLNotifyBox::showXml("ReplacedMissingWearable"); + LLNotifications::instance().add("ReplacedMissingWearable"); lldebugs << "Wearable " << LLWearable::typeToTypeLabel( type ) << " could not be downloaded. Replaced inventory item with default wearable." << llendl; LLWearable* new_wearable = gWearableList.createNewWearable(type); @@ -7157,8 +7157,10 @@ void LLAgent::removeWearable( EWearableType type ) { if( old_wearable->isDirty() ) { + LLSD payload; + payload["wearable_type"] = (S32)type; // Bring up view-modal dialog: Save changes? Yes, No, Cancel - gViewerWindow->alertXml("WearableSave", LLAgent::onRemoveWearableDialog, (void*)type ); + LLNotifications::instance().add("WearableSave", LLSD(), payload, &LLAgent::onRemoveWearableDialog); return; } else @@ -7169,9 +7171,10 @@ void LLAgent::removeWearable( EWearableType type ) } // static -void LLAgent::onRemoveWearableDialog( S32 option, void* userdata ) +bool LLAgent::onRemoveWearableDialog(const LLSD& notification, const LLSD& response ) { - EWearableType type = (EWearableType)(intptr_t)userdata; + S32 option = LLNotification::getSelectedOption(notification, response); + EWearableType type = (EWearableType)notification["payload"]["wearable_type"].asInteger(); switch( option ) { case 0: // "Save" @@ -7190,6 +7193,7 @@ void LLAgent::onRemoveWearableDialog( S32 option, void* userdata ) llassert(0); break; } + return false; } // Called by removeWearable() and onRemoveWearableDialog() to actually do the removal. @@ -7388,8 +7392,9 @@ void LLAgent::setWearable( LLInventoryItem* new_item, LLWearable* new_wearable ) if( old_wearable->isDirty() ) { // Bring up modal dialog: Save changes? Yes, No, Cancel - gViewerWindow->alertXml( "WearableSave", LLAgent::onSetWearableDialog, - new LLSetWearableData( new_item->getUUID(), new_wearable )); + LLSD payload; + payload["item_id"] = new_item->getUUID(); + LLNotifications::instance().add( "WearableSave", LLSD(), payload, boost::bind(LLAgent::onSetWearableDialog, _1, _2, new_wearable)); return; } } @@ -7398,25 +7403,25 @@ void LLAgent::setWearable( LLInventoryItem* new_item, LLWearable* new_wearable ) } // static -void LLAgent::onSetWearableDialog( S32 option, void* userdata ) +bool LLAgent::onSetWearableDialog( const LLSD& notification, const LLSD& response, LLWearable* wearable ) { - LLSetWearableData* data = (LLSetWearableData*)userdata; - LLInventoryItem* new_item = gInventory.getItem( data->mNewItemID ); + S32 option = LLNotification::getSelectedOption(notification, response); + LLInventoryItem* new_item = gInventory.getItem( notification["payload"]["item_id"].asUUID()); if( !new_item ) { - delete data; - return; + delete wearable; + return false; } switch( option ) { case 0: // "Save" - gAgent.saveWearable( data->mNewWearable->getType() ); - gAgent.setWearableFinal( new_item, data->mNewWearable ); + gAgent.saveWearable( wearable->getType() ); + gAgent.setWearableFinal( new_item, wearable ); break; case 1: // "Don't Save" - gAgent.setWearableFinal( new_item, data->mNewWearable ); + gAgent.setWearableFinal( new_item, wearable ); break; case 2: // "Cancel" @@ -7427,7 +7432,8 @@ void LLAgent::onSetWearableDialog( S32 option, void* userdata ) break; } - delete data; + delete wearable; + return false; } // Called from setWearable() and onSetWearableDialog() to actually set the wearable. diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index f561f55e46..f1e0bc9308 100644 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -591,10 +591,8 @@ public: //-------------------------------------------------------------------- // Wearables //-------------------------------------------------------------------- - BOOL getWearablesLoaded() const { return mWearablesLoaded; } - void setWearable( LLInventoryItem* new_item, LLWearable* wearable ); - static void onSetWearableDialog( S32 option, void* userdata ); + static bool onSetWearableDialog( const LLSD& notification, const LLSD& response, LLWearable* wearable ); void setWearableFinal( LLInventoryItem* new_item, LLWearable* new_wearable ); void setWearableOutfit( const LLInventoryItem::item_array_t& items, const LLDynamicArray< LLWearable* >& wearables, BOOL remove ); void queryWearableCache(); @@ -624,7 +622,7 @@ public: void makeNewOutfitDone(S32 index); void removeWearable( EWearableType type ); - static void onRemoveWearableDialog( S32 option, void* userdata ); + static bool onRemoveWearableDialog(const LLSD& notification, const LLSD& response ); void removeWearableFinal( EWearableType type ); void sendAgentWearablesUpdate(); diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index b8b08855a8..54fdcc3894 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -652,6 +652,7 @@ bool LLAppViewer::init() // Widget construction depends on LLUI being initialized LLUI::initClass(&gSavedSettings, + &gSavedSettings, &gColors, LLUIImageList::getInstance(), ui_audio_callback, @@ -663,7 +664,7 @@ bool LLAppViewer::init() &LLURLDispatcher::dispatchFromTextEditor); LLUICtrlFactory::getInstance()->setupPaths(); // update paths with correct language set - + ///////////////////////////////////////////////// // // Load settings files @@ -736,7 +737,10 @@ bool LLAppViewer::init() // initWindow(); -#if LL_LCD_COMPILE + // call all self-registered classes + LLInitClassList::instance().fireCallbacks(); + + #if LL_LCD_COMPILE // start up an LCD window on a logitech keyboard, if there is one HINSTANCE hInstance = GetModuleHandle(NULL); gLcdScreen = new LLLCD(hInstance); @@ -762,64 +766,67 @@ bool LLAppViewer::init() // If we don't have the right GL requirements, exit. if (!gGLManager.mHasRequirements && !gNoRender) { - // can't use an alert here since we're existing and + // can't use an alert here since we're exiting and // all hell breaks lose. OSMessageBox( - LLAlertDialog::getTemplateMessage("UnsupportedGLRequirements"), + LLNotifications::instance().getGlobalString("UnsupportedGLRequirements"), LLStringUtil::null, OSMB_OK); return 0; } - - bool unsupported = false; - LLStringUtil::format_map_t args; - std::string minSpecs; - - // get cpu data from xml - std::stringstream minCPUString(LLAlertDialog::getTemplateMessage("UnsupportedCPUAmount")); - S32 minCPU = 0; - minCPUString >> minCPU; - - // get RAM data from XML - std::stringstream minRAMString(LLAlertDialog::getTemplateMessage("UnsupportedRAMAmount")); - U64 minRAM = 0; - minRAMString >> minRAM; - minRAM = minRAM * 1024 * 1024; - - if(!LLFeatureManager::getInstance()->isGPUSupported() && LLFeatureManager::getInstance()->getGPUClass() != GPU_CLASS_UNKNOWN) - { - minSpecs += LLAlertDialog::getTemplateMessage("UnsupportedGPU"); - minSpecs += "\n"; - unsupported = true; - } - if(gSysCPU.getMhz() < minCPU) - { - minSpecs += LLAlertDialog::getTemplateMessage("UnsupportedCPU"); - minSpecs += "\n"; - unsupported = true; - } - if(gSysMemory.getPhysicalMemoryClamped() < minRAM) - { - minSpecs += LLAlertDialog::getTemplateMessage("UnsupportedRAM"); - minSpecs += "\n"; - unsupported = true; - } - - if (LLFeatureManager::getInstance()->getGPUClass() == GPU_CLASS_UNKNOWN) + // alert the user if they are using unsupported hardware + if(!gSavedSettings.getBOOL("AlertedUnsupportedHardware")) { - gViewerWindow->alertXml("UnknownGPU"); - } + bool unsupported = false; + LLSD args; + std::string minSpecs; - if(unsupported) - { - if(!gSavedSettings.controlExists("WarnUnsupportedHardware") - || gSavedSettings.getBOOL("WarnUnsupportedHardware")) + // get cpu data from xml + std::stringstream minCPUString(LLNotifications::instance().getGlobalString("UnsupportedCPUAmount")); + S32 minCPU = 0; + minCPUString >> minCPU; + + // get RAM data from XML + std::stringstream minRAMString(LLNotifications::instance().getGlobalString("UnsupportedRAMAmount")); + U64 minRAM = 0; + minRAMString >> minRAM; + minRAM = minRAM * 1024 * 1024; + + if(!LLFeatureManager::getInstance()->isGPUSupported() && LLFeatureManager::getInstance()->getGPUClass() != GPU_CLASS_UNKNOWN) + { + minSpecs += LLNotifications::instance().getGlobalString("UnsupportedGPU"); + minSpecs += "\n"; + unsupported = true; + } + if(gSysCPU.getMhz() < minCPU) + { + minSpecs += LLNotifications::instance().getGlobalString("UnsupportedCPU"); + minSpecs += "\n"; + unsupported = true; + } + if(gSysMemory.getPhysicalMemoryClamped() < minRAM) { - args["MINSPECS"] = minSpecs; - gViewerWindow->alertXml("UnsupportedHardware", args ); + minSpecs += LLNotifications::instance().getGlobalString("UnsupportedRAM"); + minSpecs += "\n"; + unsupported = true; } + if (LLFeatureManager::getInstance()->getGPUClass() == GPU_CLASS_UNKNOWN) + { + LLNotifications::instance().add("UnknownGPU"); + } + + if(unsupported) + { + if(!gSavedSettings.controlExists("WarnUnsupportedHardware") + || gSavedSettings.getBOOL("WarnUnsupportedHardware")) + { + args["MINSPECS"] = minSpecs; + LLNotifications::instance().add("UnsupportedHardware", args ); + } + + } } // save the graphics card @@ -1153,8 +1160,6 @@ bool LLAppViewer::cleanup() // Note: this is where gLocalSpeakerMgr and gActiveSpeakerMgr used to be deleted. - LLNotifyBox::cleanup(); - LLWorldMap::getInstance()->reset(); // release any images llinfos << "Global stuff deleted" << llendflush; @@ -1705,25 +1710,6 @@ bool LLAppViewer::initConfiguration() LLFirstUse::addConfigVariable("FirstVoice"); LLFirstUse::addConfigVariable("FirstMedia"); - ////// - // *FIX:Mani - Find a way to remove the gUICtrlFactory and - // LLAlertDialog::parseAlerts dependecies on the being loaded - // *before* the user settings. Having to do this init here - // seems odd. - - // This is where gUICtrlFactory used to be instantiated with a new LLUICtrlFactory - // which needed to happen before calling parseAlerts below. - // TODO: That method is still dependant upon the base LLUICtrlFactory constructor being called - // which registers some callbacks so I'm leaving in a call to getInstance here to cause that to - // still happen. This needs to be cleaned up later when the base and derived classes - // are planned to be combined. -MG - LLUICtrlFactory::getInstance(); - - - // Pre-load alerts.xml to define the warnings settings (always loads from skins/xui/en-us/) - // Do this *before* loading the settings file - LLAlertDialog::parseAlerts("alerts.xml", &gSavedSettings, TRUE); - // - read command line settings. LLControlGroupCLP clp; std::string cmd_line_config = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, @@ -2151,8 +2137,6 @@ bool LLAppViewer::initWindow() LLUI::sWindow = gViewerWindow->getWindow(); - LLAlertDialog::parseAlerts("alerts.xml"); - LLNotifyBox::parseNotify("notify.xml"); LLTrans::parseStrings("strings.xml"); // Show watch cursor @@ -2614,32 +2598,34 @@ void LLAppViewer::requestQuit() mQuitRequested = true; } -static void finish_quit(S32 option, void *userdata) +static bool finish_quit(const LLSD& notification, const LLSD& response) { + S32 option = LLNotification::getSelectedOption(notification, response); + if (option == 0) { LLAppViewer::instance()->requestQuit(); } + return false; } +static LLNotificationFunctorRegistration finish_quit_reg("ConfirmQuit", finish_quit); void LLAppViewer::userQuit() { - gViewerWindow->alertXml("ConfirmQuit", finish_quit, NULL); + LLNotifications::instance().add("ConfirmQuit"); } -static void finish_early_exit(S32 option, void* userdata) +static bool finish_early_exit(const LLSD& notification, const LLSD& response) { LLAppViewer::instance()->forceQuit(); + return false; } -void LLAppViewer::earlyExit(const std::string& msg) +void LLAppViewer::earlyExit(const std::string& name, const LLSD& substitutions) { - llwarns << "app_early_exit: " << msg << llendl; + llwarns << "app_early_exit: " << name << llendl; gDoDisconnect = TRUE; -// LLStringUtil::format_map_t args; -// args["[MESSAGE]"] = mesg; -// gViewerWindow->alertXml("AppEarlyExit", args, finish_early_exit); - LLAlertDialog::showCritical(msg, finish_early_exit, NULL); + LLNotifications::instance().add(name, substitutions, LLSD(), finish_early_exit); } void LLAppViewer::forceExit(S32 arg) @@ -2953,18 +2939,22 @@ const std::string& LLAppViewer::getWindowTitle() const } // Callback from a dialog indicating user was logged out. -void finish_disconnect(S32 option, void* userdata) +bool finish_disconnect(const LLSD& notification, const LLSD& response) { + S32 option = LLNotification::getSelectedOption(notification, response); + if (1 == option) { LLAppViewer::instance()->forceQuit(); } + return false; } // Callback from an early disconnect dialog, force an exit -void finish_forced_disconnect(S32 /* option */, void* /* userdata */) +bool finish_forced_disconnect(const LLSD& notification, const LLSD& response) { LLAppViewer::instance()->forceQuit(); + return false; } @@ -2984,19 +2974,19 @@ void LLAppViewer::forceDisconnect(const std::string& mesg) big_reason = mesg; } - LLStringUtil::format_map_t args; + LLSD args; gDoDisconnect = TRUE; if (LLStartUp::getStartupState() < STATE_STARTED) { // Tell users what happened - args["[ERROR_MESSAGE]"] = big_reason; - gViewerWindow->alertXml("ErrorMessage", args, finish_forced_disconnect); + args["ERROR_MESSAGE"] = big_reason; + LLNotifications::instance().add("ErrorMessage", args, LLSD(), &finish_forced_disconnect); } else { - args["[MESSAGE]"] = big_reason; - gViewerWindow->alertXml("YouHaveBeenLoggedOut", args, finish_disconnect ); + args["MESSAGE"] = big_reason; + LLNotifications::instance().add("YouHaveBeenLoggedOut", args, LLSD(), &finish_disconnect ); } } @@ -3763,6 +3753,9 @@ void LLAppViewer::disconnectViewer() // Now we just ask the LLWorld singleton to cleanly shut down. LLWorld::getInstance()->destroyClass(); + // call all self-registered classes + LLDestroyClassList::instance().fireCallbacks(); + cleanup_xfer_manager(); gDisconnected = TRUE; } diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h index 41081237c7..f8940322c5 100644 --- a/indra/newview/llappviewer.h +++ b/indra/newview/llappviewer.h @@ -63,7 +63,8 @@ public: void forceQuit(); // Puts the viewer into 'shutting down without error' mode. void requestQuit(); // Request a quit. A kinder, gentler quit. void userQuit(); // The users asks to quit. Confirm, then requestQuit() - void earlyExit(const std::string& msg); // Display an error dialog and forcibly quit. + void earlyExit(const std::string& name, + const LLSD& substitutions = LLSD()); // Display an error dialog and forcibly quit. void forceExit(S32 arg); // exit() immediately (after some cleanup). void abortQuit(); // Called to abort a quit request. diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp index d25f827a72..a90532b451 100644 --- a/indra/newview/llassetuploadresponders.cpp +++ b/indra/newview/llassetuploadresponders.cpp @@ -102,21 +102,21 @@ void LLAssetUploadResponder::error(U32 statusNum, const std::string& reason) { llinfos << "LLAssetUploadResponder::error " << statusNum << " reason: " << reason << llendl; - LLStringUtil::format_map_t args; + LLSD args; switch(statusNum) { case 400: - args["[FILE]"] = (mFileName.empty() ? mVFileID.asString() : mFileName); - args["[REASON]"] = "Error in upload request. Please visit " + args["FILE"] = (mFileName.empty() ? mVFileID.asString() : mFileName); + args["REASON"] = "Error in upload request. Please visit " "http://secondlife.com/support for help fixing this problem."; - gViewerWindow->alertXml("CannotUploadReason", args); + LLNotifications::instance().add("CannotUploadReason", args); break; case 500: default: - args["[FILE]"] = (mFileName.empty() ? mVFileID.asString() : mFileName); - args["[REASON]"] = "The server is experiencing unexpected " + args["FILE"] = (mFileName.empty() ? mVFileID.asString() : mFileName); + args["REASON"] = "The server is experiencing unexpected " "difficulties."; - gViewerWindow->alertXml("CannotUploadReason", args); + LLNotifications::instance().add("CannotUploadReason", args); break; } LLUploadDialog::modalUploadFinished(); @@ -171,10 +171,10 @@ void LLAssetUploadResponder::uploadFailure(const LLSD& content) } else { - LLStringUtil::format_map_t args; - args["[FILE]"] = (mFileName.empty() ? mVFileID.asString() : mFileName); - args["[REASON]"] = content["message"].asString(); - gViewerWindow->alertXml("CannotUploadReason", args); + LLSD args; + args["FILE"] = (mFileName.empty() ? mVFileID.asString() : mFileName); + args["REASON"] = content["message"].asString(); + LLNotifications::instance().add("CannotUploadReason", args); } } @@ -220,9 +220,9 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content) gMessageSystem->addUUIDFast(_PREHASH_TransactionID, LLUUID::null ); gAgent.sendReliableMessage(); - LLStringUtil::format_map_t args; - args["[AMOUNT]"] = llformat("%d",LLGlobalEconomy::Singleton::getInstance()->getPriceUpload()); - LLNotifyBox::showXml("UploadPayment", args); + LLSD args; + args["AMOUNT"] = llformat("%d",LLGlobalEconomy::Singleton::getInstance()->getPriceUpload()); + LLNotifications::instance().add("UploadPayment", args); } // Actually add the upload to viewer inventory diff --git a/indra/newview/llcallingcard.cpp b/indra/newview/llcallingcard.cpp index 1fdefbac49..2395d1daab 100644 --- a/indra/newview/llcallingcard.cpp +++ b/indra/newview/llcallingcard.cpp @@ -592,19 +592,19 @@ void LLAvatarTracker::processChange(LLMessageSystem* msg) if((mBuddyInfo[agent_id]->getRightsGrantedFrom() ^ new_rights) & LLRelationship::GRANT_MODIFY_OBJECTS) { std::string first, last; - LLStringUtil::format_map_t args; + LLSD args; if(gCacheName->getName(agent_id, first, last)) { - args["[FIRST_NAME]"] = first; - args["[LAST_NAME]"] = last; + args["FIRST_NAME"] = first; + args["LAST_NAME"] = last; } if(LLRelationship::GRANT_MODIFY_OBJECTS & new_rights) { - gViewerWindow->alertXml("GrantedModifyRights",args); + LLNotifications::instance().add("GrantedModifyRights",args); } else { - gViewerWindow->alertXml("RevokedModifyRights",args); + LLNotifications::instance().add("RevokedModifyRights",args); } } (mBuddyInfo[agent_id])->setRightsFrom(new_rights); @@ -638,7 +638,7 @@ void LLAvatarTracker::processNotify(LLMessageSystem* msg, bool online) tracking_id = mTrackingData->mAvatarID; } BOOL notify = FALSE; - LLStringUtil::format_map_t args; + LLSD args; for(S32 i = 0; i < count; ++i) { msg->getUUIDFast(_PREHASH_AgentBlock, _PREHASH_AgentID, agent_id, i); @@ -652,8 +652,8 @@ void LLAvatarTracker::processNotify(LLMessageSystem* msg, bool online) if(gCacheName->getName(agent_id, first, last)) { notify = TRUE; - args["[FIRST]"] = first; - args["[LAST]"] = last; + args["FIRST"] = first; + args["LAST"] = last; } } } @@ -674,14 +674,14 @@ void LLAvatarTracker::processNotify(LLMessageSystem* msg, bool online) if(notify) { // Popup a notify box with online status of this agent - LLNotifyBox::showXml(online ? "FriendOnline" : "FriendOffline", args); + LLNotificationPtr notification = LLNotifications::instance().add(online ? "FriendOnline" : "FriendOffline", args); // If there's an open IM session with this agent, send a notification there too. LLUUID session_id = LLIMMgr::computeSessionID(IM_NOTHING_SPECIAL, agent_id); LLFloaterIMPanel *floater = gIMMgr->findFloaterBySession(session_id); if (floater) { - LLUIString notifyMsg = LLNotifyBox::getTemplateMessage((online ? "FriendOnline" : "FriendOffline"),args); + std::string notifyMsg = notification->getMessage(); if (!notifyMsg.empty()) floater->addHistoryLine(notifyMsg,gSavedSettings.getColor4("SystemChatColor")); } diff --git a/indra/newview/llcompilequeue.cpp b/indra/newview/llcompilequeue.cpp index e9dbc69bce..299a2cc33a 100644 --- a/indra/newview/llcompilequeue.cpp +++ b/indra/newview/llcompilequeue.cpp @@ -524,9 +524,9 @@ void LLFloaterCompileQueue::onSaveTextComplete(const LLUUID& asset_id, void* use if (status) { llwarns << "Unable to save text for script." << llendl; - LLStringUtil::format_map_t args; - args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); - gViewerWindow->alertXml("CompileQueueSaveText", args); + LLSD args; + args["REASON"] = std::string(LLAssetStorage::getErrorString(status)); + LLNotifications::instance().add("CompileQueueSaveText", args); } } @@ -545,9 +545,9 @@ void LLFloaterCompileQueue::onSaveBytecodeComplete(const LLUUID& asset_id, void* else { llwarns << "Unable to save bytecode for script." << llendl; - LLStringUtil::format_map_t args; - args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); - gViewerWindow->alertXml("CompileQueueSaveBytecode", args); + LLSD args; + args["REASON"] = std::string(LLAssetStorage::getErrorString(status)); + LLNotifications::instance().add("CompileQueueSaveBytecode", args); } delete data; data = NULL; diff --git a/indra/newview/llconfirmationmanager.cpp b/indra/newview/llconfirmationmanager.cpp index 167afb8062..6c465ccf92 100644 --- a/indra/newview/llconfirmationmanager.cpp +++ b/indra/newview/llconfirmationmanager.cpp @@ -45,24 +45,22 @@ LLConfirmationManager::ListenerBase::~ListenerBase() } -static void onConfirmAlert(S32 option, void* data) +static bool onConfirmAlert(const LLSD& notification, const LLSD& response, LLConfirmationManager::ListenerBase* listener) { - LLConfirmationManager::ListenerBase* listener - = (LLConfirmationManager::ListenerBase*)data; - + S32 option = LLNotification::getSelectedOption(notification, response); if (option == 0) { listener->confirmed(""); } delete listener; + return false; } -static void onConfirmAlertPassword( - S32 option, const std::string& text, void* data) +static bool onConfirmAlertPassword(const LLSD& notification, const LLSD& response, LLConfirmationManager::ListenerBase* listener) { - LLConfirmationManager::ListenerBase* listener - = (LLConfirmationManager::ListenerBase*)data; + std::string text = response["message"].asString(); + S32 option = LLNotification::getSelectedOption(notification, response); if (option == 0) { @@ -70,6 +68,7 @@ static void onConfirmAlertPassword( } delete listener; + return false; } @@ -77,22 +76,17 @@ void LLConfirmationManager::confirm(Type type, const std::string& action, ListenerBase* listener) { - LLStringUtil::format_map_t args; - args["[ACTION]"] = action; + LLSD args; + args["ACTION"] = action; switch (type) { case TYPE_CLICK: - gViewerWindow->alertXml("ConfirmPurchase", args, - onConfirmAlert, listener); + LLNotifications::instance().add("ConfirmPurchase", args, LLSD(), boost::bind(onConfirmAlert, _1, _2, listener)); break; case TYPE_PASSWORD: - gViewerWindow->alertXmlEditText("ConfirmPurchasePassword", args, - NULL, NULL, - onConfirmAlertPassword, listener, - LLStringUtil::format_map_t(), - TRUE); + LLNotifications::instance().add("ConfirmPurchasePassword", args, LLSD(), boost::bind(onConfirmAlertPassword, _1, _2, listener)); break; case TYPE_NONE: default: diff --git a/indra/newview/lldelayedgestureerror.cpp b/indra/newview/lldelayedgestureerror.cpp index 832b1b9130..9799bc1240 100644 --- a/indra/newview/lldelayedgestureerror.cpp +++ b/indra/newview/lldelayedgestureerror.cpp @@ -98,18 +98,18 @@ void LLDelayedGestureError::onIdle(void *userdata) //static bool LLDelayedGestureError::doDialog(const LLErrorEntry &ent, bool uuid_ok) { - LLStringUtil::format_map_t args; + LLSD args; LLInventoryItem *item = gInventory.getItem( ent.mItemID ); if ( item ) { - args["[NAME]"] = item->getName(); + args["NAME"] = item->getName(); } else { if ( uuid_ok || ent.mTimer.getElapsedTimeF32() > MAX_NAME_WAIT_TIME ) { - args["[NAME]"] = std::string( ent.mItemID.asString() ); + args["NAME"] = ent.mItemID.asString(); } else { @@ -118,7 +118,7 @@ bool LLDelayedGestureError::doDialog(const LLErrorEntry &ent, bool uuid_ok) } - LLNotifyBox::showXml(ent.mNotifyName, args); + LLNotifications::instance().add(ent.mNotifyName, args); return true; } diff --git a/indra/newview/lleventnotifier.cpp b/indra/newview/lleventnotifier.cpp index 343a572a6a..59f5cd342b 100644 --- a/indra/newview/lleventnotifier.cpp +++ b/indra/newview/lleventnotifier.cpp @@ -77,11 +77,11 @@ void LLEventNotifier::update() if (np->getEventDate() < (alert_time)) { - LLStringUtil::format_map_t args; - args["[NAME]"] = np->getEventName(); - args["[DATE]"] = np->getEventDateStr(); - LLNotifyBox::showXml("EventNotification", args, - notifyCallback, np); + LLSD args; + args["NAME"] = np->getEventName(); + args["DATE"] = np->getEventDateStr(); + LLNotifications::instance().add("EventNotification", args, LLSD(), + boost::bind(&LLEventNotification::handleResponse, np, _1, _2)); mEventNotifications.erase(iter++); } else @@ -173,47 +173,38 @@ void LLEventNotifier::remove(const U32 event_id) mEventNotifications.erase(iter); } -//static -void LLEventNotifier::notifyCallback(S32 option, void *user_data) +LLEventNotification::LLEventNotification() : + mEventID(0), + mEventName("") { - LLEventNotification *np = (LLEventNotification *)user_data; - if (!np) - { - llwarns << "Event notification callback without data!" << llendl; - return; - } +} + + +LLEventNotification::~LLEventNotification() +{ +} + +bool LLEventNotification::handleResponse(const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotification::getSelectedOption(notification, response); switch (option) { case 0: - gAgent.teleportViaLocation(np->getEventPosGlobal()); - gFloaterWorldMap->trackLocation(np->getEventPosGlobal()); + gAgent.teleportViaLocation(getEventPosGlobal()); + gFloaterWorldMap->trackLocation(getEventPosGlobal()); break; case 1: gDisplayEventHack = TRUE; - LLFloaterDirectory::showEvents(np->getEventID()); + LLFloaterDirectory::showEvents(getEventID()); break; case 2: break; } // We could clean up the notification on the server now if we really wanted to. + return false; } - - -LLEventNotification::LLEventNotification() : - mEventID(0), - mEventName(""), - mEventDate(0) -{ -} - - -LLEventNotification::~LLEventNotification() -{ -} - - BOOL LLEventNotification::load(const LLUserAuth::response_t &response) { diff --git a/indra/newview/lleventnotifier.h b/indra/newview/lleventnotifier.h index bbd1facf31..ac906521d2 100644 --- a/indra/newview/lleventnotifier.h +++ b/indra/newview/lleventnotifier.h @@ -56,7 +56,6 @@ public: typedef std::map<U32, LLEventNotification *> en_map; - static void notifyCallback(S32 option, void *user_data); protected: en_map mEventNotifications; LLFrameTimer mNotificationTimer; @@ -78,6 +77,7 @@ public: time_t getEventDate() const { return mEventDate; } const std::string &getEventDateStr() const { return mEventDateStr; } LLVector3d getEventPosGlobal() const { return mEventPosGlobal; } + bool handleResponse(const LLSD& notification, const LLSD& payload); protected: U32 mEventID; // EventID for this event std::string mEventName; diff --git a/indra/newview/llfirstuse.cpp b/indra/newview/llfirstuse.cpp index 475473abe7..fce4d41207 100644 --- a/indra/newview/llfirstuse.cpp +++ b/indra/newview/llfirstuse.cpp @@ -85,9 +85,9 @@ void LLFirstUse::useBalanceIncrease(S32 delta) { gSavedSettings.setWarning("FirstBalanceIncrease", FALSE); - LLStringUtil::format_map_t args; - args["[AMOUNT]"] = llformat("%d",delta); - LLNotifyBox::showXml("FirstBalanceIncrease", args); + LLSD args; + args["AMOUNT"] = llformat("%d",delta); + LLNotifications::instance().add("FirstBalanceIncrease", args); } } @@ -99,9 +99,9 @@ void LLFirstUse::useBalanceDecrease(S32 delta) { gSavedSettings.setWarning("FirstBalanceDecrease", FALSE); - LLStringUtil::format_map_t args; - args["[AMOUNT]"] = llformat("%d",-delta); - LLNotifyBox::showXml("FirstBalanceDecrease", args); + LLSD args; + args["AMOUNT"] = llformat("%d",-delta); + LLNotifications::instance().add("FirstBalanceDecrease", args); } } @@ -114,8 +114,8 @@ void LLFirstUse::useSit() //if (gSavedSettings.getWarning("FirstSit")) //{ // gSavedSettings.setWarning("FirstSit", FALSE); - - // LLNotifyBox::showXml("FirstSit"); + // + // LLNotifications::instance().add("FirstSit"); //} } @@ -126,7 +126,7 @@ void LLFirstUse::useMap() { gSavedSettings.setWarning("FirstMap", FALSE); - LLNotifyBox::showXml("FirstMap"); + LLNotifications::instance().add("FirstMap"); } } @@ -143,7 +143,7 @@ void LLFirstUse::useBuild() { gSavedSettings.setWarning("FirstBuild", FALSE); - LLNotifyBox::showXml("FirstBuild"); + LLNotifications::instance().add("FirstBuild"); } } @@ -154,7 +154,7 @@ void LLFirstUse::useLeftClickNoHit() { gSavedSettings.setWarning("FirstLeftClickNoHit", FALSE); - LLNotifyBox::showXml("FirstLeftClickNoHit"); + LLNotifications::instance().add("FirstLeftClickNoHit"); } } @@ -168,7 +168,7 @@ void LLFirstUse::useTeleport() { gSavedSettings.setWarning("FirstTeleport", FALSE); - LLNotifyBox::showXml("FirstTeleport"); + LLNotifications::instance().add("FirstTeleport"); } } } @@ -184,7 +184,7 @@ void LLFirstUse::useOverrideKeys() { gSavedSettings.setWarning("FirstOverrideKeys", FALSE); - LLNotifyBox::showXml("FirstOverrideKeys"); + LLNotifications::instance().add("FirstOverrideKeys"); } } } @@ -202,7 +202,7 @@ void LLFirstUse::useAppearance() { gSavedSettings.setWarning("FirstAppearance", FALSE); - LLNotifyBox::showXml("FirstAppearance"); + LLNotifications::instance().add("FirstAppearance"); } } @@ -213,7 +213,7 @@ void LLFirstUse::useInventory() { gSavedSettings.setWarning("FirstInventory", FALSE); - LLNotifyBox::showXml("FirstInventory"); + LLNotifications::instance().add("FirstInventory"); } } @@ -225,10 +225,10 @@ void LLFirstUse::useSandbox() { gSavedSettings.setWarning("FirstSandbox", FALSE); - LLStringUtil::format_map_t args; - args["[HOURS]"] = llformat("%d",SANDBOX_CLEAN_FREQ); - args["[TIME]"] = llformat("%d",SANDBOX_FIRST_CLEAN_HOUR); - LLNotifyBox::showXml("FirstSandbox", args); + LLSD args; + args["HOURS"] = llformat("%d",SANDBOX_CLEAN_FREQ); + args["TIME"] = llformat("%d",SANDBOX_FIRST_CLEAN_HOUR); + LLNotifications::instance().add("FirstSandbox", args); } } @@ -239,7 +239,7 @@ void LLFirstUse::useFlexible() { gSavedSettings.setWarning("FirstFlexible", FALSE); - LLNotifyBox::showXml("FirstFlexible"); + LLNotifications::instance().add("FirstFlexible"); } } @@ -250,7 +250,7 @@ void LLFirstUse::useDebugMenus() { gSavedSettings.setWarning("FirstDebugMenus", FALSE); - LLNotifyBox::showXml("FirstDebugMenus"); + LLNotifications::instance().add("FirstDebugMenus"); } } @@ -261,7 +261,7 @@ void LLFirstUse::useSculptedPrim() { gSavedSettings.setWarning("FirstSculptedPrim", FALSE); - LLNotifyBox::showXml("FirstSculptedPrim"); + LLNotifications::instance().add("FirstSculptedPrim"); } } @@ -273,6 +273,6 @@ void LLFirstUse::useMedia() { gSavedSettings.setWarning("FirstMedia", FALSE); - LLNotifyBox::showXml("FirstMedia"); + LLNotifications::instance().add("FirstMedia"); } } diff --git a/indra/newview/llfloateranimpreview.cpp b/indra/newview/llfloateranimpreview.cpp index c7e35bcfb5..a84026e132 100644 --- a/indra/newview/llfloateranimpreview.cpp +++ b/indra/newview/llfloateranimpreview.cpp @@ -1001,7 +1001,7 @@ void LLFloaterAnimPreview::onBtnOK(void* userdata) else { llwarns << "Failure writing animation data." << llendl; - gViewerWindow->alertXml("WriteAnimationFail"); + LLNotifications::instance().add("WriteAnimationFail"); } } diff --git a/indra/newview/llfloaterauction.cpp b/indra/newview/llfloaterauction.cpp index a90d11f6ea..100c6ee20d 100644 --- a/indra/newview/llfloaterauction.cpp +++ b/indra/newview/llfloaterauction.cpp @@ -238,7 +238,7 @@ void LLFloaterAuction::onClickOK(void* data) FALSE); self->getWindow()->incBusyCount(); - LLNotifyBox::showXml("UploadingAuctionSnapshot"); + LLNotifications::instance().add("UploadingAuctionSnapshot"); } LLMessageSystem* msg = gMessageSystem; @@ -277,13 +277,13 @@ void auction_tga_upload_done(const LLUUID& asset_id, void* user_data, S32 status if (0 == status) { - LLNotifyBox::showXml("UploadWebSnapshotDone"); + LLNotifications::instance().add("UploadWebSnapshotDone"); } else { - LLStringUtil::format_map_t args; - args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); - gViewerWindow->alertXml("UploadAuctionSnapshotFail", args); + LLSD args; + args["REASON"] = std::string(LLAssetStorage::getErrorString(status)); + LLNotifications::instance().add("UploadAuctionSnapshotFail", args); } } @@ -298,12 +298,12 @@ void auction_j2c_upload_done(const LLUUID& asset_id, void* user_data, S32 status if (0 == status) { - LLNotifyBox::showXml("UploadSnapshotDone"); + LLNotifications::instance().add("UploadSnapshotDone"); } else { - LLStringUtil::format_map_t args; - args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); - gViewerWindow->alertXml("UploadAuctionSnapshotFail", args); + LLSD args; + args["REASON"] = std::string(LLAssetStorage::getErrorString(status)); + LLNotifications::instance().add("UploadAuctionSnapshotFail", args); } } diff --git a/indra/newview/llfloaterbuy.cpp b/indra/newview/llfloaterbuy.cpp index 9edb0afb5c..5bdb4a2374 100644 --- a/indra/newview/llfloaterbuy.cpp +++ b/indra/newview/llfloaterbuy.cpp @@ -86,7 +86,7 @@ void LLFloaterBuy::show(const LLSaleInfo& sale_info) if (selection->getRootObjectCount() != 1) { - gViewerWindow->alertXml("BuyOneObjectOnly"); + LLNotifications::instance().add("BuyOneObjectOnly"); return; } @@ -136,7 +136,7 @@ void LLFloaterBuy::show(const LLSaleInfo& sale_info) BOOL owners_identical = LLSelectMgr::getInstance()->selectGetOwner(owner_id, owner_name); if (!owners_identical) { - gViewerWindow->alertXml("BuyObjectOneOwner"); + LLNotifications::instance().add("BuyObjectOneOwner"); return; } diff --git a/indra/newview/llfloaterbuycontents.cpp b/indra/newview/llfloaterbuycontents.cpp index d74707f6b1..1dd12413cc 100644 --- a/indra/newview/llfloaterbuycontents.cpp +++ b/indra/newview/llfloaterbuycontents.cpp @@ -83,7 +83,7 @@ void LLFloaterBuyContents::show(const LLSaleInfo& sale_info) if (selection->getRootObjectCount() != 1) { - gViewerWindow->alertXml("BuyContentsOneOnly"); + LLNotifications::instance().add("BuyContentsOneOnly"); return; } @@ -113,7 +113,7 @@ void LLFloaterBuyContents::show(const LLSaleInfo& sale_info) BOOL owners_identical = LLSelectMgr::getInstance()->selectGetOwner(owner_id, owner_name); if (!owners_identical) { - gViewerWindow->alertXml("BuyContentsOneOwner"); + LLNotifications::instance().add("BuyContentsOneOwner"); return; } diff --git a/indra/newview/llfloaterbuyland.cpp b/indra/newview/llfloaterbuyland.cpp index 7aa6af2fea..65cea37a0f 100644 --- a/indra/newview/llfloaterbuyland.cpp +++ b/indra/newview/llfloaterbuyland.cpp @@ -213,7 +213,7 @@ void LLFloaterBuyLand::buyLand( { if(is_for_group && !gAgent.hasPowerInActiveGroup(GP_LAND_DEED)) { - gViewerWindow->alertXml("OnlyOfficerCanBuyLand"); + LLNotifications::instance().add("OnlyOfficerCanBuyLand"); return; } @@ -976,7 +976,7 @@ BOOL LLFloaterBuyLandUI::canClose() if (!can_close) { // explain to user why they can't do this, see DEV-9605 - gViewerWindow->alertXml("CannotCloseFloaterBuyLand"); + LLNotifications::instance().add("CannotCloseFloaterBuyLand"); } return can_close; } diff --git a/indra/newview/llfloaterdaycycle.cpp b/indra/newview/llfloaterdaycycle.cpp index af42a92ed8..de308b5425 100644 --- a/indra/newview/llfloaterdaycycle.cpp +++ b/indra/newview/llfloaterdaycycle.cpp @@ -98,17 +98,9 @@ LLFloaterDayCycle::~LLFloaterDayCycle() void LLFloaterDayCycle::onClickHelp(void* data) { LLFloaterDayCycle* self = LLFloaterDayCycle::instance(); - const std::string* xml_alert = (std::string*)data; - LLAlertDialog* dialogp = gViewerWindow->alertXml(*xml_alert); - if (dialogp) - { - LLFloater* root_floater = gFloaterView->getParentFloater(self); - if (root_floater) - { - root_floater->addDependentFloater(dialogp); - } - } + std::string xml_alert = *(std::string *) data; + LLNotifications::instance().add(self->contextualNotification(xml_alert)); } void LLFloaterDayCycle::initHelpBtn(const std::string& name, const std::string& xml_alert) diff --git a/indra/newview/llfloaterenvsettings.cpp b/indra/newview/llfloaterenvsettings.cpp index b28cc04047..90225ecfa1 100644 --- a/indra/newview/llfloaterenvsettings.cpp +++ b/indra/newview/llfloaterenvsettings.cpp @@ -67,18 +67,8 @@ LLFloaterEnvSettings::~LLFloaterEnvSettings() void LLFloaterEnvSettings::onClickHelp(void* data) { - LLFloaterEnvSettings* self = static_cast<LLFloaterEnvSettings*>(data); - - const char* xml_alert = "EnvSettingsHelpButton"; - LLAlertDialog* dialogp = gViewerWindow->alertXml(xml_alert); - if (dialogp) - { - LLFloater* root_floater = gFloaterView->getParentFloater(self); - if (root_floater) - { - root_floater->addDependentFloater(dialogp); - } - } + LLFloaterEnvSettings* self = (LLFloaterEnvSettings*)data; + LLNotifications::instance().add(self->contextualNotification("EnvSettingsHelpButton")); } void LLFloaterEnvSettings::initCallbacks(void) diff --git a/indra/newview/llfloaterfriends.cpp b/indra/newview/llfloaterfriends.cpp index 2d7d2ee15d..f5493172ba 100644 --- a/indra/newview/llfloaterfriends.cpp +++ b/indra/newview/llfloaterfriends.cpp @@ -523,9 +523,9 @@ void LLPanelFriends::onSelectName(LLUICtrl* ctrl, void* user_data) //static void LLPanelFriends::onMaximumSelect(void* user_data) { - LLStringUtil::format_map_t args; - args["[MAX_SELECT]"] = llformat("%d", MAX_FRIEND_SELECT); - LLNotifyBox::showXml("MaxListSelectMessage", args); + LLSD args; + args["MAX_SELECT"] = llformat("%d", MAX_FRIEND_SELECT); + LLNotifications::instance().add("MaxListSelectMessage", args); }; // static @@ -585,27 +585,22 @@ void LLPanelFriends::requestFriendship(const LLUUID& target_id, const std::strin calling_card_folder_id); } -struct LLAddFriendData -{ - LLUUID mID; - std::string mName; -}; - // static -void LLPanelFriends::callbackAddFriendWithMessage(S32 option, const std::string& text, void* data) +bool LLPanelFriends::callbackAddFriendWithMessage(const LLSD& notification, const LLSD& response) { - LLAddFriendData* add = (LLAddFriendData*)data; + S32 option = LLNotification::getSelectedOption(notification, response); if (option == 0) { - requestFriendship(add->mID, add->mName, text); + requestFriendship(notification["payload"]["id"].asUUID(), + notification["payload"]["name"].asString(), + response["message"].asString()); } - delete add; + return false; } -// static -void LLPanelFriends::callbackAddFriend(S32 option, void* data) +bool LLPanelFriends::callbackAddFriend(const LLSD& notification, const LLSD& response) { - LLAddFriendData* add = (LLAddFriendData*)data; + S32 option = LLNotification::getSelectedOption(notification, response); if (option == 0) { // Servers older than 1.25 require the text of the message to be the @@ -613,9 +608,11 @@ void LLPanelFriends::callbackAddFriend(S32 option, void* data) LLUUID calling_card_folder_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_CALLINGCARD); std::string message = calling_card_folder_id.asString(); - requestFriendship(add->mID, add->mName, message); + requestFriendship(notification["payload"]["id"].asUUID(), + notification["payload"]["name"].asString(), + message); } - delete add; + return false; } // static @@ -634,27 +631,25 @@ void LLPanelFriends::requestFriendshipDialog(const LLUUID& id, { if(id == gAgentID) { - LLNotifyBox::showXml("AddSelfFriend"); + LLNotifications::instance().add("AddSelfFriend"); return; } - LLAddFriendData* data = new LLAddFriendData(); - data->mID = id; - data->mName = name; - - LLStringUtil::format_map_t args; - args["[NAME]"] = name; - - // Look for server versions like: Second Life Server 1.24.4.95600 + LLSD args; + args["NAME"] = name; + LLSD payload; + payload["id"] = id; + payload["name"] = name; + // Look for server versions like: Second Life Server 1.24.4.95600 if (gLastVersionChannel.find(" 1.24.") != std::string::npos) { // Old and busted server version, doesn't support friend // requests with messages. - gViewerWindow->alertXml("AddFriend", args, callbackAddFriend, data); + LLNotifications::instance().add("AddFriend", args, payload, &callbackAddFriend); } else { - gViewerWindow->alertXmlEditText("AddFriendWithMessage", args, NULL, NULL, callbackAddFriendWithMessage, data); + LLNotifications::instance().add("AddFriendWithMessage", args, payload, &callbackAddFriendWithMessage); } } @@ -677,7 +672,7 @@ void LLPanelFriends::onClickRemove(void* user_data) //llinfos << "LLPanelFriends::onClickRemove()" << llendl; LLDynamicArray<LLUUID> ids = panelp->getSelectedIDs(); - LLStringUtil::format_map_t args; + LLSD args; if(ids.size() > 0) { std::string msgType = "RemoveFromFriends"; @@ -687,18 +682,27 @@ void LLPanelFriends::onClickRemove(void* user_data) std::string first, last; if(gCacheName->getName(agent_id, first, last)) { - args["[FIRST_NAME]"] = first; - args["[LAST_NAME]"] = last; + args["FIRST_NAME"] = first; + args["LAST_NAME"] = last; } } else { msgType = "RemoveMultipleFromFriends"; } - gViewerWindow->alertXml(msgType, + LLSD payload; + + for (LLDynamicArray<LLUUID>::iterator it = ids.begin(); + it != ids.end(); + ++it) + { + payload["ids"].append(*it); + } + + LLNotifications::instance().add(msgType, args, - &handleRemove, - (void*)new LLDynamicArray<LLUUID>(ids)); + payload, + &handleRemove); } } @@ -730,13 +734,10 @@ void LLPanelFriends::confirmModifyRights(rights_map_t& ids, EGrantRevoke command { if (ids.empty()) return; - LLStringUtil::format_map_t args; + LLSD args; if(ids.size() > 0) { - // copy map of ids onto heap - rights_map_t* rights = new rights_map_t(ids); - // package with panel pointer - std::pair<LLPanelFriends*, rights_map_t*>* user_data = new std::pair<LLPanelFriends*, rights_map_t*>(this, rights); + rights_map_t* rights = new rights_map_t(ids); // for single friend, show their name if(ids.size() == 1) @@ -745,62 +746,65 @@ void LLPanelFriends::confirmModifyRights(rights_map_t& ids, EGrantRevoke command std::string first, last; if(gCacheName->getName(agent_id, first, last)) { - args["[FIRST_NAME]"] = first; - args["[LAST_NAME]"] = last; + args["FIRST_NAME"] = first; + args["LAST_NAME"] = last; } if (command == GRANT) { - gViewerWindow->alertXml("GrantModifyRights", args, modifyRightsConfirmation, user_data); + LLNotifications::instance().add("GrantModifyRights", + args, + LLSD(), + boost::bind(&LLPanelFriends::modifyRightsConfirmation, this, _1, _2, rights)); } else { - gViewerWindow->alertXml("RevokeModifyRights", args, modifyRightsConfirmation, user_data); + LLNotifications::instance().add("RevokeModifyRights", + args, + LLSD(), + boost::bind(&LLPanelFriends::modifyRightsConfirmation, this, _1, _2, rights)); } } else { if (command == GRANT) { - gViewerWindow->alertXml("GrantModifyRightsMultiple", args, modifyRightsConfirmation, user_data); + LLNotifications::instance().add("GrantModifyRightsMultiple", + args, + LLSD(), + boost::bind(&LLPanelFriends::modifyRightsConfirmation, this, _1, _2, rights)); } else { - gViewerWindow->alertXml("RevokeModifyRightsMultiple", args, modifyRightsConfirmation, user_data); + LLNotifications::instance().add("RevokeModifyRightsMultiple", + args, + LLSD(), + boost::bind(&LLPanelFriends::modifyRightsConfirmation, this, _1, _2, rights)); } } } } -// static -void LLPanelFriends::modifyRightsConfirmation(S32 option, void* user_data) +bool LLPanelFriends::modifyRightsConfirmation(const LLSD& notification, const LLSD& response, rights_map_t* rights) { - std::pair<LLPanelFriends*, rights_map_t*>* data = (std::pair<LLPanelFriends*, rights_map_t*>*)user_data; - LLPanelFriends* panelp = data->first; - - if(panelp) + S32 option = LLNotification::getSelectedOption(notification, response); + if(0 == option) { - if(0 == option) - { - panelp->sendRightsGrant(*(data->second)); - } - else + sendRightsGrant(*rights); + } + else + { + // need to resync view with model, since user cancelled operation + rights_map_t::iterator rights_it; + for (rights_it = rights->begin(); rights_it != rights->end(); ++rights_it) { - // need to resync view with model, since user cancelled operation - rights_map_t* rights = data->second; - rights_map_t::iterator rights_it; - for (rights_it = rights->begin(); rights_it != rights->end(); ++rights_it) - { - const LLRelationship* info = LLAvatarTracker::instance().getBuddyInfo(rights_it->first); - panelp->updateFriendItem(rights_it->first, info); - // Might have changed the column the user is sorted on. - panelp->mFriendsList->sortItems(); - } + const LLRelationship* info = LLAvatarTracker::instance().getBuddyInfo(rights_it->first); + updateFriendItem(rights_it->first, info); } - panelp->refreshUI(); } + refreshUI(); - delete data->second; - delete data; + delete rights; + return false; } void LLPanelFriends::applyRightsToFriends() @@ -924,12 +928,14 @@ void LLPanelFriends::sendRightsGrant(rights_map_t& ids) // static -void LLPanelFriends::handleRemove(S32 option, void* user_data) +bool LLPanelFriends::handleRemove(const LLSD& notification, const LLSD& response) { - LLDynamicArray<LLUUID>* ids = static_cast<LLDynamicArray<LLUUID>*>(user_data); - for(LLDynamicArray<LLUUID>::iterator itr = ids->begin(); itr != ids->end(); ++itr) + S32 option = LLNotification::getSelectedOption(notification, response); + + const LLSD& ids = notification["payload"]["ids"]; + for(LLSD::array_const_iterator itr = ids.beginArray(); itr != ids.endArray(); ++itr) { - LLUUID id = (*itr); + LLUUID id = itr->asUUID(); const LLRelationship* ip = LLAvatarTracker::instance().getBuddyInfo(id); if(ip) { @@ -955,5 +961,5 @@ void LLPanelFriends::handleRemove(S32 option, void* user_data) } } - delete ids; + return false; } diff --git a/indra/newview/llfloaterfriends.h b/indra/newview/llfloaterfriends.h index e3f3f96d00..58f7cc3bb2 100644 --- a/indra/newview/llfloaterfriends.h +++ b/indra/newview/llfloaterfriends.h @@ -119,8 +119,8 @@ private: // callback methods static void onSelectName(LLUICtrl* ctrl, void* user_data); - static void callbackAddFriendWithMessage(S32 option, const std::string& text, void* user_data); - static void callbackAddFriend(S32 option, void* user_data); + static bool callbackAddFriend(const LLSD& notification, const LLSD& response); + static bool callbackAddFriendWithMessage(const LLSD& notification, const LLSD& response); static void onPickAvatar(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* user_data); static void onMaximumSelect(void* user_data); @@ -134,8 +134,8 @@ private: static void onClickModifyStatus(LLUICtrl* ctrl, void* user_data); - static void handleRemove(S32 option, void* user_data); - static void modifyRightsConfirmation(S32 option, void* user_data); + static bool handleRemove(const LLSD& notification, const LLSD& response); + bool modifyRightsConfirmation(const LLSD& notification, const LLSD& response, rights_map_t* rights); private: // member data diff --git a/indra/newview/llfloatergodtools.cpp b/indra/newview/llfloatergodtools.cpp index a4022d844a..c1eb273acc 100644 --- a/indra/newview/llfloatergodtools.cpp +++ b/indra/newview/llfloatergodtools.cpp @@ -918,34 +918,31 @@ void LLPanelGridTools::refresh() // static void LLPanelGridTools::onClickKickAll(void* userdata) { - LLPanelGridTools* self = (LLPanelGridTools*) userdata; - S32 left, top; gFloaterView->getNewFloaterPosition(&left, &top); LLRect rect(left, top, left+400, top-300); - gViewerWindow->alertXmlEditText("KickAllUsers", LLStringUtil::format_map_t(), - NULL, NULL, - LLPanelGridTools::confirmKick, self); + LLNotifications::instance().add("KickAllUsers", LLSD(), LLSD(), LLPanelGridTools::confirmKick); } -void LLPanelGridTools::confirmKick(S32 option, const std::string& text, void* userdata) +bool LLPanelGridTools::confirmKick(const LLSD& notification, const LLSD& response) { - LLPanelGridTools* self = (LLPanelGridTools*) userdata; - - if (option == 0) + if (LLNotification::getSelectedOption(notification, response) == 0) { - self->mKickMessage = text; - gViewerWindow->alertXml("ConfirmKick",LLPanelGridTools::finishKick, self); + LLSD payload; + payload["kick_message"] = response["message"].asString(); + LLNotifications::instance().add("ConfirmKick", LLSD(), payload, LLPanelGridTools::finishKick); } + return false; } // static -void LLPanelGridTools::finishKick(S32 option, void* userdata) +bool LLPanelGridTools::finishKick(const LLSD& notification, const LLSD& response) { - LLPanelGridTools* self = (LLPanelGridTools*) userdata; + S32 option = LLNotification::getSelectedOption(notification, response); + if (option == 0) { @@ -957,26 +954,24 @@ void LLPanelGridTools::finishKick(S32 option, void* userdata) msg->addUUIDFast(_PREHASH_GodSessionID, gAgent.getSessionID()); msg->addUUIDFast(_PREHASH_AgentID, LL_UUID_ALL_AGENTS ); msg->addU32("KickFlags", KICK_FLAGS_DEFAULT ); - msg->addStringFast(_PREHASH_Reason, self->mKickMessage ); + msg->addStringFast(_PREHASH_Reason, notification["payload"]["kick_message"].asString()); gAgent.sendReliableMessage(); } + return false; } // static void LLPanelGridTools::onClickFlushMapVisibilityCaches(void* data) { - gViewerWindow->alertXml("FlushMapVisibilityCaches", - flushMapVisibilityCachesConfirm, data); + LLNotifications::instance().add("FlushMapVisibilityCaches", LLSD(), LLSD(), flushMapVisibilityCachesConfirm); } // static -void LLPanelGridTools::flushMapVisibilityCachesConfirm(S32 option, void* data) +bool LLPanelGridTools::flushMapVisibilityCachesConfirm(const LLSD& notification, const LLSD& response) { - if (option != 0) return; - - LLPanelGridTools* self = (LLPanelGridTools*)data; - if (!self) return; + S32 option = LLNotification::getSelectedOption(notification, response); + if (option != 0) return false; // HACK: Send this as an EstateOwnerRequest so it gets routed // correctly by the spaceserver. JC @@ -992,6 +987,7 @@ void LLPanelGridTools::flushMapVisibilityCachesConfirm(S32 option, void* data) msg->nextBlock("ParamList"); msg->addString("Parameter", gAgent.getID().asString()); gAgent.sendReliableMessage(); + return false; } @@ -1182,13 +1178,16 @@ void LLPanelObjectTools::onClickDeletePublicOwnedBy(void* userdata) panelp->mSimWideDeletesFlags = SWD_SCRIPTED_ONLY | SWD_OTHERS_LAND_ONLY; - LLStringUtil::format_map_t args; - args["[AVATAR_NAME]"] = panelp->childGetValue("target_avatar_name").asString(); + LLSD args; + args["AVATAR_NAME"] = panelp->childGetValue("target_avatar_name").asString(); + LLSD payload; + payload["avatar_id"] = panelp->mTargetAvatar; + payload["flags"] = (S32)panelp->mSimWideDeletesFlags; - gViewerWindow->alertXml( "GodDeleteAllScriptedPublicObjectsByUser", + LLNotifications::instance().add( "GodDeleteAllScriptedPublicObjectsByUser", args, - callbackSimWideDeletes, - userdata); + payload, + callbackSimWideDeletes); } } @@ -1201,13 +1200,16 @@ void LLPanelObjectTools::onClickDeleteAllScriptedOwnedBy(void* userdata) { panelp->mSimWideDeletesFlags = SWD_SCRIPTED_ONLY; - LLStringUtil::format_map_t args; - args["[AVATAR_NAME]"] = panelp->childGetValue("target_avatar_name").asString(); + LLSD args; + args["AVATAR_NAME"] = panelp->childGetValue("target_avatar_name").asString(); + LLSD payload; + payload["avatar_id"] = panelp->mTargetAvatar; + payload["flags"] = (S32)panelp->mSimWideDeletesFlags; - gViewerWindow->alertXml( "GodDeleteAllScriptedObjectsByUser", + LLNotifications::instance().add( "GodDeleteAllScriptedObjectsByUser", args, - callbackSimWideDeletes, - userdata); + payload, + callbackSimWideDeletes); } } @@ -1220,28 +1222,32 @@ void LLPanelObjectTools::onClickDeleteAllOwnedBy(void* userdata) { panelp->mSimWideDeletesFlags = 0; - LLStringUtil::format_map_t args; - args["[AVATAR_NAME]"] = panelp->childGetValue("target_avatar_name").asString(); + LLSD args; + args["AVATAR_NAME"] = panelp->childGetValue("target_avatar_name").asString(); + LLSD payload; + payload["avatar_id"] = panelp->mTargetAvatar; + payload["flags"] = (S32)panelp->mSimWideDeletesFlags; - gViewerWindow->alertXml( "GodDeleteAllObjectsByUser", + LLNotifications::instance().add( "GodDeleteAllObjectsByUser", args, - callbackSimWideDeletes, - userdata); + payload, + callbackSimWideDeletes); } } // static -void LLPanelObjectTools::callbackSimWideDeletes( S32 option, void* userdata ) +bool LLPanelObjectTools::callbackSimWideDeletes( const LLSD& notification, const LLSD& response ) { + S32 option = LLNotification::getSelectedOption(notification, response); if (option == 0) { - LLPanelObjectTools* object_tools = (LLPanelObjectTools*) userdata; - if (!object_tools->mTargetAvatar.isNull()) + if (!notification["payload"]["avatar_id"].asUUID().isNull()) { - send_sim_wide_deletes(object_tools->mTargetAvatar, - object_tools->mSimWideDeletesFlags); + send_sim_wide_deletes(notification["payload"]["avatar_id"].asUUID(), + notification["payload"]["flags"].asInteger()); } } + return false; } void LLPanelObjectTools::onClickSet(void* data) @@ -1420,7 +1426,7 @@ void LLPanelRequestTools::onClickRequest(void* data) void terrain_download_done(void** data, S32 status, LLExtStat ext_status) { - LLNotifyBox::showXml("TerrainDownloaded"); + LLNotifications::instance().add("TerrainDownloaded"); } diff --git a/indra/newview/llfloatergodtools.h b/indra/newview/llfloatergodtools.h index 7cc840cc97..b70b9d795d 100644 --- a/indra/newview/llfloatergodtools.h +++ b/indra/newview/llfloatergodtools.h @@ -201,11 +201,11 @@ public: void refresh(); static void onClickKickAll(void *data); - static void confirmKick(S32 option, const std::string& text, void* userdata); - static void finishKick(S32 option, void* userdata); + static bool confirmKick(const LLSD& notification, const LLSD& response); + static bool finishKick(const LLSD& notification, const LLSD& response); static void onDragSunPhase(LLUICtrl *ctrl, void *userdata); static void onClickFlushMapVisibilityCaches(void* data); - static void flushMapVisibilityCachesConfirm(S32 option, void* data); + static bool flushMapVisibilityCachesConfirm(const LLSD& notification, const LLSD& response); protected: std::string mKickMessage; // Message to send on kick @@ -240,7 +240,7 @@ public: static void onClickDeletePublicOwnedBy(void* data); static void onClickDeleteAllScriptedOwnedBy(void* data); static void onClickDeleteAllOwnedBy(void* data); - static void callbackSimWideDeletes(S32 option, void* userdata); + static bool callbackSimWideDeletes(const LLSD& notification, const LLSD& response); static void onGetTopColliders(void* data); static void onGetTopScripts(void* data); static void onGetScriptDigest(void* data); diff --git a/indra/newview/llfloatergroups.cpp b/indra/newview/llfloatergroups.cpp index ca3332e4ad..e798327bb7 100644 --- a/indra/newview/llfloatergroups.cpp +++ b/indra/newview/llfloatergroups.cpp @@ -388,10 +388,11 @@ void LLPanelGroups::leave() } if(i < count) { - LLUUID* cb_data = new LLUUID((const LLUUID&)group_id); - LLStringUtil::format_map_t args; - args["[GROUP]"] = gAgent.mGroups.get(i).mName; - gViewerWindow->alertXml("GroupLeaveConfirmMember", args, callbackLeaveGroup, (void*)cb_data); + LLSD args; + args["GROUP"] = gAgent.mGroups.get(i).mName; + LLSD payload; + payload["group_id"] = group_id; + LLNotifications::instance().add("GroupLeaveConfirmMember", args, payload, callbackLeaveGroup); } } } @@ -402,10 +403,11 @@ void LLPanelGroups::search() } // static -void LLPanelGroups::callbackLeaveGroup(S32 option, void* userdata) +bool LLPanelGroups::callbackLeaveGroup(const LLSD& notification, const LLSD& response) { - LLUUID* group_id = (LLUUID*)userdata; - if(option == 0 && group_id) + S32 option = LLNotification::getSelectedOption(notification, response); + LLUUID group_id = notification["payload"]["group_id"].asUUID(); + if(option == 0) { LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_LeaveGroupRequest); @@ -413,10 +415,10 @@ void LLPanelGroups::callbackLeaveGroup(S32 option, void* userdata) msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->nextBlockFast(_PREHASH_GroupData); - msg->addUUIDFast(_PREHASH_GroupID, *group_id); + msg->addUUIDFast(_PREHASH_GroupID, group_id); gAgent.sendReliableMessage(); } - delete group_id; + return false; } void LLPanelGroups::onGroupList(LLUICtrl* ctrl, void* userdata) diff --git a/indra/newview/llfloatergroups.h b/indra/newview/llfloatergroups.h index 6d99f34085..a94b143d39 100644 --- a/indra/newview/llfloatergroups.h +++ b/indra/newview/llfloatergroups.h @@ -120,7 +120,7 @@ protected: void search(); void callVote(); - static void callbackLeaveGroup(S32 option, void* userdata); + static bool callbackLeaveGroup(const LLSD& notification, const LLSD& response); }; diff --git a/indra/newview/llfloaterhardwaresettings.cpp b/indra/newview/llfloaterhardwaresettings.cpp index e4c13b2ae4..1db153434f 100644 --- a/indra/newview/llfloaterhardwaresettings.cpp +++ b/indra/newview/llfloaterhardwaresettings.cpp @@ -62,7 +62,7 @@ LLFloaterHardwareSettings::~LLFloaterHardwareSettings() void LLFloaterHardwareSettings::onClickHelp(void* data) { const char* xml_alert = "HardwareSettingsHelpButton"; - gViewerWindow->alertXml(xml_alert); + LLNotifications::instance().add(xml_alert); } void LLFloaterHardwareSettings::initCallbacks(void) diff --git a/indra/newview/llfloaterhud.cpp b/indra/newview/llfloaterhud.cpp index 848068ee9d..8c97628e4e 100644 --- a/indra/newview/llfloaterhud.cpp +++ b/indra/newview/llfloaterhud.cpp @@ -102,7 +102,7 @@ void LLFloaterHUD::showHUD() // do not build the floater if there the url is empty if (gSavedSettings.getString("TutorialURL") == "") { - LLAlertDialog::showXml("TutorialNotFound"); + LLNotifications::instance().add("TutorialNotFound"); return; } diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp index a92634bc31..8b4b3805ee 100644 --- a/indra/newview/llfloaterland.cpp +++ b/indra/newview/llfloaterland.cpp @@ -85,8 +85,6 @@ static const BOOL BUY_PERSONAL_LAND = FALSE; LLParcelSelectionObserver* LLFloaterLand::sObserver = NULL; S32 LLFloaterLand::sLastTab = 0; -LLHandle<LLFloater> LLPanelLandGeneral::sBuyPassDialogHandle; - // Local classes class LLParcelSelectionObserver : public LLParcelObserver { @@ -872,12 +870,12 @@ void LLPanelLandGeneral::onClickBuyPass(void* data) cost = llformat("%d", pass_price); time = llformat("%.2f", pass_hours); - LLStringUtil::format_map_t args; - args["[COST]"] = cost; - args["[PARCEL_NAME]"] = parcel_name; - args["[TIME]"] = time; + LLSD args; + args["COST"] = cost; + args["PARCEL_NAME"] = parcel_name; + args["TIME"] = time; - sBuyPassDialogHandle = gViewerWindow->alertXml("LandBuyPass", args, cbBuyPass)->getHandle(); + LLNotifications::instance().add("LandBuyPass", args, LLSD(), cbBuyPass); } // static @@ -889,7 +887,7 @@ void LLPanelLandGeneral::onClickStartAuction(void* data) { if(parcelp->getForSale()) { - gViewerWindow->alertXml("CannotStartAuctionAlreadForSale"); + LLNotifications::instance().add("CannotStartAuctionAlreadForSale"); } else { @@ -899,19 +897,15 @@ void LLPanelLandGeneral::onClickStartAuction(void* data) } // static -void LLPanelLandGeneral::cbBuyPass(S32 option, void* data) +bool LLPanelLandGeneral::cbBuyPass(const LLSD& notification, const LLSD& response) { + S32 option = LLNotification::getSelectedOption(notification, response); if (0 == option) { // User clicked OK LLViewerParcelMgr::getInstance()->buyPass(); } -} - -//static -BOOL LLPanelLandGeneral::buyPassDialogVisible() -{ - return sBuyPassDialogHandle.get() != NULL; + return false; } // static @@ -1249,28 +1243,27 @@ void send_return_objects_message(S32 parcel_local_id, S32 return_type, msg->sendReliable(region->getHost()); } -// static -void LLPanelLandObjects::callbackReturnOwnerObjects(S32 option, void* userdata) +bool LLPanelLandObjects::callbackReturnOwnerObjects(const LLSD& notification, const LLSD& response) { - LLPanelLandObjects *lop = (LLPanelLandObjects *)userdata; - LLParcel *parcel = lop->mParcel->getParcel(); + S32 option = LLNotification::getSelectedOption(notification, response); + LLParcel *parcel = mParcel->getParcel(); if (0 == option) { if (parcel) { LLUUID owner_id = parcel->getOwnerID(); - LLStringUtil::format_map_t args; + LLSD args; if (owner_id == gAgentID) { - LLNotifyBox::showXml("OwnedObjectsReturned"); + LLNotifications::instance().add("OwnedObjectsReturned"); } else { std::string first, last; gCacheName->getName(owner_id, first, last); - args["[FIRST]"] = first; - args["[LAST]"] = last; - LLNotifyBox::showXml("OtherObjectsReturned", args); + args["FIRST"] = first; + args["LAST"] = last; + LLNotifications::instance().add("OtherObjectsReturned", args); } send_return_objects_message(parcel->getLocalID(), RT_OWNER); } @@ -1278,81 +1271,82 @@ void LLPanelLandObjects::callbackReturnOwnerObjects(S32 option, void* userdata) LLSelectMgr::getInstance()->unhighlightAll(); LLViewerParcelMgr::getInstance()->sendParcelPropertiesUpdate( parcel ); - lop->refresh(); + refresh(); + return false; } -// static -void LLPanelLandObjects::callbackReturnGroupObjects(S32 option, void* userdata) +bool LLPanelLandObjects::callbackReturnGroupObjects(const LLSD& notification, const LLSD& response) { - LLPanelLandObjects *lop = (LLPanelLandObjects *)userdata; - LLParcel *parcel = lop->mParcel->getParcel(); + S32 option = LLNotification::getSelectedOption(notification, response); + LLParcel *parcel = mParcel->getParcel(); if (0 == option) { if (parcel) { std::string group_name; gCacheName->getGroupName(parcel->getGroupID(), group_name); - LLStringUtil::format_map_t args; - args["[GROUPNAME]"] = group_name; - LLNotifyBox::showXml("GroupObjectsReturned", args); + LLSD args; + args["GROUPNAME"] = group_name; + LLNotifications::instance().add("GroupObjectsReturned", args); send_return_objects_message(parcel->getLocalID(), RT_GROUP); } } LLSelectMgr::getInstance()->unhighlightAll(); LLViewerParcelMgr::getInstance()->sendParcelPropertiesUpdate( parcel ); - lop->refresh(); + refresh(); + return false; } -// static -void LLPanelLandObjects::callbackReturnOtherObjects(S32 option, void* userdata) +bool LLPanelLandObjects::callbackReturnOtherObjects(const LLSD& notification, const LLSD& response) { - LLPanelLandObjects *lop = (LLPanelLandObjects *)userdata; - LLParcel *parcel = lop->mParcel->getParcel(); + S32 option = LLNotification::getSelectedOption(notification, response); + LLParcel *parcel = mParcel->getParcel(); if (0 == option) { if (parcel) { - LLNotifyBox::showXml("UnOwnedObjectsReturned"); + LLNotifications::instance().add("UnOwnedObjectsReturned"); send_return_objects_message(parcel->getLocalID(), RT_OTHER); } } LLSelectMgr::getInstance()->unhighlightAll(); LLViewerParcelMgr::getInstance()->sendParcelPropertiesUpdate( parcel ); - lop->refresh(); + refresh(); + return false; } -// static -void LLPanelLandObjects::callbackReturnOwnerList(S32 option, void* userdata) +bool LLPanelLandObjects::callbackReturnOwnerList(const LLSD& notification, const LLSD& response) { - LLPanelLandObjects *self = (LLPanelLandObjects *)userdata; - LLParcel *parcel = self->mParcel->getParcel(); + S32 option = LLNotification::getSelectedOption(notification, response); + LLParcel *parcel = mParcel->getParcel(); if (0 == option) { if (parcel) { // Make sure we have something selected. - uuid_list_t::iterator selected = self->mSelectedOwners.begin(); - if (selected != self->mSelectedOwners.end()) + uuid_list_t::iterator selected = mSelectedOwners.begin(); + if (selected != mSelectedOwners.end()) { - LLStringUtil::format_map_t args; - if (self->mSelectedIsGroup) + LLSD args; + if (mSelectedIsGroup) { - args["[GROUPNAME]"] = self->mSelectedName; - LLNotifyBox::showXml("GroupObjectsReturned", args); + args["GROUPNAME"] = mSelectedName; + LLNotifications::instance().add("GroupObjectsReturned", args); } else { - args["[NAME]"] = self->mSelectedName; - LLNotifyBox::showXml("OtherObjectsReturned2", args); + args["NAME"] = mSelectedName; + LLNotifications::instance().add("OtherObjectsReturned2", args); } - send_return_objects_message(parcel->getLocalID(), RT_LIST, &(self->mSelectedOwners)); + send_return_objects_message(parcel->getLocalID(), RT_LIST, &(mSelectedOwners)); } } } LLSelectMgr::getInstance()->unhighlightAll(); LLViewerParcelMgr::getInstance()->sendParcelPropertiesUpdate( parcel ); - self->refresh(); + refresh(); + return false; } @@ -1374,16 +1368,16 @@ void LLPanelLandObjects::onClickReturnOwnerList(void* userdata) send_parcel_select_objects(parcelp->getLocalID(), RT_LIST, &(self->mSelectedOwners)); - LLStringUtil::format_map_t args; - args["[NAME]"] = self->mSelectedName; - args["[N]"] = llformat("%d",self->mSelectedCount); + LLSD args; + args["NAME"] = self->mSelectedName; + args["N"] = llformat("%d",self->mSelectedCount); if (self->mSelectedIsGroup) { - gViewerWindow->alertXml("ReturnObjectsDeededToGroup", args, callbackReturnOwnerList, userdata); + LLNotifications::instance().add("ReturnObjectsDeededToGroup", args, LLSD(), boost::bind(&LLPanelLandObjects::callbackReturnOwnerList, self, _1, _2)); } else { - gViewerWindow->alertXml("ReturnObjectsOwnedByUser", args, callbackReturnOwnerList, userdata); + LLNotifications::instance().add("ReturnObjectsOwnedByUser", args, LLSD(), boost::bind(&LLPanelLandObjects::callbackReturnOwnerList, self, _1, _2)); } } @@ -1591,19 +1585,19 @@ void LLPanelLandObjects::onClickReturnOwnerObjects(void* userdata) LLUUID owner_id = parcel->getOwnerID(); - LLStringUtil::format_map_t args; - args["[N]"] = llformat("%d",owned); + LLSD args; + args["N"] = llformat("%d",owned); if (owner_id == gAgent.getID()) { - gViewerWindow->alertXml("ReturnObjectsOwnedBySelf", args, callbackReturnOwnerObjects, userdata); + LLNotifications::instance().add("ReturnObjectsOwnedBySelf", args, LLSD(), boost::bind(&LLPanelLandObjects::callbackReturnOwnerObjects, panelp, _1, _2)); } else { std::string name; gCacheName->getFullName(owner_id, name); - args["[NAME]"] = name; - gViewerWindow->alertXml("ReturnObjectsOwnedByUser", args, callbackReturnOwnerObjects, userdata); + args["NAME"] = name; + LLNotifications::instance().add("ReturnObjectsOwnedByUser", args, LLSD(), boost::bind(&LLPanelLandObjects::callbackReturnOwnerObjects, panelp, _1, _2)); } } @@ -1619,12 +1613,12 @@ void LLPanelLandObjects::onClickReturnGroupObjects(void* userdata) std::string group_name; gCacheName->getGroupName(parcel->getGroupID(), group_name); - LLStringUtil::format_map_t args; - args["[NAME]"] = group_name; - args["[N]"] = llformat("%d", parcel->getGroupPrimCount()); + LLSD args; + args["NAME"] = group_name; + args["N"] = llformat("%d", parcel->getGroupPrimCount()); // create and show confirmation textbox - gViewerWindow->alertXml("ReturnObjectsDeededToGroup", args, callbackReturnGroupObjects, userdata); + LLNotifications::instance().add("ReturnObjectsDeededToGroup", args, LLSD(), boost::bind(&LLPanelLandObjects::callbackReturnGroupObjects, panelp, _1, _2)); } // static @@ -1640,16 +1634,16 @@ void LLPanelLandObjects::onClickReturnOtherObjects(void* userdata) send_parcel_select_objects(parcel->getLocalID(), RT_OTHER); - LLStringUtil::format_map_t args; - args["[N]"] = llformat("%d", other); + LLSD args; + args["N"] = llformat("%d", other); if (parcel->getIsGroupOwned()) { std::string group_name; gCacheName->getGroupName(parcel->getGroupID(), group_name); - args["[NAME]"] = group_name; + args["NAME"] = group_name; - gViewerWindow->alertXml("ReturnObjectsNotOwnedByGroup", args, callbackReturnOtherObjects, userdata); + LLNotifications::instance().add("ReturnObjectsNotOwnedByGroup", args, LLSD(), boost::bind(&LLPanelLandObjects::callbackReturnOtherObjects, panelp, _1, _2)); } else { @@ -1657,15 +1651,15 @@ void LLPanelLandObjects::onClickReturnOtherObjects(void* userdata) if (owner_id == gAgent.getID()) { - gViewerWindow->alertXml("ReturnObjectsNotOwnedBySelf", args, callbackReturnOtherObjects, userdata); + LLNotifications::instance().add("ReturnObjectsNotOwnedBySelf", args, LLSD(), boost::bind(&LLPanelLandObjects::callbackReturnOtherObjects, panelp, _1, _2)); } else { std::string name; gCacheName->getFullName(owner_id, name); - args["[NAME]"] = name; + args["NAME"] = name; - gViewerWindow->alertXml("ReturnObjectsNotOwnedByUser", args, callbackReturnOtherObjects, userdata); + LLNotifications::instance().add("ReturnObjectsNotOwnedByUser", args, LLSD(), boost::bind(&LLPanelLandObjects::callbackReturnOtherObjects, panelp, _1, _2)); } } } @@ -2073,7 +2067,7 @@ void LLPanelLandOptions::onCommitAny(LLUICtrl *ctrl, void *userdata) if (!allow_other_scripts && region && region->getAllowDamage()) { - gViewerWindow->alertXml("UnableToDisableOutsideScripts"); + LLNotifications::instance().add("UnableToDisableOutsideScripts"); return; } @@ -2117,7 +2111,7 @@ void LLPanelLandOptions::onClickSet(void* userdata) if (agent_parcel->getLocalID() != selected_parcel->getLocalID()) { - gViewerWindow->alertXml("MustBeInParcel"); + LLNotifications::instance().add("MustBeInParcel"); return; } @@ -2160,11 +2154,11 @@ void LLPanelLandOptions::onClickPublishHelp(void*) if(! can_change_identity) { - gViewerWindow->alertXml("ClickPublishHelpLandDisabled"); + LLNotifications::instance().add("ClickPublishHelpLandDisabled"); } else { - gViewerWindow->alertXml("ClickPublishHelpLand"); + LLNotifications::instance().add("ClickPublishHelpLand"); } } diff --git a/indra/newview/llfloaterland.h b/indra/newview/llfloaterland.h index 9bed9d53ae..1d95a3e3f6 100644 --- a/indra/newview/llfloaterland.h +++ b/indra/newview/llfloaterland.h @@ -151,8 +151,7 @@ public: static void finalizeSetSellChange(void * userdata); static void onSalePriceChange(LLUICtrl *ctrl, void * userdata); - static void cbBuyPass(S32 option, void*); - static BOOL buyPassDialogVisible(); + static bool cbBuyPass(const LLSD& notification, const LLSD& response); static void onClickSellLand(void* data); static void onClickStopSellLand(void* data); @@ -234,10 +233,10 @@ public: void refresh(); virtual void draw(); - static void callbackReturnOwnerObjects(S32, void*); - static void callbackReturnGroupObjects(S32, void*); - static void callbackReturnOtherObjects(S32, void*); - static void callbackReturnOwnerList(S32, void*); + bool callbackReturnOwnerObjects(const LLSD& notification, const LLSD& response); + bool callbackReturnGroupObjects(const LLSD& notification, const LLSD& response); + bool callbackReturnOtherObjects(const LLSD& notification, const LLSD& response); + bool callbackReturnOwnerList(const LLSD& notification, const LLSD& response); static void clickShowCore(LLPanelLandObjects* panelp, S32 return_type, uuid_list_t* list = 0); static void onClickShowOwnerObjects(void*); diff --git a/indra/newview/llfloaternotificationsconsole.cpp b/indra/newview/llfloaternotificationsconsole.cpp new file mode 100644 index 0000000000..12dcd58254 --- /dev/null +++ b/indra/newview/llfloaternotificationsconsole.cpp @@ -0,0 +1,292 @@ +/** + * @file llnotificationsconsole.cpp + * @brief Debugging console for unified notifications. + * + * $LicenseInfo:firstyear=2003&license=viewergpl$ + * + * Copyright (c) 2003-2007, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlife.com/developers/opensource/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at http://secondlife.com/developers/opensource/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" +#include "llfloaternotificationsconsole.h" +#include "llnotifications.h" +#include "lluictrlfactory.h" +#include "llbutton.h" +#include "llscrolllistctrl.h" +#include "llpanel.h" +#include "llcombobox.h" +#include "llviewertexteditor.h" + +const S32 NOTIFICATION_PANEL_HEADER_HEIGHT = 20; +const S32 HEADER_PADDING = 38; + +class LLNotificationChannelPanel : public LLPanel +{ +public: + LLNotificationChannelPanel(const std::string& channel_name); + BOOL postBuild(); + +private: + bool update(const LLSD& payload, bool passed_filter); + static void toggleClick(void* user_data); + static void onClickNotification(void* user_data); + static void onClickNotificationReject(void* user_data); + LLNotificationChannelPtr mChannelPtr; + LLNotificationChannelPtr mChannelRejectsPtr; +}; + +LLNotificationChannelPanel::LLNotificationChannelPanel(const std::string& channel_name) + : LLPanel(channel_name) +{ + mChannelPtr = LLNotifications::instance().getChannel(channel_name); + mChannelRejectsPtr = LLNotificationChannelPtr( + new LLNotificationChannel(channel_name + "rejects", mChannelPtr->getParentChannelName(), !boost::bind(mChannelPtr->getFilter(), _1))); + LLUICtrlFactory::instance().buildPanel(this, "panel_notifications_channel.xml"); +} + +BOOL LLNotificationChannelPanel::postBuild() +{ + LLButton* header_button = getChild<LLButton>("header"); + header_button->setLabel(mChannelPtr->getName()); + header_button->setClickedCallback(toggleClick, this); + + mChannelPtr->connectChanged(boost::bind(&LLNotificationChannelPanel::update, this, _1, true)); + mChannelRejectsPtr->connectChanged(boost::bind(&LLNotificationChannelPanel::update, this, _1, false)); + + LLScrollListCtrl* scroll = getChild<LLScrollListCtrl>("notifications_list"); + scroll->setDoubleClickCallback(onClickNotification); + scroll->setCallbackUserData(this); + + scroll = getChild<LLScrollListCtrl>("notification_rejects_list"); + scroll->setDoubleClickCallback(onClickNotificationReject); + scroll->setCallbackUserData(this); + + return TRUE; +} + +//static +void LLNotificationChannelPanel::toggleClick(void *user_data) +{ + LLNotificationChannelPanel* self = (LLNotificationChannelPanel*)user_data; + if (!self) return; + + LLButton* header_button = self->getChild<LLButton>("header"); + + LLLayoutStack* stack = dynamic_cast<LLLayoutStack*>(self->getParent()); + if (stack) + { + stack->collapsePanel(self, header_button->getToggleState()); + } + + // turn off tab stop for collapsed panel + self->getChild<LLScrollListCtrl>("notifications_list")->setTabStop(!header_button->getToggleState()); + self->getChild<LLScrollListCtrl>("notifications_list")->setVisible(!header_button->getToggleState()); + self->getChild<LLScrollListCtrl>("notification_rejects_list")->setTabStop(!header_button->getToggleState()); + self->getChild<LLScrollListCtrl>("notification_rejects_list")->setVisible(!header_button->getToggleState()); +} + +/*static*/ +void LLNotificationChannelPanel::onClickNotification(void* user_data) +{ + LLNotificationChannelPanel* self = (LLNotificationChannelPanel*)user_data; + if (!self) return; + void* data = self->getChild<LLScrollListCtrl>("notifications_list")->getFirstSelected()->getUserdata(); + if (data) + { + gFloaterView->getParentFloater(self)->addDependentFloater(new LLFloaterNotification((LLNotification*)data), TRUE); + } +} + +/*static*/ +void LLNotificationChannelPanel::onClickNotificationReject(void* user_data) +{ + LLNotificationChannelPanel* self = (LLNotificationChannelPanel*)user_data; + if (!self) return; + void* data = self->getChild<LLScrollListCtrl>("notification_rejects_list")->getFirstSelected()->getUserdata(); + if (data) + { + gFloaterView->getParentFloater(self)->addDependentFloater(new LLFloaterNotification((LLNotification*)data), TRUE); + } +} + +bool LLNotificationChannelPanel::update(const LLSD& payload, bool passed_filter) +{ + LLNotificationPtr notification = LLNotifications::instance().find(payload["id"].asUUID()); + if (notification) + { + LLSD row; + row["columns"][0]["value"] = notification->getName(); + row["columns"][0]["column"] = "name"; + + row["columns"][1]["value"] = notification->getMessage(); + row["columns"][1]["column"] = "content"; + + row["columns"][2]["value"] = notification->getDate(); + row["columns"][2]["column"] = "date"; + row["columns"][2]["type"] = "date"; + + LLScrollListItem* sli = passed_filter ? + getChild<LLScrollListCtrl>("notifications_list")->addElement(row) : + getChild<LLScrollListCtrl>("notification_rejects_list")->addElement(row); + sli->setUserdata(&(*notification)); + } + + return false; +} + +// +// LLFloaterNotificationConsole +// +LLFloaterNotificationConsole::LLFloaterNotificationConsole(const LLSD& key) +{ + LLUICtrlFactory::instance().buildFloater(this, "floater_notifications_console.xml"); +} + +void LLFloaterNotificationConsole::onClose(bool app_quitting) +{ + setVisible(FALSE); + //destroy(); +} + + +BOOL LLFloaterNotificationConsole::postBuild() +{ + // these are in the order of processing + addChannel("Unexpired"); + addChannel("Ignore"); + addChannel("Visible", true); + // all the ones below attach to the Visible channel + addChannel("History"); + addChannel("Alerts"); + addChannel("AlertModal"); + addChannel("Group Notifications"); + addChannel("Notifications"); + addChannel("NotificationTips"); + + getChild<LLButton>("add_notification")->setClickedCallback(onClickAdd, this); + + LLComboBox* notifications = getChild<LLComboBox>("notification_types"); + LLNotifications::TemplateNames names = LLNotifications::instance().getTemplateNames(); + for (LLNotifications::TemplateNames::iterator template_it = names.begin(); + template_it != names.end(); + ++template_it) + { + notifications->add(*template_it); + } + notifications->sortByName(); + + return TRUE; +} + +void LLFloaterNotificationConsole::addChannel(const std::string& name, bool open) +{ + LLLayoutStack& stack = getChildRef<LLLayoutStack>("notification_channels"); + LLNotificationChannelPanel* panelp = new LLNotificationChannelPanel(name); + stack.addPanel(panelp, 0, NOTIFICATION_PANEL_HEADER_HEIGHT, TRUE, TRUE, LLLayoutStack::ANIMATE); + + LLButton& header_button = panelp->getChildRef<LLButton>("header"); + header_button.setToggleState(!open); + stack.collapsePanel(panelp, !open); + + updateResizeLimits(); +} + +void LLFloaterNotificationConsole::removeChannel(const std::string& name) +{ + LLPanel* panelp = getChild<LLPanel>(name, TRUE, FALSE); + if (panelp) + { + getChildRef<LLLayoutStack>("notification_channels").removePanel(panelp); + delete panelp; + } + + updateResizeLimits(); +} + +//static +void LLFloaterNotificationConsole::updateResizeLimits() +{ + LLLayoutStack& stack = getChildRef<LLLayoutStack>("notification_channels"); + setResizeLimits(getMinWidth(), LLFLOATER_HEADER_SIZE + HEADER_PADDING + ((NOTIFICATION_PANEL_HEADER_HEIGHT + 3) * stack.getNumPanels())); +} + +void LLFloaterNotificationConsole::onClickAdd(void* user_data) +{ + LLFloaterNotificationConsole* floater = (LLFloaterNotificationConsole*)user_data; + + std::string message_name = floater->getChild<LLComboBox>("notification_types")->getValue().asString(); + if (!message_name.empty()) + { + LLNotifications::instance().add(message_name, LLSD()); + } +} + + +//=============== LLFloaterNotification ================ + +LLFloaterNotification::LLFloaterNotification(LLNotification* note) : mNote(note) +{ + LLUICtrlFactory::instance().buildFloater(this, "floater_notification.xml"); +} + +BOOL LLFloaterNotification::postBuild() +{ + setTitle(mNote->getName()); + getChild<LLViewerTextEditor>("payload")->setText(mNote->getMessage()); + + LLComboBox* responses_combo = getChild<LLComboBox>("response"); + LLCtrlListInterface* response_list = responses_combo->getListInterface(); + LLNotificationFormPtr form(mNote->getForm()); + if(!form) + { + return TRUE; + } + + responses_combo->setCommitCallback(onCommitResponse); + responses_combo->setCallbackUserData(this); + + LLSD form_sd = form->asLLSD(); + + for (LLSD::array_const_iterator form_item = form_sd.beginArray(); form_item != form_sd.endArray(); ++form_item) + { + if ( (*form_item)["type"].asString() != "button") continue; + std::string text = (*form_item)["text"].asString(); + response_list->addSimpleElement(text); + } + + return TRUE; +} + +void LLFloaterNotification::respond() +{ + LLComboBox* responses_combo = getChild<LLComboBox>("response"); + LLCtrlListInterface* response_list = responses_combo->getListInterface(); + const std::string& trigger = response_list->getSelectedValue().asString(); + //llinfos << trigger << llendl; + + LLSD response = mNote->getResponseTemplate(); + response[trigger] = true; + mNote->respond(response); +} diff --git a/indra/newview/llfloaternotificationsconsole.h b/indra/newview/llfloaternotificationsconsole.h new file mode 100644 index 0000000000..5b8e79f0bb --- /dev/null +++ b/indra/newview/llfloaternotificationsconsole.h @@ -0,0 +1,78 @@ +/** + * @file llfloaternotificationsconsole.h + * @brief Debugging console for unified notifications. + * + * $LicenseInfo:firstyear=2003&license=viewergpl$ + * + * Copyright (c) 2003-2007, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlife.com/developers/opensource/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at http://secondlife.com/developers/opensource/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#ifndef LL_LLFLOATER_NOTIFICATIONS_CONSOLE_H +#define LL_LLFLOATER_NOTIFICATIONS_CONSOLE_H + +#include "llfloater.h" +#include "llnotifications.h" + +class LLFloaterNotificationConsole : + public LLFloater, + public LLFloaterSingleton<LLFloaterNotificationConsole> +{ +public: + LLFloaterNotificationConsole(const LLSD& key); + + // LLPanel + BOOL postBuild(); + void onClose(bool app_quitting); + + void addChannel(const std::string& type, bool open = false); + void updateResizeLimits(LLLayoutStack &stack); + + void removeChannel(const std::string& type); + void updateResizeLimits(); + +private: + static void onClickAdd(void* user_data); +}; + + +/* + * @brief Pop-up debugging view of a generic new notification. + */ +class LLFloaterNotification : public LLFloater +{ +public: + LLFloaterNotification(LLNotification* note); + + // LLPanel + BOOL postBuild(); + void respond(); + void onClose(bool app_quitting) { setVisible(FALSE); } + +private: + static void onCommitResponse(LLUICtrl* ctrl, void* data) { ((LLFloaterNotification*)data)->respond(); } + LLNotification* mNote; +}; +#endif + diff --git a/indra/newview/llfloateropenobject.cpp b/indra/newview/llfloateropenobject.cpp index b1380ccd8c..55376c5634 100644 --- a/indra/newview/llfloateropenobject.cpp +++ b/indra/newview/llfloateropenobject.cpp @@ -109,7 +109,7 @@ void LLFloaterOpenObject::show() LLObjectSelectionHandle object_selection = LLSelectMgr::getInstance()->getSelection(); if (object_selection->getRootObjectCount() != 1) { - gViewerWindow->alertXml("UnableToViewContentsMoreThanOne"); + LLNotifications::instance().add("UnableToViewContentsMoreThanOne"); return; } @@ -131,7 +131,7 @@ void LLFloaterOpenObject::moveToInventory(bool wear) { if (mObjectSelection->getRootObjectCount() != 1) { - gViewerWindow->alertXml("OnlyCopyContentsOfSingleItem"); + LLNotifications::instance().add("OnlyCopyContentsOfSingleItem"); return; } @@ -172,7 +172,7 @@ void LLFloaterOpenObject::moveToInventory(bool wear) delete data; data = NULL; - gViewerWindow->alertXml("OpenObjectCannotCopy"); + LLNotifications::instance().add("OpenObjectCannotCopy"); } } diff --git a/indra/newview/llfloaterperms.cpp b/indra/newview/llfloaterperms.cpp index 9405bc61b2..c2d67d602a 100644 --- a/indra/newview/llfloaterperms.cpp +++ b/indra/newview/llfloaterperms.cpp @@ -153,5 +153,5 @@ U32 LLFloaterPerms::getNextOwnerPerms(std::string prefix) //static void LLFloaterPerms::onClickHelp(void* data) { - gViewerWindow->alertXml("ClickUploadHelpPermissions"); + LLNotifications::instance().add("ClickUploadHelpPermissions"); } diff --git a/indra/newview/llfloaterpostcard.cpp b/indra/newview/llfloaterpostcard.cpp index 3182568fe8..f5a7a65abf 100644 --- a/indra/newview/llfloaterpostcard.cpp +++ b/indra/newview/llfloaterpostcard.cpp @@ -249,20 +249,20 @@ void LLFloaterPostcard::onClickSend(void* data) if (to.empty() || !boost::regex_match(to, emailFormat)) { - gViewerWindow->alertXml("PromptRecipientEmail"); + LLNotifications::instance().add("PromptRecipientEmail"); return; } if (from.empty() || !boost::regex_match(from, emailFormat)) { - gViewerWindow->alertXml("PromptSelfEmail"); + LLNotifications::instance().add("PromptSelfEmail"); return; } std::string subject(self->childGetValue("subject_form").asString()); if(subject.empty() || !self->mHasFirstMsgFocus) { - gViewerWindow->alertXml("PromptMissingSubjMsg", missingSubjMsgAlertCallback, self); + LLNotifications::instance().add("PromptMissingSubjMsg", LLSD(), LLSD(), boost::bind(&LLFloaterPostcard::missingSubjMsgAlertCallback, self, _1, _2)); return; } @@ -272,7 +272,7 @@ void LLFloaterPostcard::onClickSend(void* data) } else { - gViewerWindow->alertXml("ErrorProcessingSnapshot"); + LLNotifications::instance().add("ErrorProcessingSnapshot"); } } } @@ -286,9 +286,9 @@ void LLFloaterPostcard::uploadCallback(const LLUUID& asset_id, void *user_data, if (result) { - LLStringUtil::format_map_t args; - args["[REASON]"] = std::string(LLAssetStorage::getErrorString(result)); - gViewerWindow->alertXml("ErrorUploadingPostcard", args); + LLSD args; + args["REASON"] = std::string(LLAssetStorage::getErrorString(result)); + LLNotifications::instance().add("ErrorUploadingPostcard", args); } else { @@ -345,30 +345,28 @@ void LLFloaterPostcard::onMsgFormFocusRecieved(LLFocusableElement* receiver, voi } } -void LLFloaterPostcard::missingSubjMsgAlertCallback(S32 option, void* data) +bool LLFloaterPostcard::missingSubjMsgAlertCallback(const LLSD& notification, const LLSD& response) { - if(data) + S32 option = LLNotification::getSelectedOption(notification, response); + if(0 == option) { - LLFloaterPostcard* self = static_cast<LLFloaterPostcard*>(data); - if(0 == option) + // User clicked OK + if((childGetValue("subject_form").asString()).empty()) { - // User clicked OK - if((self->childGetValue("subject_form").asString()).empty()) - { - // Stuff the subject back into the form. - self->childSetValue("subject_form", self->getString("default_subject")); - } - - if(!self->mHasFirstMsgFocus) - { - // The user never switched focus to the messagee window. - // Using the default string. - self->childSetValue("msg_form", self->getString("default_message")); - } + // Stuff the subject back into the form. + childSetValue("subject_form", getString("default_subject")); + } - self->sendPostcard(); + if(!mHasFirstMsgFocus) + { + // The user never switched focus to the messagee window. + // Using the default string. + childSetValue("msg_form", getString("default_message")); } + + sendPostcard(); } + return false; } void LLFloaterPostcard::sendPostcard() diff --git a/indra/newview/llfloaterpostcard.h b/indra/newview/llfloaterpostcard.h index 28248f65df..94c619c7e5 100644 --- a/indra/newview/llfloaterpostcard.h +++ b/indra/newview/llfloaterpostcard.h @@ -65,7 +65,7 @@ public: static void updateUserInfo(const std::string& email); static void onMsgFormFocusRecieved(LLFocusableElement* receiver, void* data); - static void missingSubjMsgAlertCallback(S32 option, void* data); + bool missingSubjMsgAlertCallback(const LLSD& notification, const LLSD& response); void sendPostcard(); diff --git a/indra/newview/llfloaterpostprocess.cpp b/indra/newview/llfloaterpostprocess.cpp index 692b7e036f..ce5f9c124f 100644 --- a/indra/newview/llfloaterpostprocess.cpp +++ b/indra/newview/llfloaterpostprocess.cpp @@ -169,11 +169,13 @@ void LLFloaterPostProcess::onSaveEffect(void* userData) { LLLineEditor* editBox = static_cast<LLLineEditor*>(userData); - LLSD::String effectName(editBox->getValue().asString()); + std::string effectName(editBox->getValue().asString()); if (gPostProcess->mAllEffects.has(effectName)) { - gViewerWindow->alertXml("PPSaveEffectAlert", &LLFloaterPostProcess::saveAlertCallback, userData); + LLSD payload; + payload["effect_name"] = effectName; + LLNotifications::instance().add("PPSaveEffectAlert", LLSD(), payload, &LLFloaterPostProcess::saveAlertCallback); } else { @@ -192,20 +194,18 @@ void LLFloaterPostProcess::onChangeEffectName(LLUICtrl* ctrl, void * userData) editBox->setValue(comboBox->getSelectedValue()); } -void LLFloaterPostProcess::saveAlertCallback(S32 option, void* userData) +bool LLFloaterPostProcess::saveAlertCallback(const LLSD& notification, const LLSD& response) { - LLLineEditor* editBox = static_cast<LLLineEditor*>(userData); + S32 option = LLNotification::getSelectedOption(notification, response); // if they choose save, do it. Otherwise, don't do anything if (option == 0) { - LLSD::String effectName(editBox->getValue().asString()); - - gPostProcess->saveEffect(effectName); + gPostProcess->saveEffect(notification["payload"]["effect_name"].asString()); sPostProcess->syncMenu(); } - + return false; } void LLFloaterPostProcess::show() diff --git a/indra/newview/llfloaterpostprocess.h b/indra/newview/llfloaterpostprocess.h index 8b590f8b8e..88d3fd04e7 100644 --- a/indra/newview/llfloaterpostprocess.h +++ b/indra/newview/llfloaterpostprocess.h @@ -68,7 +68,7 @@ public: static void onChangeEffectName(LLUICtrl* ctrl, void * userData); /// prompts a user when overwriting an effect - static void saveAlertCallback(S32 option, void* userData); + static bool saveAlertCallback(const LLSD& notification, const LLSD& response); /// show off our menu static void show(); diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 737a2afbb7..1e10f90609 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -59,6 +59,7 @@ #include "llfloatergroups.h" #include "llfloatertelehub.h" #include "llfloaterwindlight.h" +#include "llinventorymodel.h" #include "lllineeditor.h" #include "llalertdialog.h" #include "llnamelistctrl.h" @@ -540,8 +541,8 @@ void LLPanelRegionInfo::initHelpBtn(const std::string& name, const std::string& // static void LLPanelRegionInfo::onClickHelp(void* data) { - const std::string* xml_alert = (std::string*)data; - gViewerWindow->alertXml(*xml_alert); + std::string* xml_alert = (std::string*)data; + LLNotifications::instance().add(*xml_alert); } ///////////////////////////////////////////////////////////////////////////// @@ -638,16 +639,17 @@ void LLPanelRegionGeneralInfo::onKickCommit(const std::vector<std::string>& name void LLPanelRegionGeneralInfo::onClickKickAll(void* userdata) { llinfos << "LLPanelRegionGeneralInfo::onClickKickAll" << llendl; - gViewerWindow->alertXml("KickUsersFromRegion", onKickAllCommit, userdata); + LLNotifications::instance().add("KickUsersFromRegion", + LLSD(), + LLSD(), + boost::bind(&LLPanelRegionGeneralInfo::onKickAllCommit, (LLPanelRegionGeneralInfo*)userdata, _1, _2)); } -// static -void LLPanelRegionGeneralInfo::onKickAllCommit(S32 option, void* userdata) +bool LLPanelRegionGeneralInfo::onKickAllCommit(const LLSD& notification, const LLSD& response) { + S32 option = LLNotification::getSelectedOption(notification, response); if (option == 0) { - LLPanelRegionGeneralInfo* self = (LLPanelRegionGeneralInfo*)userdata; - if(!self) return; strings_t strings; // [0] = our agent id std::string buffer; @@ -656,26 +658,29 @@ void LLPanelRegionGeneralInfo::onKickAllCommit(S32 option, void* userdata) LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); // historical message name - self->sendEstateOwnerMessage(gMessageSystem, "teleporthomeallusers", invoice, strings); + sendEstateOwnerMessage(gMessageSystem, "teleporthomeallusers", invoice, strings); } + return false; } // static void LLPanelRegionGeneralInfo::onClickMessage(void* userdata) { llinfos << "LLPanelRegionGeneralInfo::onClickMessage" << llendl; - gViewerWindow->alertXmlEditText("MessageRegion", LLStringUtil::format_map_t(), - NULL, NULL, - onMessageCommit, userdata); + LLNotifications::instance().add("MessageRegion", + LLSD(), + LLSD(), + boost::bind(&LLPanelRegionGeneralInfo::onMessageCommit, (LLPanelRegionGeneralInfo*)userdata, _1, _2)); } // static -void LLPanelRegionGeneralInfo::onMessageCommit(S32 option, const std::string& text, void* userdata) +bool LLPanelRegionGeneralInfo::onMessageCommit(const LLSD& notification, const LLSD& response) { - if(option != 0) return; - if(text.empty()) return; - LLPanelRegionGeneralInfo* self = (LLPanelRegionGeneralInfo*)userdata; - if(!self) return; + if(LLNotification::getSelectedOption(notification, response) != 0) return false; + + std::string text = response["message"].asString(); + if (text.empty()) return false; + llinfos << "Message to everyone: " << text << llendl; strings_t strings; // [0] grid_x, unused here @@ -693,7 +698,8 @@ void LLPanelRegionGeneralInfo::onMessageCommit(S32 option, const std::string& te strings.push_back(strings_t::value_type(name)); strings.push_back(strings_t::value_type(text)); LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - self->sendEstateOwnerMessage(gMessageSystem, "simulatormessage", invoice, strings); + sendEstateOwnerMessage(gMessageSystem, "simulatormessage", invoice, strings); + return false; } // static @@ -780,7 +786,7 @@ BOOL LLPanelRegionGeneralInfo::sendUpdate() LLViewerRegion* region = gAgent.getRegion(); if (region && access != region->getSimAccess() ) { - gViewerWindow->alertXml("RegionMaturityChange"); + LLNotifications::instance().add("RegionMaturityChange"); } } @@ -881,48 +887,56 @@ void LLPanelRegionDebugInfo::onClickReturn(void* data) LLPanelRegionDebugInfo* panelp = (LLPanelRegionDebugInfo*) data; if (panelp->mTargetAvatar.isNull()) return; - LLStringUtil::format_map_t args; - args["[USER_NAME]"] = panelp->childGetValue("target_avatar_name").asString(); - gViewerWindow->alertXml("EstateObjectReturn", args, callbackReturn, data); + LLSD args; + args["USER_NAME"] = panelp->childGetValue("target_avatar_name").asString(); + LLSD payload; + payload["avatar_id"] = panelp->mTargetAvatar; + + U32 flags = SWD_ALWAYS_RETURN_OBJECTS; + + if (panelp->childGetValue("return_scripts").asBoolean()) + { + flags |= SWD_SCRIPTED_ONLY; + } + + if (panelp->childGetValue("return_other_land").asBoolean()) + { + flags |= SWD_OTHERS_LAND_ONLY; + } + payload["flags"] = int(flags); + payload["return_estate_wide"] = panelp->childGetValue("return_estate_wide").asBoolean(); + LLNotifications::instance().add("EstateObjectReturn", args, payload, + boost::bind(&LLPanelRegionDebugInfo::callbackReturn, panelp, _1, _2)); } -// static -void LLPanelRegionDebugInfo::callbackReturn( S32 option, void* userdata ) +bool LLPanelRegionDebugInfo::callbackReturn(const LLSD& notification, const LLSD& response) { - if (option != 0) return; + S32 option = LLNotification::getSelectedOption(notification, response); + if (option != 0) return false; - LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*) userdata; - if (!self->mTargetAvatar.isNull()) + LLUUID target_avatar = notification["payload"]["avatar_id"].asUUID(); + if (!target_avatar.isNull()) { - U32 flags = SWD_ALWAYS_RETURN_OBJECTS; - - if (self->childGetValue("return_scripts").asBoolean()) - { - flags |= SWD_SCRIPTED_ONLY; - } - - if (self->childGetValue("return_other_land").asBoolean()) - { - flags |= SWD_OTHERS_LAND_ONLY; - } - - if (self->childGetValue("return_estate_wide").asBoolean()) + U32 flags = notification["payload"]["flags"].asInteger(); + bool return_estate_wide = notification["payload"]["return_estate_wide"]; + if (return_estate_wide) { // send as estate message - routed by spaceserver to all regions in estate strings_t strings; strings.push_back(llformat("%d", flags)); - strings.push_back(self->mTargetAvatar.asString()); + strings.push_back(target_avatar.asString()); LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - self->sendEstateOwnerMessage(gMessageSystem, "estateobjectreturn", invoice, strings); + sendEstateOwnerMessage(gMessageSystem, "estateobjectreturn", invoice, strings); } else { // send to this simulator only - send_sim_wide_deletes(self->mTargetAvatar, flags); - } + send_sim_wide_deletes(target_avatar, flags); + } } + return false; } @@ -953,19 +967,20 @@ void LLPanelRegionDebugInfo::onClickTopScripts(void* data) // static void LLPanelRegionDebugInfo::onClickRestart(void* data) { - gViewerWindow->alertXml("ConfirmRestart", callbackRestart, data); + LLNotifications::instance().add("ConfirmRestart", LLSD(), LLSD(), + boost::bind(&LLPanelRegionDebugInfo::callbackRestart, (LLPanelRegionDebugInfo*)data, _1, _2)); } -// static -void LLPanelRegionDebugInfo::callbackRestart(S32 option, void* data) +bool LLPanelRegionDebugInfo::callbackRestart(const LLSD& notification, const LLSD& response) { - if (option != 0) return; + S32 option = LLNotification::getSelectedOption(notification, response); + if (option != 0) return false; - LLPanelRegionDebugInfo* self = (LLPanelRegionDebugInfo*)data; strings_t strings; strings.push_back("120"); LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - self->sendEstateOwnerMessage(gMessageSystem, "restart", invoice, strings); + sendEstateOwnerMessage(gMessageSystem, "restart", invoice, strings); + return false; } // static @@ -1123,21 +1138,21 @@ BOOL LLPanelRegionTextureInfo::validateTextureSizes() if (components != 3) { - LLStringUtil::format_map_t args; - args["[TEXTURE_NUM]"] = llformat("%d",i+1); - args["[TEXTURE_BIT_DEPTH]"] = llformat("%d",components * 8); - gViewerWindow->alertXml("InvalidTerrainBitDepth", args); + LLSD args; + args["TEXTURE_NUM"] = i+1; + args["TEXTURE_BIT_DEPTH"] = llformat("%d",components * 8); + LLNotifications::instance().add("InvalidTerrainBitDepth", args); return FALSE; } if (width > 512 || height > 512) { - LLStringUtil::format_map_t args; - args["[TEXTURE_NUM]"] = llformat("%d",i+1); - args["[TEXTURE_SIZE_X]"] = llformat("%d",width); - args["[TEXTURE_SIZE_Y]"] = llformat("%d",height); - gViewerWindow->alertXml("InvalidTerrainSize", args); + LLSD args; + args["TEXTURE_NUM"] = i+1; + args["TEXTURE_SIZE_X"] = width; + args["TEXTURE_SIZE_Y"] = height; + LLNotifications::instance().add("InvalidTerrainSize", args); return FALSE; } @@ -1334,26 +1349,27 @@ void LLPanelRegionTerrainInfo::onClickUploadRaw(void* data) LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); self->sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings); - gViewerWindow->alertXml("RawUploadStarted"); + LLNotifications::instance().add("RawUploadStarted"); } // static void LLPanelRegionTerrainInfo::onClickBakeTerrain(void* data) { - gViewerWindow->alertXml("ConfirmBakeTerrain", - callbackBakeTerrain, data); + LLNotifications::instance().add( + LLNotification::Params("ConfirmBakeTerrain") + .functor(boost::bind(&LLPanelRegionTerrainInfo::callbackBakeTerrain, (LLPanelRegionTerrainInfo*)data, _1, _2))); } -// static -void LLPanelRegionTerrainInfo::callbackBakeTerrain(S32 option, void* data) +bool LLPanelRegionTerrainInfo::callbackBakeTerrain(const LLSD& notification, const LLSD& response) { - if (option != 0) return; + S32 option = LLNotification::getSelectedOption(notification, response); + if (option != 0) return false; - LLPanelRegionTerrainInfo* self = (LLPanelRegionTerrainInfo*)data; strings_t strings; strings.push_back("bake"); LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - self->sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings); + sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings); + return false; } ///////////////////////////////////////////////////////////////////////////// @@ -1440,9 +1456,9 @@ void LLPanelEstateInfo::onClickAddAllowedAgent(void* user_data) { //args - LLStringUtil::format_map_t args; - args["[MAX_AGENTS]"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); - gViewerWindow->alertXml("MaxAllowedAgentOnRegion", args); + LLSD args; + args["MAX_AGENTS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); + LLNotifications::instance().add("MaxAllowedAgentOnRegion", args); return; } accessAddCore(ESTATE_ACCESS_ALLOWED_AGENT_ADD, "EstateAllowedAgentAdd"); @@ -1462,35 +1478,36 @@ void LLPanelEstateInfo::onClickAddAllowedGroup(void* user_data) if (!list) return; if (list->getItemCount() >= ESTATE_MAX_ACCESS_IDS) { - LLStringUtil::format_map_t args; - args["[MAX_GROUPS]"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); - gViewerWindow->alertXml("MaxAllowedGroupsOnRegion", args); + LLSD args; + args["MAX_GROUPS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); + LLNotifications::instance().add("MaxAllowedGroupsOnRegion", args); return; } + + LLNotification::Params params("ChangeLindenAccess"); + params.functor(boost::bind(&LLPanelEstateInfo::addAllowedGroup, self, _1, _2)); if (isLindenEstate()) { - gViewerWindow->alertXml("ChangeLindenAccess", addAllowedGroup, user_data); + LLNotifications::instance().add(params); } else { - addAllowedGroup(0, user_data); + LLNotifications::instance().forceResponse(params, 0); } } -// static -void LLPanelEstateInfo::addAllowedGroup(S32 option, void* user_data) +bool LLPanelEstateInfo::addAllowedGroup(const LLSD& notification, const LLSD& response) { - if (option != 0) return; + S32 option = LLNotification::getSelectedOption(notification, response); + if (option != 0) return false; - LLPanelEstateInfo* panelp = (LLPanelEstateInfo*)user_data; - - LLFloater* parent_floater = gFloaterView->getParentFloater(panelp); + LLFloater* parent_floater = gFloaterView->getParentFloater(this); LLFloaterGroupPicker* widget; widget = LLFloaterGroupPicker::showInstance(LLSD(gAgent.getID())); if (widget) { - widget->setSelectCallback(addAllowedGroup2, user_data); + widget->setSelectCallback(addAllowedGroup2, NULL); if (parent_floater) { LLRect new_rect = gFloaterView->findNeighboringPosition(parent_floater, widget); @@ -1498,6 +1515,8 @@ void LLPanelEstateInfo::addAllowedGroup(S32 option, void* user_data) parent_floater->addDependentFloater(widget); } } + + return false; } // static @@ -1514,9 +1533,9 @@ void LLPanelEstateInfo::onClickAddBannedAgent(void* user_data) if (!list) return; if (list->getItemCount() >= ESTATE_MAX_ACCESS_IDS) { - LLStringUtil::format_map_t args; - args["[MAX_BANNED]"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); - gViewerWindow->alertXml("MaxBannedAgentsOnRegion", args); + LLSD args; + args["MAX_BANNED"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); + LLNotifications::instance().add("MaxBannedAgentsOnRegion", args); return; } accessAddCore(ESTATE_ACCESS_BANNED_AGENT_ADD, "EstateBannedAgentAdd"); @@ -1536,9 +1555,9 @@ void LLPanelEstateInfo::onClickAddEstateManager(void* user_data) if (!list) return; if (list->getItemCount() >= ESTATE_MAX_MANAGERS) { // Tell user they can't add more managers - LLStringUtil::format_map_t args; - args["[MAX_MANAGER]"] = llformat("%d",ESTATE_MAX_MANAGERS); - gViewerWindow->alertXml("MaxManagersOnRegion", args); + LLSD args; + args["MAX_MANAGER"] = llformat("%d",ESTATE_MAX_MANAGERS); + LLNotifications::instance().add("MaxManagersOnRegion", args); } else { // Go pick managers to add @@ -1558,7 +1577,6 @@ void LLPanelEstateInfo::onClickRemoveEstateManager(void* user_data) struct LLKickFromEstateInfo { LLPanelEstateInfo *mEstatePanelp; - std::string mDialogName; LLUUID mAgentID; }; @@ -1590,45 +1608,42 @@ void LLPanelEstateInfo::onKickUserCommit(const std::vector<std::string>& names, //keep track of what user they want to kick and other misc info LLKickFromEstateInfo *kick_info = new LLKickFromEstateInfo(); kick_info->mEstatePanelp = self; - kick_info->mDialogName = "EstateKickUser"; kick_info->mAgentID = ids[0]; //Bring up a confirmation dialog - LLStringUtil::format_map_t args; - args["[EVIL_USER]"] = names[0]; - gViewerWindow->alertXml(kick_info->mDialogName, args, LLPanelEstateInfo::kickUserConfirm, (void*)kick_info); + LLSD args; + args["EVIL_USER"] = names[0]; + LLSD payload; + payload["agent_id"] = ids[0]; + LLNotifications::instance().add("EstateKickUser", args, payload, boost::bind(&LLPanelEstateInfo::kickUserConfirm, self, _1, _2)); } -void LLPanelEstateInfo::kickUserConfirm(S32 option, void* userdata) +bool LLPanelEstateInfo::kickUserConfirm(const LLSD& notification, const LLSD& response) { - //extract the callback parameter - LLKickFromEstateInfo *kick_info = (LLKickFromEstateInfo*) userdata; - if (!kick_info) return; - - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - strings_t strings; - std::string buffer; - + S32 option = LLNotification::getSelectedOption(notification, response); switch(option) { case 0: - //Kick User - kick_info->mAgentID.toString(buffer); - strings.push_back(buffer); + { + //Kick User + strings_t strings; + strings.push_back(notification["payload"]["agent_id"].asString()); - kick_info->mEstatePanelp->sendEstateOwnerMessage(gMessageSystem, "kickestate", invoice, strings); - break; + sendEstateOwnerMessage(gMessageSystem, "kickestate", LLFloaterRegionInfo::getLastInvoice(), strings); + break; + } default: break; } - - delete kick_info; - kick_info = NULL; + return false; } //--------------------------------------------------------------------------- // Core Add/Remove estate access methods +// TODO: INTERNATIONAL: don't build message text here; +// instead, create multiple translatable messages and choose +// one based on the status. //--------------------------------------------------------------------------- std::string all_estates_text() { @@ -1669,6 +1684,33 @@ bool LLPanelEstateInfo::isLindenEstate() typedef std::vector<LLUUID> AgentOrGroupIDsVector; struct LLEstateAccessChangeInfo { + LLEstateAccessChangeInfo(const LLSD& sd) + { + mDialogName = sd["dialog_name"].asString(); + mOperationFlag = (U32)sd["operation"].asInteger(); + LLSD::array_const_iterator end_it = sd["allowed_ids"].endArray(); + for (LLSD::array_const_iterator id_it = sd["allowed_ids"].beginArray(); + id_it != end_it; + ++id_it) + { + mAgentOrGroupIDs.push_back(id_it->asUUID()); + } + } + + const LLSD asLLSD() const + { + LLSD sd; + sd["name"] = mDialogName; + sd["operation"] = (S32)mOperationFlag; + for (AgentOrGroupIDsVector::const_iterator it = mAgentOrGroupIDs.begin(); + it != mAgentOrGroupIDs.end(); + ++it) + { + sd["allowed_ids"].append(*it); + } + return sd; + } + U32 mOperationFlag; // ESTATE_ACCESS_BANNED_AGENT_ADD, _REMOVE, etc. std::string mDialogName; AgentOrGroupIDsVector mAgentOrGroupIDs; // List of agent IDs to apply to this change @@ -1678,56 +1720,65 @@ struct LLEstateAccessChangeInfo // static void LLPanelEstateInfo::addAllowedGroup2(LLUUID id, void* user_data) { - LLEstateAccessChangeInfo* change_info = new LLEstateAccessChangeInfo; - change_info->mOperationFlag = ESTATE_ACCESS_ALLOWED_GROUP_ADD; - change_info->mDialogName = "EstateAllowedGroupAdd"; - change_info->mAgentOrGroupIDs.push_back(id); + LLSD payload; + payload["operation"] = (S32)ESTATE_ACCESS_ALLOWED_GROUP_ADD; + payload["dialog_name"] = "EstateAllowedGroupAdd"; + payload["allowed_ids"].append(id); + + LLSD args; + args["ALL_ESTATES"] = all_estates_text(); + LLNotification::Params params("EstateAllowedGroupAdd"); + params.payload(payload) + .substitutions(args) + .functor(accessCoreConfirm); if (isLindenEstate()) { - accessCoreConfirm(0, (void*)change_info); + LLNotifications::instance().forceResponse(params, 0); } else { - LLStringUtil::format_map_t args; - args["[ALL_ESTATES]"] = all_estates_text(); - gViewerWindow->alertXml(change_info->mDialogName, args, accessCoreConfirm, (void*)change_info); + LLNotifications::instance().add(params); } } // static void LLPanelEstateInfo::accessAddCore(U32 operation_flag, const std::string& dialog_name) { - LLEstateAccessChangeInfo* change_info = new LLEstateAccessChangeInfo; - change_info->mOperationFlag = operation_flag; - change_info->mDialogName = dialog_name; + LLSD payload; + payload["operation"] = (S32)operation_flag; + payload["dialog_name"] = dialog_name; // agent id filled in after avatar picker + LLNotification::Params params("ChangeLindenAccess"); + params.payload(payload) + .functor(accessAddCore2); + if (isLindenEstate()) { - gViewerWindow->alertXml("ChangeLindenAccess", accessAddCore2, change_info); + LLNotifications::instance().add(params); } else { // same as clicking "OK" - accessAddCore2(0, change_info); + LLNotifications::instance().forceResponse(params, 0); } } // static -void LLPanelEstateInfo::accessAddCore2(S32 option, void* data) +bool LLPanelEstateInfo::accessAddCore2(const LLSD& notification, const LLSD& response) { - LLEstateAccessChangeInfo* change_info = (LLEstateAccessChangeInfo*)data; + S32 option = LLNotification::getSelectedOption(notification, response); if (option != 0) { // abort change - delete change_info; - change_info = NULL; - return; + return false; } + LLEstateAccessChangeInfo* change_info = new LLEstateAccessChangeInfo(notification["payload"]); // avatar picker yes multi-select, yes close-on-select LLFloaterAvatarPicker::show(accessAddCore3, (void*)change_info, TRUE, TRUE); + return false; } // static @@ -1756,12 +1807,12 @@ void LLPanelEstateInfo::accessAddCore3(const std::vector<std::string>& names, co int currentCount = (list ? list->getItemCount() : 0); if (ids.size() + currentCount > ESTATE_MAX_ACCESS_IDS) { - LLStringUtil::format_map_t args; - args["[NUM_ADDED]"] = llformat("%d",ids.size()); - args["[MAX_AGENTS]"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); - args["[LIST_TYPE]"] = "Allowed Residents"; - args["[NUM_EXCESS]"] = llformat("%d",(ids.size()+currentCount)-ESTATE_MAX_ACCESS_IDS); - gViewerWindow->alertXml("MaxAgentOnRegionBatch", args); + LLSD args; + args["NUM_ADDED"] = llformat("%d",ids.size()); + args["MAX_AGENTS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); + args["LIST_TYPE"] = "Allowed Residents"; + args["NUM_EXCESS"] = llformat("%d",(ids.size()+currentCount)-ESTATE_MAX_ACCESS_IDS); + LLNotifications::instance().add("MaxAgentOnRegionBatch", args); delete change_info; return; } @@ -1772,28 +1823,34 @@ void LLPanelEstateInfo::accessAddCore3(const std::vector<std::string>& names, co int currentCount = (list ? list->getItemCount() : 0); if (ids.size() + currentCount > ESTATE_MAX_ACCESS_IDS) { - LLStringUtil::format_map_t args; - args["[NUM_ADDED]"] = llformat("%d",ids.size()); - args["[MAX_AGENTS]"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); - args["[LIST_TYPE]"] = "Banned Residents"; - args["[NUM_EXCESS]"] = llformat("%d",(ids.size()+currentCount)-ESTATE_MAX_ACCESS_IDS); - gViewerWindow->alertXml("MaxAgentOnRegionBatch", args); + LLSD args; + args["NUM_ADDED"] = llformat("%d",ids.size()); + args["MAX_AGENTS"] = llformat("%d",ESTATE_MAX_ACCESS_IDS); + args["LIST_TYPE"] = "Banned Residents"; + args["NUM_EXCESS"] = llformat("%d",(ids.size()+currentCount)-ESTATE_MAX_ACCESS_IDS); + LLNotifications::instance().add("MaxAgentOnRegionBatch", args); delete change_info; return; } } + LLSD args; + args["ALL_ESTATES"] = all_estates_text(); + + LLNotification::Params params(change_info->mDialogName); + params.substitutions(args) + .payload(change_info->asLLSD()) + .functor(accessCoreConfirm); + if (isLindenEstate()) { // just apply to this estate - accessCoreConfirm(0, (void*)change_info); + LLNotifications::instance().forceResponse(params, 0); } else { // ask if this estate or all estates with this owner - LLStringUtil::format_map_t args; - args["[ALL_ESTATES]"] = all_estates_text(); - gViewerWindow->alertXml(change_info->mDialogName, args, accessCoreConfirm, (void*)change_info); + LLNotifications::instance().add(params); } } @@ -1809,85 +1866,87 @@ void LLPanelEstateInfo::accessRemoveCore(U32 operation_flag, const std::string& if (list_vector.size() == 0) return; - LLEstateAccessChangeInfo* change_info = new LLEstateAccessChangeInfo; - change_info->mOperationFlag = operation_flag; - change_info->mDialogName = dialog_name; + LLSD payload; + payload["operation"] = (S32)operation_flag; + payload["dialog_name"] = dialog_name; for (std::vector<LLScrollListItem*>::const_iterator iter = list_vector.begin(); iter != list_vector.end(); iter++) { LLScrollListItem *item = (*iter); - change_info->mAgentOrGroupIDs.push_back(item->getUUID()); + payload["allowed_ids"].append(item->getUUID()); } + LLNotification::Params params("ChangeLindenAccess"); + params.payload(payload) + .functor(accessRemoveCore2); + if (isLindenEstate()) { // warn on change linden estate - gViewerWindow->alertXml("ChangeLindenAccess", - accessRemoveCore2, - (void*)change_info); + LLNotifications::instance().add(params); } else { // just proceed, as if clicking OK - accessRemoveCore2(0, (void*)change_info); + LLNotifications::instance().forceResponse(params, 0); } } // static -void LLPanelEstateInfo::accessRemoveCore2(S32 option, void* data) +bool LLPanelEstateInfo::accessRemoveCore2(const LLSD& notification, const LLSD& response) { - LLEstateAccessChangeInfo* change_info = (LLEstateAccessChangeInfo*)data; + S32 option = LLNotification::getSelectedOption(notification, response); if (option != 0) { // abort - delete change_info; - change_info = NULL; - return; + return false; } // If Linden estate, can only apply to "this" estate, not all estates // owned by NULL. if (isLindenEstate()) { - accessCoreConfirm(0, (void*)change_info); + accessCoreConfirm(notification, response); } else { - LLStringUtil::format_map_t args; - args["[ALL_ESTATES]"] = all_estates_text(); - gViewerWindow->alertXml(change_info->mDialogName, - args, - accessCoreConfirm, - (void*)change_info); + LLSD args; + args["ALL_ESTATES"] = all_estates_text(); + LLNotifications::instance().add(notification["payload"]["dialog_name"], + args, + notification["payload"], + accessCoreConfirm); } + return false; } // Used for both access add and remove operations, depending on the mOperationFlag // passed in (ESTATE_ACCESS_BANNED_AGENT_ADD, ESTATE_ACCESS_ALLOWED_AGENT_REMOVE, etc.) // static -void LLPanelEstateInfo::accessCoreConfirm(S32 option, void* data) +bool LLPanelEstateInfo::accessCoreConfirm(const LLSD& notification, const LLSD& response) { - LLEstateAccessChangeInfo* change_info = (LLEstateAccessChangeInfo*)data; - const U32 originalFlags = change_info->mOperationFlag; - AgentOrGroupIDsVector& ids = change_info->mAgentOrGroupIDs; + S32 option = LLNotification::getSelectedOption(notification, response); + const U32 originalFlags = (U32)notification["payload"]["operation"].asInteger(); LLViewerRegion* region = gAgent.getRegion(); - for (AgentOrGroupIDsVector::const_iterator iter = ids.begin(); - iter != ids.end(); + LLSD::array_const_iterator end_it = notification["payload"]["allowed_ids"].endArray(); + + for (LLSD::array_const_iterator iter = notification["payload"]["allowed_ids"].beginArray(); + iter != end_it; iter++) { U32 flags = originalFlags; - if (iter + 1 != ids.end()) + if (iter + 1 != end_it) flags |= ESTATE_ACCESS_NO_REPLY; - const LLUUID id = (*iter); - if ((change_info->mOperationFlag & ESTATE_ACCESS_BANNED_AGENT_ADD) + const LLUUID id = iter->asUUID(); + if (((U32)notification["payload"]["operation"].asInteger() & ESTATE_ACCESS_BANNED_AGENT_ADD) && region && (region->getOwner() == id)) { - gViewerWindow->alertXml("OwnerCanNotBeDenied"); + LLNotifications::instance().add("OwnerCanNotBeDenied"); break; } switch(option) @@ -1919,8 +1978,7 @@ void LLPanelEstateInfo::accessCoreConfirm(S32 option, void* data) break; } } - delete change_info; - change_info = NULL; + return false; } // key = "estateaccessdelta" @@ -2146,34 +2204,34 @@ BOOL LLPanelEstateInfo::sendUpdate() { llinfos << "LLPanelEsateInfo::sendUpdate()" << llendl; + LLNotification::Params params("ChangeLindenEstate"); + params.functor(boost::bind(&LLPanelEstateInfo::callbackChangeLindenEstate, this, _1, _2)); + if (getEstateID() <= ESTATE_LAST_LINDEN) { // trying to change reserved estate, warn - gViewerWindow->alertXml("ChangeLindenEstate", - callbackChangeLindenEstate, - this); + LLNotifications::instance().add(params); } else { // for normal estates, just make the change - callbackChangeLindenEstate(0, this); + LLNotifications::instance().forceResponse(params, 0); } return TRUE; } -// static -void LLPanelEstateInfo::callbackChangeLindenEstate(S32 option, void* data) +bool LLPanelEstateInfo::callbackChangeLindenEstate(const LLSD& notification, const LLSD& response) { - LLPanelEstateInfo* self = (LLPanelEstateInfo*)data; + S32 option = LLNotification::getSelectedOption(notification, response); switch(option) { case 0: // send the update - if (!self->commitEstateInfoCaps()) + if (!commitEstateInfoCaps()) { // the caps method failed, try the old way LLFloaterRegionInfo::nextInvoice(); - self->commitEstateInfoDataserver(); + commitEstateInfoDataserver(); } // we don't want to do this because we'll get it automatically from the sim // after the spaceserver processes it @@ -2188,6 +2246,7 @@ void LLPanelEstateInfo::callbackChangeLindenEstate(S32 option, void* data) // do nothing break; } + return false; } @@ -2572,18 +2631,15 @@ BOOL LLPanelEstateInfo::checkSunHourSlider(LLUICtrl* child_ctrl) void LLPanelEstateInfo::onClickMessageEstate(void* userdata) { llinfos << "LLPanelEstateInfo::onClickMessageEstate" << llendl; - gViewerWindow->alertXmlEditText("MessageEstate", LLStringUtil::format_map_t(), - NULL, NULL, - onMessageCommit, userdata); + LLNotifications::instance().add("MessageEstate", LLSD(), LLSD(), boost::bind(&LLPanelEstateInfo::onMessageCommit, (LLPanelEstateInfo*)userdata, _1, _2)); } -// static -void LLPanelEstateInfo::onMessageCommit(S32 option, const std::string& text, void* userdata) +bool LLPanelEstateInfo::onMessageCommit(const LLSD& notification, const LLSD& response) { - if(option != 0) return; - if(text.empty()) return; - LLPanelEstateInfo* self = (LLPanelEstateInfo*)userdata; - if(!self) return; + S32 option = LLNotification::getSelectedOption(notification, response); + std::string text = response["message"].asString(); + if(option != 0) return false; + if(text.empty()) return false; llinfos << "Message to everyone: " << text << llendl; strings_t strings; //integers_t integers; @@ -2592,7 +2648,8 @@ void LLPanelEstateInfo::onMessageCommit(S32 option, const std::string& text, voi strings.push_back(strings_t::value_type(name)); strings.push_back(strings_t::value_type(text)); LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - self->sendEstateOwnerMessage(gMessageSystem, "instantmessage", invoice, strings); + sendEstateOwnerMessage(gMessageSystem, "instantmessage", invoice, strings); + return false; } LLPanelEstateCovenant::LLPanelEstateCovenant() @@ -2695,9 +2752,10 @@ BOOL LLPanelEstateCovenant::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop *accept = ACCEPT_YES_COPY_SINGLE; if (item && drop) { - gViewerWindow->alertXml("EstateChangeCovenant", - LLPanelEstateCovenant::confirmChangeCovenantCallback, - item); + LLSD payload; + payload["item_id"] = item->getUUID(); + LLNotifications::instance().add("EstateChangeCovenant", LLSD(), payload, + LLPanelEstateCovenant::confirmChangeCovenantCallback); } break; default: @@ -2709,12 +2767,13 @@ BOOL LLPanelEstateCovenant::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop } // static -void LLPanelEstateCovenant::confirmChangeCovenantCallback(S32 option, void* userdata) +bool LLPanelEstateCovenant::confirmChangeCovenantCallback(const LLSD& notification, const LLSD& response) { - LLInventoryItem* item = (LLInventoryItem*)userdata; + S32 option = LLNotification::getSelectedOption(notification, response); + LLInventoryItem* item = gInventory.getItem(notification["payload"]["item_id"].asUUID()); LLPanelEstateCovenant* self = LLFloaterRegionInfo::getPanelCovenant(); - if (!item || !self) return; + if (!item || !self) return false; switch(option) { @@ -2724,22 +2783,22 @@ void LLPanelEstateCovenant::confirmChangeCovenantCallback(S32 option, void* user default: break; } + return false; } // static void LLPanelEstateCovenant::resetCovenantID(void* userdata) { - gViewerWindow->alertXml("EstateChangeCovenant", - LLPanelEstateCovenant::confirmResetCovenantCallback, - NULL); + LLNotifications::instance().add("EstateChangeCovenant", LLSD(), LLSD(), confirmResetCovenantCallback); } // static -void LLPanelEstateCovenant::confirmResetCovenantCallback(S32 option, void* userdata) +bool LLPanelEstateCovenant::confirmResetCovenantCallback(const LLSD& notification, const LLSD& response) { LLPanelEstateCovenant* self = LLFloaterRegionInfo::getPanelCovenant(); - if (!self) return; + if (!self) return false; + S32 option = LLNotification::getSelectedOption(notification, response); switch(option) { case 0: @@ -2748,6 +2807,7 @@ void LLPanelEstateCovenant::confirmResetCovenantCallback(S32 option, void* userd default: break; } + return false; } void LLPanelEstateCovenant::loadInvItem(LLInventoryItem *itemp) @@ -2808,7 +2868,7 @@ void LLPanelEstateCovenant::onLoadComplete(LLVFS *vfs, if( !panelp->mEditor->importBuffer( buffer, file_length+1 ) ) { llwarns << "Problem importing estate covenant." << llendl; - gViewerWindow->alertXml("ProblemImportingEstateCovenant"); + LLNotifications::instance().add("ProblemImportingEstateCovenant"); } else { @@ -2829,15 +2889,15 @@ void LLPanelEstateCovenant::onLoadComplete(LLVFS *vfs, if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status || LL_ERR_FILE_EMPTY == status) { - gViewerWindow->alertXml("MissingNotecardAssetID"); + LLNotifications::instance().add("MissingNotecardAssetID"); } else if (LL_ERR_INSUFFICIENT_PERMISSIONS == status) { - gViewerWindow->alertXml("NotAllowedToViewNotecard"); + LLNotifications::instance().add("NotAllowedToViewNotecard"); } else { - gViewerWindow->alertXml("UnableToLoadNotecard"); + LLNotifications::instance().add("UnableToLoadNotecardAsset"); } llwarns << "Problem loading notecard: " << status << llendl; diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h index 8580189a2e..8c14e463ff 100644 --- a/indra/newview/llfloaterregioninfo.h +++ b/indra/newview/llfloaterregioninfo.h @@ -161,9 +161,9 @@ protected: static void onClickKick(void* userdata); static void onKickCommit(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* userdata); static void onClickKickAll(void* userdata); - static void onKickAllCommit(S32 option, void* userdata); + bool onKickAllCommit(const LLSD& notification, const LLSD& response); static void onClickMessage(void* userdata); - static void onMessageCommit(S32 option, const std::string& text, void* userdata); + bool onMessageCommit(const LLSD& notification, const LLSD& response); static void onClickManageTelehub(void* data); }; @@ -186,11 +186,11 @@ protected: static void onClickChooseAvatar(void*); static void callbackAvatarID(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* data); static void onClickReturn(void *); - static void callbackReturn(S32 option, void*); + bool callbackReturn(const LLSD& notification, const LLSD& response); static void onClickTopColliders(void*); static void onClickTopScripts(void*); static void onClickRestart(void* data); - static void callbackRestart(S32 option, void* data); + bool callbackRestart(const LLSD& notification, const LLSD& response); static void onClickCancelRestart(void* data); private: @@ -240,7 +240,7 @@ protected: static void onClickDownloadRaw(void*); static void onClickUploadRaw(void*); static void onClickBakeTerrain(void*); - static void callbackBakeTerrain(S32 option, void* data); + bool callbackBakeTerrain(const LLSD& notification, const LLSD& response); }; ///////////////////////////////////////////////////////////////////////////// @@ -269,27 +269,27 @@ public: static void onClickKickUser(void* userdata); // Group picker callback is different, can't use core methods below - static void addAllowedGroup(S32 option, void* data); + bool addAllowedGroup(const LLSD& notification, const LLSD& response); static void addAllowedGroup2(LLUUID id, void* data); // Core methods for all above add/remove button clicks static void accessAddCore(U32 operation_flag, const std::string& dialog_name); - static void accessAddCore2(S32 option, void* data); + static bool accessAddCore2(const LLSD& notification, const LLSD& response); static void accessAddCore3(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* data); static void accessRemoveCore(U32 operation_flag, const std::string& dialog_name, const std::string& list_ctrl_name); - static void accessRemoveCore2(S32 option, void* data); + static bool accessRemoveCore2(const LLSD& notification, const LLSD& response); // used for both add and remove operations - static void accessCoreConfirm(S32 option, void* data); - static void kickUserConfirm(S32 option, void* userdata); + static bool accessCoreConfirm(const LLSD& notification, const LLSD& response); + bool kickUserConfirm(const LLSD& notification, const LLSD& response); // Send the actual EstateOwnerRequest "estateaccessdelta" message static void sendEstateAccessDelta(U32 flags, const LLUUID& agent_id); static void onKickUserCommit(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* userdata); static void onClickMessageEstate(void* data); - static void onMessageCommit(S32 option, const std::string& text, void* data); + bool onMessageCommit(const LLSD& notification, const LLSD& response); LLPanelEstateInfo(); ~LLPanelEstateInfo() {} @@ -344,7 +344,7 @@ public: protected: virtual BOOL sendUpdate(); // confirmation dialog callback - static void callbackChangeLindenEstate(S32 opt, void* data); + bool callbackChangeLindenEstate(const LLSD& notification, const LLSD& response); void commitEstateInfoDataserver(); bool commitEstateInfoCaps(); @@ -377,9 +377,9 @@ public: BOOL drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, std::string& tooltip_msg); - static void confirmChangeCovenantCallback(S32 option, void* userdata); + static bool confirmChangeCovenantCallback(const LLSD& notification, const LLSD& response); static void resetCovenantID(void* userdata); - static void confirmResetCovenantCallback(S32 option, void* userdata); + static bool confirmResetCovenantCallback(const LLSD& notification, const LLSD& response); void sendChangeCovenantID(const LLUUID &asset_id); void loadInvItem(LLInventoryItem *itemp); static void onLoadComplete(LLVFS *vfs, diff --git a/indra/newview/llfloaterreporter.cpp b/indra/newview/llfloaterreporter.cpp index da435c9452..e87ffeb258 100644 --- a/indra/newview/llfloaterreporter.cpp +++ b/indra/newview/llfloaterreporter.cpp @@ -207,10 +207,10 @@ void LLFloaterReporter::processRegionInfo(LLMessageSystem* msg) { if ( gEmailToEstateOwner ) { - gViewerWindow->alertXml("HelpReportAbuseEmailEO"); + LLNotifications::instance().add("HelpReportAbuseEmailEO"); } else - gViewerWindow->alertXml("HelpReportAbuseEmailLL"); + LLNotifications::instance().add("HelpReportAbuseEmailLL"); }; } @@ -406,7 +406,7 @@ void LLFloaterReporter::onClickSend(void *userdata) category_value == IP_CONTENT_REMOVAL || category_value == IP_PERMISSONS_EXPLOIT) { - gViewerWindow->alertXml("HelpReportAbuseContainsCopyright"); + LLNotifications::instance().add("HelpReportAbuseContainsCopyright"); self->mCopyrightWarningSeen = TRUE; return; } @@ -415,7 +415,7 @@ void LLFloaterReporter::onClickSend(void *userdata) { // IP_CONTENT_REMOVAL *always* shows the dialog - // ergo you can never send that abuse report type. - gViewerWindow->alertXml("HelpReportAbuseContainsCopyright"); + LLNotifications::instance().add("HelpReportAbuseContainsCopyright"); return; } } @@ -524,7 +524,7 @@ void LLFloaterReporter::showFromMenu(EReportType report_type) if (report_type == BUG_REPORT) { - gViewerWindow->alertXml("HelpReportBug"); + LLNotifications::instance().add("HelpReportBug"); } else { @@ -610,11 +610,11 @@ bool LLFloaterReporter::validateReport() { if ( mReportType != BUG_REPORT ) { - gViewerWindow->alertXml("HelpReportAbuseSelectCategory"); + LLNotifications::instance().add("HelpReportAbuseSelectCategory"); } else { - gViewerWindow->alertXml("HelpReportBugSelectCategory"); + LLNotifications::instance().add("HelpReportBugSelectCategory"); } return false; } @@ -623,13 +623,13 @@ bool LLFloaterReporter::validateReport() { if ( childGetText("abuser_name_edit").empty() ) { - gViewerWindow->alertXml("HelpReportAbuseAbuserNameEmpty"); + LLNotifications::instance().add("HelpReportAbuseAbuserNameEmpty"); return false; }; if ( childGetText("abuse_location_edit").empty() ) { - gViewerWindow->alertXml("HelpReportAbuseAbuserLocationEmpty"); + LLNotifications::instance().add("HelpReportAbuseAbuserLocationEmpty"); return false; }; }; @@ -638,11 +638,11 @@ bool LLFloaterReporter::validateReport() { if ( mReportType != BUG_REPORT ) { - gViewerWindow->alertXml("HelpReportAbuseSummaryEmpty"); + LLNotifications::instance().add("HelpReportAbuseSummaryEmpty"); } else { - gViewerWindow->alertXml("HelpReportBugSummaryEmpty"); + LLNotifications::instance().add("HelpReportBugSummaryEmpty"); } return false; }; @@ -651,11 +651,11 @@ bool LLFloaterReporter::validateReport() { if ( mReportType != BUG_REPORT ) { - gViewerWindow->alertXml("HelpReportAbuseDetailsEmpty"); + LLNotifications::instance().add("HelpReportAbuseDetailsEmpty"); } else { - gViewerWindow->alertXml("HelpReportBugDetailsEmpty"); + LLNotifications::instance().add("HelpReportBugDetailsEmpty"); } return false; }; @@ -951,13 +951,12 @@ void LLFloaterReporter::uploadDoneCallback(const LLUUID &uuid, void *user_data, if(result < 0) { - LLStringUtil::format_map_t args; - std::string reason = std::string(LLAssetStorage::getErrorString(result)); - args["[REASON]"] = reason; - gViewerWindow->alertXml("ErrorUploadingReportScreenshot", args); + LLSD args; + args["REASON"] = std::string(LLAssetStorage::getErrorString(result)); + LLNotifications::instance().add("ErrorUploadingReportScreenshot", args); std::string err_msg("There was a problem uploading a report screenshot"); - err_msg += " due to the following reason: " + reason; + err_msg += " due to the following reason: " + args["REASON"].asString(); llwarns << err_msg << llendl; return; } diff --git a/indra/newview/llfloatersellland.cpp b/indra/newview/llfloatersellland.cpp index 749ccbe7fa..1e1d1f6fd2 100644 --- a/indra/newview/llfloatersellland.cpp +++ b/indra/newview/llfloatersellland.cpp @@ -79,9 +79,9 @@ private: static void doSelectAgent(void *userdata); static void doCancel(void *userdata); static void doSellLand(void *userdata); - static void onConfirmSale(S32 option, void *userdata); + bool onConfirmSale(const LLSD& notification, const LLSD& response); static void doShowObjects(void *userdata); - static void callbackHighlightTransferable(S32 option, void* userdata); + static bool callbackHighlightTransferable(const LLSD& notification, const LLSD& response); static void callbackAvatarPick(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* data); @@ -443,15 +443,16 @@ void LLFloaterSellLandUI::doShowObjects(void *userdata) send_parcel_select_objects(parcel->getLocalID(), RT_SELL); - LLNotifyBox::showXml("TransferObjectsHighlighted", - callbackHighlightTransferable, - userdata); + LLNotifications::instance().add("TransferObjectsHighlighted", + LLSD(), LLSD(), + &LLFloaterSellLandUI::callbackHighlightTransferable); } // static -void LLFloaterSellLandUI::callbackHighlightTransferable(S32 option, void* userdata) +bool LLFloaterSellLandUI::callbackHighlightTransferable(const LLSD& notification, const LLSD& data) { LLSelectMgr::getInstance()->unhighlightAll(); + return false; } // static @@ -462,83 +463,89 @@ void LLFloaterSellLandUI::doSellLand(void *userdata) LLParcel* parcel = self->mParcelSelection->getParcel(); // Do a confirmation - if (!parcel->getForSale()) + S32 sale_price = self->childGetValue("price"); + S32 area = parcel->getArea(); + std::string authorizedBuyerName = "Anyone"; + bool sell_to_anyone = true; + if ("user" == self->childGetValue("sell_to").asString()) { - S32 sale_price = self->childGetValue("price"); - S32 area = parcel->getArea(); - std::string authorizedBuyerName = "Anyone"; - bool sell_to_anyone = true; - if ("user" == self->childGetValue("sell_to").asString()) - { - authorizedBuyerName = self->childGetText("sell_to_agent"); - sell_to_anyone = false; - } + authorizedBuyerName = self->childGetText("sell_to_agent"); + sell_to_anyone = false; + } - // must sell to someone if indicating sale to anyone - if ((sale_price == 0) && sell_to_anyone) - { - gViewerWindow->alertXml("SalePriceRestriction"); - return; - } + // must sell to someone if indicating sale to anyone + if (!parcel->getForSale() + && (sale_price == 0) + && sell_to_anyone) + { + LLNotifications::instance().add("SalePriceRestriction"); + return; + } - LLStringUtil::format_map_t args; - args["[LAND_SIZE]"] = llformat("%d",area); - args["[SALE_PRICE]"] = llformat("%d",sale_price); - args["[NAME]"] = authorizedBuyerName; + LLSD args; + args["LAND_SIZE"] = llformat("%d",area); + args["SALE_PRICE"] = llformat("%d",sale_price); + args["NAME"] = authorizedBuyerName; - if (sell_to_anyone) - { - gViewerWindow->alertXml("ConfirmLandSaleToAnyoneChange", args, onConfirmSale, self); - } - else - { - gViewerWindow->alertXml("ConfirmLandSaleChange", args, onConfirmSale, self); - } + LLNotification::Params params("ConfirmLandSaleChange"); + params.substitutions(args) + .functor(boost::bind(&LLFloaterSellLandUI::onConfirmSale, self, _1, _2)); + + if (sell_to_anyone) + { + params.name("ConfirmLandSaleToAnyoneChange"); + } + + if (parcel->getForSale()) + { + // parcel already for sale, so ignore this question + LLNotifications::instance().forceResponse(params, -1); } else { - onConfirmSale(-1, self); + // ask away + LLNotifications::instance().add(params); } + } -// static -void LLFloaterSellLandUI::onConfirmSale(S32 option, void *userdata) +bool LLFloaterSellLandUI::onConfirmSale(const LLSD& notification, const LLSD& response) { + S32 option = LLNotification::getSelectedOption(notification, response); if (option != 0) { - return; + return false; } - LLFloaterSellLandUI* self = (LLFloaterSellLandUI*)userdata; - S32 sale_price = self->childGetValue("price"); + S32 sale_price = childGetValue("price"); // Valid extracted data if (sale_price < 0) { // TomY TODO: Throw an error - return; + return false; } - LLParcel* parcel = self->mParcelSelection->getParcel(); - if (!parcel) return; + LLParcel* parcel = mParcelSelection->getParcel(); + if (!parcel) return false; // can_agent_modify_parcel deprecated by GROUPS // if (!can_agent_modify_parcel(parcel)) // { -// self->close(); +// close(); // return; // } parcel->setParcelFlag(PF_FOR_SALE, TRUE); parcel->setSalePrice(sale_price); bool sell_with_objects = false; - if ("yes" == self->childGetValue("sell_objects").asString()) + if ("yes" == childGetValue("sell_objects").asString()) { sell_with_objects = true; } parcel->setSellWithObjects(sell_with_objects); - if ("user" == self->childGetValue("sell_to").asString()) + if ("user" == childGetValue("sell_to").asString()) { - parcel->setAuthorizedBuyerID(self->mAuthorizedBuyer); + parcel->setAuthorizedBuyerID(mAuthorizedBuyer); } else { @@ -548,5 +555,6 @@ void LLFloaterSellLandUI::onConfirmSale(S32 option, void *userdata) // Send update to server LLViewerParcelMgr::getInstance()->sendParcelPropertiesUpdate( parcel ); - self->close(); + close(); + return false; } diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp index dcfb1e9442..207b2ea655 100644 --- a/indra/newview/llfloatersnapshot.cpp +++ b/indra/newview/llfloatersnapshot.cpp @@ -966,7 +966,7 @@ void LLSnapshotLivePreview::saveTexture() } else { - gViewerWindow->alertXml("ErrorEncodingSnapshot"); + LLNotifications::instance().add("ErrorEncodingSnapshot"); llwarns << "Error encoding snapshot" << llendl; } diff --git a/indra/newview/llfloatertopobjects.cpp b/indra/newview/llfloatertopobjects.cpp index eea6b40cba..3b79f58db7 100644 --- a/indra/newview/llfloatertopobjects.cpp +++ b/indra/newview/llfloatertopobjects.cpp @@ -353,17 +353,19 @@ void LLFloaterTopObjects::doToObjects(int action, bool all) } //static -void LLFloaterTopObjects::callbackReturnAll(S32 option, void* userdata) +bool LLFloaterTopObjects::callbackReturnAll(const LLSD& notification, const LLSD& response) { + S32 option = LLNotification::getSelectedOption(notification, response); if (option == 0) { sInstance->doToObjects(ACTION_RETURN, true); } + return false; } void LLFloaterTopObjects::onReturnAll(void* data) { - gViewerWindow->alertXml("ReturnAllTopObjects", callbackReturnAll, NULL); + LLNotifications::instance().add("ReturnAllTopObjects", LLSD(), LLSD(), &callbackReturnAll); } @@ -374,17 +376,19 @@ void LLFloaterTopObjects::onReturnSelected(void* data) //static -void LLFloaterTopObjects::callbackDisableAll(S32 option, void* userdata) +bool LLFloaterTopObjects::callbackDisableAll(const LLSD& notification, const LLSD& response) { + S32 option = LLNotification::getSelectedOption(notification, response); if (option == 0) { sInstance->doToObjects(ACTION_DISABLE, true); } + return false; } void LLFloaterTopObjects::onDisableAll(void* data) { - gViewerWindow->alertXml("DisableAllTopObjects", callbackDisableAll, NULL); + LLNotifications::instance().add("DisableAllTopObjects", LLSD(), LLSD(), callbackDisableAll); } void LLFloaterTopObjects::onDisableSelected(void* data) diff --git a/indra/newview/llfloatertopobjects.h b/indra/newview/llfloatertopobjects.h index 5b23e737d7..a6f07a6a34 100644 --- a/indra/newview/llfloatertopobjects.h +++ b/indra/newview/llfloatertopobjects.h @@ -72,8 +72,8 @@ private: static void onDisableAll(void* data); static void onDisableSelected(void* data); - static void callbackReturnAll(S32 option, void* userdata); - static void callbackDisableAll(S32 option, void* userdata); + static bool callbackReturnAll(const LLSD& notification, const LLSD& response); + static bool callbackDisableAll(const LLSD& notification, const LLSD& response); static void onGetByOwnerName(LLUICtrl* ctrl, void* data); static void onGetByObjectName(LLUICtrl* ctrl, void* data); diff --git a/indra/newview/llfloatertos.cpp b/indra/newview/llfloatertos.cpp index ad592f909e..bd09bf9ef6 100644 --- a/indra/newview/llfloatertos.cpp +++ b/indra/newview/llfloatertos.cpp @@ -257,7 +257,7 @@ void LLFloaterTOS::onCancel( void* userdata ) { LLFloaterTOS* self = (LLFloaterTOS*) userdata; llinfos << "User disagrees with TOS." << llendl; - gViewerWindow->alertXml("MustAgreeToLogIn", login_alert_done); + LLNotifications::instance().add("MustAgreeToLogIn", LLSD(), LLSD(), login_alert_done); LLStartUp::setStartupState( STATE_LOGIN_SHOW ); self->mLoadCompleteCount = 0; // reset counter for next time we come to TOS self->close(); // destroys this object diff --git a/indra/newview/llfloaterurlentry.cpp b/indra/newview/llfloaterurlentry.cpp index 69916f80ea..3efd6eed61 100644 --- a/indra/newview/llfloaterurlentry.cpp +++ b/indra/newview/llfloaterurlentry.cpp @@ -262,32 +262,30 @@ void LLFloaterURLEntry::onBtnCancel( void* userdata ) //----------------------------------------------------------------------------- void LLFloaterURLEntry::onBtnClear( void* userdata ) { - gViewerWindow->alertXml( "ConfirmClearMediaUrlList", callback_clear_url_list, userdata ); + LLNotifications::instance().add( "ConfirmClearMediaUrlList", LLSD(), LLSD(), + boost::bind(&LLFloaterURLEntry::callback_clear_url_list, (LLFloaterURLEntry*)userdata, _1, _2) ); } -void LLFloaterURLEntry::callback_clear_url_list(S32 option, void* userdata) +bool LLFloaterURLEntry::callback_clear_url_list(const LLSD& notification, const LLSD& response) { + S32 option = LLNotification::getSelectedOption(notification, response); if ( option == 0 ) // YES { - LLFloaterURLEntry *self =(LLFloaterURLEntry *)userdata; - - if ( self ) + // clear saved list + LLCtrlListInterface* url_list = childGetListInterface("media_entry"); + if ( url_list ) { - // clear saved list - LLCtrlListInterface* url_list = self->childGetListInterface("media_entry"); - if ( url_list ) - { - url_list->operateOnAll( LLCtrlListInterface::OP_DELETE ); - } + url_list->operateOnAll( LLCtrlListInterface::OP_DELETE ); + } - // clear current contents of combo box - self->mMediaURLEdit->clear(); + // clear current contents of combo box + mMediaURLEdit->clear(); - // clear stored version of list - LLURLHistory::clear("parcel"); + // clear stored version of list + LLURLHistory::clear("parcel"); - // cleared the list so disable Clear button - self->childSetEnabled( "clear_btn", false ); - } + // cleared the list so disable Clear button + childSetEnabled( "clear_btn", false ); } + return false; } diff --git a/indra/newview/llfloaterurlentry.h b/indra/newview/llfloaterurlentry.h index 53e77880f5..f85106dffe 100644 --- a/indra/newview/llfloaterurlentry.h +++ b/indra/newview/llfloaterurlentry.h @@ -63,7 +63,7 @@ private: static void onBtnOK(void*); static void onBtnCancel(void*); static void onBtnClear(void*); - static void callback_clear_url_list(S32 option, void* userdata); + bool callback_clear_url_list(const LLSD& notification, const LLSD& response); }; #endif // LL_LLFLOATERURLENTRY_H diff --git a/indra/newview/llfloaterwater.cpp b/indra/newview/llfloaterwater.cpp index 4705b2f5ba..1a8beb7a58 100644 --- a/indra/newview/llfloaterwater.cpp +++ b/indra/newview/llfloaterwater.cpp @@ -176,15 +176,7 @@ void LLFloaterWater::onClickHelp(void* data) LLFloaterWater* self = LLFloaterWater::instance(); const std::string* xml_alert = (std::string*)data; - LLAlertDialog* dialogp = gViewerWindow->alertXml(*xml_alert); - if (dialogp) - { - LLFloater* root_floater = gFloaterView->getParentFloater(self); - if (root_floater) - { - root_floater->addDependentFloater(dialogp); - } - } + LLNotifications::instance().add(self->contextualNotification(*xml_alert)); } void LLFloaterWater::initHelpBtn(const std::string& name, const std::string& xml_alert) @@ -192,11 +184,14 @@ void LLFloaterWater::initHelpBtn(const std::string& name, const std::string& xml childSetAction(name, onClickHelp, new std::string(xml_alert)); } -void LLFloaterWater::newPromptCallback(S32 option, const std::string& text, void* userData) +bool LLFloaterWater::newPromptCallback(const LLSD& notification, const LLSD& response) { + std::string text = response["message"].asString(); + S32 option = LLNotification::getSelectedOption(notification, response); + if(text == "") { - return; + return false; } if(option == 0) { @@ -224,9 +219,10 @@ void LLFloaterWater::newPromptCallback(S32 option, const std::string& text, void } else { - gViewerWindow->alertXml("ExistsWaterPresetAlert"); + LLNotifications::instance().add("ExistsWaterPresetAlert"); } } + return false; } void LLFloaterWater::syncMenu() @@ -596,8 +592,7 @@ void LLFloaterWater::onNormalMapPicked(LLUICtrl* ctrl, void* userData) void LLFloaterWater::onNewPreset(void* userData) { - gViewerWindow->alertXmlEditText("NewWaterPreset", LLStringUtil::format_map_t(), - NULL, NULL, newPromptCallback, NULL); + LLNotifications::instance().add("NewWaterPreset", LLSD(), LLSD(), newPromptCallback); } void LLFloaterWater::onSavePreset(void* userData) @@ -619,15 +614,16 @@ void LLFloaterWater::onSavePreset(void* userData) comboBox->getSelectedItemLabel()); if(sIt != sDefaultPresets.end() && !gSavedSettings.getBOOL("WaterEditPresets")) { - gViewerWindow->alertXml("WLNoEditDefault"); + LLNotifications::instance().add("WLNoEditDefault"); return; } - gViewerWindow->alertXml("WLSavePresetAlert", saveAlertCallback, sWaterMenu); + LLNotifications::instance().add("WLSavePresetAlert", LLSD(), LLSD(), saveAlertCallback); } -void LLFloaterWater::saveAlertCallback(S32 option, void* userdata) +bool LLFloaterWater::saveAlertCallback(const LLSD& notification, const LLSD& response) { + S32 option = LLNotification::getSelectedOption(notification, response); // if they choose save, do it. Otherwise, don't do anything if(option == 0) { @@ -640,7 +636,7 @@ void LLFloaterWater::saveAlertCallback(S32 option, void* userdata) // comment this back in to save to file param_mgr->savePreset(param_mgr->mCurParams.mName); } - + return false; } void LLFloaterWater::onDeletePreset(void* userData) @@ -652,13 +648,14 @@ void LLFloaterWater::onDeletePreset(void* userData) return; } - LLStringUtil::format_map_t args; - args["[SKY]"] = combo_box->getSelectedValue().asString(); - gViewerWindow->alertXml("WLDeletePresetAlert", args, deleteAlertCallback, sWaterMenu); + LLSD args; + args["SKY"] = combo_box->getSelectedValue().asString(); + LLNotifications::instance().add("WLDeletePresetAlert", args, LLSD(), deleteAlertCallback); } -void LLFloaterWater::deleteAlertCallback(S32 option, void* userdata) +bool LLFloaterWater::deleteAlertCallback(const LLSD& notification, const LLSD& response) { + S32 option = LLNotification::getSelectedOption(notification, response); // if they choose delete, do it. Otherwise, don't do anything if(option == 0) { @@ -680,8 +677,8 @@ void LLFloaterWater::deleteAlertCallback(S32 option, void* userdata) std::set<std::string>::iterator sIt = sDefaultPresets.find(name); if(sIt != sDefaultPresets.end()) { - gViewerWindow->alertXml("WaterNoEditDefault"); - return; + LLNotifications::instance().add("WaterNoEditDefault"); + return false; } LLWaterParamManager::instance()->removeParamSet(name, true); @@ -710,6 +707,7 @@ void LLFloaterWater::deleteAlertCallback(S32 option, void* userdata) combo_box->setCurrentByIndex(new_index); } } + return false; } diff --git a/indra/newview/llfloaterwater.h b/indra/newview/llfloaterwater.h index 883b2a35f1..ad361266fe 100644 --- a/indra/newview/llfloaterwater.h +++ b/indra/newview/llfloaterwater.h @@ -63,7 +63,7 @@ public: static void onClickHelp(void* data); void initHelpBtn(const std::string& name, const std::string& xml_alert); - static void newPromptCallback(S32 option, const std::string& text, void* userData); + static bool newPromptCallback(const LLSD& notification, const LLSD& response); /// general purpose callbacks for dealing with color controllers static void onColorControlRMoved(LLUICtrl* ctrl, void* userData); @@ -97,13 +97,13 @@ public: static void onSavePreset(void* userData); /// prompts a user when overwriting a preset - static void saveAlertCallback(S32 option, void* userdata); + static bool saveAlertCallback(const LLSD& notification, const LLSD& response); /// when user hits the save preset button static void onDeletePreset(void* userData); /// prompts a user when overwriting a preset - static void deleteAlertCallback(S32 option, void* userdata); + static bool deleteAlertCallback(const LLSD& notification, const LLSD& response); /// what to do when you change the preset name static void onChangePresetName(LLUICtrl* ctrl, void* userData); diff --git a/indra/newview/llfloaterwindlight.cpp b/indra/newview/llfloaterwindlight.cpp index 4e27774029..8ae291f24c 100644 --- a/indra/newview/llfloaterwindlight.cpp +++ b/indra/newview/llfloaterwindlight.cpp @@ -233,16 +233,8 @@ void LLFloaterWindLight::onClickHelp(void* data) { LLFloaterWindLight* self = LLFloaterWindLight::instance(); - const std::string* xml_alert = (std::string*)data; - LLAlertDialog* dialogp = gViewerWindow->alertXml(*xml_alert); - if (dialogp) - { - LLFloater* root_floater = gFloaterView->getParentFloater(self); - if (root_floater) - { - root_floater->addDependentFloater(dialogp); - } - } + const std::string xml_alert = *(std::string*)data; + LLNotifications::instance().add(self->contextualNotification(xml_alert)); } void LLFloaterWindLight::initHelpBtn(const std::string& name, const std::string& xml_alert) @@ -250,11 +242,14 @@ void LLFloaterWindLight::initHelpBtn(const std::string& name, const std::string& childSetAction(name, onClickHelp, new std::string(xml_alert)); } -void LLFloaterWindLight::newPromptCallback(S32 option, const std::string& text, void* userData) +bool LLFloaterWindLight::newPromptCallback(const LLSD& notification, const LLSD& response) { + std::string text = response["message"].asString(); + S32 option = LLNotification::getSelectedOption(notification, response); + if(text == "") { - return; + return false; } if(option == 0) { @@ -303,9 +298,10 @@ void LLFloaterWindLight::newPromptCallback(S32 option, const std::string& text, } else { - gViewerWindow->alertXml("ExistsSkyPresetAlert"); + LLNotifications::instance().add("ExistsSkyPresetAlert"); } } + return false; } void LLFloaterWindLight::syncMenu() @@ -784,8 +780,7 @@ void LLFloaterWindLight::onStarAlphaMoved(LLUICtrl* ctrl, void* userData) void LLFloaterWindLight::onNewPreset(void* userData) { - gViewerWindow->alertXmlEditText("NewSkyPreset", LLStringUtil::format_map_t(), - NULL, NULL, newPromptCallback, NULL); + LLNotifications::instance().add("NewSkyPreset", LLSD(), LLSD(), newPromptCallback); } void LLFloaterWindLight::onSavePreset(void* userData) @@ -805,18 +800,19 @@ void LLFloaterWindLight::onSavePreset(void* userData) comboBox->getSelectedItemLabel()); if(sIt != sDefaultPresets.end() && !gSavedSettings.getBOOL("SkyEditPresets")) { - gViewerWindow->alertXml("WLNoEditDefault"); + LLNotifications::instance().add("WLNoEditDefault"); return; } LLWLParamManager::instance()->mCurParams.mName = comboBox->getSelectedItemLabel(); - gViewerWindow->alertXml("WLSavePresetAlert", saveAlertCallback, sWindLight); + LLNotifications::instance().add("WLSavePresetAlert", LLSD(), LLSD(), saveAlertCallback); } -void LLFloaterWindLight::saveAlertCallback(S32 option, void* userdata) +bool LLFloaterWindLight::saveAlertCallback(const LLSD& notification, const LLSD& response) { + S32 option = LLNotification::getSelectedOption(notification, response); // if they choose save, do it. Otherwise, don't do anything if(option == 0) { @@ -827,7 +823,7 @@ void LLFloaterWindLight::saveAlertCallback(S32 option, void* userdata) // comment this back in to save to file param_mgr->savePreset(param_mgr->mCurParams.mName); } - + return false; } void LLFloaterWindLight::onDeletePreset(void* userData) @@ -840,17 +836,20 @@ void LLFloaterWindLight::onDeletePreset(void* userData) return; } - LLStringUtil::format_map_t args; - args["[SKY]"] = combo_box->getSelectedValue().asString(); - gViewerWindow->alertXml("WLDeletePresetAlert", args, deleteAlertCallback, sWindLight); + LLSD args; + args["SKY"] = combo_box->getSelectedValue().asString(); + LLNotifications::instance().add("WLDeletePresetAlert", args, LLSD(), + boost::bind(&LLFloaterWindLight::deleteAlertCallback, sWindLight, _1, _2)); } -void LLFloaterWindLight::deleteAlertCallback(S32 option, void* userdata) +bool LLFloaterWindLight::deleteAlertCallback(const LLSD& notification, const LLSD& response) { + S32 option = LLNotification::getSelectedOption(notification, response); + // if they choose delete, do it. Otherwise, don't do anything if(option == 0) { - LLComboBox* combo_box = sWindLight->getChild<LLComboBox>( + LLComboBox* combo_box = getChild<LLComboBox>( "WLPresetsCombo"); LLFloaterDayCycle* day_cycle = NULL; LLComboBox* key_combo = NULL; @@ -870,8 +869,8 @@ void LLFloaterWindLight::deleteAlertCallback(S32 option, void* userdata) std::set<std::string>::iterator sIt = sDefaultPresets.find(name); if(sIt != sDefaultPresets.end()) { - gViewerWindow->alertXml("WLNoEditDefault"); - return; + LLNotifications::instance().add("WLNoEditDefault"); + return false; } LLWLParamManager::instance()->removeParamSet(name, true); @@ -899,6 +898,7 @@ void LLFloaterWindLight::deleteAlertCallback(S32 option, void* userdata) combo_box->setCurrentByIndex(new_index); } } + return false; } diff --git a/indra/newview/llfloaterwindlight.h b/indra/newview/llfloaterwindlight.h index d9e02b1117..35f8a65cbd 100644 --- a/indra/newview/llfloaterwindlight.h +++ b/indra/newview/llfloaterwindlight.h @@ -63,7 +63,7 @@ public: static void onClickHelp(void* data); void initHelpBtn(const std::string& name, const std::string& xml_alert); - static void newPromptCallback(S32 option, const std::string& text, void* userData); + static bool newPromptCallback(const LLSD& notification, const LLSD& response); /// general purpose callbacks for dealing with color controllers static void onColorControlRMoved(LLUICtrl* ctrl, void* userData); @@ -94,13 +94,13 @@ public: static void onSavePreset(void* userData); /// prompts a user when overwriting a preset - static void saveAlertCallback(S32 option, void* userdata); + static bool saveAlertCallback(const LLSD& notification, const LLSD& response); /// when user hits the save preset button static void onDeletePreset(void* userData); /// prompts a user when overwriting a preset - static void deleteAlertCallback(S32 option, void* userdata); + bool deleteAlertCallback(const LLSD& notification, const LLSD& response); /// what to do when you change the preset name static void onChangePresetName(LLUICtrl* ctrl, void* userData); diff --git a/indra/newview/llfloaterworldmap.cpp b/indra/newview/llfloaterworldmap.cpp index 2281f1b598..1c6eb84a8a 100644 --- a/indra/newview/llfloaterworldmap.cpp +++ b/indra/newview/llfloaterworldmap.cpp @@ -1303,10 +1303,10 @@ void LLFloaterWorldMap::onCopySLURL(void* data) LLFloaterWorldMap* self = (LLFloaterWorldMap*)data; gViewerWindow->mWindow->copyTextToClipboard(utf8str_to_wstring(self->mSLURL)); - LLStringUtil::format_map_t args; - args["[SLURL]"] = self->mSLURL; + LLSD args; + args["SLURL"] = self->mSLURL; - LLAlertDialog::showXml("CopySLURL", args); + LLNotifications::instance().add("CopySLURL", args); } void LLFloaterWorldMap::onCheckEvents(LLUICtrl*, void* data) diff --git a/indra/newview/llgesturemgr.cpp b/indra/newview/llgesturemgr.cpp index a25b1daebf..eba295531a 100644 --- a/indra/newview/llgesturemgr.cpp +++ b/indra/newview/llgesturemgr.cpp @@ -952,9 +952,9 @@ void LLGestureManager::onLoadComplete(LLVFS *vfs, && gGestureManager.mDeactivateSimilarNames.length() > 0) { // we're done with this set of deactivations - LLStringUtil::format_map_t args; - args["[NAMES]"] = gGestureManager.mDeactivateSimilarNames; - LLNotifyBox::showXml("DeactivatedGesturesTrigger", args); + LLSD args; + args["NAMES"] = gGestureManager.mDeactivateSimilarNames; + LLNotifications::instance().add("DeactivatedGesturesTrigger", args); } } diff --git a/indra/newview/llgroupmgr.cpp b/indra/newview/llgroupmgr.cpp index 631b2caa91..9a8e70242c 100644 --- a/indra/newview/llgroupmgr.cpp +++ b/indra/newview/llgroupmgr.cpp @@ -1288,9 +1288,9 @@ void LLGroupMgr::processCreateGroupReply(LLMessageSystem* msg, void ** data) else { // *TODO:translate - LLStringUtil::format_map_t args; - args["[MESSAGE]"] = message; - gViewerWindow->alertXml("UnableToCreateGroup", args); + LLSD args; + args["MESSAGE"] = message; + LLNotifications::instance().add("UnableToCreateGroup", args); } } diff --git a/indra/newview/llimpanel.cpp b/indra/newview/llimpanel.cpp index 770c117798..98b0786200 100644 --- a/indra/newview/llimpanel.cpp +++ b/indra/newview/llimpanel.cpp @@ -306,13 +306,13 @@ void LLVoiceCallCapResponder::error(U32 status, const std::string& reason) if ( 403 == status ) { //403 == no ability - LLNotifyBox::showXml( + LLNotifications::instance().add( "VoiceNotAllowed", channelp->getNotifyArgs()); } else { - LLNotifyBox::showXml( + LLNotifications::instance().add( "VoiceCallGenericError", channelp->getNotifyArgs()); } @@ -348,7 +348,7 @@ LLVoiceChannel::LLVoiceChannel(const LLUUID& session_id, const std::string& sess mSessionName(session_name), mIgnoreNextSessionLeave(FALSE) { - mNotifyArgs["[VOICE_CHANNEL_NAME]"] = mSessionName; + mNotifyArgs["VOICE_CHANNEL_NAME"] = mSessionName; if (!sVoiceChannelMap.insert(std::make_pair(session_id, this)).second) { @@ -384,13 +384,13 @@ void LLVoiceChannel::setChannelInfo( { if (mURI.empty()) { - LLNotifyBox::showXml("VoiceChannelJoinFailed", mNotifyArgs); + LLNotifications::instance().add("VoiceChannelJoinFailed", mNotifyArgs); llwarns << "Received empty URI for channel " << mSessionName << llendl; deactivate(); } else if (mCredentials.empty()) { - LLNotifyBox::showXml("VoiceChannelJoinFailed", mNotifyArgs); + LLNotifications::instance().add("VoiceChannelJoinFailed", mNotifyArgs); llwarns << "Received empty credentials for channel " << mSessionName << llendl; deactivate(); } @@ -433,25 +433,26 @@ void LLVoiceChannel::handleStatusChange(EStatusType type) switch(type) { case STATUS_LOGIN_RETRY: - mLoginNotificationHandle = LLNotifyBox::showXml("VoiceLoginRetry")->getHandle(); + //mLoginNotificationHandle = LLNotifyBox::showXml("VoiceLoginRetry")->getHandle(); + LLNotifications::instance().add("VoiceLoginRetry"); break; case STATUS_LOGGED_IN: - if (!mLoginNotificationHandle.isDead()) - { - LLNotifyBox* notifyp = (LLNotifyBox*)mLoginNotificationHandle.get(); - if (notifyp) - { - notifyp->close(); - } - mLoginNotificationHandle.markDead(); - } + //if (!mLoginNotificationHandle.isDead()) + //{ + // LLNotifyBox* notifyp = (LLNotifyBox*)mLoginNotificationHandle.get(); + // if (notifyp) + // { + // notifyp->close(); + // } + // mLoginNotificationHandle.markDead(); + //} break; case STATUS_LEFT_CHANNEL: if (callStarted() && !mIgnoreNextSessionLeave && !sSuspended) { // if forceably removed from channel // update the UI and revert to default channel - LLNotifyBox::showXml("VoiceChannelDisconnected", mNotifyArgs); + LLNotifications::instance().add("VoiceChannelDisconnected", mNotifyArgs); deactivate(); } mIgnoreNextSessionLeave = FALSE; @@ -793,9 +794,9 @@ void LLVoiceChannelGroup::handleError(EStatusType status) // notification if (!notify.empty()) { - LLNotifyBox::showXml(notify, mNotifyArgs); + LLNotificationPtr notification = LLNotifications::instance().add(notify, mNotifyArgs); // echo to im window - gIMMgr->addMessage(mSessionID, LLUUID::null, SYSTEM_FROM, LLNotifyBox::getTemplateMessage(notify, mNotifyArgs)); + gIMMgr->addMessage(mSessionID, LLUUID::null, SYSTEM_FROM, notification->getMessage()); } LLVoiceChannel::handleError(status); @@ -896,7 +897,7 @@ void LLVoiceChannelProximal::handleError(EStatusType status) // notification if (!notify.empty()) { - LLNotifyBox::showXml(notify, mNotifyArgs); + LLNotifications::instance().add(notify, mNotifyArgs); } LLVoiceChannel::handleError(status); @@ -934,12 +935,12 @@ void LLVoiceChannelP2P::handleStatusChange(EStatusType type) if (mState == STATE_RINGING) { // other user declined call - LLNotifyBox::showXml("P2PCallDeclined", mNotifyArgs); + LLNotifications::instance().add("P2PCallDeclined", mNotifyArgs); } else { // other user hung up - LLNotifyBox::showXml("VoiceChannelDisconnectedP2P", mNotifyArgs); + LLNotifications::instance().add("VoiceChannelDisconnectedP2P", mNotifyArgs); } deactivate(); } @@ -957,7 +958,7 @@ void LLVoiceChannelP2P::handleError(EStatusType type) switch(type) { case ERROR_NOT_AVAILABLE: - LLNotifyBox::showXml("P2PCallNoAnswer", mNotifyArgs); + LLNotifications::instance().add("P2PCallNoAnswer", mNotifyArgs); break; default: break; @@ -2213,35 +2214,33 @@ void LLFloaterIMPanel::showSessionStartError( //their own XML file which would be read in by any LLIMPanel //post build function instead of repeating the same info //in the group, adhoc and normal IM xml files. - LLStringUtil::format_map_t args; - args["[REASON]"] = + LLSD args; + args["REASON"] = LLFloaterIM::sErrorStringsMap[error_string]; - args["[RECIPIENT]"] = getTitle(); + args["RECIPIENT"] = getTitle(); + + LLSD payload; + payload["session_id"] = mSessionUUID; - gViewerWindow->alertXml( + LLNotifications::instance().add( "ChatterBoxSessionStartError", args, - onConfirmForceCloseError, - new LLUUID(mSessionUUID)); + payload, + onConfirmForceCloseError); } void LLFloaterIMPanel::showSessionEventError( const std::string& event_string, const std::string& error_string) { - LLStringUtil::format_map_t args; - std::string event; - - event = LLFloaterIM::sEventStringsMap[event_string]; - args["[RECIPIENT]"] = getTitle(); - LLStringUtil::format(event, args); - - - args = LLStringUtil::format_map_t(); - args["[REASON]"] = LLFloaterIM::sErrorStringsMap[error_string]; - args["[EVENT]"] = event; + LLSD args; + args["REASON"] = + LLFloaterIM::sErrorStringsMap[error_string]; + args["EVENT"] = + LLFloaterIM::sEventStringsMap[event_string]; + args["RECIPIENT"] = getTitle(); - gViewerWindow->alertXml( + LLNotifications::instance().add( "ChatterBoxSessionEventError", args); } @@ -2249,16 +2248,19 @@ void LLFloaterIMPanel::showSessionEventError( void LLFloaterIMPanel::showSessionForceClose( const std::string& reason_string) { - LLStringUtil::format_map_t args; + LLSD args; - args["[NAME]"] = getTitle(); - args["[REASON]"] = LLFloaterIM::sForceCloseSessionMap[reason_string]; + args["NAME"] = getTitle(); + args["REASON"] = LLFloaterIM::sForceCloseSessionMap[reason_string]; - gViewerWindow->alertXml( + LLSD payload; + payload["session_id"] = mSessionUUID; + + LLNotifications::instance().add( "ForceCloseChatterBoxSession", args, - LLFloaterIMPanel::onConfirmForceCloseError, - new LLUUID(mSessionUUID)); + payload, + LLFloaterIMPanel::onConfirmForceCloseError); } @@ -2268,10 +2270,10 @@ void LLFloaterIMPanel::onKickSpeaker(void* user_data) } -void LLFloaterIMPanel::onConfirmForceCloseError(S32 option, void* data) +bool LLFloaterIMPanel::onConfirmForceCloseError(const LLSD& notification, const LLSD& response) { //only 1 option really - LLUUID session_id = *((LLUUID*) data); + LLUUID session_id = notification["payload"]["session_id"]; if ( gIMMgr ) { @@ -2280,6 +2282,7 @@ void LLFloaterIMPanel::onConfirmForceCloseError(S32 option, void* data) if ( floaterp ) floaterp->close(FALSE); } + return false; } diff --git a/indra/newview/llimpanel.h b/indra/newview/llimpanel.h index b20dcd02bd..4681c5684b 100644 --- a/indra/newview/llimpanel.h +++ b/indra/newview/llimpanel.h @@ -81,7 +81,7 @@ public: EState getState() { return mState; } void updateSessionID(const LLUUID& new_session_id); - const LLStringUtil::format_map_t& getNotifyArgs() { return mNotifyArgs; } + const LLSD& getNotifyArgs() { return mNotifyArgs; } static LLVoiceChannel* getChannelByID(const LLUUID& session_id); static LLVoiceChannel* getChannelByURI(std::string uri); @@ -100,7 +100,7 @@ protected: LLUUID mSessionID; EState mState; std::string mSessionName; - LLStringUtil::format_map_t mNotifyArgs; + LLSD mNotifyArgs; BOOL mIgnoreNextSessionLeave; LLHandle<LLPanel> mLoginNotificationHandle; @@ -266,7 +266,7 @@ public: const std::string& error_string); void showSessionForceClose(const std::string& reason); - static void onConfirmForceCloseError(S32 option, void* data); + static bool onConfirmForceCloseError(const LLSD& notification, const LLSD& response); private: // called by constructors diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index c33de4c457..552854e7fa 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -97,6 +97,96 @@ std::map<std::string,std::string> LLFloaterIM::sForceCloseSessionMap; // return (LLStringUtil::compareDict( a->mName, b->mName ) < 0); //} +class LLViewerChatterBoxInvitationAcceptResponder : + public LLHTTPClient::Responder +{ +public: + LLViewerChatterBoxInvitationAcceptResponder( + const LLUUID& session_id, + LLIMMgr::EInvitationType invitation_type) + { + mSessionID = session_id; + mInvitiationType = invitation_type; + } + + void result(const LLSD& content) + { + if ( gIMMgr) + { + LLFloaterIMPanel* floaterp = + gIMMgr->findFloaterBySession(mSessionID); + + if (floaterp) + { + //we've accepted our invitation + //and received a list of agents that were + //currently in the session when the reply was sent + //to us. Now, it is possible that there were some agents + //to slip in/out between when that message was sent to us + //and now. + + //the agent list updates we've received have been + //accurate from the time we were added to the session + //but unfortunately, our base that we are receiving here + //may not be the most up to date. It was accurate at + //some point in time though. + floaterp->setSpeakers(content); + + //we now have our base of users in the session + //that was accurate at some point, but maybe not now + //so now we apply all of the udpates we've received + //in case of race conditions + floaterp->updateSpeakersList( + gIMMgr->getPendingAgentListUpdates(mSessionID)); + + if ( mInvitiationType == LLIMMgr::INVITATION_TYPE_VOICE ) + { + floaterp->requestAutoConnect(); + LLFloaterIMPanel::onClickStartCall(floaterp); + // always open IM window when connecting to voice + LLFloaterChatterBox::showInstance(TRUE); + } + else if ( mInvitiationType == LLIMMgr::INVITATION_TYPE_IMMEDIATE ) + { + LLFloaterChatterBox::showInstance(TRUE); + } + } + + gIMMgr->clearPendingAgentListUpdates(mSessionID); + gIMMgr->clearPendingInvitation(mSessionID); + } + } + + void error(U32 statusNum, const std::string& reason) + { + //throw something back to the viewer here? + if ( gIMMgr ) + { + gIMMgr->clearPendingAgentListUpdates(mSessionID); + gIMMgr->clearPendingInvitation(mSessionID); + + LLFloaterIMPanel* floaterp = + gIMMgr->findFloaterBySession(mSessionID); + + if ( floaterp ) + { + if ( 404 == statusNum ) + { + std::string error_string; + error_string = "does not exist"; + + floaterp->showSessionStartError( + error_string); + } + } + } + } + +private: + LLUUID mSessionID; + LLIMMgr::EInvitationType mInvitiationType; +}; + // the other_participant_id is either an agent_id, a group_id, or an inventory // folder item_id (collection of calling cards) @@ -256,38 +346,104 @@ protected: }; -class LLIMMgr::LLIMSessionInvite +bool inviteUserResponse(const LLSD& notification, const LLSD& response) { -public: - LLIMSessionInvite( - const LLUUID& session_id, - const std::string& session_name, - const LLUUID& caller_id, - const std::string& caller_name, - EInstantMessage type, - EInvitationType inv_type, - const std::string& session_handle, - const std::string& notify_box) : - mSessionID(session_id), - mSessionName(session_name), - mCallerID(caller_id), - mCallerName(caller_name), - mType(type), - mInvType(inv_type), - mSessionHandle(session_handle), - mNotifyBox(notify_box) - {}; - - LLUUID mSessionID; - std::string mSessionName; - LLUUID mCallerID; - std::string mCallerName; - EInstantMessage mType; - EInvitationType mInvType; - std::string mSessionHandle; - std::string mNotifyBox; -}; + const LLSD& payload = notification["payload"]; + LLUUID session_id = payload["session_id"].asUUID(); + EInstantMessage type = (EInstantMessage)payload["type"].asInteger(); + LLIMMgr::EInvitationType inv_type = (LLIMMgr::EInvitationType)payload["inv_type"].asInteger(); + S32 option = LLNotification::getSelectedOption(notification, response); + switch(option) + { + case 0: // accept + { + if (type == IM_SESSION_P2P_INVITE) + { + // create a normal IM session + session_id = gIMMgr->addP2PSession( + payload["session_name"].asString(), + payload["caller_id"].asUUID(), + payload["session_handle"].asString()); + + LLFloaterIMPanel* im_floater = + gIMMgr->findFloaterBySession( + session_id); + if (im_floater) + { + im_floater->requestAutoConnect(); + LLFloaterIMPanel::onClickStartCall(im_floater); + // always open IM window when connecting to voice + LLFloaterChatterBox::showInstance(session_id); + } + + gIMMgr->clearPendingAgentListUpdates(session_id); + gIMMgr->clearPendingInvitation(session_id); + } + else + { + gIMMgr->addSession( + payload["session_name"].asString(), + type, + session_id); + + std::string url = gAgent.getRegion()->getCapability( + "ChatSessionRequest"); + + LLSD data; + data["method"] = "accept invitation"; + data["session-id"] = session_id; + LLHTTPClient::post( + url, + data, + new LLViewerChatterBoxInvitationAcceptResponder( + session_id, + inv_type)); + } + } + break; + case 2: // mute (also implies ignore, so this falls through to the "ignore" case below) + { + // mute the sender of this invite + if (!LLMuteList::getInstance()->isMuted(payload["caller_id"].asUUID())) + { + LLMute mute(payload["caller_id"].asUUID(), payload["caller_name"].asString(), LLMute::AGENT); + LLMuteList::getInstance()->add(mute); + } + } + /* FALLTHROUGH */ + + case 1: // decline + { + if (type == IM_SESSION_P2P_INVITE) + { + if(gVoiceClient) + { + std::string s = payload["session_handle"].asString(); + gVoiceClient->declineInvite(s); + } + } + else + { + std::string url = gAgent.getRegion()->getCapability( + "ChatSessionRequest"); + + LLSD data; + data["method"] = "decline invitation"; + data["session-id"] = session_id; + LLHTTPClient::post( + url, + data, + NULL); + } + } + gIMMgr->clearPendingAgentListUpdates(session_id); + gIMMgr->clearPendingInvitation(session_id); + break; + } + + return false; +} // // Public Static Member Functions @@ -510,7 +666,7 @@ void LLIMMgr::addMessage( } } -void LLIMMgr::addSystemMessage(const LLUUID& session_id, const std::string& message_name, const LLStringUtil::format_map_t& args) +void LLIMMgr::addSystemMessage(const LLUUID& session_id, const std::string& message_name, const LLSD& args) { LLUIString message; @@ -520,7 +676,7 @@ void LLIMMgr::addSystemMessage(const LLUUID& session_id, const std::string& mess LLFloaterChat* floaterp = LLFloaterChat::getInstance(); message = floaterp->getString(message_name); - message.setArgList(args); + message.setArgs(args); LLChat chat(message); chat.mSourceType = CHAT_SOURCE_SYSTEM; @@ -532,7 +688,7 @@ void LLIMMgr::addSystemMessage(const LLUUID& session_id, const std::string& mess if (floaterp) { message = floaterp->getString(message_name); - message.setArgList(args); + message.setArgs(args); gIMMgr->addMessage(session_id, LLUUID::null, SYSTEM_FROM, message.getString()); } @@ -687,7 +843,7 @@ void LLIMMgr::removeSession(const LLUUID& session_id) LLFloaterChatterBox::getInstance(LLSD())->removeFloater(floater); //mTabContainer->removeTabPanel(floater); - clearPendingInviation(session_id); + clearPendingInvitation(session_id); clearPendingAgentListUpdates(session_id); } } @@ -733,21 +889,21 @@ void LLIMMgr::inviteToSession( ad_hoc_invite = TRUE; } - LLIMSessionInvite* invite = new LLIMSessionInvite( - session_id, - session_name, - caller_id, - caller_name, - type, - inv_type, - session_handle, - notify_box_type); + LLSD payload; + payload["session_id"] = session_id; + payload["session_name"] = session_name; + payload["caller_id"] = caller_id; + payload["caller_name"] = caller_name; + payload["type"] = type; + payload["inv_type"] = inv_type; + payload["session_handle"] = session_handle; + payload["notify_box_type"] = notify_box_type; LLVoiceChannel* channelp = LLVoiceChannel::getChannelByID(session_id); if (channelp && channelp->callStarted()) { // you have already started a call to the other user, so just accept the invite - inviteUserResponse(0, invite); // inviteUserResponse deletes + LLNotifications::instance().forceResponse(LLNotification::Params("VoiceInviteP2P").payload(payload), 0); return; } @@ -761,7 +917,7 @@ void LLIMMgr::inviteToSession( if (gSavedSettings.getBOOL("VoiceCallsFriendsOnly")) { // invite not from a friend, so decline - inviteUserResponse(1, invite); // inviteUserResponse deletes + LLNotifications::instance().forceResponse(LLNotification::Params("VoiceInviteP2P").payload(payload), 1); return; } } @@ -771,230 +927,41 @@ void LLIMMgr::inviteToSession( { if (caller_name.empty()) { - gCacheName->get(caller_id, FALSE, onInviteNameLookup, invite); + gCacheName->getName(caller_id, onInviteNameLookup, new LLSD(payload)); } else { - LLStringUtil::format_map_t args; - args["[NAME]"] = caller_name; - args["[GROUP]"] = session_name; + LLSD args; + args["NAME"] = caller_name; + args["GROUP"] = session_name; - LLNotifyBox::showXml(notify_box_type, + LLNotifications::instance().add(notify_box_type, args, - inviteUserResponse, - (void*)invite); // inviteUserResponse deletes + payload, + &inviteUserResponse); } mPendingInvitations[session_id.asString()] = LLSD(); } - else - { - delete invite; - } } //static void LLIMMgr::onInviteNameLookup(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group, void* userdata) { - LLIMSessionInvite* invite = (LLIMSessionInvite*)userdata; + LLSD payload = *(LLSD*)userdata; + delete (LLSD*)userdata; - invite->mCallerName = first + " " + last; - invite->mSessionName = invite->mCallerName; + payload["caller_name"] = first + " " + last; + payload["session_name"] = payload["caller_name"].asString(); - LLStringUtil::format_map_t args; - args["[NAME]"] = invite->mCallerName; + LLSD args; + args["NAME"] = payload["caller_name"].asString(); - LLNotifyBox::showXml( - invite->mNotifyBox, + LLNotifications::instance().add( + payload["notify_box_type"].asString(), args, - inviteUserResponse, - (void*)invite); -} - -class LLViewerChatterBoxInvitationAcceptResponder : - public LLHTTPClient::Responder -{ -public: - LLViewerChatterBoxInvitationAcceptResponder( - const LLUUID& session_id, - LLIMMgr::EInvitationType invitation_type) - { - mSessionID = session_id; - mInvitiationType = invitation_type; - } - - void result(const LLSD& content) - { - if ( gIMMgr) - { - LLFloaterIMPanel* floaterp = - gIMMgr->findFloaterBySession(mSessionID); - - if (floaterp) - { - //we've accepted our invitation - //and received a list of agents that were - //currently in the session when the reply was sent - //to us. Now, it is possible that there were some agents - //to slip in/out between when that message was sent to us - //and now. - - //the agent list updates we've received have been - //accurate from the time we were added to the session - //but unfortunately, our base that we are receiving here - //may not be the most up to date. It was accurate at - //some point in time though. - floaterp->setSpeakers(content); - - //we now have our base of users in the session - //that was accurate at some point, but maybe not now - //so now we apply all of the udpates we've received - //in case of race conditions - floaterp->updateSpeakersList( - gIMMgr->getPendingAgentListUpdates(mSessionID)); - - if ( mInvitiationType == LLIMMgr::INVITATION_TYPE_VOICE ) - { - floaterp->requestAutoConnect(); - LLFloaterIMPanel::onClickStartCall(floaterp); - // always open IM window when connecting to voice - LLFloaterChatterBox::showInstance(TRUE); - } - else if ( mInvitiationType == LLIMMgr::INVITATION_TYPE_IMMEDIATE ) - { - LLFloaterChatterBox::showInstance(TRUE); - } - } - - gIMMgr->clearPendingAgentListUpdates(mSessionID); - gIMMgr->clearPendingInviation(mSessionID); - } - } - - void error(U32 statusNum, const std::string& reason) - { - //throw something back to the viewer here? - if ( gIMMgr ) - { - gIMMgr->clearPendingAgentListUpdates(mSessionID); - gIMMgr->clearPendingInviation(mSessionID); - - LLFloaterIMPanel* floaterp = - gIMMgr->findFloaterBySession(mSessionID); - - if ( floaterp ) - { - if ( 404 == statusNum ) - { - std::string error_string; - error_string = "does not exist"; - - floaterp->showSessionStartError( - error_string); - } - } - } - } - -private: - LLUUID mSessionID; - LLIMMgr::EInvitationType mInvitiationType; -}; - -//static -void LLIMMgr::inviteUserResponse(S32 option, void* user_data) -{ - LLIMSessionInvite* invitep = (LLIMSessionInvite*)user_data; - - switch(option) - { - case 0: // accept - { - if (invitep->mType == IM_SESSION_P2P_INVITE) - { - // create a normal IM session - invitep->mSessionID = gIMMgr->addP2PSession( - invitep->mSessionName, - invitep->mCallerID, - invitep->mSessionHandle); - - LLFloaterIMPanel* im_floater = - gIMMgr->findFloaterBySession( - invitep->mSessionID); - if (im_floater) - { - im_floater->requestAutoConnect(); - LLFloaterIMPanel::onClickStartCall(im_floater); - // always open IM window when connecting to voice - LLFloaterChatterBox::showInstance(invitep->mSessionID); - } - - gIMMgr->clearPendingAgentListUpdates(invitep->mSessionID); - gIMMgr->clearPendingInviation(invitep->mSessionID); - } - else - { - gIMMgr->addSession( - invitep->mSessionName, - invitep->mType, - invitep->mSessionID); - - std::string url = gAgent.getRegion()->getCapability( - "ChatSessionRequest"); - - LLSD data; - data["method"] = "accept invitation"; - data["session-id"] = invitep->mSessionID; - LLHTTPClient::post( - url, - data, - new LLViewerChatterBoxInvitationAcceptResponder( - invitep->mSessionID, - invitep->mInvType)); - } - } - break; - case 2: // mute (also implies ignore, so this falls through to the "ignore" case below) - { - // mute the sender of this invite - if (!LLMuteList::getInstance()->isMuted(invitep->mCallerID)) - { - LLMute mute(invitep->mCallerID, invitep->mCallerName, LLMute::AGENT); - LLMuteList::getInstance()->add(mute); - } - } - /* FALLTHROUGH */ - - case 1: // decline - { - if (invitep->mType == IM_SESSION_P2P_INVITE) - { - if(gVoiceClient) - { - gVoiceClient->declineInvite(invitep->mSessionHandle); - } - } - else - { - std::string url = gAgent.getRegion()->getCapability( - "ChatSessionRequest"); - - LLSD data; - data["method"] = "decline invitation"; - data["session-id"] = invitep->mSessionID; - LLHTTPClient::post( - url, - data, - NULL); - } - } - - gIMMgr->clearPendingAgentListUpdates(invitep->mSessionID); - gIMMgr->clearPendingInviation(invitep->mSessionID); - break; - } - - delete invitep; + payload, + &inviteUserResponse); } void LLIMMgr::refresh() @@ -1068,7 +1035,7 @@ BOOL LLIMMgr::hasSession(const LLUUID& session_id) return (findFloaterBySession(session_id) != NULL); } -void LLIMMgr::clearPendingInviation(const LLUUID& session_id) +void LLIMMgr::clearPendingInvitation(const LLUUID& session_id) { if ( mPendingInvitations.has(session_id.asString()) ) { diff --git a/indra/newview/llimview.h b/indra/newview/llimview.h index da64cd3bab..175f47ebc1 100644 --- a/indra/newview/llimview.h +++ b/indra/newview/llimview.h @@ -68,7 +68,7 @@ public: const LLVector3& position = LLVector3::zero, bool link_name = false); - void addSystemMessage(const LLUUID& session_id, const std::string& message_name, const LLStringUtil::format_map_t& args); + void addSystemMessage(const LLUUID& session_id, const std::string& message_name, const LLSD& args); // This method returns TRUE if the local viewer has a session // currently open keyed to the uuid. The uuid can be keyed by @@ -157,7 +157,7 @@ public: static LLUUID computeSessionID(EInstantMessage dialog, const LLUUID& other_participant_id); - void clearPendingInviation(const LLUUID& session_id); + void clearPendingInvitation(const LLUUID& session_id); LLSD getPendingAgentListUpdates(const LLUUID& session_id); void addPendingAgentListUpdates( @@ -169,8 +169,6 @@ public: const std::set<LLHandle<LLFloater> >& getIMFloaterHandles() { return mFloaters; } private: - class LLIMSessionInvite; - // create a panel and update internal representation for // consistency. Returns the pointer, caller (the class instance // since it is a private method) is not responsible for deleting @@ -197,7 +195,6 @@ private: void processIMTypingCore(const LLIMInfo* im_info, BOOL typing); - static void inviteUserResponse(S32 option, void* user_data); static void onInviteNameLookup(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group, void* userdata); private: diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index a4b80ed7c1..3852755850 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -109,8 +109,8 @@ void wear_inventory_category_on_avatar_loop(LLWearable* wearable, void*); void wear_inventory_category_on_avatar_step3(LLWearableHoldingPattern* holder, BOOL append); void remove_inventory_category_from_avatar(LLInventoryCategory* category); void remove_inventory_category_from_avatar_step2( BOOL proceed, void* userdata); -void move_task_inventory_callback(S32 option, void* user_data); -void confirm_replace_attachment_rez(S32 option, void* user_data); +bool move_task_inventory_callback(const LLSD& notification, const LLSD& response, LLMoveInv*); +bool confirm_replace_attachment_rez(const LLSD& notification, const LLSD& response); std::string ICON_NAME[ICON_NAME_COUNT] = { @@ -1288,7 +1288,7 @@ void warn_move_inventory(LLViewerObject* object, LLMoveInv* move_inv) { dialog = "MoveInventoryFromObject"; } - gViewerWindow->alertXml(dialog, move_task_inventory_callback, move_inv); + LLNotifications::instance().add(dialog, LLSD(), LLSD(), boost::bind(move_task_inventory_callback, _1, _2, move_inv)); } // Move/copy all inventory items from the Contents folder of an in-world @@ -1377,7 +1377,9 @@ BOOL move_inv_category_world_to_agent(const LLUUID& object_id, } else { - move_task_inventory_callback(0, (void*)(move_inv)); + LLNotification::Params params("MoveInventoryFromObject"); + params.functor(boost::bind(move_task_inventory_callback, _1, _2, move_inv)); + LLNotifications::instance().forceResponse(params, 0); } } return accept; @@ -2187,12 +2189,12 @@ void LLFolderBridge::modifyOutfit(BOOL append) } // helper stuff -void move_task_inventory_callback(S32 option, void* user_data) +bool move_task_inventory_callback(const LLSD& notification, const LLSD& response, LLMoveInv* move_inv) { - LLMoveInv* move_inv = (LLMoveInv*)user_data; LLFloaterOpenObject::LLCatAndWear* cat_and_wear = (LLFloaterOpenObject::LLCatAndWear* )move_inv->mUserData; LLViewerObject* object = gObjectList.findObject(move_inv->mObjectID); - + S32 option = LLNotification::getSelectedOption(notification, response); + if(option == 0 && object) { if (cat_and_wear && cat_and_wear->mWear) @@ -2223,6 +2225,7 @@ void move_task_inventory_callback(S32 option, void* user_data) } delete move_inv; + return false; } BOOL LLFolderBridge::dragItemIntoFolder(LLInventoryItem* inv_item, @@ -2353,7 +2356,9 @@ BOOL LLFolderBridge::dragItemIntoFolder(LLInventoryItem* inv_item, } else { - move_task_inventory_callback(0, (void*)(move_inv)); + LLNotification::Params params("MoveInventoryFromObject"); + params.functor(boost::bind(move_task_inventory_callback, _1, _2, move_inv)); + LLNotifications::instance().forceResponse(params, 0); } } @@ -2648,23 +2653,28 @@ void open_landmark(LLViewerInventoryItem* inv_item, } } -static void open_landmark_callback(S32 option, void* data) +static bool open_landmark_callback(const LLSD& notification, const LLSD& response) { - LLUUID* asset_idp = (LLUUID*)data; + S32 option = LLNotification::getSelectedOption(notification, response); + + LLUUID asset_id = notification["payload"]["asset_id"].asUUID(); if (option == 0) { // HACK: This is to demonstrate teleport on double click for landmarks - gAgent.teleportViaLandmark( *asset_idp ); + gAgent.teleportViaLandmark( asset_id ); // we now automatically track the landmark you're teleporting to // because you'll probably arrive at a telehub instead if( gFloaterWorldMap ) { - gFloaterWorldMap->trackLandmark( *asset_idp ); + gFloaterWorldMap->trackLandmark( asset_id ); } } - delete asset_idp; + + return false; } +static LLNotificationFunctorRegistration open_landmark_callback_reg("TeleportFromLandmark", open_landmark_callback); + void LLLandmarkBridge::openItem() { @@ -2674,9 +2684,9 @@ void LLLandmarkBridge::openItem() // Opening (double-clicking) a landmark immediately teleports, // but warns you the first time. // open_landmark(item, std::string(" ") + getPrefix() + item->getName(), FALSE); - LLUUID* asset_idp = new LLUUID(item->getAssetUUID()); - LLAlertDialog::showXml("TeleportFromLandmark", - open_landmark_callback, (void*)asset_idp); + LLSD payload; + payload["asset_id"] = item->getAssetUUID(); + LLNotifications::instance().add("TeleportFromLandmark", LLSD(), payload); } } @@ -3321,8 +3331,9 @@ std::string LLObjectBridge::getLabelSuffix() const void rez_attachment(LLViewerInventoryItem* item, LLViewerJointAttachment* attachment) { - LLAttachmentRezAction* rez_action = new LLAttachmentRezAction; - rez_action->mItemID = item->getUUID(); + LLSD payload; + payload["item_id"] = item->getUUID(); + S32 attach_pt = 0; if (gAgent.getAvatarObject() && attachment) { @@ -3336,46 +3347,46 @@ void rez_attachment(LLViewerInventoryItem* item, LLViewerJointAttachment* attach } } } - rez_action->mAttachPt = attach_pt; + + payload["attachment_point"] = attach_pt; + if (attachment && attachment->getObject()) { - gViewerWindow->alertXml("ReplaceAttachment", confirm_replace_attachment_rez, (void*)rez_action); + LLNotifications::instance().add("ReplaceAttachment", LLSD(), payload, confirm_replace_attachment_rez); } else { - confirm_replace_attachment_rez(0/*YES*/, (void*)rez_action); + LLNotifications::instance().forceResponse(LLNotification::Params("ReplaceAttachment").payload(payload), 0/*YES*/); } } -void confirm_replace_attachment_rez(S32 option, void* user_data) +bool confirm_replace_attachment_rez(const LLSD& notification, const LLSD& response) { - LLAttachmentRezAction* rez_action = (LLAttachmentRezAction*)user_data; + S32 option = LLNotification::getSelectedOption(notification, response); if (option == 0/*YES*/) { - if (rez_action) + LLViewerInventoryItem* itemp = gInventory.getItem(notification["payload"]["item_id"].asUUID()); + + if (itemp) { - LLViewerInventoryItem* itemp = gInventory.getItem(rez_action->mItemID); - - if (itemp) - { - LLMessageSystem* msg = gMessageSystem; - msg->newMessageFast(_PREHASH_RezSingleAttachmentFromInv); - msg->nextBlockFast(_PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - msg->nextBlockFast(_PREHASH_ObjectData); - msg->addUUIDFast(_PREHASH_ItemID, itemp->getUUID()); - msg->addUUIDFast(_PREHASH_OwnerID, itemp->getPermissions().getOwner()); - msg->addU8Fast(_PREHASH_AttachmentPt, rez_action->mAttachPt); - pack_permissions_slam(msg, itemp->getFlags(), itemp->getPermissions()); - msg->addStringFast(_PREHASH_Name, itemp->getName()); - msg->addStringFast(_PREHASH_Description, itemp->getDescription()); - msg->sendReliable(gAgent.getRegion()->getHost()); - } + LLMessageSystem* msg = gMessageSystem; + msg->newMessageFast(_PREHASH_RezSingleAttachmentFromInv); + msg->nextBlockFast(_PREHASH_AgentData); + msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); + msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + msg->nextBlockFast(_PREHASH_ObjectData); + msg->addUUIDFast(_PREHASH_ItemID, itemp->getUUID()); + msg->addUUIDFast(_PREHASH_OwnerID, itemp->getPermissions().getOwner()); + msg->addU8Fast(_PREHASH_AttachmentPt, notification["payload"]["attachment_point"].asInteger()); + pack_permissions_slam(msg, itemp->getFlags(), itemp->getPermissions()); + msg->addStringFast(_PREHASH_Name, itemp->getName()); + msg->addStringFast(_PREHASH_Description, itemp->getDescription()); + msg->sendReliable(gAgent.getRegion()->getHost()); } } - delete rez_action; + return false; } +static LLNotificationFunctorRegistration confirm_replace_attachment_rez_reg("ReplaceAttachment", confirm_replace_attachment_rez); void LLObjectBridge::buildContextMenu(LLMenuGL& menu, U32 flags) { @@ -3927,7 +3938,7 @@ void wear_inventory_category_on_avatar_step2( BOOL proceed, void* userdata ) if( !wearable_count && !obj_count && !gest_count) { - gViewerWindow->alertXml("CouldNotPutOnOutfit"); + LLNotifications::instance().add("CouldNotPutOnOutfit"); delete wear_info; return; } @@ -4334,7 +4345,7 @@ void LLWearableBridge::openItem() { if( isInTrash() ) { - gViewerWindow->alertXml("CannotWearTrash"); + LLNotifications::instance().add("CannotWearTrash"); } else if(isAgentInventory()) { @@ -4363,7 +4374,7 @@ void LLWearableBridge::openItem() { // *TODO: We should fetch the item details, and then do // the operation above. - gViewerWindow->alertXml("CannotWearInfoNotComplete"); + LLNotifications::instance().add("CannotWearInfoNotComplete"); } } } @@ -4464,7 +4475,7 @@ void LLWearableBridge::wearOnAvatar() // destroy clothing items. if (!gAgent.areWearablesLoaded()) { - gViewerWindow->alertXml("CanNotChangeAppearanceUntilLoaded"); + LLNotifications::instance().add("CanNotChangeAppearanceUntilLoaded"); return; } diff --git a/indra/newview/llinventorymodel.h b/indra/newview/llinventorymodel.h index 064ace52f2..c0cda4c6a4 100644 --- a/indra/newview/llinventorymodel.h +++ b/indra/newview/llinventorymodel.h @@ -92,7 +92,6 @@ class LLViewerInventoryItem; class LLViewerInventoryCategory; class LLMessageSystem; class LLInventoryCollectFunctor; -class LLAlertDialog; class LLInventoryModel { diff --git a/indra/newview/lllandmarklist.cpp b/indra/newview/lllandmarklist.cpp index 59b4d245ac..d98ee1894b 100644 --- a/indra/newview/lllandmarklist.cpp +++ b/indra/newview/lllandmarklist.cpp @@ -119,11 +119,11 @@ void LLLandmarkList::processGetAssetReply( if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status ) { - LLNotifyBox::showXml("LandmarkMissing"); + LLNotifications::instance().add("LandmarkMissing"); } else { - LLNotifyBox::showXml("UnableToLoadLandmark"); + LLNotifications::instance().add("UnableToLoadLandmark"); } gLandmarkList.mBadList.insert(uuid); diff --git a/indra/newview/llmutelist.cpp b/indra/newview/llmutelist.cpp index 3ad26b703a..cc9be04cfc 100644 --- a/indra/newview/llmutelist.cpp +++ b/indra/newview/llmutelist.cpp @@ -66,7 +66,8 @@ #include "llfloaterchat.h" #include "llimpanel.h" #include "llimview.h" -#include "llnotify.h" +#include "lltrans.h" +#include "llnotifications.h" #include "lluistring.h" #include "llviewerobject.h" #include "llviewerobjectlist.h" @@ -278,7 +279,7 @@ BOOL LLMuteList::add(const LLMute& mute, U32 flags) if ((mute.mType == LLMute::AGENT) && isLinden(mute.mName) && (flags & LLMute::flagTextChat || flags == 0)) { - gViewerWindow->alertXml("MuteLinden"); + LLNotifications::instance().add("MuteLinden"); return FALSE; } @@ -480,35 +481,35 @@ void notify_automute_callback(const LLUUID& agent_id, const std::string& first_n { U32 temp_data = (U32) (uintptr_t) user_data; LLMuteList::EAutoReason reason = (LLMuteList::EAutoReason)temp_data; - LLUIString auto_message; - + + std::string auto_message; switch (reason) { default: case LLMuteList::AR_IM: - auto_message = LLNotifyBox::getTemplateMessage("AutoUnmuteByIM"); + auto_message = LLTrans::getString("AutoUnmuteByIM"); break; case LLMuteList::AR_INVENTORY: - auto_message = LLNotifyBox::getTemplateMessage("AutoUnmuteByInventory"); + auto_message = LLTrans::getString("AutoUnmuteByInventory"); break; case LLMuteList::AR_MONEY: - auto_message = LLNotifyBox::getTemplateMessage("AutoUnmuteByMoney"); + auto_message = LLTrans::getString("AutoUnmuteByMoney"); break; } - auto_message.setArg("[FIRST]", first_name); - auto_message.setArg("[LAST]", last_name); + std::string message = LLNotification::format(auto_message, + LLSD().insert("FIRST", first_name).insert("LAST", last_name)); if (reason == LLMuteList::AR_IM) { LLFloaterIMPanel *timp = gIMMgr->findFloaterBySession(agent_id); if (timp) { - timp->addHistoryLine(auto_message.getString()); + timp->addHistoryLine(message); } } - LLChat auto_chat(auto_message.getString()); + LLChat auto_chat(message); LLFloaterChat::addChat(auto_chat, FALSE, FALSE); } diff --git a/indra/newview/llnamelistctrl.cpp b/indra/newview/llnamelistctrl.cpp index dfc327e329..5b4e956137 100644 --- a/indra/newview/llnamelistctrl.cpp +++ b/indra/newview/llnamelistctrl.cpp @@ -349,7 +349,7 @@ LLView* LLNameListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFacto LLSD columns; S32 index = 0; - S32 total_static = 0; + //S32 total_static = 0; LLXMLNodePtr child; for (child = node->getFirstChild(); child.notNull(); child = child->getNextSibling()) { @@ -383,7 +383,7 @@ LLView* LLNameListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFacto LLFontGL::HAlign h_align = LLFontGL::LEFT; h_align = LLView::selectFontHAlign(child); - if(!columndynamicwidth) total_static += llmax(0, columnwidth); + //if(!columndynamicwidth) total_static += llmax(0, columnwidth); columns[index]["name"] = columnname; columns[index]["label"] = labelname; @@ -394,7 +394,6 @@ LLView* LLNameListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFacto index++; } } - name_list->setTotalStaticColumnWidth(total_static); name_list->setColumnHeadings(columns); diff --git a/indra/newview/llpanelavatar.cpp b/indra/newview/llpanelavatar.cpp index 9c8817da9a..3f4732692f 100644 --- a/indra/newview/llpanelavatar.cpp +++ b/indra/newview/llpanelavatar.cpp @@ -352,20 +352,24 @@ void LLPanelAvatarSecondLife::onDoubleClickGroup(void* data) // static void LLPanelAvatarSecondLife::onClickPublishHelp(void *) { - gViewerWindow->alertXml("ClickPublishHelpAvatar"); + LLNotifications::instance().add("ClickPublishHelpAvatar"); } // static void LLPanelAvatarSecondLife::onClickPartnerHelp(void *) { - gViewerWindow->alertXml("ClickPartnerHelpAvatar", onClickPartnerHelpLoadURL, (void*) NULL); + LLNotifications::instance().add("ClickPartnerHelpAvatar", LLSD(), LLSD(), onClickPartnerHelpLoadURL); } // static -void LLPanelAvatarSecondLife::onClickPartnerHelpLoadURL(S32 option, void* userdata) +bool LLPanelAvatarSecondLife::onClickPartnerHelpLoadURL(const LLSD& notification, const LLSD& response) { - if (option == 0) - LLWeb::loadURL("http://secondlife.com/partner"); + S32 option = LLNotification::getSelectedOption(notification, response); + if (option == 0) + { + LLWeb::loadURL("http://secondlife.com/partner"); + } + return false; } // static @@ -593,7 +597,7 @@ void LLPanelAvatarWeb::onCommitURL(LLUICtrl* ctrl, void* data) // static void LLPanelAvatarWeb::onClickWebProfileHelp(void *) { - gViewerWindow->alertXml("ClickWebProfileHelpAvatar"); + LLNotifications::instance().add("ClickWebProfileHelpAvatar"); } void LLPanelAvatarWeb::load(std::string url) @@ -930,26 +934,25 @@ void LLPanelAvatarClassified::onClickNew(void* data) { LLPanelAvatarClassified* self = (LLPanelAvatarClassified*)data; - gViewerWindow->alertXml("AddClassified",callbackNew,self); + LLNotifications::instance().add("AddClassified", LLSD(), LLSD(), boost::bind(&LLPanelAvatarClassified::callbackNew, self, _1, _2)); } -// static -void LLPanelAvatarClassified::callbackNew(S32 option, void* data) +bool LLPanelAvatarClassified::callbackNew(const LLSD& notification, const LLSD& response) { - LLPanelAvatarClassified* self = (LLPanelAvatarClassified*)data; - + S32 option = LLNotification::getSelectedOption(notification, response); if (0 == option) { LLPanelClassified* panel_classified = new LLPanelClassified(false, false); panel_classified->initNewClassified(); - LLTabContainer* tabs = self->getChild<LLTabContainer>("classified tab"); + LLTabContainer* tabs = getChild<LLTabContainer>("classified tab"); if(tabs) { tabs->addTabPanel(panel_classified, panel_classified->getClassifiedName()); tabs->selectLastTab(); } } + return false; } @@ -966,18 +969,17 @@ void LLPanelAvatarClassified::onClickDelete(void* data) } if (!panel_classified) return; - LLStringUtil::format_map_t args; - args["[NAME]"] = panel_classified->getClassifiedName(); - gViewerWindow->alertXml("DeleteClassified", args, callbackDelete, self); + LLSD args; + args["NAME"] = panel_classified->getClassifiedName(); + LLNotifications::instance().add("DeleteClassified", args, LLSD(), boost::bind(&LLPanelAvatarClassified::callbackDelete, self, _1, _2)); } -// static -void LLPanelAvatarClassified::callbackDelete(S32 option, void* data) +bool LLPanelAvatarClassified::callbackDelete(const LLSD& notification, const LLSD& response) { - LLPanelAvatarClassified* self = (LLPanelAvatarClassified*)data; - LLTabContainer* tabs = self->getChild<LLTabContainer>("classified tab"); + S32 option = LLNotification::getSelectedOption(notification, response); + LLTabContainer* tabs = getChild<LLTabContainer>("classified tab"); LLPanelClassified* panel_classified=NULL; if(tabs) { @@ -986,7 +988,7 @@ void LLPanelAvatarClassified::callbackDelete(S32 option, void* data) LLMessageSystem* msg = gMessageSystem; - if (!panel_classified) return; + if (!panel_classified) return false; if (0 == option) { @@ -1005,6 +1007,7 @@ void LLPanelAvatarClassified::callbackDelete(S32 option, void* data) delete panel_classified; panel_classified = NULL; } + return false; } @@ -1124,24 +1127,23 @@ void LLPanelAvatarPicks::onClickDelete(void* data) if (!panel_pick) return; - LLStringUtil::format_map_t args; - args["[PICK]"] = panel_pick->getPickName(); + LLSD args; + args["PICK"] = panel_pick->getPickName(); - gViewerWindow->alertXml("DeleteAvatarPick", args, - callbackDelete, - self); + LLNotifications::instance().add("DeleteAvatarPick", args, LLSD(), + boost::bind(&LLPanelAvatarPicks::callbackDelete, self, _1, _2)); } // static -void LLPanelAvatarPicks::callbackDelete(S32 option, void* data) +bool LLPanelAvatarPicks::callbackDelete(const LLSD& notification, const LLSD& response) { - LLPanelAvatarPicks* self = (LLPanelAvatarPicks*)data; - LLTabContainer* tabs = self->getChild<LLTabContainer>("picks tab"); - LLPanelPick* panel_pick = tabs?(LLPanelPick*)tabs->getCurrentPanel():NULL; + S32 option = LLNotification::getSelectedOption(notification, response); + LLTabContainer* tabs = getChild<LLTabContainer>("picks tab"); + LLPanelPick* panel_pick = tabs ? (LLPanelPick*)tabs->getCurrentPanel() : NULL; LLMessageSystem* msg = gMessageSystem; - if (!panel_pick) return; + if (!panel_pick) return false; if (0 == option) { @@ -1177,6 +1179,7 @@ void LLPanelAvatarPicks::callbackDelete(S32 option, void* data) delete panel_pick; panel_pick = NULL; } + return false; } @@ -1835,7 +1838,7 @@ void LLPanelAvatar::processAvatarPropertiesReply(LLMessageSystem *msg, void**) args["[PAYMENTINFO]"] = self->mPanelSecondLife->getString(payment_text); std::string age_text = age_verified ? "AgeVerified" : "NotAgeVerified"; // Do not display age verification status at this time - //args["[AGEVERIFICATION]"] = self->mPanelSecondLife->getString(age_text); + //args["[[AGEVERIFICATION]]"] = self->mPanelSecondLife->getString(age_text); args["[AGEVERIFICATION]"] = " "; } else @@ -2187,85 +2190,93 @@ void LLPanelAvatar::onClickKick(void* userdata) gFloaterView->getNewFloaterPosition(&left, &top); LLRect rect(left, top, left+400, top-300); - gViewerWindow->alertXmlEditText("KickUser", LLStringUtil::format_map_t(), - NULL, NULL, - LLPanelAvatar::finishKick, self); + LLSD payload; + payload["avatar_id"] = self->mAvatarID; + LLNotifications::instance().add("KickUser", LLSD(), payload, finishKick); } -// static -void LLPanelAvatar::finishKick(S32 option, const std::string& text, void* userdata) +//static +bool LLPanelAvatar::finishKick(const LLSD& notification, const LLSD& response) { - LLPanelAvatar* self = (LLPanelAvatar*) userdata; + S32 option = LLNotification::getSelectedOption(notification, response); if (option == 0) { + LLUUID avatar_id = notification["payload"]["avatar_id"].asUUID(); LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_GodKickUser); msg->nextBlockFast(_PREHASH_UserInfo); msg->addUUIDFast(_PREHASH_GodID, gAgent.getID() ); msg->addUUIDFast(_PREHASH_GodSessionID, gAgent.getSessionID()); - msg->addUUIDFast(_PREHASH_AgentID, self->mAvatarID ); + msg->addUUIDFast(_PREHASH_AgentID, avatar_id ); msg->addU32("KickFlags", KICK_FLAGS_DEFAULT ); - msg->addStringFast(_PREHASH_Reason, text ); + msg->addStringFast(_PREHASH_Reason, response["message"].asString() ); gAgent.sendReliableMessage(); } + return false; } // static void LLPanelAvatar::onClickFreeze(void* userdata) { - gViewerWindow->alertXmlEditText("FreezeUser", LLStringUtil::format_map_t(), - NULL, NULL, - LLPanelAvatar::finishFreeze, userdata); + LLPanelAvatar* self = (LLPanelAvatar*) userdata; + LLSD payload; + payload["avatar_id"] = self->mAvatarID; + LLNotifications::instance().add("FreezeUser", LLSD(), payload, LLPanelAvatar::finishFreeze); } // static -void LLPanelAvatar::finishFreeze(S32 option, const std::string& text, void* userdata) +bool LLPanelAvatar::finishFreeze(const LLSD& notification, const LLSD& response) { - LLPanelAvatar* self = (LLPanelAvatar*) userdata; + S32 option = LLNotification::getSelectedOption(notification, response); if (option == 0) { + LLUUID avatar_id = notification["payload"]["avatar_id"].asUUID(); LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_GodKickUser); msg->nextBlockFast(_PREHASH_UserInfo); msg->addUUIDFast(_PREHASH_GodID, gAgent.getID() ); msg->addUUIDFast(_PREHASH_GodSessionID, gAgent.getSessionID()); - msg->addUUIDFast(_PREHASH_AgentID, self->mAvatarID ); + msg->addUUIDFast(_PREHASH_AgentID, avatar_id ); msg->addU32("KickFlags", KICK_FLAGS_FREEZE ); - msg->addStringFast(_PREHASH_Reason, text ); + msg->addStringFast(_PREHASH_Reason, response["message"].asString() ); gAgent.sendReliableMessage(); } + return false; } // static void LLPanelAvatar::onClickUnfreeze(void* userdata) { - gViewerWindow->alertXmlEditText("UnFreezeUser", LLStringUtil::format_map_t(), - NULL, NULL, - LLPanelAvatar::finishUnfreeze, userdata); + LLPanelAvatar* self = (LLPanelAvatar*) userdata; + LLSD payload; + payload["avatar_id"] = self->mAvatarID; + LLNotifications::instance().add("UnFreezeUser", LLSD(), payload, LLPanelAvatar::finishUnfreeze); } // static -void LLPanelAvatar::finishUnfreeze(S32 option, const std::string& text, void* userdata) +bool LLPanelAvatar::finishUnfreeze(const LLSD& notification, const LLSD& response) { - LLPanelAvatar* self = (LLPanelAvatar*) userdata; - + S32 option = LLNotification::getSelectedOption(notification, response); + std::string text = response["message"].asString(); if (option == 0) { + LLUUID avatar_id = notification["payload"]["avatar_id"].asUUID(); LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_GodKickUser); msg->nextBlockFast(_PREHASH_UserInfo); msg->addUUIDFast(_PREHASH_GodID, gAgent.getID() ); msg->addUUIDFast(_PREHASH_GodSessionID, gAgent.getSessionID()); - msg->addUUIDFast(_PREHASH_AgentID, self->mAvatarID ); + msg->addUUIDFast(_PREHASH_AgentID, avatar_id ); msg->addU32("KickFlags", KICK_FLAGS_UNFREEZE ); msg->addStringFast(_PREHASH_Reason, text ); gAgent.sendReliableMessage(); } + return false; } // static diff --git a/indra/newview/llpanelavatar.h b/indra/newview/llpanelavatar.h index 833b124389..b7f9c69687 100644 --- a/indra/newview/llpanelavatar.h +++ b/indra/newview/llpanelavatar.h @@ -117,7 +117,7 @@ public: static void onDoubleClickGroup(void* userdata); static void onClickPublishHelp(void *userdata); static void onClickPartnerHelp(void *userdata); - static void onClickPartnerHelpLoadURL(S32 option, void* userdata); + static bool onClickPartnerHelpLoadURL(const LLSD& notification, const LLSD& response); static void onClickPartnerInfo(void *userdata); // Clear out the controls anticipating new network data. @@ -231,8 +231,8 @@ private: static void onClickNew(void* data); static void onClickDelete(void* data); - static void callbackDelete(S32 option, void* data); - static void callbackNew(S32 option, void* data); + bool callbackDelete(const LLSD& notification, const LLSD& response); + bool callbackNew(const LLSD& notification, const LLSD& response); }; @@ -257,7 +257,7 @@ private: static void onClickNew(void* data); static void onClickDelete(void* data); - static void callbackDelete(S32 option, void* data); + bool callbackDelete(const LLSD& notification, const LLSD& response); }; @@ -325,9 +325,9 @@ public: private: void enableOKIfReady(); - static void finishKick(S32 option, const std::string& text, void* userdata); - static void finishFreeze(S32 option, const std::string& text, void* userdata); - static void finishUnfreeze(S32 option, const std::string& text, void* userdata); + static bool finishKick(const LLSD& notification, const LLSD& response); + static bool finishFreeze(const LLSD& notification, const LLSD& response); + static bool finishUnfreeze(const LLSD& notification, const LLSD& response); static void showProfileCallback(S32 option, void *userdata); diff --git a/indra/newview/llpanelclassified.cpp b/indra/newview/llpanelclassified.cpp index 64cc19e2fd..e50f2649af 100644 --- a/indra/newview/llpanelclassified.cpp +++ b/indra/newview/llpanelclassified.cpp @@ -317,12 +317,12 @@ BOOL LLPanelClassified::titleIsValid() const std::string& name = mNameEditor->getText(); if (name.empty()) { - gViewerWindow->alertXml("BlankClassifiedName"); + LLNotifications::instance().add("BlankClassifiedName"); return FALSE; } if (!isalnum(name[0])) { - gViewerWindow->alertXml("ClassifiedMustBeAlphanumeric"); + LLNotifications::instance().add("ClassifiedMustBeAlphanumeric"); return FALSE; } @@ -339,31 +339,24 @@ void LLPanelClassified::apply() } } - -// static -void LLPanelClassified::saveCallback(S32 option, void* data) +bool LLPanelClassified::saveCallback(const LLSD& notification, const LLSD& response) { - LLPanelClassified* self = (LLPanelClassified*)data; + S32 option = LLNotification::getSelectedOption(notification, response); + switch(option) { case 0: // Save - self->sendClassifiedInfoUpdate(); + sendClassifiedInfoUpdate(); // fall through to close case 1: // Don't Save { - self->mForceClose = true; + mForceClose = true; // Close containing floater - LLView* view = self; - while (view) + LLFloater* parent_floater = gFloaterView->getParentFloater(this); + if (parent_floater) { - LLFloater* floaterp = dynamic_cast<LLFloater*>(view); - if (floaterp) - { - floaterp->close(); - break; - } - view = view->getParent(); + parent_floater->close(); } } break; @@ -373,16 +366,18 @@ void LLPanelClassified::saveCallback(S32 option, void* data) LLAppViewer::instance()->abortQuit(); break; } + return false; } + BOOL LLPanelClassified::canClose() { if (mForceClose || !checkDirty()) return TRUE; - LLStringUtil::format_map_t args; - args["[NAME]"] = mNameEditor->getText(); - LLAlertDialog::showXml("ClassifiedSave", args, saveCallback, this); + LLSD args; + args["NAME"] = mNameEditor->getText(); + LLNotifications::instance().add("ClassifiedSave", args, LLSD(), boost::bind(&LLPanelClassified::saveCallback, this, _1, _2)); return FALSE; } @@ -785,8 +780,11 @@ void LLPanelClassified::onClickUpdate(void* data) // If user has not set mature, do not allow publish if(self->mMatureCombo->getCurrentIndex() == DECLINE_TO_STATE) { - LLStringUtil::format_map_t args; - gViewerWindow->alertXml("SetClassifiedMature", &callbackConfirmMature, self); + // Tell user about it + LLNotifications::instance().add("SetClassifiedMature", + LLSD(), + LLSD(), + boost::bind(&LLPanelClassified::confirmMature, self, _1, _2)); return; } @@ -794,16 +792,11 @@ void LLPanelClassified::onClickUpdate(void* data) self->gotMature(); } -// static -void LLPanelClassified::callbackConfirmMature(S32 option, void* data) -{ - LLPanelClassified* self = (LLPanelClassified*)data; - self->confirmMature(option); -} - -// invoked from callbackConfirmMature -void LLPanelClassified::confirmMature(S32 option) +// Callback from a dialog indicating response to mature notification +bool LLPanelClassified::confirmMature(const LLSD& notification, const LLSD& response) { + S32 option = LLNotification::getSelectedOption(notification, response); + // 0 == Yes // 1 == No // 2 == Cancel @@ -816,11 +809,12 @@ void LLPanelClassified::confirmMature(S32 option) mMatureCombo->setCurrentByIndex(NON_MATURE_CONTENT); break; default: - return; + return false; } // If we got here it means they set a valid value gotMature(); + return false; } // Called after we have determined whether this classified has @@ -830,7 +824,9 @@ void LLPanelClassified::gotMature() // if already paid for, just do the update if (mPaidFor) { - callbackConfirmPublish(0, this); + LLNotification::Params params("PublishClassified"); + params.functor(boost::bind(&LLPanelClassified::confirmPublish, this, _1, _2)); + LLNotifications::instance().forceResponse(params, 0); } else { @@ -850,11 +846,11 @@ void LLPanelClassified::callbackGotPriceForListing(S32 option, std::string text, S32 price_for_listing = strtol(text.c_str(), NULL, 10); if (price_for_listing < MINIMUM_PRICE_FOR_LISTING) { - LLStringUtil::format_map_t args; + LLSD args; std::string price_text = llformat("%d", MINIMUM_PRICE_FOR_LISTING); - args["[MIN_PRICE]"] = price_text; + args["MIN_PRICE"] = price_text; - gViewerWindow->alertXml("MinClassifiedPrice", args); + LLNotifications::instance().add("MinClassifiedPrice", args); return; } @@ -862,10 +858,10 @@ void LLPanelClassified::callbackGotPriceForListing(S32 option, std::string text, // update send self->mPriceForListing = price_for_listing; - LLStringUtil::format_map_t args; - args["[AMOUNT]"] = llformat("%d", price_for_listing); - gViewerWindow->alertXml("PublishClassified", args, &callbackConfirmPublish, self); - + LLSD args; + args["AMOUNT"] = llformat("%d", price_for_listing); + LLNotifications::instance().add("PublishClassified", args, LLSD(), + boost::bind(&LLPanelClassified::confirmPublish, self, _1, _2)); } void LLPanelClassified::resetDirty() @@ -889,10 +885,11 @@ void LLPanelClassified::resetDirty() } // invoked from callbackConfirmPublish -void LLPanelClassified::confirmPublish(S32 option) +bool LLPanelClassified::confirmPublish(const LLSD& notification, const LLSD& response) { + S32 option = LLNotification::getSelectedOption(notification, response); // Option 0 = publish - if (option != 0) return; + if (option != 0) return false; sendClassifiedInfoUpdate(); @@ -911,14 +908,9 @@ void LLPanelClassified::confirmPublish(S32 option) } resetDirty(); + return false; } -// static -void LLPanelClassified::callbackConfirmPublish(S32 option, void* data) -{ - LLPanelClassified* self = (LLPanelClassified*)data; - self->confirmPublish(option); -} // static void LLPanelClassified::onClickTeleport(void* data) diff --git a/indra/newview/llpanelclassified.h b/indra/newview/llpanelclassified.h index ee84d89f43..f808eb9913 100644 --- a/indra/newview/llpanelclassified.h +++ b/indra/newview/llpanelclassified.h @@ -100,17 +100,15 @@ public: static void processClassifiedInfoReply(LLMessageSystem* msg, void**); // Confirmation dialogs flow in this order - static void callbackConfirmMature(S32 option, void* data); - void confirmMature(S32 option); + bool confirmMature(const LLSD& notification, const LLSD& response); void gotMature(); static void callbackGotPriceForListing(S32 option, std::string text, void* data); - static void callbackConfirmPublish(S32 option, void* data); - void confirmPublish(S32 option); + bool confirmPublish(const LLSD& notification, const LLSD& response); void sendClassifiedClickMessage(const std::string& type); protected: - static void saveCallback(S32 option, void* data); + bool saveCallback(const LLSD& notification, const LLSD& response); static void onClickUpdate(void* data); static void onClickTeleport(void* data); diff --git a/indra/newview/llpanelgroup.cpp b/indra/newview/llpanelgroup.cpp index 2d5f789141..6233740d53 100644 --- a/indra/newview/llpanelgroup.cpp +++ b/indra/newview/llpanelgroup.cpp @@ -45,6 +45,7 @@ #include "lluictrlfactory.h" #include "llviewerwindow.h" #include "llappviewer.h" +#include "llnotifications.h" // static void* LLPanelGroupTab::createTab(void* data) @@ -115,17 +116,12 @@ void LLPanelGroupTab::handleClickHelp() std::string help_text( getHelpText() ); if ( !help_text.empty() ) { - LLStringUtil::format_map_t args; - args["[MESSAGE]"] = help_text; - LLAlertDialog* dialogp = gViewerWindow->alertXml("GenericAlert", args); - if (dialogp) - { - LLFloater* root_floater = gFloaterView->getParentFloater(this);; - if (root_floater) - { - root_floater->addDependentFloater(dialogp); - } - } + LLSD args; + args["MESSAGE"] = help_text; + LLFloater* parent_floater = gFloaterView->getParentFloater(this); + LLNotification::Params params(parent_floater->contextualNotification("GenericAlert")); + params.substitutions(args); + LLNotifications::instance().add(params); } } @@ -411,11 +407,11 @@ BOOL LLPanelGroup::attemptTransition() mesg = mDefaultNeedsApplyMesg; } // Create a notify box, telling the user about the unapplied tab. - LLStringUtil::format_map_t args; - args["[NEEDS_APPLY_MESSAGE]"] = mesg; - args["[WANT_APPLY_MESSAGE]"] = mWantApplyMesg; - gViewerWindow->alertXml("PanelGroupApply", args, - onNotifyCallback, (void*) this); + LLSD args; + args["NEEDS_APPLY_MESSAGE"] = mesg; + args["WANT_APPLY_MESSAGE"] = mWantApplyMesg; + LLNotifications::instance().add("PanelGroupApply", args, LLSD(), + boost::bind(&LLPanelGroup::handleNotifyCallback, this, _1, _2)); mShowingNotifyDialog = TRUE; // We need to reselect the current tab, since it isn't finished. @@ -465,18 +461,9 @@ void LLPanelGroup::transitionToTab() } } -// static -void LLPanelGroup::onNotifyCallback(S32 option, void* user_data) -{ - LLPanelGroup* self = static_cast<LLPanelGroup*>(user_data); - if (self) - { - self->handleNotifyCallback(option); - } -} - -void LLPanelGroup::handleNotifyCallback(S32 option) +bool LLPanelGroup::handleNotifyCallback(const LLSD& notification, const LLSD& response) { + S32 option = LLNotification::getSelectedOption(notification, response); mShowingNotifyDialog = FALSE; switch (option) { @@ -512,6 +499,7 @@ void LLPanelGroup::handleNotifyCallback(S32 option) LLAppViewer::instance()->abortQuit(); break; } + return false; } // static @@ -568,9 +556,9 @@ bool LLPanelGroup::apply() // Inform the user. if ( !apply_mesg.empty() ) { - LLStringUtil::format_map_t args; - args["[MESSAGE]"] = apply_mesg; - gViewerWindow->alertXml("GenericAlert", args); + LLSD args; + args["MESSAGE"] = apply_mesg; + LLNotifications::instance().add("GenericAlert", args); } return false; @@ -638,7 +626,7 @@ void LLPanelGroup::showNotice(const std::string& subject, // We need to clean up that inventory offer. if (inventory_offer) { - inventory_offer_callback( IOR_DECLINE , inventory_offer); + inventory_offer->forceResponse(IOR_DECLINE); } return; } diff --git a/indra/newview/llpanelgroup.h b/indra/newview/llpanelgroup.h index f27ef75843..946448a224 100644 --- a/indra/newview/llpanelgroup.h +++ b/indra/newview/llpanelgroup.h @@ -87,8 +87,7 @@ public: void updateTabVisibility(); // Used by attemptTransition to query the user's response to a tab that needs to apply. - static void onNotifyCallback(S32 option, void* user_data); - void handleNotifyCallback(S32 option); + bool handleNotifyCallback(const LLSD& notification, const LLSD& response); bool apply(); void refreshData(); diff --git a/indra/newview/llpanelgroupgeneral.cpp b/indra/newview/llpanelgroupgeneral.cpp index 044ad280fa..f6f262f2be 100644 --- a/indra/newview/llpanelgroupgeneral.cpp +++ b/indra/newview/llpanelgroupgeneral.cpp @@ -344,18 +344,18 @@ void LLPanelGroupGeneral::onClickJoin(void *userdata) if (gdatap) { S32 cost = gdatap->mMembershipFee; - LLStringUtil::format_map_t args; - args["[COST]"] = llformat("%d", cost); - + LLSD args; + args["COST"] = llformat("%d", cost); + LLSD payload; + payload["group_id"] = self->mGroupID; + if (can_afford_transaction(cost)) { - gViewerWindow->alertXml("JoinGroupCanAfford", args, - LLPanelGroupGeneral::joinDlgCB, - self); + LLNotifications::instance().add("JoinGroupCanAfford", args, payload, LLPanelGroupGeneral::joinDlgCB); } else { - gViewerWindow->alertXml("JoinGroupCannotAfford", args); + LLNotifications::instance().add("JoinGroupCannotAfford", args, payload); } } else @@ -366,17 +366,18 @@ void LLPanelGroupGeneral::onClickJoin(void *userdata) } // static -void LLPanelGroupGeneral::joinDlgCB(S32 which, void *userdata) +bool LLPanelGroupGeneral::joinDlgCB(const LLSD& notification, const LLSD& response) { - LLPanelGroupGeneral* self = (LLPanelGroupGeneral*) userdata; + S32 option = LLNotification::getSelectedOption(notification, response); - if (which == 1 || !self) + if (option == 1) { // user clicked cancel - return; + return false; } - LLGroupMgr::getInstance()->sendGroupMemberJoin(self->mGroupID); + LLGroupMgr::getInstance()->sendGroupMemberJoin(notification["payload"]["group_id"].asUUID()); + return false; } // static @@ -444,9 +445,8 @@ bool LLPanelGroupGeneral::apply(std::string& mesg) if(mComboMature && mComboMature->getCurrentIndex() == DECLINE_TO_STATE) { - LLStringUtil::format_map_t args; - gViewerWindow->alertXml("SetGroupMature", &callbackConfirmMatureApply, - new LLHandle<LLPanel>(getHandle())); + LLNotifications::instance().add("SetGroupMature", LLSD(), LLSD(), + boost::bind(&LLPanelGroupGeneral::confirmMatureApply, this, _1, _2)); return false; } @@ -464,10 +464,9 @@ bool LLPanelGroupGeneral::apply(std::string& mesg) return false; } - LLStringUtil::format_map_t args; - args["[MESSAGE]"] = mConfirmGroupCreateStr; - gViewerWindow->alertXml("GenericAlertYesCancel", args, - createGroupCallback, new LLHandle<LLPanel>(getHandle()) ); + LLSD args; + args["MESSAGE"] = mConfirmGroupCreateStr; + LLNotifications::instance().add("GenericAlertYesCancel", args, LLSD(), boost::bind(&LLPanelGroupGeneral::createGroupCallback, this, _1, _2)); return false; } @@ -545,22 +544,10 @@ void LLPanelGroupGeneral::cancel() notifyObservers(); } - -// static -void LLPanelGroupGeneral::callbackConfirmMatureApply(S32 option, void* data) -{ - LLHandle<LLPanel>* handlep = (LLHandle<LLPanel>*)data; - LLPanelGroupGeneral* self = dynamic_cast<LLPanelGroupGeneral*>(handlep->get()); - delete handlep; - if (self) - { - self->confirmMatureApply(option); - } -} - // invoked from callbackConfirmMature -void LLPanelGroupGeneral::confirmMatureApply(S32 option) +bool LLPanelGroupGeneral::confirmMatureApply(const LLSD& notification, const LLSD& response) { + S32 option = LLNotification::getSelectedOption(notification, response); // 0 == Yes // 1 == No // 2 == Cancel @@ -573,39 +560,35 @@ void LLPanelGroupGeneral::confirmMatureApply(S32 option) mComboMature->setCurrentByIndex(NON_MATURE_CONTENT); break; default: - return; + return false; } // If we got here it means they set a valid value std::string mesg = ""; apply(mesg); + return false; } // static -void LLPanelGroupGeneral::createGroupCallback(S32 option, void* userdata) +bool LLPanelGroupGeneral::createGroupCallback(const LLSD& notification, const LLSD& response) { - LLHandle<LLPanel> panel_handle = *(LLHandle<LLPanel>*)userdata; - delete (LLHandle<LLPanel>*)userdata; - - LLPanelGroupGeneral* self = dynamic_cast<LLPanelGroupGeneral*>(panel_handle.get()); - if (!self) return; - + S32 option = LLNotification::getSelectedOption(notification, response); switch(option) { case 0: { // Yay! We are making a new group! - U32 enrollment_fee = (self->mCtrlEnrollmentFee->get() ? - (U32) self->mSpinEnrollmentFee->get() : 0); + U32 enrollment_fee = (mCtrlEnrollmentFee->get() ? + (U32) mSpinEnrollmentFee->get() : 0); - LLGroupMgr::getInstance()->sendCreateGroupRequest(self->mGroupNameEditor->getText(), - self->mEditCharter->getText(), - self->mCtrlShowInGroupList->get(), - self->mInsignia->getImageAssetID(), + LLGroupMgr::getInstance()->sendCreateGroupRequest(mGroupNameEditor->getText(), + mEditCharter->getText(), + mCtrlShowInGroupList->get(), + mInsignia->getImageAssetID(), enrollment_fee, - self->mCtrlOpenEnrollment->get(), + mCtrlOpenEnrollment->get(), false, - self->mComboMature->getCurrentIndex() == MATURE_CONTENT); + mComboMature->getCurrentIndex() == MATURE_CONTENT); } break; @@ -613,6 +596,7 @@ void LLPanelGroupGeneral::createGroupCallback(S32 option, void* userdata) default: break; } + return false; } static F32 sSDTime = 0.0f; diff --git a/indra/newview/llpanelgroupgeneral.h b/indra/newview/llpanelgroupgeneral.h index 982d0678dd..c38594ef0d 100644 --- a/indra/newview/llpanelgroupgeneral.h +++ b/indra/newview/llpanelgroupgeneral.h @@ -57,8 +57,7 @@ public: virtual bool needsApply(std::string& mesg); virtual bool apply(std::string& mesg); virtual void cancel(); - static void createGroupCallback(S32 option, void* user_data); - static void callbackConfirmMatureApply(S32 option, void* data); + bool createGroupCallback(const LLSD& notification, const LLSD& response); virtual void update(LLGroupChange gc); @@ -77,11 +76,11 @@ private: static void onReceiveNotices(LLUICtrl* ctrl, void* data); static void openProfile(void* data); - static void joinDlgCB(S32 which, void *userdata); + static bool joinDlgCB(const LLSD& notification, const LLSD& response); void updateMembers(); void updateChanged(); - void confirmMatureApply(S32 option); + bool confirmMatureApply(const LLSD& notification, const LLSD& response); BOOL mPendingMemberUpdate; BOOL mChanged; diff --git a/indra/newview/llpanelgroupinvite.cpp b/indra/newview/llpanelgroupinvite.cpp index c4af61587c..70440dd75a 100644 --- a/indra/newview/llpanelgroupinvite.cpp +++ b/indra/newview/llpanelgroupinvite.cpp @@ -66,7 +66,7 @@ public: static void callbackAddUsers(const std::vector<std::string>& names, const std::vector<LLUUID>& agent_ids, void* user_data); - static void inviteOwnerCallback(S32 option, void* userdata); + bool inviteOwnerCallback(const LLSD& notification, const LLSD& response); public: LLUUID mGroupID; @@ -158,9 +158,9 @@ void LLPanelGroupInvite::impl::submitInvitations() // owner role: display confirmation and wait for callback if ((role_id == gdatap->mOwnerRole) && (!mConfirmedOwnerInvite)) { - LLStringUtil::format_map_t args; - args["[MESSAGE]"] = mOwnerWarning; - gViewerWindow->alertXml("GenericAlertYesCancel", args, inviteOwnerCallback, this); + LLSD args; + args["MESSAGE"] = mOwnerWarning; + LLNotifications::instance().add("GenericAlertYesCancel", args, LLSD(), boost::bind(&LLPanelGroupInvite::impl::inviteOwnerCallback, this, _1, _2)); return; // we'll be called again if user confirms } } @@ -180,24 +180,23 @@ void LLPanelGroupInvite::impl::submitInvitations() (*mCloseCallback)(mCloseCallbackUserData); } -//static -void LLPanelGroupInvite::impl::inviteOwnerCallback(S32 option, void* userdata) +bool LLPanelGroupInvite::impl::inviteOwnerCallback(const LLSD& notification, const LLSD& response) { - LLPanelGroupInvite::impl* self = (LLPanelGroupInvite::impl*)userdata; - if (!self) return; + S32 option = LLNotification::getSelectedOption(notification, response); switch(option) { case 0: // user confirmed that they really want a new group owner - self->mConfirmedOwnerInvite = true; - self->submitInvitations(); + mConfirmedOwnerInvite = true; + submitInvitations(); break; case 1: // fall through default: break; } + return false; } @@ -396,16 +395,14 @@ void LLPanelGroupInvite::addUsers(std::vector<LLUUID>& agent_ids) if(dest && dest->isAvatar()) { std::string fullname; - LLStringUtil::format_map_t args; + LLSD args; LLNameValue* nvfirst = dest->getNVPair("FirstName"); LLNameValue* nvlast = dest->getNVPair("LastName"); if(nvfirst && nvlast) { - args["[FIRST]"] = nvfirst->getString(); - args["[LAST]"] = nvlast->getString(); - fullname = nvfirst->getString(); - fullname += " "; - fullname += nvlast->getString(); + args["FIRST"] = std::string(nvfirst->getString()); + args["LAST"] = std::string(nvlast->getString()); + fullname = std::string(nvfirst->getString()) + " " + std::string(nvlast->getString()); } if (!fullname.empty()) { diff --git a/indra/newview/llpanelgroupnotices.cpp b/indra/newview/llpanelgroupnotices.cpp index 18fcc9d291..1b1a7e32a0 100644 --- a/indra/newview/llpanelgroupnotices.cpp +++ b/indra/newview/llpanelgroupnotices.cpp @@ -53,6 +53,7 @@ #include "roles_constants.h" #include "llviewerwindow.h" #include "llviewermessage.h" +#include "llnotifications.h" const S32 NOTICE_DATE_STRING_SIZE = 30; @@ -195,7 +196,8 @@ LLPanelGroupNotices::~LLPanelGroupNotices() if (mInventoryOffer) { // Cancel the inventory offer. - inventory_offer_callback( IOR_DECLINE , mInventoryOffer); + mInventoryOffer->forceResponse(IOR_DECLINE); + mInventoryOffer = NULL; } } @@ -345,7 +347,7 @@ void LLPanelGroupNotices::onClickOpenAttachment(void* data) { LLPanelGroupNotices* self = (LLPanelGroupNotices*)data; - inventory_offer_callback( IOR_ACCEPT , self->mInventoryOffer); + self->mInventoryOffer->forceResponse(IOR_ACCEPT); self->mInventoryOffer = NULL; self->mBtnOpenAttachment->setEnabled(FALSE); } @@ -357,7 +359,7 @@ void LLPanelGroupNotices::onClickSendMessage(void* data) if (self->mCreateSubject->getText().empty()) { // Must supply a subject - gViewerWindow->alertXml("MustSpecifyGroupNoticeSubject"); + LLNotifications::instance().add("MustSpecifyGroupNoticeSubject"); return; } send_group_notice( @@ -384,7 +386,7 @@ void LLPanelGroupNotices::onClickNewMessage(void* data) if (self->mInventoryOffer) { - inventory_offer_callback( IOR_DECLINE , self->mInventoryOffer); + self->mInventoryOffer->forceResponse(IOR_DECLINE); self->mInventoryOffer = NULL; } @@ -535,7 +537,7 @@ void LLPanelGroupNotices::showNotice(const std::string& subject, if (mInventoryOffer) { // Cancel the inventory offer for the previously viewed notice - inventory_offer_callback( IOR_DECLINE , mInventoryOffer); + mInventoryOffer->forceResponse(IOR_DECLINE); mInventoryOffer = NULL; } diff --git a/indra/newview/llpanelgrouproles.cpp b/indra/newview/llpanelgrouproles.cpp index 4b48fb3510..6fb601bf56 100644 --- a/indra/newview/llpanelgrouproles.cpp +++ b/indra/newview/llpanelgrouproles.cpp @@ -237,11 +237,11 @@ BOOL LLPanelGroupRoles::attemptTransition() mesg = mDefaultNeedsApplyMesg; } // Create a notify box, telling the user about the unapplied tab. - LLStringUtil::format_map_t args; - args["[NEEDS_APPLY_MESSAGE]"] = mesg; - args["[WANT_APPLY_MESSAGE]"] = mWantApplyMesg; - gViewerWindow->alertXml("PanelGroupApply", args, - onNotifyCallback, (void*) this); + LLSD args; + args["NEEDS_APPLY_MESSAGE"] = mesg; + args["WANT_APPLY_MESSAGE"] = mWantApplyMesg; + LLNotifications::instance().add("PanelGroupApply", args, LLSD(), + boost::bind(&LLPanelGroupRoles::handleNotifyCallback, this, _1, _2)); mHasModal = TRUE; // We need to reselect the current tab, since it isn't finished. if (mSubTabContainer) @@ -282,18 +282,9 @@ void LLPanelGroupRoles::transitionToTab() } } -// static -void LLPanelGroupRoles::onNotifyCallback(S32 option, void* user_data) -{ - LLPanelGroupRoles* self = static_cast<LLPanelGroupRoles*>(user_data); - if (self) - { - self->handleNotifyCallback(option); - } -} - -void LLPanelGroupRoles::handleNotifyCallback(S32 option) +bool LLPanelGroupRoles::handleNotifyCallback(const LLSD& notification, const LLSD& response) { + S32 option = LLNotification::getSelectedOption(notification, response); mHasModal = FALSE; switch (option) { @@ -307,9 +298,9 @@ void LLPanelGroupRoles::handleNotifyCallback(S32 option) if ( !apply_mesg.empty() ) { mHasModal = TRUE; - LLStringUtil::format_map_t args; - args["[MESSAGE]"] = apply_mesg; - gViewerWindow->alertXml("GenericAlert", args, onModalClose, (void*) this); + LLSD args; + args["MESSAGE"] = apply_mesg; + LLNotifications::instance().add("GenericAlert", args, LLSD(), boost::bind(&LLPanelGroupRoles::onModalClose, this, _1, _2)); } // Skip switching tabs. break; @@ -337,16 +328,13 @@ void LLPanelGroupRoles::handleNotifyCallback(S32 option) // Do nothing. The user is canceling the action. break; } + return false; } -// static -void LLPanelGroupRoles::onModalClose(S32 option, void* user_data) +bool LLPanelGroupRoles::onModalClose(const LLSD& notification, const LLSD& response) { - LLPanelGroupRoles* self = static_cast<LLPanelGroupRoles*>(user_data); - if (self) - { - self->mHasModal = FALSE; - } + mHasModal = FALSE; + return false; } @@ -1375,16 +1363,16 @@ bool LLPanelGroupMembersSubTab::apply(std::string& mesg) if ( mNumOwnerAdditions > 0 ) { LLRoleData rd; - LLStringUtil::format_map_t args; + LLSD args; if ( gdatap->getRoleData(gdatap->mOwnerRole, rd) ) { mHasModal = TRUE; - args["[ROLE_NAME]"] = rd.mRoleName; - gViewerWindow->alertXml("AddGroupOwnerWarning", + args["ROLE_NAME"] = rd.mRoleName; + LLNotifications::instance().add("AddGroupOwnerWarning", args, - addOwnerCB, - this); + LLSD(), + boost::bind(&LLPanelGroupMembersSubTab::addOwnerCB, this, _1, _2)); } else { @@ -1404,20 +1392,17 @@ bool LLPanelGroupMembersSubTab::apply(std::string& mesg) return true; } -//static -void LLPanelGroupMembersSubTab::addOwnerCB(S32 option, void* data) +bool LLPanelGroupMembersSubTab::addOwnerCB(const LLSD& notification, const LLSD& response) { - LLPanelGroupMembersSubTab* self = (LLPanelGroupMembersSubTab*) data; - - if (!self) return; - - self->mHasModal = FALSE; + S32 option = LLNotification::getSelectedOption(notification, response); + mHasModal = FALSE; if (0 == option) { // User clicked "Yes" - self->applyMemberChanges(); + applyMemberChanges(); } + return false; } void LLPanelGroupMembersSubTab::applyMemberChanges() @@ -2225,22 +2210,19 @@ void LLPanelGroupRolesSubTab::handleActionCheck(LLCheckBoxCtrl* check, bool forc check->set(FALSE); LLRoleData rd; - LLStringUtil::format_map_t args; + LLSD args; if ( gdatap->getRoleData(role_id, rd) ) { - args["[ACTION_NAME]"] = rap->mDescription; - args["[ROLE_NAME]"] = rd.mRoleName; - struct ActionCBData* cb_data = new ActionCBData; - cb_data->mSelf = this; - cb_data->mCheck = check; + args["ACTION_NAME"] = rap->mDescription; + args["ROLE_NAME"] = rd.mRoleName; mHasModal = TRUE; std::string warning = "AssignDangerousActionWarning"; if (GP_ROLE_CHANGE_ACTIONS == power) { warning = "AssignDangerousAbilityWarning"; } - gViewerWindow->alertXml(warning, args, addActionCB, cb_data); + LLNotifications::instance().add(warning, args, LLSD(), boost::bind(&LLPanelGroupRolesSubTab::addActionCB, this, _1, _2, check)); } else { @@ -2262,22 +2244,21 @@ void LLPanelGroupRolesSubTab::handleActionCheck(LLCheckBoxCtrl* check, bool forc notifyObservers(); } -//static -void LLPanelGroupRolesSubTab::addActionCB(S32 option, void* data) +bool LLPanelGroupRolesSubTab::addActionCB(const LLSD& notification, const LLSD& response, LLCheckBoxCtrl* check) { - struct ActionCBData* cb_data = (struct ActionCBData*) data; + if (!check) return false; - if (!cb_data || !cb_data->mSelf || !cb_data->mCheck) return; - - cb_data->mSelf->mHasModal = FALSE; + mHasModal = FALSE; + S32 option = LLNotification::getSelectedOption(notification, response); if (0 == option) { // User clicked "Yes" - cb_data->mCheck->set(TRUE); + check->set(TRUE); const bool force_add = true; - cb_data->mSelf->handleActionCheck(cb_data->mCheck, force_add); + handleActionCheck(check, force_add); } + return false; } @@ -2413,9 +2394,9 @@ void LLPanelGroupRolesSubTab::handleDeleteRole() if (role_item->getUUID().isNull() || role_item->getUUID() == gdatap->mOwnerRole) { - LLStringUtil::format_map_t args; - args["[MESSAGE]"] = mRemoveEveryoneTxt; - LLNotifyBox::showXml("GenericNotify", args); + LLSD args; + args["MESSAGE"] = mRemoveEveryoneTxt; + LLNotifications::instance().add("GenericNotify", args); return; } diff --git a/indra/newview/llpanelgrouproles.h b/indra/newview/llpanelgrouproles.h index f55d70f018..592e585f9e 100644 --- a/indra/newview/llpanelgrouproles.h +++ b/indra/newview/llpanelgrouproles.h @@ -73,9 +73,8 @@ public: void transitionToTab(); // Used by attemptTransition to query the user's response to a tab that needs to apply. - static void onNotifyCallback(S32 option, void* user_data); - void handleNotifyCallback(S32 option); - static void onModalClose(S32 option, void* user_data); + bool handleNotifyCallback(const LLSD& notification, const LLSD& response); + bool onModalClose(const LLSD& notification, const LLSD& response); // Most of these messages are just passed on to the current sub-tab. virtual std::string getHelpText() const; @@ -188,7 +187,7 @@ public: LLRoleMemberChangeType type); void applyMemberChanges(); - static void addOwnerCB(S32 option, void* data); + bool addOwnerCB(const LLSD& notification, const LLSD& response); virtual void activate(); virtual void deactivate(); @@ -250,7 +249,7 @@ public: static void onActionCheck(LLUICtrl*, void*); void handleActionCheck(LLCheckBoxCtrl*, bool force=false); - static void addActionCB(S32 option, void* data); + bool addActionCB(const LLSD& notification, const LLSD& response, LLCheckBoxCtrl* check); static void onPropertiesKey(LLLineEditor*, void*); diff --git a/indra/newview/llpanelland.cpp b/indra/newview/llpanelland.cpp index 11f88695c5..05381ae7d8 100644 --- a/indra/newview/llpanelland.cpp +++ b/indra/newview/llpanelland.cpp @@ -266,5 +266,5 @@ void LLPanelLandInfo::onClickAbout(void*) void LLPanelLandInfo::onShowOwnersHelp(void* user_data) { - gViewerWindow->alertXml("ShowOwnersHelp"); + LLNotifications::instance().add("ShowOwnersHelp"); } diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp index 20228ed306..929043e97d 100644 --- a/indra/newview/llpanellogin.cpp +++ b/indra/newview/llpanellogin.cpp @@ -899,16 +899,17 @@ void LLPanelLogin::onClickConnect(void *) } else { - gViewerWindow->alertXml("MustHaveAccountToLogIn", - LLPanelLogin::newAccountAlertCallback); + LLNotifications::instance().add("MustHaveAccountToLogIn", LLSD(), LLSD(), + LLPanelLogin::newAccountAlertCallback); } } } // static -void LLPanelLogin::newAccountAlertCallback(S32 option, void*) +bool LLPanelLogin::newAccountAlertCallback(const LLSD& notification, const LLSD& response) { + S32 option = LLNotification::getSelectedOption(notification, response); if (0 == option) { llinfos << "Going to account creation URL" << llendl; @@ -918,6 +919,7 @@ void LLPanelLogin::newAccountAlertCallback(S32 option, void*) { sInstance->setFocus(TRUE); } + return false; } @@ -964,7 +966,7 @@ void LLPanelLogin::onPassKey(LLLineEditor* caller, void* user_data) { if (gKeyboard->getKeyDown(KEY_CAPSLOCK) && sCapslockDidNotification == FALSE) { - LLNotifyBox::showXml("CapsKeyOn"); + LLNotifications::instance().add("CapsKeyOn"); sCapslockDidNotification = TRUE; } } diff --git a/indra/newview/llpanellogin.h b/indra/newview/llpanellogin.h index 9d7e386cda..1f803fa57c 100644 --- a/indra/newview/llpanellogin.h +++ b/indra/newview/llpanellogin.h @@ -82,7 +82,7 @@ public: private: static void onClickConnect(void*); static void onClickNewAccount(void*); - static void newAccountAlertCallback(S32 option, void*); + static bool newAccountAlertCallback(const LLSD& notification, const LLSD& response); static void onClickQuit(void*); static void onClickVersion(void*); virtual void onNavigateComplete( const EventType& eventIn ); diff --git a/indra/newview/llpanelpermissions.cpp b/indra/newview/llpanelpermissions.cpp index 8a75385984..b46e04d462 100644 --- a/indra/newview/llpanelpermissions.cpp +++ b/indra/newview/llpanelpermissions.cpp @@ -876,8 +876,9 @@ void LLPanelPermissions::cbGroupID(LLUUID group_id, void* userdata) LLSelectMgr::getInstance()->sendGroup(group_id); } -void callback_deed_to_group(S32 option, void*) +bool callback_deed_to_group(const LLSD& notification, const LLSD& response) { + S32 option = LLNotification::getSelectedOption(notification, response); if (0 == option) { LLUUID group_id; @@ -888,12 +889,12 @@ void callback_deed_to_group(S32 option, void*) // LLViewerStats::getInstance()->incStat(LLViewerStats::ST_RELEASE_COUNT); } } + return false; } void LLPanelPermissions::onClickDeedToGroup(void* data) { - gViewerWindow->alertXml( "DeedObjectToGroup", - callback_deed_to_group, NULL); + LLNotifications::instance().add( "DeedObjectToGroup", LLSD(), LLSD(), callback_deed_to_group); } ///---------------------------------------------------------------------------- @@ -1092,7 +1093,7 @@ void LLPanelPermissions::onCommitClickAction(LLUICtrl* ctrl, void*) LLSelectMgr::getInstance()->selectGetSaleInfo(sale_info); if (!sale_info.isForSale()) { - gViewerWindow->alertXml("CantSetBuyObject"); + LLNotifications::instance().add("CantSetBuyObject"); // Set click action back to its old value U8 click_action = 0; @@ -1110,7 +1111,7 @@ void LLPanelPermissions::onCommitClickAction(LLUICtrl* ctrl, void*) if (!can_pay) { // Warn, but do it anyway. - gViewerWindow->alertXml("ClickActionNotPayable"); + LLNotifications::instance().add("ClickActionNotPayable"); } } LLSelectMgr::getInstance()->selectionSetClickAction(click_action); diff --git a/indra/newview/llpanelpick.cpp b/indra/newview/llpanelpick.cpp index 9bd118fa1d..2420d8d424 100644 --- a/indra/newview/llpanelpick.cpp +++ b/indra/newview/llpanelpick.cpp @@ -476,7 +476,7 @@ void LLPanelPick::onClickSet(void* data) // is the location and nothing else if ( gAgent.getRegion ()->getName () != self->mSimName ) { - gViewerWindow->alertXml("SetPickLocation"); + LLNotifications::instance().add("SetPickLocation"); }; self->mLocationEditor->setText(location_text); diff --git a/indra/newview/llpanelplace.cpp b/indra/newview/llpanelplace.cpp index 4ae253360a..100fa3209d 100644 --- a/indra/newview/llpanelplace.cpp +++ b/indra/newview/llpanelplace.cpp @@ -416,24 +416,24 @@ void LLPanelPlace::onClickLandmark(void* data) void LLPanelPlace::onClickAuction(void* data) { LLPanelPlace* self = (LLPanelPlace*)data; + LLSD payload; + payload["auction_id"] = self->mAuctionID; - gViewerWindow->alertXml("GoToAuctionPage", - callbackAuctionWebPage, - self); + LLNotifications::instance().add("GoToAuctionPage", LLSD(), payload, callbackAuctionWebPage); } // static -void LLPanelPlace::callbackAuctionWebPage(S32 option, void* data) +bool LLPanelPlace::callbackAuctionWebPage(const LLSD& notification, const LLSD& response) { - LLPanelPlace* self = (LLPanelPlace*)data; - + S32 option = LLNotification::getSelectedOption(notification, response); if (0 == option) { std::string url; - url = AUCTION_URL + llformat( "%010d", self->mAuctionID); + url = AUCTION_URL + llformat("%010d", response["auction_id"].asInteger()); llinfos << "Loading auction page " << url << llendl; LLWeb::loadURL(url); } + return false; } diff --git a/indra/newview/llpanelplace.h b/indra/newview/llpanelplace.h index 7a09f5cca6..db47889546 100644 --- a/indra/newview/llpanelplace.h +++ b/indra/newview/llpanelplace.h @@ -83,7 +83,7 @@ protected: static void onClickAuction(void* data); // Go to auction web page if user clicked OK - static void callbackAuctionWebPage(S32 option, void* data); + static bool callbackAuctionWebPage(const LLSD& notification, const LLSD& response); protected: LLUUID mParcelID; diff --git a/indra/newview/llpreviewgesture.cpp b/indra/newview/llpreviewgesture.cpp index 7661f9acd6..7e465a88bc 100644 --- a/indra/newview/llpreviewgesture.cpp +++ b/indra/newview/llpreviewgesture.cpp @@ -284,9 +284,8 @@ BOOL LLPreviewGesture::canClose() else { // Bring up view-modal dialog: Save changes? Yes, No, Cancel - gViewerWindow->alertXml("SaveChanges", - handleSaveChangesDialog, - this ); + LLNotifications::instance().add("SaveChanges", LLSD(), LLSD(), + boost::bind(&LLPreviewGesture::handleSaveChangesDialog, this, _1, _2) ); return FALSE; } } @@ -320,22 +319,21 @@ void LLPreviewGesture::setMinimized(BOOL minimize) } -// static -void LLPreviewGesture::handleSaveChangesDialog(S32 option, void* data) +bool LLPreviewGesture::handleSaveChangesDialog(const LLSD& notification, const LLSD& response) { - LLPreviewGesture* self = (LLPreviewGesture*)data; + S32 option = LLNotification::getSelectedOption(notification, response); switch(option) { case 0: // "Yes" - gGestureManager.stopGesture(self->mPreviewGesture); - self->mCloseAfterSave = TRUE; - onClickSave(data); + gGestureManager.stopGesture(mPreviewGesture); + mCloseAfterSave = TRUE; + onClickSave(this); break; case 1: // "No" - gGestureManager.stopGesture(self->mPreviewGesture); - self->mDirty = FALSE; // Force the dirty flag because user has clicked NO on confirm save dialog... - self->close(); + gGestureManager.stopGesture(mPreviewGesture); + mDirty = FALSE; // Force the dirty flag because user has clicked NO on confirm save dialog... + close(); break; case 2: // "Cancel" @@ -344,6 +342,7 @@ void LLPreviewGesture::handleSaveChangesDialog(S32 option, void* data) LLAppViewer::instance()->abortQuit(); break; } + return false; } @@ -1114,14 +1113,14 @@ void LLPreviewGesture::saveIfNeeded() if (dp.getCurrentSize() > 1000) { - gViewerWindow->alertXml("GestureSaveFailedTooManySteps"); + LLNotifications::instance().add("GestureSaveFailedTooManySteps"); delete gesture; gesture = NULL; } else if (!ok) { - gViewerWindow->alertXml("GestureSaveFailedTryAgain"); + LLNotifications::instance().add("GestureSaveFailedTryAgain"); delete gesture; gesture = NULL; } @@ -1260,7 +1259,7 @@ void LLPreviewGesture::onSaveComplete(const LLUUID& asset_uuid, void* user_data, } else { - gViewerWindow->alertXml("GestureSaveFailedObjectNotFound"); + LLNotifications::instance().add("GestureSaveFailedObjectNotFound"); } } @@ -1274,9 +1273,9 @@ void LLPreviewGesture::onSaveComplete(const LLUUID& asset_uuid, void* user_data, else { llwarns << "Problem saving gesture: " << status << llendl; - LLStringUtil::format_map_t args; - args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); - gViewerWindow->alertXml("GestureSaveFailedReason",args); + LLSD args; + args["REASON"] = std::string(LLAssetStorage::getErrorString(status)); + LLNotifications::instance().add("GestureSaveFailedReason", args); } delete info; info = NULL; diff --git a/indra/newview/llpreviewgesture.h b/indra/newview/llpreviewgesture.h index 3b07608134..bbe9486bfd 100644 --- a/indra/newview/llpreviewgesture.h +++ b/indra/newview/llpreviewgesture.h @@ -101,7 +101,7 @@ protected: void* user_data, S32 status, LLExtStat ext_status); - static void handleSaveChangesDialog(S32 option, void* userdata); + bool handleSaveChangesDialog(const LLSD& notification, const LLSD& response); // Write UI back into gesture LLMultiGesture* createGesture(); diff --git a/indra/newview/llpreviewnotecard.cpp b/indra/newview/llpreviewnotecard.cpp index 61ebe6cbbc..ef61270069 100644 --- a/indra/newview/llpreviewnotecard.cpp +++ b/indra/newview/llpreviewnotecard.cpp @@ -229,9 +229,7 @@ BOOL LLPreviewNotecard::canClose() else { // Bring up view-modal dialog: Save changes? Yes, No, Cancel - gViewerWindow->alertXml("SaveChanges", - &LLPreviewNotecard::handleSaveChangesDialog, - this); + LLNotifications::instance().add("SaveChanges", LLSD(), LLSD(), boost::bind(&LLPreviewNotecard::handleSaveChangesDialog,this, _1, _2)); return FALSE; } @@ -403,15 +401,15 @@ void LLPreviewNotecard::onLoadComplete(LLVFS *vfs, if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status || LL_ERR_FILE_EMPTY == status) { - LLNotifyBox::showXml("NotecardMissing"); + LLNotifications::instance().add("NotecardMissing"); } else if (LL_ERR_INSUFFICIENT_PERMISSIONS == status) { - LLNotifyBox::showXml("NotecardNoPermissions"); + LLNotifications::instance().add("NotecardNoPermissions"); } else { - LLNotifyBox::showXml("UnableToLoadNotecard"); + LLNotifications::instance().add("UnableToLoadNotecard"); } llwarns << "Problem loading notecard: " << status << llendl; @@ -578,7 +576,7 @@ void LLPreviewNotecard::onSaveComplete(const LLUUID& asset_uuid, void* user_data } else { - gViewerWindow->alertXml("SaveNotecardFailObjectNotFound"); + LLNotifications::instance().add("SaveNotecardFailObjectNotFound"); } } // Perform item copy to inventory @@ -601,9 +599,9 @@ void LLPreviewNotecard::onSaveComplete(const LLUUID& asset_uuid, void* user_data else { llwarns << "Problem saving notecard: " << status << llendl; - LLStringUtil::format_map_t args; - args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); - gViewerWindow->alertXml("SaveNotecardFailReason",args); + LLSD args; + args["REASON"] = std::string(LLAssetStorage::getErrorString(status)); + LLNotifications::instance().add("SaveNotecardFailReason", args); } std::string uuid_string; @@ -614,20 +612,19 @@ void LLPreviewNotecard::onSaveComplete(const LLUUID& asset_uuid, void* user_data delete info; } -// static -void LLPreviewNotecard::handleSaveChangesDialog(S32 option, void* userdata) +bool LLPreviewNotecard::handleSaveChangesDialog(const LLSD& notification, const LLSD& response) { - LLPreviewNotecard* self = (LLPreviewNotecard*)userdata; + S32 option = LLNotification::getSelectedOption(notification, response); switch(option) { case 0: // "Yes" - self->mCloseAfterSave = TRUE; - LLPreviewNotecard::onClickSave((void*)self); + mCloseAfterSave = TRUE; + LLPreviewNotecard::onClickSave((void*)this); break; case 1: // "No" - self->mForceClose = TRUE; - self->close(); + mForceClose = TRUE; + close(); break; case 2: // "Cancel" @@ -636,6 +633,7 @@ void LLPreviewNotecard::handleSaveChangesDialog(S32 option, void* userdata) LLAppViewer::instance()->abortQuit(); break; } + return false; } void LLPreviewNotecard::reshape(S32 width, S32 height, BOOL called_from_parent) diff --git a/indra/newview/llpreviewnotecard.h b/indra/newview/llpreviewnotecard.h index 1c801abf59..7175a764ec 100644 --- a/indra/newview/llpreviewnotecard.h +++ b/indra/newview/llpreviewnotecard.h @@ -101,7 +101,7 @@ protected: void* user_data, S32 status, LLExtStat ext_status); - static void handleSaveChangesDialog(S32 option, void* userdata); + bool handleSaveChangesDialog(const LLSD& notification, const LLSD& response); virtual const char *getTitleName() const { return "Note"; } diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 2717c44415..42363079a4 100644 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -608,27 +608,26 @@ BOOL LLScriptEdCore::canClose() else { // Bring up view-modal dialog: Save changes? Yes, No, Cancel - gViewerWindow->alertXml("SaveChanges", LLScriptEdCore::handleSaveChangesDialog, this); + LLNotifications::instance().add("SaveChanges", LLSD(), LLSD(), boost::bind(&LLScriptEdCore::handleSaveChangesDialog, this, _1, _2)); return FALSE; } } -// static -void LLScriptEdCore::handleSaveChangesDialog( S32 option, void* userdata ) +bool LLScriptEdCore::handleSaveChangesDialog(const LLSD& notification, const LLSD& response ) { - LLScriptEdCore* self = (LLScriptEdCore*) userdata; + S32 option = LLNotification::getSelectedOption(notification, response); switch( option ) { case 0: // "Yes" // close after saving - LLScriptEdCore::doSave( self, TRUE ); + LLScriptEdCore::doSave( this, TRUE ); break; case 1: // "No" - self->mForceClose = TRUE; + mForceClose = TRUE; // This will close immediately because mForceClose is true, so we won't // infinite loop with these dialogs. JC - ((LLFloater*) self->getParent())->close(); + ((LLFloater*) getParent())->close(); break; case 2: // "Cancel" @@ -637,29 +636,32 @@ void LLScriptEdCore::handleSaveChangesDialog( S32 option, void* userdata ) LLAppViewer::instance()->abortQuit(); break; } + return false; } // static -void LLScriptEdCore::onHelpWebDialog(S32 option, void* userdata) +bool LLScriptEdCore::onHelpWebDialog(const LLSD& notification, const LLSD& response) { - LLScriptEdCore* corep = (LLScriptEdCore*)userdata; + S32 option = LLNotification::getSelectedOption(notification, response); switch(option) { case 0: - LLWeb::loadURL(corep->mHelpURL); + LLWeb::loadURL(notification["payload"]["help_url"]); break; default: break; } + return false; } // static void LLScriptEdCore::onBtnHelp(void* userdata) { - gViewerWindow->alertXml("WebLaunchLSLGuide", - onHelpWebDialog, - userdata); + LLScriptEdCore* corep = (LLScriptEdCore*)userdata; + LLSD payload; + payload["help_url"] = corep->mHelpURL; + LLNotifications::instance().add("WebLaunchLSLGuide", LLSD(), payload, onHelpWebDialog); } // static @@ -818,8 +820,7 @@ void LLScriptEdCore::onBtnUndoChanges( void* userdata ) LLScriptEdCore* self = (LLScriptEdCore*) userdata; if( !self->mEditor->tryToRevertToPristineState() ) { - gViewerWindow->alertXml("ScriptCannotUndo", - LLScriptEdCore::handleReloadFromServerDialog, self); + LLNotifications::instance().add("ScriptCannotUndo", LLSD(), LLSD(), boost::bind(&LLScriptEdCore::handleReloadFromServerDialog, self, _1, _2)); } } @@ -965,17 +966,16 @@ void LLScriptEdCore::onErrorList(LLUICtrl*, void* user_data) } } -// static -void LLScriptEdCore::handleReloadFromServerDialog( S32 option, void* userdata ) +bool LLScriptEdCore::handleReloadFromServerDialog(const LLSD& notification, const LLSD& response ) { - LLScriptEdCore* self = (LLScriptEdCore*) userdata; + S32 option = LLNotification::getSelectedOption(notification, response); switch( option ) { case 0: // "Yes" - if( self->mLoadCallback ) + if( mLoadCallback ) { - self->mEditor->setText( self->getString("loading") ); - self->mLoadCallback( self->mUserdata ); + mEditor->setText( getString("loading") ); + mLoadCallback( mUserdata ); } break; @@ -986,6 +986,7 @@ void LLScriptEdCore::handleReloadFromServerDialog( S32 option, void* userdata ) llassert(0); break; } + return false; } void LLScriptEdCore::selectFirstError() @@ -1444,9 +1445,9 @@ void LLPreviewLSL::onSaveComplete(const LLUUID& asset_uuid, void* user_data, S32 else { llwarns << "Problem saving script: " << status << llendl; - LLStringUtil::format_map_t args; - args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); - gViewerWindow->alertXml("SaveScriptFailReason", args); + LLSD args; + args["REASON"] = std::string(LLAssetStorage::getErrorString(status)); + LLNotifications::instance().add("SaveScriptFailReason", args); } delete info; } @@ -1482,9 +1483,9 @@ void LLPreviewLSL::onSaveBytecodeComplete(const LLUUID& asset_uuid, void* user_d else { llwarns << "Problem saving LSL Bytecode (Preview)" << llendl; - LLStringUtil::format_map_t args; - args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); - gViewerWindow->alertXml("SaveBytecodeFailReason", args); + LLSD args; + args["REASON"] = std::string(LLAssetStorage::getErrorString(status)); + LLNotifications::instance().add("SaveBytecodeFailReason", args); } delete instance_uuid; } @@ -1530,15 +1531,15 @@ void LLPreviewLSL::onLoadComplete( LLVFS *vfs, const LLUUID& asset_uuid, LLAsset if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status || LL_ERR_FILE_EMPTY == status) { - LLNotifyBox::showXml("ScriptMissing"); + LLNotifications::instance().add("ScriptMissing"); } else if (LL_ERR_INSUFFICIENT_PERMISSIONS == status) { - LLNotifyBox::showXml("ScriptNoPermissions"); + LLNotifications::instance().add("ScriptNoPermissions"); } else { - LLNotifyBox::showXml("UnableToLoadScript"); + LLNotifications::instance().add("UnableToLoadScript"); } preview->mAssetStatus = PREVIEW_ASSET_ERROR; @@ -1846,15 +1847,15 @@ void LLLiveLSLEditor::onLoadComplete(LLVFS *vfs, const LLUUID& asset_id, if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status || LL_ERR_FILE_EMPTY == status) { - LLNotifyBox::showXml("ScriptMissing"); + LLNotifications::instance().add("ScriptMissing"); } else if (LL_ERR_INSUFFICIENT_PERMISSIONS == status) { - LLNotifyBox::showXml("ScriptNoPermissions"); + LLNotifications::instance().add("ScriptNoPermissions"); } else { - LLNotifyBox::showXml("UnableToLoadScript"); + LLNotifications::instance().add("UnableToLoadScript"); } instance->mAssetStatus = PREVIEW_ASSET_ERROR; } @@ -1941,7 +1942,7 @@ void LLLiveLSLEditor::onRunningCheckboxClicked( LLUICtrl*, void* userdata ) else { runningCheckbox->set(!running); - gViewerWindow->alertXml("CouldNotStartStopScript"); + LLNotifications::instance().add("CouldNotStartStopScript"); } } @@ -1964,7 +1965,7 @@ void LLLiveLSLEditor::onReset(void *userdata) } else { - gViewerWindow->alertXml("CouldNotStartStopScript"); + LLNotifications::instance().add("CouldNotStartStopScript"); } } @@ -2058,7 +2059,7 @@ void LLLiveLSLEditor::saveIfNeeded() LLViewerObject* object = gObjectList.findObject(mObjectID); if(!object) { - gViewerWindow->alertXml("SaveScriptFailObjectNotFound"); + LLNotifications::instance().add("SaveScriptFailObjectNotFound"); return; } @@ -2066,7 +2067,7 @@ void LLLiveLSLEditor::saveIfNeeded() { // $NOTE: While the error message may not be exactly correct, // it's pretty close. - gViewerWindow->alertXml("SaveScriptFailObjectNotFound"); + LLNotifications::instance().add("SaveScriptFailObjectNotFound"); return; } @@ -2268,9 +2269,9 @@ void LLLiveLSLEditor::onSaveTextComplete(const LLUUID& asset_uuid, void* user_da if (status) { llwarns << "Unable to save text for a script." << llendl; - LLStringUtil::format_map_t args; - args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); - gViewerWindow->alertXml("CompileQueueSaveText", args); + LLSD args; + args["REASON"] = std::string(LLAssetStorage::getErrorString(status)); + LLNotifications::instance().add("CompileQueueSaveText", args); } else { @@ -2329,9 +2330,9 @@ void LLLiveLSLEditor::onSaveBytecodeComplete(const LLUUID& asset_uuid, void* use llinfos << "Problem saving LSL Bytecode (Live Editor)" << llendl; llwarns << "Unable to save a compiled script." << llendl; - LLStringUtil::format_map_t args; - args["[REASON]"] = std::string(LLAssetStorage::getErrorString(status)); - gViewerWindow->alertXml("CompileQueueSaveBytecode", args); + LLSD args; + args["REASON"] = std::string(LLAssetStorage::getErrorString(status)); + LLNotifications::instance().add("CompileQueueSaveBytecode", args); } std::string filepath = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,asset_uuid.asString()); diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index c0af06f480..c84d5e6d8f 100644 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -80,10 +80,10 @@ public: BOOL canClose(); - static void handleSaveChangesDialog(S32 option, void* userdata); - static void handleReloadFromServerDialog(S32 option, void* userdata); + bool handleSaveChangesDialog(const LLSD& notification, const LLSD& response); + bool handleReloadFromServerDialog(const LLSD& notification, const LLSD& response); - static void onHelpWebDialog(S32 option, void* userdata); + static bool onHelpWebDialog(const LLSD& notification, const LLSD& response); static void onBtnHelp(void* userdata); static void onBtnDynamicHelp(void* userdata); static void onCheckLock(LLUICtrl*, void*); diff --git a/indra/newview/llpreviewtexture.cpp b/indra/newview/llpreviewtexture.cpp index 79b8313352..fefa6d40d7 100644 --- a/indra/newview/llpreviewtexture.cpp +++ b/indra/newview/llpreviewtexture.cpp @@ -349,15 +349,15 @@ void LLPreviewTexture::onFileLoadedForSave(BOOL success, LLPointer<LLImageTGA> image_tga = new LLImageTGA; if( !image_tga->encode( src ) ) { - LLStringUtil::format_map_t args; - args["[FILE]"] = self->mSaveFileName; - gViewerWindow->alertXml("CannotEncodeFile", args); + LLSD args; + args["FILE"] = self->mSaveFileName; + LLNotifications::instance().add("CannotEncodeFile", args); } else if( !image_tga->save( self->mSaveFileName ) ) { - LLStringUtil::format_map_t args; - args["[FILE]"] = self->mSaveFileName; - gViewerWindow->alertXml("CannotWriteFile", args); + LLSD args; + args["FILE"] = self->mSaveFileName; + LLNotifications::instance().add("CannotWriteFile", args); } else { @@ -370,7 +370,7 @@ void LLPreviewTexture::onFileLoadedForSave(BOOL success, if( self && !success ) { - gViewerWindow->alertXml("CannotDownloadFile"); + LLNotifications::instance().add("CannotDownloadFile"); } } diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 81decdf40a..ae4be6173b 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -2695,7 +2695,8 @@ void LLSelectMgr::selectDelete() return; } - LLObjectSelectionHandle* selection_handlep = new LLObjectSelectionHandle(getSelection()); + LLNotification::Params params("ConfirmObjectDeleteLock"); + params.functor(boost::bind(&LLSelectMgr::confirmDelete, _1, _2, getSelection())); if(locked_but_deleteable_object || no_copy_but_deleteable_object || @@ -2711,72 +2712,55 @@ void LLSelectMgr::selectDelete() if(locked_but_deleteable_object && !no_copy_but_deleteable_object && all_owned_by_you) { //Locked only - gViewerWindow->alertXml( "ConfirmObjectDeleteLock", - &LLSelectMgr::confirmDelete, - selection_handlep); + params.name("ConfirmObjectDeleteLock"); } else if(!locked_but_deleteable_object && no_copy_but_deleteable_object && all_owned_by_you) { //No Copy only - gViewerWindow->alertXml( "ConfirmObjectDeleteNoCopy", - &LLSelectMgr::confirmDelete, - selection_handlep); + params.name("ConfirmObjectDeleteNoCopy"); } else if(!locked_but_deleteable_object && !no_copy_but_deleteable_object && !all_owned_by_you) { //not owned only - gViewerWindow->alertXml( "ConfirmObjectDeleteNoOwn", - &LLSelectMgr::confirmDelete, - selection_handlep); + params.name("ConfirmObjectDeleteNoOwn"); } else if(locked_but_deleteable_object && no_copy_but_deleteable_object && all_owned_by_you) { //locked and no copy - gViewerWindow->alertXml( "ConfirmObjectDeleteLockNoCopy", - &LLSelectMgr::confirmDelete, - selection_handlep); + params.name("ConfirmObjectDeleteLockNoCopy"); } else if(locked_but_deleteable_object && !no_copy_but_deleteable_object && !all_owned_by_you) { //locked and not owned - gViewerWindow->alertXml( "ConfirmObjectDeleteLockNoOwn", - &LLSelectMgr::confirmDelete, - selection_handlep); + params.name("ConfirmObjectDeleteLockNoOwn"); } else if(!locked_but_deleteable_object && no_copy_but_deleteable_object && !all_owned_by_you) { //no copy and not owned - gViewerWindow->alertXml( "ConfirmObjectDeleteNoCopyNoOwn", - &LLSelectMgr::confirmDelete, - selection_handlep); + params.name("ConfirmObjectDeleteNoCopyNoOwn"); } else { //locked, no copy and not owned - gViewerWindow->alertXml( "ConfirmObjectDeleteLockNoCopyNoOwn", - &LLSelectMgr::confirmDelete, - selection_handlep); + params.name("ConfirmObjectDeleteLockNoCopyNoOwn"); } - - + LLNotifications::instance().add(params); } else { - confirmDelete(0, (void*)selection_handlep); + LLNotifications::instance().forceResponse(params, 0); } } // static -void LLSelectMgr::confirmDelete(S32 option, void* data) +bool LLSelectMgr::confirmDelete(const LLSD& notification, const LLSD& response, LLObjectSelectionHandle handle) { - LLObjectSelectionHandle handle = *(LLObjectSelectionHandle*)data; - delete (LLObjectSelectionHandle*)data; - + S32 option = LLNotification::getSelectedOption(notification, response); if (!handle->getObjectCount()) { llwarns << "Nothing to delete!" << llendl; - return; + return false; } switch(option) @@ -2815,6 +2799,7 @@ void LLSelectMgr::confirmDelete(S32 option, void* data) default: break; } + return false; } diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h index f210fdb9d3..27bcb5a582 100644 --- a/indra/newview/llselectmgr.h +++ b/indra/newview/llselectmgr.h @@ -683,7 +683,7 @@ private: static void packHingeHead(void *user_data); static void packPermissionsHead(void* user_data); static void packGodlikeHead(void* user_data); - static void confirmDelete(S32 option, void* data); + static bool confirmDelete(const LLSD& notification, const LLSD& response, LLObjectSelectionHandle handle); private: LLPointer<LLViewerImage> mSilhouetteImagep; diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 9a6454be33..1dc1ddd451 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -235,18 +235,17 @@ std::string load_password_from_disk(); void save_password_to_disk(const char* hashed_password); bool is_hex_string(U8* str, S32 len); void show_first_run_dialog(); -void first_run_dialog_callback(S32 option, void* userdata); +bool first_run_dialog_callback(const LLSD& notification, const LLSD& response); void set_startup_status(const F32 frac, const std::string& string, const std::string& msg); -void login_alert_status(S32 option, void* user_data); +bool login_alert_status(const LLSD& notification, const LLSD& response); void update_app(BOOL mandatory, const std::string& message); -void update_dialog_callback(S32 option, void *userdata); +bool update_dialog_callback(const LLSD& notification, const LLSD& response); void login_packet_failed(void**, S32 result); void use_circuit_callback(void**, S32 result); void register_viewer_callbacks(LLMessageSystem* msg); void init_stat_view(); void asset_callback_nothing(LLVFS*, const LLUUID&, LLAssetType::EType, void*, S32); -void dialog_choose_gender_first_start(); -void callback_choose_gender(S32 option, void* userdata); +bool callback_choose_gender(const LLSD& notification, const LLSD& response); void init_start_screen(S32 location_id); void release_start_screen(); void reset_login(); @@ -387,16 +386,16 @@ bool idle_startup() if (LLFeatureManager::getInstance()->isSafe()) { - gViewerWindow->alertXml("DisplaySetToSafe"); + LLNotifications::instance().add("DisplaySetToSafe"); } else if ((gSavedSettings.getS32("LastFeatureVersion") < LLFeatureManager::getInstance()->getVersion()) && (gSavedSettings.getS32("LastFeatureVersion") != 0)) { - gViewerWindow->alertXml("DisplaySetToRecommended"); + LLNotifications::instance().add("DisplaySetToRecommended"); } else if (!gViewerWindow->getInitAlert().empty()) { - gViewerWindow->alertXml(gViewerWindow->getInitAlert()); + LLNotifications::instance().add(gViewerWindow->getInitAlert()); } gSavedSettings.setS32("LastFeatureVersion", LLFeatureManager::getInstance()->getVersion()); @@ -419,10 +418,11 @@ bool idle_startup() } if (!xml_ok) { - // *TODO:translate (maybe - very unlikely error message) - // Note: alerts.xml may be invalid - if this gets translated it will need to be in the code - std::string bad_xui_msg = "An error occured while updating Second Life. Please download the latest version from www.secondlife.com."; - LLAppViewer::instance()->earlyExit(bad_xui_msg); + // If XML is bad, there's a good possibility that notifications.xml is ALSO bad. + // If that's so, then we'll get a fatal error on attempting to load it, + // which will display a nontranslatable error message that says so. + // Otherwise, we'll display a reasonable error message that IS translatable. + LLAppViewer::instance()->earlyExit("BadInstallation"); } // // Statistics stuff @@ -440,9 +440,9 @@ bool idle_startup() if (ll_init_ares() == NULL || !gAres->isInitialized()) { - LL_WARNS("AppInit") << "Could not start address resolution system" << LL_ENDL; - std::string msg = LLTrans::getString("LoginFailedNoNetwork"); - LLAppViewer::instance()->earlyExit(msg); + std::string diagnostic = "Could not start address resolution system"; + LL_WARNS("AppInit") << diagnostic << LL_ENDL; + LLAppViewer::instance()->earlyExit("LoginFailedNoNetwork", LLSD().insert("DIAGNOSTIC", diagnostic)); } // @@ -500,9 +500,9 @@ bool idle_startup() circuit_heartbeat_interval, circuit_timeout)) { - std::string msg = LLTrans::getString("LoginFailedNoNetwork"); - msg.append(llformat(" Error: %d", gMessageSystem->getErrorCode())); - LLAppViewer::instance()->earlyExit(msg); + std::string diagnostic = llformat(" Error: %d", gMessageSystem->getErrorCode()); + LL_WARNS("AppInit") << diagnostic << LL_ENDL; + LLAppViewer::instance()->earlyExit("LoginFailedNoNetwork", LLSD().insert("DIAGNOSTIC", diagnostic)); } #if LL_WINDOWS @@ -525,7 +525,7 @@ bool idle_startup() } else { - LLAppViewer::instance()->earlyExit("Message Template " + message_template_path + " not found."); + LLAppViewer::instance()->earlyExit("MessageTemplateNotFound", LLSD().insert("PATH", message_template_path)); } if(gMessageSystem && gMessageSystem->isOK()) @@ -1551,9 +1551,9 @@ bool idle_startup() exit(0); } // Bounce back to the login screen. - LLStringUtil::format_map_t args; - args["[ERROR_MESSAGE]"] = emsg.str(); - gViewerWindow->alertXml("ErrorMessage", args, login_alert_done); + LLSD args; + args["ERROR_MESSAGE"] = emsg.str(); + LLNotifications::instance().add("ErrorMessage", args, LLSD(), login_alert_done); reset_login(); gSavedSettings.setBOOL("AutoLogin", FALSE); show_connect_box = true; @@ -1571,9 +1571,9 @@ bool idle_startup() exit(0); } // Bounce back to the login screen. - LLStringUtil::format_map_t args; - args["[ERROR_MESSAGE]"] = emsg.str(); - gViewerWindow->alertXml("ErrorMessage", args, login_alert_done); + LLSD args; + args["ERROR_MESSAGE"] = emsg.str(); + LLNotifications::instance().add("ErrorMessage", args, LLSD(), login_alert_done); reset_login(); gSavedSettings.setBOOL("AutoLogin", FALSE); show_connect_box = true; @@ -2300,23 +2300,23 @@ bool idle_startup() // location is not your expected location. So, if this is // your first login, then you do not have an expectation, // thus, do not show this alert. - LLStringUtil::format_map_t args; + LLSD args; if (url_ok) { - args["[TYPE]"] = "desired"; - args["[HELP]"] = ""; + args["TYPE"] = "desired"; + args["HELP"] = ""; } else if (gSavedSettings.getBOOL("LoginLastLocation")) { - args["[TYPE]"] = "last"; - args["[HELP]"] = ""; + args["TYPE"] = "last"; + args["HELP"] = ""; } else { - args["[TYPE]"] = "home"; - args["[HELP]"] = "You may want to set a new home location."; + args["TYPE"] = "home"; + args["HELP"] = "You may want to set a new home location."; } - gViewerWindow->alertXml("AvatarMoved", args); + LLNotifications::instance().add("AvatarMoved", args); } else { @@ -2411,16 +2411,15 @@ bool idle_startup() // initial outfit, but if the load hasn't started // already then something is wrong so fall back // to generic outfits. JC - gViewerWindow->alertXml("WelcomeChooseSex", - callback_choose_gender, NULL); + LLNotifications::instance().add("WelcomeChooseSex", LLSD(), LLSD(), + callback_choose_gender); LLStartUp::setStartupState( STATE_CLEANUP ); return TRUE; } if (wearables_time > MAX_WEARABLES_TIME) { - // It's taken too long to load, show the world - gViewerWindow->alertXml("ClothingLoading"); + LLNotifications::instance().add("ClothingLoading"); LLViewerStats::getInstance()->incStat(LLViewerStats::ST_WEARABLES_TOO_LONG); LLStartUp::setStartupState( STATE_CLEANUP ); return TRUE; @@ -2440,7 +2439,7 @@ bool idle_startup() else { // OK to just get the wearables - if ( gAgent.getWearablesLoaded() ) + if ( gAgent.areWearablesLoaded() ) { // We have our clothing, proceed. //llinfos << "wearables loaded" << llendl; @@ -2722,11 +2721,12 @@ bool is_hex_string(U8* str, S32 len) void show_first_run_dialog() { - gViewerWindow->alertXml("FirstRun", first_run_dialog_callback, NULL); + LLNotifications::instance().add("FirstRun", LLSD(), LLSD(), first_run_dialog_callback); } -void first_run_dialog_callback(S32 option, void* userdata) +bool first_run_dialog_callback(const LLSD& notification, const LLSD& response) { + S32 option = LLNotification::getSelectedOption(notification, response); if (0 == option) { LL_DEBUGS("AppInit") << "First run dialog cancelling" << LL_ENDL; @@ -2734,6 +2734,7 @@ void first_run_dialog_callback(S32 option, void* userdata) } LLPanelLogin::giveFocus(); + return false; } @@ -2746,8 +2747,9 @@ void set_startup_status(const F32 frac, const std::string& string, const std::st gViewerWindow->setProgressMessage(msg); } -void login_alert_status(S32 option, void* user_data) +bool login_alert_status(const LLSD& notification, const LLSD& response) { + S32 option = LLNotification::getSelectedOption(notification, response); // Buttons switch( option ) { @@ -2766,6 +2768,7 @@ void login_alert_status(S32 option, void* user_data) } LLPanelLogin::giveFocus(); + return false; } void update_app(BOOL mandatory, const std::string& auth_msg) @@ -2781,67 +2784,66 @@ void update_app(BOOL mandatory, const std::string& auth_msg) { msg = "(" + auth_msg + ") \n"; } - LLStringUtil::format_map_t args; - args["[MESSAGE]"] = msg; - - // represent a bool as a null/non-null pointer - void *mandatoryp = mandatory ? &mandatory : NULL; + LLSD args; + args["MESSAGE"] = msg; + + LLSD payload; + payload["mandatory"] = mandatory; + +/* + We're constructing one of the following 6 strings here: + "DownloadWindowsMandatory" + "DownloadWindowsReleaseForDownload" + "DownloadWindows" + "DownloadMacMandatory" + "DownloadMacReleaseForDownload" + "DownloadMac" + + I've called them out explicitly in this comment so that they can be grepped for. + + Also, we assume that if we're not Windows we're Mac. If we ever intend to support + Linux with autoupdate, this should be an explicit #elif LL_DARWIN, but + we'd rather deliver the wrong message than no message, so until Linux is supported + we'll leave it alone. + */ + std::string notification_name = "Download"; + #if LL_WINDOWS - if (mandatory) - { - gViewerWindow->alertXml("DownloadWindowsMandatory", args, - update_dialog_callback, - mandatoryp); - } - else - { -#if LL_RELEASE_FOR_DOWNLOAD - gViewerWindow->alertXml("DownloadWindowsReleaseForDownload", args, - update_dialog_callback, - mandatoryp); + notification_name += "Windows"; #else - gViewerWindow->alertXml("DownloadWindows", args, - update_dialog_callback, - mandatoryp); + notification_name += "Mac"; #endif - } -#else + if (mandatory) { - gViewerWindow->alertXml("DownloadMacMandatory", args, - update_dialog_callback, - mandatoryp); + notification_name += "Mandatory"; } else { #if LL_RELEASE_FOR_DOWNLOAD - gViewerWindow->alertXml("DownloadMacReleaseForDownload", args, - update_dialog_callback, - mandatoryp); -#else - gViewerWindow->alertXml("DownloadMac", args, - update_dialog_callback, - mandatoryp); + notification_name += "ReleaseForDownload"; #endif } -#endif - + + LLNotifications::instance().add(notification_name, args, payload, update_dialog_callback); + } - -void update_dialog_callback(S32 option, void *userdata) +bool update_dialog_callback(const LLSD& notification, const LLSD& response) { - bool mandatory = userdata != NULL; + S32 option = LLNotification::getSelectedOption(notification, response); + std::string update_exe_path; + bool mandatory = notification["payload"]["mandatory"].asBoolean(); #if !LL_RELEASE_FOR_DOWNLOAD if (option == 2) { LLStartUp::setStartupState( STATE_LOGIN_AUTH_INIT ); - return; + return false; } #endif - + if (option == 1) { // ...user doesn't want to do it @@ -2855,7 +2857,7 @@ void update_dialog_callback(S32 option, void *userdata) { LLStartUp::setStartupState( STATE_LOGIN_AUTH_INIT ); } - return; + return false; } LLSD query_map = LLSD::emptyMap(); @@ -2890,7 +2892,7 @@ void update_dialog_callback(S32 option, void *userdata) // We're hosed, bail LL_WARNS("AppInit") << "LLDir::getTempFilename() failed" << LL_ENDL; LLAppViewer::instance()->forceQuit(); - return; + return false; } LLAppViewer::sUpdaterInfo->mUpdateExePath += ".exe"; @@ -2911,7 +2913,7 @@ void update_dialog_callback(S32 option, void *userdata) LL_WARNS("AppInit") << "Unable to copy the updater!" << LL_ENDL; LLAppViewer::instance()->forceQuit(); - return; + return false; } // if a sim name was passed in via command line parameter (typically through a SLURL) @@ -2955,6 +2957,7 @@ void update_dialog_callback(S32 option, void *userdata) LLStringUtil::null, OSMB_OK); #endif LLAppViewer::instance()->forceQuit(); + return false; } void use_circuit_callback(void**, S32 result) @@ -2968,8 +2971,7 @@ void use_circuit_callback(void**, S32 result) { // Make sure user knows something bad happened. JC LL_WARNS("AppInit") << "Backing up to login screen!" << LL_ENDL; - gViewerWindow->alertXml("LoginPacketNeverReceived", - login_alert_status, NULL); + LLNotifications::instance().add("LoginPacketNeverReceived", LLSD(), LLSD(), login_alert_status); reset_login(); } else @@ -3753,8 +3755,9 @@ const S32 OPT_CLOSED_WINDOW = -1; const S32 OPT_MALE = 0; const S32 OPT_FEMALE = 1; -void callback_choose_gender(S32 option, void* userdata) -{ +bool callback_choose_gender(const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotification::getSelectedOption(notification, response); switch(option) { case OPT_MALE: @@ -3767,6 +3770,7 @@ void callback_choose_gender(S32 option, void* userdata) LLStartUp::loadInitialOutfit( FEMALE_OUTFIT_FOLDER, "female" ); break; } + return false; } void LLStartUp::loadInitialOutfit( const std::string& outfit_folder_name, @@ -3809,8 +3813,8 @@ void LLStartUp::loadInitialOutfit( const std::string& outfit_folder_name, // This is really misnamed -- it means we have started loading // an outfit/shape that will give the avatar a gender eventually. JC gAgent.setGenderChosen(TRUE); + } - // Loads a bitmap to display during load // location_id = 0 => last position @@ -3990,9 +3994,10 @@ bool LLStartUp::dispatchURL() return false; } -void login_alert_done(S32 option, void* user_data) +bool login_alert_done(const LLSD& notification, const LLSD& response) { LLPanelLogin::giveFocus(); + return false; } diff --git a/indra/newview/llstartup.h b/indra/newview/llstartup.h index 1639ed55b6..f89642aa2a 100644 --- a/indra/newview/llstartup.h +++ b/indra/newview/llstartup.h @@ -38,7 +38,7 @@ bool idle_startup(); std::string load_password_from_disk(); void release_start_screen(); -void login_alert_done(S32 option, void* user_data); +bool login_alert_done(const LLSD& notification, const LLSD& response); // constants, variables, & enumerations extern std::string SCREEN_HOME_FILENAME; diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp index 278f7ea9d1..8b274a045b 100644 --- a/indra/newview/llstatusbar.cpp +++ b/indra/newview/llstatusbar.cpp @@ -767,7 +767,7 @@ static void onClickBuyCurrency(void* data) static void onClickHealth(void* ) { - LLNotifyBox::showXml("NotSafe"); + LLNotifications::instance().add("NotSafe"); } static void onClickScriptDebug(void*) @@ -777,22 +777,22 @@ static void onClickScriptDebug(void*) static void onClickFly(void* ) { - LLNotifyBox::showXml("NoFly"); + LLNotifications::instance().add("NoFly"); } static void onClickPush(void* ) { - LLNotifyBox::showXml("PushRestricted"); + LLNotifications::instance().add("PushRestricted"); } static void onClickVoice(void* ) { - LLNotifyBox::showXml("NoVoice"); + LLNotifications::instance().add("NoVoice"); } static void onClickBuild(void*) { - LLNotifyBox::showXml("NoBuild"); + LLNotifications::instance().add("NoBuild"); } static void onClickScripts(void*) @@ -800,15 +800,15 @@ static void onClickScripts(void*) LLViewerRegion* region = gAgent.getRegion(); if(region && region->getRegionFlags() & REGION_FLAGS_ESTATE_SKIP_SCRIPTS) { - LLNotifyBox::showXml("ScriptsStopped"); + LLNotifications::instance().add("ScriptsStopped"); } else if(region && region->getRegionFlags() & REGION_FLAGS_SKIP_SCRIPTS) { - LLNotifyBox::showXml("ScriptsNotRunning"); + LLNotifications::instance().add("ScriptsNotRunning"); } else { - LLNotifyBox::showXml("NoOutsideScripts"); + LLNotifications::instance().add("NoOutsideScripts"); } } diff --git a/indra/newview/lltoolbar.cpp b/indra/newview/lltoolbar.cpp index d7db0f85d9..b9235a489a 100644 --- a/indra/newview/lltoolbar.cpp +++ b/indra/newview/lltoolbar.cpp @@ -307,7 +307,10 @@ void LLToolBar::refresh() } gSavedSettings.setBOOL("BuildBtnState", build_mode); - updateCommunicateList(); + if (isInVisibleChain()) + { + updateCommunicateList(); + } } void LLToolBar::updateCommunicateList() @@ -444,7 +447,7 @@ void LLToolBar::onClickChat(void* user_data) // static void LLToolBar::onClickAppearance(void*) { - if (gAgent.getWearablesLoaded()) + if (gAgent.areWearablesLoaded()) { gAgent.changeCameraToCustomizeAvatar(); } diff --git a/indra/newview/lltoolbrush.cpp b/indra/newview/lltoolbrush.cpp index 6bdd4e7767..92233c0d9f 100644 --- a/indra/newview/lltoolbrush.cpp +++ b/indra/newview/lltoolbrush.cpp @@ -648,9 +648,9 @@ void LLToolBrushLand::alertNoTerraform(LLViewerRegion* regionp) { if (!regionp) return; - LLStringUtil::format_map_t args; - args["[REGION]"] = regionp->getName(); - gViewerWindow->alertXml("RegionNoTerraforming", args); + LLSD args; + args["REGION"] = regionp->getName(); + LLNotifications::instance().add("RegionNoTerraforming", args); } diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index 25b58e1409..7459a23bef 100644 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -1052,9 +1052,9 @@ BOOL LLToolDragAndDrop::handleDropTextureProtections(LLViewerObject* hit_obj, if (hit_obj->isInventoryDirty()) { hit_obj->fetchInventoryFromServer(); - LLStringUtil::format_map_t args; - args["[ERROR_MESSAGE]"] = "Unable to add texture.\nPlease wait a few seconds and try again."; - gViewerWindow->alertXml("ErrorMessage", args); + LLSD args; + args["ERROR_MESSAGE"] = "Unable to add texture.\nPlease wait a few seconds and try again."; + LLNotifications::instance().add("ErrorMessage", args); return FALSE; } if (hit_obj->getInventoryItemByAsset(item->getAssetUUID())) @@ -1505,45 +1505,42 @@ void LLToolDragAndDrop::giveInventory(const LLUUID& to_agent, else { // ask if the agent is sure. - LLGiveInventoryInfo* info = new LLGiveInventoryInfo(to_agent, - item->getUUID(), - im_session_id); - - gViewerWindow->alertXml("CannotCopyWarning", - &LLToolDragAndDrop::handleCopyProtectedItem, - (void*)info); + LLSD payload; + payload["agent_id"] = to_agent; + payload["item_id"] = item->getUUID(); + LLNotifications::instance().add("CannotCopyWarning", LLSD(), payload, + &LLToolDragAndDrop::handleCopyProtectedItem); } } - // static -void LLToolDragAndDrop::handleCopyProtectedItem(S32 option, void* data) +bool LLToolDragAndDrop::handleCopyProtectedItem(const LLSD& notification, const LLSD& response) { - LLGiveInventoryInfo* info = (LLGiveInventoryInfo*)data; + S32 option = LLNotification::getSelectedOption(notification, response); LLInventoryItem* item = NULL; switch(option) { case 0: // "Yes" - item = gInventory.getItem(info->mInventoryObjectID); + item = gInventory.getItem(notification["payload"]["item_id"].asUUID()); if(item) { - LLToolDragAndDrop::commitGiveInventoryItem(info->mToAgentID, - item, - info->mIMSessionID); + LLToolDragAndDrop::commitGiveInventoryItem(notification["payload"]["agent_id"].asUUID(), + item); // delete it for now - it will be deleted on the server // quickly enough. - gInventory.deleteObject(info->mInventoryObjectID); + gInventory.deleteObject(notification["payload"]["item_id"].asUUID()); gInventory.notifyObservers(); } else { - gViewerWindow->alertXml("CannotGiveItem"); + LLNotifications::instance().add("CannotGiveItem"); } break; default: // no, cancel, whatever, who cares, not yes. - gViewerWindow->alertXml("TransactionCancelled"); + LLNotifications::instance().add("TransactionCancelled"); break; } + return false; } // static @@ -1592,7 +1589,7 @@ void LLToolDragAndDrop::commitGiveInventoryItem(const LLUUID& to_agent, // If this item was given by drag-and-drop into an IM panel, log this action in the IM panel chat. if (im_session_id != LLUUID::null) { - LLStringUtil::format_map_t args; + LLSD args; gIMMgr->addSystemMessage(im_session_id, "inventory_item_offered", args); } @@ -1632,18 +1629,18 @@ void LLToolDragAndDrop::giveInventoryCategory(const LLUUID& to_agent, } if(!complete) { - LLNotifyBox::showXml("IncompleteInventory"); + LLNotifications::instance().add("IncompleteInventory"); return; } count = items.count() + cats.count(); if(count > MAX_ITEMS) { - gViewerWindow->alertXml("TooManyItems"); + LLNotifications::instance().add("TooManyItems"); return; } else if(count == 0) { - gViewerWindow->alertXml("NoItems"); + LLNotifications::instance().add("NoItems"); return; } else @@ -1656,29 +1653,29 @@ void LLToolDragAndDrop::giveInventoryCategory(const LLUUID& to_agent, { LLGiveInventoryInfo* info = NULL; info = new LLGiveInventoryInfo(to_agent, cat->getUUID()); - LLStringUtil::format_map_t args; - args["[COUNT]"] = llformat("%d",giveable.countNoCopy()); - gViewerWindow->alertXml("CannotCopyCountItems", args, - &LLToolDragAndDrop::handleCopyProtectedCategory, - (void*)info); - + LLSD args; + args["COUNT"] = llformat("%d",giveable.countNoCopy()); + LLSD payload; + payload["agent_id"] = to_agent; + payload["folder_id"] = cat->getUUID(); + LLNotifications::instance().add("CannotCopyCountItems", args, payload, &LLToolDragAndDrop::handleCopyProtectedCategory); } } } // static -void LLToolDragAndDrop::handleCopyProtectedCategory(S32 option, void* data) +bool LLToolDragAndDrop::handleCopyProtectedCategory(const LLSD& notification, const LLSD& response) { - LLGiveInventoryInfo* info = (LLGiveInventoryInfo*)data; + S32 option = LLNotification::getSelectedOption(notification, response); LLInventoryCategory* cat = NULL; switch(option) { case 0: // "Yes" - cat = gInventory.getCategory(info->mInventoryObjectID); + cat = gInventory.getCategory(notification["payload"]["folder_id"].asUUID()); if(cat) { - LLToolDragAndDrop::commitGiveInventoryCategory(info->mToAgentID, + LLToolDragAndDrop::commitGiveInventoryCategory(notification["payload"]["agent_id"].asUUID(), cat); LLViewerInventoryCategory::cat_array_t cats; LLViewerInventoryItem::item_array_t items; @@ -1697,14 +1694,15 @@ void LLToolDragAndDrop::handleCopyProtectedCategory(S32 option, void* data) } else { - gViewerWindow->alertXml("CannotGiveCategory"); + LLNotifications::instance().add("CannotGiveCategory"); } break; default: // no, cancel, whatever, who cares, not yes. - gViewerWindow->alertXml("TransactionCancelled"); + LLNotifications::instance().add("TransactionCancelled"); break; } + return false; } // static @@ -1731,12 +1729,12 @@ void LLToolDragAndDrop::commitGiveInventoryCategory(const LLUUID& to_agent, S32 count = items.count() + cats.count(); if(count > MAX_ITEMS) { - gViewerWindow->alertXml("TooManyItems"); + LLNotifications::instance().add("TooManyItems"); return; } else if(count == 0) { - gViewerWindow->alertXml("NoItems"); + LLNotifications::instance().add("NoItems"); return; } else @@ -2299,7 +2297,7 @@ EAcceptance LLToolDragAndDrop::dad3dWearItem( // destroy clothing items. if (!gAgent.areWearablesLoaded()) { - gViewerWindow->alertXml("CanNotChangeAppearanceUntilLoaded"); + LLNotifications::instance().add("CanNotChangeAppearanceUntilLoaded"); return ACCEPT_NO; } @@ -2394,7 +2392,7 @@ EAcceptance LLToolDragAndDrop::dad3dWearCategory( // destroy clothing items. if (!gAgent.areWearablesLoaded()) { - gViewerWindow->alertXml("CanNotChangeAppearanceUntilLoaded"); + LLNotifications::instance().add("CanNotChangeAppearanceUntilLoaded"); return ACCEPT_NO; } } diff --git a/indra/newview/lltooldraganddrop.h b/indra/newview/lltooldraganddrop.h index 627ef86c38..462e57b390 100644 --- a/indra/newview/lltooldraganddrop.h +++ b/indra/newview/lltooldraganddrop.h @@ -209,13 +209,13 @@ protected: // give inventory item functionality - static void handleCopyProtectedItem(S32 option, void* data); + static bool handleCopyProtectedItem(const LLSD& notification, const LLSD& response); static void commitGiveInventoryItem(const LLUUID& to_agent, LLInventoryItem* item, const LLUUID &im_session_id = LLUUID::null); // give inventory category functionality - static void handleCopyProtectedCategory(S32 option, void* data); + static bool handleCopyProtectedCategory(const LLSD& notification, const LLSD& response); static void commitGiveInventoryCategory(const LLUUID& to_agent, LLInventoryCategory* cat); public: diff --git a/indra/newview/llurldispatcher.cpp b/indra/newview/llurldispatcher.cpp index 477146a473..3f6227ee56 100644 --- a/indra/newview/llurldispatcher.cpp +++ b/indra/newview/llurldispatcher.cpp @@ -43,7 +43,6 @@ #include "llpanellogin.h" #include "llstartup.h" // gStartupState #include "llurlsimstring.h" -#include "llviewerwindow.h" // alertXml() #include "llweb.h" #include "llworldmap.h" @@ -147,8 +146,8 @@ bool LLURLDispatcherImpl::dispatchCore(const std::string& url, /* // Inform the user we can't handle this std::map<std::string, std::string> args; - args["[SLURL]"] = url; - gViewerWindow->alertXml("BadURL", args); + args["SLURL"] = url; + r; */ return false; diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index c28ed7c435..e52b3a9b83 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -403,7 +403,7 @@ void LLViewerInventoryCategory::updateServer(BOOL is_new) const // communicate that change with the server. if(LLAssetType::AT_NONE != mPreferredType) { - LLNotifyBox::showXml("CannotModifyProtectedCategories"); + LLNotifications::instance().add("CannotModifyProtectedCategories"); return; } @@ -427,7 +427,7 @@ void LLViewerInventoryCategory::removeFromServer( void ) // communicate that change with the server. if(LLAssetType::AT_NONE != mPreferredType) { - LLNotifyBox::showXml("CannotRemoveProtectedCategories"); + LLNotifications::instance().add("CannotRemoveProtectedCategories"); return; } diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index c8ad7fad97..5131b77a7c 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -1,3 +1,4 @@ + /** * @file llviewermenu.cpp * @brief Builds menus out of items. @@ -309,7 +310,7 @@ BOOL is_selection_buy_not_take(); S32 selection_price(); BOOL enable_take(); void handle_take(); -void confirm_take(S32 option, void* data); +bool confirm_take(const LLSD& notification, const LLSD& response); BOOL enable_buy(void*); void handle_buy(void *); void handle_buy_object(LLSaleInfo sale_info); @@ -999,6 +1000,7 @@ void init_debug_world_menu(LLMenuGL* menu) void handle_export_menus_to_xml(void*) { + LLFilePicker& picker = LLFilePicker::instance(); if(!picker.getSaveFile(LLFilePicker::FFSAVE_XML)) { @@ -2122,9 +2124,10 @@ class LLGoToObject : public view_listener_t //--------------------------------------------------------------------------- // Parcel freeze, eject, etc. //--------------------------------------------------------------------------- -void callback_freeze(S32 option, void* data) +bool callback_freeze(const LLSD& notification, const LLSD& response) { - LLUUID* avatar_id = (LLUUID*) data; + LLUUID avatar_id = notification["payload"]["avatar_id"].asUUID(); + S32 option = LLNotification::getSelectedOption(notification, response); if (0 == option || 1 == option) { @@ -2136,7 +2139,7 @@ void callback_freeze(S32 option, void* data) } LLMessageSystem* msg = gMessageSystem; - LLViewerObject* avatar = gObjectList.findObject(*avatar_id); + LLViewerObject* avatar = gObjectList.findObject(avatar_id); if (avatar) { @@ -2145,16 +2148,15 @@ void callback_freeze(S32 option, void* data) msg->addUUID("AgentID", gAgent.getID()); msg->addUUID("SessionID", gAgent.getSessionID()); msg->nextBlock("Data"); - msg->addUUID("TargetID", *avatar_id ); + msg->addUUID("TargetID", avatar_id ); msg->addU32("Flags", flags ); msg->sendReliable( avatar->getRegion()->getHost() ); } } - - delete avatar_id; - avatar_id = NULL; + return false; } + class LLAvatarFreeze : public view_listener_t { bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) @@ -2162,23 +2164,25 @@ class LLAvatarFreeze : public view_listener_t LLVOAvatar* avatar = find_avatar_from_object( LLSelectMgr::getInstance()->getSelection()->getPrimaryObject() ); if( avatar ) { - LLUUID* avatar_id = new LLUUID( avatar->getID() ); std::string fullname = avatar->getFullname(); + LLSD payload; + payload["avatar_id"] = avatar->getID(); if (!fullname.empty()) { - LLStringUtil::format_map_t args; - args["[AVATAR_NAME]"] = fullname; - gViewerWindow->alertXml("FreezeAvatarFullname", + LLSD args; + args["AVATAR_NAME"] = fullname; + LLNotifications::instance().add("FreezeAvatarFullname", args, - callback_freeze, - (void*)avatar_id); + payload, + callback_freeze); } else { - gViewerWindow->alertXml("FreezeAvatar", - callback_freeze, - (void*)avatar_id); + LLNotifications::instance().add("FreezeAvatar", + LLSD(), + payload, + callback_freeze); } } return true; @@ -2224,26 +2228,16 @@ class LLAvatarDebug : public view_listener_t } }; -struct MenuCallbackData +bool callback_eject(const LLSD& notification, const LLSD& response) { - bool ban_enabled; - LLUUID avatar_id; -}; - -void callback_eject(S32 option, void* data) -{ - MenuCallbackData *callback_data = (MenuCallbackData*)data; - if (!callback_data) - { - return; - } + S32 option = LLNotification::getSelectedOption(notification, response); if (2 == option) { - // Cancle button. - return; + // Cancel button. + return false; } - LLUUID avatar_id = callback_data->avatar_id; - bool ban_enabled = callback_data->ban_enabled; + LLUUID avatar_id = notification["payload"]["avatar_id"].asUUID(); + bool ban_enabled = notification["payload"]["ban_enabled"].asBoolean(); if (0 == option) { @@ -2285,10 +2279,7 @@ void callback_eject(S32 option, void* data) msg->sendReliable( avatar->getRegion()->getHost() ); } } - - - delete callback_data; - callback_data = NULL; + return false; } class LLAvatarEject : public view_listener_t @@ -2298,8 +2289,8 @@ class LLAvatarEject : public view_listener_t LLVOAvatar* avatar = find_avatar_from_object( LLSelectMgr::getInstance()->getSelection()->getPrimaryObject() ); if( avatar ) { - MenuCallbackData *data = new MenuCallbackData; - (*data).avatar_id = avatar->getID(); + LLSD payload; + payload["avatar_id"] = avatar->getID(); std::string fullname = avatar->getFullname(); const LLVector3d& pos = avatar->getPositionGlobal(); @@ -2307,40 +2298,42 @@ class LLAvatarEject : public view_listener_t if (LLViewerParcelMgr::getInstance()->isParcelOwnedByAgent(parcel,GP_LAND_MANAGE_BANNED)) { - (*data).ban_enabled = true; + payload["ban_enabled"] = true; if (!fullname.empty()) { - LLStringUtil::format_map_t args; - args["[AVATAR_NAME]"] = fullname; - gViewerWindow->alertXml("EjectAvatarFullname", - args, - callback_eject, - (void*)data); + LLSD args; + args["AVATAR_NAME"] = fullname; + LLNotifications::instance().add("EjectAvatarFullname", + args, + payload, + callback_eject); } else { - gViewerWindow->alertXml("EjectAvatar", - callback_eject, - (void*)data); + LLNotifications::instance().add("EjectAvatarFullname", + LLSD(), + payload, + callback_eject); } } else { - (*data).ban_enabled = false; + payload["ban_enabled"] = false; if (!fullname.empty()) { - LLStringUtil::format_map_t args; - args["[AVATAR_NAME]"] = fullname; - gViewerWindow->alertXml("EjectAvatarFullnameNoBan", - args, - callback_eject, - (void*)data); + LLSD args; + args["AVATAR_NAME"] = fullname; + LLNotifications::instance().add("EjectAvatarFullnameNoBan", + args, + payload, + callback_eject); } else { - gViewerWindow->alertXml("EjectAvatarNoBan", - callback_eject, - (void*)data); + LLNotifications::instance().add("EjectAvatarNoBan", + LLSD(), + payload, + callback_eject); } } } @@ -2387,13 +2380,16 @@ class LLAvatarGiveCard : public view_listener_t if(dest && dest->isAvatar()) { bool found_name = false; - LLStringUtil::format_map_t args; + LLSD args; + LLSD old_args; LLNameValue* nvfirst = dest->getNVPair("FirstName"); LLNameValue* nvlast = dest->getNVPair("LastName"); if(nvfirst && nvlast) { - args["[FIRST]"] = nvfirst->getString(); - args["[LAST]"] = nvlast->getString(); + args["FIRST"] = nvfirst->getString(); + args["LAST"] = nvlast->getString(); + old_args["FIRST"] = nvfirst->getString(); + old_args["LAST"] = nvlast->getString(); found_name = true; } LLViewerRegion* region = dest->getRegion(); @@ -2415,11 +2411,11 @@ class LLAvatarGiveCard : public view_listener_t transaction_id.generate(); msg->addUUIDFast(_PREHASH_TransactionID, transaction_id); msg->sendReliable(dest_host); - LLNotifyBox::showXml("OfferedCard", args); + LLNotifications::instance().add("OfferedCard", args); } else { - gViewerWindow->alertXml("CantOfferCallingCard", args); + LLNotifications::instance().add("CantOfferCallingCard", old_args); } } return true; @@ -2436,8 +2432,9 @@ void login_done(S32 which, void *user) } -void callback_leave_group(S32 option, void *userdata) +bool callback_leave_group(const LLSD& notification, const LLSD& response) { + S32 option = LLNotification::getSelectedOption(notification, response); if (option == 0) { LLMessageSystem *msg = gMessageSystem; @@ -2450,15 +2447,16 @@ void callback_leave_group(S32 option, void *userdata) msg->addUUIDFast(_PREHASH_GroupID, gAgent.mGroupID ); gAgent.sendReliableMessage(); } + return false; } void handle_leave_group(void *) { if (gAgent.getGroupID() != LLUUID::null) { - LLStringUtil::format_map_t args; - args["[GROUP]"] = gAgent.mGroupName; - gViewerWindow->alertXml("GroupLeaveConfirmMember", args, callback_leave_group); + LLSD args; + args["GROUP"] = gAgent.mGroupName; + LLNotifications::instance().add("GroupLeaveConfirmMember", args, LLSD(), callback_leave_group); } } @@ -2521,7 +2519,7 @@ void handle_buy_object(LLSaleInfo sale_info) { if(!LLSelectMgr::getInstance()->selectGetAllRootsValid()) { - LLNotifyBox::showXml("UnableToBuyWhileDownloading"); + LLNotifications::instance().add("UnableToBuyWhileDownloading"); return; } @@ -2530,7 +2528,7 @@ void handle_buy_object(LLSaleInfo sale_info) BOOL owners_identical = LLSelectMgr::getInstance()->selectGetOwner(owner_id, owner_name); if (!owners_identical) { - LLNotifyBox::showXml("CannotBuyObjectsFromDifferentOwners"); + LLNotifications::instance().add("CannotBuyObjectsFromDifferentOwners"); return; } @@ -2540,7 +2538,7 @@ void handle_buy_object(LLSaleInfo sale_info) valid &= LLSelectMgr::getInstance()->selectGetAggregatePermissions(ag_perm); if(!valid || !sale_info.isForSale() || !perm.allowTransferTo(gAgent.getID())) { - LLNotifyBox::showXml("ObjectNotForSale"); + LLNotifications::instance().add("ObjectNotForSale"); return; } @@ -2686,22 +2684,22 @@ void set_god_level(U8 god_level) // inventory in items may change in god mode gObjectList.dirtyAllObjectInventory(); - if(gViewerWindow) - { - gViewerWindow->setMenuBackgroundColor(god_level > GOD_NOT, + if(gViewerWindow) + { + gViewerWindow->setMenuBackgroundColor(god_level > GOD_NOT, LLViewerLogin::getInstance()->isInProductionGrid()); - } - - LLStringUtil::format_map_t args; + } + + LLSD args; if(god_level > GOD_NOT) { - args["[LEVEL]"] = llformat("%d",(S32)god_level); - LLNotifyBox::showXml("EnteringGodMode", args); + args["LEVEL"] = llformat("%d",(S32)god_level); + LLNotifications::instance().add("EnteringGodMode", args); } else { - args["[LEVEL]"] = llformat("%d",(S32)old_god_level); - LLNotifyBox::showXml("LeavingGodMode", args); + args["LEVEL"] = llformat("%d",(S32)old_god_level); + LLNotifications::instance().add("LeavingGodMode", args); } @@ -2826,13 +2824,13 @@ void request_friendship(const LLUUID& dest_id) if(dest && dest->isAvatar()) { std::string fullname; - LLStringUtil::format_map_t args; + LLSD args; LLNameValue* nvfirst = dest->getNVPair("FirstName"); LLNameValue* nvlast = dest->getNVPair("LastName"); if(nvfirst && nvlast) { - args["[FIRST]"] = nvfirst->getString(); - args["[LAST]"] = nvlast->getString(); + args["FIRST"] = nvfirst->getString(); + args["LAST"] = nvlast->getString(); fullname = nvfirst->getString(); fullname += " "; fullname += nvlast->getString(); @@ -2843,7 +2841,7 @@ void request_friendship(const LLUUID& dest_id) } else { - gViewerWindow->alertXml("CantOfferFriendship"); + LLNotifications::instance().add("CantOfferFriendship"); } } } @@ -2853,12 +2851,8 @@ class LLEditEnableCustomizeAvatar : public view_listener_t { bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) { - LLVOAvatar* avatar = gAgent.getAvatarObject(); - - bool enabled = ((avatar && avatar->isFullyLoaded()) && - (gAgent.getWearablesLoaded())); - - gMenuHolder->findControl(userdata["control"].asString())->setValue(enabled); + bool new_value = gAgent.areWearablesLoaded(); + gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value); return true; } }; @@ -3184,7 +3178,7 @@ void disabled_duplicate(void*) { if (LLSelectMgr::getInstance()->getSelection()->getPrimaryObject()) { - LLNotifyBox::showXml("CopyFailed"); + LLNotifications::instance().add("CopyFailed"); } } @@ -3317,7 +3311,7 @@ void handle_claim_public_land(void*) { if (LLViewerParcelMgr::getInstance()->getSelectionRegion() != gAgent.getRegion()) { - LLNotifyBox::showXml("ClaimPublicLand"); + LLNotifications::instance().add("ClaimPublicLand"); return; } @@ -3550,7 +3544,7 @@ void derez_objects(EDeRezDestination dest, const LLUUID& dest_id) } else if(!error.empty()) { - gViewerWindow->alertXml(error); + LLNotifications::instance().add(error); } } @@ -3577,16 +3571,13 @@ class LLObjectReturn : public view_listener_t mObjectSelection = LLSelectMgr::getInstance()->getEditSelection(); - gViewerWindow->alertXml("ReturnToOwner", - onReturnToOwner, - (void*)this); + LLNotifications::instance().add("ReturnToOwner", LLSD(), LLSD(), boost::bind(&LLObjectReturn::onReturnToOwner, this, _1, _2)); return true; } - static void onReturnToOwner(S32 option, void* data) + bool onReturnToOwner(const LLSD& notification, const LLSD& response) { - LLObjectReturn* object_return = (LLObjectReturn*)data; - + S32 option = LLNotification::getSelectedOption(notification, response); if (0 == option) { // Ignore category ID for this derez destination. @@ -3594,7 +3585,8 @@ class LLObjectReturn : public view_listener_t } // drop reference to current selection - object_return->mObjectSelection = NULL; + mObjectSelection = NULL; + return false; } protected: @@ -3731,48 +3723,46 @@ void handle_take() { category_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_OBJECT); } - LLUUID* cat_id = new LLUUID(category_id); + LLSD payload; + payload["folder_id"] = category_id; + + LLNotification::Params params("ConfirmObjectTakeLock"); + params.payload(payload) + .functor(confirm_take); + if(locked_but_takeable_object || !you_own_everything) { if(locked_but_takeable_object && you_own_everything) { - gViewerWindow->alertXml("ConfirmObjectTakeLock", - confirm_take, - (void*)cat_id); + params.name("ConfirmObjectTakeLock"); } else if(!locked_but_takeable_object && !you_own_everything) { - gViewerWindow->alertXml("ConfirmObjectTakeNoOwn", - confirm_take, - (void*)cat_id); + params.name("ConfirmObjectTakeNoOwn"); } else { - gViewerWindow->alertXml("ConfirmObjectTakeLockNoOwn", - confirm_take, - (void*)cat_id); + params.name("ConfirmObjectTakeLockNoOwn"); } - - + + LLNotifications::instance().add(params); } - else { - confirm_take(0, (void*)cat_id); + LLNotifications::instance().forceResponse(params, 0); } } -void confirm_take(S32 option, void* data) +bool confirm_take(const LLSD& notification, const LLSD& response) { - LLUUID* cat_id = (LLUUID*)data; - if(!cat_id) return; + S32 option = LLNotification::getSelectedOption(notification, response); if(enable_take() && (option == 0)) { - derez_objects(DRD_TAKE_INTO_AGENT_INVENTORY, *cat_id); + derez_objects(DRD_TAKE_INTO_AGENT_INVENTORY, notification["payload"]["folder_id"].asUUID()); } - delete cat_id; + return false; } // You can take an item when it is public and transferrable, or when @@ -3934,13 +3924,15 @@ S32 selection_price() return total_price; } -void callback_show_buy_currency(S32 option, void*) +bool callback_show_buy_currency(const LLSD& notification, const LLSD& response) { + S32 option = LLNotification::getSelectedOption(notification, response); if (0 == option) { llinfos << "Loading page " << BUY_CURRENCY_URL << llendl; LLWeb::loadURL(BUY_CURRENCY_URL); } + return false; } @@ -3955,14 +3947,13 @@ void show_buy_currency(const char* extra) } mesg << "Go to " << BUY_CURRENCY_URL << "\nfor information on purchasing currency?"; - LLStringUtil::format_map_t args; + LLSD args; if (extra != NULL) { - args["[EXTRA]"] = extra; + args["EXTRA"] = extra; } - args["[URL]"] = BUY_CURRENCY_URL; - gViewerWindow->alertXml("PromptGoToCurrencyPage", args, - callback_show_buy_currency); + args["URL"] = BUY_CURRENCY_URL; + LLNotifications::instance().add("PromptGoToCurrencyPage", args, LLSD(), callback_show_buy_currency); } void handle_buy_currency(void*) @@ -4142,29 +4133,29 @@ class LLToolsLink : public view_listener_t { if(!LLSelectMgr::getInstance()->selectGetAllRootsValid()) { - LLNotifyBox::showXml("UnableToLinkWhileDownloading"); + LLNotifications::instance().add("UnableToLinkWhileDownloading"); return true; } S32 object_count = LLSelectMgr::getInstance()->getSelection()->getObjectCount(); if (object_count > MAX_CHILDREN_PER_TASK + 1) { - LLStringUtil::format_map_t args; - args["[COUNT]"] = llformat("%d", object_count); + LLSD args; + args["COUNT"] = llformat("%d", object_count); int max = MAX_CHILDREN_PER_TASK+1; - args["[MAX]"] = llformat("%d", max); - gViewerWindow->alertXml("UnableToLinkObjects", args); + args["MAX"] = llformat("%d", max); + LLNotifications::instance().add("UnableToLinkObjects", args); return true; } if(LLSelectMgr::getInstance()->getSelection()->getRootObjectCount() < 2) { - gViewerWindow->alertXml("CannotLinkIncompleteSet"); + LLNotifications::instance().add("CannotLinkIncompleteSet"); return true; } if(!LLSelectMgr::getInstance()->selectGetRootsModify()) { - gViewerWindow->alertXml("CannotLinkModify"); + LLNotifications::instance().add("CannotLinkModify"); return true; } LLUUID owner_id; @@ -4174,7 +4165,7 @@ class LLToolsLink : public view_listener_t // we don't actually care if you're the owner, but novices are // the most likely to be stumped by this one, so offer the // easiest and most likely solution. - gViewerWindow->alertXml("CannotLinkDifferentOwners"); + LLNotifications::instance().add("CannotLinkDifferentOwners"); return true; } LLSelectMgr::getInstance()->sendLink(); @@ -4738,7 +4729,7 @@ class LLWorldSetBusy : public view_listener_t else { gAgent.setBusy(); - gViewerWindow->alertXml("BusyModeSet"); + LLNotifications::instance().add("BusyModeSet"); } return true; } @@ -4764,7 +4755,7 @@ class LLWorldCreateLandmark : public view_listener_t if (!agent_parcel->getAllowLandmark() && !LLViewerParcelMgr::isParcelOwnedByAgent(agent_parcel, GP_LAND_ALLOW_LANDMARK)) { - gViewerWindow->alertXml("CannotCreateLandmarkNotOwner"); + LLNotifications::instance().add("CannotCreateLandmarkNotOwner"); return true; } @@ -4871,16 +4862,14 @@ class LLAvatarAddFriend : public view_listener_t } }; -void complete_give_money(S32 option, void* user_data) +bool complete_give_money(const LLSD& notification, const LLSD& response, LLObjectSelectionHandle handle) { + S32 option = LLNotification::getSelectedOption(notification, response); if (option == 0) { gAgent.clearBusy(); } - LLObjectSelectionHandle handle(*(LLObjectSelectionHandle*)user_data); - delete (LLObjectSelectionHandle*)user_data; - LLViewerObject* objectp = handle->getPrimaryObject(); // Show avatar's name if paying attachment @@ -4906,19 +4895,22 @@ void complete_give_money(S32 option, void* user_data) LLFloaterPay::payViaObject(&give_money, objectp->getID()); } } + return false; } bool handle_give_money_dialog() { - LLObjectSelectionHandle* handlep = new LLObjectSelectionHandle(LLSelectMgr::getInstance()->getSelection()); + LLNotification::Params params("BusyModePay"); + params.functor(boost::bind(complete_give_money, _1, _2, LLSelectMgr::getInstance()->getSelection())); + if (gAgent.getBusy()) { // warn users of being in busy mode during a transaction - gViewerWindow->alertXml("BusyModePay", complete_give_money, handlep); + LLNotifications::instance().add(params); } else { - complete_give_money(1, handlep); + LLNotifications::instance().forceResponse(params, 1); } return true; } @@ -5069,7 +5061,7 @@ class LLShowFloater : public view_listener_t } else if (floater_name == "appearance") { - if (gAgent.getWearablesLoaded()) + if (gAgent.areWearablesLoaded()) { gAgent.changeCameraToCustomizeAvatar(); } @@ -5272,14 +5264,14 @@ class LLFloaterVisible : public view_listener_t } }; -void callback_show_url(S32 option, void* data) +bool callback_show_url(const LLSD& notification, const LLSD& response) { - std::string* urlp = (std::string*)data; + S32 option = LLNotification::getSelectedOption(notification, response); if (0 == option) { - LLWeb::loadURL(*urlp); + LLWeb::loadURL(notification["payload"]["url"].asString()); } - delete urlp; + return false; } class LLPromptShowURL : public view_listener_t @@ -5292,15 +5284,16 @@ class LLPromptShowURL : public view_listener_t { std::string alert = param.substr(0, offset); std::string url = param.substr(offset+1); - std::string* url_copy = new std::string(url); if(gSavedSettings.getBOOL("UseExternalBrowser")) { - gViewerWindow->alertXml(alert, callback_show_url, url_copy); + LLSD payload; + payload["url"] = url; + LLNotifications::instance().add(alert, LLSD(), payload, callback_show_url); } else { - callback_show_url(0, url_copy); + LLWeb::loadURL(url); } } else @@ -5311,6 +5304,39 @@ class LLPromptShowURL : public view_listener_t } }; +bool callback_show_file(const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotification::getSelectedOption(notification, response); + if (0 == option) + { + LLWeb::loadURL(notification["payload"]["url"]); + } + return false; +} + +class LLPromptShowFile : public view_listener_t +{ + bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) + { + std::string param = userdata.asString(); + std::string::size_type offset = param.find(","); + if (offset != param.npos) + { + std::string alert = param.substr(0, offset); + std::string file = param.substr(offset+1); + + LLSD payload; + payload["url"] = file; + LLNotifications::instance().add(alert, LLSD(), payload, callback_show_file); + } + else + { + llinfos << "PromptShowFile invalid parameters! Expecting \"ALERT,FILE\"." << llendl; + } + return true; + } +}; + class LLShowAgentProfile : public view_listener_t { bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) @@ -5940,11 +5966,11 @@ void queue_actions(LLFloaterScriptQueue* q, const std::string& noscriptmsg, cons { if ( !func.scripted ) { - gViewerWindow->alertXml(noscriptmsg); + LLNotifications::instance().add(noscriptmsg); } else if ( !func.modifiable ) { - gViewerWindow->alertXml(nomodmsg); + LLNotifications::instance().add(nomodmsg); } else { @@ -6933,7 +6959,7 @@ void handle_save_to_xml(void*) LLFloater* frontmost = gFloaterView->getFrontmost(); if (!frontmost) { - gViewerWindow->alertXml("NoFrontmostFloater"); + LLNotifications::instance().add("NoFrontmostFloater"); return; } diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 33c21b4061..5f42aff526 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -178,9 +178,9 @@ const std::string upload_pick(void* data) std::string short_name = gDirUtilp->getBaseFileName(filename); // No extension - LLStringUtil::format_map_t args; - args["[FILE]"] = short_name; - gViewerWindow->alertXml("NoFileExtension", args); + LLSD args; + args["FILE"] = short_name; + LLNotifications::instance().add("NoFileExtension", args); return std::string(); } else @@ -220,11 +220,11 @@ const std::string upload_pick(void* data) { //should only get here if the extension exists //but is invalid - LLStringUtil::format_map_t args; - args["[EXTENSION]"] = ext; - args["[VALIDS]"] = valid_extensions; - gViewerWindow->alertXml("InvalidFileExtension", args); - return std::string(); + LLSD args; + args["EXTENSION"] = ext; + args["VALIDS"] = valid_extensions; + LLNotifications::instance().add("InvalidFileExtension", args); + return NULL; } }//end else (non-null extension) @@ -239,9 +239,9 @@ const std::string upload_pick(void* data) if (check_for_invalid_wav_formats(filename,error_msg)) { llinfos << error_msg << ": " << filename << llendl; - LLStringUtil::format_map_t args; - args["[FILE]"] = filename; - gViewerWindow->alertXml( error_msg, args ); + LLSD args; + args["FILE"] = filename; + LLNotifications::instance().add( error_msg, args ); return std::string(); } }//end if a wave/sound file @@ -337,10 +337,10 @@ class LLFileUploadBulk : public view_listener_t } }; -void upload_error(const std::string& error_message, const std::string& label, const std::string& filename, const LLStringUtil::format_map_t args) +void upload_error(const std::string& error_message, const std::string& label, const std::string& filename, const LLSD& args) { llwarns << error_message << llendl; - gViewerWindow->alertXml(label, args); + LLNotifications::instance().add(label, args); if(LLFile::remove(filename) == -1) { lldebugs << "unable to remove temp file" << llendl; @@ -531,10 +531,9 @@ void upload_new_resource(const std::string& src_filename, std::string name, LLTransactionID tid; LLAssetID uuid; - LLStringUtil::format_map_t args; + LLSD args; std::string exten = gDirUtilp->getExtension(src_filename); - LLAssetType::EType asset_type = LLAssetType::AT_NONE; std::string error_message; @@ -548,7 +547,7 @@ void upload_new_resource(const std::string& src_filename, std::string name, error_message = llformat( "No file extension for the file: '%s'\nPlease make sure the file has a correct file extension", short_name.c_str()); - args["[FILE]"] = short_name; + args["FILE"] = short_name; upload_error(error_message, "NofileExtension", filename, args); return; } @@ -560,9 +559,9 @@ void upload_new_resource(const std::string& src_filename, std::string name, IMG_CODEC_BMP )) { error_message = llformat( "Problem with file %s:\n\n%s\n", - src_filename.c_str(), LLImage::getLastError().c_str()); - args["[FILE]"] = src_filename; - args["[ERROR]"] = LLImage::getLastError(); + src_filename.c_str(), LLImage::getLastError().c_str()); + args["FILE"] = src_filename; + args["ERROR"] = LLImage::getLastError(); upload_error(error_message, "ProblemWithFile", filename, args); return; } @@ -576,8 +575,8 @@ void upload_new_resource(const std::string& src_filename, std::string name, { error_message = llformat("Problem with file %s:\n\n%s\n", src_filename.c_str(), LLImage::getLastError().c_str()); - args["[FILE]"] = src_filename; - args["[ERROR]"] = LLImage::getLastError(); + args["FILE"] = src_filename; + args["ERROR"] = LLImage::getLastError(); upload_error(error_message, "ProblemWithFile", filename, args); return; } @@ -591,8 +590,8 @@ void upload_new_resource(const std::string& src_filename, std::string name, { error_message = llformat("Problem with file %s:\n\n%s\n", src_filename.c_str(), LLImage::getLastError().c_str()); - args["[FILE]"] = src_filename; - args["[ERROR]"] = LLImage::getLastError(); + args["FILE"] = src_filename; + args["ERROR"] = LLImage::getLastError(); upload_error(error_message, "ProblemWithFile", filename, args); return; } @@ -606,8 +605,8 @@ void upload_new_resource(const std::string& src_filename, std::string name, { error_message = llformat("Problem with file %s:\n\n%s\n", src_filename.c_str(), LLImage::getLastError().c_str()); - args["[FILE]"] = src_filename; - args["[ERROR]"] = LLImage::getLastError(); + args["FILE"] = src_filename; + args["ERROR"] = LLImage::getLastError(); upload_error(error_message, "ProblemWithFile", filename, args); return; } @@ -627,13 +626,13 @@ void upload_new_resource(const std::string& src_filename, std::string name, { case LLVORBISENC_DEST_OPEN_ERR: error_message = llformat( "Couldn't open temporary compressed sound file for writing: %s\n", filename.c_str()); - args["[FILE]"] = filename; + args["FILE"] = filename; upload_error(error_message, "CannotOpenTemporarySoundFile", filename, args); break; default: error_message = llformat("Unknown vorbis encode failure on: %s\n", src_filename.c_str()); - args["[FILE]"] = src_filename; + args["FILE"] = src_filename; upload_error(error_message, "UnknownVorbisEncodeFailure", filename, args); break; } @@ -675,7 +674,7 @@ void upload_new_resource(const std::string& src_filename, std::string name, { fclose(in); error_message = llformat("corrupt resource file: %s", src_filename.c_str()); - args["[FILE]"] = src_filename; + args["FILE"] = src_filename; upload_error(error_message, "CorruptResourceFile", filename, args); return; } @@ -703,7 +702,7 @@ void upload_new_resource(const std::string& src_filename, std::string name, { fclose(in); error_message = llformat("unknown linden resource file version in file: %s", src_filename.c_str()); - args["[FILE]"] = src_filename; + args["FILE"] = src_filename; upload_error(error_message, "UnknownResourceFileVersion", filename, args); return; } @@ -745,7 +744,7 @@ void upload_new_resource(const std::string& src_filename, std::string name, { fclose(in); error_message = llformat( "Unable to create output file: %s", filename.c_str()); - args["[FILE]"] = filename; + args["FILE"] = filename; upload_error(error_message, "UnableToCreateOutputFile", filename, args); return; } @@ -815,9 +814,9 @@ void upload_new_resource(const std::string& src_filename, std::string name, else { llwarns << error_message << llendl; - LLStringUtil::format_map_t args; - args["[ERROR_MESSAGE]"] = error_message; - gViewerWindow->alertXml("ErrorMessage", args); + LLSD args; + args["ERROR_MESSAGE"] = error_message; + LLNotifications::instance().add("ErrorMessage", args); if(LLFile::remove(filename) == -1) { lldebugs << "unable to remove temp file" << llendl; @@ -900,10 +899,10 @@ void upload_done_callback(const LLUUID& uuid, void* user_data, S32 result, LLExt } else // if(result >= 0) { - LLStringUtil::format_map_t args; - args["[FILE]"] = LLInventoryType::lookupHumanReadable(data->mInventoryType); - args["[REASON]"] = std::string(LLAssetStorage::getErrorString(result)); - gViewerWindow->alertXml("CannotUploadReason", args); + LLSD args; + args["FILE"] = LLInventoryType::lookupHumanReadable(data->mInventoryType); + args["REASON"] = std::string(LLAssetStorage::getErrorString(result)); + LLNotifications::instance().add("CannotUploadReason", args); } LLUploadDialog::modalUploadFinished(); diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index e38ef27cf1..daab3a7847 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -96,6 +96,7 @@ #include "llmenugl.h" #include "llmutelist.h" #include "llnetmap.h" +#include "llnotifications.h" #include "llnotify.h" #include "llpanelgrouplandmoney.h" #include "llselectmgr.h" @@ -157,7 +158,6 @@ extern BOOL gDebugClicks; // function prototypes void open_offer(const std::vector<LLUUID>& items, const std::string& from_name); -void friendship_offer_callback(S32 option, void* user_data); bool check_offer_throttle(const std::string& from_name, bool check_only); void callbackCacheEstateOwnerName(const LLUUID& id, const std::string& first, const std::string& last, @@ -184,14 +184,66 @@ const std::string SCRIPT_QUESTIONS[SCRIPT_PERMISSION_EOF] = "ControlYourCamera" }; -struct LLFriendshipOffer +const BOOL SCRIPT_QUESTION_IS_CAUTION[SCRIPT_PERMISSION_EOF] = { - LLUUID mFromID; - LLUUID mTransactionID; - BOOL mOnline; - LLHost mHost; + TRUE, // ScriptTakeMoney, + FALSE, // ActOnControlInputs + FALSE, // RemapControlInputs + FALSE, // AnimateYourAvatar + FALSE, // AttachToYourAvatar + FALSE, // ReleaseOwnership, + FALSE, // LinkAndDelink, + FALSE, // AddAndRemoveJoints + FALSE, // ChangePermissions + FALSE, // TrackYourCamera, + FALSE // ControlYourCamera }; +bool friendship_offer_callback(const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotification::getSelectedOption(notification, response); + LLUUID fid; + LLMessageSystem* msg = gMessageSystem; + const LLSD& payload = notification["payload"]; + switch(option) + { + case 0: + // accept + LLAvatarTracker::formFriendship(payload["from_id"]); + + fid = gInventory.findCategoryUUIDForType(LLAssetType::AT_CALLINGCARD); + + // This will also trigger an onlinenotification if the user is online + msg->newMessageFast(_PREHASH_AcceptFriendship); + msg->nextBlockFast(_PREHASH_AgentData); + msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); + msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + msg->nextBlockFast(_PREHASH_TransactionBlock); + msg->addUUIDFast(_PREHASH_TransactionID, payload["session_id"]); + msg->nextBlockFast(_PREHASH_FolderData); + msg->addUUIDFast(_PREHASH_FolderID, fid); + msg->sendReliable(LLHost(payload["sender"].asString())); + break; + case 1: + // decline + msg->newMessageFast(_PREHASH_DeclineFriendship); + msg->nextBlockFast(_PREHASH_AgentData); + msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); + msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + msg->nextBlockFast(_PREHASH_TransactionBlock); + msg->addUUIDFast(_PREHASH_TransactionID, payload["session_id"]); + msg->sendReliable(LLHost(payload["sender"].asString())); + break; + default: + // close button probably, possibly timed out + break; + } + + return false; +} +static LLNotificationFunctorRegistration friendship_offer_callback_reg("OfferFriendship", friendship_offer_callback); +static LLNotificationFunctorRegistration friendship_offer_callback_reg_nm("OfferFriendshipNoMessage", friendship_offer_callback); + //const char BUSY_AUTO_RESPONSE[] = "The Resident you messaged is in 'busy mode' which means they have " // "requested not to be disturbed. Your message will still be shown in their IM " // "panel for later viewing."; @@ -563,34 +615,31 @@ void send_sound_trigger(const LLUUID& sound_id, F32 gain) gAgent.sendMessage(); } -struct LLJoinGroupData -{ - LLUUID mGroupID; - LLUUID mTransactionID; - std::string mName; - std::string mMessage; - S32 mFee; -}; - -void join_group_callback(S32 option, void* user_data) +bool join_group_response(const LLSD& notification, const LLSD& response) { - LLJoinGroupData* data = (LLJoinGroupData*)user_data; + S32 option = LLNotification::getSelectedOption(notification, response); BOOL delete_context_data = TRUE; bool accept_invite = false; - if (option == 2 && data && !data->mGroupID.isNull()) + LLUUID group_id = notification["payload"]["group_id"].asUUID(); + LLUUID transaction_id = notification["payload"]["transaction_id"].asUUID(); + std::string name = notification["payload"]["name"].asString(); + std::string message = notification["payload"]["message"].asString(); + S32 fee = notification["payload"]["fee"].asInteger(); + + if (option == 2 && !group_id.isNull()) { - LLFloaterGroupInfo::showFromUUID(data->mGroupID); - LLStringUtil::format_map_t args; - args["[MESSAGE]"] = data->mMessage; - LLNotifyBox::showXml("JoinGroup", args, &join_group_callback, data); - return; + LLFloaterGroupInfo::showFromUUID(group_id); + LLSD args; + args["MESSAGE"] = message; + LLNotifications::instance().add("JoinGroup", args, notification["payload"]); + return false; } - if(option == 0 && data && !data->mGroupID.isNull()) + if(option == 0 && !group_id.isNull()) { // check for promotion or demotion. S32 max_groups = MAX_AGENT_GROUPS; - if(gAgent.isInGroup(data->mGroupID)) ++max_groups; + if(gAgent.isInGroup(group_id)) ++max_groups; if(gAgent.mGroups.count() < max_groups) { @@ -599,10 +648,10 @@ void join_group_callback(S32 option, void* user_data) else { delete_context_data = FALSE; - LLStringUtil::format_map_t args; - args["[NAME]"] = data->mName; - args["[INVITE]"] = data->mMessage; - LLAlertDialog::showXml("JoinedTooManyGroupsMember", args, join_group_callback, (void*)data); + LLSD args; + args["NAME"] = name; + args["INVITE"] = message; + LLNotifications::instance().add("JoinedTooManyGroupsMember", args, notification["payload"]); } } @@ -610,45 +659,44 @@ void join_group_callback(S32 option, void* user_data) { // If there is a fee to join this group, make // sure the user is sure they want to join. - if (data->mFee > 0) + if (fee > 0) { delete_context_data = FALSE; - LLStringUtil::format_map_t args; - args["[COST]"] = llformat("%d", data->mFee); - // Set the fee to 0, so that we don't keep + LLSD args; + args["COST"] = llformat("%d", fee); + // Set the fee for next time to 0, so that we don't keep // asking about a fee. - data->mFee = 0; - gViewerWindow->alertXml("JoinGroupCanAfford", + LLSD next_payload = notification["payload"]; + next_payload["fee"] = 0; + LLNotifications::instance().add("JoinGroupCanAfford", args, - join_group_callback, - (void*)data); + next_payload); } else { - send_improved_im(data->mGroupID, + send_improved_im(group_id, std::string("name"), std::string("message"), IM_ONLINE, IM_GROUP_INVITATION_ACCEPT, - data->mTransactionID); + transaction_id); } } - else if (data) + else { - send_improved_im(data->mGroupID, + send_improved_im(group_id, std::string("name"), std::string("message"), IM_ONLINE, IM_GROUP_INVITATION_DECLINE, - data->mTransactionID); + transaction_id); } - if(delete_context_data) - { - delete data; - data = NULL; - } + return false; } +static LLNotificationFunctorRegistration jgr_1("JoinGroup", join_group_response); +static LLNotificationFunctorRegistration jgr_2("JoinedTooManyGroupsMember", join_group_response); +static LLNotificationFunctorRegistration jgr_3("JoinGroupCanAfford", join_group_response); //----------------------------------------------------------------------------- @@ -930,9 +978,15 @@ void inventory_offer_mute_callback(const LLUUID& blocked_id, { public: OfferMatcher(const LLUUID& to_block) : blocked_id(to_block) {} - BOOL matches(LLNotifyBox::notify_callback_t callback, void* cb_data) const + BOOL matches(const LLNotificationPtr notification) const { - return callback == inventory_offer_callback && ((LLOfferInfo*)cb_data)->mFromID == blocked_id; + if(notification->getName() == "ObjectGiveItem" + || notification->getName() == "ObjectGiveItemUnknownUser" + || notification->getName() == "UserGiveItem") + { + return (notification->getPayload()["from_id"].asUUID() == blocked_id); + } + return FALSE; } private: const LLUUID& blocked_id; @@ -940,12 +994,43 @@ void inventory_offer_mute_callback(const LLUUID& blocked_id, gNotifyBoxView->purgeMessagesMatching(OfferMatcher(blocked_id)); } -void inventory_offer_callback(S32 button, void* user_data) +LLOfferInfo::LLOfferInfo(const LLSD& sd) +{ + mIM = (EInstantMessage)sd["im_type"].asInteger(); + mFromID = sd["from_id"].asUUID(); + mFromGroup = sd["from_group"].asBoolean(); + mFromObject = sd["from_object"].asBoolean(); + mTransactionID = sd["transaction_id"].asUUID(); + mFolderID = sd["folder_id"].asUUID(); + mObjectID = sd["object_id"].asUUID(); + mType = LLAssetType::lookup(sd["type"].asString().c_str()); + mFromName = sd["from_name"].asString(); + mDesc = sd["description"].asString(); + mHost = LLHost(sd["sender"].asString()); +} + +LLSD LLOfferInfo::asLLSD() +{ + LLSD sd; + sd["im_type"] = mIM; + sd["from_id"] = mFromID; + sd["from_group"] = mFromGroup; + sd["from_object"] = mFromObject; + sd["transaction_id"] = mTransactionID; + sd["folder_id"] = mFolderID; + sd["object_id"] = mObjectID; + sd["type"] = LLAssetType::lookup(mType); + sd["from_name"] = mFromName; + sd["description"] = mDesc; + sd["sender"] = mHost.getIPandPort(); + return sd; +} + +bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD& response) { LLChat chat; std::string log_message; - LLOfferInfo* info = (LLOfferInfo*)user_data; - if(!info) return; + S32 button = LLNotification::getSelectedOption(notification, response); // For muting, we need to add the mute, then decline the offer. // This must be done here because: @@ -954,7 +1039,7 @@ void inventory_offer_callback(S32 button, void* user_data) // * we can't build two messages at once. JC if (2 == button) { - gCacheName->get(info->mFromID, info->mFromGroup, inventory_offer_mute_callback, user_data); + gCacheName->get(mFromID, mFromGroup, inventory_offer_mute_callback, this); } LLMessageSystem* msg = gMessageSystem; @@ -964,9 +1049,9 @@ void inventory_offer_callback(S32 button, void* user_data) msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->nextBlockFast(_PREHASH_MessageBlock); msg->addBOOLFast(_PREHASH_FromGroup, FALSE); - msg->addUUIDFast(_PREHASH_ToAgentID, info->mFromID); + msg->addUUIDFast(_PREHASH_ToAgentID, mFromID); msg->addU8Fast(_PREHASH_Offline, IM_ONLINE); - msg->addUUIDFast(_PREHASH_ID, info->mTransactionID); + msg->addUUIDFast(_PREHASH_ID, mTransactionID); msg->addU32Fast(_PREHASH_Timestamp, NO_TIMESTAMP); // no timestamp necessary std::string name; gAgent.buildFullname(name); @@ -977,50 +1062,50 @@ void inventory_offer_callback(S32 button, void* user_data) msg->addVector3Fast(_PREHASH_Position, gAgent.getPositionAgent()); LLInventoryObserver* opener = NULL; LLViewerInventoryCategory* catp = NULL; - catp = (LLViewerInventoryCategory*)gInventory.getCategory(info->mObjectID); + catp = (LLViewerInventoryCategory*)gInventory.getCategory(mObjectID); LLViewerInventoryItem* itemp = NULL; if(!catp) { - itemp = (LLViewerInventoryItem*)gInventory.getItem(info->mObjectID); + itemp = (LLViewerInventoryItem*)gInventory.getItem(mObjectID); } // *TODO:translate std::string from_string; // Used in the pop-up. std::string chatHistory_string; // Used in chat history. - if (info->mFromObject == TRUE) + if (mFromObject == TRUE) { - if (info->mFromGroup) + if (mFromGroup) { std::string group_name; - if (gCacheName->getGroupName(info->mFromID, group_name)) + if (gCacheName->getGroupName(mFromID, group_name)) { - from_string = std::string("An object named '") + info->mFromName + "' owned by the group '" + group_name + "'"; - chatHistory_string = info->mFromName + " owned by the group '" + group_name + "'"; + from_string = std::string("An object named '") + mFromName + "' owned by the group '" + group_name + "'"; + chatHistory_string = mFromName + " owned by the group '" + group_name + "'"; } else { - from_string = std::string("An object named '") + info->mFromName + "' owned by an unknown group"; - chatHistory_string = info->mFromName + " owned by an unknown group"; + from_string = std::string("An object named '") + mFromName + "' owned by an unknown group"; + chatHistory_string = mFromName + " owned by an unknown group"; } } else { std::string first_name, last_name; - if (gCacheName->getName(info->mFromID, first_name, last_name)) + if (gCacheName->getName(mFromID, first_name, last_name)) { - from_string = std::string("An object named '") + info->mFromName + "' owned by " + first_name + " " + last_name; - chatHistory_string = info->mFromName + " owned by " + first_name + " " + last_name; + from_string = std::string("An object named '") + mFromName + "' owned by " + first_name + " " + last_name; + chatHistory_string = mFromName + " owned by " + first_name + " " + last_name; } else { - from_string = std::string("An object named '") + info->mFromName + "' owned by an unknown user"; - chatHistory_string = info->mFromName + " owned by an unknown user"; + from_string = std::string("An object named '") + mFromName + "' owned by an unknown user"; + chatHistory_string = mFromName + " owned by an unknown user"; } } } else { - from_string = chatHistory_string = info->mFromName; + from_string = chatHistory_string = mFromName; } bool busy=FALSE; @@ -1033,24 +1118,24 @@ void inventory_offer_callback(S32 button, void* user_data) // group_notice_inventory is 1 greater than the offer integer value. // Generates IM_INVENTORY_ACCEPTED, IM_TASK_INVENTORY_ACCEPTED, // or IM_GROUP_NOTICE_INVENTORY_ACCEPTED - msg->addU8Fast(_PREHASH_Dialog, (U8)(info->mIM + 1)); - msg->addBinaryDataFast(_PREHASH_BinaryBucket, &(info->mFolderID.mData), - sizeof(info->mFolderID.mData)); + msg->addU8Fast(_PREHASH_Dialog, (U8)(mIM + 1)); + msg->addBinaryDataFast(_PREHASH_BinaryBucket, &(mFolderID.mData), + sizeof(mFolderID.mData)); // send the message - msg->sendReliable(info->mHost); + msg->sendReliable(mHost); //don't spam them if they are getting flooded - if (check_offer_throttle(info->mFromName, true)) + if (check_offer_throttle(mFromName, true)) { - log_message = chatHistory_string + " gave you " + info->mDesc + "."; + log_message = chatHistory_string + " gave you " + mDesc + "."; chat.mText = log_message; LLFloaterChat::addChatHistory(chat); } // we will want to open this item when it comes back. - LL_DEBUGS("Messaging") << "Initializing an opener for tid: " << info->mTransactionID + LL_DEBUGS("Messaging") << "Initializing an opener for tid: " << mTransactionID << LL_ENDL; - switch (info->mIM) + switch (mIM) { case IM_INVENTORY_OFFERED: { @@ -1058,7 +1143,7 @@ void inventory_offer_callback(S32 button, void* user_data) // end has already copied the items into your inventory, // so we can fetch it out of our inventory. LLInventoryFetchObserver::item_ref_t items; - items.push_back(info->mObjectID); + items.push_back(mObjectID); LLOpenAgentOffer* open_agent_offer = new LLOpenAgentOffer(from_string); open_agent_offer->fetchItems(items); if(catp || (itemp && itemp->isComplete())) @@ -1084,7 +1169,7 @@ void inventory_offer_callback(S32 button, void* user_data) default: LL_WARNS("Messaging") << "inventory_offer_callback: unknown offer type" << LL_ENDL; break; - } // end switch (info->mIM) + } // end switch (mIM) break; case IOR_BUSY: @@ -1100,14 +1185,14 @@ void inventory_offer_callback(S32 button, void* user_data) // or IM_GROUP_NOTICE_INVENTORY_DECLINED default: // close button probably (or any of the fall-throughs from above) - msg->addU8Fast(_PREHASH_Dialog, (U8)(info->mIM + 2)); + msg->addU8Fast(_PREHASH_Dialog, (U8)(mIM + 2)); msg->addBinaryDataFast(_PREHASH_BinaryBucket, EMPTY_BINARY_BUCKET, EMPTY_BINARY_BUCKET_SIZE); // send the message - msg->sendReliable(info->mHost); + msg->sendReliable(mHost); - log_message = "You decline " + info->mDesc + " from " + info->mFromName + "."; + log_message = "You decline " + mDesc + " from " + mFromName + "."; chat.mText = log_message; - if( LLMuteList::getInstance()->isMuted(info->mFromID ) && ! LLMuteList::getInstance()->isLinden(info->mFromName) ) // muting for SL-42269 + if( LLMuteList::getInstance()->isMuted(mFromID ) && ! LLMuteList::getInstance()->isLinden(mFromName) ) // muting for SL-42269 { chat.mMuted = TRUE; } @@ -1116,13 +1201,13 @@ void inventory_offer_callback(S32 button, void* user_data) // If it's from an agent, we have to fetch the item to throw // it away. If it's from a task or group, just denying the // request will suffice to discard the item. - if(IM_INVENTORY_OFFERED == info->mIM) + if(IM_INVENTORY_OFFERED == mIM) { LLInventoryFetchComboObserver::folder_ref_t folders; LLInventoryFetchComboObserver::item_ref_t items; - items.push_back(info->mObjectID); + items.push_back(mObjectID); LLDiscardAgentOffer* discard_agent_offer; - discard_agent_offer = new LLDiscardAgentOffer(info->mFolderID, info->mObjectID); + discard_agent_offer = new LLDiscardAgentOffer(mFolderID, mObjectID); discard_agent_offer->fetch(folders, items); if(catp || (itemp && itemp->isComplete())) { @@ -1134,9 +1219,9 @@ void inventory_offer_callback(S32 button, void* user_data) } } - if (busy && (!info->mFromGroup && !info->mFromObject)) + if (busy && (!mFromGroup && !mFromObject)) { - busy_message(msg,info->mFromID); + busy_message(msg,mFromID); } break; } @@ -1146,12 +1231,12 @@ void inventory_offer_callback(S32 button, void* user_data) gInventory.addObserver(opener); } - delete info; - info = NULL; - // Allow these to stack up, but once you deal with one, reset the // position. gFloaterView->resetStartingFloaterPosition(); + + delete this; + return false; } @@ -1161,14 +1246,14 @@ void inventory_offer_handler(LLOfferInfo* info, BOOL from_task) //accepting it. SEE SL-39554 if (gAgent.getBusy()) { - inventory_offer_callback(IOR_BUSY, info); + info->forceResponse(IOR_BUSY); return; } //If muted, don't even go through the messaging stuff. Just curtail the offer here. if (LLMuteList::getInstance()->isMuted(info->mFromID, info->mFromName)) { - inventory_offer_callback(IOR_MUTE, info); + info->forceResponse(IOR_MUTE); return; } @@ -1180,7 +1265,7 @@ void inventory_offer_handler(LLOfferInfo* info, BOOL from_task) { // For certain types, just accept the items into the inventory, // and possibly open them on receipt depending upon "ShowNewInventory". - inventory_offer_callback(IOR_ACCEPT, info); + info->forceResponse(IOR_ACCEPT); return; } @@ -1192,23 +1277,25 @@ void inventory_offer_handler(LLOfferInfo* info, BOOL from_task) LLStringUtil::truncate(msg, indx); } - LLStringUtil::format_map_t args; + LLSD args; args["[OBJECTNAME]"] = msg; + LLSD payload; + // must protect against a NULL return from lookupHumanReadable() std::string typestr = ll_safe_string(LLAssetType::lookupHumanReadable(info->mType)); if (!typestr.empty()) { - args["[OBJECTTYPE]"] = typestr; + args["OBJECTTYPE"] = typestr; } else { LL_WARNS("Messaging") << "LLAssetType::lookupHumanReadable() returned NULL - probably bad asset type: " << info->mType << LL_ENDL; - args["[OBJECTTYPE]"] = ""; + args["OBJECTTYPE"] = ""; // This seems safest, rather than propagating bogosity LL_WARNS("Messaging") << "Forcing an inventory-decline for probably-bad asset type." << LL_ENDL; - inventory_offer_callback(IOR_DECLINE, info); + info->forceResponse(IOR_DECLINE); return; } @@ -1220,8 +1307,8 @@ void inventory_offer_handler(LLOfferInfo* info, BOOL from_task) std::string group_name; if (gCacheName->getGroupName(info->mFromID, group_name)) { - args["[FIRST]"] = group_name; - args["[LAST]"] = ""; + args["FIRST"] = group_name; + args["LAST"] = ""; name_found = TRUE; } } @@ -1230,95 +1317,100 @@ void inventory_offer_handler(LLOfferInfo* info, BOOL from_task) std::string first_name, last_name; if (gCacheName->getName(info->mFromID, first_name, last_name)) { - args["[FIRST]"] = first_name; - args["[LAST]"] = last_name; + args["FIRST"] = first_name; + args["LAST"] = last_name; name_found = TRUE; } } + + payload["from_id"] = info->mFromID; + args["OBJECTFROMNAME"] = info->mFromName; + args["NAME"] = info->mFromName; + + LLNotification::Params p("ObjectGiveItem"); + p.substitutions(args).payload(payload).functor(boost::bind(&LLOfferInfo::inventory_offer_callback, info, _1, _2)); + if (from_task) { - args["[OBJECTFROMNAME]"] = info->mFromName; - LLNotifyBox::showXml(name_found ? "ObjectGiveItem" : "ObjectGiveItemUnknownUser", - args, &inventory_offer_callback, (void*)info); + p.name = name_found ? "ObjectGiveItem" : "ObjectGiveItemUnknownUser"; } else { - // *TODO:translate -> [FIRST] [LAST] - args["[NAME]"] = info->mFromName; - LLNotifyBox::showXml("UserGiveItem", args, - &inventory_offer_callback, (void*)info); + p.name = "UserGiveItem"; } + + LLNotifications::instance().add(p); } -void group_vote_callback(S32 option, void *userdata) +bool group_vote_callback(const LLSD& notification, const LLSD& response) { - LLUUID *group_id = (LLUUID *)userdata; - if (!group_id) return; - + LLUUID group_id = notification["payload"]["group_id"].asUUID(); + S32 option = LLNotification::getSelectedOption(notification, response); switch(option) { case 0: // Vote Now // Open up the voting tab - LLFloaterGroupInfo::showFromUUID(*group_id, "voting_tab"); + LLFloaterGroupInfo::showFromUUID(group_id, "voting_tab"); break; default: // Vote Later or // close button break; } - delete group_id; - group_id = NULL; + return false; } +static LLNotificationFunctorRegistration group_vote_callback_reg("GroupVote", group_vote_callback); -struct LLLureInfo +bool lure_callback(const LLSD& notification, const LLSD& response) { - LLLureInfo(const LLUUID& from, const LLUUID& lure_id, BOOL godlike) : - mFromID(from), - mLureID(lure_id), - mGodlike(godlike) - {} - - LLUUID mFromID; - LLUUID mLureID; - BOOL mGodlike; -}; + S32 option = 0; + if (response.isInteger()) + { + option = response.asInteger(); + } + else + { + option = LLNotification::getSelectedOption(notification, response); + } + + LLUUID from_id = notification["payload"]["from_id"].asUUID(); + LLUUID lure_id = notification["payload"]["lure_id"].asUUID(); + BOOL godlike = notification["payload"]["godlike"].asBoolean(); -void lure_callback(S32 option, void* user_data) -{ - LLLureInfo* info = (LLLureInfo*)user_data; - if(!info) return; switch(option) { case 0: { // accept - gAgent.teleportViaLure(info->mLureID, info->mGodlike); + gAgent.teleportViaLure(lure_id, godlike); } break; case 1: default: // decline - send_simple_im(info->mFromID, + send_simple_im(from_id, LLStringUtil::null, IM_LURE_DECLINED, - info->mLureID); + lure_id); break; } - delete info; - info = NULL; + return false; } +static LLNotificationFunctorRegistration lure_callback_reg("TeleportOffered", lure_callback); -void goto_url_callback(S32 option, void* user_data) +bool goto_url_callback(const LLSD& notification, const LLSD& response) { - char* url = (char*)user_data; + std::string url = notification["payload"]["url"].asString(); + S32 option = LLNotification::getSelectedOption(notification, response); if(1 == option) { LLWeb::loadURL(url); } - delete[] url; + return false; } +static LLNotificationFunctorRegistration goto_url_callback_reg("GotoURL", goto_url_callback); void process_improved_im(LLMessageSystem *msg, void **user_data) { @@ -1332,7 +1424,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) U8 offline; U8 d = 0; LLUUID session_id; - U32 t; + U32 timestamp; std::string name; std::string message; U32 parent_estate_id = 0; @@ -1350,7 +1442,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) msg->getU8Fast( _PREHASH_MessageBlock, _PREHASH_Offline, offline); msg->getU8Fast( _PREHASH_MessageBlock, _PREHASH_Dialog, d); msg->getUUIDFast(_PREHASH_MessageBlock, _PREHASH_ID, session_id); - msg->getU32Fast( _PREHASH_MessageBlock, _PREHASH_Timestamp, t); + msg->getU32Fast( _PREHASH_MessageBlock, _PREHASH_Timestamp, timestamp); //msg->getData("MessageBlock", "Count", &count); msg->getStringFast(_PREHASH_MessageBlock, _PREHASH_FromAgentName, name); msg->getStringFast(_PREHASH_MessageBlock, _PREHASH_Message, message); @@ -1360,7 +1452,6 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) msg->getBinaryDataFast( _PREHASH_MessageBlock, _PREHASH_BinaryBucket, binary_bucket, 0, 0, MTUBYTES); binary_bucket_size = msg->getSizeFast(_PREHASH_MessageBlock, _PREHASH_BinaryBucket); EInstantMessage dialog = (EInstantMessage)d; - time_t timestamp = (time_t)t; BOOL is_busy = gAgent.getBusy(); BOOL is_muted = LLMuteList::getInstance()->isMuted(from_id, name, LLMute::flagTextChat); @@ -1389,18 +1480,18 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) message_offset = 3; } - LLStringUtil::format_map_t args; + LLSD args; switch(dialog) { case IM_CONSOLE_AND_CHAT_HISTORY: // These are used for system messages, hence don't need the name, // as it is always "Second Life". // *TODO:translate - args["[MESSAGE]"] = message; + args["MESSAGE"] = message; // Note: don't put the message in the IM history, even though was sent // via the IM mechanism. - LLNotifyBox::showXml("SystemMessageTip",args); + LLNotifications::instance().add("SystemMessageTip",args); break; case IM_NOTHING_SPECIAL: @@ -1470,9 +1561,9 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) else if (to_id.isNull()) { // Message to everyone from GOD - args["[NAME]"] = name; - args["[MESSAGE]"] = message; - LLNotifyBox::showXml("GodMessage", args); + args["NAME"] = name; + args["MESSAGE"] = message; + LLNotifications::instance().add("GodMessage", args); // Treat like a system message and put in chat history. // Claim to be from a local agent so it doesn't go into @@ -1541,8 +1632,8 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) { // This is a block, modeless dialog. //*TODO:translate - args["[MESSAGE]"] = message; - LLNotifyBox::showXml("SystemMessage", args); + args["MESSAGE"] = message; + LLNotifications::instance().add("SystemMessage", args); } break; case IM_GROUP_NOTICE: @@ -1579,9 +1670,11 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) // If there is inventory, give the user the inventory offer. LLOfferInfo* info = NULL; + if (has_inventory) { info = new LLOfferInfo; + info->mIM = IM_GROUP_NOTICE; info->mFromID = from_id; info->mFromGroup = from_group; @@ -1610,13 +1703,26 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) std::string subj(*iter++); std::string mes(*iter++); - if (IM_GROUP_NOTICE == dialog) + // Send the notification down the new path. + // For requested notices, we don't want to send the popups. + if (dialog != IM_GROUP_NOTICE_REQUESTED) { - subj += "\n"; - mes = "\n\n" + mes; - LLGroupNotifyBox::show(subj,mes,name,group_id,t,has_inventory,item_name,info); + LLSD payload; + payload["subject"] = subj; + payload["message"] = mes; + payload["sender_name"] = name; + payload["group_id"] = group_id; + payload["inventory_name"] = item_name; + payload["inventory_offer"] = info ? info->asLLSD() : LLSD(); + + LLSD args; + args["SUBJECT"] = subj; + args["MESSAGE"] = mes; + LLNotifications::instance().add(LLNotification::Params("GroupNotice").substitutions(args).payload(payload).timestamp(timestamp)); } - else if (IM_GROUP_NOTICE_REQUESTED == dialog) + + // Also send down the old path for now. + if (IM_GROUP_NOTICE_REQUESTED == dialog) { LLFloaterGroupInfo::showNotice(subj,mes,group_id,has_inventory,item_name,info); } @@ -1628,7 +1734,6 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) if ((is_busy || is_muted)) { LLMessageSystem *msg = gMessageSystem; - join_group_callback(1, NULL); busy_message(msg,from_id); } else @@ -1651,18 +1756,16 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) invite_bucket = (struct invite_bucket_t*) &binary_bucket[0]; S32 membership_fee = ntohl(invite_bucket->membership_fee); - LLJoinGroupData* userdata = new LLJoinGroupData; - userdata->mTransactionID = session_id; - userdata->mGroupID = from_id; - userdata->mName.assign(name); - userdata->mMessage.assign(message); - userdata->mFee = membership_fee; - - LLStringUtil::format_map_t args; - args["[MESSAGE]"] = message; - LLNotifyBox::showXml("JoinGroup", args, - &join_group_callback, - (void*)userdata); + LLSD payload; + payload["transaction_id"] = session_id; + payload["group_id"] = from_id; + payload["name"] = name; + payload["message"] = message; + payload["fee"] = membership_fee; + + LLSD args; + args["MESSAGE"] = message; + LLNotifications::instance().add("JoinGroup", args, payload, join_group_response); } } break; @@ -1722,7 +1825,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) if ( is_muted ) { // Same as closing window - inventory_offer_callback(-1, info); + info->forceResponse(IOR_DECLINE); } else { @@ -1733,23 +1836,25 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) case IM_INVENTORY_ACCEPTED: { - args["[NAME]"] = name; - LLNotifyBox::showXml("InventoryAccepted", args); + args["NAME"] = name; + LLNotifications::instance().add("InventoryAccepted", args); break; } case IM_INVENTORY_DECLINED: { - args["[NAME]"] = name; - LLNotifyBox::showXml("InventoryDeclined", args); + args["NAME"] = name; + LLNotifications::instance().add("InventoryDeclined", args); break; } case IM_GROUP_VOTE: { - LLUUID *userdata = new LLUUID(session_id); - args["[NAME]"] = name; - args["[MESSAGE]"] = message; - LLNotifyBox::showXml("GroupVote", args, - &group_vote_callback, userdata); + LLSD args; + args["NAME"] = name; + args["MESSAGE"] = message; + + LLSD payload; + payload["group_id"] = session_id; + LLNotifications::instance().add("GroupVote", args, payload); } break; @@ -1856,9 +1961,9 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) } { // Construct a viewer alert for this message. - args["[NAME]"] = name; - args["[MESSAGE]"] = message; - LLNotifyBox::showXml("ObjectMessage", args); + args["NAME"] = name; + args["MESSAGE"] = message; + LLNotifications::instance().add("ObjectMessage", args); } break; case IM_BUSY_AUTO_RESPONSE: @@ -1887,27 +1992,34 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) } else { + LLSD args; // *TODO:translate -> [FIRST] [LAST] (maybe) - LLLureInfo* info = new LLLureInfo(from_id, session_id, FALSE); - args["[NAME]"] = name; - args["[MESSAGE]"] = message; - LLNotifyBox::showXml("OfferTeleport", args, - lure_callback, (void*)info); + args["NAME"] = name; + args["MESSAGE"] = message; + LLSD payload; + payload["from_id"] = from_id; + payload["lure_id"] = session_id; + payload["godlike"] = FALSE; + LLNotifications::instance().add("TeleportOffered", args, payload); } } break; case IM_GODLIKE_LURE_USER: { - LLLureInfo* info = new LLLureInfo(from_id, session_id, TRUE); + LLSD payload; + payload["from_id"] = from_id; + payload["lure_id"] = session_id; + payload["godlike"] = TRUE; // do not show a message box, because you're about to be // teleported. - lure_callback(0, (void *)info); + LLNotifications::instance().forceResponse(LLNotification::Params("TeleportOffered").payload(payload), 0); } break; case IM_GOTO_URL: { + LLSD args; // n.b. this is for URLs sent by the system, not for // URLs sent by scripts (i.e. llLoadURL) if (binary_bucket_size <= 0) @@ -1918,38 +2030,33 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) return; } - char* url = new char[binary_bucket_size]; - if (url == NULL) - { - LL_ERRS("Messaging") << "Memory Allocation failed" << LL_ENDL; - return; - } - - strncpy(url, (char*)binary_bucket, binary_bucket_size-1); /* Flawfinder: ignore */ - url[binary_bucket_size-1] = '\0'; - args["[MESSAGE]"] = message; - args["[URL]"] = url; - LLNotifyBox::showXml("GotoURL", args, - goto_url_callback, (void*)url); + std::string url; + + url.assign((char*)binary_bucket, binary_bucket_size-1); + args["MESSAGE"] = message; + args["URL"] = url; + LLSD payload; + payload["url"] = url; + LLNotifications::instance().add("GotoURL", args, payload ); } break; case IM_FRIENDSHIP_OFFERED: { - LLFriendshipOffer* offer = new LLFriendshipOffer; - offer->mFromID = from_id; - offer->mTransactionID = session_id; - offer->mOnline = (offline == IM_ONLINE); - offer->mHost = msg->getSender(); + LLSD payload; + payload["from_id"] = from_id; + payload["session_id"] = session_id;; + payload["online"] = (offline == IM_ONLINE); + payload["sender"] = msg->getSender().getIPandPort(); if (is_busy) { busy_message(msg, from_id); - friendship_offer_callback(1, (void*)offer); + LLNotifications::instance().forceResponse(LLNotification::Params("OfferFriendship").payload(payload), 1); } else if (is_muted) { - friendship_offer_callback(1, (void*)offer); + LLNotifications::instance().forceResponse(LLNotification::Params("OfferFriendship").payload(payload), 1); } else { @@ -1957,14 +2064,12 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) if(message.empty()) { //support for frienship offers from clients before July 2008 - LLNotifyBox::showXml("OfferFriendshipNoMessage", args, - &friendship_offer_callback, (void*)offer); + LLNotifications::instance().add("OfferFriendshipNoMessage", args, payload); } else { args["[MESSAGE]"] = message; - LLNotifyBox::showXml("OfferFriendship", args, - &friendship_offer_callback, (void*)offer); + LLNotifications::instance().add("OfferFriendship", args, payload); } } } @@ -1981,14 +2086,14 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) strings.push_back(from_id.asString()); send_generic_message("requestonlinenotification", strings); - args["[NAME]"] = name; - LLNotifyBox::showXml("FriendshipAccepted", args); + args["NAME"] = name; + LLNotifications::instance().add("FriendshipAccepted", args); } break; case IM_FRIENDSHIP_DECLINED: - args["[NAME]"] = name; - LLNotifyBox::showXml("FriendshipDeclined", args); + args["NAME"] = name; + LLNotifications::instance().add("FriendshipDeclined", args); break; default: @@ -2025,61 +2130,9 @@ void busy_message (LLMessageSystem* msg, LLUUID from_id) } } -void friendship_offer_callback(S32 option, void* user_data) +bool callingcard_offer_callback(const LLSD& notification, const LLSD& response) { - LLFriendshipOffer* offer = (LLFriendshipOffer*)user_data; - if(!offer) return; - LLUUID fid; - LLMessageSystem* msg = gMessageSystem; - switch(option) - { - case 0: - // accept - LLAvatarTracker::formFriendship(offer->mFromID); - - fid = gInventory.findCategoryUUIDForType(LLAssetType::AT_CALLINGCARD); - - // This will also trigger an onlinenotification if the user is online - msg->newMessageFast(_PREHASH_AcceptFriendship); - msg->nextBlockFast(_PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - msg->nextBlockFast(_PREHASH_TransactionBlock); - msg->addUUIDFast(_PREHASH_TransactionID, offer->mTransactionID); - msg->nextBlockFast(_PREHASH_FolderData); - msg->addUUIDFast(_PREHASH_FolderID, fid); - msg->sendReliable(offer->mHost); - break; - case 1: - // decline - msg->newMessageFast(_PREHASH_DeclineFriendship); - msg->nextBlockFast(_PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - msg->nextBlockFast(_PREHASH_TransactionBlock); - msg->addUUIDFast(_PREHASH_TransactionID, offer->mTransactionID); - msg->sendReliable(offer->mHost); - break; - default: - // close button probably, possibly timed out - break; - } - - delete offer; - offer = NULL; -} - -struct LLCallingCardOfferData -{ - LLUUID mTransactionID; - LLUUID mSourceID; - LLHost mHost; -}; - -void callingcard_offer_callback(S32 option, void* user_data) -{ - LLCallingCardOfferData* offerdata = (LLCallingCardOfferData*)user_data; - if(!offerdata) return; + S32 option = LLNotification::getSelectedOption(notification, response); LLUUID fid; LLUUID from_id; LLMessageSystem* msg = gMessageSystem; @@ -2092,11 +2145,11 @@ void callingcard_offer_callback(S32 option, void* user_data) msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->nextBlockFast(_PREHASH_TransactionBlock); - msg->addUUIDFast(_PREHASH_TransactionID, offerdata->mTransactionID); + msg->addUUIDFast(_PREHASH_TransactionID, notification["payload"]["transaction_id"].asUUID()); fid = gInventory.findCategoryUUIDForType(LLAssetType::AT_CALLINGCARD); msg->nextBlockFast(_PREHASH_FolderData); msg->addUUIDFast(_PREHASH_FolderID, fid); - msg->sendReliable(offerdata->mHost); + msg->sendReliable(LLHost(notification["payload"]["sender"].asString())); break; case 1: // decline @@ -2105,18 +2158,18 @@ void callingcard_offer_callback(S32 option, void* user_data) msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->nextBlockFast(_PREHASH_TransactionBlock); - msg->addUUIDFast(_PREHASH_TransactionID, offerdata->mTransactionID); - msg->sendReliable(offerdata->mHost); - busy_message(msg, offerdata->mSourceID); + msg->addUUIDFast(_PREHASH_TransactionID, notification["payload"]["transaction_id"].asUUID()); + msg->sendReliable(LLHost(notification["payload"]["sender"].asString())); + busy_message(msg, notification["payload"]["source_id"].asUUID()); break; default: // close button probably, possibly timed out break; } - delete offerdata; - offerdata = NULL; + return false; } +static LLNotificationFunctorRegistration callingcard_offer_cb_reg("OfferCallingCard", callingcard_offer_callback); void process_offer_callingcard(LLMessageSystem* msg, void**) { @@ -2128,13 +2181,13 @@ void process_offer_callingcard(LLMessageSystem* msg, void**) LLUUID tid; msg->getUUIDFast(_PREHASH_AgentBlock, _PREHASH_TransactionID, tid); - LLCallingCardOfferData* offerdata = new LLCallingCardOfferData; - offerdata->mTransactionID = tid; - offerdata->mSourceID = source_id; - offerdata->mHost = msg->getSender(); + LLSD payload; + payload["transaction_id"] = tid; + payload["source_id"] = source_id; + payload["sender"] = msg->getSender().getIPandPort(); LLViewerObject* source = gObjectList.findObject(source_id); - LLStringUtil::format_map_t args; + LLSD args; std::string source_name; if(source && source->isAvatar()) { @@ -2142,8 +2195,8 @@ void process_offer_callingcard(LLMessageSystem* msg, void**) LLNameValue* nvlast = source->getNVPair("LastName"); if (nvfirst && nvlast) { - args["[FIRST]"] = nvfirst->getString(); - args["[LAST]"] = nvlast->getString(); + args["FIRST"] = nvfirst->getString(); + args["LAST"] = nvlast->getString(); source_name = std::string(nvfirst->getString()) + " " + nvlast->getString(); } } @@ -2154,33 +2207,27 @@ void process_offer_callingcard(LLMessageSystem* msg, void**) || LLMuteList::getInstance()->isMuted(source_id, source_name, LLMute::flagTextChat)) { // automatically decline offer - callingcard_offer_callback(1, (void*)offerdata); - offerdata = NULL; // pointer was freed by callback + LLNotifications::instance().forceResponse(LLNotification::Params("OfferCallingCard").payload(payload), 1); } else { - LLNotifyBox::showXml("OfferCallingCard", args, - &callingcard_offer_callback, (void*)offerdata); - offerdata = NULL; // pointer ownership transferred + LLNotifications::instance().add("OfferCallingCard", args, payload); } } else { LL_WARNS("Messaging") << "Calling card offer from an unknown source." << LL_ENDL; } - - delete offerdata; // !=NULL if we didn't give ownership away - offerdata = NULL; } void process_accept_callingcard(LLMessageSystem* msg, void**) { - LLNotifyBox::showXml("CallingCardAccepted"); + LLNotifications::instance().add("CallingCardAccepted"); } void process_decline_callingcard(LLMessageSystem* msg, void**) { - LLNotifyBox::showXml("CallingCardDeclined"); + LLNotifications::instance().add("CallingCardDeclined"); } @@ -2496,18 +2543,18 @@ public: LLInventoryModel::EXCLUDE_TRASH, is_card); } - LLStringUtil::format_map_t args; + LLSD args; if ( land_items.count() > 0 ) { // Show notification that they can now teleport to landmarks. Use a random landmark from the inventory S32 random_land = ll_rand( land_items.count() - 1 ); - args["[NAME]"] = land_items[random_land]->getName(); - LLNotifyBox::showXml("TeleportToLandmark",args); + args["NAME"] = land_items[random_land]->getName(); + LLNotifications::instance().add("TeleportToLandmark",args); } if ( card_items.count() > 0 ) { // Show notification that they can now contact people. Use a random calling card from the inventory S32 random_card = ll_rand( card_items.count() - 1 ); - args["[NAME]"] = card_items[random_card]->getName(); - LLNotifyBox::showXml("TeleportToPerson",args); + args["NAME"] = card_items[random_card]->getName(); + LLNotifications::instance().add("TeleportToPerson",args); } gInventory.removeObserver(this); @@ -2688,11 +2735,6 @@ void process_avatar_init_complete(LLMessageSystem* msg, void**) } */ -static void display_release_notes(S32, void* data) -{ - gAgent.getRegion()->showReleaseNotes(); -} - void process_agent_movement_complete(LLMessageSystem* msg, void**) { gAgentMovementCompleted = true; @@ -2864,8 +2906,9 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**) if (!gLastVersionChannel.empty()) { - LLNotifyBox::showXml( - "ServerVersionChanged", display_release_notes, NULL); + LLSD payload; + payload["message"] = version_channel; + LLNotifications::instance().add("ServerVersionChanged", LLSD(), payload); } gLastVersionChannel = version_channel; @@ -4059,9 +4102,9 @@ void process_money_balance_reply( LLMessageSystem* msg, void** ) // Make the user confirm the transaction, since they might // have missed something during an event. // *TODO:translate - LLStringUtil::format_map_t args; - args["[MESSAGE]"] = desc; - LLNotifyBox::showXml("SystemMessage", args); + LLSD args; + args["MESSAGE"] = desc; + LLNotifications::instance().add("SystemMessage", args); // Once the 'recent' container gets large enough, chop some // off the beginning. @@ -4121,54 +4164,54 @@ void process_alert_core(const std::string& message, BOOL modal) // Allow the server to spawn a named alert so that server alerts can be // translated out of English. std::string alert_name(message.substr(ALERT_PREFIX.length())); - LLAlertDialog::showXml(alert_name); + LLNotifications::instance().add(alert_name); } else if (message.find(NOTIFY_PREFIX) == 0) { // Allow the server to spawn a named notification so that server notifications can be // translated out of English. std::string notify_name(message.substr(NOTIFY_PREFIX.length())); - LLNotifyBox::showXml(notify_name); + LLNotifications::instance().add(notify_name); } else if (message[0] == '/') { // System message is important, show in upper-right box not tip std::string text(message.substr(1)); - LLStringUtil::format_map_t args; + LLSD args; if (text.substr(0,17) == "RESTART_X_MINUTES") { S32 mins = 0; LLStringUtil::convertToS32(text.substr(18), mins); - args["[MINUTES]"] = llformat("%d",mins); - LLNotifyBox::showXml("RegionRestartMinutes", args); + args["MINUTES"] = llformat("%d",mins); + LLNotifications::instance().add("RegionRestartMinutes", args); } else if (text.substr(0,17) == "RESTART_X_SECONDS") { S32 secs = 0; LLStringUtil::convertToS32(text.substr(18), secs); - args["[SECONDS]"] = llformat("%d",secs); - LLNotifyBox::showXml("RegionRestartSeconds", args); + args["SECONDS"] = llformat("%d",secs); + LLNotifications::instance().add("RegionRestartSeconds", args); } else { // *TODO:translate - args["[MESSAGE]"] = text; - LLNotifyBox::showXml("SystemMessage", args); + args["MESSAGE"] = text; + LLNotifications::instance().add("SystemMessage", args); } } else if (modal) { // *TODO:translate - LLStringUtil::format_map_t args; - args["[ERROR_MESSAGE]"] = message; - gViewerWindow->alertXml("ErrorMessage", args); + LLSD args; + args["ERROR_MESSAGE"] = message; + LLNotifications::instance().add("ErrorMessage", args); } else { // *TODO:translate - LLStringUtil::format_map_t args; - args["[MESSAGE]"] = message; - LLNotifyBox::showXml("SystemMessageTip", args); + LLSD args; + args["MESSAGE"] = message; + LLNotifications::instance().add("SystemMessageTip", args); } } @@ -4300,23 +4343,7 @@ void process_economy_data(LLMessageSystem *msg, void** /*user_data*/) gMenuHolder->childSetLabelArg("Bulk Upload", "[COST]", llformat("%d", upload_cost)); } -class LLScriptQuestionCBData -{ -public: - LLScriptQuestionCBData(const LLUUID &taskid, const LLUUID &itemid, const LLHost &sender, S32 questions, const std::string& object_name, const std::string& owner_name) - : mTaskID(taskid), mItemID(itemid), mSender(sender), mQuestions(questions), mObjectName(object_name), mOwnerName(owner_name) - { - } - - LLUUID mTaskID; - LLUUID mItemID; - LLHost mSender; - S32 mQuestions; - std::string mObjectName; - std::string mOwnerName; -}; - -void notify_cautioned_script_question(LLScriptQuestionCBData* cbdata, S32 orig_questions, BOOL granted) +void notify_cautioned_script_question(const LLSD& notification, const LLSD& response, S32 orig_questions, BOOL granted) { // only continue if at least some permissions were requested if (orig_questions) @@ -4327,16 +4354,16 @@ void notify_cautioned_script_question(LLScriptQuestionCBData* cbdata, S32 orig_q // located in [REGIONNAME] at [REGIONPOS], // has been <granted|denied> permission to: [PERMISSIONS]." - LLUIString notice(LLNotifyBox::getTemplateMessage(granted ? "ScriptQuestionCautionChatGranted" : "ScriptQuestionCautionChatDenied")); + LLUIString notice(LLFloaterChat::getInstance()->getString(granted ? "ScriptQuestionCautionChatGranted" : "ScriptQuestionCautionChatDenied")); // always include the object name and owner name - notice.setArg("[OBJECTNAME]", cbdata->mObjectName); - notice.setArg("[OWNERNAME]", cbdata->mOwnerName); + notice.setArg("[OBJECTNAME]", notification["payload"]["object_name"].asString()); + notice.setArg("[OWNERNAME]", notification["payload"]["owner_name"].asString()); // try to lookup viewerobject that corresponds to the object that // requested permissions (here, taskid->requesting object id) BOOL foundpos = FALSE; - LLViewerObject* viewobj = gObjectList.findObject(cbdata->mTaskID); + LLViewerObject* viewobj = gObjectList.findObject(notification["payload"]["task_id"].asUUID()); if (viewobj) { // found the viewerobject, get it's position in its region @@ -4369,7 +4396,7 @@ void notify_cautioned_script_question(LLScriptQuestionCBData* cbdata, S32 orig_q std::string perms; for (S32 i = 0; i < SCRIPT_PERMISSION_EOF; i++) { - if ((orig_questions & LSCRIPTRunTimePermissionBits[i]) && LLNotifyBox::getTemplateIsCaution(SCRIPT_QUESTIONS[i])) + if ((orig_questions & LSCRIPTRunTimePermissionBits[i]) && SCRIPT_QUESTION_IS_CAUTION[i]) { count++; caution = TRUE; @@ -4381,7 +4408,7 @@ void notify_cautioned_script_question(LLScriptQuestionCBData* cbdata, S32 orig_q perms.append(", "); } - perms.append(LLNotifyBox::getTemplateMessage(SCRIPT_QUESTIONS[i])); + perms.append(LLFloaterChat::getInstance()->getString(SCRIPT_QUESTIONS[i])); } } @@ -4397,43 +4424,12 @@ void notify_cautioned_script_question(LLScriptQuestionCBData* cbdata, S32 orig_q } } -void script_question_decline_cb(S32 option, void* user_data) -{ - LLMessageSystem *msg = gMessageSystem; - LLScriptQuestionCBData *cbdata = (LLScriptQuestionCBData *)user_data; - - // remember the permissions requested so they can be checked - // when it comes time to log a chat message - S32 orig = cbdata->mQuestions; - - // this callback will always decline all permissions requested - // (any question flags set in the ScriptAnswerYes message - // will be interpreted as having been granted, so clearing all - // the bits will deny every permission) - cbdata->mQuestions = 0; - - // respond with the permissions denial - msg->newMessageFast(_PREHASH_ScriptAnswerYes); - msg->nextBlockFast(_PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - msg->nextBlockFast(_PREHASH_Data); - msg->addUUIDFast(_PREHASH_TaskID, cbdata->mTaskID); - msg->addUUIDFast(_PREHASH_ItemID, cbdata->mItemID); - msg->addS32Fast(_PREHASH_Questions, cbdata->mQuestions); - msg->sendReliable(cbdata->mSender); - - // log a chat message, if appropriate - notify_cautioned_script_question(cbdata, orig, FALSE); - - delete cbdata; -} - -void script_question_cb(S32 option, void* user_data) +bool script_question_cb(const LLSD& notification, const LLSD& response) { + S32 option = LLNotification::getSelectedOption(notification, response); LLMessageSystem *msg = gMessageSystem; - LLScriptQuestionCBData *cbdata = (LLScriptQuestionCBData *)user_data; - S32 orig = cbdata->mQuestions; + S32 orig = notification["payload"]["questions"].asInteger(); + S32 new_questions = orig; // check whether permissions were granted or denied BOOL allowed = TRUE; @@ -4441,48 +4437,68 @@ void script_question_cb(S32 option, void* user_data) // if any other button was clicked, the permissions were denied if (option != 0) { - cbdata->mQuestions = 0; + new_questions = 0; allowed = FALSE; } + LLUUID task_id = notification["payload"]["task_id"].asUUID(); + LLUUID item_id = notification["payload"]["item_id"].asUUID(); + // reply with the permissions granted or denied msg->newMessageFast(_PREHASH_ScriptAnswerYes); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->nextBlockFast(_PREHASH_Data); - msg->addUUIDFast(_PREHASH_TaskID, cbdata->mTaskID); - msg->addUUIDFast(_PREHASH_ItemID, cbdata->mItemID); - msg->addS32Fast(_PREHASH_Questions, cbdata->mQuestions); - msg->sendReliable(cbdata->mSender); + msg->addUUIDFast(_PREHASH_TaskID, task_id); + msg->addUUIDFast(_PREHASH_ItemID, item_id); + msg->addS32Fast(_PREHASH_Questions, new_questions); + msg->sendReliable(LLHost(notification["payload"]["sender"].asString())); // only log a chat message if caution prompts are enabled if (gSavedSettings.getBOOL("PermissionsCautionEnabled")) { // log a chat message, if appropriate - notify_cautioned_script_question(cbdata, orig, allowed); + notify_cautioned_script_question(notification, response, orig, allowed); } - if ( option == 2 ) // mute + if ( response["Mute"] ) // mute { - LLMuteList::getInstance()->add(LLMute(cbdata->mItemID, cbdata->mObjectName, LLMute::OBJECT)); + LLMuteList::getInstance()->add(LLMute(item_id, notification["payload"]["object_name"].asString(), LLMute::OBJECT)); // purge the message queue of any previously queued requests from the same source. DEV-4879 class OfferMatcher : public LLNotifyBoxView::Matcher { public: OfferMatcher(const LLUUID& to_block) : blocked_id(to_block) {} - BOOL matches(LLNotifyBox::notify_callback_t callback, void* cb_data) const + BOOL matches(const LLNotificationPtr notification) const { - return callback == script_question_cb && ((LLScriptQuestionCBData*)cb_data)->mItemID == blocked_id; + if (notification->getName() == "ScriptQuestionCaution" + || notification->getName() == "ScriptQuestion") + { + return (notification->getPayload()["item_id"].asUUID() == blocked_id); + } + return FALSE; } private: const LLUUID& blocked_id; }; - gNotifyBoxView->purgeMessagesMatching(OfferMatcher(cbdata->mItemID)); + // should do this via the channel + gNotifyBoxView->purgeMessagesMatching(OfferMatcher(item_id)); + } + + if (response["Details"]) + { + // respawn notification... + LLNotifications::instance().add(notification["name"], notification["substitutions"], notification["payload"]); + + // ...with description on top + LLNotifications::instance().add("DebitPermissionDetails"); } - delete cbdata; + return false; } +static LLNotificationFunctorRegistration script_question_cb_reg_1("ScriptQuestion", script_question_cb); +static LLNotificationFunctorRegistration script_question_cb_reg_2("ScriptQuestionCaution", script_question_cb); void process_script_question(LLMessageSystem *msg, void **user_data) { @@ -4532,9 +4548,9 @@ void process_script_question(LLMessageSystem *msg, void **user_data) { BOOL caution = FALSE; S32 count = 0; - LLStringUtil::format_map_t args; - args["[OBJECTNAME]"] = object_name; - args["[NAME]"] = owner_name; + LLSD args; + args["OBJECTNAME"] = object_name; + args["NAME"] = owner_name; // check the received permission flags against each permission for (S32 i = 0; i < SCRIPT_PERMISSION_EOF; i++) @@ -4542,34 +4558,32 @@ void process_script_question(LLMessageSystem *msg, void **user_data) if (questions & LSCRIPTRunTimePermissionBits[i]) { count++; - script_question += " " + LLNotifyBox::getTemplateMessage(SCRIPT_QUESTIONS[i]) + "\n"; + script_question += " " + LLFloaterChat::getInstance()->getString(SCRIPT_QUESTIONS[i]) + "\n"; // check whether permission question should cause special caution dialog - caution |= LLNotifyBox::getTemplateIsCaution(SCRIPT_QUESTIONS[i]); + caution |= (SCRIPT_QUESTION_IS_CAUTION[i]); } } - args["[QUESTIONS]"] = script_question; + args["QUESTIONS"] = script_question; - LLScriptQuestionCBData *cbdata = new LLScriptQuestionCBData(taskid, itemid, sender, questions, object_name, owner_name); + LLSD payload; + payload["task_id"] = taskid; + payload["item_id"] = itemid; + payload["sender"] = sender.getIPandPort(); + payload["questions"] = questions; + payload["object_name"] = object_name; + payload["owner_name"] = owner_name; // check whether cautions are even enabled or not if (gSavedSettings.getBOOL("PermissionsCautionEnabled")) { - if (caution) - { - // display the caution permissions prompt - LLNotifyBox::showXml("ScriptQuestionCaution", args, TRUE, script_question_cb, cbdata); - } - else - { - // display the permissions request normally - LLNotifyBox::showXml("ScriptQuestion", args, FALSE, script_question_cb, cbdata); - } + // display the caution permissions prompt + LLNotifications::instance().add(caution ? "ScriptQuestionCaution" : "ScriptQuestion", args, payload); } else { // fall back to default behavior if cautions are entirely disabled - LLNotifyBox::showXml("ScriptQuestion", args, FALSE, script_question_cb, cbdata); + LLNotifications::instance().add("ScriptQuestion", args, payload); } } @@ -4706,18 +4720,18 @@ void process_teleport_failed(LLMessageSystem *msg, void**) std::string reason; msg->getStringFast(_PREHASH_Info, _PREHASH_Reason, reason); - LLStringUtil::format_map_t args; + LLSD args; std::string big_reason = LLAgent::sTeleportErrorMessages[reason]; if ( big_reason.size() > 0 ) { // Substitute verbose reason from the local map - args["[REASON]"] = big_reason; + args["REASON"] = big_reason; } else { // Nothing found in the map - use what the server returned - args["[REASON]"] = reason; + args["REASON"] = reason; } - gViewerWindow->alertXml("CouldNotTeleportReason", args); + LLNotifications::instance().add("CouldNotTeleportReason", args); if( gAgent.getTeleportState() != LLAgent::TELEPORT_NONE ) { @@ -4839,9 +4853,10 @@ void send_group_notice(const LLUUID& group_id, bin_bucket_size); } -void handle_lure_callback(S32 option, const std::string& text, void* userdata) +bool handle_lure_callback(const LLSD& notification, const LLSD& response) { - LLDynamicArray<LLUUID>* invitees = (LLDynamicArray<LLUUID>*)userdata; + std::string text = response["message"].asString(); + S32 option = LLNotification::getSelectedOption(notification, response); if(0 == option) { @@ -4853,21 +4868,17 @@ void handle_lure_callback(S32 option, const std::string& text, void* userdata) msg->nextBlockFast(_PREHASH_Info); msg->addU8Fast(_PREHASH_LureType, (U8)0); // sim will fill this in. msg->addStringFast(_PREHASH_Message, text); - for(LLDynamicArray<LLUUID>::iterator itr = invitees->begin(); itr != invitees->end(); ++itr) + for(LLSD::array_const_iterator it = notification["payload"]["ids"].beginArray(); + it != notification["payload"]["ids"].endArray(); + ++it) { msg->nextBlockFast(_PREHASH_TargetData); - msg->addUUIDFast(_PREHASH_TargetID, *itr); + msg->addUUIDFast(_PREHASH_TargetID, it->asUUID()); } gAgent.sendReliableMessage(); } - delete invitees; - invitees = NULL; -} - -void handle_lure_callback_godlike(S32 option, void* userdata) -{ - handle_lure_callback(option, LLStringUtil::null, userdata); + return false; } void handle_lure(const LLUUID& invitee) @@ -4880,21 +4891,23 @@ void handle_lure(const LLUUID& invitee) // Prompt for a message to the invited user. void handle_lure(LLDynamicArray<LLUUID>& ids) { - LLDynamicArray<LLUUID>* userdata = new LLDynamicArray<LLUUID>(ids); + LLSD edit_args; + edit_args["REGION"] = gAgent.getRegion()->getName(); - LLStringUtil::format_map_t edit_args; - edit_args["[REGION]"] = gAgent.getRegion()->getName(); + LLSD payload; + for (LLDynamicArray<LLUUID>::iterator it = ids.begin(); + it != ids.end(); + ++it) + { + payload["ids"].append(*it); + } if (gAgent.isGodlike()) { - gViewerWindow->alertXmlEditText("OfferTeleportFromGod", edit_args, - &handle_lure_callback_godlike, userdata, - NULL, NULL, edit_args); + LLNotifications::instance().add("OfferTeleportFromGod", edit_args, payload, handle_lure_callback); } else { - gViewerWindow->alertXmlEditText("OfferTeleport", edit_args, - NULL, NULL, - handle_lure_callback, userdata, edit_args); + LLNotifications::instance().add("OfferTeleport", edit_args, payload, handle_lure_callback); } } @@ -4986,21 +4999,13 @@ const S32 SCRIPT_DIALOG_BUTTON_STR_SIZE = 24; const S32 SCRIPT_DIALOG_MAX_MESSAGE_SIZE = 512; const char* SCRIPT_DIALOG_HEADER = "Script Dialog:\n"; -struct ScriptDialogInfo +bool callback_script_dialog(const LLSD& notification, const LLSD& response) { - LLHost mSender; - LLUUID mObjectID; - S32 mChatChannel; - std::vector<std::string> mButtons; -}; - -void callback_script_dialog(S32 option, void* data) -{ - ScriptDialogInfo* info = (ScriptDialogInfo*)data; - if (!info) return; - + LLNotificationForm form(notification["form"]); + std::string button = LLNotification::getSelectedOptionName(response); + S32 button_idx = LLNotification::getSelectedOption(notification, response); // Didn't click "Ignore" - if (0 != option) + if (button_idx != -1) { LLMessageSystem* msg = gMessageSystem; msg->newMessage("ScriptDialogReply"); @@ -5008,112 +5013,108 @@ void callback_script_dialog(S32 option, void* data) msg->addUUID("AgentID", gAgent.getID()); msg->addUUID("SessionID", gAgent.getSessionID()); msg->nextBlock("Data"); - msg->addUUID("ObjectID", info->mObjectID); - msg->addS32("ChatChannel", info->mChatChannel); - msg->addS32("ButtonIndex", option); - msg->addString("ButtonLabel", info->mButtons[option-1]); - msg->sendReliable(info->mSender); + msg->addUUID("ObjectID", notification["payload"]["object_id"].asUUID()); + msg->addS32("ChatChannel", notification["payload"]["chat_channel"].asInteger()); + msg->addS32("ButtonIndex", button_idx); + msg->addString("ButtonLabel", button); + msg->sendReliable(LLHost(notification["payload"]["sender"].asString())); } - delete info; + return false; } +static LLNotificationFunctorRegistration callback_script_dialog_reg_1("ScriptDialog", callback_script_dialog); +static LLNotificationFunctorRegistration callback_script_dialog_reg_2("ScriptDialogGroup", callback_script_dialog); void process_script_dialog(LLMessageSystem* msg, void**) { S32 i; - ScriptDialogInfo* info = new ScriptDialogInfo; + LLSD payload; - std::string message; // Account for size of "Script Dialog:\n" + std::string message; std::string first_name; std::string last_name; std::string title; - info->mSender = msg->getSender(); - msg->getUUID("Data", "ObjectID", info->mObjectID); + LLUUID object_id; + S32 chat_channel; + msg->getUUID("Data", "ObjectID", object_id); msg->getString("Data", "FirstName", first_name); msg->getString("Data", "LastName", last_name); msg->getString("Data", "ObjectName", title); msg->getString("Data", "Message", message); - msg->getS32("Data", "ChatChannel", info->mChatChannel); + msg->getS32("Data", "ChatChannel", chat_channel); // unused for now LLUUID image_id; msg->getUUID("Data", "ImageID", image_id); + payload["sender"] = msg->getSender().getIPandPort(); + payload["object_id"] = object_id; + payload["chat_channel"] = chat_channel; + + // build up custom form S32 button_count = msg->getNumberOfBlocks("Buttons"); if (button_count > SCRIPT_DIALOG_MAX_BUTTONS) { button_count = SCRIPT_DIALOG_MAX_BUTTONS; } + LLNotificationForm form; for (i = 0; i < button_count; i++) { std::string tdesc; msg->getString("Buttons", "ButtonLabel", tdesc, i); - info->mButtons.push_back(tdesc); + form.addElement("button", std::string(tdesc)); } - LLStringUtil::format_map_t args; - args["[TITLE]"] = title; - args["[MESSAGE]"] = message; + LLSD args; + args["TITLE"] = title; + args["MESSAGE"] = message; + LLNotificationPtr notification; if (!first_name.empty()) { - args["[FIRST]"] = first_name; - args["[LAST]"] = last_name; - LLNotifyBox::showXml("ScriptDialog", args, - callback_script_dialog, info, - info->mButtons, - TRUE); + args["FIRST"] = first_name; + args["LAST"] = last_name; + notification = LLNotifications::instance().add( + LLNotification::Params("ScriptDialog").substitutions(args).payload(payload).form_elements(form.asLLSD())); } else { - args["[GROUPNAME]"] = last_name; - LLNotifyBox::showXml("ScriptDialogGroup", args, - callback_script_dialog, info, - info->mButtons, - TRUE); + args["GROUPNAME"] = last_name; + notification = LLNotifications::instance().add( + LLNotification::Params("ScriptDialogGroup").substitutions(args).payload(payload).form_elements(form.asLLSD())); } } //--------------------------------------------------------------------------- -struct LoadUrlInfo -{ - LLUUID mObjectID; - LLUUID mOwnerID; - BOOL mOwnerIsGroup; - std::string mObjectName; - std::string mMessage; - std::string mUrl; -}; -std::vector<LoadUrlInfo*> gLoadUrlList; +std::vector<LLSD> gLoadUrlList; -void callback_load_url(S32 option, void* data) +bool callback_load_url(const LLSD& notification, const LLSD& response) { - LoadUrlInfo* infop = (LoadUrlInfo*)data; - if (!infop) return; + S32 option = LLNotification::getSelectedOption(notification, response); if (0 == option) { - LLWeb::loadURLExternal(infop->mUrl); + LLWeb::loadURL(notification["payload"]["url"].asString()); } - delete infop; - infop = NULL; + return false; } +static LLNotificationFunctorRegistration callback_load_url_reg("LoadWebPage", callback_load_url); // We've got the name of the person who owns the object hurling the url. // Display confirmation dialog. void callback_load_url_name(const LLUUID& id, const std::string& first, const std::string& last, BOOL is_group, void* data) { - std::vector<LoadUrlInfo*>::iterator it; + std::vector<LLSD>::iterator it; for (it = gLoadUrlList.begin(); it != gLoadUrlList.end(); ) { - LoadUrlInfo* infop = *it; - if (infop->mOwnerID == id) + LLSD load_url_info = *it; + if (load_url_info["owner_id"].asUUID() == id) { it = gLoadUrlList.erase(it); @@ -5130,16 +5131,15 @@ void callback_load_url_name(const LLUUID& id, const std::string& first, const st // For legacy name-only mutes. if (LLMuteList::getInstance()->isMuted(LLUUID::null, owner_name)) { - delete infop; - infop = NULL; continue; } - LLStringUtil::format_map_t args; - args["[URL]"] = infop->mUrl; - args["[MESSAGE]"] = infop->mMessage; - args["[OBJECTNAME]"] = infop->mObjectName; - args["[NAME]"] = owner_name; - LLNotifyBox::showXml("LoadWebPage", args, callback_load_url, infop); + LLSD args; + args["URL"] = load_url_info["url"].asString(); + args["MESSAGE"] = load_url_info["message"].asString();; + args["OBJECTNAME"] = load_url_info["object_name"].asString(); + args["NAME"] = owner_name; + + LLNotifications::instance().add("LoadWebPage", args, load_url_info); } else { @@ -5150,40 +5150,51 @@ void callback_load_url_name(const LLUUID& id, const std::string& first, const st void process_load_url(LLMessageSystem* msg, void**) { - LoadUrlInfo* infop = new LoadUrlInfo; - - msg->getString("Data", "ObjectName", infop->mObjectName); - msg->getUUID( "Data", "ObjectID", infop->mObjectID); - msg->getUUID( "Data", "OwnerID", infop->mOwnerID); - msg->getBOOL( "Data", "OwnerIsGroup", infop->mOwnerIsGroup); - msg->getString("Data", "Message", infop->mMessage); - msg->getString("Data", "URL", infop->mUrl); + LLUUID object_id; + LLUUID owner_id; + BOOL owner_is_group; + char object_name[256]; /* Flawfinder: ignore */ + char message[256]; /* Flawfinder: ignore */ + char url[256]; /* Flawfinder: ignore */ + + msg->getString("Data", "ObjectName", 256, object_name); + msg->getUUID( "Data", "ObjectID", object_id); + msg->getUUID( "Data", "OwnerID", owner_id); + msg->getBOOL( "Data", "OwnerIsGroup", owner_is_group); + msg->getString("Data", "Message", 256, message); + msg->getString("Data", "URL", 256, url); + + LLSD payload; + payload["object_id"] = object_id; + payload["owner_id"] = owner_id; + payload["owner_is_group"] = owner_is_group; + payload["object_name"] = object_name; + payload["message"] = message; + payload["url"] = url; // URL is safety checked in load_url above // Check if object or owner is muted - if (LLMuteList::getInstance()->isMuted(infop->mObjectID, infop->mObjectName) || - LLMuteList::getInstance()->isMuted(infop->mOwnerID)) + if (LLMuteList::getInstance()->isMuted(object_id, object_name) || + LLMuteList::getInstance()->isMuted(owner_id)) { LL_INFOS("Messaging")<<"Ignoring load_url from muted object/owner."<<LL_ENDL; - delete infop; - infop = NULL; return; } // Add to list of pending name lookups - gLoadUrlList.push_back(infop); + gLoadUrlList.push_back(payload); - gCacheName->get(infop->mOwnerID, infop->mOwnerIsGroup, callback_load_url_name); + gCacheName->get(owner_id, owner_is_group, callback_load_url_name); } void callback_download_complete(void** data, S32 result, LLExtStat ext_status) { std::string* filepath = (std::string*)data; - LLStringUtil::format_map_t args; - args["[DOWNLOAD_PATH]"] = *filepath; - gViewerWindow->alertXml("FinishedRawDownload", args); + LLSD args; + args["DOWNLOAD_PATH"] = *filepath; + LLNotifications::instance().add("FinishedRawDownload", args); delete filepath; } @@ -5415,3 +5426,10 @@ void invalid_message_callback(LLMessageSystem* msg, // Please do not add more message handlers here. This file is huge. // Put them in a file related to the functionality you are implementing. JC + +void LLOfferInfo::forceResponse(InventoryOfferResponse response) +{ + LLNotification::Params params("UserGiveItem"); + params.functor(boost::bind(&LLOfferInfo::inventory_offer_callback, this, _1, _2)); + LLNotifications::instance().forceResponse(params, response); +} diff --git a/indra/newview/llviewermessage.h b/indra/newview/llviewermessage.h index a2ed04d0a7..bbda752e89 100644 --- a/indra/newview/llviewermessage.h +++ b/indra/newview/llviewermessage.h @@ -192,11 +192,15 @@ void process_decline_callingcard(LLMessageSystem* msg, void**); void invalid_message_callback(LLMessageSystem*, void*, EMessageException); void process_initiate_download(LLMessageSystem* msg, void**); -void inventory_offer_callback(S32 option, void* user_data); void start_new_inventory_observer(); struct LLOfferInfo { + LLOfferInfo() {}; + LLOfferInfo(const LLSD& sd); + + void forceResponse(InventoryOfferResponse response); + EInstantMessage mIM; LLUUID mFromID; BOOL mFromGroup; @@ -208,6 +212,10 @@ struct LLOfferInfo std::string mFromName; std::string mDesc; LLHost mHost; + + LLSD asLLSD(); + bool inventory_offer_callback(const LLSD& notification, const LLSD& response); + }; void process_feature_disabled_message(LLMessageSystem* msg, void**); diff --git a/indra/newview/llviewerparcelmedia.cpp b/indra/newview/llviewerparcelmedia.cpp index fe588534e5..05c589c398 100644 --- a/indra/newview/llviewerparcelmedia.cpp +++ b/indra/newview/llviewerparcelmedia.cpp @@ -50,7 +50,7 @@ S32 LLViewerParcelMedia::sMediaParcelLocalID = 0; LLUUID LLViewerParcelMedia::sMediaRegionID; // Local functions -void callback_play_media(S32 option, void* data); +bool callback_play_media(const LLSD& notification, const LLSD& response, LLParcel* parcel); // Move this to its own file. // helper class that tries to download a URL from a web site and calls a method @@ -167,8 +167,8 @@ void LLViewerParcelMedia::update(LLParcel* parcel) // First use warning if( gSavedSettings.getWarning("FirstStreamingVideo") ) { - gViewerWindow->alertXml("ParcelCanPlayMedia", - callback_play_media, (void*)parcel); + LLNotifications::instance().add("ParcelCanPlayMedia", LLSD(), LLSD(), + boost::bind(callback_play_media, _1, _2, parcel)); } @@ -192,7 +192,7 @@ void LLViewerParcelMedia::update(LLParcel* parcel) { gSavedSettings.setWarning("QuickTimeInstalled", FALSE); - LLNotifyBox::showXml("NoQuickTime" ); + LLNotifications::instance().add("NoQuickTime" ); }; } } @@ -382,9 +382,9 @@ void LLViewerParcelMedia::processParcelMediaUpdate( LLMessageSystem *msg, void * } } -void callback_play_media(S32 option, void* data) +bool callback_play_media(const LLSD& notification, const LLSD& response, LLParcel* parcel) { - LLParcel* parcel = (LLParcel*)data; + S32 option = LLNotification::getSelectedOption(notification, response); if (option == 0) { gSavedSettings.setBOOL("AudioStreamingVideo", TRUE); @@ -395,6 +395,6 @@ void callback_play_media(S32 option, void* data) gSavedSettings.setBOOL("AudioStreamingVideo", FALSE); } gSavedSettings.setWarning("FirstStreamingVideo", FALSE); - + return false; } diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp index 6e37ec2095..099204e740 100644 --- a/indra/newview/llviewerparcelmgr.cpp +++ b/indra/newview/llviewerparcelmgr.cpp @@ -90,7 +90,7 @@ void callback_prepare_video(S32 option, void* data); void prepare_video(const LLParcel *parcelp); void start_video(const LLParcel *parcelp); void stop_video(); -void callback_god_force_owner(S32 option, void* user_data); +bool callback_god_force_owner(const LLSD&, const LLSD&); struct LLGodForceOwnerData { @@ -515,7 +515,7 @@ LLParcelSelectionHandle LLViewerParcelMgr::selectLand(const LLVector3d &corner1, if (region != region_other) { - LLNotifyBox::showXml("CantSelectLandFromMultipleRegions"); + LLNotifications::instance().add("CantSelectLandFromMultipleRegions"); mSelected = FALSE; notifyObservers(); return NULL; @@ -904,7 +904,7 @@ void LLViewerParcelMgr::sendParcelGodForceOwner(const LLUUID& owner_id) { if (!mSelected) { - gViewerWindow->alertXml("CannotSetLandOwnerNothingSelected"); + LLNotifications::instance().add("CannotSetLandOwnerNothingSelected"); return; } @@ -919,7 +919,7 @@ void LLViewerParcelMgr::sendParcelGodForceOwner(const LLUUID& owner_id) if (!region) { // TODO: Add a force owner version of this alert. - gViewerWindow->alertXml("CannotContentifyNoRegion"); + LLNotifications::instance().add("CannotContentifyNoRegion"); return; } @@ -927,29 +927,33 @@ void LLViewerParcelMgr::sendParcelGodForceOwner(const LLUUID& owner_id) LLViewerRegion *region2 = LLWorld::getInstance()->getRegionFromPosGlobal( east_north_region_check ); if (region != region2) { - gViewerWindow->alertXml("CannotSetLandOwnerMultipleRegions"); + LLNotifications::instance().add("CannotSetLandOwnerMultipleRegions"); return; } llinfos << "Region " << region->getOriginGlobal() << llendl; - LLGodForceOwnerData* data = new LLGodForceOwnerData(owner_id, mCurrentParcel->getLocalID(), region->getHost()); + LLSD payload; + payload["owner_id"] = owner_id; + payload["parcel_local_id"] = mCurrentParcel->getLocalID(); + payload["region_host"] = region->getHost().getIPandPort(); + LLNotification::Params params("ForceOwnerAuctionWarning"); + params.payload(payload).functor(callback_god_force_owner); + if(mCurrentParcel->getAuctionID()) { - gViewerWindow->alertXml("ForceOwnerAuctionWarning", - callback_god_force_owner, - (void*)data); + LLNotifications::instance().add(params); } else { - callback_god_force_owner(0, (void*)data); + LLNotifications::instance().forceResponse(params, 0); } } -void callback_god_force_owner(S32 option, void* user_data) +bool callback_god_force_owner(const LLSD& notification, const LLSD& response) { - LLGodForceOwnerData* data = (LLGodForceOwnerData*)user_data; - if(data && (0 == option)) + S32 option = LLNotification::getSelectedOption(notification, response); + if(0 == option) { LLMessageSystem* msg = gMessageSystem; msg->newMessage("ParcelGodForceOwner"); @@ -957,24 +961,24 @@ void callback_god_force_owner(S32 option, void* user_data) msg->addUUID("AgentID", gAgent.getID()); msg->addUUID("SessionID", gAgent.getSessionID()); msg->nextBlock("Data"); - msg->addUUID("OwnerID", data->mOwnerID); - msg->addS32( "LocalID", data->mLocalID); - msg->sendReliable(data->mHost); + msg->addUUID("OwnerID", notification["payload"]["owner_id"].asUUID()); + msg->addS32( "LocalID", notification["payload"]["parcel_local_id"].asInteger()); + msg->sendReliable(LLHost(notification["payload"]["region_host"].asString())); } - delete data; + return false; } void LLViewerParcelMgr::sendParcelGodForceToContent() { if (!mSelected) { - gViewerWindow->alertXml("CannotContentifyNothingSelected"); + LLNotifications::instance().add("CannotContentifyNothingSelected"); return; } LLViewerRegion* region = LLWorld::getInstance()->getRegionFromPosGlobal( mWestSouth ); if (!region) { - gViewerWindow->alertXml("CannotContentifyNoRegion"); + LLNotifications::instance().add("CannotContentifyNoRegion"); return; } @@ -992,14 +996,14 @@ void LLViewerParcelMgr::sendParcelRelease() { if (!mSelected) { - gViewerWindow->alertXml("CannotReleaseLandNothingSelected"); + LLNotifications::instance().add("CannotReleaseLandNothingSelected"); return; } LLViewerRegion *region = LLWorld::getInstance()->getRegionFromPosGlobal( mWestSouth ); if (!region) { - gViewerWindow->alertXml("CannotReleaseLandNoRegion"); + LLNotifications::instance().add("CannotReleaseLandNoRegion"); return; } @@ -1054,14 +1058,14 @@ LLViewerParcelMgr::ParcelBuyInfo* LLViewerParcelMgr::setupParcelBuy( { if (!mSelected || !mCurrentParcel) { - gViewerWindow->alertXml("CannotBuyLandNothingSelected"); + LLNotifications::instance().add("CannotBuyLandNothingSelected"); return NULL; } LLViewerRegion *region = LLWorld::getInstance()->getRegionFromPosGlobal( mWestSouth ); if (!region) { - gViewerWindow->alertXml("CannotBuyLandNoRegion"); + LLNotifications::instance().add("CannotBuyLandNoRegion"); return NULL; } @@ -1079,7 +1083,7 @@ LLViewerParcelMgr::ParcelBuyInfo* LLViewerParcelMgr::setupParcelBuy( if (region != region2) { - gViewerWindow->alertXml("CantBuyLandAcrossMultipleRegions"); + LLNotifications::instance().add("CantBuyLandAcrossMultipleRegions"); return NULL; } } @@ -1160,18 +1164,18 @@ void LLViewerParcelMgr::sendParcelDeed(const LLUUID& group_id) { if (!mSelected || !mCurrentParcel) { - gViewerWindow->alertXml("CannotDeedLandNothingSelected"); + LLNotifications::instance().add("CannotDeedLandNothingSelected"); return; } if(group_id.isNull()) { - gViewerWindow->alertXml("CannotDeedLandNoGroup"); + LLNotifications::instance().add("CannotDeedLandNoGroup"); return; } LLViewerRegion *region = LLWorld::getInstance()->getRegionFromPosGlobal( mWestSouth ); if (!region) { - gViewerWindow->alertXml("CannotDeedLandNoRegion"); + LLNotifications::instance().add("CannotDeedLandNoRegion"); return; } @@ -1908,26 +1912,27 @@ void LLViewerParcelMgr::deedLandToGroup() { std::string group_name; gCacheName->getGroupName(mCurrentParcel->getGroupID(), group_name); - LLStringUtil::format_map_t args; - args["[AREA]"] = llformat("%d", mCurrentParcel->getArea()); - args["[GROUP_NAME]"] = group_name; + LLSD args; + args["AREA"] = llformat("%d", mCurrentParcel->getArea()); + args["GROUP_NAME"] = group_name; if(mCurrentParcel->getContributeWithDeed()) { std::string first_name, last_name; gCacheName->getName(mCurrentParcel->getOwnerID(), first_name, last_name); - args["[FIRST_NAME]"] = first_name; - args["[LAST_NAME]"] = last_name; - gViewerWindow->alertXml("DeedLandToGroupWithContribution",args, deedAlertCB, NULL); + args["FIRST_NAME"] = first_name; + args["LAST_NAME"] = last_name; + LLNotifications::instance().add("DeedLandToGroupWithContribution",args, LLSD(), deedAlertCB); } else { - gViewerWindow->alertXml("DeedLandToGroup",args, deedAlertCB, NULL); + LLNotifications::instance().add("DeedLandToGroup",args, LLSD(), deedAlertCB); } } // static -void LLViewerParcelMgr::deedAlertCB(S32 option, void*) +bool LLViewerParcelMgr::deedAlertCB(const LLSD& notification, const LLSD& response) { + S32 option = LLNotification::getSelectedOption(notification, response); if (option == 0) { LLParcel* parcel = LLViewerParcelMgr::getInstance()->getParcelSelection()->getParcel(); @@ -1938,6 +1943,7 @@ void LLViewerParcelMgr::deedAlertCB(S32 option, void*) } LLViewerParcelMgr::getInstance()->sendParcelDeed(group_id); } + return false; } @@ -1945,26 +1951,26 @@ void LLViewerParcelMgr::startReleaseLand() { if (!mSelected) { - gViewerWindow->alertXml("CannotReleaseLandNothingSelected"); + LLNotifications::instance().add("CannotReleaseLandNothingSelected"); return; } if (mRequestResult == PARCEL_RESULT_NO_DATA) { - gViewerWindow->alertXml("CannotReleaseLandWatingForServer"); + LLNotifications::instance().add("CannotReleaseLandWatingForServer"); return; } if (mRequestResult == PARCEL_RESULT_MULTIPLE) { - gViewerWindow->alertXml("CannotReleaseLandSelected"); + LLNotifications::instance().add("CannotReleaseLandSelected"); return; } if (!isParcelOwnedByAgent(mCurrentParcel, GP_LAND_RELEASE) && !(gAgent.canManageEstate())) { - gViewerWindow->alertXml("CannotReleaseLandDontOwn"); + LLNotifications::instance().add("CannotReleaseLandDontOwn"); return; } @@ -1972,31 +1978,30 @@ void LLViewerParcelMgr::startReleaseLand() LLViewerRegion* region = LLWorld::getInstance()->getRegionFromPosGlobal(parcel_center); if (!region) { - gViewerWindow->alertXml("CannotReleaseLandRegionNotFound"); + LLNotifications::instance().add("CannotReleaseLandRegionNotFound"); return; } /* if ((region->getRegionFlags() & REGION_FLAGS_BLOCK_LAND_RESELL) && !gAgent.isGodlike()) { - LLStringUtil::format_map_t args; - args["[REGION]"] = region->getName(); - gViewerWindow->alertXml("CannotReleaseLandNoTransfer", args); + LLSD args; + args["REGION"] = region->getName(); + LLNotifications::instance().add("CannotReleaseLandNoTransfer", args); return; } */ if (!mCurrentParcelSelection->mWholeParcelSelected) { - gViewerWindow->alertXml("CannotReleaseLandPartialSelection"); + LLNotifications::instance().add("CannotReleaseLandPartialSelection"); return; } // Compute claim price - LLStringUtil::format_map_t args; - args["[AREA]"] = llformat("%d",mCurrentParcel->getArea()); - gViewerWindow->alertXml("ReleaseLandWarning", args, - releaseAlertCB, this); + LLSD args; + args["AREA"] = llformat("%d",mCurrentParcel->getArea()); + LLNotifications::instance().add("ReleaseLandWarning", args, LLSD(), releaseAlertCB); } bool LLViewerParcelMgr::canAgentBuyParcel(LLParcel* parcel, bool forGroup) const @@ -2052,38 +2057,42 @@ void LLViewerParcelMgr::startDivideLand() { if (!mSelected) { - gViewerWindow->alertXml("CannotDivideLandNothingSelected"); + LLNotifications::instance().add("CannotDivideLandNothingSelected"); return; } if (mCurrentParcelSelection->mWholeParcelSelected) { - gViewerWindow->alertXml("CannotDivideLandPartialSelection"); + LLNotifications::instance().add("CannotDivideLandPartialSelection"); return; } - gViewerWindow->alertXml("LandDivideWarning", - callbackDivideLand, - this); + LLSD payload; + payload["west_south_border"] = ll_sd_from_vector3d(mWestSouth); + payload["east_north_border"] = ll_sd_from_vector3d(mEastNorth); + + LLNotifications::instance().add("LandDivideWarning", LLSD(), payload, callbackDivideLand); } // static -void LLViewerParcelMgr::callbackDivideLand(S32 option, void* data) +bool LLViewerParcelMgr::callbackDivideLand(const LLSD& notification, const LLSD& response) { - LLViewerParcelMgr* self = (LLViewerParcelMgr*)data; + S32 option = LLNotification::getSelectedOption(notification, response); + LLVector3d west_south_d = ll_vector3d_from_sd(notification["payload"]["west_south_border"]); + LLVector3d east_north_d = ll_vector3d_from_sd(notification["payload"]["east_north_border"]); + LLVector3d parcel_center = (west_south_d + east_north_d) / 2.0; - LLVector3d parcel_center = (self->mWestSouth + self->mEastNorth) / 2.0; LLViewerRegion* region = LLWorld::getInstance()->getRegionFromPosGlobal(parcel_center); if (!region) { - gViewerWindow->alertXml("CannotDivideLandNoRegion"); - return; + LLNotifications::instance().add("CannotDivideLandNoRegion"); + return false; } if (0 == option) { - LLVector3 west_south = region->getPosRegionFromGlobal(self->mWestSouth); - LLVector3 east_north = region->getPosRegionFromGlobal(self->mEastNorth); + LLVector3 west_south = region->getPosRegionFromGlobal(west_south_d); + LLVector3 east_north = region->getPosRegionFromGlobal(east_north_d); LLMessageSystem* msg = gMessageSystem; msg->newMessage("ParcelDivide"); @@ -2097,6 +2106,7 @@ void LLViewerParcelMgr::callbackDivideLand(S32 option, void* data) msg->addF32("North", east_north.mV[VY]); msg->sendReliable(region->getHost()); } + return false; } @@ -2104,44 +2114,48 @@ void LLViewerParcelMgr::startJoinLand() { if (!mSelected) { - gViewerWindow->alertXml("CannotJoinLandNothingSelected"); + LLNotifications::instance().add("CannotJoinLandNothingSelected"); return; } if (mCurrentParcelSelection->mWholeParcelSelected) { - gViewerWindow->alertXml("CannotJoinLandEntireParcelSelected"); + LLNotifications::instance().add("CannotJoinLandEntireParcelSelected"); return; } if (!mCurrentParcelSelection->mSelectedMultipleOwners) { - gViewerWindow->alertXml("CannotJoinLandSelection"); + LLNotifications::instance().add("CannotJoinLandSelection"); return; } - gViewerWindow->alertXml("JoinLandWarning", - callbackJoinLand, - this); + LLSD payload; + payload["west_south_border"] = ll_sd_from_vector3d(mWestSouth); + payload["east_north_border"] = ll_sd_from_vector3d(mEastNorth); + + LLNotifications::instance().add("JoinLandWarning", LLSD(), payload, callbackJoinLand); } // static -void LLViewerParcelMgr::callbackJoinLand(S32 option, void* data) +bool LLViewerParcelMgr::callbackJoinLand(const LLSD& notification, const LLSD& response) { - LLViewerParcelMgr* self = (LLViewerParcelMgr*)data; + S32 option = LLNotification::getSelectedOption(notification, response); + LLVector3d west_south_d = ll_vector3d_from_sd(notification["payload"]["west_south_border"]); + LLVector3d east_north_d = ll_vector3d_from_sd(notification["payload"]["east_north_border"]); + LLVector3d parcel_center = (west_south_d + east_north_d) / 2.0; - LLVector3d parcel_center = (self->mWestSouth + self->mEastNorth) / 2.0; LLViewerRegion* region = LLWorld::getInstance()->getRegionFromPosGlobal(parcel_center); if (!region) { - gViewerWindow->alertXml("CannotJoinLandNoRegion"); - return; + LLNotifications::instance().add("CannotJoinLandNoRegion"); + return false; } if (0 == option) { - LLVector3 west_south = region->getPosRegionFromGlobal(self->mWestSouth); - LLVector3 east_north = region->getPosRegionFromGlobal(self->mEastNorth); + LLVector3 west_south = region->getPosRegionFromGlobal(west_south_d); + LLVector3 east_north = region->getPosRegionFromGlobal(east_north_d); LLMessageSystem* msg = gMessageSystem; msg->newMessage("ParcelJoin"); @@ -2155,6 +2169,7 @@ void LLViewerParcelMgr::callbackJoinLand(S32 option, void* data) msg->addF32("North", east_north.mV[VY]); msg->sendReliable(region->getHost()); } + return false; } @@ -2162,19 +2177,19 @@ void LLViewerParcelMgr::startDeedLandToGroup() { if (!mSelected || !mCurrentParcel) { - gViewerWindow->alertXml("CannotDeedLandNothingSelected"); + LLNotifications::instance().add("CannotDeedLandNothingSelected"); return; } if (mRequestResult == PARCEL_RESULT_NO_DATA) { - gViewerWindow->alertXml("CannotDeedLandWaitingForServer"); + LLNotifications::instance().add("CannotDeedLandWaitingForServer"); return; } if (mRequestResult == PARCEL_RESULT_MULTIPLE) { - gViewerWindow->alertXml("CannotDeedLandMultipleSelected"); + LLNotifications::instance().add("CannotDeedLandMultipleSelected"); return; } @@ -2182,7 +2197,7 @@ void LLViewerParcelMgr::startDeedLandToGroup() LLViewerRegion* region = LLWorld::getInstance()->getRegionFromPosGlobal(parcel_center); if (!region) { - gViewerWindow->alertXml("CannotDeedLandNoRegion"); + LLNotifications::instance().add("CannotDeedLandNoRegion"); return; } @@ -2192,9 +2207,9 @@ void LLViewerParcelMgr::startDeedLandToGroup() if((region->getRegionFlags() & REGION_FLAGS_BLOCK_LAND_RESELL) && (mCurrentParcel->getOwnerID() != region->getOwner())) { - LLStringUtil::format_map_t args; - args["[REGION]"] = region->getName(); - gViewerWindow->alertXml("CannotDeedLandNoTransfer", args); + LLSD args; + args["REGION"] = region->getName(); + LLNotifications::instance().add("CannotDeedLandNoTransfer", args); return; } } @@ -2222,13 +2237,15 @@ void LLViewerParcelMgr::reclaimParcel() } // static -void LLViewerParcelMgr::releaseAlertCB(S32 option, void *) +bool LLViewerParcelMgr::releaseAlertCB(const LLSD& notification, const LLSD& response) { + S32 option = LLNotification::getSelectedOption(notification, response); if (option == 0) { // Send the release message, not a force LLViewerParcelMgr::getInstance()->sendParcelRelease(); } + return false; } void LLViewerParcelMgr::buyPass() diff --git a/indra/newview/llviewerparcelmgr.h b/indra/newview/llviewerparcelmgr.h index 4326e07e46..920423cdfa 100644 --- a/indra/newview/llviewerparcelmgr.h +++ b/indra/newview/llviewerparcelmgr.h @@ -110,7 +110,7 @@ public: void selectCollisionParcel(); // Select the parcel at a specific point - LLSafeHandle<LLParcelSelection> selectParcelAt(const LLVector3d& pos_global); + LLParcelSelectionHandle selectParcelAt(const LLVector3d& pos_global); // Take the current rectangle select, and select the parcel contained // within it. @@ -259,7 +259,7 @@ public: static BOOL isParcelModifiableByAgent(const LLParcel* parcelp, U64 group_proxy_power); private: - static void releaseAlertCB(S32 option, void *data); + static bool releaseAlertCB(const LLSD& notification, const LLSD& response); // If the user is claiming land and the current selection // borders a piece of land the user already owns, ask if he @@ -272,12 +272,10 @@ private: // move land from current owner to it's group. void deedLandToGroup(); - static void claimAlertCB(S32 option, void* data); - static void buyAlertCB(S32 option, void* data); - static void deedAlertCB(S32 option, void*); + static bool deedAlertCB(const LLSD& notification, const LLSD& response); - static void callbackDivideLand(S32 option, void* data); - static void callbackJoinLand(S32 option, void* data); + static bool callbackDivideLand(const LLSD& notification, const LLSD& response); + static bool callbackJoinLand(const LLSD& notification, const LLSD& response); //void finishClaim(BOOL user_to_user_sale, U32 join); LLViewerImage* getBlockedImage() const; diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp index c2c3e7e320..50486137c1 100644 --- a/indra/newview/llviewertexteditor.cpp +++ b/indra/newview/llviewertexteditor.cpp @@ -1420,58 +1420,50 @@ void LLViewerTextEditor::openEmbeddedLandmark( LLInventoryItem* item ) void LLViewerTextEditor::openEmbeddedNotecard( LLInventoryItem* item ) { - //if (saved) - //{ - // An LLInventoryItem needs to be in an inventory to be opened. - // This will give the item to the viewer's agent. - // The callback will attempt to open it if its not already opened. copyInventory(item, gInventoryCallbacks.registerCB(mInventoryCallback)); - - //} - //else - //{ - // LLNotecardCopyInfo *info = new LLNotecardCopyInfo(this, item); - // gViewerWindow->alertXml("ConfirmNotecardSave", - // LLViewerTextEditor::onNotecardDialog, (void*)info); - //} } void LLViewerTextEditor::showUnsavedAlertDialog( LLInventoryItem* item ) { - LLNotecardCopyInfo *info = new LLNotecardCopyInfo(this, item); - gViewerWindow->alertXml( "ConfirmNotecardSave", - LLViewerTextEditor::onNotecardDialog, (void*)info); + LLSD payload; + payload["item_id"] = item->getUUID(); + payload["notecard_id"] = mNotecardInventoryID; + LLNotifications::instance().add( "ConfirmNotecardSave", LLSD(), payload, LLViewerTextEditor::onNotecardDialog); } + // static -void LLViewerTextEditor::onNotecardDialog( S32 option, void* userdata ) +bool LLViewerTextEditor::onNotecardDialog(const LLSD& notification, const LLSD& response ) { - LLNotecardCopyInfo *info = (LLNotecardCopyInfo *)userdata; + S32 option = LLNotification::getSelectedOption(notification, response); if( option == 0 ) { // itemptr is deleted by LLPreview::save - LLPointer<LLInventoryItem>* itemptr = new LLPointer<LLInventoryItem>(info->mItem); - LLPreview::save( info->mTextEd->mNotecardInventoryID, itemptr); + LLPointer<LLInventoryItem>* itemptr = new LLPointer<LLInventoryItem>(gInventory.getItem(notification["payload"]["item_id"].asUUID())); + LLPreview::save( notification["payload"]["notecard_id"].asUUID() , itemptr); } + return false; } void LLViewerTextEditor::showCopyToInvDialog( LLInventoryItem* item ) { - LLNotecardCopyInfo *info = new LLNotecardCopyInfo(this, item); - gViewerWindow->alertXml( "ConfirmItemCopy", - LLViewerTextEditor::onCopyToInvDialog, (void*)info); + LLSD payload; + payload["item_id"] = item->getUUID(); + payload["notecard_id"] = mNotecardInventoryID; + LLNotifications::instance().add( "ConfirmItemCopy", LLSD(), payload, + boost::bind(&LLViewerTextEditor::onCopyToInvDialog, this, _1, _2)); } -// static -void LLViewerTextEditor::onCopyToInvDialog( S32 option, void* userdata ) +bool LLViewerTextEditor::onCopyToInvDialog(const LLSD& notification, const LLSD& response) { - LLNotecardCopyInfo *info = (LLNotecardCopyInfo *)userdata; + S32 option = LLNotification::getSelectedOption(notification, response); if( 0 == option ) { - info->mTextEd->copyInventory(info->mItem); + LLInventoryItem* itemp = gInventory.getItem(notification["payload"]["item_id"].asUUID()); + copyInventory(itemp); } - delete info; + return false; } diff --git a/indra/newview/llviewertexteditor.h b/indra/newview/llviewertexteditor.h index 7ce28fc60a..2e1c0f1d86 100644 --- a/indra/newview/llviewertexteditor.h +++ b/indra/newview/llviewertexteditor.h @@ -113,8 +113,8 @@ private: void showCopyToInvDialog( LLInventoryItem* item ); void showUnsavedAlertDialog( LLInventoryItem* item ); - static void onCopyToInvDialog( S32 option, void* userdata ); - static void onNotecardDialog( S32 option, void* userdata ); + bool onCopyToInvDialog(const LLSD& notification, const LLSD& response ); + static bool onNotecardDialog(const LLSD& notification, const LLSD& response ); LLPointer<LLInventoryItem> mDragItem; BOOL mDragItemSaved; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 48b4a79afa..a129fac47b 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -182,6 +182,9 @@ #include "llviewerjoystick.h" #include "llviewernetwork.h" +#include "llfloatertest.h" // HACK! +#include "llfloaternotificationsconsole.h" + #if LL_WINDOWS #include <tchar.h> // For Unicode conversion methods #endif @@ -246,6 +249,7 @@ std::string LLViewerWindow::sMovieBaseName; extern void toggle_debug_menus(void*); + //////////////////////////////////////////////////////////////////////////// // // LLDebugText @@ -1421,6 +1425,13 @@ LLViewerWindow::LLViewerWindow( mIsFullscreenChecked(false), mCurrResolutionIndex(0) { + // these are self registering so they don't need to be retained here + new LLNotificationChannel("VW_alerts", "Visible", LLNotificationFilters::filterBy<std::string>(&LLNotification::getType, "alert")); + new LLNotificationChannel("VW_alertmodal", "Visible", LLNotificationFilters::filterBy<std::string>(&LLNotification::getType, "alertmodal")); + + LLNotifications::instance().getChannel("VW_alerts")->connectChanged(&LLViewerWindow::onAlert); + LLNotifications::instance().getChannel("VW_alertmodal")->connectChanged(&LLViewerWindow::onAlert); + // Default to application directory. LLViewerWindow::sSnapshotBaseName = "Snapshot"; LLViewerWindow::sMovieBaseName = "SLmovie"; @@ -1532,8 +1543,6 @@ LLViewerWindow::LLViewerWindow( // Can't have spaces in settings.ini strings, so use underscores instead and convert them. LLStringUtil::replaceChar(mOverlayTitle, '_', ' '); - LLAlertDialog::setDisplayCallback(alertCallback); // call this before calling any modal dialogs - // sync the keyboard's setting with the saved setting gSavedSettings.getControl("NumpadControl")->firePropertyChanged(); @@ -2179,7 +2188,7 @@ void LLViewerWindow::setNormalControlsVisible( BOOL visible ) void LLViewerWindow::setMenuBackgroundColor(bool god_mode, bool dev_grid) { - LLStringUtil::format_map_t args; + LLSD args; LLColor4 new_bg_color; if(god_mode && LLViewerLogin::getInstance()->isInProductionGrid()) @@ -2232,12 +2241,6 @@ void LLViewerWindow::draw() stop_glerror(); LLUI::setLineWidth(1.f); - //popup alerts from the UI - LLAlertInfo alert; - while (LLPanel::nextAlert(alert)) - { - alertXml(alert.mLabel, alert.mArgs); - } LLUI::setLineWidth(1.f); // Reset any left-over transforms @@ -2421,6 +2424,15 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask) } } + // Debugging view for unified notifications + if ((MASK_SHIFT & mask) + && (MASK_CONTROL & mask) + && ('N' == key || 'n' == key)) + { + LLFloaterNotificationConsole::showInstance(); + return TRUE; + } + // handle escape key //if (key == KEY_ESCAPE && mask == MASK_NONE) //{ @@ -4909,10 +4921,10 @@ BOOL LLViewerWindow::changeDisplaySettings(BOOL fullscreen, LLCoordScreen size, if (!result_first_try) { - LLStringUtil::format_map_t args; - args["[RESX]"] = llformat("%d",size.mX); - args["[RESY]"] = llformat("%d",size.mY); - alertXml("ResolutionSwitchFail", args); + LLSD args; + args["RESX"] = llformat("%d",size.mX); + args["RESY"] = llformat("%d",size.mY); + LLNotifications::instance().add("ResolutionSwitchFail", args); size = old_size; // for reshape below } @@ -5027,72 +5039,18 @@ S32 LLViewerWindow::getChatConsoleBottomPad() //---------------------------------------------------------------------------- -// static -bool LLViewerWindow::alertCallback(S32 modal) -{ - if (gNoRender) - { - return false; - } - else - { -// if (modal) // we really always want to take you out of mouselook - { - // If we're in mouselook, the mouse is hidden and so the user can't click - // the dialog buttons. In that case, change to First Person instead. - if( gAgent.cameraMouselook() ) - { - gAgent.changeCameraToDefault(); - } - } - return true; - } -} - -LLAlertDialog* LLViewerWindow::alertXml(const std::string& xml_filename, - LLAlertDialog::alert_callback_t callback, void* user_data) -{ - LLStringUtil::format_map_t args; - return alertXml( xml_filename, args, callback, user_data ); -} -LLAlertDialog* LLViewerWindow::alertXml(const std::string& xml_filename, const LLStringUtil::format_map_t& args, - LLAlertDialog::alert_callback_t callback, void* user_data) +//static +bool LLViewerWindow::onAlert(const LLSD& notify) { - if (gNoRender) - { - llinfos << "Alert: " << xml_filename << llendl; - if (callback) - { - callback(-1, user_data); - } - return NULL; - } + LLNotificationPtr notification = LLNotifications::instance().find(notify["id"].asUUID()); - // If we're in mouselook, the mouse is hidden and so the user can't click - // the dialog buttons. In that case, change to First Person instead. - if( gAgent.cameraMouselook() ) - { - gAgent.changeCameraToDefault(); - } - - // Note: object adds, removes, and destroys itself. - return LLAlertDialog::showXml( xml_filename, args, callback, user_data ); -} - -LLAlertDialog* LLViewerWindow::alertXmlEditText(const std::string& xml_filename, const LLStringUtil::format_map_t& args, - LLAlertDialog::alert_callback_t callback, void* user_data, - LLAlertDialog::alert_text_callback_t text_callback, void *text_data, - const LLStringUtil::format_map_t& edit_args, BOOL draw_asterixes) -{ if (gNoRender) { - llinfos << "Alert: " << xml_filename << llendl; - if (callback) - { - callback(-1, user_data); - } - return NULL; + llinfos << "Alert: " << notification->getName() << llendl; + notification->respond(LLSD::emptyMap()); + LLNotifications::instance().cancel(notification); + return false; } // If we're in mouselook, the mouse is hidden and so the user can't click @@ -5101,20 +5059,7 @@ LLAlertDialog* LLViewerWindow::alertXmlEditText(const std::string& xml_filename, { gAgent.changeCameraToDefault(); } - - // Note: object adds, removes, and destroys itself. - LLAlertDialog* alert = LLAlertDialog::createXml( xml_filename, args, callback, user_data ); - if (alert) - { - if (text_callback) - { - alert->setEditTextCallback(text_callback, text_data); - } - alert->setEditTextArgs(edit_args); - alert->setDrawAsterixes(draw_asterixes); - alert->show(); - } - return alert; + return false; } //////////////////////////////////////////////////////////////////////////// diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index 6309cec819..d6c27a31bc 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -47,6 +47,7 @@ #include "lltimer.h" #include "llstat.h" #include "llalertdialog.h" +#include "llnotifications.h" class LLView; class LLViewerObject; @@ -353,20 +354,10 @@ public: void drawPickBuffer() const; - LLAlertDialog* alertXml(const std::string& xml_filename, - LLAlertDialog::alert_callback_t callback = NULL, void* user_data = NULL); - LLAlertDialog* alertXml(const std::string& xml_filename, const LLStringUtil::format_map_t& args, - LLAlertDialog::alert_callback_t callback = NULL, void* user_data = NULL); - LLAlertDialog* alertXmlEditText(const std::string& xml_filename, const LLStringUtil::format_map_t& args, - LLAlertDialog::alert_callback_t callback, void* user_data, - LLAlertDialog::alert_text_callback_t text_callback, void *text_data, - const LLStringUtil::format_map_t& edit_args = LLStringUtil::format_map_t(), - BOOL draw_asterixes = FALSE); - - static bool alertCallback(S32 modal); - private: bool shouldShowToolTipFor(LLMouseHandler *mh); + static bool onAlert(const LLSD& notify); + void switchToolByMask(MASK mask); void destroyWindow(); void drawMouselookInstructions(); diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp index d416ae5bf6..d644ad5085 100644 --- a/indra/newview/llvograss.cpp +++ b/indra/newview/llvograss.cpp @@ -109,12 +109,6 @@ void LLVOGrass::updateSpecies() } -void alert_done(S32 option, void* user_data) -{ - return; -} - - void LLVOGrass::initClass() { LLVector3 pos(0.0f, 0.0f, 0.0f); @@ -224,9 +218,9 @@ void LLVOGrass::initClass() if (!have_all_grass) { - LLStringUtil::format_map_t args; - args["[SPECIES]"] = err; - gViewerWindow->alertXml("ErrorUndefinedGrasses", args, alert_done ); + LLSD args; + args["SPECIES"] = err; + LLNotifications::instance().add("ErrorUndefinedGrasses", args); } for (S32 i = 0; i < GRASS_MAX_BLADES; ++i) diff --git a/indra/newview/llvoiceclient.cpp b/indra/newview/llvoiceclient.cpp index 8b1eba11a0..fb28420715 100644 --- a/indra/newview/llvoiceclient.cpp +++ b/indra/newview/llvoiceclient.cpp @@ -4188,7 +4188,7 @@ class LLViewerRequiredVoiceVersion : public LLHTTPNode if (!sAlertedUser) { //sAlertedUser = TRUE; - gViewerWindow->alertXml("VoiceVersionMismatch"); + LLNotifications::instance().add("VoiceVersionMismatch"); gSavedSettings.setBOOL("EnableVoiceChat", FALSE); // toggles listener } } diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp index 7e3b96eb8f..486ecb82e3 100644 --- a/indra/newview/llvotree.cpp +++ b/indra/newview/llvotree.cpp @@ -253,9 +253,9 @@ void LLVOTree::initClass() if (!have_all_trees) { - LLStringUtil::format_map_t args; - args["[SPECIES]"] = err; - gViewerWindow->alertXml("ErrorUndefinedTrees", args ); + LLSD args; + args["SPECIES"] = err; + LLNotifications::instance().add("ErrorUndefinedTrees", args); } }; diff --git a/indra/newview/llwearable.cpp b/indra/newview/llwearable.cpp index ef077101e9..c473fed04a 100644 --- a/indra/newview/llwearable.cpp +++ b/indra/newview/llwearable.cpp @@ -867,9 +867,9 @@ void LLWearable::saveNewAsset() std::string buffer = llformat("Unable to save '%s' to wearable file.", mName.c_str()); llwarns << buffer << llendl; - LLStringUtil::format_map_t args; - args["[NAME]"] = mName; - gViewerWindow->alertXml("CannotSaveWearableOutOfSpace", args); + LLSD args; + args["NAME"] = mName; + LLNotifications::instance().add("CannotSaveWearableOutOfSpace", args); return; } @@ -915,9 +915,9 @@ void LLWearable::onSaveNewAssetComplete(const LLUUID& new_asset_id, void* userda { std::string buffer = llformat("Unable to save %s to central asset store.", type_name.c_str()); llwarns << buffer << " Status: " << status << llendl; - LLStringUtil::format_map_t args; - args["[NAME]"] = type_name; - gViewerWindow->alertXml("CannotSaveToAssetStore", args); + LLSD args; + args["NAME"] = type_name; + LLNotifications::instance().add("CannotSaveToAssetStore", args); } // Delete temp file diff --git a/indra/newview/llwearablelist.cpp b/indra/newview/llwearablelist.cpp index a32c43302d..70719b827c 100644 --- a/indra/newview/llwearablelist.cpp +++ b/indra/newview/llwearablelist.cpp @@ -149,27 +149,27 @@ void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID { // Fail break; - } + } default: - { + { static const S32 MAX_RETRIES = 3; if (data->mRetries < MAX_RETRIES) { - // Try again + // Try again data->mRetries++; - gAssetStorage->getAssetData(uuid, - data->mAssetType, - LLWearableList::processGetAssetReply, - userdata); // re-use instead of deleting. - return; - } + gAssetStorage->getAssetData(uuid, + data->mAssetType, + LLWearableList::processGetAssetReply, + userdata); // re-use instead of deleting. + return; + } else { // Fail break; } } - } + } } if (wearable) // success @@ -180,17 +180,17 @@ void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID } else { - LLStringUtil::format_map_t args; + LLSD args; // *TODO:translate - args["[TYPE]"] = LLAssetType::lookupHumanReadable(data->mAssetType); + args["TYPE"] = LLAssetType::lookupHumanReadable(data->mAssetType); if (data->mName.empty()) { - LLNotifyBox::showXml("FailedToFindWearableUnnamed", args); + LLNotifications::instance().add("FailedToFindWearableUnnamed", args); } else { - args["[DESC]"] = data->mName; - LLNotifyBox::showXml("FailedToFindWearable", args); + args["DESC"] = data->mName; + LLNotifications::instance().add("FailedToFindWearable", args); } } // Always call callback; wearable will be NULL if we failed diff --git a/indra/newview/llwldaycycle.cpp b/indra/newview/llwldaycycle.cpp index 1abf760580..9f8ddc1029 100644 --- a/indra/newview/llwldaycycle.cpp +++ b/indra/newview/llwldaycycle.cpp @@ -82,9 +82,9 @@ void LLWLDayCycle::loadDayCycle(const std::string & fileName) if(!success) { // alert the user - LLStringUtil::format_map_t args; - args["[SKY]"] = day_data[i][1].asString(); - gViewerWindow->alertXml("WLMissingSky", args); + LLSD args; + args["SKY"] = day_data[i][1].asString(); + LLNotifications::instance().add("WLMissingSky", args); continue; } diff --git a/indra/newview/llxmlrpctransaction.cpp b/indra/newview/llxmlrpctransaction.cpp index d9c6b6c58a..7fbcaf6c21 100644 --- a/indra/newview/llxmlrpctransaction.cpp +++ b/indra/newview/llxmlrpctransaction.cpp @@ -417,28 +417,10 @@ void LLXMLRPCTransaction::Impl::setStatus(Status status, mStatusMessage = "Despite our best efforts, something unexpected has gone wrong. \n" " \n" - "Please check www.secondlife.com/status \n" + "Please check secondlife.com/status \n" "to see if there is a known problem with the service."; mStatusURI = "http://secondlife.com/status/"; - /* - mStatusMessage = - "Despite our best efforts, something unexpected has gone wrong.\n" - "Please go to the Support section of the SecondLife.com web site\n" - "and report the problem. If possible, include your SecondLife.log\n" - "file from:\n" -#if LL_WINDOWS - "C:\\Documents and Settings\\<name>\\Application Data\\SecondLife\\logs\n" -#elif LL_DARWIN - "~/Library/Application Support/SecondLife/logs\n" -#elif LL_LINUX - "~/.secondlife/logs\n" -#else -#error "Need platform here." -#endif - "Thank you."; - mStatusURI = "http://secondlife.com/community/support.php"; - */ } } } |