aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llpanelclassified.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llpanelclassified.cpp')
-rw-r--r--linden/indra/newview/llpanelclassified.cpp181
1 files changed, 120 insertions, 61 deletions
diff --git a/linden/indra/newview/llpanelclassified.cpp b/linden/indra/newview/llpanelclassified.cpp
index 4d28be5..afaaea2 100644
--- a/linden/indra/newview/llpanelclassified.cpp
+++ b/linden/indra/newview/llpanelclassified.cpp
@@ -17,7 +17,8 @@
17 * There are special exceptions to the terms and conditions of the GPL as 17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception 18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or 19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception 20 * online at
21 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 * 22 *
22 * By copying, modifying or distributing this software, you acknowledge 23 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above, 24 * that you have read and understood your obligations described above,
@@ -71,8 +72,9 @@
71#include "llappviewer.h" // abortQuit() 72#include "llappviewer.h" // abortQuit()
72 73
73const S32 MINIMUM_PRICE_FOR_LISTING = 50; // L$ 74const S32 MINIMUM_PRICE_FOR_LISTING = 50; // L$
75const S32 MATURE_UNDEFINED = -1;
74const S32 MATURE_CONTENT = 1; 76const S32 MATURE_CONTENT = 1;
75const S32 NON_MATURE_CONTENT = 2; 77const S32 PG_CONTENT = 2;
76const S32 DECLINE_TO_STATE = 0; 78const S32 DECLINE_TO_STATE = 0;
77 79
78//static 80//static
@@ -116,7 +118,7 @@ class LLClassifiedTeleportHandler : public LLCommandHandler
116{ 118{
117public: 119public:
118 // don't allow from external browsers because it moves you immediately 120 // don't allow from external browsers because it moves you immediately
119 LLClassifiedTeleportHandler() : LLCommandHandler("classifiedteleport", false) { } 121 LLClassifiedTeleportHandler() : LLCommandHandler("classifiedteleport", true) { }
120 122
121 bool handle(const LLSD& tokens, const LLSD& queryMap) 123 bool handle(const LLSD& tokens, const LLSD& queryMap)
122 { 124 {
@@ -139,8 +141,9 @@ public:
139 const bool from_search = true; 141 const bool from_search = true;
140 LLPanelClassified::sendClassifiedClickMessage(classified_id, "teleport", from_search); 142 LLPanelClassified::sendClassifiedClickMessage(classified_id, "teleport", from_search);
141 // Invoke teleport 143 // Invoke teleport
142 const bool from_external_browser = false; 144 LLWebBrowserCtrl* web = NULL;
143 return LLURLDispatcher::dispatch(url, from_external_browser); 145 const bool trusted_browser = true;
146 return LLURLDispatcher::dispatch(url, web, trusted_browser);
144 } 147 }
145}; 148};
146// Creating the object registers with the dispatcher. 149// Creating the object registers with the dispatcher.
@@ -221,6 +224,7 @@ void LLPanelClassified::reset()
221 mPosGlobal.clearVec(); 224 mPosGlobal.clearVec();
222 225
223 clearCtrls(); 226 clearCtrls();
227 resetDirty();
224} 228}
225 229
226 230
@@ -283,11 +287,11 @@ BOOL LLPanelClassified::postBuild()
283 mMatureCombo->setCurrentByIndex(0); 287 mMatureCombo->setCurrentByIndex(0);
284 mMatureCombo->setCommitCallback(onCommitAny); 288 mMatureCombo->setCommitCallback(onCommitAny);
285 mMatureCombo->setCallbackUserData(this); 289 mMatureCombo->setCallbackUserData(this);
286 if (gAgent.isTeen()) 290 if (gAgent.wantsPGOnly())
287 { 291 {
288 // Teens don't get to set mature flag. JC 292 // Teens don't get to set mature flag. JC
289 mMatureCombo->setVisible(FALSE); 293 mMatureCombo->setVisible(FALSE);
290 mMatureCombo->setCurrentByIndex(NON_MATURE_CONTENT); 294 mMatureCombo->setCurrentByIndex(PG_CONTENT);
291 } 295 }
292 296
293 if (!mInFinder) 297 if (!mInFinder)
@@ -306,6 +310,7 @@ BOOL LLPanelClassified::postBuild()
306 mClickThroughText = getChild<LLTextBox>("click_through_text"); 310 mClickThroughText = getChild<LLTextBox>("click_through_text");
307 } 311 }
308 312
313 resetDirty();
309 return TRUE; 314 return TRUE;
310} 315}
311 316
@@ -316,12 +321,12 @@ BOOL LLPanelClassified::titleIsValid()
316 const std::string& name = mNameEditor->getText(); 321 const std::string& name = mNameEditor->getText();
317 if (name.empty()) 322 if (name.empty())
318 { 323 {
319 gViewerWindow->alertXml("BlankClassifiedName"); 324 LLNotifications::instance().add("BlankClassifiedName");
320 return FALSE; 325 return FALSE;
321 } 326 }
322 if (!isalnum(name[0])) 327 if (!isalnum(name[0]))
323 { 328 {
324 gViewerWindow->alertXml("ClassifiedMustBeAlphanumeric"); 329 LLNotifications::instance().add("ClassifiedMustBeAlphanumeric");
325 return FALSE; 330 return FALSE;
326 } 331 }
327 332
@@ -338,31 +343,24 @@ void LLPanelClassified::apply()
338 } 343 }
339} 344}
340 345
341 346bool LLPanelClassified::saveCallback(const LLSD& notification, const LLSD& response)
342// static
343void LLPanelClassified::saveCallback(S32 option, void* data)
344{ 347{
345 LLPanelClassified* self = (LLPanelClassified*)data; 348 S32 option = LLNotification::getSelectedOption(notification, response);
349
346 switch(option) 350 switch(option)
347 { 351 {
348 case 0: // Save 352 case 0: // Save
349 self->sendClassifiedInfoUpdate(); 353 sendClassifiedInfoUpdate();
350 // fall through to close 354 // fall through to close
351 355
352 case 1: // Don't Save 356 case 1: // Don't Save
353 { 357 {
354 self->mForceClose = true; 358 mForceClose = true;
355 // Close containing floater 359 // Close containing floater
356 LLView* view = self; 360 LLFloater* parent_floater = gFloaterView->getParentFloater(this);
357 while (view) 361 if (parent_floater)
358 { 362 {
359 LLFloater* floaterp = dynamic_cast<LLFloater*>(view); 363 parent_floater->close();
360 if (floaterp)
361 {
362 floaterp->close();
363 break;
364 }
365 view = view->getParent();
366 } 364 }
367 } 365 }
368 break; 366 break;
@@ -372,16 +370,18 @@ void LLPanelClassified::saveCallback(S32 option, void* data)
372 LLAppViewer::instance()->abortQuit(); 370 LLAppViewer::instance()->abortQuit();
373 break; 371 break;
374 } 372 }
373 return false;
375} 374}
376 375
376
377BOOL LLPanelClassified::canClose() 377BOOL LLPanelClassified::canClose()
378{ 378{
379 if (mForceClose || !checkDirty()) 379 if (mForceClose || !checkDirty())
380 return TRUE; 380 return TRUE;
381 381
382 LLStringUtil::format_map_t args; 382 LLSD args;
383 args["[NAME]"] = mNameEditor->getText(); 383 args["NAME"] = mNameEditor->getText();
384 LLAlertDialog::showXml("ClassifiedSave", args, saveCallback, this); 384 LLNotifications::instance().add("ClassifiedSave", args, LLSD(), boost::bind(&LLPanelClassified::saveCallback, this, _1, _2));
385 return FALSE; 385 return FALSE;
386} 386}
387 387
@@ -409,6 +409,9 @@ void LLPanelClassified::initNewClassified()
409 } 409 }
410 410
411 mUpdateBtn->setLabel(getString("publish_txt")); 411 mUpdateBtn->setLabel(getString("publish_txt"));
412
413 // simulate clicking the "location" button
414 LLPanelClassified::onClickSet(this);
412} 415}
413 416
414 417
@@ -543,7 +546,10 @@ void LLPanelClassified::sendClassifiedInfoUpdate()
543 { 546 {
544 auto_renew = mAutoRenewCheck->get(); 547 auto_renew = mAutoRenewCheck->get();
545 } 548 }
546 U8 flags = pack_classified_flags(mature, auto_renew); 549 // These flags doesn't matter here.
550 const bool adult_enabled = false;
551 const bool is_pg = false;
552 U8 flags = pack_classified_flags_request(auto_renew, is_pg, mature, adult_enabled);
547 msg->addU8Fast(_PREHASH_ClassifiedFlags, flags); 553 msg->addU8Fast(_PREHASH_ClassifiedFlags, flags);
548 msg->addS32("PriceForListing", mPriceForListing); 554 msg->addS32("PriceForListing", mPriceForListing);
549 gAgent.sendReliableMessage(); 555 gAgent.sendReliableMessage();
@@ -661,7 +667,7 @@ void LLPanelClassified::processClassifiedInfoReply(LLMessageSystem *msg, void **
661 } 667 }
662 else 668 else
663 { 669 {
664 self->mMatureCombo->setCurrentByIndex(NON_MATURE_CONTENT); 670 self->mMatureCombo->setCurrentByIndex(PG_CONTENT);
665 } 671 }
666 if (self->mAutoRenewCheck) 672 if (self->mAutoRenewCheck)
667 { 673 {
@@ -681,6 +687,7 @@ void LLPanelClassified::processClassifiedInfoReply(LLMessageSystem *msg, void **
681 687
682 self->resetDirty(); 688 self->resetDirty();
683 689
690 // I don't know if a second call is deliberate or a bad merge, so I'm leaving it here.
684 self->resetDirty(); 691 self->resetDirty();
685 } 692 }
686} 693}
@@ -748,8 +755,22 @@ void LLPanelClassified::refresh()
748 //mPriceEditor->setEnabled(is_self); 755 //mPriceEditor->setEnabled(is_self);
749 mCategoryCombo->setEnabled(is_self); 756 mCategoryCombo->setEnabled(is_self);
750 757
751 mMatureCombo->setEnabled(is_self); 758 if( is_self )
752 759 {
760 if( mMatureCombo->getCurrentIndex() == 0 )
761 {
762 // It's a new panel.
763 // PG regions must have PG classifieds. AO must have mature.
764 // Only Mature can be PG or Mature.
765
766 constrainAccessCombo();
767 }
768 }
769 else
770 {
771 mMatureCombo->setEnabled( FALSE );
772 }
773
753 if (mAutoRenewCheck) 774 if (mAutoRenewCheck)
754 { 775 {
755 mAutoRenewCheck->setEnabled(is_self); 776 mAutoRenewCheck->setEnabled(is_self);
@@ -784,8 +805,11 @@ void LLPanelClassified::onClickUpdate(void* data)
784 // If user has not set mature, do not allow publish 805 // If user has not set mature, do not allow publish
785 if(self->mMatureCombo->getCurrentIndex() == DECLINE_TO_STATE) 806 if(self->mMatureCombo->getCurrentIndex() == DECLINE_TO_STATE)
786 { 807 {
787 LLStringUtil::format_map_t args; 808 // Tell user about it
788 gViewerWindow->alertXml("SetClassifiedMature", &callbackConfirmMature, self); 809 LLNotifications::instance().add("SetClassifiedMature",
810 LLSD(),
811 LLSD(),
812 boost::bind(&LLPanelClassified::confirmMature, self, _1, _2));
789 return; 813 return;
790 } 814 }
791 815
@@ -793,16 +817,11 @@ void LLPanelClassified::onClickUpdate(void* data)
793 self->gotMature(); 817 self->gotMature();
794} 818}
795 819
796// static 820// Callback from a dialog indicating response to mature notification
797void LLPanelClassified::callbackConfirmMature(S32 option, void* data) 821bool LLPanelClassified::confirmMature(const LLSD& notification, const LLSD& response)
798{
799 LLPanelClassified* self = (LLPanelClassified*)data;
800 self->confirmMature(option);
801}
802
803// invoked from callbackConfirmMature
804void LLPanelClassified::confirmMature(S32 option)
805{ 822{
823 S32 option = LLNotification::getSelectedOption(notification, response);
824
806 // 0 == Yes 825 // 0 == Yes
807 // 1 == No 826 // 1 == No
808 // 2 == Cancel 827 // 2 == Cancel
@@ -812,14 +831,15 @@ void LLPanelClassified::confirmMature(S32 option)
812 mMatureCombo->setCurrentByIndex(MATURE_CONTENT); 831 mMatureCombo->setCurrentByIndex(MATURE_CONTENT);
813 break; 832 break;
814 case 1: 833 case 1:
815 mMatureCombo->setCurrentByIndex(NON_MATURE_CONTENT); 834 mMatureCombo->setCurrentByIndex(PG_CONTENT);
816 break; 835 break;
817 default: 836 default:
818 return; 837 return false;
819 } 838 }
820 839
821 // If we got here it means they set a valid value 840 // If we got here it means they set a valid value
822 gotMature(); 841 gotMature();
842 return false;
823} 843}
824 844
825// Called after we have determined whether this classified has 845// Called after we have determined whether this classified has
@@ -829,7 +849,9 @@ void LLPanelClassified::gotMature()
829 // if already paid for, just do the update 849 // if already paid for, just do the update
830 if (mPaidFor) 850 if (mPaidFor)
831 { 851 {
832 callbackConfirmPublish(0, this); 852 LLNotification::Params params("PublishClassified");
853 params.functor(boost::bind(&LLPanelClassified::confirmPublish, this, _1, _2));
854 LLNotifications::instance().forceResponse(params, 0);
833 } 855 }
834 else 856 else
835 { 857 {
@@ -849,11 +871,11 @@ void LLPanelClassified::callbackGotPriceForListing(S32 option, std::string text,
849 S32 price_for_listing = strtol(text.c_str(), NULL, 10); 871 S32 price_for_listing = strtol(text.c_str(), NULL, 10);
850 if (price_for_listing < MINIMUM_PRICE_FOR_LISTING) 872 if (price_for_listing < MINIMUM_PRICE_FOR_LISTING)
851 { 873 {
852 LLStringUtil::format_map_t args; 874 LLSD args;
853 std::string price_text = llformat("%d", MINIMUM_PRICE_FOR_LISTING); 875 std::string price_text = llformat("%d", MINIMUM_PRICE_FOR_LISTING);
854 args["[MIN_PRICE]"] = price_text; 876 args["MIN_PRICE"] = price_text;
855 877
856 gViewerWindow->alertXml("MinClassifiedPrice", args); 878 LLNotifications::instance().add("MinClassifiedPrice", args);
857 return; 879 return;
858 } 880 }
859 881
@@ -861,10 +883,10 @@ void LLPanelClassified::callbackGotPriceForListing(S32 option, std::string text,
861 // update send 883 // update send
862 self->mPriceForListing = price_for_listing; 884 self->mPriceForListing = price_for_listing;
863 885
864 LLStringUtil::format_map_t args; 886 LLSD args;
865 args["[AMOUNT]"] = llformat("%d", price_for_listing); 887 args["AMOUNT"] = llformat("%d", price_for_listing);
866 gViewerWindow->alertXml("PublishClassified", args, &callbackConfirmPublish, self); 888 LLNotifications::instance().add("PublishClassified", args, LLSD(),
867 889 boost::bind(&LLPanelClassified::confirmPublish, self, _1, _2));
868} 890}
869 891
870void LLPanelClassified::resetDirty() 892void LLPanelClassified::resetDirty()
@@ -888,10 +910,11 @@ void LLPanelClassified::resetDirty()
888} 910}
889 911
890// invoked from callbackConfirmPublish 912// invoked from callbackConfirmPublish
891void LLPanelClassified::confirmPublish(S32 option) 913bool LLPanelClassified::confirmPublish(const LLSD& notification, const LLSD& response)
892{ 914{
915 S32 option = LLNotification::getSelectedOption(notification, response);
893 // Option 0 = publish 916 // Option 0 = publish
894 if (option != 0) return; 917 if (option != 0) return false;
895 918
896 sendClassifiedInfoUpdate(); 919 sendClassifiedInfoUpdate();
897 920
@@ -910,14 +933,9 @@ void LLPanelClassified::confirmPublish(S32 option)
910 } 933 }
911 934
912 resetDirty(); 935 resetDirty();
936 return false;
913} 937}
914 938
915// static
916void LLPanelClassified::callbackConfirmPublish(S32 option, void* data)
917{
918 LLPanelClassified* self = (LLPanelClassified*)data;
919 self->confirmPublish(option);
920}
921 939
922// static 940// static
923void LLPanelClassified::onClickTeleport(void* data) 941void LLPanelClassified::onClickTeleport(void* data)
@@ -970,7 +988,13 @@ void LLPanelClassified::onClickSet(void* data)
970 self->mPosGlobal = gAgent.getPositionGlobal(); 988 self->mPosGlobal = gAgent.getPositionGlobal();
971 989
972 std::string location_text; 990 std::string location_text;
973 location_text.assign("(will update after publish)"); 991 std::string regionName = "(will update after publish)";
992 LLViewerRegion* pRegion = gAgent.getRegion();
993 if (pRegion)
994 {
995 regionName = pRegion->getName();
996 }
997 location_text.assign(regionName);
974 location_text.append(", "); 998 location_text.append(", ");
975 999
976 S32 region_x = llround((F32)self->mPosGlobal.mdV[VX]) % REGION_WIDTH_UNITS; 1000 S32 region_x = llround((F32)self->mPosGlobal.mdV[VX]) % REGION_WIDTH_UNITS;
@@ -982,6 +1006,8 @@ void LLPanelClassified::onClickSet(void* data)
982 1006
983 self->mLocationEditor->setText(location_text); 1007 self->mLocationEditor->setText(location_text);
984 self->mLocationChanged = true; 1008 self->mLocationChanged = true;
1009
1010 self->constrainAccessCombo();
985 1011
986 // Set this to null so it updates on the next save. 1012 // Set this to null so it updates on the next save.
987 self->mParcelID.setNull(); 1013 self->mParcelID.setNull();
@@ -1110,3 +1136,36 @@ void LLFloaterPriceForListing::buttonCore(S32 button, void* data)
1110 self->close(); 1136 self->close();
1111 } 1137 }
1112} 1138}
1139
1140void LLPanelClassified::constrainAccessCombo()
1141{
1142 // Location changed.
1143 // PG regions must have PG classifieds. AO must have mature.
1144 // Only Mature can be PG or Mature.
1145
1146 bool pref_visible = TRUE;
1147
1148 S32 force_access = MATURE_UNDEFINED;
1149 LLViewerRegion *regionp = gAgent.getRegion();
1150
1151 switch( regionp->getSimAccess() )
1152 {
1153 case SIM_ACCESS_PG:
1154 force_access = PG_CONTENT;
1155 break;
1156 case SIM_ACCESS_ADULT:
1157 force_access = MATURE_CONTENT;
1158 break;
1159 default:
1160 // You are free to move about the cabin.
1161 break;
1162 }
1163
1164 if ( force_access != MATURE_UNDEFINED )
1165 {
1166 pref_visible = FALSE;
1167 mMatureCombo->setCurrentByIndex(force_access);
1168 }
1169
1170 mMatureCombo->setEnabled(pref_visible);
1171}