26#include <com/sun/star/configuration/theDefaultProvider.hpp>
27#include <com/sun/star/lang/XMultiServiceFactory.hpp>
28#include <com/sun/star/ui/dialogs/XFolderPicker2.hpp>
29#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
30#include <com/sun/star/deployment/UpdateInformationProvider.hpp>
31#include <com/sun/star/ucb/XWebDAVCommandEnvironment.hpp>
32#include <com/sun/star/frame/Desktop.hpp>
33#include <com/sun/star/frame/XDispatchProvider.hpp>
34#include <com/sun/star/util/XChangesBatch.hpp>
35#include <com/sun/star/util/URLTransformer.hpp>
36#include <com/sun/star/util/XURLTransformer.hpp>
37#include <com/sun/star/setup/UpdateCheckConfig.hpp>
38#include <com/sun/star/configuration/ReadWriteAccess.hpp>
39#include <com/sun/star/beans/PropertyAttribute.hpp>
40#include <com/sun/star/beans/NamedValue.hpp>
42#include <officecfg/Office/Common.hxx>
43#include <osl/file.hxx>
44#include <osl/security.hxx>
51 :
SfxTabPage(pPage, pController,
"cui/ui/optonlineupdatepage.ui",
"OptOnlineUpdatePage", &
rSet)
52 , m_xNeverChecked(m_xBuilder->weld_label(
"neverchecked"))
53 , m_xAutoCheckCheckBox(m_xBuilder->weld_check_button(
"autocheck"))
54 , m_xEveryDayButton(m_xBuilder->weld_radio_button(
"everyday"))
55 , m_xEveryWeekButton(m_xBuilder->weld_radio_button(
"everyweek"))
56 , m_xEveryMonthButton(m_xBuilder->weld_radio_button(
"everymonth"))
57 , m_xCheckNowButton(m_xBuilder->weld_button(
"checknow"))
58 , m_xAutoDownloadCheckBox(m_xBuilder->weld_check_button(
"autodownload"))
59 , m_xDestPathLabel(m_xBuilder->weld_label(
"destpathlabel"))
60 , m_xDestPath(m_xBuilder->weld_label(
"destpath"))
61 , m_xChangePathButton(m_xBuilder->weld_button(
"changepath"))
62 , m_xLastChecked(m_xBuilder->weld_label(
"lastchecked"))
63 , m_xExtrasCheckBox(m_xBuilder->weld_check_button(
"extrabits"))
64 , m_xUserAgentLabel(m_xBuilder->weld_label(
"useragent"))
65 , m_xPrivacyPolicyButton(m_xBuilder->weld_link_button(
"btnPrivacyPolicy"))
74 officecfg::Office::Common::Menus::PrivacyPolicyURL::get()
84 bool bDownloadSupported =
false;
85 m_xUpdateAccess->getByName(
"DownloadSupported" ) >>= bDownloadSupported;
105 sal_Int64 lastChecked = 0;
109 if( lastChecked == 0 )
115 TimeValue lastCheckedTV;
116 oslDateTime lastCheckedDT;
121 lastCheckedTV.Seconds =
static_cast<sal_uInt32
>(lastChecked);
122 osl_getLocalTimeFromSystemTime( &lastCheckedTV, &lastCheckedTV );
124 if ( osl_getDateTimeFromTimeValue( &lastCheckedTV, &lastCheckedDT ) )
126 aDate =
Date( lastCheckedDT.Day, lastCheckedDT.Month, lastCheckedDT.Year );
127 aTime =
::tools::Time( lastCheckedDT.Hours, lastCheckedDT.Minutes );
131 std::optional<SvNumberFormatter> pNumberFormatter( std::in_place, ::comphelper::getProcessComponentContext(), eUILang );
132 const Color* pColor =
nullptr;
133 const Date& rNullDate = pNumberFormatter->GetNullDate();
134 sal_uInt32 nFormat = pNumberFormatter->GetStandardFormat( SvNumFormatType::DATE, eUILang );
137 pNumberFormatter->GetOutputString( aDate - rNullDate, nFormat, aDateStr, &pColor );
139 nFormat = pNumberFormatter->GetStandardFormat( SvNumFormatType::TIME, eUILang );
141 pNumberFormatter->GetOutputString( aTime.
GetTimeInDays(), nFormat, aTimeStr, &pColor );
143 pNumberFormatter.reset();
146 sal_Int32
nIndex = aText.indexOf(
"%DATE%" );
148 aText = aText.replaceAt(
nIndex, 6, aDateStr );
150 nIndex = aText.indexOf(
"%TIME%" );
152 aText = aText.replaceAt(
nIndex, 6, aTimeStr );
162 css::deployment::UpdateInformationProvider::create(
163 ::comphelper::getProcessComponentContext() ),
164 css::uno::UNO_QUERY_THROW );
166 OUString aPseudoURL =
"useragent:normal";
168 aPseudoURL =
"useragent:extended";
170 = xDav->getUserRequestHeaders( aPseudoURL, ucb::WebDAVHTTPMethod(0) );
172 for (
const css::beans::StringPair & aHeader : aHeaders)
174 if ( aHeader.First ==
"User-Agent" )
176 OUString aText = aHeader.Second;
177 aText = aText.replaceAll(
";",
";\n");
178 aText = aText.replaceAll(
"(",
"\n(");
183 }
catch (
const uno::Exception &) {
190 return std::make_unique<SvxOnlineUpdateTabPage>( pPage, pController, *rAttrSet );
195 bool bModified =
false;
237 OUString sValue,
aURL;
240 if( ( osl::FileBase::E_None == osl::FileBase::getFileURLFromSystemPath(
m_xDestPath->get_label(),
aURL) ) &&
255 if( xChangesBatch.is() && xChangesBatch->hasPendingChanges() )
256 xChangesBatch->commitChanges();
265 beans::Property aProperty =
m_xReadWriteAccess->getPropertyByHierarchicalName(
"/org.openoffice.Office.Jobs/Jobs/org.openoffice.Office.Jobs:Job['UpdateCheck']/Arguments/AutoCheckEnabled");
266 bool bReadOnly = (aProperty.Attributes & beans::PropertyAttribute::READONLY) != 0;
273 aProperty =
m_xReadWriteAccess->getPropertyByHierarchicalName(
"/org.openoffice.Office.Jobs/Jobs/org.openoffice.Office.Jobs:Job['UpdateCheck']/Arguments/CheckInterval");
274 bool bReadOnly2 = (aProperty.Attributes & beans::PropertyAttribute::READONLY) != 0;
281 else if(
nValue == 604800 )
292 aProperty =
m_xReadWriteAccess->getPropertyByHierarchicalName(
"/org.openoffice.Office.Jobs/Jobs/org.openoffice.Office.Jobs:Job['UpdateCheck']/Arguments/AutoDownloadEnabled");
293 bReadOnly = (aProperty.Attributes & beans::PropertyAttribute::READONLY) != 0;
299 OUString sValue, aPath;
301 aProperty =
m_xReadWriteAccess->getPropertyByHierarchicalName(
"/org.openoffice.Office.Jobs/Jobs/org.openoffice.Office.Jobs:Job['UpdateCheck']/Arguments/DownloadDestination");
302 bReadOnly = (aProperty.Attributes & beans::PropertyAttribute::READONLY) != 0;
305 if( osl::FileBase::E_None == osl::FileBase::getSystemPathFromFileURL(sValue, aPath) )
309 aProperty =
m_xReadWriteAccess->getPropertyByHierarchicalName(
"/org.openoffice.Office.Jobs/Jobs/org.openoffice.Office.Jobs:Job['UpdateCheck']/Arguments/ExtendedUserAgent");
310 bReadOnly = (aProperty.Attributes & beans::PropertyAttribute::READONLY) != 0;
325 bool bEnabled = rBox.get_active();
326 beans::Property aProperty = m_xReadWriteAccess->getPropertyByHierarchicalName(
"/org.openoffice.Office.Jobs/Jobs/org.openoffice.Office.Jobs:Job['UpdateCheck']/Arguments/CheckInterval");
327 bool bReadOnly = (aProperty.Attributes & beans::PropertyAttribute::READONLY) != 0;
328 m_xEveryDayButton->set_sensitive(bEnabled && !
bReadOnly);
329 m_xEveryWeekButton->set_sensitive(bEnabled && !
bReadOnly);
330 m_xEveryMonthButton->set_sensitive(bEnabled && !
bReadOnly);
344 if( osl::FileBase::E_None != osl::FileBase::getFileURLFromSystemPath(m_xDestPath->get_label(),
aURL) )
345 osl::Security().getHomeDir(
aURL);
347 xFolderPicker->setDisplayDirectory(
aURL );
348 sal_Int16 nRet = xFolderPicker->execute();
350 if ( ui::dialogs::ExecutableDialogResults::OK == nRet )
353 if( osl::FileBase::E_None == osl::FileBase::getSystemPathFromFileURL(xFolderPicker->getDirectory(), aFolder))
354 m_xDestPath->set_label(aFolder);
365 css::configuration::theDefaultProvider::get( xContext ) );
367 beans::NamedValue aProperty;
368 aProperty.Name =
"nodepath";
369 aProperty.Value <<= OUString(
"org.openoffice.Office.Addons/AddonUI/OfficeHelp/UpdateCheckJob");
374 xConfigProvider->createInstanceWithArguments(
375 "com.sun.star.configuration.ConfigurationAccess", aArgumentList ),
376 uno::UNO_QUERY_THROW );
379 xNameAccess->getByName(
"URL") >>=
aURL.Complete;
383 xTransformer->parseStrict(
aURL);
388 xDesktop->getCurrentFrame(), uno::UNO_QUERY );
391 if( xDispatchProvider.is() )
392 xDispatch = xDispatchProvider->queryDispatch(
aURL, OUString(), 0);
397 UpdateLastCheckedText();
399 catch(
const uno::Exception& )
const LanguageTag & GetUILanguageTag() const
static const AllSettings & GetSettings()
LanguageType getLanguageType(bool bResolveSystem=true) const
std::unique_ptr< weld::CheckButton > m_xAutoCheckCheckBox
std::unique_ptr< weld::Label > m_xUserAgentLabel
SvxOnlineUpdateTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
virtual void Reset(const SfxItemSet *rSet) override
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
std::unique_ptr< weld::LinkButton > m_xPrivacyPolicyButton
virtual ~SvxOnlineUpdateTabPage() override
OUString m_aLastCheckedTemplate
std::unique_ptr< weld::CheckButton > m_xAutoDownloadCheckBox
std::unique_ptr< weld::CheckButton > m_xExtrasCheckBox
std::unique_ptr< weld::Label > m_xNeverChecked
std::unique_ptr< weld::Button > m_xCheckNowButton
void UpdateLastCheckedText()
virtual void FillUserData() override
css::uno::Reference< css::container::XNameReplace > m_xUpdateAccess
std::unique_ptr< weld::Label > m_xDestPath
std::unique_ptr< weld::Button > m_xChangePathButton
virtual bool FillItemSet(SfxItemSet *rSet) override
std::unique_ptr< weld::RadioButton > m_xEveryMonthButton
std::unique_ptr< weld::RadioButton > m_xEveryDayButton
css::uno::Reference< css::configuration::XReadWriteAccess > m_xReadWriteAccess
std::unique_ptr< weld::RadioButton > m_xEveryWeekButton
std::unique_ptr< weld::Label > m_xLastChecked
std::unique_ptr< weld::Label > m_xDestPathLabel
static OUString getProductVersion()
static OUString getUILocale()
#define TOOLS_WARN_EXCEPTION(area, stream)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Reference< XDispatch > xDispatch
#define LINK(Instance, Class, Member)
css::uno::Reference< css::ui::dialogs::XFolderPicker2 > createFolderPicker(const css::uno::Reference< css::uno::XComponentContext > &rContext, weld::Window *pPreferredParent)
IMPL_LINK_NOARG(SvxOnlineUpdateTabPage, ExtrasCheckHdl_Impl, weld::Toggleable &, void)
IMPL_LINK(SvxOnlineUpdateTabPage, AutoCheckHdl_Impl, weld::Toggleable &, rBox, void)