Merge branch 'DRTVWR-580-maint-T' of https://github.com/secondlife/viewer

# Conflicts:
#	indra/newview/app_settings/settings.xml
#	indra/newview/llfilepicker.cpp
#	indra/newview/llpanelface.cpp
#	indra/newview/llpanelface.h
#	indra/newview/llpanelwearing.cpp
#	indra/newview/llvovolume.cpp
master
Ansariel 2023-03-22 17:35:43 +01:00
commit 2c51fe5aad
40 changed files with 820 additions and 386 deletions

View File

@ -1404,6 +1404,7 @@ Sovereign Engineer
SL-18497
SL-18525
SL-18534
SL-19336
SpacedOut Frye
VWR-34
VWR-45

View File

@ -39,6 +39,11 @@ void LL::ThreadPool::start()
run(tname);
});
}
// Special workflow for LLWindowWin32Thread - it's close() should be called explicitly
if (mExplicitShutdown)
return;
// Listen on "LLApp", and when the app is shutting down, close the queue
// and join the workers.
LLEventPumps::instance().obtain("LLApp").listen(

View File

@ -59,6 +59,10 @@ namespace LL
*/
virtual void run();
protected:
// LLWindowWin32Thread should set this flag to true
bool mExplicitShutdown { false };
private:
void run(const std::string& name);

View File

@ -426,18 +426,18 @@ bool LLMaterial::operator != (const LLMaterial& rhs) const
}
U32 LLMaterial::getShaderMask(U32 alpha_mode)
U32 LLMaterial::getShaderMask(U32 alpha_mode, BOOL is_alpha)
{ //NEVER incorporate this value into the message system -- this function will vary depending on viewer implementation
U32 ret = 0;
//two least significant bits are "diffuse alpha mode"
if (alpha_mode != DIFFUSE_ALPHA_MODE_DEFAULT)
//two least significant bits are "diffuse alpha mode"
U32 ret = alpha_mode;
if (ret == DIFFUSE_ALPHA_MODE_DEFAULT)
{
ret = alpha_mode;
}
else
{
ret = getDiffuseAlphaMode();
ret = getDiffuseAlphaMode();
if (ret == DIFFUSE_ALPHA_MODE_BLEND && !is_alpha)
{
ret = DIFFUSE_ALPHA_MODE_NONE;
}
}
llassert(ret < SHADER_COUNT);

View File

@ -135,7 +135,7 @@ public:
bool operator == (const LLMaterial& rhs) const;
bool operator != (const LLMaterial& rhs) const;
U32 getShaderMask(U32 alpha_mode = DIFFUSE_ALPHA_MODE_DEFAULT);
U32 getShaderMask(U32 alpha_mode, BOOL is_alpha);
protected:
LLUUID mNormalID;

View File

@ -867,9 +867,16 @@ BOOL LLImageGL::setImage(const U8* data_in, BOOL data_hasmips /* = FALSE */, S32
stop_glerror();
if (prev_mip_data)
delete[] prev_mip_data;
{
if (prev_mip_data != cur_mip_data)
delete[] prev_mip_data;
prev_mip_data = nullptr;
}
if (cur_mip_data)
{
delete[] cur_mip_data;
cur_mip_data = nullptr;
}
mGLTextureCreated = false;
return FALSE;

View File

@ -432,7 +432,7 @@ S32 LLFolderViewItem::arrange( S32* width, S32* height )
// it is purely visual, so it is fine to do at our laisure
refreshSuffix();
}
mLabelWidth = getLabelXPos() + getLabelFontForStyle(mLabelStyle)->getWidth(mLabel) + getLabelFontForStyle(mLabelStyle)->getWidth(mLabelSuffix) + mLabelPaddingRight;
mLabelWidth = getLabelXPos() + getLabelFontForStyle(mLabelStyle)->getWidth(mLabel) + getLabelFontForStyle(mLabelStyle)->getWidth(mLabelSuffix) + mLabelPaddingRight;
mLabelWidthDirty = false;
}

View File

@ -37,6 +37,8 @@
#include "lluiimage.h"
#include "llwindow.h"
#include "llgltexture.h"
static LLDefaultChildRegistry::Register<LLIconCtrl> r("icon");
LLIconCtrl::Params::Params()
@ -94,6 +96,22 @@ BOOL LLIconCtrl::handleHover(S32 x, S32 y, MASK mask)
return LLUICtrl::handleHover(x, y, mask);
}
void LLIconCtrl::onVisibilityChange(BOOL new_visibility)
{
LLUICtrl::onVisibilityChange(new_visibility);
if (mPriority == LLGLTexture::BOOST_ICON)
{
if (new_visibility)
{
loadImage(getValue(), mPriority);
}
else
{
mImagep = nullptr;
}
}
}
// virtual
// value might be a string or a UUID
void LLIconCtrl::setValue(const LLSD& value)
@ -110,6 +128,14 @@ void LLIconCtrl::setValue(const LLSD& value, S32 priority)
tvalue = LLSD(LLUUID(value.asString()));
}
LLUICtrl::setValue(tvalue);
loadImage(tvalue, priority);
}
void LLIconCtrl::loadImage(const LLSD& tvalue, S32 priority)
{
if(mPriority == LLGLTexture::BOOST_ICON && !getVisible()) return;
if (tvalue.isUUID())
{
mImagep = LLUI::getUIImageByID(tvalue.asUUID(), priority);

View File

@ -72,6 +72,7 @@ public:
virtual BOOL handleHover(S32 x, S32 y, MASK mask);
// lluictrl overrides
void onVisibilityChange(BOOL new_visibility);
virtual void setValue(const LLSD& value );
std::string getImageName() const;
@ -95,6 +96,8 @@ protected:
bool mInteractable;
private:
void loadImage(const LLSD& value, S32 priority);
LLUIColor mColor;
LLPointer<LLUIImage> mImagep;
};

View File

@ -127,6 +127,7 @@ public:
virtual void clearCtrls(); // overridden in LLPanelObject and LLPanelVolume
// Border controls
const LLViewBorder* getBorder() const { return mBorder; }
void addBorder( LLViewBorder::Params p);
void addBorder();
void removeBorder();

View File

@ -1526,9 +1526,9 @@ void LLTextBase::draw()
drawCursor();
}
mDocumentView->setVisible(FALSE);
mDocumentView->setVisibleDirect(FALSE);
LLUICtrl::draw();
mDocumentView->setVisible(TRUE);
mDocumentView->setVisibleDirect(TRUE);
}

View File

@ -226,7 +226,6 @@ LLUIColor LLUIColorTable::getColor( char const *name, const LLColor4& default_co
void LLUIColorTable::setColor(const std::string& name, const LLColor4& color)
{
setColor(name, color, mUserSetColors);
setColor(name, color, mLoadedColors);
}
bool LLUIColorTable::loadFromSettings()
@ -255,6 +254,11 @@ void LLUIColorTable::saveUserSettings() const
it != mUserSetColors.end();
++it)
{
// Compare user color value with the default value, skip if equal
string_color_map_t::const_iterator itd = mLoadedColors.find(it->first);
if(itd != mUserSetColors.end() && itd->second == it->second)
continue;
ColorEntryParams color_entry;
// color_entry.name = it->first;

View File

@ -293,6 +293,7 @@ public:
void setAllChildrenEnabled(BOOL b);
virtual void setVisible(BOOL visible);
void setVisibleDirect(BOOL visible) { mVisible = visible; }
const BOOL& getVisible() const { return mVisible; }
virtual void setEnabled(BOOL enabled);
BOOL getEnabled() const { return mEnabled; }

View File

@ -4708,6 +4708,9 @@ void LLWindowWin32::getWindowChrome( U32 &aChromeW, U32 &aChromeH )
inline LLWindowWin32::LLWindowWin32Thread::LLWindowWin32Thread()
: ThreadPool("Window Thread", 1, MAX_QUEUE_SIZE)
{
// Set this flag to true to avoid of implicit call of close() from start()
mExplicitShutdown = true;
ThreadPool::start();
}

View File

@ -16161,13 +16161,13 @@ Change of this parameter will affect the layout of buttons in notification toast
<key>TranslationService</key>
<map>
<key>Comment</key>
<string>Translation API to use. (google|bing)</string>
<string>Translation API to use. (google|azure)</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>String</string>
<key>Value</key>
<string>bing</string>
<string>azure</string>
</map>
<key>GoogleTranslateAPIKey</key>
<map>
@ -16183,7 +16183,7 @@ Change of this parameter will affect the layout of buttons in notification toast
<key>BingTranslateAPIKey</key>
<map>
<key>Comment</key>
<string>Bing AppID to use with the Microsoft Translator API</string>
<string>(Deprecated) Bing AppID to use with the Microsoft Translator API</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
@ -16191,6 +16191,17 @@ Change of this parameter will affect the layout of buttons in notification toast
<key>Value</key>
<string></string>
</map>
<key>AzureTranslateAPIKey</key>
<map>
<key>Comment</key>
<string>Azure Translation service data to use with the MS Azure Translator API</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>LLSD</string>
<key>Value</key>
<string></string>
</map>
<key>TutorialURL</key>
<map>
<key>Comment</key>

View File

@ -282,6 +282,8 @@ void LLDrawPoolAlpha::renderDebugAlpha()
{
gHighlightProgram.bind();
gGL.diffuseColor4f(1, 0, 0, 1);
LLViewerFetchedTexture::sSmokeImagep->addTextureStats(1024.f * 1024.f);
gGL.getTexUnit(0)->bindFast(LLViewerFetchedTexture::sSmokeImagep);

View File

@ -61,9 +61,6 @@ LLFilePicker LLFilePicker::sInstance;
#define IMAGE_FILTER L"Images (*.tga; *.bmp; *.jpg; *.jpeg; *.png)\0*.tga;*.bmp;*.jpg;*.jpeg;*.png\0"
#define ANIM_FILTER L"Animations (*.bvh; *.anim)\0*.bvh;*.anim\0"
#define COLLADA_FILTER L"Scene (*.dae)\0*.dae\0"
#ifdef _CORY_TESTING
#define GEOMETRY_FILTER L"SL Geometry (*.slg)\0*.slg\0"
#endif
#define XML_FILTER L"XML files (*.xml)\0*.xml\0"
#define SLOBJECT_FILTER L"Objects (*.slobject)\0*.slobject\0"
#define RAW_FILTER L"RAW files (*.raw)\0*.raw\0"
@ -217,12 +214,6 @@ BOOL LLFilePicker::setupFilter(ELoadFilter filter)
mOFN.lpstrFilter = COLLADA_FILTER \
L"\0";
break;
#ifdef _CORY_TESTING
case FFLOAD_GEOMETRY:
mOFN.lpstrFilter = GEOMETRY_FILTER \
L"\0";
break;
#endif
case FFLOAD_XML:
mOFN.lpstrFilter = XML_FILTER \
L"\0";
@ -506,18 +497,6 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename,
L"XAF Anim File (*.xaf)\0*.xaf\0" \
L"\0";
break;
#ifdef _CORY_TESTING
case FFSAVE_GEOMETRY:
if (filename.empty())
{
wcsncpy( mFilesW,L"untitled.slg", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/
}
mOFN.lpstrDefExt = L"slg";
mOFN.lpstrFilter =
L"SLG SL Geometry File (*.slg)\0*.slg\0" \
L"\0";
break;
#endif
case FFSAVE_XML:
if (filename.empty())
{
@ -687,11 +666,6 @@ std::unique_ptr<std::vector<std::string>> LLFilePicker::navOpenFilterProc(ELoadF
case FFLOAD_COLLADA:
allowedv->push_back("dae");
break;
#ifdef _CORY_TESTING
case FFLOAD_GEOMETRY:
allowedv->push_back("slg");
break;
#endif
case FFLOAD_XML:
allowedv->push_back("xml");
break;
@ -796,14 +770,6 @@ bool LLFilePicker::doNavSaveDialog(ESaveFilter filter, const std::string& filena
creator = "\?\?\?\?";
extension = "xaf";
break;
#ifdef _CORY_TESTING
case FFSAVE_GEOMETRY:
type = "\?\?\?\?";
creator = "\?\?\?\?";
extension = "slg";
break;
#endif
// <FS:TS> Compile fix
// case FFSAVE_XML:
// type = "\?\?\?\?";

View File

@ -84,9 +84,6 @@ public:
FFLOAD_WAV = 2,
FFLOAD_IMAGE = 3,
FFLOAD_ANIM = 4,
#ifdef _CORY_TESTING
FFLOAD_GEOMETRY = 5,
#endif
FFLOAD_XML = 6,
FFLOAD_SLOBJECT = 7,
FFLOAD_RAW = 8,
@ -109,9 +106,6 @@ public:
FFSAVE_BMP = 5,
FFSAVE_AVI = 6,
FFSAVE_ANIM = 7,
#ifdef _CORY_TESTING
FFSAVE_GEOMETRY = 8,
#endif
FFSAVE_XML = 9,
FFSAVE_COLLADA = 10,
FFSAVE_RAW = 11,

View File

@ -118,6 +118,8 @@ LLFloaterIMNearbyChat::LLFloaterIMNearbyChat(const LLSD& llsd)
mEnableCallbackRegistrar.add("Avatar.EnableGearItem", boost::bind(&cb_do_nothing));
mCommitCallbackRegistrar.add("Avatar.GearDoToSelected", boost::bind(&cb_do_nothing));
mEnableCallbackRegistrar.add("Avatar.CheckGearItem", boost::bind(&cb_do_nothing));
mMinFloaterHeight = EXPANDED_MIN_HEIGHT;
}
//static

View File

@ -94,6 +94,8 @@ LLFloaterIMSessionTab::LLFloaterIMSessionTab(const LLSD& session_id)
mEnableCallbackRegistrar.add("Avatar.EnableItem", boost::bind(&LLFloaterIMSessionTab::enableContextMenuItem, this, _2));
mCommitCallbackRegistrar.add("Avatar.DoToSelected", boost::bind(&LLFloaterIMSessionTab::doToSelected, this, _2));
mCommitCallbackRegistrar.add("Group.DoToSelected", boost::bind(&cb_group_do_nothing));
mMinFloaterHeight = getMinHeight();
}
LLFloaterIMSessionTab::~LLFloaterIMSessionTab()
@ -936,10 +938,13 @@ void LLFloaterIMSessionTab::reshapeFloater(bool collapse)
S32 height = mContentPanel->getRect().getHeight() + mToolbarPanel->getRect().getHeight()
+ mChatLayoutPanel->getRect().getHeight() - mChatLayoutPanelHeight + 2;
floater_rect.mTop -= height;
setResizeLimits(getMinWidth(), floater_rect.getHeight());
}
else
{
floater_rect.mTop = floater_rect.mBottom + mFloaterHeight;
setResizeLimits(getMinWidth(), mMinFloaterHeight);
}
enableResizeCtrls(true, true, !collapse);
@ -964,6 +969,7 @@ void LLFloaterIMSessionTab::restoreFloater()
setShape(floater_rect, true);
mBodyStack->updateLayout();
mExpandCollapseLineBtn->setImageOverlay(getString("expandline_icon"));
setResizeLimits(getMinWidth(), mMinFloaterHeight);
setMessagePaneExpanded(true);
saveCollapsedState();
mInputEditor->enableSingleLineMode(false);

View File

@ -154,6 +154,7 @@ protected:
bool mMessagePaneExpanded;
bool mIsParticipantListExpanded;
S32 mMinFloaterHeight;
LLIMModel::LLIMSession* mSession;

View File

@ -336,7 +336,6 @@ void LLFloaterRegionInfo::onOpen(const LLSD& key)
}
refreshFromRegion(gAgent.getRegion());
requestRegionInfo();
requestMeshRezInfo();
if (!mGodLevelChangeSlot.connected())
{
@ -1066,19 +1065,6 @@ bool LLPanelRegionGeneralInfo::onMessageCommit(const LLSD& notification, const L
return false;
}
void LLFloaterRegionInfo::requestMeshRezInfo()
{
std::string sim_console_url = gAgent.getRegionCapability("SimConsoleAsync");
if (!sim_console_url.empty())
{
std::string request_str = "get mesh_rez_enabled";
LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost(sim_console_url, LLSD(request_str),
"Requested mesh_rez_enabled", "Error requesting mesh_rez_enabled");
}
}
// setregioninfo
// strings[0] = 'Y' - block terraform, 'N' - not
// strings[1] = 'Y' - block fly, 'N' - not

View File

@ -108,7 +108,6 @@ public:
void onRegionChanged();
void requestRegionInfo();
void requestMeshRezInfo();
void enableTopButtons();
void disableTopButtons();

View File

@ -48,14 +48,7 @@
LLFloaterTranslationSettings::LLFloaterTranslationSettings(const LLSD& key)
: LLFloater(key)
, mMachineTranslationCB(NULL)
, mLanguageCombo(NULL)
, mTranslationServiceRadioGroup(NULL)
, mBingAPIKeyEditor(NULL)
, mGoogleAPIKeyEditor(NULL)
, mBingVerifyBtn(NULL)
, mGoogleVerifyBtn(NULL)
, mOKBtn(NULL)
, mBingKeyVerified(false)
, mAzureKeyVerified(false)
, mGoogleKeyVerified(false)
{
}
@ -66,9 +59,11 @@ BOOL LLFloaterTranslationSettings::postBuild()
mMachineTranslationCB = getChild<LLCheckBoxCtrl>("translate_chat_checkbox");
mLanguageCombo = getChild<LLComboBox>("translate_language_combo");
mTranslationServiceRadioGroup = getChild<LLRadioGroup>("translation_service_rg");
mBingAPIKeyEditor = getChild<LLLineEditor>("bing_api_key");
mAzureAPIEndpointEditor = getChild<LLComboBox>("azure_api_endpoint_combo");
mAzureAPIKeyEditor = getChild<LLLineEditor>("azure_api_key");
mAzureAPIRegionEditor = getChild<LLLineEditor>("azure_api_region");
mGoogleAPIKeyEditor = getChild<LLLineEditor>("google_api_key");
mBingVerifyBtn = getChild<LLButton>("verify_bing_api_key_btn");
mAzureVerifyBtn = getChild<LLButton>("verify_azure_api_key_btn");
mGoogleVerifyBtn = getChild<LLButton>("verify_google_api_key_btn");
mOKBtn = getChild<LLButton>("ok_btn");
@ -76,11 +71,17 @@ BOOL LLFloaterTranslationSettings::postBuild()
mTranslationServiceRadioGroup->setCommitCallback(boost::bind(&LLFloaterTranslationSettings::updateControlsEnabledState, this));
mOKBtn->setClickedCallback(boost::bind(&LLFloaterTranslationSettings::onBtnOK, this));
getChild<LLButton>("cancel_btn")->setClickedCallback(boost::bind(&LLFloater::closeFloater, this, false));
mBingVerifyBtn->setClickedCallback(boost::bind(&LLFloaterTranslationSettings::onBtnBingVerify, this));
mAzureVerifyBtn->setClickedCallback(boost::bind(&LLFloaterTranslationSettings::onBtnAzureVerify, this));
mGoogleVerifyBtn->setClickedCallback(boost::bind(&LLFloaterTranslationSettings::onBtnGoogleVerify, this));
mBingAPIKeyEditor->setFocusReceivedCallback(boost::bind(&LLFloaterTranslationSettings::onEditorFocused, this, _1));
mBingAPIKeyEditor->setKeystrokeCallback(boost::bind(&LLFloaterTranslationSettings::onBingKeyEdited, this), NULL);
mAzureAPIKeyEditor->setFocusReceivedCallback(boost::bind(&LLFloaterTranslationSettings::onEditorFocused, this, _1));
mAzureAPIKeyEditor->setKeystrokeCallback(boost::bind(&LLFloaterTranslationSettings::onAzureKeyEdited, this), NULL);
mAzureAPIRegionEditor->setFocusReceivedCallback(boost::bind(&LLFloaterTranslationSettings::onEditorFocused, this, _1));
mAzureAPIRegionEditor->setKeystrokeCallback(boost::bind(&LLFloaterTranslationSettings::onAzureKeyEdited, this), NULL);
mAzureAPIEndpointEditor->setFocusLostCallback(boost::bind(&LLFloaterTranslationSettings::onAzureKeyEdited, this));
mAzureAPIEndpointEditor->setCommitCallback(boost::bind(&LLFloaterTranslationSettings::onAzureKeyEdited, this));
mGoogleAPIKeyEditor->setFocusReceivedCallback(boost::bind(&LLFloaterTranslationSettings::onEditorFocused, this, _1));
mGoogleAPIKeyEditor->setKeystrokeCallback(boost::bind(&LLFloaterTranslationSettings::onGoogleKeyEdited, this), NULL);
@ -95,17 +96,28 @@ void LLFloaterTranslationSettings::onOpen(const LLSD& key)
mLanguageCombo->setSelectedByValue(gSavedSettings.getString("TranslateLanguage"), TRUE);
mTranslationServiceRadioGroup->setSelectedByValue(gSavedSettings.getString("TranslationService"), TRUE);
std::string bing_key = gSavedSettings.getString("BingTranslateAPIKey");
if (!bing_key.empty())
LLSD azure_key = gSavedSettings.getLLSD("AzureTranslateAPIKey");
if (azure_key.isMap() && !azure_key["id"].asString().empty())
{
mBingAPIKeyEditor->setText(bing_key);
mBingAPIKeyEditor->setTentative(FALSE);
verifyKey(LLTranslate::SERVICE_BING, bing_key, false);
mAzureAPIKeyEditor->setText(azure_key["id"].asString());
mAzureAPIKeyEditor->setTentative(false);
if (azure_key.has("region") && !azure_key["region"].asString().empty())
{
mAzureAPIRegionEditor->setText(azure_key["region"].asString());
mAzureAPIRegionEditor->setTentative(false);
}
else
{
mAzureAPIRegionEditor->setTentative(true);
}
mAzureAPIEndpointEditor->setValue(azure_key["endpoint"]);
verifyKey(LLTranslate::SERVICE_AZURE, azure_key, false);
}
else
{
mBingAPIKeyEditor->setTentative(TRUE);
mBingKeyVerified = FALSE;
mAzureAPIKeyEditor->setTentative(TRUE);
mAzureAPIRegionEditor->setTentative(true);
mAzureKeyVerified = FALSE;
}
std::string google_key = gSavedSettings.getString("GoogleTranslateAPIKey");
@ -124,22 +136,22 @@ void LLFloaterTranslationSettings::onOpen(const LLSD& key)
updateControlsEnabledState();
}
void LLFloaterTranslationSettings::setBingVerified(bool ok, bool alert)
void LLFloaterTranslationSettings::setAzureVerified(bool ok, bool alert, S32 status)
{
if (alert)
{
showAlert(ok ? "bing_api_key_verified" : "bing_api_key_not_verified");
showAlert(ok ? "azure_api_key_verified" : "azure_api_key_not_verified", status);
}
mBingKeyVerified = ok;
mAzureKeyVerified = ok;
updateControlsEnabledState();
}
void LLFloaterTranslationSettings::setGoogleVerified(bool ok, bool alert)
void LLFloaterTranslationSettings::setGoogleVerified(bool ok, bool alert, S32 status)
{
if (alert)
{
showAlert(ok ? "google_api_key_verified" : "google_api_key_not_verified");
showAlert(ok ? "google_api_key_verified" : "google_api_key_not_verified", status);
}
mGoogleKeyVerified = ok;
@ -151,9 +163,19 @@ std::string LLFloaterTranslationSettings::getSelectedService() const
return mTranslationServiceRadioGroup->getSelectedValue().asString();
}
std::string LLFloaterTranslationSettings::getEnteredBingKey() const
LLSD LLFloaterTranslationSettings::getEnteredAzureKey() const
{
return mBingAPIKeyEditor->getTentative() ? LLStringUtil::null : mBingAPIKeyEditor->getText();
LLSD key;
if (!mAzureAPIKeyEditor->getTentative())
{
key["endpoint"] = mAzureAPIEndpointEditor->getValue();
key["id"] = mAzureAPIKeyEditor->getText();
if (!mAzureAPIRegionEditor->getTentative())
{
key["region"] = mAzureAPIRegionEditor->getText();
}
}
return key;
}
std::string LLFloaterTranslationSettings::getEnteredGoogleKey() const
@ -161,10 +183,15 @@ std::string LLFloaterTranslationSettings::getEnteredGoogleKey() const
return mGoogleAPIKeyEditor->getTentative() ? LLStringUtil::null : mGoogleAPIKeyEditor->getText();
}
void LLFloaterTranslationSettings::showAlert(const std::string& msg_name) const
void LLFloaterTranslationSettings::showAlert(const std::string& msg_name, S32 status) const
{
LLStringUtil::format_map_t string_args;
// For now just show an http error code, whole 'reason' string might be added later
string_args["[STATUS]"] = llformat("%d", status);
std::string message = getString(msg_name, string_args);
LLSD args;
args["MESSAGE"] = getString(msg_name);
args["MESSAGE"] = message;
LLNotificationsUtil::add("GenericAlert", args);
}
@ -173,34 +200,38 @@ void LLFloaterTranslationSettings::updateControlsEnabledState()
// Enable/disable controls based on the checkbox value.
bool on = mMachineTranslationCB->getValue().asBoolean();
std::string service = getSelectedService();
bool bing_selected = service == "bing";
bool azure_selected = service == "azure";
bool google_selected = service == "google";
mTranslationServiceRadioGroup->setEnabled(on);
mLanguageCombo->setEnabled(on);
getChild<LLTextBox>("bing_api_key_label")->setEnabled(on);
mBingAPIKeyEditor->setEnabled(on);
getChild<LLTextBox>("azure_api_endoint_label")->setEnabled(on);
mAzureAPIEndpointEditor->setEnabled(on);
getChild<LLTextBox>("azure_api_key_label")->setEnabled(on);
mAzureAPIKeyEditor->setEnabled(on);
getChild<LLTextBox>("azure_api_region_label")->setEnabled(on);
mAzureAPIRegionEditor->setEnabled(on);
getChild<LLTextBox>("google_api_key_label")->setEnabled(on);
mGoogleAPIKeyEditor->setEnabled(on);
mBingAPIKeyEditor->setEnabled(on && bing_selected);
mAzureAPIKeyEditor->setEnabled(on && azure_selected);
mGoogleAPIKeyEditor->setEnabled(on && google_selected);
mBingVerifyBtn->setEnabled(on && bing_selected &&
!mBingKeyVerified && !getEnteredBingKey().empty());
mAzureVerifyBtn->setEnabled(on && azure_selected &&
!mAzureKeyVerified && getEnteredAzureKey().isMap());
mGoogleVerifyBtn->setEnabled(on && google_selected &&
!mGoogleKeyVerified && !getEnteredGoogleKey().empty());
bool service_verified = (bing_selected && mBingKeyVerified) || (google_selected && mGoogleKeyVerified);
bool service_verified = (azure_selected && mAzureKeyVerified) || (google_selected && mGoogleKeyVerified);
gSavedPerAccountSettings.setBOOL("TranslatingEnabled", service_verified);
mOKBtn->setEnabled(!on || service_verified);
}
/*static*/
void LLFloaterTranslationSettings::setVerificationStatus(int service, bool ok, bool alert)
void LLFloaterTranslationSettings::setVerificationStatus(int service, bool ok, bool alert, S32 status)
{
LLFloaterTranslationSettings* floater =
LLFloaterReg::getTypedInstance<LLFloaterTranslationSettings>("prefs_translation");
@ -213,20 +244,20 @@ void LLFloaterTranslationSettings::setVerificationStatus(int service, bool ok, b
switch (service)
{
case LLTranslate::SERVICE_BING:
floater->setBingVerified(ok, alert);
case LLTranslate::SERVICE_AZURE:
floater->setAzureVerified(ok, alert, status);
break;
case LLTranslate::SERVICE_GOOGLE:
floater->setGoogleVerified(ok, alert);
floater->setGoogleVerified(ok, alert, status);
break;
}
}
void LLFloaterTranslationSettings::verifyKey(int service, const std::string& key, bool alert)
void LLFloaterTranslationSettings::verifyKey(int service, const LLSD& key, bool alert)
{
LLTranslate::verifyKey(static_cast<LLTranslate::EService>(service), key,
boost::bind(&LLFloaterTranslationSettings::setVerificationStatus, _1, _2, alert));
boost::bind(&LLFloaterTranslationSettings::setVerificationStatus, _1, _2, alert, _3));
}
void LLFloaterTranslationSettings::onEditorFocused(LLFocusableElement* control)
@ -242,11 +273,14 @@ void LLFloaterTranslationSettings::onEditorFocused(LLFocusableElement* control)
}
}
void LLFloaterTranslationSettings::onBingKeyEdited()
void LLFloaterTranslationSettings::onAzureKeyEdited()
{
if (mBingAPIKeyEditor->isDirty())
if (mAzureAPIKeyEditor->isDirty()
|| mAzureAPIRegionEditor->isDirty()
|| mAzureAPIEndpointEditor->getValue().isString())
{
setBingVerified(false, false);
// todo: verify mAzureAPIEndpointEditor url
setAzureVerified(false, false, 0);
}
}
@ -254,16 +288,16 @@ void LLFloaterTranslationSettings::onGoogleKeyEdited()
{
if (mGoogleAPIKeyEditor->isDirty())
{
setGoogleVerified(false, false);
setGoogleVerified(false, false, 0);
}
}
void LLFloaterTranslationSettings::onBtnBingVerify()
void LLFloaterTranslationSettings::onBtnAzureVerify()
{
std::string key = getEnteredBingKey();
if (!key.empty())
LLSD key = getEnteredAzureKey();
if (key.isMap())
{
verifyKey(LLTranslate::SERVICE_BING, key);
verifyKey(LLTranslate::SERVICE_AZURE, key);
}
}
@ -272,16 +306,16 @@ void LLFloaterTranslationSettings::onBtnGoogleVerify()
std::string key = getEnteredGoogleKey();
if (!key.empty())
{
verifyKey(LLTranslate::SERVICE_GOOGLE, key);
verifyKey(LLTranslate::SERVICE_GOOGLE, LLSD(key));
}
}
void LLFloaterTranslationSettings::onClose(bool app_quitting)
{
std::string service = gSavedSettings.getString("TranslationService");
bool bing_selected = service == "bing";
bool azure_selected = service == "azure";
bool google_selected = service == "google";
bool service_verified = (bing_selected && mBingKeyVerified) || (google_selected && mGoogleKeyVerified);
bool service_verified = (azure_selected && mAzureKeyVerified) || (google_selected && mGoogleKeyVerified);
gSavedPerAccountSettings.setBOOL("TranslatingEnabled", service_verified);
}
@ -290,7 +324,7 @@ void LLFloaterTranslationSettings::onBtnOK()
gSavedSettings.setBOOL("TranslateChat", mMachineTranslationCB->getValue().asBoolean());
gSavedSettings.setString("TranslateLanguage", mLanguageCombo->getSelectedValue().asString());
gSavedSettings.setString("TranslationService", getSelectedService());
gSavedSettings.setString("BingTranslateAPIKey", getEnteredBingKey());
gSavedSettings.setLLSD("AzureTranslateAPIKey", getEnteredAzureKey());
gSavedSettings.setString("GoogleTranslateAPIKey", getEnteredGoogleKey());
closeFloater(false);

View File

@ -42,37 +42,39 @@ public:
/*virtual*/ BOOL postBuild();
/*virtual*/ void onOpen(const LLSD& key);
void setBingVerified(bool ok, bool alert);
void setGoogleVerified(bool ok, bool alert);
void setAzureVerified(bool ok, bool alert, S32 status);
void setGoogleVerified(bool ok, bool alert, S32 status);
void onClose(bool app_quitting);
private:
std::string getSelectedService() const;
std::string getEnteredBingKey() const;
LLSD getEnteredAzureKey() const;
std::string getEnteredGoogleKey() const;
void showAlert(const std::string& msg_name) const;
void showAlert(const std::string& msg_name, S32 status) const;
void updateControlsEnabledState();
void verifyKey(int service, const std::string& key, bool alert = true);
void verifyKey(int service, const LLSD& key, bool alert = true);
void onEditorFocused(LLFocusableElement* control);
void onBingKeyEdited();
void onAzureKeyEdited();
void onGoogleKeyEdited();
void onBtnBingVerify();
void onBtnAzureVerify();
void onBtnGoogleVerify();
void onBtnOK();
static void setVerificationStatus(int service, bool alert, bool ok);
static void setVerificationStatus(int service, bool alert, bool ok, S32 status);
LLCheckBoxCtrl* mMachineTranslationCB;
LLComboBox* mLanguageCombo;
LLLineEditor* mBingAPIKeyEditor;
LLComboBox* mAzureAPIEndpointEditor;;
LLLineEditor* mAzureAPIKeyEditor;
LLLineEditor* mAzureAPIRegionEditor;
LLLineEditor* mGoogleAPIKeyEditor;
LLRadioGroup* mTranslationServiceRadioGroup;
LLButton* mBingVerifyBtn;
LLButton* mAzureVerifyBtn;
LLButton* mGoogleVerifyBtn;
LLButton* mOKBtn;
bool mBingKeyVerified;
bool mAzureKeyVerified;
bool mGoogleKeyVerified;
};

View File

@ -939,7 +939,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/)
{ //set state of UI to match state of texture entry(ies) (calls setEnabled, setValue, etc, but NOT setVisible)
LLViewerObject* objectp = LLSelectMgr::getInstance()->getSelection()->getFirstObject();
if( objectp
if (objectp
&& objectp->getPCode() == LL_PCODE_VOLUME
&& objectp->permModify())
{
@ -965,7 +965,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/)
}
//LLRadioGroup* radio_mat_type = getChild<LLRadioGroup>("radio_material_type");
if(mRadioMatType)
if (mRadioMatType)
{
if (mRadioMatType->getSelectedIndex() < MATTYPE_DIFFUSE)
{
@ -999,12 +999,12 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/)
{
getChildView("color label")->setEnabled(editable);
}
//LLColorSwatchCtrl* color_swatch = findChild<LLColorSwatchCtrl>("colorswatch");
//LLColorSwatchCtrl* color_swatch = findChild<LLColorSwatchCtrl>("colorswatch");
LLColor4 color = LLColor4::white;
bool identical_color = false;
LLColor4 color = LLColor4::white;
bool identical_color = false;
if(mColorSwatch)
if (mColorSwatch)
{
LLSelectedTE::getColor(color, identical_color);
LLColor4 prev_color = mColorSwatch->get();
@ -1038,7 +1038,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/)
LLCtrlSelectionInterface* combobox_shininess = childGetSelectionInterface("combobox shininess");
if (combobox_shininess)
{
{
combobox_shininess->selectNthItem((S32)shiny);
}
@ -1058,8 +1058,8 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/)
getChild<LLUICtrl>("shinycolorswatch")->setTentative(!identical_spec);
//LLColorSwatchCtrl* mShinyColorSwatch = getChild<LLColorSwatchCtrl>("shinycolorswatch");
if(mShinyColorSwatch)
{
if (mShinyColorSwatch)
{
mShinyColorSwatch->setValid(editable);
mShinyColorSwatch->setEnabled( editable );
mShinyColorSwatch->setCanApplyImmediately( editable );
@ -1067,7 +1067,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/)
U8 bumpy = 0;
// Bumpy
{
{
bool identical_bumpy = false;
LLSelectedTE::getBumpmap(bumpy,identical_bumpy);
@ -1077,18 +1077,18 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/)
bumpy = norm_map_id.isNull() ? bumpy : BUMPY_TEXTURE;
if (combobox_bumpiness)
{
{
combobox_bumpiness->selectNthItem((S32)bumpy);
}
}
else
{
{
LL_WARNS() << "failed childGetSelectionInterface for 'combobox bumpiness'" << LL_ENDL;
}
}
getChildView("combobox bumpiness")->setEnabled(editable);
getChild<LLUICtrl>("combobox bumpiness")->setTentative(!identical_bumpy);
getChildView("label bumpiness")->setEnabled(editable);
}
}
// Texture
{
@ -1102,25 +1102,25 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/)
bool identical_image_format = false;
LLSelectedTE::getImageFormat(image_format, identical_image_format);
mIsAlpha = FALSE;
switch (image_format)
{
case GL_RGBA:
case GL_ALPHA:
{
mIsAlpha = TRUE;
}
break;
case GL_RGB: break;
default:
{
LL_WARNS() << "Unexpected tex format in LLPanelFace...resorting to no alpha" << LL_ENDL;
}
break;
mIsAlpha = FALSE;
switch (image_format)
{
case GL_RGBA:
case GL_ALPHA:
{
mIsAlpha = TRUE;
}
break;
if(LLViewerMedia::getInstance()->textureHasMedia(id))
case GL_RGB: break;
default:
{
LL_WARNS() << "Unexpected tex format in LLPanelFace...resorting to no alpha" << LL_ENDL;
}
break;
}
if (LLViewerMedia::getInstance()->textureHasMedia(id))
{
getChildView("button align")->setEnabled(editable);
}
@ -1196,7 +1196,6 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/)
mTextureCtrl->setBakeTextureEnabled(TRUE);
}
}
if (mShinyTextureCtrl)
@ -1468,15 +1467,14 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/)
combobox_texgen->selectNthItem(((S32)selected_texgen) >> 1);
}
else
{
{
LL_WARNS() << "failed childGetSelectionInterface for 'combobox texgen'" << LL_ENDL;
}
}
getChildView("combobox texgen")->setEnabled(editable);
getChild<LLUICtrl>("combobox texgen")->setTentative(!identical);
getChildView("tex gen")->setEnabled(editable);
}
}
{
U8 fullbright_flag = 0;
@ -1506,7 +1504,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/)
LLComboBox* mComboTexGen = getChild<LLComboBox>("combobox texgen");
if (mComboTexGen)
{
{
S32 index = mComboTexGen ? mComboTexGen->getCurrentIndex() : 0;
BOOL enabled = editable && (index != 1);
BOOL identical_repeats = true;
@ -1516,27 +1514,27 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/)
LLSelectMgr::getInstance()->setTextureChannel(LLRender::eTexIndex(material_type));
switch (material_type)
{
{
default:
case MATTYPE_DIFFUSE:
{
{
enabled = editable && !id.isNull();
identical_repeats = identical_diff_repeats;
repeats = repeats_diff;
}
}
break;
case MATTYPE_SPECULAR:
{
{
enabled = (editable && ((shiny == SHINY_TEXTURE) && !specmap_id.isNull())
&& enable_material_controls); // <FS:CR> Materials Alignment
identical_repeats = identical_spec_repeats;
repeats = repeats_spec;
}
}
break;
case MATTYPE_NORMAL:
{
{
enabled = (editable && ((bumpy == BUMPY_TEXTURE) && !normmap_id.isNull())
&& enable_material_controls); // <FS:CR> Materials Alignment
identical_repeats = identical_norm_repeats;
@ -1591,14 +1589,14 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/)
if (!mIsAlpha)
{ // ... unless there is no alpha channel in the texture, in which case alpha mode MUST ebe none
alpha_mode = LLMaterial::DIFFUSE_ALPHA_MODE_NONE;
}
}
combobox_alphamode->selectNthItem(alpha_mode);
}
else
{
}
else
{
LL_WARNS() << "failed childGetSelectionInterface for 'combobox alphamode'" << LL_ENDL;
}
}
getChild<LLUICtrl>("maskcutoff")->setValue(material->getAlphaMaskCutoff());
updateAlphaControls();
@ -1610,15 +1608,15 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/)
mShinyTextureCtrl->setImageAssetID(material->getSpecularID());
if (!material->getSpecularID().isNull() && (shiny == SHINY_TEXTURE))
{
{
material->getSpecularOffset(offset_x,offset_y);
material->getSpecularRepeat(repeat_x,repeat_y);
if (identical_planar_texgen)
{
{
repeat_x *= 2.0f;
repeat_y *= 2.0f;
}
}
rot = material->getSpecularRotation();
mCtrlShinyScaleU->setValue(repeat_x);
@ -1630,7 +1628,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/)
getChild<LLUICtrl>("environment")->setValue(material->getEnvironmentIntensity());
updateShinyControls(!material->getSpecularID().isNull(), true);
}
}
// Assert desired colorswatch color to match material AFTER updateShinyControls
// to avoid getting overwritten with the default on some UI state changes.
@ -1695,14 +1693,14 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/)
// Disable non-UICtrls
//LLTextureCtrl* texture_ctrl = getChild<LLTextureCtrl>("texture control");
if(mTextureCtrl)
if (mTextureCtrl)
{
mTextureCtrl->setImageAssetID( LLUUID::null );
mTextureCtrl->setEnabled( FALSE ); // this is a LLUICtrl, but we don't want it to have keyboard focus so we add it as a child, not a ctrl.
// texture_ctrl->setValid(FALSE);
}
//LLColorSwatchCtrl* mColorSwatch = getChild<LLColorSwatchCtrl>("colorswatch");
if(mColorSwatch)
if (mColorSwatch)
{
mColorSwatch->setEnabled( FALSE );
mColorSwatch->setFallbackImage(LLUI::getUIImage("locked_image.j2c") );

View File

@ -137,7 +137,6 @@ protected:
void sendShiny(U32 shininess); // applies and sends shininess
void sendFullbright(); // applies and sends full bright
void sendGlow();
void sendMedia();
void alignTestureLayer();
void updateCopyTexButton();
@ -272,7 +271,6 @@ public:
// </FS>
private:
bool isAlpha() { return mIsAlpha; }
// Convenience funcs to keep the visual flack to a minimum
@ -281,10 +279,10 @@ private:
LLUUID getCurrentSpecularMap();
U32 getCurrentShininess();
U32 getCurrentBumpiness();
U8 getCurrentDiffuseAlphaMode();
U8 getCurrentAlphaMaskCutoff();
U8 getCurrentEnvIntensity();
U8 getCurrentGlossiness();
U8 getCurrentDiffuseAlphaMode();
U8 getCurrentAlphaMaskCutoff();
U8 getCurrentEnvIntensity();
U8 getCurrentGlossiness();
F32 getCurrentBumpyRot();
F32 getCurrentBumpyScaleU();
F32 getCurrentBumpyScaleV();
@ -386,7 +384,7 @@ private:
U32 new_alpha_mode = new_material->getDiffuseAlphaMode();
LLUUID new_normal_map_id = new_material->getNormalID();
LLUUID new_spec_map_id = new_material->getSpecularID();
LLUUID new_spec_map_id = new_material->getSpecularID();
if ((new_alpha_mode == LLMaterial::DIFFUSE_ALPHA_MODE_BLEND) && !is_alpha_face)
{
@ -602,7 +600,6 @@ public:
class LLSelectedTE
{
public:
static void getFace(class LLFace*& face_to_return, bool& identical_face);
static void getImageFormat(LLGLenum& image_format_to_return, bool& identical_face);
static void getTexId(LLUUID& id, bool& identical);

View File

@ -1543,7 +1543,8 @@ void LLPanelObjectInventory::reset()
LLEditMenuHandler::gEditMenuHandler = mFolders;
}
LLRect scroller_rect(0, getRect().getHeight(), getRect().getWidth(), 0);
int offset = hasBorder() ? getBorder()->getBorderWidth() << 1 : 0;
LLRect scroller_rect(0, getRect().getHeight() - offset, getRect().getWidth() - offset, 0);
LLScrollContainer::Params scroll_p;
scroll_p.name("task inventory scroller");
scroll_p.rect(scroller_rect);

View File

@ -563,6 +563,7 @@ void LLPanelProfilePick::setAvatarId(const LLUUID& avatar_id)
pick_name = parcel->getName();
pick_desc = parcel->getDesc();
snapshot_id = parcel->getSnapshotID();
mPickDescription->setParseHTML(false);
}
LLViewerRegion* region = gAgent.getRegion();

View File

@ -617,8 +617,6 @@ void LLPanelWearing::onRemoveAttachment()
{
LLSelectMgr::getInstance()->deselectAll();
LLSelectMgr::getInstance()->selectObjectAndFamily(mAttachmentsMap[item->getUUID()]);
// <FS:Ansariel> Can't drop to the ground, so detach instead
//LLSelectMgr::getInstance()->sendDropAttachment();
LLSelectMgr::getInstance()->sendDetach();
}
}

View File

@ -2062,8 +2062,16 @@ bool idle_startup()
}
else if (regionp->capabilitiesError())
{
// Try to connect despite capabilities' error state
LLStartUp::setStartupState(STATE_SEED_CAP_GRANTED);
LL_WARNS("AppInit") << "Failed to get capabilities. Backing up to login screen!" << LL_ENDL;
if (gRememberPassword)
{
LLNotificationsUtil::add("LoginPacketNeverReceived", LLSD(), LLSD(), login_alert_status);
}
else
{
LLNotificationsUtil::add("LoginPacketNeverReceivedNoTP", LLSD(), LLSD(), login_alert_status);
}
reset_login();
}
else
{

View File

@ -41,8 +41,8 @@
#include "llurlregistry.h"
static const std::string BING_NOTRANSLATE_OPENING_TAG("<div class=\"notranslate\">");
static const std::string BING_NOTRANSLATE_CLOSING_TAG("</div>");
static const std::string AZURE_NOTRANSLATE_OPENING_TAG("<div translate=\"no\">");
static const std::string AZURE_NOTRANSLATE_CLOSING_TAG("</div>");
/**
* Handler of an HTTP machine translation service.
@ -80,7 +80,18 @@ public:
* @param[in] key Key to verify.
*/
virtual std::string getKeyVerificationURL(
const std::string &key) const = 0;
const LLSD &key) const = 0;
/**
* Check API verification response.
*
* @param[out] bool true if valid.
* @param[in] response
* @param[in] status
*/
virtual bool checkVerificationResponse(
const LLSD &response,
int status) const = 0;
/**
* Parse translation response.
@ -92,6 +103,7 @@ public:
* @param[out] err_msg Error message (in case of error).
*/
virtual bool parseResponse(
const LLSD& http_response,
int& status,
const std::string& body,
std::string& translation,
@ -105,14 +117,28 @@ public:
virtual LLTranslate::EService getCurrentService() = 0;
virtual void verifyKey(const std::string &key, LLTranslate::KeyVerificationResult_fn fnc) = 0;
virtual void verifyKey(const LLSD &key, LLTranslate::KeyVerificationResult_fn fnc) = 0;
virtual void translateMessage(LanguagePair_t fromTo, std::string msg, LLTranslate::TranslationSuccess_fn success, LLTranslate::TranslationFailure_fn failure);
virtual ~LLTranslationAPIHandler() {}
void verifyKeyCoro(LLTranslate::EService service, std::string key, LLTranslate::KeyVerificationResult_fn fnc);
void verifyKeyCoro(LLTranslate::EService service, LLSD key, LLTranslate::KeyVerificationResult_fn fnc);
void translateMessageCoro(LanguagePair_t fromTo, std::string msg, LLTranslate::TranslationSuccess_fn success, LLTranslate::TranslationFailure_fn failure);
virtual void initHttpHeader(LLCore::HttpHeaders::ptr_t headers, const std::string& user_agent) const = 0;
virtual void initHttpHeader(LLCore::HttpHeaders::ptr_t headers, const std::string& user_agent, const LLSD &key) const = 0;
virtual LLSD sendMessageAndSuspend(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t adapter,
LLCore::HttpRequest::ptr_t request,
LLCore::HttpOptions::ptr_t options,
LLCore::HttpHeaders::ptr_t headers,
const std::string & url,
const std::string & msg) const = 0;
virtual LLSD verifyAndSuspend(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t adapter,
LLCore::HttpRequest::ptr_t request,
LLCore::HttpOptions::ptr_t options,
LLCore::HttpHeaders::ptr_t headers,
const std::string & url) const = 0;
};
void LLTranslationAPIHandler::translateMessage(LanguagePair_t fromTo, std::string msg, LLTranslate::TranslationSuccess_fn success, LLTranslate::TranslationFailure_fn failure)
@ -122,8 +148,7 @@ void LLTranslationAPIHandler::translateMessage(LanguagePair_t fromTo, std::strin
}
void LLTranslationAPIHandler::verifyKeyCoro(LLTranslate::EService service, std::string key, LLTranslate::KeyVerificationResult_fn fnc)
void LLTranslationAPIHandler::verifyKeyCoro(LLTranslate::EService service, LLSD key, LLTranslate::KeyVerificationResult_fn fnc)
{
LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
@ -140,8 +165,7 @@ void LLTranslationAPIHandler::verifyKeyCoro(LLTranslate::EService service, std::
LLVersionInfo::instance().getPatch(),
LLVersionInfo::instance().getBuild());
httpHeaders->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_TEXT_PLAIN);
httpHeaders->append(HTTP_OUT_HEADER_USER_AGENT, user_agent);
initHttpHeader(httpHeaders, user_agent, key);
httpOpts->setFollowRedirects(true);
httpOpts->setSSLVerifyPeer(false);
@ -153,17 +177,29 @@ void LLTranslationAPIHandler::verifyKeyCoro(LLTranslate::EService service, std::
return;
}
LLSD result = httpAdapter->getAndSuspend(httpRequest, url, httpOpts, httpHeaders);
std::string::size_type delim_pos = url.find("://");
if (delim_pos == std::string::npos)
{
LL_INFOS("Translate") << "URL is missing a scheme" << LL_ENDL;
return;
}
LLSD result = verifyAndSuspend(httpAdapter, httpRequest, httpOpts, httpHeaders, url);
LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
bool bOk = true;
if (!status)
int parseResult = status.getType();
if (!checkVerificationResponse(httpResults, parseResult))
{
bOk = false;
}
if (!fnc.empty())
fnc(service, bOk);
{
fnc(service, bOk, parseResult);
}
}
void LLTranslationAPIHandler::translateMessageCoro(LanguagePair_t fromTo, std::string msg,
@ -184,8 +220,7 @@ void LLTranslationAPIHandler::translateMessageCoro(LanguagePair_t fromTo, std::s
LLVersionInfo::instance().getPatch(),
LLVersionInfo::instance().getBuild());
httpHeaders->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_TEXT_PLAIN);
httpHeaders->append(HTTP_OUT_HEADER_USER_AGENT, user_agent);
initHttpHeader(httpHeaders, user_agent);
httpOpts->setSSLVerifyPeer(false);
std::string url = this->getTranslateURL(fromTo.first, fromTo.second, msg);
@ -195,7 +230,7 @@ void LLTranslationAPIHandler::translateMessageCoro(LanguagePair_t fromTo, std::s
return;
}
LLSD result = httpAdapter->getRawAndSuspend(httpRequest, url, httpOpts, httpHeaders);
LLSD result = sendMessageAndSuspend(httpAdapter, httpRequest, httpOpts, httpHeaders, url, msg);
if (LLApp::isQuitting())
{
@ -216,7 +251,7 @@ void LLTranslationAPIHandler::translateMessageCoro(LanguagePair_t fromTo, std::s
try
{
res = this->parseResponse(parseResult, body, translation, detected_lang, err_msg);
res = this->parseResponse(httpResults, parseResult, body, translation, detected_lang, err_msg);
}
catch (std::out_of_range&)
{
@ -242,6 +277,11 @@ void LLTranslationAPIHandler::translateMessageCoro(LanguagePair_t fromTo, std::s
}
else
{
if (err_msg.empty() && httpResults.has("error_body"))
{
err_msg = httpResults["error_body"].asString();
}
if (err_msg.empty())
{
err_msg = LLTrans::getString("TranslationResponseParseError");
@ -262,23 +302,42 @@ class LLGoogleTranslationHandler : public LLTranslationAPIHandler
LOG_CLASS(LLGoogleTranslationHandler);
public:
/*virtual*/ std::string getTranslateURL(
std::string getTranslateURL(
const std::string &from_lang,
const std::string &to_lang,
const std::string &text) const;
/*virtual*/ std::string getKeyVerificationURL(
const std::string &key) const;
/*virtual*/ bool parseResponse(
const std::string &text) const override;
std::string getKeyVerificationURL(
const LLSD &key) const override;
bool checkVerificationResponse(
const LLSD &response,
int status) const override;
bool parseResponse(
const LLSD& http_response,
int& status,
const std::string& body,
std::string& translation,
std::string& detected_lang,
std::string& err_msg) const;
/*virtual*/ bool isConfigured() const;
std::string& err_msg) const override;
bool isConfigured() const override;
/*virtual*/ LLTranslate::EService getCurrentService() { return LLTranslate::EService::SERVICE_GOOGLE; }
LLTranslate::EService getCurrentService() override { return LLTranslate::EService::SERVICE_GOOGLE; }
/*virtual*/ void verifyKey(const std::string &key, LLTranslate::KeyVerificationResult_fn fnc);
void verifyKey(const LLSD &key, LLTranslate::KeyVerificationResult_fn fnc) override;
void initHttpHeader(LLCore::HttpHeaders::ptr_t headers, const std::string& user_agent) const override;
void initHttpHeader(LLCore::HttpHeaders::ptr_t headers, const std::string& user_agent, const LLSD &key) const override;
LLSD sendMessageAndSuspend(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t adapter,
LLCore::HttpRequest::ptr_t request,
LLCore::HttpOptions::ptr_t options,
LLCore::HttpHeaders::ptr_t headers,
const std::string & url,
const std::string & msg) const override;
LLSD verifyAndSuspend(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t adapter,
LLCore::HttpRequest::ptr_t request,
LLCore::HttpOptions::ptr_t options,
LLCore::HttpHeaders::ptr_t headers,
const std::string & url) const override;
private:
static void parseErrorResponse(
@ -311,15 +370,24 @@ std::string LLGoogleTranslationHandler::getTranslateURL(
// virtual
std::string LLGoogleTranslationHandler::getKeyVerificationURL(
const std::string& key) const
const LLSD& key) const
{
std::string url = std::string("https://www.googleapis.com/language/translate/v2/languages?key=")
+ key + "&target=en";
std::string url = std::string("https://www.googleapis.com/language/translate/v2/languages?key=")
+ key.asString() +"&target=en";
return url;
}
//virtual
bool LLGoogleTranslationHandler::checkVerificationResponse(
const LLSD &response,
int status) const
{
return status == HTTP_OK;
}
// virtual
bool LLGoogleTranslationHandler::parseResponse(
const LLSD& http_response,
int& status,
const std::string& body,
std::string& translation,
@ -407,75 +475,192 @@ bool LLGoogleTranslationHandler::parseTranslation(
// static
std::string LLGoogleTranslationHandler::getAPIKey()
{
return gSavedSettings.getString("GoogleTranslateAPIKey");
static LLCachedControl<std::string> google_key(gSavedSettings, "GoogleTranslateAPIKey");
return google_key;
}
/*virtual*/
void LLGoogleTranslationHandler::verifyKey(const std::string &key, LLTranslate::KeyVerificationResult_fn fnc)
void LLGoogleTranslationHandler::verifyKey(const LLSD &key, LLTranslate::KeyVerificationResult_fn fnc)
{
LLCoros::instance().launch("Google /Verify Key", boost::bind(&LLTranslationAPIHandler::verifyKeyCoro,
this, LLTranslate::SERVICE_GOOGLE, key, fnc));
}
/*virtual*/
void LLGoogleTranslationHandler::initHttpHeader(LLCore::HttpHeaders::ptr_t headers, const std::string& user_agent) const
{
headers->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_TEXT_PLAIN);
headers->append(HTTP_OUT_HEADER_USER_AGENT, user_agent);
}
/*virtual*/
void LLGoogleTranslationHandler::initHttpHeader(
LLCore::HttpHeaders::ptr_t headers,
const std::string& user_agent,
const LLSD &key) const
{
headers->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_TEXT_PLAIN);
headers->append(HTTP_OUT_HEADER_USER_AGENT, user_agent);
}
LLSD LLGoogleTranslationHandler::sendMessageAndSuspend(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t adapter,
LLCore::HttpRequest::ptr_t request,
LLCore::HttpOptions::ptr_t options,
LLCore::HttpHeaders::ptr_t headers,
const std::string & url,
const std::string & msg) const
{
return adapter->getRawAndSuspend(request, url, options, headers);
}
LLSD LLGoogleTranslationHandler::verifyAndSuspend(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t adapter,
LLCore::HttpRequest::ptr_t request,
LLCore::HttpOptions::ptr_t options,
LLCore::HttpHeaders::ptr_t headers,
const std::string & url) const
{
return adapter->getAndSuspend(request, url, options, headers);
}
//=========================================================================
/// Microsoft Translator v2 API handler.
class LLBingTranslationHandler : public LLTranslationAPIHandler
class LLAzureTranslationHandler : public LLTranslationAPIHandler
{
LOG_CLASS(LLBingTranslationHandler);
LOG_CLASS(LLAzureTranslationHandler);
public:
/*virtual*/ std::string getTranslateURL(
std::string getTranslateURL(
const std::string &from_lang,
const std::string &to_lang,
const std::string &text) const;
/*virtual*/ std::string getKeyVerificationURL(
const std::string &key) const;
/*virtual*/ bool parseResponse(
const std::string &text) const override;
std::string getKeyVerificationURL(
const LLSD &key) const override;
bool checkVerificationResponse(
const LLSD &response,
int status) const override;
bool parseResponse(
const LLSD& http_response,
int& status,
const std::string& body,
std::string& translation,
std::string& detected_lang,
std::string& err_msg) const;
/*virtual*/ bool isConfigured() const;
std::string& err_msg) const override;
bool isConfigured() const override;
/*virtual*/ LLTranslate::EService getCurrentService() { return LLTranslate::EService::SERVICE_BING; }
LLTranslate::EService getCurrentService() override { return LLTranslate::EService::SERVICE_AZURE; }
/*virtual*/ void verifyKey(const std::string &key, LLTranslate::KeyVerificationResult_fn fnc);
void verifyKey(const LLSD &key, LLTranslate::KeyVerificationResult_fn fnc) override;
void initHttpHeader(LLCore::HttpHeaders::ptr_t headers, const std::string& user_agent) const override;
void initHttpHeader(LLCore::HttpHeaders::ptr_t headers, const std::string& user_agent, const LLSD &key) const override;
LLSD sendMessageAndSuspend(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t adapter,
LLCore::HttpRequest::ptr_t request,
LLCore::HttpOptions::ptr_t options,
LLCore::HttpHeaders::ptr_t headers,
const std::string & url,
const std::string & msg) const override;
LLSD verifyAndSuspend(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t adapter,
LLCore::HttpRequest::ptr_t request,
LLCore::HttpOptions::ptr_t options,
LLCore::HttpHeaders::ptr_t headers,
const std::string & url) const override;
private:
static std::string getAPIKey();
static std::string parseErrorResponse(
const std::string& body);
static LLSD getAPIKey();
static std::string getAPILanguageCode(const std::string& lang);
};
//-------------------------------------------------------------------------
// virtual
std::string LLBingTranslationHandler::getTranslateURL(
std::string LLAzureTranslationHandler::getTranslateURL(
const std::string &from_lang,
const std::string &to_lang,
const std::string &text) const
{
std::string url = std::string("http://api.microsofttranslator.com/v2/Http.svc/Translate?appId=")
+ getAPIKey() + "&text=" + LLURI::escape(text) + "&to=" + getAPILanguageCode(to_lang);
if (!from_lang.empty())
{
url += "&from=" + getAPILanguageCode(from_lang);
}
std::string url;
LLSD key = getAPIKey();
if (key.isMap())
{
std::string endpoint = key["endpoint"].asString();
if (*endpoint.rbegin() != '/')
{
endpoint += "/";
}
url = endpoint + std::string("translate?api-version=3.0&to=")
+ getAPILanguageCode(to_lang);
}
return url;
}
// virtual
std::string LLBingTranslationHandler::getKeyVerificationURL(
const std::string& key) const
std::string LLAzureTranslationHandler::getKeyVerificationURL(
const LLSD& key) const
{
std::string url = std::string("http://api.microsofttranslator.com/v2/Http.svc/GetLanguagesForTranslate?appId=")
+ key;
std::string url;
if (key.isMap())
{
std::string endpoint = key["endpoint"].asString();
if (*endpoint.rbegin() != '/')
{
endpoint += "/";
}
url = endpoint + std::string("translate?api-version=3.0&to=en");
}
return url;
}
//virtual
bool LLAzureTranslationHandler::checkVerificationResponse(
const LLSD &response,
int status) const
{
if (status == HTTP_UNAUTHORIZED)
{
LL_DEBUGS("Translate") << "Key unathorised" << LL_ENDL;
return false;
}
if (status == HTTP_NOT_FOUND)
{
LL_DEBUGS("Translate") << "Either endpoint doesn't have requested resource" << LL_ENDL;
return false;
}
if (status != HTTP_BAD_REQUEST)
{
LL_DEBUGS("Translate") << "Unexpected error code" << LL_ENDL;
return false;
}
if (!response.has("error_body"))
{
LL_DEBUGS("Translate") << "Unexpected response, no error returned" << LL_ENDL;
return false;
}
// Expected: "{\"error\":{\"code\":400000,\"message\":\"One of the request inputs is not valid.\"}}"
// But for now just verify response is a valid json
Json::Value root;
Json::Reader reader;
if (!reader.parse(response["error_body"].asString(), root))
{
LL_DEBUGS("Translate") << "Failed to parse error_body:" << reader.getFormatedErrorMessages() << LL_ENDL;
return false;
}
return true;
}
// virtual
bool LLBingTranslationHandler::parseResponse(
bool LLAzureTranslationHandler::parseResponse(
const LLSD& http_response,
int& status,
const std::string& body,
std::string& translation,
@ -484,65 +669,173 @@ bool LLBingTranslationHandler::parseResponse(
{
if (status != HTTP_OK)
{
static const std::string MSG_BEGIN_MARKER = "Message: ";
size_t begin = body.find(MSG_BEGIN_MARKER);
if (begin != std::string::npos)
{
begin += MSG_BEGIN_MARKER.size();
}
else
{
begin = 0;
err_msg.clear();
}
size_t end = body.find("</p>", begin);
err_msg = body.substr(begin, end-begin);
LLStringUtil::replaceString(err_msg, "&#xD;", ""); // strip CR
if (http_response.has("error_body"))
err_msg = parseErrorResponse(http_response["error_body"].asString());
return false;
}
// Sample response: <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">Hola</string>
size_t begin = body.find(">");
if (begin == std::string::npos || begin >= (body.size() - 1))
{
begin = 0;
}
else
{
++begin;
}
//Example:
// "[{\"detectedLanguage\":{\"language\":\"en\",\"score\":1.0},\"translations\":[{\"text\":\"Hello, what is your name?\",\"to\":\"en\"}]}]"
size_t end = body.find("</string>", begin);
Json::Value root;
Json::Reader reader;
detected_lang = ""; // unsupported by this API
translation = body.substr(begin, end-begin);
LLStringUtil::replaceString(translation, "&#xD;", ""); // strip CR
return true;
if (!reader.parse(body, root))
{
err_msg = reader.getFormatedErrorMessages();
return false;
}
if (!root.isArray()) // empty response? should not happen
{
return false;
}
// Request succeeded, extract translation from the response.
const Json::Value& data = root[0U];
if (!data.isObject()
|| !data.isMember("detectedLanguage")
|| !data.isMember("translations"))
{
return false;
}
const Json::Value& detectedLanguage = data["detectedLanguage"];
if (!detectedLanguage.isObject() || !detectedLanguage.isMember("language"))
{
return false;
}
detected_lang = detectedLanguage["language"].asString();
const Json::Value& translations = data["translations"];
if (!translations.isArray() || translations.size() == 0)
{
return false;
}
const Json::Value& first = translations[0U];
if (!first.isObject() || !first.isMember("text"))
{
return false;
}
translation = first["text"].asString();
return true;
}
// virtual
bool LLBingTranslationHandler::isConfigured() const
bool LLAzureTranslationHandler::isConfigured() const
{
return !getAPIKey().empty();
return !getAPIKey().isMap();
}
//static
std::string LLAzureTranslationHandler::parseErrorResponse(
const std::string& body)
{
// Expected: "{\"error\":{\"code\":400000,\"message\":\"One of the request inputs is not valid.\"}}"
// But for now just verify response is a valid json with an error
Json::Value root;
Json::Reader reader;
if (!reader.parse(body, root))
{
return std::string();
}
if (!root.isObject() || !root.isMember("error"))
{
return std::string();
}
const Json::Value& error_map = root["error"];
if (!error_map.isObject() || !error_map.isMember("message"))
{
return std::string();
}
return error_map["message"].asString();
}
// static
std::string LLBingTranslationHandler::getAPIKey()
LLSD LLAzureTranslationHandler::getAPIKey()
{
return gSavedSettings.getString("BingTranslateAPIKey");
static LLCachedControl<LLSD> azure_key(gSavedSettings, "AzureTranslateAPIKey");
return azure_key;
}
// static
std::string LLBingTranslationHandler::getAPILanguageCode(const std::string& lang)
std::string LLAzureTranslationHandler::getAPILanguageCode(const std::string& lang)
{
return lang == "zh" ? "zh-CHT" : lang; // treat Chinese as Traditional Chinese
}
/*virtual*/
void LLBingTranslationHandler::verifyKey(const std::string &key, LLTranslate::KeyVerificationResult_fn fnc)
void LLAzureTranslationHandler::verifyKey(const LLSD &key, LLTranslate::KeyVerificationResult_fn fnc)
{
LLCoros::instance().launch("Bing /Verify Key", boost::bind(&LLTranslationAPIHandler::verifyKeyCoro,
this, LLTranslate::SERVICE_BING, key, fnc));
LLCoros::instance().launch("Azure /Verify Key", boost::bind(&LLTranslationAPIHandler::verifyKeyCoro,
this, LLTranslate::SERVICE_AZURE, key, fnc));
}
/*virtual*/
void LLAzureTranslationHandler::initHttpHeader(
LLCore::HttpHeaders::ptr_t headers,
const std::string& user_agent) const
{
initHttpHeader(headers, user_agent, getAPIKey());
}
/*virtual*/
void LLAzureTranslationHandler::initHttpHeader(
LLCore::HttpHeaders::ptr_t headers,
const std::string& user_agent,
const LLSD &key) const
{
headers->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_JSON);
headers->append(HTTP_OUT_HEADER_USER_AGENT, user_agent);
if (key.has("id"))
{
// Token based autorization
headers->append("Ocp-Apim-Subscription-Key", key["id"].asString());
}
if (key.has("region"))
{
// ex: "westeurope"
headers->append("Ocp-Apim-Subscription-Region", key["region"].asString());
}
}
LLSD LLAzureTranslationHandler::sendMessageAndSuspend(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t adapter,
LLCore::HttpRequest::ptr_t request,
LLCore::HttpOptions::ptr_t options,
LLCore::HttpHeaders::ptr_t headers,
const std::string & url,
const std::string & msg) const
{
LLCore::BufferArray::ptr_t rawbody(new LLCore::BufferArray);
LLCore::BufferArrayStream outs(rawbody.get());
outs << "[{\"text\":\"";
outs << msg;
outs << "\"}]";
return adapter->postRawAndSuspend(request, url, rawbody, options, headers);
}
LLSD LLAzureTranslationHandler::verifyAndSuspend(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t adapter,
LLCore::HttpRequest::ptr_t request,
LLCore::HttpOptions::ptr_t options,
LLCore::HttpHeaders::ptr_t headers,
const std::string & url) const
{
LLCore::BufferArray::ptr_t rawbody(new LLCore::BufferArray);
LLCore::BufferArrayStream outs(rawbody.get());
outs << "[{\"intentionally_invalid_400\"}]";
return adapter->postRawAndSuspend(request, url, rawbody, options, headers);
}
//=========================================================================
@ -557,58 +850,69 @@ void LLTranslate::translateMessage(const std::string &from_lang, const std::stri
std::string LLTranslate::addNoTranslateTags(std::string mesg)
{
if (getPreferredHandler().getCurrentService() != SERVICE_BING)
if (getPreferredHandler().getCurrentService() == SERVICE_GOOGLE)
{
return mesg;
}
std::string upd_msg(mesg);
LLUrlMatch match;
S32 dif = 0;
//surround all links (including SLURLs) with 'no-translate' tags to prevent unnecessary translation
while (LLUrlRegistry::instance().findUrl(mesg, match))
if (getPreferredHandler().getCurrentService() == SERVICE_AZURE)
{
upd_msg.insert(dif + match.getStart(), BING_NOTRANSLATE_OPENING_TAG);
upd_msg.insert(dif + BING_NOTRANSLATE_OPENING_TAG.size() + match.getEnd() + 1, BING_NOTRANSLATE_CLOSING_TAG);
mesg.erase(match.getStart(), match.getEnd() - match.getStart());
dif += match.getEnd() - match.getStart() + BING_NOTRANSLATE_OPENING_TAG.size() + BING_NOTRANSLATE_CLOSING_TAG.size();
// https://learn.microsoft.com/en-us/azure/cognitive-services/translator/prevent-translation
std::string upd_msg(mesg);
LLUrlMatch match;
S32 dif = 0;
//surround all links (including SLURLs) with 'no-translate' tags to prevent unnecessary translation
while (LLUrlRegistry::instance().findUrl(mesg, match))
{
upd_msg.insert(dif + match.getStart(), AZURE_NOTRANSLATE_OPENING_TAG);
upd_msg.insert(dif + AZURE_NOTRANSLATE_OPENING_TAG.size() + match.getEnd() + 1, AZURE_NOTRANSLATE_CLOSING_TAG);
mesg.erase(match.getStart(), match.getEnd() - match.getStart());
dif += match.getEnd() - match.getStart() + AZURE_NOTRANSLATE_OPENING_TAG.size() + AZURE_NOTRANSLATE_CLOSING_TAG.size();
}
return upd_msg;
}
return upd_msg;
return mesg;
}
std::string LLTranslate::removeNoTranslateTags(std::string mesg)
{
if (getPreferredHandler().getCurrentService() != SERVICE_BING)
if (getPreferredHandler().getCurrentService() == SERVICE_GOOGLE)
{
return mesg;
}
std::string upd_msg(mesg);
LLUrlMatch match;
S32 opening_tag_size = BING_NOTRANSLATE_OPENING_TAG.size();
S32 closing_tag_size = BING_NOTRANSLATE_CLOSING_TAG.size();
S32 dif = 0;
//remove 'no-translate' tags we added to the links before
while (LLUrlRegistry::instance().findUrl(mesg, match))
{
if (upd_msg.substr(dif + match.getStart() - opening_tag_size, opening_tag_size) == BING_NOTRANSLATE_OPENING_TAG)
{
upd_msg.erase(dif + match.getStart() - opening_tag_size, opening_tag_size);
dif -= opening_tag_size;
if (upd_msg.substr(dif + match.getEnd() + 1, closing_tag_size) == BING_NOTRANSLATE_CLOSING_TAG)
if (getPreferredHandler().getCurrentService() == SERVICE_AZURE)
{
std::string upd_msg(mesg);
LLUrlMatch match;
S32 opening_tag_size = AZURE_NOTRANSLATE_OPENING_TAG.size();
S32 closing_tag_size = AZURE_NOTRANSLATE_CLOSING_TAG.size();
S32 dif = 0;
//remove 'no-translate' tags we added to the links before
while (LLUrlRegistry::instance().findUrl(mesg, match))
{
if (upd_msg.substr(dif + match.getStart() - opening_tag_size, opening_tag_size) == AZURE_NOTRANSLATE_OPENING_TAG)
{
upd_msg.replace(dif + match.getEnd() + 1, closing_tag_size, " ");
dif -= closing_tag_size - 1;
upd_msg.erase(dif + match.getStart() - opening_tag_size, opening_tag_size);
dif -= opening_tag_size;
if (upd_msg.substr(dif + match.getEnd() + 1, closing_tag_size) == AZURE_NOTRANSLATE_CLOSING_TAG)
{
upd_msg.replace(dif + match.getEnd() + 1, closing_tag_size, " ");
dif -= closing_tag_size - 1;
}
}
mesg.erase(match.getStart(), match.getUrl().size());
dif += match.getUrl().size();
}
mesg.erase(match.getStart(), match.getUrl().size());
dif += match.getUrl().size();
return upd_msg;
}
return upd_msg;
return mesg;
}
/*static*/
void LLTranslate::verifyKey(EService service, const std::string &key, KeyVerificationResult_fn fnc)
void LLTranslate::verifyKey(EService service, const LLSD &key, KeyVerificationResult_fn fnc)
{
LLTranslationAPIHandler& handler = getHandler(service);
@ -637,7 +941,7 @@ bool LLTranslate::isTranslationConfigured()
// static
LLTranslationAPIHandler& LLTranslate::getPreferredHandler()
{
EService service = SERVICE_BING;
EService service = SERVICE_AZURE;
std::string service_str = gSavedSettings.getString("TranslationService");
if (service_str == "google")
@ -652,12 +956,12 @@ LLTranslationAPIHandler& LLTranslate::getPreferredHandler()
LLTranslationAPIHandler& LLTranslate::getHandler(EService service)
{
static LLGoogleTranslationHandler google;
static LLBingTranslationHandler bing;
static LLAzureTranslationHandler azure;
if (service == SERVICE_GOOGLE)
{
return google;
}
return bing;
return azure;
}

View File

@ -55,11 +55,11 @@ class LLTranslate
public :
typedef enum e_service {
SERVICE_BING,
SERVICE_AZURE,
SERVICE_GOOGLE,
} EService;
typedef boost::function<void(EService, bool)> KeyVerificationResult_fn;
typedef boost::function<void(EService, bool, S32)> KeyVerificationResult_fn;
typedef boost::function<void(std::string , std::string )> TranslationSuccess_fn;
typedef boost::function<void(int, std::string)> TranslationFailure_fn;
@ -74,12 +74,12 @@ public :
static void translateMessage(const std::string &from_lang, const std::string &to_lang, const std::string &mesg, TranslationSuccess_fn success, TranslationFailure_fn failure);
/**
* Verify given API key of a translation service.
*
* @param receiver Object to pass verification result to.
* @param key Key to verify.
*/
static void verifyKey(EService service, const std::string &key, KeyVerificationResult_fn fnc);
* Verify given API key of a translation service.
*
* @param receiver Object to pass verification result to.
* @param key Key to verify.
*/
static void verifyKey(EService service, const LLSD &key, KeyVerificationResult_fn fnc);
/**
* @return translation target language

View File

@ -339,10 +339,6 @@ void handle_object_owner_permissive(void*);
void handle_object_lock(void*);
void handle_object_asset_ids(void*);
void force_take_copy(void*);
#ifdef _CORY_TESTING
void force_export_copy(void*);
void force_import_geometry(void*);
#endif
void handle_force_parcel_owner_to_me(void*);
void handle_force_parcel_to_content(void*);

View File

@ -285,9 +285,6 @@ void LLMediaFilePicker::notify(const std::vector<std::string>& filenames)
static std::string SOUND_EXTENSIONS = "wav";
static std::string IMAGE_EXTENSIONS = "tga bmp jpg jpeg png";
static std::string ANIM_EXTENSIONS = "bvh anim";
#ifdef _CORY_TESTING
static std::string GEOMETRY_EXTENSIONS = "slg";
#endif
static std::string XML_EXTENSIONS = "xml";
static std::string SLOBJECT_EXTENSIONS = "slobject";
#endif
@ -309,10 +306,6 @@ std::string build_extensions_string(LLFilePicker::ELoadFilter filter)
return SLOBJECT_EXTENSIONS;
case LLFilePicker::FFLOAD_MODEL:
return MODEL_EXTENSIONS;
#ifdef _CORY_TESTING
case LLFilePicker::FFLOAD_GEOMETRY:
return GEOMETRY_EXTENSIONS;
#endif
case LLFilePicker::FFLOAD_XML:
return XML_EXTENSIONS;
case LLFilePicker::FFLOAD_ALL:

View File

@ -423,9 +423,6 @@ void LLViewerTextureManager::init()
LLViewerFetchedTexture::sDefaultImagep->dontDiscard();
LLViewerFetchedTexture::sDefaultImagep->setCategory(LLGLTexture::OTHER);
LLViewerFetchedTexture::sSmokeImagep = LLViewerTextureManager::getFetchedTexture(IMG_SMOKE, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI);
LLViewerFetchedTexture::sSmokeImagep->setNoDelete();
image_raw = new LLImageRaw(32,32,3);
data = image_raw->getData();

View File

@ -234,6 +234,8 @@ void LLViewerTextureList::doPrefetchImages()
LLViewerTextureManager::getFetchedTexture(IMG_SHOT);
LLViewerTextureManager::getFetchedTexture(IMG_SMOKE_POOF);
LLViewerFetchedTexture::sSmokeImagep = LLViewerTextureManager::getFetchedTexture(IMG_SMOKE, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI);
LLViewerFetchedTexture::sSmokeImagep->setNoDelete();
LLStandardBumpmap::addstandard();

View File

@ -5586,13 +5586,14 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
if (mat)
{
BOOL is_alpha = (facep->getPoolType() == LLDrawPool::POOL_ALPHA) || (facep->getTextureEntry()->getColor().mV[3] < 0.999f) ? TRUE : FALSE;
if (type == LLRenderPass::PASS_ALPHA)
{
shader_mask = mat->getShaderMask(LLMaterial::DIFFUSE_ALPHA_MODE_BLEND);
shader_mask = mat->getShaderMask(LLMaterial::DIFFUSE_ALPHA_MODE_BLEND, is_alpha);
}
else
{
shader_mask = mat->getShaderMask();
shader_mask = mat->getShaderMask(LLMaterial::DIFFUSE_ALPHA_MODE_DEFAULT, is_alpha);
}
}
@ -6190,18 +6191,21 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
}
else
{
// <FS:ND> Even more crash avoidance ...
// if (te->getColor().mV[3] > 0.f || te->getGlow() > 0.f)
if (te && (te->getColor().mV[3] > 0.f || te->getGlow() > 0.f))
// </FS:ND>
{ //only treat as alpha in the pipeline if < 100% transparent
drawablep->setState(LLDrawable::HAS_ALPHA);
add_face(sAlphaFaces, alpha_count, facep);
}
else if (LLDrawPoolAlpha::sShowDebugAlpha)
{
add_face(sAlphaFaces, alpha_count, facep);
}
// <FS:ND> Even more crash avoidance ...
//if (te->getColor().mV[3] > 0.f || te->getGlow() > 0.f)
if (te && (te->getColor().mV[3] > 0.f || te->getGlow() > 0.f))
// </FS:ND>
{ //only treat as alpha in the pipeline if < 100% transparent
drawablep->setState(LLDrawable::HAS_ALPHA);
add_face(sAlphaFaces, alpha_count, facep);
}
else if (LLDrawPoolAlpha::sShowDebugAlpha ||
(gPipeline.sRenderHighlight &&
(LLPipeline::getRenderScriptedBeacons() || LLPipeline::getRenderScriptedTouchBeacons()) &&
drawablep->getVObj() && drawablep->getVObj()->flagScripted()))
{ //draw the transparent face for debugging purposes using a custom texture
add_face(sAlphaFaces, alpha_count, facep);
}
}
}
else
@ -7043,7 +7047,7 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace
LLRenderPass::PASS_NORMSPEC_EMISSIVE,
};
U32 mask = mat->getShaderMask();
U32 mask = mat->getShaderMask(LLMaterial::DIFFUSE_ALPHA_MODE_DEFAULT, is_alpha);
llassert(mask < sizeof(pass)/sizeof(U32));

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<floater
legacy_header_height="18"
height="310"
height="370"
layout="topleft"
name="floater_translation_settings"
help_topic="translation_settings"
@ -9,10 +9,10 @@
title="Chat Translation Settings"
width="485">
<string name="bing_api_key_not_verified">Bing appID not verified. Please try again.</string>
<string name="google_api_key_not_verified">Google API key not verified. Please try again.</string>
<string name="azure_api_key_not_verified">Azure service identifier not verified. Status: [STATUS]. Please check your settings and try again.</string>
<string name="google_api_key_not_verified">Google API key not verified. Status: [STATUS]. Please check your key and try again.</string>
<string name="bing_api_key_verified">Bing appID verified.</string>
<string name="azure_api_key_verified">Azure service identifier verified.</string>
<string name="google_api_key_verified">Google API key verified.</string>
<check_box
@ -128,25 +128,80 @@
<radio_group
follows="top|left"
height="80"
height="140"
layout="topleft"
left_delta="10"
name="translation_service_rg"
top_pad="20"
width="320">
<radio_item
initial_value="bing"
label="Bing Translator"
initial_value="azure"
label="Azure Translator"
layout="topleft"
name="bing" />
name="azure" />
<radio_item
initial_value="google"
label="Google Translate"
layout="topleft"
name="google"
top_pad="55" />
top_pad="115" />
</radio_group>
<text
follows="top|right"
height="20"
layout="topleft"
left="185"
length="1"
name="google_links_text"
top_pad="-142"
type="string"
width="100">
[https://learn.microsoft.com/en-us/azure/cognitive-services/translator/create-translator-resource Setup]
</text>
<text
type="string"
length="1"
follows="top|right"
height="20"
layout="topleft"
left="70"
name="azure_api_endoint_label"
top_pad="8"
width="85">
Endpoint:
</text>
<combo_box
allow_text_entry="true"
follows="left|top"
name="azure_api_endpoint_combo"
height="23"
left_pad="10"
right="-10"
top_delta="-4"
max_chars="512"
value="https://api.cognitive.microsofttranslator.com"
combo_button.scale_image="true">
<combo_box.item
label="https://api.cognitive.microsofttranslator.com"
name="global"
value="https://api.cognitive.microsofttranslator.com" />
<combo_box.item
label="https://api-apc.cognitive.microsofttranslator.com"
name="api-apc"
value="https://api-apc.cognitive.microsofttranslator.com" />
<combo_box.item
label="https://api-eur.cognitive.microsofttranslator.com"
name="api-eur"
value="https://api-eur.cognitive.microsofttranslator.com" />
<combo_box.item
label="https://api-nam.cognitive.microsofttranslator.com"
name="api-nam"
value="https://api-nam.cognitive.microsofttranslator.com" />
</combo_box>
<text
type="string"
length="1"
@ -154,20 +209,20 @@
height="20"
layout="topleft"
left="70"
name="bing_api_key_label"
top_pad="-55"
name="azure_api_key_label"
top_pad="10"
width="85">
Bing [http://www.bing.com/developers/createapp.aspx AppID]:
Azure Key:
</text>
<line_editor
default_text="Enter Bing AppID and click &quot;Verify&quot;"
default_text="Enter Translator Key and click &quot;Verify&quot;"
follows="top|left"
height="20"
layout="topleft"
left_pad="10"
max_length_chars="50"
top_delta="-4"
name="bing_api_key"
name="azure_api_key"
width="210" />
<button
follows="left|top"
@ -175,9 +230,31 @@
label="Verify"
layout="topleft"
left_pad="10"
name="verify_bing_api_key_btn"
name="verify_azure_api_key_btn"
top_delta="-2"
width="90" />
width="90" />
<text
type="string"
length="1"
follows="top|right"
height="20"
layout="topleft"
left="70"
name="azure_api_region_label"
top_pad="10"
width="85">
Region:
</text>
<line_editor
default_text="Can be left empty for global services"
follows="top|left"
height="20"
layout="topleft"
left_pad="10"
max_length_chars="50"
top_delta="-4"
name="azure_api_region"
width="210" />
<text
follows="top|right"
@ -186,7 +263,7 @@
left="70"
length="1"
name="google_api_key_label"
top_pad="50"
top_pad="55"
type="string"
width="85">
Google [http://code.google.com/apis/language/translate/v2/getting_started.html#auth API key]:

View File

@ -7,7 +7,7 @@
<accordion name="wearable_accordion">
<accordion_tab name="hair_color_tab" title="Cor"/>
<accordion_tab name="hair_style_tab" title="Estilo"/>
<accordion_tab name="hair_eyebrows_tab" title="Sombrancelhas"/>
<accordion_tab name="hair_eyebrows_tab" title="Sobrancelhas"/>
<accordion_tab name="hair_facial_tab" title="Faciais"/>
</accordion>
</panel>