Kaydet (Commit) 56a95946 authored tarafından Michael Meeks's avatar Michael Meeks

Update-check, expand to allow reporting of H/W and OS versions.

Off by default.
Expand config options to show the user agent used.
Re-use this to show more useful info in Help->About too.

Change-Id: I1044116ef9beeb341a537c0f4451dca54e198f67
Reviewed-on: https://gerrit.libreoffice.org/20098Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
üst 91cbbb77
...@@ -48,7 +48,6 @@ ...@@ -48,7 +48,6 @@
#include <rtl/ustrbuf.hxx> #include <rtl/ustrbuf.hxx>
#include <vcl/bitmap.hxx> #include <vcl/bitmap.hxx>
#include <officecfg/Office/Common.hxx> #include <officecfg/Office/Common.hxx>
#include <vcl/opengl/OpenGLWrapper.hxx>
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans; using namespace ::com::sun::star::beans;
...@@ -295,10 +294,9 @@ OUString AboutDialog::GetVersionString() ...@@ -295,10 +294,9 @@ OUString AboutDialog::GetVersionString()
sVersion += m_sBuildStr.replaceAll("$BUILDID", sBuildId); sVersion += m_sBuildStr.replaceAll("$BUILDID", sBuildId);
} }
if (OpenGLWrapper::isVCLOpenGLEnabled()) sVersion += "\n";
{ sVersion += Application::GetHWOSConfInfo();
sVersion += "-GL"; sVersion += "\n";
}
if (EXTRA_BUILDID[0] != '\0') if (EXTRA_BUILDID[0] != '\0')
{ {
......
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/ui/dialogs/FolderPicker.hpp> #include <com/sun/star/ui/dialogs/FolderPicker.hpp>
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
#include <com/sun/star/deployment/UpdateInformationProvider.hpp>
#include <com/sun/star/ucb/XWebDAVCommandEnvironment.hpp>
#include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp>
#include <com/sun/star/util/XChangesBatch.hpp> #include <com/sun/star/util/XChangesBatch.hpp>
...@@ -38,9 +40,7 @@ ...@@ -38,9 +40,7 @@
#include <osl/file.hxx> #include <osl/file.hxx>
#include <osl/security.hxx> #include <osl/security.hxx>
using namespace ::com::sun::star; using namespace ::css;
// class SvxOnlineUpdateTabPage --------------------------------------------------
SvxOnlineUpdateTabPage::SvxOnlineUpdateTabPage(vcl::Window* pParent, const SfxItemSet& rSet) SvxOnlineUpdateTabPage::SvxOnlineUpdateTabPage(vcl::Window* pParent, const SfxItemSet& rSet)
: SfxTabPage(pParent, "OptOnlineUpdatePage", "cui/ui/optonlineupdatepage.ui", &rSet) : SfxTabPage(pParent, "OptOnlineUpdatePage", "cui/ui/optonlineupdatepage.ui", &rSet)
...@@ -56,8 +56,11 @@ SvxOnlineUpdateTabPage::SvxOnlineUpdateTabPage(vcl::Window* pParent, const SfxIt ...@@ -56,8 +56,11 @@ SvxOnlineUpdateTabPage::SvxOnlineUpdateTabPage(vcl::Window* pParent, const SfxIt
get(m_pDestPath, "destpath"); get(m_pDestPath, "destpath");
get(m_pChangePathButton, "changepath"); get(m_pChangePathButton, "changepath");
get(m_pLastChecked, "lastchecked"); get(m_pLastChecked, "lastchecked");
get(m_pExtrasCheckBox, "extrabits");
get(m_pUserAgentLabel, "useragent");
m_pAutoCheckCheckBox->SetClickHdl( LINK( this, SvxOnlineUpdateTabPage, AutoCheckHdl_Impl ) ); m_pAutoCheckCheckBox->SetClickHdl( LINK( this, SvxOnlineUpdateTabPage, AutoCheckHdl_Impl ) );
m_pExtrasCheckBox->SetClickHdl( LINK( this, SvxOnlineUpdateTabPage, ExtrasCheckHdl_Impl ) );
m_pCheckNowButton->SetClickHdl( LINK( this, SvxOnlineUpdateTabPage, CheckNowHdl_Impl ) ); m_pCheckNowButton->SetClickHdl( LINK( this, SvxOnlineUpdateTabPage, CheckNowHdl_Impl ) );
m_pChangePathButton->SetClickHdl( LINK( this, SvxOnlineUpdateTabPage, FileDialogHdl_Impl ) ); m_pChangePathButton->SetClickHdl( LINK( this, SvxOnlineUpdateTabPage, FileDialogHdl_Impl ) );
...@@ -80,6 +83,7 @@ SvxOnlineUpdateTabPage::SvxOnlineUpdateTabPage(vcl::Window* pParent, const SfxIt ...@@ -80,6 +83,7 @@ SvxOnlineUpdateTabPage::SvxOnlineUpdateTabPage(vcl::Window* pParent, const SfxIt
m_aLastCheckedTemplate = m_pLastChecked->GetText(); m_aLastCheckedTemplate = m_pLastChecked->GetText();
UpdateLastCheckedText(); UpdateLastCheckedText();
UpdateUserAgent();
} }
SvxOnlineUpdateTabPage::~SvxOnlineUpdateTabPage() SvxOnlineUpdateTabPage::~SvxOnlineUpdateTabPage()
...@@ -99,10 +103,12 @@ void SvxOnlineUpdateTabPage::dispose() ...@@ -99,10 +103,12 @@ void SvxOnlineUpdateTabPage::dispose()
m_pDestPath.clear(); m_pDestPath.clear();
m_pChangePathButton.clear(); m_pChangePathButton.clear();
m_pLastChecked.clear(); m_pLastChecked.clear();
m_pExtrasCheckBox.clear();
m_pUserAgentLabel.clear();
SfxTabPage::dispose(); SfxTabPage::dispose();
} }
void SvxOnlineUpdateTabPage::UpdateLastCheckedText() void SvxOnlineUpdateTabPage::UpdateLastCheckedText()
{ {
OUString aDateStr; OUString aDateStr;
...@@ -160,6 +166,36 @@ void SvxOnlineUpdateTabPage::UpdateLastCheckedText() ...@@ -160,6 +166,36 @@ void SvxOnlineUpdateTabPage::UpdateLastCheckedText()
m_pLastChecked->SetText( aText ); m_pLastChecked->SetText( aText );
} }
void SvxOnlineUpdateTabPage::UpdateUserAgent()
{
try {
uno::Reference< ucb::XWebDAVCommandEnvironment > xDav(
css::deployment::UpdateInformationProvider::create(
::comphelper::getProcessComponentContext() ),
css::uno::UNO_QUERY_THROW );
OUString aPseudoURL = "useragent:normal";
if( m_pExtrasCheckBox->IsChecked() )
aPseudoURL = "useragent:extended";
uno::Sequence< beans::StringPair > aHeaders
= xDav->getUserRequestHeaders( aPseudoURL, ucb::WebDAVHTTPMethod(0) );
for ( auto i = aHeaders.begin(); i != aHeaders.end(); ++i )
{
if ( i->First == "User-Agent" )
{
OUString aText = i->Second;
aText = aText.replaceAll(";", ";\n");
aText = aText.replaceAll("(", "\n(");
m_pUserAgentLabel->SetText( aText );
break;
}
}
} catch (const uno::Exception &) {
SAL_WARN( "cui.options", "Unexpected exception fetching User Agent" );
}
}
VclPtr<SfxTabPage> VclPtr<SfxTabPage>
SvxOnlineUpdateTabPage::Create( vcl::Window* pParent, const SfxItemSet* rAttrSet ) SvxOnlineUpdateTabPage::Create( vcl::Window* pParent, const SfxItemSet* rAttrSet )
{ {
...@@ -220,6 +256,13 @@ bool SvxOnlineUpdateTabPage::FillItemSet( SfxItemSet* ) ...@@ -220,6 +256,13 @@ bool SvxOnlineUpdateTabPage::FillItemSet( SfxItemSet* )
bModified = true; bModified = true;
} }
if( m_pExtrasCheckBox->IsValueChangedFromSaved() )
{
bValue = m_pExtrasCheckBox->IsChecked();
m_xUpdateAccess->replaceByName( "ExtendedUserAgent", uno::makeAny( bValue ) );
bModified = true;
}
uno::Reference< util::XChangesBatch > xChangesBatch(m_xUpdateAccess, uno::UNO_QUERY); uno::Reference< util::XChangesBatch > xChangesBatch(m_xUpdateAccess, uno::UNO_QUERY);
if( xChangesBatch.is() && xChangesBatch->hasPendingChanges() ) if( xChangesBatch.is() && xChangesBatch->hasPendingChanges() )
xChangesBatch->commitChanges(); xChangesBatch->commitChanges();
...@@ -227,8 +270,6 @@ bool SvxOnlineUpdateTabPage::FillItemSet( SfxItemSet* ) ...@@ -227,8 +270,6 @@ bool SvxOnlineUpdateTabPage::FillItemSet( SfxItemSet* )
return bModified; return bModified;
} }
void SvxOnlineUpdateTabPage::Reset( const SfxItemSet* ) void SvxOnlineUpdateTabPage::Reset( const SfxItemSet* )
{ {
bool bValue = false; bool bValue = false;
...@@ -266,17 +307,18 @@ void SvxOnlineUpdateTabPage::Reset( const SfxItemSet* ) ...@@ -266,17 +307,18 @@ void SvxOnlineUpdateTabPage::Reset( const SfxItemSet* )
if( osl::FileBase::E_None == osl::FileBase::getSystemPathFromFileURL(sValue, aPath) ) if( osl::FileBase::E_None == osl::FileBase::getSystemPathFromFileURL(sValue, aPath) )
m_pDestPath->SetText(aPath); m_pDestPath->SetText(aPath);
m_xUpdateAccess->getByName( "ExtendedUserAgent" ) >>= bValue;
m_pExtrasCheckBox->Check(bValue);
m_pExtrasCheckBox->SaveValue();
UpdateUserAgent();
m_pAutoDownloadCheckBox->SaveValue(); m_pAutoDownloadCheckBox->SaveValue();
} }
void SvxOnlineUpdateTabPage::FillUserData() void SvxOnlineUpdateTabPage::FillUserData()
{ {
} }
IMPL_LINK_TYPED( SvxOnlineUpdateTabPage, AutoCheckHdl_Impl, Button*, pBox, void ) IMPL_LINK_TYPED( SvxOnlineUpdateTabPage, AutoCheckHdl_Impl, Button*, pBox, void )
{ {
bool bEnabled = static_cast<CheckBox*>(pBox)->IsChecked(); bool bEnabled = static_cast<CheckBox*>(pBox)->IsChecked();
...@@ -286,7 +328,10 @@ IMPL_LINK_TYPED( SvxOnlineUpdateTabPage, AutoCheckHdl_Impl, Button*, pBox, void ...@@ -286,7 +328,10 @@ IMPL_LINK_TYPED( SvxOnlineUpdateTabPage, AutoCheckHdl_Impl, Button*, pBox, void
m_pEveryMonthButton->Enable(bEnabled); m_pEveryMonthButton->Enable(bEnabled);
} }
IMPL_LINK_TYPED( SvxOnlineUpdateTabPage, ExtrasCheckHdl_Impl, Button*, , void )
{
UpdateUserAgent();
}
IMPL_LINK_NOARG_TYPED(SvxOnlineUpdateTabPage, FileDialogHdl_Impl, Button*, void) IMPL_LINK_NOARG_TYPED(SvxOnlineUpdateTabPage, FileDialogHdl_Impl, Button*, void)
{ {
...@@ -308,8 +353,6 @@ IMPL_LINK_NOARG_TYPED(SvxOnlineUpdateTabPage, FileDialogHdl_Impl, Button*, void) ...@@ -308,8 +353,6 @@ IMPL_LINK_NOARG_TYPED(SvxOnlineUpdateTabPage, FileDialogHdl_Impl, Button*, void)
} }
} }
IMPL_LINK_NOARG_TYPED(SvxOnlineUpdateTabPage, CheckNowHdl_Impl, Button*, void) IMPL_LINK_NOARG_TYPED(SvxOnlineUpdateTabPage, CheckNowHdl_Impl, Button*, void)
{ {
uno::Reference < uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext() ); uno::Reference < uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
......
...@@ -39,16 +39,20 @@ private: ...@@ -39,16 +39,20 @@ private:
VclPtr<FixedText> m_pDestPath; VclPtr<FixedText> m_pDestPath;
VclPtr<PushButton> m_pChangePathButton; VclPtr<PushButton> m_pChangePathButton;
VclPtr<FixedText> m_pLastChecked; VclPtr<FixedText> m_pLastChecked;
VclPtr<CheckBox> m_pExtrasCheckBox;
VclPtr<FixedText> m_pUserAgentLabel;
OUString m_aNeverChecked; OUString m_aNeverChecked;
OUString m_aLastCheckedTemplate; OUString m_aLastCheckedTemplate;
DECL_LINK_TYPED(FileDialogHdl_Impl, Button*, void); DECL_LINK_TYPED(FileDialogHdl_Impl, Button*, void);
DECL_LINK_TYPED(CheckNowHdl_Impl, Button*, void); DECL_LINK_TYPED(CheckNowHdl_Impl, Button*, void);
DECL_LINK_TYPED(AutoCheckHdl_Impl, Button*, void); DECL_LINK_TYPED(AutoCheckHdl_Impl, Button*, void);
DECL_LINK_TYPED(ExtrasCheckHdl_Impl, Button*, void);
css::uno::Reference< css::container::XNameReplace > m_xUpdateAccess; css::uno::Reference< css::container::XNameReplace > m_xUpdateAccess;
void UpdateLastCheckedText(); void UpdateLastCheckedText();
void UpdateUserAgent();
public: public:
SvxOnlineUpdateTabPage( vcl::Window* pParent, const SfxItemSet& rSet ); SvxOnlineUpdateTabPage( vcl::Window* pParent, const SfxItemSet& rSet );
......
...@@ -215,6 +215,71 @@ ...@@ -215,6 +215,71 @@
<property name="width">2</property> <property name="width">2</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkCheckButton" id="extrabits">
<property name="label" translatable="yes">_Send OS version &amp; simple hardware info.</property>
<property name="tooltip_text" translatable="yes">This information lets us optimize for your hardware &amp; OS.</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">7</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">8</property>
<property name="homogeneous">False</property>
<child>
<object class="GtkLabel" id="useragent_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="yalign">0</property>
<property name="label" translatable="yes">User Agent:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="useragent_changed">
<property name="visible">False</property>
<property name="can_focus">False</property>
<property name="yalign">0</property>
<property name="label" translatable="yes">Hit apply to update</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="useragent">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">8</property>
<property name="width">2</property>
</packing>
</child>
<child> <child>
<object class="GtkLabel" id="neverchecked"> <object class="GtkLabel" id="neverchecked">
<property name="can_focus">False</property> <property name="can_focus">False</property>
......
...@@ -49,6 +49,9 @@ ...@@ -49,6 +49,9 @@
<prop oor:name="DownloadPaused" oor:type="xs:boolean" oor:op="replace"> <prop oor:name="DownloadPaused" oor:type="xs:boolean" oor:op="replace">
<value>false</value> <value>false</value>
</prop> </prop>
<prop oor:name="ExtendedUserAgent" oor:type="xs:boolean" oor:op="replace">
<value>false</value>
</prop>
</node> </node>
</node> </node>
</node> </node>
......
...@@ -46,6 +46,8 @@ ...@@ -46,6 +46,8 @@
#include <com/sun/star/task/PasswordContainerInteractionHandler.hpp> #include <com/sun/star/task/PasswordContainerInteractionHandler.hpp>
#include <com/sun/star/xml/dom/DocumentBuilder.hpp> #include <com/sun/star/xml/dom/DocumentBuilder.hpp>
#include <com/sun/star/xml/xpath/XPathAPI.hpp> #include <com/sun/star/xml/xpath/XPathAPI.hpp>
#include <com/sun/star/awt/Toolkit.hpp>
#include <com/sun/star/awt/XToolkitExperimental.hpp>
#include <rtl/ref.hxx> #include <rtl/ref.hxx>
#include <rtl/bootstrap.hxx> #include <rtl/bootstrap.hxx>
...@@ -136,6 +138,8 @@ class UpdateInformationProvider : ...@@ -136,6 +138,8 @@ class UpdateInformationProvider :
ucb::XWebDAVCommandEnvironment, ucb::XWebDAVCommandEnvironment,
lang::XServiceInfo > lang::XServiceInfo >
{ {
OUString getUserAgent(bool bExtended);
bool isUserAgentExtended();
public: public:
static uno::Reference< uno::XInterface > createInstance(const uno::Reference<uno::XComponentContext>& xContext); static uno::Reference< uno::XInterface > createInstance(const uno::Reference<uno::XComponentContext>& xContext);
...@@ -176,7 +180,7 @@ public: ...@@ -176,7 +180,7 @@ public:
// XWebDAVCommandEnvironment // XWebDAVCommandEnvironment
virtual uno::Sequence< beans::StringPair > SAL_CALL getUserRequestHeaders( virtual uno::Sequence< beans::StringPair > SAL_CALL getUserRequestHeaders(
const OUString&, ucb::WebDAVHTTPMethod ) const OUString&, ucb::WebDAVHTTPMethod )
throw ( uno::RuntimeException, std::exception ) override { return m_aRequestHeaderList; }; throw ( uno::RuntimeException, std::exception ) override;
// XServiceInfo // XServiceInfo
virtual OUString SAL_CALL getImplementationName() virtual OUString SAL_CALL getImplementationName()
...@@ -190,6 +194,7 @@ protected: ...@@ -190,6 +194,7 @@ protected:
virtual ~UpdateInformationProvider(); virtual ~UpdateInformationProvider();
static OUString getConfigurationItem(uno::Reference<lang::XMultiServiceFactory> const & configurationProvider, OUString const & node, OUString const & item); static OUString getConfigurationItem(uno::Reference<lang::XMultiServiceFactory> const & configurationProvider, OUString const & node, OUString const & item);
static uno::Any getConfigurationItemAny(uno::Reference<lang::XMultiServiceFactory> const & configurationProvider, OUString const & node, OUString const & item);
private: private:
uno::Reference< io::XInputStream > load(const OUString& rURL); uno::Reference< io::XInputStream > load(const OUString& rURL);
...@@ -312,9 +317,6 @@ private: ...@@ -312,9 +317,6 @@ private:
deployment::UpdateInformationEntry m_aEntry; deployment::UpdateInformationEntry m_aEntry;
}; };
UpdateInformationProvider::UpdateInformationProvider( UpdateInformationProvider::UpdateInformationProvider(
const uno::Reference<uno::XComponentContext>& xContext, const uno::Reference<uno::XComponentContext>& xContext,
const uno::Reference< ucb::XUniversalContentBroker >& xUniversalContentBroker, const uno::Reference< ucb::XUniversalContentBroker >& xUniversalContentBroker,
...@@ -324,11 +326,35 @@ UpdateInformationProvider::UpdateInformationProvider( ...@@ -324,11 +326,35 @@ UpdateInformationProvider::UpdateInformationProvider(
, m_xUniversalContentBroker(xUniversalContentBroker) , m_xUniversalContentBroker(xUniversalContentBroker)
, m_xDocumentBuilder(xDocumentBuilder) , m_xDocumentBuilder(xDocumentBuilder)
, m_xXPathAPI(xXPathAPI) , m_xXPathAPI(xXPathAPI)
, m_aRequestHeaderList(1) , m_aRequestHeaderList(2)
, m_nCommandId(0) , m_nCommandId(0)
{ {
uno::Reference< lang::XMultiServiceFactory > xConfigurationProvider( uno::Reference< lang::XMultiServiceFactory > xConfigurationProvider(
css::configuration::theDefaultProvider::get(xContext)); css::configuration::theDefaultProvider::get(m_xContext));
m_aRequestHeaderList[0].First = "Accept-Language";
m_aRequestHeaderList[0].Second = getConfigurationItem( xConfigurationProvider, "org.openoffice.Setup/L10N", "ooLocale" );
}
bool
UpdateInformationProvider::isUserAgentExtended()
{
uno::Reference< lang::XMultiServiceFactory > xConfigurationProvider(
css::configuration::theDefaultProvider::get(m_xContext));
uno::Any aExtended = getConfigurationItemAny(
xConfigurationProvider,
"org.openoffice.Office.Jobs/Jobs/UpdateCheck/Arguments",
"ExtendedUserAgent");
bool bExtendedUserAgent = false;
aExtended >>= bExtendedUserAgent;
return bExtendedUserAgent;
}
OUString UpdateInformationProvider::getUserAgent(bool bExtended)
{
uno::Reference< lang::XMultiServiceFactory > xConfigurationProvider(
css::configuration::theDefaultProvider::get(m_xContext));
OUStringBuffer buf; OUStringBuffer buf;
buf.append( buf.append(
...@@ -342,30 +368,63 @@ UpdateInformationProvider::UpdateInformationProvider( ...@@ -342,30 +368,63 @@ UpdateInformationProvider::UpdateInformationProvider(
xConfigurationProvider, xConfigurationProvider,
"org.openoffice.Setup/Product", "org.openoffice.Setup/Product",
"ooSetupVersion")); "ooSetupVersion"));
OUString extension( OUString extension(
getConfigurationItem( getConfigurationItem(
xConfigurationProvider, xConfigurationProvider,
"org.openoffice.Setup/Product", "org.openoffice.Setup/Product",
"ooSetupExtension")); "ooSetupExtension"));
if (!extension.isEmpty()) { if (!extension.isEmpty())
buf.append(extension); buf.append(extension);
}
OUString product(buf.makeStringAndClear()); OUString product(buf.makeStringAndClear());
OUString aUserAgent( "${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("version") ":UpdateUserAgent}" ); OUString aUserAgent( "${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("version") ":UpdateUserAgent}" );
OUString aExtended;
if( bExtended )
{
try {
uno::Reference< css::awt::XToolkitExperimental > xToolkit(
css::awt::Toolkit::create( m_xContext ), uno::UNO_QUERY_THROW );
if ( xToolkit.is() )
aExtended = xToolkit->getHWOSConfInfo();
} catch (const uno::Exception &) {
SAL_WARN( "extensions.update", "Failed to find version info from toolkit" );
}
}
rtl::Bootstrap::expandMacros( aUserAgent ); rtl::Bootstrap::expandMacros( aUserAgent );
aUserAgent = aUserAgent.replaceAll("<PRODUCT>", product); aUserAgent = aUserAgent.replaceAll("<PRODUCT>", product);
aUserAgent = aUserAgent.replaceAll("<OPTIONAL_OS_HW_DATA>", aExtended);
SAL_INFO("extensions.update", "UpdateUserAgent: " << aUserAgent); SAL_INFO("extensions.update", "UpdateUserAgent: " << aUserAgent);
m_aRequestHeaderList[0].First = "Accept-Language"; return aUserAgent;
m_aRequestHeaderList[0].Second = getConfigurationItem( xConfigurationProvider, "org.openoffice.Setup/L10N", "ooLocale" ); }
if( !aUserAgent.isEmpty() )
uno::Sequence< beans::StringPair > SAL_CALL UpdateInformationProvider::getUserRequestHeaders(
const OUString &aURL, ucb::WebDAVHTTPMethod )
throw ( uno::RuntimeException, std::exception )
{
bool bExtendedUserAgent;
uno::Sequence< beans::StringPair > aPair = m_aRequestHeaderList;
// Internal use from cui/ some magic URLs
if( aURL.startsWith( "useragent:" ) )
bExtendedUserAgent = (aURL == "useragent:extended");
else
bExtendedUserAgent = isUserAgentExtended();
OUString aUserAgent = getUserAgent(bExtendedUserAgent);
if( aUserAgent.isEmpty() )
aPair.realloc(1);
else
{ {
m_aRequestHeaderList.realloc(2); aPair[1].First = "User-Agent";
m_aRequestHeaderList[1].First = "User-Agent"; aPair[1].Second = aUserAgent;
m_aRequestHeaderList[1].Second = aUserAgent;
} }
}
return aPair;
};
uno::Reference< uno::XInterface > uno::Reference< uno::XInterface >
UpdateInformationProvider::createInstance(const uno::Reference<uno::XComponentContext>& xContext) UpdateInformationProvider::createInstance(const uno::Reference<uno::XComponentContext>& xContext)
...@@ -383,18 +442,13 @@ UpdateInformationProvider::createInstance(const uno::Reference<uno::XComponentCo ...@@ -383,18 +442,13 @@ UpdateInformationProvider::createInstance(const uno::Reference<uno::XComponentCo
return *new UpdateInformationProvider(xContext, xUniversalContentBroker, xDocumentBuilder, xXPath); return *new UpdateInformationProvider(xContext, xUniversalContentBroker, xDocumentBuilder, xXPath);
} }
UpdateInformationProvider::~UpdateInformationProvider() UpdateInformationProvider::~UpdateInformationProvider()
{ {
} }
uno::Any
UpdateInformationProvider::getConfigurationItemAny(uno::Reference<lang::XMultiServiceFactory> const & configurationProvider, OUString const & node, OUString const & item)
OUString
UpdateInformationProvider::getConfigurationItem(uno::Reference<lang::XMultiServiceFactory> const & configurationProvider, OUString const & node, OUString const & item)
{ {
rtl::OUString sRet;
beans::PropertyValue aProperty; beans::PropertyValue aProperty;
aProperty.Name = "nodepath"; aProperty.Name = "nodepath";
aProperty.Value = uno::makeAny(node); aProperty.Value = uno::makeAny(node);
...@@ -408,11 +462,16 @@ UpdateInformationProvider::getConfigurationItem(uno::Reference<lang::XMultiServi ...@@ -408,11 +462,16 @@ UpdateInformationProvider::getConfigurationItem(uno::Reference<lang::XMultiServi
aArgumentList ), aArgumentList ),
uno::UNO_QUERY_THROW); uno::UNO_QUERY_THROW);
xNameAccess->getByName(item) >>= sRet; return xNameAccess->getByName(item);
return sRet;
} }
OUString
UpdateInformationProvider::getConfigurationItem(uno::Reference<lang::XMultiServiceFactory> const & configurationProvider, OUString const & node, OUString const & item)
{
OUString sRet;
getConfigurationItemAny(configurationProvider, node, item) >>= sRet;
return sRet;
}
void void
UpdateInformationProvider::storeCommandInfo( UpdateInformationProvider::storeCommandInfo(
...@@ -425,8 +484,6 @@ UpdateInformationProvider::storeCommandInfo( ...@@ -425,8 +484,6 @@ UpdateInformationProvider::storeCommandInfo(
m_xCommandProcessor = rxCommandProcessor; m_xCommandProcessor = rxCommandProcessor;
} }
uno::Reference< io::XInputStream > uno::Reference< io::XInputStream >
UpdateInformationProvider::load(const OUString& rURL) UpdateInformationProvider::load(const OUString& rURL)
{ {
......
...@@ -948,6 +948,11 @@ public: ...@@ -948,6 +948,11 @@ public:
*/ */
static OUString GetAppName(); static OUString GetAppName();
/** Get useful OS, Hardware and configuration information,
* cf. Help->About, and User-Agent
*/
static OUString GetHWOSConfInfo();
/** Load a localized branding PNG file as a bitmap. /** Load a localized branding PNG file as a bitmap.
@param pName Name of the bitmap to load. @param pName Name of the bitmap to load.
......
...@@ -143,7 +143,7 @@ $(call gb_CustomTarget_get_workdir,instsetoo_native/setup)/$(call gb_Helper_get_ ...@@ -143,7 +143,7 @@ $(call gb_CustomTarget_get_workdir,instsetoo_native/setup)/$(call gb_Helper_get_
&& echo 'ReferenceOOoMajorMinor=4.1' \ && echo 'ReferenceOOoMajorMinor=4.1' \
&& echo 'UpdateID=$(PRODUCTNAME)_$(LIBO_VERSION_MAJOR)_en-US' \ && echo 'UpdateID=$(PRODUCTNAME)_$(LIBO_VERSION_MAJOR)_en-US' \
&& echo 'UpdateURL=$(if $(ENABLE_ONLINE_UPDATE),http://update.libreoffice.org/check.php$(if $(filter-out WNT,$(OS)),?pkgfmt=$(PKGFORMAT)))' \ && echo 'UpdateURL=$(if $(ENABLE_ONLINE_UPDATE),http://update.libreoffice.org/check.php$(if $(filter-out WNT,$(OS)),?pkgfmt=$(PKGFORMAT)))' \
&& echo 'UpdateUserAgent=<PRODUCT> ($${buildid}; $${_OS}; $${_ARCH}; BundledLanguages=$${AllLanguages})' \ && echo 'UpdateUserAgent=<PRODUCT> ($${buildid}; $${_OS}; $${_ARCH}; <OPTIONAL_OS_HW_DATA>BundledLanguages=$${AllLanguages})' \
&& echo 'Vendor=$(OOO_VENDOR)' \ && echo 'Vendor=$(OOO_VENDOR)' \
) > $@ ) > $@
......
...@@ -23,6 +23,9 @@ interface XToolkitExperimental : XToolkit2 ...@@ -23,6 +23,9 @@ interface XToolkitExperimental : XToolkit2
*/ */
void processEventsToIdle(); void processEventsToIdle();
/** Get misc. information for User-Agent:
*/
string getHWOSConfInfo();
}; };
}; }; }; }; }; }; }; };
......
...@@ -194,6 +194,8 @@ public: ...@@ -194,6 +194,8 @@ public:
// css::awt::XToolkitExperimental // css::awt::XToolkitExperimental
virtual void SAL_CALL processEventsToIdle() virtual void SAL_CALL processEventsToIdle()
throw (css::uno::RuntimeException, std::exception) override; throw (css::uno::RuntimeException, std::exception) override;
virtual OUString SAL_CALL getHWOSConfInfo()
throw (::css::uno::RuntimeException, ::std::exception) override;
// css::awt::XToolkit // css::awt::XToolkit
css::uno::Reference< css::awt::XWindowPeer > SAL_CALL getDesktopWindow( ) throw(css::uno::RuntimeException, std::exception) override; css::uno::Reference< css::awt::XWindowPeer > SAL_CALL getDesktopWindow( ) throw(css::uno::RuntimeException, std::exception) override;
...@@ -1913,6 +1915,13 @@ void SAL_CALL VCLXToolkit::processEventsToIdle() ...@@ -1913,6 +1915,13 @@ void SAL_CALL VCLXToolkit::processEventsToIdle()
Scheduler::ProcessTaskScheduling(false); Scheduler::ProcessTaskScheduling(false);
} }
OUString SAL_CALL VCLXToolkit::getHWOSConfInfo()
throw (::css::uno::RuntimeException, ::std::exception)
{
SolarMutexGuard aSolarGuard;
return Application::GetHWOSConfInfo();
}
// css:awt:XToolkitRobot // css:awt:XToolkitRobot
void SAL_CALL VCLXToolkit::keyPress( const css::awt::KeyEvent & aKeyEvent ) void SAL_CALL VCLXToolkit::keyPress( const css::awt::KeyEvent & aKeyEvent )
......
...@@ -20,6 +20,10 @@ ...@@ -20,6 +20,10 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#if defined(LINUX)
# include <stdio.h>
#endif
#include <osl/module.hxx> #include <osl/module.hxx>
#include <comphelper/solarmutex.hxx> #include <comphelper/solarmutex.hxx>
#include <vcl/opengl/OpenGLContext.hxx> #include <vcl/opengl/OpenGLContext.hxx>
...@@ -128,4 +132,33 @@ SalGenericInstance::~SalGenericInstance() ...@@ -128,4 +132,33 @@ SalGenericInstance::~SalGenericInstance()
delete mpSalYieldMutex; delete mpSalYieldMutex;
} }
OUString SalGenericInstance::getOSVersion()
{
OUString aKernelVer = "unknown";
// not so generic, but at least shared between all unix backend
#if defined(LINUX)
FILE* pVersion = fopen( "/proc/version", "r" );
if ( pVersion )
{
char aVerBuffer[512];
if ( fgets ( aVerBuffer, 511, pVersion ) )
{
aKernelVer = OUString::createFromAscii( aVerBuffer );
sal_Int32 nIndex = 0;
// "Linux version 3.16.7-29-desktop ..."
OUString aVers = aKernelVer.getToken( 2, ' ', nIndex );
// "3.16.7-29-desktop ..."
sal_Int32 nTooDetailed = aVers.indexOf( '.', 2);
if (nTooDetailed < 1 || nTooDetailed > 8)
aKernelVer = "misparse";
else // "3.16.7-29-desktop ..."
aKernelVer = aVers.copy(0, nTooDetailed);
}
fclose( pVersion );
}
#endif
return aKernelVer;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -105,6 +105,8 @@ public: ...@@ -105,6 +105,8 @@ public:
bool isPrinterInit() const { return mbPrinterInit; } bool isPrinterInit() const { return mbPrinterInit; }
virtual GenPspGraphics *CreatePrintGraphics() = 0; virtual GenPspGraphics *CreatePrintGraphics() = 0;
virtual OUString getOSVersion() override;
// prolly belongs somewhere else ... just a font help // prolly belongs somewhere else ... just a font help
static void RegisterFontSubstitutors( PhysicalFontCollection* pFontCollection ); static void RegisterFontSubstitutors( PhysicalFontCollection* pFontCollection );
static int FetchFontSubstitutionFlags(); static int FetchFontSubstitutionFlags();
......
...@@ -172,6 +172,9 @@ public: ...@@ -172,6 +172,9 @@ public:
virtual void updatePrinterUpdate() {} virtual void updatePrinterUpdate() {}
virtual void jobStartedPrinterUpdate() {} virtual void jobStartedPrinterUpdate() {}
virtual void jobEndedPrinterUpdate() {} virtual void jobEndedPrinterUpdate() {}
/// get information about underlying versions
virtual OUString getOSVersion() { return OUString("-"); }
}; };
// called from SVMain // called from SVMain
......
...@@ -82,6 +82,8 @@ public: ...@@ -82,6 +82,8 @@ public:
virtual void* GetConnectionIdentifier( ConnectionIdentifierType& rReturnedType, int& rReturnedBytes ) override; virtual void* GetConnectionIdentifier( ConnectionIdentifierType& rReturnedType, int& rReturnedBytes ) override;
virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService) override; virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService) override;
virtual OUString getOSVersion() override;
static int WorkaroundExceptionHandlingInUSER32Lib(int nExcept, LPEXCEPTION_POINTERS pExceptionInfo); static int WorkaroundExceptionHandlingInUSER32Lib(int nExcept, LPEXCEPTION_POINTERS pExceptionInfo);
}; };
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#include "vcl/scheduler.hxx" #include "vcl/scheduler.hxx"
#include "vcl/unohelp.hxx" #include "vcl/unohelp.hxx"
#include "vcl/lazydelete.hxx" #include "vcl/lazydelete.hxx"
#include "vcl/opengl/OpenGLWrapper.hxx"
#include "salinst.hxx" #include "salinst.hxx"
#include "salframe.hxx" #include "salframe.hxx"
...@@ -74,6 +75,7 @@ ...@@ -74,6 +75,7 @@
#include <cassert> #include <cassert>
#include <utility> #include <utility>
#include <thread>
using namespace ::com::sun::star; using namespace ::com::sun::star;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
...@@ -1162,6 +1164,36 @@ OUString Application::GetAppName() ...@@ -1162,6 +1164,36 @@ OUString Application::GetAppName()
return OUString(); return OUString();
} }
OUString Application::GetHWOSConfInfo()
{
ImplSVData* pSVData = ImplGetSVData();
OUStringBuffer aDetails;
aDetails.append( "Threads " );
aDetails.append( (sal_Int32)
std::thread::hardware_concurrency() );
aDetails.append( "; " );
OUString aVersion;
if ( pSVData && pSVData->mpDefInst )
aVersion = pSVData->mpDefInst->getOSVersion();
else
aVersion = "-";
aDetails.append( "Ver: " );
aDetails.append( aVersion );
aDetails.append( "; " );
aDetails.append( "Render: " );
if ( OpenGLWrapper::isVCLOpenGLEnabled() )
aDetails.append( "GL" );
else
aDetails.append( "default" );
aDetails.append( "; " );
return aDetails.makeStringAndClear();
}
void Application::SetDisplayName( const OUString& rName ) void Application::SetDisplayName( const OUString& rName )
{ {
ImplSVData* pSVData = ImplGetSVData(); ImplSVData* pSVData = ImplGetSVData();
......
...@@ -115,7 +115,7 @@ class SalYieldMutex : public comphelper::SolarMutex ...@@ -115,7 +115,7 @@ class SalYieldMutex : public comphelper::SolarMutex
public: // for ImplSalYield() public: // for ImplSalYield()
WinSalInstance* mpInstData; WinSalInstance* mpInstData;
sal_uLong mnCount; sal_uLong mnCount;
DWORD mnThreadId; DWORD mnThreadId;
public: public:
...@@ -125,7 +125,7 @@ public: ...@@ -125,7 +125,7 @@ public:
virtual void release(); virtual void release();
virtual bool tryToAcquire(); virtual bool tryToAcquire();
sal_uLong GetAcquireCount( sal_uLong nThreadId ); sal_uLong GetAcquireCount( sal_uLong nThreadId );
}; };
SalYieldMutex::SalYieldMutex( WinSalInstance* pInstData ) SalYieldMutex::SalYieldMutex( WinSalInstance* pInstData )
...@@ -1114,4 +1114,40 @@ int WinSalInstance::WorkaroundExceptionHandlingInUSER32Lib(int, LPEXCEPTION_POIN ...@@ -1114,4 +1114,40 @@ int WinSalInstance::WorkaroundExceptionHandlingInUSER32Lib(int, LPEXCEPTION_POIN
} }
#endif #endif
OUString WinSalInstance::getOSVersion()
{
SalData* pSalData = GetSalData();
if ( !pSalData )
return OUString("unknown");
WORD nMajor = 0, nMinor = 0;
#ifdef _WIN32_WINNT_WINBLUE
// Trying to hide the real version info behind an
// uber-lame non-forward-compatible, 'compatibility' API
// seems unlikely to help OS designers, or API users.
nMajor = 30;
while( !IsWindowsVersionOrGreater( nMajor, 0, 0 ) && nMajor > 0)
nMajor--;
nMinor = 30;
while( !IsWindowsVersionOrGreater( nMajor, nMinor, 0 ) && nMinor > 0)
nMinor--;
#else
OSVERSIONINFO aVersionInfo;
memset( &aVersionInfo, 0, sizeof( aVersionInfo ) );
aVersionInfo.dwOSVersionInfoSize = sizeof( aVersionInfo );
if ( GetVersionEx( &aVersionInfo ) )
{
nMajor = aVersionInfo.dwMajorVersion;
nMinor = aVersionInfo.dwMinorVersion;
}
#endif
OUStringBuffer aVer;
aVer.append( "Windows " );
aVer.append( (sal_Int32)nMajor );
aVer.append( "." );
aVer.append( (sal_Int32)nMinor );
return aVer.makeStringAndClear();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment