Annotation of /trunk/linden/indra/newview/llgivemoney.cpp
Parent Directory
|
Revision Log
Revision 61 - (view) (download)
| 1 : | mjm | 57 | /** |
| 2 : | * @file llgivemoney.cpp | ||
| 3 : | * @author Aaron Brashears, Kelly Washington, James Cook | ||
| 4 : | * @brief Implementation of the LLFloaterPay class. | ||
| 5 : | * | ||
| 6 : | * $LicenseInfo:firstyear=2002&license=viewergpl$ | ||
| 7 : | * | ||
| 8 : | * Copyright (c) 2002-2008, Linden Research, Inc. | ||
| 9 : | * | ||
| 10 : | * Second Life Viewer Source Code | ||
| 11 : | * The source code in this file ("Source Code") is provided by Linden Lab | ||
| 12 : | * to you under the terms of the GNU General Public License, version 2.0 | ||
| 13 : | * ("GPL"), unless you have obtained a separate licensing agreement | ||
| 14 : | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
| 15 : | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
| 16 : | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
| 17 : | * | ||
| 18 : | * There are special exceptions to the terms and conditions of the GPL as | ||
| 19 : | * it is applied to this Source Code. View the full text of the exception | ||
| 20 : | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
| 21 : | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
| 22 : | * | ||
| 23 : | * By copying, modifying or distributing this software, you acknowledge | ||
| 24 : | * that you have read and understood your obligations described above, | ||
| 25 : | * and agree to abide by those obligations. | ||
| 26 : | * | ||
| 27 : | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
| 28 : | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
| 29 : | * COMPLETENESS OR PERFORMANCE. | ||
| 30 : | * $/LicenseInfo$ | ||
| 31 : | */ | ||
| 32 : | |||
| 33 : | #include "llviewerprecompiledheaders.h" | ||
| 34 : | |||
| 35 : | #include "llgivemoney.h" | ||
| 36 : | |||
| 37 : | #include "message.h" | ||
| 38 : | |||
| 39 : | #include "llagent.h" | ||
| 40 : | #include "llresmgr.h" | ||
| 41 : | #include "lltextbox.h" | ||
| 42 : | #include "lllineeditor.h" | ||
| 43 : | #include "llmutelist.h" | ||
| 44 : | #include "llfloaterreporter.h" | ||
| 45 : | #include "llviewerobject.h" | ||
| 46 : | #include "llviewerobjectlist.h" | ||
| 47 : | #include "llviewerregion.h" | ||
| 48 : | #include "llviewerwindow.h" | ||
| 49 : | #include "llbutton.h" | ||
| 50 : | #include "llselectmgr.h" | ||
| 51 : | #include "lltransactiontypes.h" | ||
| 52 : | #include "lluictrlfactory.h" | ||
| 53 : | |||
| 54 : | ///---------------------------------------------------------------------------- | ||
| 55 : | /// Local function declarations, constants, enums, and typedefs | ||
| 56 : | ///---------------------------------------------------------------------------- | ||
| 57 : | |||
| 58 : | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 59 : | // Class LLGiveMoneyInfo | ||
| 60 : | // | ||
| 61 : | // A small class used to track callback information | ||
| 62 : | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 63 : | |||
| 64 : | struct LLGiveMoneyInfo | ||
| 65 : | { | ||
| 66 : | LLFloaterPay* mFloater; | ||
| 67 : | S32 mAmount; | ||
| 68 : | LLGiveMoneyInfo(LLFloaterPay* floater, S32 amount) : | ||
| 69 : | mFloater(floater), mAmount(amount){} | ||
| 70 : | }; | ||
| 71 : | |||
| 72 : | ///---------------------------------------------------------------------------- | ||
| 73 : | /// Class LLFloaterPay | ||
| 74 : | ///---------------------------------------------------------------------------- | ||
| 75 : | |||
| 76 : | S32 LLFloaterPay::sLastAmount = 0; | ||
| 77 : | const S32 MAX_AMOUNT_LENGTH = 10; | ||
| 78 : | const S32 FASTPAY_BUTTON_WIDTH = 80; | ||
| 79 : | |||
| 80 : | // Default constructor | ||
| 81 : | LLFloaterPay::LLFloaterPay(const std::string& name, | ||
| 82 : | money_callback callback, | ||
| 83 : | const LLUUID& uuid, | ||
| 84 : | BOOL target_is_object) : | ||
| 85 : | LLFloater(name, std::string("FloaterPayRectB"), LLStringUtil::null, RESIZE_NO, | ||
| 86 : | DEFAULT_MIN_WIDTH, DEFAULT_MIN_HEIGHT, DRAG_ON_TOP, | ||
| 87 : | MINIMIZE_NO, CLOSE_YES), | ||
| 88 : | mCallbackData(), | ||
| 89 : | mCallback(callback), | ||
| 90 : | mObjectNameText(NULL), | ||
| 91 : | mTargetUUID(uuid), | ||
| 92 : | mTargetIsObject(target_is_object), | ||
| 93 : | mTargetIsGroup(FALSE) | ||
| 94 : | { | ||
| 95 : | if (target_is_object) | ||
| 96 : | { | ||
| 97 : | LLUICtrlFactory::getInstance()->buildFloater(this,"floater_pay_object.xml"); | ||
| 98 : | mObjectSelection = LLSelectMgr::getInstance()->getEditSelection(); | ||
| 99 : | } | ||
| 100 : | else | ||
| 101 : | { | ||
| 102 : | LLUICtrlFactory::getInstance()->buildFloater(this,"floater_pay.xml"); | ||
| 103 : | } | ||
| 104 : | |||
| 105 : | |||
| 106 : | S32 i =0; | ||
| 107 : | |||
| 108 : | LLGiveMoneyInfo* info = new LLGiveMoneyInfo(this, PAY_BUTTON_DEFAULT_0); | ||
| 109 : | mCallbackData.push_back(info); | ||
| 110 : | |||
| 111 : | childSetAction("fastpay 1",&LLFloaterPay::onGive,info); | ||
| 112 : | childSetVisible("fastpay 1", FALSE); | ||
| 113 : | |||
| 114 : | mQuickPayButton[i] = getChild<LLButton>("fastpay 1"); | ||
| 115 : | mQuickPayInfo[i] = info; | ||
| 116 : | ++i; | ||
| 117 : | |||
| 118 : | info = new LLGiveMoneyInfo(this, PAY_BUTTON_DEFAULT_1); | ||
| 119 : | mCallbackData.push_back(info); | ||
| 120 : | |||
| 121 : | childSetAction("fastpay 5",&LLFloaterPay::onGive,info); | ||
| 122 : | childSetVisible("fastpay 5", FALSE); | ||
| 123 : | |||
| 124 : | mQuickPayButton[i] = getChild<LLButton>("fastpay 5"); | ||
| 125 : | mQuickPayInfo[i] = info; | ||
| 126 : | ++i; | ||
| 127 : | |||
| 128 : | info = new LLGiveMoneyInfo(this, PAY_BUTTON_DEFAULT_2); | ||
| 129 : | mCallbackData.push_back(info); | ||
| 130 : | |||
| 131 : | childSetAction("fastpay 10",&LLFloaterPay::onGive,info); | ||
| 132 : | childSetVisible("fastpay 10", FALSE); | ||
| 133 : | |||
| 134 : | mQuickPayButton[i] = getChild<LLButton>("fastpay 10"); | ||
| 135 : | mQuickPayInfo[i] = info; | ||
| 136 : | ++i; | ||
| 137 : | |||
| 138 : | info = new LLGiveMoneyInfo(this, PAY_BUTTON_DEFAULT_3); | ||
| 139 : | mCallbackData.push_back(info); | ||
| 140 : | |||
| 141 : | childSetAction("fastpay 20",&LLFloaterPay::onGive,info); | ||
| 142 : | childSetVisible("fastpay 20", FALSE); | ||
| 143 : | |||
| 144 : | mQuickPayButton[i] = getChild<LLButton>("fastpay 20"); | ||
| 145 : | mQuickPayInfo[i] = info; | ||
| 146 : | ++i; | ||
| 147 : | |||
| 148 : | |||
| 149 : | childSetVisible("amount text", FALSE); | ||
| 150 : | |||
| 151 : | std::string last_amount; | ||
| 152 : | if(sLastAmount > 0) | ||
| 153 : | { | ||
| 154 : | last_amount = llformat("%d", sLastAmount); | ||
| 155 : | } | ||
| 156 : | |||
| 157 : | childSetVisible("amount", FALSE); | ||
| 158 : | |||
| 159 : | childSetKeystrokeCallback("amount", &LLFloaterPay::onKeystroke, this); | ||
| 160 : | childSetText("amount", last_amount); | ||
| 161 : | childSetPrevalidate("amount", LLLineEditor::prevalidateNonNegativeS32); | ||
| 162 : | |||
| 163 : | info = new LLGiveMoneyInfo(this, 0); | ||
| 164 : | mCallbackData.push_back(info); | ||
| 165 : | |||
| 166 : | childSetAction("pay btn",&LLFloaterPay::onGive,info); | ||
| 167 : | setDefaultBtn("pay btn"); | ||
| 168 : | childSetVisible("pay btn", FALSE); | ||
| 169 : | childSetEnabled("pay btn", (sLastAmount > 0)); | ||
| 170 : | |||
| 171 : | childSetAction("cancel btn",&LLFloaterPay::onCancel,this); | ||
| 172 : | |||
| 173 : | center(); | ||
| 174 : | open(); /*Flawfinder: ignore*/ | ||
| 175 : | } | ||
| 176 : | |||
| 177 : | // Destroys the object | ||
| 178 : | LLFloaterPay::~LLFloaterPay() | ||
| 179 : | { | ||
| 180 : | std::for_each(mCallbackData.begin(), mCallbackData.end(), DeletePointer()); | ||
| 181 : | |||
| 182 : | // Clean up if we are still waiting for a name. | ||
| 183 : | gCacheName->cancelCallback(mTargetUUID,onCacheOwnerName,this); | ||
| 184 : | } | ||
| 185 : | |||
| 186 : | // static | ||
| 187 : | void LLFloaterPay::processPayPriceReply(LLMessageSystem* msg, void **userdata) | ||
| 188 : | { | ||
| 189 : | LLFloaterPay* self = (LLFloaterPay*)userdata; | ||
| 190 : | if (self) | ||
| 191 : | { | ||
| 192 : | S32 price; | ||
| 193 : | LLUUID target; | ||
| 194 : | |||
| 195 : | msg->getUUIDFast(_PREHASH_ObjectData,_PREHASH_ObjectID,target); | ||
| 196 : | if (target != self->mTargetUUID) | ||
| 197 : | { | ||
| 198 : | // This is a message for a different object's pay info | ||
| 199 : | return; | ||
| 200 : | } | ||
| 201 : | |||
| 202 : | msg->getS32Fast(_PREHASH_ObjectData,_PREHASH_DefaultPayPrice,price); | ||
| 203 : | |||
| 204 : | if (PAY_PRICE_HIDE == price) | ||
| 205 : | { | ||
| 206 : | self->childSetVisible("amount", FALSE); | ||
| 207 : | self->childSetVisible("pay btn", FALSE); | ||
| 208 : | self->childSetVisible("amount text", FALSE); | ||
| 209 : | } | ||
| 210 : | else if (PAY_PRICE_DEFAULT == price) | ||
| 211 : | { | ||
| 212 : | self->childSetVisible("amount", TRUE); | ||
| 213 : | self->childSetVisible("pay btn", TRUE); | ||
| 214 : | self->childSetVisible("amount text", TRUE); | ||
| 215 : | } | ||
| 216 : | else | ||
| 217 : | { | ||
| 218 : | // PAY_PRICE_HIDE and PAY_PRICE_DEFAULT are negative values | ||
| 219 : | // So we take the absolute value here after we have checked for those cases | ||
| 220 : | |||
| 221 : | self->childSetVisible("amount", TRUE); | ||
| 222 : | self->childSetVisible("pay btn", TRUE); | ||
| 223 : | self->childSetEnabled("pay btn", TRUE); | ||
| 224 : | self->childSetVisible("amount text", TRUE); | ||
| 225 : | |||
| 226 : | self->childSetText("amount", llformat("%d", llabs(price))); | ||
| 227 : | } | ||
| 228 : | |||
| 229 : | S32 num_blocks = msg->getNumberOfBlocksFast(_PREHASH_ButtonData); | ||
| 230 : | S32 i = 0; | ||
| 231 : | if (num_blocks > MAX_PAY_BUTTONS) num_blocks = MAX_PAY_BUTTONS; | ||
| 232 : | |||
| 233 : | S32 max_pay_amount = 0; | ||
| 234 : | S32 padding_required = 0; | ||
| 235 : | |||
| 236 : | for (i=0;i<num_blocks;++i) | ||
| 237 : | { | ||
| 238 : | S32 pay_button; | ||
| 239 : | msg->getS32Fast(_PREHASH_ButtonData,_PREHASH_PayButton,pay_button,i); | ||
| 240 : | if (pay_button > 0) | ||
| 241 : | { | ||
| 242 : | std::string button_str = "L$"; | ||
| 243 : | button_str += LLResMgr::getInstance()->getMonetaryString( pay_button ); | ||
| 244 : | |||
| 245 : | self->mQuickPayButton[i]->setLabelSelected(button_str); | ||
| 246 : | self->mQuickPayButton[i]->setLabelUnselected(button_str); | ||
| 247 : | self->mQuickPayButton[i]->setVisible(TRUE); | ||
| 248 : | self->mQuickPayInfo[i]->mAmount = pay_button; | ||
| 249 : | self->childSetVisible("fastpay text",TRUE); | ||
| 250 : | |||
| 251 : | if ( pay_button > max_pay_amount ) | ||
| 252 : | { | ||
| 253 : | max_pay_amount = pay_button; | ||
| 254 : | } | ||
| 255 : | } | ||
| 256 : | else | ||
| 257 : | { | ||
| 258 : | self->mQuickPayButton[i]->setVisible(FALSE); | ||
| 259 : | } | ||
| 260 : | } | ||
| 261 : | |||
| 262 : | // build a string containing the maximum value and calc nerw button width from it. | ||
| 263 : | std::string balance_str = "L$"; | ||
| 264 : | balance_str += LLResMgr::getInstance()->getMonetaryString( max_pay_amount ); | ||
| 265 : | const LLFontGL* font = LLResMgr::getInstance()->getRes(LLFONT_SANSSERIF); | ||
| 266 : | S32 new_button_width = font->getWidth( std::string(balance_str)); | ||
| 267 : | new_button_width += ( 12 + 12 ); // padding | ||
| 268 : | |||
| 269 : | // dialong is sized for 2 digit pay amounts - larger pay values need to be scaled | ||
| 270 : | const S32 threshold = 100000; | ||
| 271 : | if ( max_pay_amount >= threshold ) | ||
| 272 : | { | ||
| 273 : | S32 num_digits_threshold = (S32)log10((double)threshold) + 1; | ||
| 274 : | S32 num_digits_max = (S32)log10((double)max_pay_amount) + 1; | ||
| 275 : | |||
| 276 : | // calculate the extra width required by 2 buttons with max amount and some commas | ||
| 277 : | padding_required = ( num_digits_max - num_digits_threshold + ( num_digits_max / 3 ) ) * font->getWidth( std::string("0") ); | ||
| 278 : | }; | ||
| 279 : | |||
| 280 : | // change in button width | ||
| 281 : | S32 button_delta = new_button_width - FASTPAY_BUTTON_WIDTH; | ||
| 282 : | if ( button_delta < 0 ) | ||
| 283 : | button_delta = 0; | ||
| 284 : | |||
| 285 : | // now we know the maximum amount, we can resize all the buttons to be | ||
| 286 : | for (i=0;i<num_blocks;++i) | ||
| 287 : | { | ||
| 288 : | LLRect r; | ||
| 289 : | r = self->mQuickPayButton[i]->getRect(); | ||
| 290 : | |||
| 291 : | // RHS button colum needs to move further because LHS changed too | ||
| 292 : | if ( i % 2 ) | ||
| 293 : | { | ||
| 294 : | r.setCenterAndSize( r.getCenterX() + ( button_delta * 3 ) / 2 , | ||
| 295 : | r.getCenterY(), | ||
| 296 : | r.getWidth() + button_delta, | ||
| 297 : | r.getHeight() ); | ||
| 298 : | } | ||
| 299 : | else | ||
| 300 : | { | ||
| 301 : | r.setCenterAndSize( r.getCenterX() + button_delta / 2, | ||
| 302 : | r.getCenterY(), | ||
| 303 : | r.getWidth() + button_delta, | ||
| 304 : | r.getHeight() ); | ||
| 305 : | } | ||
| 306 : | self->mQuickPayButton[i]->setRect( r ); | ||
| 307 : | } | ||
| 308 : | |||
| 309 : | for (i=num_blocks;i<MAX_PAY_BUTTONS;++i) | ||
| 310 : | { | ||
| 311 : | self->mQuickPayButton[i]->setVisible(FALSE); | ||
| 312 : | } | ||
| 313 : | |||
| 314 : | self->reshape( self->getRect().getWidth() + padding_required, self->getRect().getHeight(), FALSE ); | ||
| 315 : | } | ||
| 316 : | msg->setHandlerFunc("PayPriceReply",NULL,NULL); | ||
| 317 : | } | ||
| 318 : | |||
| 319 : | // static | ||
| 320 : | void LLFloaterPay::payViaObject(money_callback callback, const LLUUID& object_id) | ||
| 321 : | { | ||
| 322 : | LLViewerObject* object = gObjectList.findObject(object_id); | ||
| 323 : | if (!object) return; | ||
| 324 : | |||
| 325 : | LLFloaterPay *floater = new LLFloaterPay("Give L$", callback, object_id, TRUE); | ||
| 326 : | if (!floater) return; | ||
| 327 : | |||
| 328 : | LLSelectNode* node = floater->mObjectSelection->getFirstRootNode(); | ||
| 329 : | if (!node) | ||
| 330 : | { | ||
| 331 : | //FIXME: notify user object no longer exists | ||
| 332 : | floater->close(); | ||
| 333 : | return; | ||
| 334 : | } | ||
| 335 : | |||
| 336 : | LLHost target_region = object->getRegion()->getHost(); | ||
| 337 : | |||
| 338 : | LLMessageSystem* msg = gMessageSystem; | ||
| 339 : | msg->newMessageFast(_PREHASH_RequestPayPrice); | ||
| 340 : | msg->nextBlockFast(_PREHASH_ObjectData); | ||
| 341 : | msg->addUUIDFast(_PREHASH_ObjectID, object_id); | ||
| 342 : | msg->sendReliable(target_region); | ||
| 343 : | msg->setHandlerFuncFast(_PREHASH_PayPriceReply, processPayPriceReply,(void **)floater); | ||
| 344 : | |||
| 345 : | LLUUID owner_id; | ||
| 346 : | BOOL is_group = FALSE; | ||
| 347 : | node->mPermissions->getOwnership(owner_id, is_group); | ||
| 348 : | |||
| 349 : | floater->childSetText("object_name_text",node->mName); | ||
| 350 : | |||
| 351 : | floater->finishPayUI(owner_id, is_group); | ||
| 352 : | } | ||
| 353 : | |||
| 354 : | void LLFloaterPay::payDirectly(money_callback callback, | ||
| 355 : | const LLUUID& target_id, | ||
| 356 : | BOOL is_group) | ||
| 357 : | { | ||
| 358 : | LLFloaterPay *floater = new LLFloaterPay("Give L$", callback, target_id, FALSE); | ||
| 359 : | if (!floater) return; | ||
| 360 : | |||
| 361 : | floater->childSetVisible("amount", TRUE); | ||
| 362 : | floater->childSetVisible("pay btn", TRUE); | ||
| 363 : | floater->childSetVisible("amount text", TRUE); | ||
| 364 : | |||
| 365 : | floater->childSetVisible("fastpay text",TRUE); | ||
| 366 : | for(S32 i=0;i<MAX_PAY_BUTTONS;++i) | ||
| 367 : | { | ||
| 368 : | floater->mQuickPayButton[i]->setVisible(TRUE); | ||
| 369 : | } | ||
| 370 : | |||
| 371 : | floater->finishPayUI(target_id, is_group); | ||
| 372 : | } | ||
| 373 : | |||
| 374 : | void LLFloaterPay::finishPayUI(const LLUUID& target_id, BOOL is_group) | ||
| 375 : | { | ||
| 376 : | gCacheName->get(target_id, is_group, onCacheOwnerName, (void*)this); | ||
| 377 : | |||
| 378 : | // Make sure the amount field has focus | ||
| 379 : | |||
| 380 : | childSetFocus("amount", TRUE); | ||
| 381 : | |||
| 382 : | LLLineEditor* amount = getChild<LLLineEditor>("amount"); | ||
| 383 : | amount->selectAll(); | ||
| 384 : | mTargetIsGroup = is_group; | ||
| 385 : | } | ||
| 386 : | |||
| 387 : | // static | ||
| 388 : | void LLFloaterPay::onCacheOwnerName(const LLUUID& owner_id, | ||
| 389 : | const std::string& firstname, | ||
| 390 : | const std::string& lastname, | ||
| 391 : | BOOL is_group, | ||
| 392 : | void* userdata) | ||
| 393 : | { | ||
| 394 : | LLFloaterPay* self = (LLFloaterPay*)userdata; | ||
| 395 : | if (!self) return; | ||
| 396 : | |||
| 397 : | if (is_group) | ||
| 398 : | { | ||
| 399 : | self->childSetVisible("payee_group",true); | ||
| 400 : | self->childSetVisible("payee_resident",false); | ||
| 401 : | } | ||
| 402 : | else | ||
| 403 : | { | ||
| 404 : | self->childSetVisible("payee_group",false); | ||
| 405 : | self->childSetVisible("payee_resident",true); | ||
| 406 : | } | ||
| 407 : | |||
| 408 : | self->childSetTextArg("payee_name", "[FIRST]", firstname); | ||
| 409 : | self->childSetTextArg("payee_name", "[LAST]", lastname); | ||
| 410 : | } | ||
| 411 : | |||
| 412 : | // static | ||
| 413 : | void LLFloaterPay::onCancel(void* data) | ||
| 414 : | { | ||
| 415 : | LLFloaterPay* self = reinterpret_cast<LLFloaterPay*>(data); | ||
| 416 : | if(self) | ||
| 417 : | { | ||
| 418 : | self->close(); | ||
| 419 : | } | ||
| 420 : | } | ||
| 421 : | |||
| 422 : | // static | ||
| 423 : | void LLFloaterPay::onKeystroke(LLLineEditor*, void* data) | ||
| 424 : | { | ||
| 425 : | LLFloaterPay* self = reinterpret_cast<LLFloaterPay*>(data); | ||
| 426 : | if(self) | ||
| 427 : | { | ||
| 428 : | // enable the Pay button when amount is non-empty and positive, disable otherwise | ||
| 429 : | std::string amtstr = self->childGetText("amount"); | ||
| 430 : | self->childSetEnabled("pay btn", !amtstr.empty() && atoi(amtstr.c_str()) > 0); | ||
| 431 : | } | ||
| 432 : | } | ||
| 433 : | |||
| 434 : | // static | ||
| 435 : | void LLFloaterPay::onGive(void* data) | ||
| 436 : | { | ||
| 437 : | LLGiveMoneyInfo* info = reinterpret_cast<LLGiveMoneyInfo*>(data); | ||
| 438 : | if(info && info->mFloater) | ||
| 439 : | { | ||
| 440 : | info->mFloater->give(info->mAmount); | ||
| 441 : | info->mFloater->close(); | ||
| 442 : | } | ||
| 443 : | } | ||
| 444 : | |||
| 445 : | void LLFloaterPay::give(S32 amount) | ||
| 446 : | { | ||
| 447 : | if(mCallback) | ||
| 448 : | { | ||
| 449 : | // if the amount is 0, that menas that we should use the | ||
| 450 : | // text field. | ||
| 451 : | if(amount == 0) | ||
| 452 : | { | ||
| 453 : | amount = atoi(childGetText("amount").c_str()); | ||
| 454 : | } | ||
| 455 : | sLastAmount = amount; | ||
| 456 : | |||
| 457 : | // Try to pay an object. | ||
| 458 : | if (mTargetIsObject) | ||
| 459 : | { | ||
| 460 : | LLViewerObject* dest_object = gObjectList.findObject(mTargetUUID); | ||
| 461 : | if(dest_object) | ||
| 462 : | { | ||
| 463 : | LLViewerRegion* region = dest_object->getRegion(); | ||
| 464 : | if (region) | ||
| 465 : | { | ||
| 466 : | // Find the name of the root object | ||
| 467 : | LLSelectNode* node = mObjectSelection->getFirstRootNode(); | ||
| 468 : | std::string object_name; | ||
| 469 : | if (node) | ||
| 470 : | { | ||
| 471 : | object_name = node->mName; | ||
| 472 : | } | ||
| 473 : | S32 tx_type = TRANS_PAY_OBJECT; | ||
| 474 : | if(dest_object->isAvatar()) tx_type = TRANS_GIFT; | ||
| 475 : | mCallback(mTargetUUID, region, amount, FALSE, tx_type, object_name); | ||
| 476 : | mObjectSelection = NULL; | ||
| 477 : | |||
| 478 : | // request the object owner in order to check if the owner needs to be unmuted | ||
| 479 : | LLMessageSystem* msg = gMessageSystem; | ||
| 480 : | msg->newMessageFast(_PREHASH_RequestObjectPropertiesFamily); | ||
| 481 : | msg->nextBlockFast(_PREHASH_AgentData); | ||
| 482 : | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); | ||
| 483 : | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); | ||
| 484 : | msg->nextBlockFast(_PREHASH_ObjectData); | ||
| 485 : | msg->addU32Fast(_PREHASH_RequestFlags, OBJECT_PAY_REQUEST ); | ||
| 486 : | msg->addUUIDFast(_PREHASH_ObjectID, mTargetUUID); | ||
| 487 : | msg->sendReliable( region->getHost() ); | ||
| 488 : | } | ||
| 489 : | } | ||
| 490 : | } | ||
| 491 : | else | ||
| 492 : | { | ||
| 493 : | // just transfer the L$ | ||
| 494 : | mCallback(mTargetUUID, gAgent.getRegion(), amount, mTargetIsGroup, TRANS_GIFT, LLStringUtil::null); | ||
| 495 : | |||
| 496 : | // check if the payee needs to be unmuted | ||
| 497 : | LLMuteList::getInstance()->autoRemove(mTargetUUID, LLMuteList::AR_MONEY); | ||
| 498 : | } | ||
| 499 : | } | ||
| 500 : | } | ||
| 501 : | |||
| 502 : | ///---------------------------------------------------------------------------- | ||
| 503 : | /// Local function definitions | ||
| 504 : | ///---------------------------------------------------------------------------- | ||
| 505 : | |||
| 506 : | |||
| 507 : |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

