PageRenderTime 29ms CodeModel.GetById 17ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

/indra/newview/llagentlanguage.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 75 lines | 34 code | 8 blank | 33 comment | 2 complexity | 5d2eed9519bb294686bcb2ce0a7ae65e MD5 | raw file
 1/**
 2 * @file llagentlanguage.cpp
 3 * @brief Transmit language information to server
 4 *
 5 * $LicenseInfo:firstyear=2006&license=viewerlgpl$
 6 * Second Life Viewer Source Code
 7 * Copyright (C) 2010, Linden Research, Inc.
 8 * 
 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation;
12 * version 2.1 of the License only.
13 * 
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * Lesser General Public License for more details.
18 * 
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 * 
23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
24 * $/LicenseInfo$
25 */
26
27#include "llviewerprecompiledheaders.h"
28#include "llagentlanguage.h"
29// viewer includes
30#include "llagent.h"
31#include "llviewercontrol.h"
32#include "llviewerregion.h"
33// library includes
34#include "llui.h"					// getLanguage()
35
36// static
37void LLAgentLanguage::init()
38{
39	gSavedSettings.getControl("Language")->getSignal()->connect(boost::bind(&onChange));
40	gSavedSettings.getControl("InstallLanguage")->getSignal()->connect(boost::bind(&onChange));
41	gSavedSettings.getControl("SystemLanguage")->getSignal()->connect(boost::bind(&onChange));
42	gSavedSettings.getControl("LanguageIsPublic")->getSignal()->connect(boost::bind(&onChange));
43}
44
45// static
46void LLAgentLanguage::onChange()
47{
48	// Clear inventory cache so that default names of inventory items
49	// appear retranslated (EXT-8308).
50	gSavedSettings.setBOOL("PurgeCacheOnNextStartup", TRUE);
51}
52
53// send language settings to the sim
54// static
55bool LLAgentLanguage::update()
56{
57	LLSD body;
58	std::string url;
59
60	if (gAgent.getRegion())
61	{
62		url = gAgent.getRegion()->getCapability("UpdateAgentLanguage");
63	}
64
65	if (!url.empty())
66	{
67		std::string language = LLUI::getLanguage();
68		
69		body["language"] = language;
70		body["language_is_public"] = gSavedSettings.getBOOL("LanguageIsPublic");
71		
72		LLHTTPClient::post(url, body, new LLHTTPClient::Responder);
73	}
74    return true;
75}