diff options
author | Tofu Linden <tofu.linden@lindenlab.com> | 2010-03-10 10:31:41 +0000 |
---|---|---|
committer | Tofu Linden <tofu.linden@lindenlab.com> | 2010-03-10 10:31:41 +0000 |
commit | 8229fdd4902012c2d87cdd0264ad30de5cd7e0fa (patch) | |
tree | 83c7138949312de0ba2d89557807ff555f23a907 /indra/newview/llpanelclassified.cpp | |
parent | d6547a9b84695b994eef5425d62d19929478109a (diff) | |
parent | bc852b9a5dcffcec4cbf15b5cc4e571f8970c125 (diff) |
merge from viewer-2-0
Diffstat (limited to 'indra/newview/llpanelclassified.cpp')
-rw-r--r-- | indra/newview/llpanelclassified.cpp | 233 |
1 files changed, 196 insertions, 37 deletions
diff --git a/indra/newview/llpanelclassified.cpp b/indra/newview/llpanelclassified.cpp index 9f24ddc799..021e1f5159 100644 --- a/indra/newview/llpanelclassified.cpp +++ b/indra/newview/llpanelclassified.cpp @@ -114,6 +114,23 @@ public: }; static LLDispatchClassifiedClickThrough sClassifiedClickThrough; +// Just to debug errors. Can be thrown away later. +class LLClassifiedClickMessageResponder : public LLHTTPClient::Responder +{ + LOG_CLASS(LLClassifiedClickMessageResponder); + +public: + // If we get back an error (not found, etc...), handle it here + virtual void errorWithContent( + U32 status, + const std::string& reason, + const LLSD& content) + { + llwarns << "Sending click message failed (" << status << "): [" << reason << "]" << llendl; + llwarns << "Content: [" << content << "]" << llendl; + } +}; + /* Re-expose this if we need to have classified ad HTML detail pages. JC @@ -1237,7 +1254,7 @@ void LLPanelClassifiedInfo::reshape(S32 width, S32 height, BOOL called_from_pare void LLPanelClassifiedInfo::onOpen(const LLSD& key) { - LLUUID avatar_id = key["avatar_id"]; + LLUUID avatar_id = key["classified_creator_id"]; if(avatar_id.isNull()) { return; @@ -1255,9 +1272,12 @@ void LLPanelClassifiedInfo::onOpen(const LLSD& key) scrollToTop(); setClassifiedId(key["classified_id"]); - setClassifiedName(key["name"]); - setDescription(key["desc"]); - setSnapshotId(key["snapshot_id"]); + setClassifiedName(key["classified_name"]); + setDescription(key["classified_desc"]); + setSnapshotId(key["classified_snapshot_id"]); + setFromSearch(key["from_search"]); + + llinfos << "Opening classified [" << getClassifiedName() << "] (" << getClassifiedId() << ")" << llendl; LLAvatarPropertiesProcessor::getInstance()->addObserver(getAvatarId(), this); LLAvatarPropertiesProcessor::getInstance()->sendClassifiedInfoRequest(getClassifiedId()); @@ -1274,6 +1294,10 @@ void LLPanelClassifiedInfo::onOpen(const LLSD& key) LLHTTPClient::post(url, body, new LLClassifiedStatsResponder(getClassifiedId())); } + // Update classified click stats. + // *TODO: Should we do this when opening not from search? + sendClickMessage("profile"); + setInfoLoaded(false); } @@ -1289,6 +1313,8 @@ void LLPanelClassifiedInfo::processProperties(void* data, EAvatarProcessorType t setSnapshotId(c_info->snapshot_id); setParcelId(c_info->parcel_id); setPosGlobal(c_info->pos_global); + setSimName(c_info->sim_name); + setClassifiedLocation(createLocationText(c_info->parcel_name, c_info->sim_name, c_info->pos_global)); childSetValue("category", LLClassifiedInfo::sCategories[c_info->category]); @@ -1299,6 +1325,8 @@ void LLPanelClassifiedInfo::processProperties(void* data, EAvatarProcessorType t bool mature = is_cf_mature(c_info->flags); childSetValue("content_type", mature ? mature_str : pg_str); + getChild<LLIconCtrl>("content_type_moderate")->setVisible(mature); + getChild<LLIconCtrl>("content_type_general")->setVisible(!mature); std::string auto_renew_str = is_cf_auto_renew(c_info->flags) ? getString("auto_renew_on") : getString("auto_renew_off"); @@ -1323,7 +1351,19 @@ void LLPanelClassifiedInfo::resetData() setClassifiedLocation(LLStringUtil::null); setClassifiedId(LLUUID::null); setSnapshotId(LLUUID::null); - mPosGlobal.clearVec(); + setPosGlobal(LLVector3d::zero); + setParcelId(LLUUID::null); + setSimName(LLStringUtil::null); + setFromSearch(false); + + // reset click stats + mTeleportClicksOld = 0; + mMapClicksOld = 0; + mProfileClicksOld = 0; + mTeleportClicksNew = 0; + mMapClicksNew = 0; + mProfileClicksNew = 0; + childSetText("category", LLStringUtil::null); childSetText("content_type", LLStringUtil::null); childSetText("click_through_text", LLStringUtil::null); @@ -1331,6 +1371,8 @@ void LLPanelClassifiedInfo::resetData() childSetText("auto_renew", LLStringUtil::null); childSetText("creation_date", LLStringUtil::null); childSetText("click_through_text", LLStringUtil::null); + getChild<LLIconCtrl>("content_type_moderate")->setVisible(FALSE); + getChild<LLIconCtrl>("content_type_general")->setVisible(FALSE); } void LLPanelClassifiedInfo::resetControls() @@ -1368,6 +1410,11 @@ void LLPanelClassifiedInfo::setClassifiedLocation(const std::string& location) childSetValue("classified_location", location); } +std::string LLPanelClassifiedInfo::getClassifiedLocation() +{ + return childGetValue("classified_location").asString(); +} + void LLPanelClassifiedInfo::setSnapshotId(const LLUUID& id) { mSnapshotCtrl->setValue(id); @@ -1444,6 +1491,13 @@ void LLPanelClassifiedInfo::setClickThrough( ct_str.setArg("[PROFILE]", llformat("%d", self->mProfileClicksNew + self->mProfileClicksOld)); self->childSetText("click_through_text", ct_str.getString()); + // *HACK: remove this when there is enough room for click stats in the info panel + self->childSetToolTip("click_through_text", ct_str.getString()); + + llinfos << "teleport: " << llformat("%d", self->mTeleportClicksNew + self->mTeleportClicksOld) + << ", map: " << llformat("%d", self->mMapClicksNew + self->mMapClicksOld) + << ", profile: " << llformat("%d", self->mProfileClicksNew + self->mProfileClicksOld) + << llendl; } } @@ -1532,8 +1586,46 @@ void LLPanelClassifiedInfo::scrollToTop() scrollContainer->goToTop(); } +// static +// *TODO: move out of the panel +void LLPanelClassifiedInfo::sendClickMessage( + const std::string& type, + bool from_search, + const LLUUID& classified_id, + const LLUUID& parcel_id, + const LLVector3d& global_pos, + const std::string& sim_name) +{ + // You're allowed to click on your own ads to reassure yourself + // that the system is working. + LLSD body; + body["type"] = type; + body["from_search"] = from_search; + body["classified_id"] = classified_id; + body["parcel_id"] = parcel_id; + body["dest_pos_global"] = global_pos.getValue(); + body["region_name"] = sim_name; + + std::string url = gAgent.getRegion()->getCapability("SearchStatTracking"); + llinfos << "Sending click msg via capability (url=" << url << ")" << llendl; + llinfos << "body: [" << body << "]" << llendl; + LLHTTPClient::post(url, body, new LLClassifiedClickMessageResponder()); +} + +void LLPanelClassifiedInfo::sendClickMessage(const std::string& type) +{ + sendClickMessage( + type, + fromSearch(), + getClassifiedId(), + getParcelId(), + getPosGlobal(), + getSimName()); +} + void LLPanelClassifiedInfo::onMapClick() { + sendClickMessage("map"); LLFloaterWorldMap::getInstance()->trackLocation(getPosGlobal()); LLFloaterReg::showInstance("world_map", "center"); } @@ -1542,6 +1634,7 @@ void LLPanelClassifiedInfo::onTeleportClick() { if (!getPosGlobal().isExactlyZero()) { + sendClickMessage("teleport"); gAgent.teleportViaLocation(getPosGlobal()); LLFloaterWorldMap::getInstance()->trackLocation(getPosGlobal()); } @@ -1563,6 +1656,7 @@ static const S32 CB_ITEM_PG = 1; LLPanelClassifiedEdit::LLPanelClassifiedEdit() : LLPanelClassifiedInfo() , mIsNew(false) + , mIsNewWithErrors(false) , mCanClose(false) , mPublishFloater(NULL) { @@ -1621,21 +1715,12 @@ BOOL LLPanelClassifiedEdit::postBuild() return TRUE; } -void LLPanelClassifiedEdit::onOpen(const LLSD& key) +void LLPanelClassifiedEdit::fillIn(const LLSD& key) { - LLUUID classified_id = key["classified_id"]; + setAvatarId(gAgent.getID()); - mIsNew = classified_id.isNull(); - - scrollToTop(); - - if(mIsNew) + if(key.isUndefined()) { - setAvatarId(gAgent.getID()); - - resetData(); - resetControls(); - setPosGlobal(gAgent.getPositionGlobal()); LLUUID snapshot_id = LLUUID::null; @@ -1658,25 +1743,55 @@ void LLPanelClassifiedEdit::onOpen(const LLSD& key) childSetValue("classified_name", makeClassifiedName()); childSetValue("classified_desc", desc); setSnapshotId(snapshot_id); - setClassifiedLocation(createLocationText(getLocationNotice(), region_name, getPosGlobal())); - // server will set valid parcel id setParcelId(LLUUID::null); + } + else + { + setClassifiedId(key["classified_id"]); + setClassifiedName(key["name"]); + setDescription(key["desc"]); + setSnapshotId(key["snapshot_id"]); + setCategory((U32)key["category"].asInteger()); + setContentType((U32)key["content_type"].asInteger()); + setClassifiedLocation(key["location_text"]); + childSetValue("auto_renew", key["auto_renew"]); + childSetValue("price_for_listing", key["price_for_listing"].asInteger()); + } +} - enableVerbs(true); - enableEditing(true); +void LLPanelClassifiedEdit::onOpen(const LLSD& key) +{ + mIsNew = key.isUndefined(); + + scrollToTop(); + + // classified is not created yet + bool is_new = isNew() || isNewWithErrors(); + + if(is_new) + { + resetData(); + resetControls(); + + fillIn(key); + + if(isNew()) + { + LLAvatarPropertiesProcessor::getInstance()->addObserver(getAvatarId(), this); + } } else { LLPanelClassifiedInfo::onOpen(key); - enableVerbs(false); - enableEditing(false); } - std::string save_btn_label = isNew() ? getString("publish_label") : getString("save_label"); + std::string save_btn_label = is_new ? getString("publish_label") : getString("save_label"); childSetLabelArg("save_changes_btn", "[LABEL]", save_btn_label); + enableVerbs(is_new); + enableEditing(is_new); resetDirty(); setInfoLoaded(false); } @@ -1688,6 +1803,14 @@ void LLPanelClassifiedEdit::processProperties(void* data, EAvatarProcessorType t LLAvatarClassifiedInfo* c_info = static_cast<LLAvatarClassifiedInfo*>(data); if(c_info && getClassifiedId() == c_info->classified_id) { + // see LLPanelClassifiedEdit::sendUpdate() for notes + mIsNewWithErrors = false; + // for just created classified - panel will probably be closed when we get here. + if(!getVisible()) + { + return; + } + enableEditing(true); setClassifiedName(c_info->name); @@ -1697,19 +1820,22 @@ void LLPanelClassifiedEdit::processProperties(void* data, EAvatarProcessorType t setClassifiedLocation(createLocationText(c_info->parcel_name, c_info->sim_name, c_info->pos_global)); // *HACK see LLPanelClassifiedEdit::sendUpdate() - getChild<LLComboBox>("category")->setCurrentByIndex(c_info->category - 1); - getChild<LLComboBox>("category")->resetDirty(); + setCategory(c_info->category - 1); bool mature = is_cf_mature(c_info->flags); bool auto_renew = is_cf_auto_renew(c_info->flags); - getChild<LLComboBox>("content_type")->setCurrentByIndex(mature ? CB_ITEM_MATURE : CB_ITEM_PG); + setContentType(mature ? CB_ITEM_MATURE : CB_ITEM_PG); childSetValue("auto_renew", auto_renew); childSetValue("price_for_listing", c_info->price_for_listing); childSetEnabled("price_for_listing", isNew()); resetDirty(); setInfoLoaded(true); + enableVerbs(false); + + // for just created classified - in case user opened edit panel before processProperties() callback + childSetLabelArg("save_changes_btn", "[LABEL]", getString("save_label")); } } } @@ -1740,7 +1866,12 @@ void LLPanelClassifiedEdit::resetDirty() LLPanelClassifiedInfo::resetDirty(); getChild<LLUICtrl>("classified_snapshot")->resetDirty(); getChild<LLUICtrl>("classified_name")->resetDirty(); - getChild<LLUICtrl>("classified_desc")->resetDirty(); + + LLTextEditor* desc = getChild<LLTextEditor>("classified_desc"); + // call blockUndo() to really reset dirty(and make isDirty work as intended) + desc->blockUndo(); + desc->resetDirty(); + getChild<LLUICtrl>("category")->resetDirty(); getChild<LLUICtrl>("content_type")->resetDirty(); getChild<LLUICtrl>("auto_renew")->resetDirty(); @@ -1762,7 +1893,7 @@ void LLPanelClassifiedEdit::resetControls() LLPanelClassifiedInfo::resetControls(); getChild<LLComboBox>("category")->setCurrentByIndex(0); - getChild<LLComboBox>("content_type")->setCurrentByIndex(0); + getChild<LLIconsComboBox>("content_type")->setCurrentByIndex(0); childSetValue("auto_renew", false); childSetValue("price_for_listing", MINIMUM_PRICE_FOR_LISTING); childSetEnabled("price_for_listing", TRUE); @@ -1789,15 +1920,31 @@ void LLPanelClassifiedEdit::stretchSnapshot() getChild<LLUICtrl>("edit_icon")->setShape(mSnapshotCtrl->getRect()); } +U32 LLPanelClassifiedEdit::getContentType() +{ + LLComboBox* ct_cb = getChild<LLComboBox>("content_type"); + return ct_cb->getCurrentIndex(); +} + +void LLPanelClassifiedEdit::setContentType(U32 content_type) +{ + LLIconsComboBox* ct_cb = getChild<LLIconsComboBox>("content_type"); + ct_cb->setCurrentByIndex(content_type); + ct_cb->resetDirty(); +} + +bool LLPanelClassifiedEdit::getAutoRenew() +{ + return childGetValue("auto_renew").asBoolean(); +} + void LLPanelClassifiedEdit::sendUpdate() { LLAvatarClassifiedInfo c_data; if(getClassifiedId().isNull()) { - LLUUID id; - id.generate(); - setClassifiedId(id); + setClassifiedId(LLUUID::generateNewID()); } c_data.agent_id = gAgent.getID(); @@ -1814,6 +1961,14 @@ void LLPanelClassifiedEdit::sendUpdate() c_data.price_for_listing = getPriceForListing(); LLAvatarPropertiesProcessor::getInstance()->sendClassifiedInfoUpdate(&c_data); + + if(isNew()) + { + // Lets assume there will be some error. + // Successful sendClassifiedInfoUpdate will trigger processProperties and + // let us know there was no error. + mIsNewWithErrors = true; + } } U32 LLPanelClassifiedEdit::getCategory() @@ -1822,11 +1977,18 @@ U32 LLPanelClassifiedEdit::getCategory() return cat_cb->getCurrentIndex(); } +void LLPanelClassifiedEdit::setCategory(U32 category) +{ + LLComboBox* cat_cb = getChild<LLComboBox>("category"); + cat_cb->setCurrentByIndex(category); + cat_cb->resetDirty(); +} + U8 LLPanelClassifiedEdit::getFlags() { bool auto_renew = childGetValue("auto_renew").asBoolean(); - LLComboBox* content_cb = getChild<LLComboBox>("content_type"); + LLComboBox* content_cb = getChild<LLIconsComboBox>("content_type"); bool mature = content_cb->getCurrentIndex() == CB_ITEM_MATURE; return pack_classified_flags_request(auto_renew, false, mature, false); @@ -1917,17 +2079,14 @@ void LLPanelClassifiedEdit::onSaveClick() notifyInvalidName(); return; } - if(isNew()) + if(isNew() || isNewWithErrors()) { if(gStatusBar->getBalance() < getPriceForListing()) { LLNotificationsUtil::add("ClassifiedInsufficientFunds"); return; } - } - if(isNew()) - { mPublishFloater = LLFloaterReg::findTypedInstance<LLPublishClassifiedFloater>( "publish_classified", LLSD()); |