summaryrefslogtreecommitdiff
path: root/extensions/source/oooimprovement
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/source/oooimprovement')
-rw-r--r--extensions/source/oooimprovement/Jobs.xcu25
-rw-r--r--extensions/source/oooimprovement/Logging.xcu8
-rw-r--r--extensions/source/oooimprovement/config.cxx296
-rw-r--r--extensions/source/oooimprovement/config.hxx68
-rw-r--r--extensions/source/oooimprovement/corecontroller.cxx89
-rw-r--r--extensions/source/oooimprovement/corecontroller.hxx84
-rw-r--r--extensions/source/oooimprovement/errormail.cxx207
-rw-r--r--extensions/source/oooimprovement/errormail.hxx54
-rw-r--r--extensions/source/oooimprovement/invite_job.cxx133
-rw-r--r--extensions/source/oooimprovement/invite_job.hxx82
-rw-r--r--extensions/source/oooimprovement/logpacker.cxx114
-rw-r--r--extensions/source/oooimprovement/logpacker.hxx51
-rw-r--r--extensions/source/oooimprovement/logstorage.cxx146
-rw-r--r--extensions/source/oooimprovement/logstorage.hxx55
-rw-r--r--extensions/source/oooimprovement/makefile.mk112
-rw-r--r--extensions/source/oooimprovement/makefile.pmk29
-rw-r--r--extensions/source/oooimprovement/myconfigurationhelper.cxx178
-rw-r--r--extensions/source/oooimprovement/myconfigurationhelper.hxx214
-rw-r--r--extensions/source/oooimprovement/onlogrotate_job.cxx240
-rw-r--r--extensions/source/oooimprovement/onlogrotate_job.hxx83
-rw-r--r--extensions/source/oooimprovement/oooimprovement.component38
-rw-r--r--extensions/source/oooimprovement/oooimprovement_exports.cxx88
-rw-r--r--extensions/source/oooimprovement/soaprequest.cxx200
-rw-r--r--extensions/source/oooimprovement/soaprequest.hxx60
-rw-r--r--extensions/source/oooimprovement/soapsender.cxx160
-rw-r--r--extensions/source/oooimprovement/soapsender.hxx56
26 files changed, 2870 insertions, 0 deletions
diff --git a/extensions/source/oooimprovement/Jobs.xcu b/extensions/source/oooimprovement/Jobs.xcu
new file mode 100644
index 000000000000..206d83dd7eb2
--- /dev/null
+++ b/extensions/source/oooimprovement/Jobs.xcu
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<oor:component-data oor:name="Jobs" oor:package="org.openoffice.Office" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <node oor:name="Jobs">
+ <node oor:name="OOoImprovement.OnLogRotateJob" oor:op="replace">
+ <prop oor:name="Service">
+ <value>com.sun.star.comp.extensions.oooimprovement.OnLogRotateJob</value>
+ </prop>
+ <node oor:name="Arguments"/>
+ </node>
+ <node oor:name="OOoImprovement.InviteJob" oor:op="replace">
+ <prop oor:name="Service">
+ <value>com.sun.star.comp.extensions.oooimprovement.InviteJob</value>
+ </prop>
+ <node oor:name="Arguments"/>
+ </node>
+ </node>
+ <node oor:name="Events">
+ <node oor:name="onFirstVisibleTask" oor:op="fuse">
+ <node oor:name="JobList">
+ <node oor:name="OOoImprovement.OnLogRotateJob" oor:op="replace"/>
+ <node oor:name="OOoImprovement.InviteJob" oor:op="replace"/>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/extensions/source/oooimprovement/Logging.xcu b/extensions/source/oooimprovement/Logging.xcu
new file mode 100644
index 000000000000..4ea492d67737
--- /dev/null
+++ b/extensions/source/oooimprovement/Logging.xcu
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<oor:component-data oor:name="Logging" oor:package="org.openoffice.Office" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <node oor:name="OOoImprovement">
+ <prop oor:name="EnablingAllowed">
+ <value>true</value>
+ </prop>
+ </node>
+</oor:component-data>
diff --git a/extensions/source/oooimprovement/config.cxx b/extensions/source/oooimprovement/config.cxx
new file mode 100644
index 000000000000..67658f405414
--- /dev/null
+++ b/extensions/source/oooimprovement/config.cxx
@@ -0,0 +1,296 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "config.hxx"
+#include "myconfigurationhelper.hxx"
+#include <rtl/ustrbuf.hxx>
+
+
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+
+
+namespace
+{
+ using namespace oooimprovement;
+
+ static const OUString CFG_COUNTERS = OUString::createFromAscii("Counters");
+ static const OUString CFG_ENABLINGALLOWED = OUString::createFromAscii("EnablingAllowed");
+ static const OUString CFG_EVENTSCOUNT = OUString::createFromAscii("LoggedEvents");
+ static const OUString CFG_EXTENSION = OUString::createFromAscii("ooSetupExtension");
+ static const OUString CFG_FAILEDATTEMPTS = OUString::createFromAscii("FailedAttempts");
+ static const OUString CFG_INVACCEPT = OUString::createFromAscii("InvitationAccepted");
+ static const OUString CFG_L10N = OUString::createFromAscii("L10N");
+ static const OUString CFG_LOCALE = OUString::createFromAscii("ooLocale");
+ static const OUString CFG_LOGGING = OUString::createFromAscii("/org.openoffice.Office.Logging");
+ static const OUString CFG_LOGPATH = OUString::createFromAscii("LogPath");
+ static const OUString CFG_NAME = OUString::createFromAscii("ooName");
+ static const OUString CFG_OFFICESTARTCOUNTDOWN = OUString::createFromAscii("OfficeStartCounterdown");
+ static const OUString CFG_OOOIMPROVEMENT = OUString::createFromAscii("OOoImprovement");
+ static const OUString CFG_OOOIMPROVEMENTPACK = OUString::createFromAscii("/org.openoffice.Office.OOoImprovement.Settings");
+ static const OUString CFG_PARTICIPATION = OUString::createFromAscii("Participation");
+ static const OUString CFG_PRODUCT = OUString::createFromAscii("Product");
+ static const OUString CFG_REPORTCOUNT = OUString::createFromAscii("UploadedReports");
+ static const OUString CFG_REPORTEREMAIL = OUString::createFromAscii("ReporterEmail");
+ static const OUString CFG_SETUP = OUString::createFromAscii("/org.openoffice.Setup");
+ static const OUString CFG_SHOWEDINV = OUString::createFromAscii("ShowedInvitation");
+ static const OUString CFG_SOAPIDADD = OUString::createFromAscii("SoapIdAdditions");
+ static const OUString CFG_SOAPURL = OUString::createFromAscii("SoapUrl");
+ static const OUString CFG_UPLOAD = OUString::createFromAscii("Upload");
+ static const OUString CFG_VERSION = OUString::createFromAscii("ooSetupVersion");
+
+ static const OUString SOAPID = OUString::createFromAscii("OpenOffice.org Improvement Report - Version 1\n");
+
+ static sal_Int32 incrementCfgValue(
+ const Reference<XMultiServiceFactory> sm,
+ const OUString& package,
+ const OUString& rel_path,
+ const OUString& key,
+ sal_Int32 increment_by)
+ {
+ sal_Int32 value;
+ Reference<XInterface> cfg =
+ MyConfigurationHelper::openConfig(
+ sm,
+ package, MyConfigurationHelper::E_STANDARD);
+ MyConfigurationHelper::readRelativeKey(
+ cfg,
+ rel_path, key) >>= value;
+ value += increment_by;
+ MyConfigurationHelper::writeRelativeKey(
+ cfg,
+ rel_path, key,
+ Any(value));
+ MyConfigurationHelper::flush(cfg);
+ return value;
+ };
+}
+
+namespace oooimprovement
+{
+ Config::Config(const Reference<XMultiServiceFactory>& sf)
+ : m_ServiceFactory(sf)
+ {}
+
+ OUString Config::getSoapUrl() const
+ {
+ OUString result;
+ MyConfigurationHelper::readDirectKey(
+ m_ServiceFactory,
+ CFG_OOOIMPROVEMENTPACK, CFG_UPLOAD, CFG_SOAPURL,
+ MyConfigurationHelper::E_READONLY) >>= result;
+ return result;
+ }
+
+ OUString Config::getSoapId() const
+ {
+ OUString value;
+ OUStringBuffer result = SOAPID;
+ MyConfigurationHelper::readDirectKey(
+ m_ServiceFactory,
+ CFG_OOOIMPROVEMENTPACK, CFG_UPLOAD, CFG_SOAPIDADD,
+ MyConfigurationHelper::E_READONLY) >>= value;
+ result.append(value);
+ return result.makeStringAndClear();
+ }
+
+ OUString Config::getReporterEmail() const
+ {
+ OUString result;
+ MyConfigurationHelper::readDirectKey(
+ m_ServiceFactory,
+ CFG_OOOIMPROVEMENTPACK, CFG_UPLOAD, CFG_REPORTEREMAIL,
+ MyConfigurationHelper::E_READONLY) >>= result;
+ return result;
+ }
+
+ OUString Config::getLogPath() const
+ {
+ OUString result;
+ MyConfigurationHelper::readDirectKey(
+ m_ServiceFactory,
+ CFG_LOGGING, CFG_OOOIMPROVEMENT, CFG_LOGPATH,
+ MyConfigurationHelper::E_READONLY) >>= result;
+ return result;
+ }
+
+ bool Config::getEnablingAllowed() const
+ {
+ bool result = false;
+ MyConfigurationHelper::readDirectKey(
+ m_ServiceFactory,
+ CFG_LOGGING, CFG_OOOIMPROVEMENT, CFG_ENABLINGALLOWED,
+ MyConfigurationHelper::E_READONLY) >>= result;
+ return result;
+ }
+
+ bool Config::getInvitationAccepted() const
+ {
+ bool result = false;
+ MyConfigurationHelper::readDirectKey(
+ m_ServiceFactory,
+ CFG_OOOIMPROVEMENTPACK, CFG_PARTICIPATION, CFG_INVACCEPT,
+ MyConfigurationHelper::E_READONLY) >>= result;
+ return result;
+ };
+
+ bool Config::getShowedInvitation() const
+ {
+ bool result = false;
+ MyConfigurationHelper::readDirectKey(
+ m_ServiceFactory,
+ CFG_OOOIMPROVEMENTPACK, CFG_PARTICIPATION, CFG_SHOWEDINV,
+ MyConfigurationHelper::E_READONLY) >>= result;
+ return result;
+ };
+
+ OUString Config::getCompleteProductname() const
+ {
+ OUStringBuffer result;
+ OUString value;
+ MyConfigurationHelper::readDirectKey(
+ m_ServiceFactory,
+ CFG_SETUP, CFG_PRODUCT, CFG_NAME,
+ MyConfigurationHelper::E_READONLY) >>= value;
+ result.append(value);
+
+ value = OUString::createFromAscii("");
+ MyConfigurationHelper::readDirectKey(
+ m_ServiceFactory,
+ CFG_SETUP, CFG_PRODUCT, CFG_VERSION,
+ MyConfigurationHelper::E_READONLY) >>= value;
+ if(value.getLength()) result.appendAscii(" ").append(value);
+
+ value = OUString::createFromAscii("");
+ MyConfigurationHelper::readDirectKey(
+ m_ServiceFactory,
+ CFG_SETUP, CFG_PRODUCT, CFG_EXTENSION,
+ MyConfigurationHelper::E_READONLY) >>= value;
+ if(value.getLength()) result.appendAscii(" ").append(value);
+
+ return result.makeStringAndClear();
+ }
+
+ OUString Config::getSetupLocale() const
+ {
+ OUString result;
+ MyConfigurationHelper::readDirectKey(
+ m_ServiceFactory,
+ CFG_SETUP, CFG_L10N, CFG_LOCALE,
+ MyConfigurationHelper::E_READONLY) >>= result;
+ return result;
+ }
+
+ sal_Int32 Config::getReportCount() const
+ {
+ sal_Int32 result = 0;
+ MyConfigurationHelper::readDirectKey(
+ m_ServiceFactory,
+ CFG_OOOIMPROVEMENTPACK, CFG_COUNTERS, CFG_REPORTCOUNT,
+ MyConfigurationHelper::E_READONLY) >>= result;
+ return result;
+ }
+
+#ifdef FUTURE
+ sal_Int32 Config::getFailedAttempts() const
+ {
+ sal_Int32 result = 0;
+ MyConfigurationHelper::readDirectKey(
+ m_ServiceFactory,
+ CFG_OOOIMPROVEMENTPACK, CFG_COUNTERS, CFG_FAILEDATTEMPTS,
+ MyConfigurationHelper::E_READONLY) >>= result;
+ return result;
+ }
+#endif
+
+ sal_Int32 Config::getOfficeStartCounterdown() const
+ {
+ sal_Int32 result = 0;
+ MyConfigurationHelper::readDirectKey(
+ m_ServiceFactory,
+ CFG_OOOIMPROVEMENTPACK, CFG_PARTICIPATION, CFG_OFFICESTARTCOUNTDOWN,
+ MyConfigurationHelper::E_READONLY) >>= result;
+ return result;
+ }
+
+ sal_Int32 Config::incrementReportCount(sal_Int32 by)
+ {
+ return incrementCfgValue(
+ m_ServiceFactory,
+ CFG_OOOIMPROVEMENTPACK, CFG_COUNTERS, CFG_REPORTCOUNT,
+ by);
+ }
+
+ sal_Int32 Config::incrementEventCount(sal_Int32 by)
+ {
+ return incrementCfgValue(
+ m_ServiceFactory,
+ CFG_OOOIMPROVEMENTPACK, CFG_COUNTERS, CFG_EVENTSCOUNT,
+ by);
+ }
+
+ sal_Int32 Config::incrementFailedAttempts(sal_Int32 by)
+ {
+ return incrementCfgValue(
+ m_ServiceFactory,
+ CFG_OOOIMPROVEMENTPACK, CFG_COUNTERS, CFG_FAILEDATTEMPTS,
+ by);
+ }
+
+ sal_Int32 Config::decrementOfficeStartCounterdown(sal_Int32 by)
+ {
+ return incrementCfgValue(
+ m_ServiceFactory,
+ CFG_OOOIMPROVEMENTPACK, CFG_PARTICIPATION, CFG_OFFICESTARTCOUNTDOWN,
+ -by);
+ }
+
+ void Config::resetFailedAttempts()
+ {
+ sal_Int32 zero = 0;
+ MyConfigurationHelper::writeDirectKey(
+ m_ServiceFactory,
+ CFG_OOOIMPROVEMENTPACK, CFG_COUNTERS, CFG_FAILEDATTEMPTS,
+ Any(zero),
+ MyConfigurationHelper::E_STANDARD);
+ }
+
+ void Config::giveupUploading()
+ {
+ sal_Bool f = false;
+ MyConfigurationHelper::writeDirectKey(
+ m_ServiceFactory,
+ CFG_OOOIMPROVEMENTPACK, CFG_PARTICIPATION, CFG_INVACCEPT,
+ Any(f),
+ MyConfigurationHelper::E_STANDARD);
+ resetFailedAttempts();
+ }
+}
diff --git a/extensions/source/oooimprovement/config.hxx b/extensions/source/oooimprovement/config.hxx
new file mode 100644
index 000000000000..d1e63fd76f7c
--- /dev/null
+++ b/extensions/source/oooimprovement/config.hxx
@@ -0,0 +1,68 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+
+
+#ifndef EXTENSIONS_OOOIMPROVEMENT_CONFIG_HXX
+#define EXTENSIONS_OOOIMPROVEMENT_CONFIG_HXX
+
+#include <rtl/ustring.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+
+namespace oooimprovement
+{
+ class Config
+ {
+ public:
+ Config(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& sf);
+ bool getEnablingAllowed() const;
+ bool getInvitationAccepted() const;
+ bool getShowedInvitation() const;
+ ::rtl::OUString getCompleteProductname() const;
+ ::rtl::OUString getLogPath() const;
+ ::rtl::OUString getReporterEmail() const;
+ ::rtl::OUString getSetupLocale() const;
+ ::rtl::OUString getSoapId() const;
+ ::rtl::OUString getSoapUrl() const;
+ sal_Int32 getReportCount() const;
+#ifdef FUTURE
+ sal_Int32 getFailedAttempts() const;
+#endif
+ sal_Int32 getOfficeStartCounterdown() const;
+ sal_Int32 incrementEventCount(sal_Int32 by);
+ sal_Int32 incrementReportCount(sal_Int32 by);
+ sal_Int32 incrementFailedAttempts(sal_Int32 by);
+ sal_Int32 decrementOfficeStartCounterdown(sal_Int32 by);
+ void resetFailedAttempts();
+ void giveupUploading();
+
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_ServiceFactory;
+ };
+}
+#endif
diff --git a/extensions/source/oooimprovement/corecontroller.cxx b/extensions/source/oooimprovement/corecontroller.cxx
new file mode 100644
index 000000000000..66e634768fef
--- /dev/null
+++ b/extensions/source/oooimprovement/corecontroller.cxx
@@ -0,0 +1,89 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "corecontroller.hxx"
+#include "config.hxx"
+
+using ::rtl::OUString;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+
+
+namespace oooimprovement
+{
+ CoreController::CoreController(const Reference<XMultiServiceFactory>& sf)
+ : m_ServiceFactory(sf)
+ { }
+
+ CoreController::~CoreController()
+ { }
+
+ sal_Bool SAL_CALL CoreController::enablingUiEventsLoggerAllowed(sal_Int16 version) throw(RuntimeException)
+ {
+ Config config(m_ServiceFactory);
+ if(version==1 && config.getEnablingAllowed() && config.getShowedInvitation() && config.getInvitationAccepted())
+ return true;
+ return false;
+ }
+
+ sal_Bool SAL_CALL CoreController::showBuiltinOptionsPage(sal_Int16 version) throw(RuntimeException)
+ {
+ Config config(m_ServiceFactory);
+ if(version==1 && config.getEnablingAllowed())
+ return true;
+ return false;
+ }
+
+ sal_Bool SAL_CALL CoreController::supportsService(const OUString& service_name) throw(RuntimeException)
+ {
+ const Sequence<OUString> service_names(getSupportedServiceNames());
+ for (sal_Int32 idx = service_names.getLength()-1; idx>=0; --idx)
+ if(service_name == service_names[idx]) return sal_True;
+ return sal_False;
+ }
+
+ OUString SAL_CALL CoreController::getImplementationName() throw(RuntimeException)
+ { return getImplementationName_static(); }
+
+ Sequence<OUString> SAL_CALL CoreController::getSupportedServiceNames() throw(RuntimeException)
+ { return getSupportedServiceNames_static(); }
+
+ OUString SAL_CALL CoreController::getImplementationName_static()
+ { return OUString::createFromAscii("com.sun.star.comp.extensions.oooimprovement.CoreController"); }
+
+ Sequence<OUString> SAL_CALL CoreController::getSupportedServiceNames_static()
+ {
+ Sequence<OUString> aServiceNames(1);
+ aServiceNames[0] = OUString::createFromAscii("com.sun.star.oooimprovement.CoreController");
+ return aServiceNames;
+ }
+
+ Reference<XInterface> SAL_CALL CoreController::Create(const Reference<XMultiServiceFactory>& sm)
+ { return *(new CoreController(sm)); }
+}
diff --git a/extensions/source/oooimprovement/corecontroller.hxx b/extensions/source/oooimprovement/corecontroller.hxx
new file mode 100644
index 000000000000..b54495397dcb
--- /dev/null
+++ b/extensions/source/oooimprovement/corecontroller.hxx
@@ -0,0 +1,84 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+
+
+#ifndef EXTENSIONS_OOOIMPROVEMENT_CORECONTROLLER_HXX
+#define EXTENSIONS_OOOIMPROVEMENT_CORECONTROLLER_HXX
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/oooimprovement/XCoreController.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <cppuhelper/implbase2.hxx>
+
+
+namespace oooimprovement
+{
+ #ifdef css
+ #error css defined globally
+ #endif
+ #define css ::com::sun::star
+ class CoreController : public ::cppu::WeakImplHelper2<
+ css::oooimprovement::XCoreController,
+ css::lang::XServiceInfo>
+ {
+ public:
+ // css::lang::XServiceInfo - static version
+ static ::rtl::OUString SAL_CALL getImplementationName_static();
+ static css::uno::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames_static();
+ //static css::uno::Reference< css::uno::XInterface> SAL_CALL Create(
+ // const css::uno::Reference<css::uno::XComponentContext>& context);
+
+ static css::uno::Reference< css::uno::XInterface> SAL_CALL Create(
+ const css::uno::Reference< css::lang::XMultiServiceFactory>& sm);
+
+ protected:
+ CoreController(const css::uno::Reference< css::uno::XComponentContext>& context);
+ CoreController(const css::uno::Reference< css::lang::XMultiServiceFactory>& sm);
+ virtual ~CoreController();
+
+ // css::oooimprovement::XCoreController
+ virtual sal_Bool SAL_CALL enablingUiEventsLoggerAllowed(sal_Int16 version)
+ throw(css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL showBuiltinOptionsPage(sal_Int16 version)
+ throw(css::uno::RuntimeException);
+
+ // css::lang::XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName()
+ throw(css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL supportsService(const ::rtl::OUString& service_name)
+ throw(css::uno::RuntimeException);
+ virtual css::uno::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames()
+ throw(css::uno::RuntimeException);
+
+ private:
+ css::uno::Reference< css::lang::XMultiServiceFactory> m_ServiceFactory;
+ };
+ #undef css
+}
+#endif
diff --git a/extensions/source/oooimprovement/errormail.cxx b/extensions/source/oooimprovement/errormail.cxx
new file mode 100644
index 000000000000..73a8869a45a2
--- /dev/null
+++ b/extensions/source/oooimprovement/errormail.cxx
@@ -0,0 +1,207 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "errormail.hxx"
+#include "config.hxx"
+#include <unotools/bootstrap.hxx>
+#include <rtl/ustring.hxx>
+#include <rtl/string.hxx>
+#include <rtl/strbuf.hxx>
+
+#if defined(UNIX) || defined(OS2)
+ #include <sys/utsname.h>
+#endif
+#ifdef WIN32
+ #include <windows.h>
+#endif
+
+
+using namespace com::sun::star::lang;
+using namespace com::sun::star::uno;
+using namespace oooimprovement;
+using ::rtl::OUString;
+using ::rtl::OString;
+using ::rtl::OStringBuffer;
+
+
+namespace {
+ static OString replaceAll(const OString& str, sal_Char old, const OString& replacement)
+ {
+ OStringBuffer result;
+ sal_Int32 idx = 0;
+ do {
+ result.append(str.getToken(0, old, idx));
+ if(idx>=0) result.append(replacement);
+ } while(idx >= 0);
+ return result.makeStringAndClear();
+ };
+
+ static OString xmlAttrEncode(const OString& input)
+ {
+ OString result = replaceAll(input, '&', OString("&amp;"));
+ result = replaceAll(result, '<', OString("&lt;"));
+ result = replaceAll(result, '"', OString("&quot;"));
+ return replaceAll(result, '>', OString("&gt;"));
+ }
+
+ static OString getPlatform()
+ {
+ #ifdef SOLARIS
+ return "Solaris";
+ #elif defined LINUX
+ return "Linux";
+ #elif defined WIN32
+ return "Win32";
+ #elif defined UNIX
+ return "Unix";
+ #elif defined OS2
+ return "OS/2";
+ #else
+ return "Unknown";
+ #endif
+ };
+
+#if defined(UNIX) || defined(OS2)
+ static const OString getLocale()
+ {
+ const char * locale = getenv( "LC_ALL" );
+ if( NULL == locale )
+ locale = getenv( "LC_CTYPE" );
+
+ if( NULL == locale )
+ locale = getenv( "LANG" );
+
+ if( NULL == locale )
+ locale = "C";
+ return locale;
+ };
+
+ static OString getSystemInfoXml(const Reference<XMultiServiceFactory>&)
+ {
+ struct utsname info;
+ //memset(&info, 0, sizeof(info));
+ uname(&info);
+ OStringBuffer result =
+ "<systeminfo:systeminfo xmlns:systeminfo=\"http://openoffice.org/2002/systeminfo\">\n"
+ "<systeminfo:System name=\""
+ + xmlAttrEncode(OString(info.sysname)) + "\" version=\""
+ + xmlAttrEncode(OString(info.version)) + "\" build=\""
+ + xmlAttrEncode(OString(info.release)) + "\" locale=\""
+ + xmlAttrEncode(OString(getLocale())) + "\"/>\n"
+ "<systeminfo:CPU type=\""
+ + xmlAttrEncode(OString(info.machine)) + "\"/>\n"
+ "</systeminfo:systeminfo>\n";
+ return result.makeStringAndClear();
+ };
+#else
+ static OString getSystemInfoXml(const Reference<XMultiServiceFactory>&)
+ {
+ OSVERSIONINFO info;
+ ZeroMemory(&info, sizeof(OSVERSIONINFO));
+ info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&info);
+ OStringBuffer result = OString(
+ "<systeminfo:systeminfo xmlns:systeminfo=\"http://openoffice.org/2002/systeminfo\">\n"
+ "<systeminfo:System name=\"");
+ if(VER_PLATFORM_WIN32_NT == info.dwPlatformId)
+ result.append(OString("Windows NT"));
+ else
+ result.append(OString("Windows"));
+ result.append("\" version=\"").append(static_cast<long>(info.dwMajorVersion));
+ result.append(".").append(static_cast<long>(info.dwMinorVersion));
+ result.append("\" build=\"").append(static_cast<long>(info.dwBuildNumber));
+ result.append("\" locale=\"").append(static_cast<long>(GetUserDefaultLangID()));
+ result.append("\"/>\n");
+ result.append("<systeminfo:CPU type=\""
+ /* x86 or AMD64 */ "\"/>\n"
+ "</systeminfo:systeminfo>\n");
+ return result.makeStringAndClear();
+ };
+#endif
+
+ static OString getOfficeInfoXml(const Reference<XMultiServiceFactory>& sf)
+ {
+ Config config(sf);
+ const OString product = OUStringToOString(config.getCompleteProductname(), RTL_TEXTENCODING_ASCII_US);
+ const OString platform = getPlatform();
+ const OString language = OUStringToOString(config.getSetupLocale(), RTL_TEXTENCODING_ASCII_US);
+ // If the oooimprovement lib is packaged in an extension, this needs to
+ // be done in another way: The build version string needs to be made
+ // available in an UNO service (if no better place is found for this,
+ // com.sun.star.comp.extensions.oooimprovecore.Core in oooimprovecore
+ // is likely the best fit)
+ const OString build = OUStringToOString(::utl::Bootstrap::getBuildIdData(OUString()), RTL_TEXTENCODING_ASCII_US);
+ const OString exceptiontype = "";
+ OStringBuffer result =
+ "<officeinfo:officeinfo xmlns:officeinfo=\"http://openoffice.org/2002/officeinfo\" platform=\""
+ + xmlAttrEncode(platform) + "\" language=\""
+ + xmlAttrEncode(language) + "\" build=\""
+ + xmlAttrEncode(build) + "\" exceptiontype=\""
+ + xmlAttrEncode(exceptiontype) + "\" product=\""
+ + xmlAttrEncode(product) + " \" />\n";
+ return result.makeStringAndClear();
+ };
+}
+
+namespace oooimprovement
+{
+ Errormail::Errormail(const Reference<XMultiServiceFactory>& sf)
+ : m_ServiceFactory(sf)
+ {}
+
+ OString Errormail::getXml()
+ {
+ Config config(m_ServiceFactory);
+ const OString usertype;
+ const OString email = OUStringToOString(config.getReporterEmail(), RTL_TEXTENCODING_ASCII_US);
+ OString feedback;
+ {
+ OStringBuffer temp;
+ temp.append(config.getReportCount());
+ feedback = temp.makeStringAndClear();
+ }
+ const OString title;
+ OStringBuffer result =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<!DOCTYPE errormail:errormail PUBLIC \"-//OpenOffice.org//DTD ErrorMail 1.0//EN\" \"errormail.dtd\">\n"
+ "<errormail:errormail xmlns:errormail=\"http://openoffice.org/2002/errormail\" usertype=\""
+ + xmlAttrEncode(usertype) + "\">\n"
+ "<reportmail:mail xmlns:reportmail=\"http://openoffice.org/2002/reportmail\" version=\"1.1\" feedback=\""
+ + xmlAttrEncode(feedback) + "\" email=\""
+ + xmlAttrEncode(email) + "\">\n"
+ "<reportmail:title>"
+ + xmlAttrEncode(title) + "</reportmail:title>\n"
+ "<reportmail:attachment name=\"data.zip\" media-type=\"application/zip\" class=\"OOoImprovementLog\"/>\n"
+ "</reportmail:mail>\n"
+ + getOfficeInfoXml(m_ServiceFactory)
+ + getSystemInfoXml(m_ServiceFactory) +
+ "</errormail:errormail>\n";
+ return result.makeStringAndClear();
+ }
+}
diff --git a/extensions/source/oooimprovement/errormail.hxx b/extensions/source/oooimprovement/errormail.hxx
new file mode 100644
index 000000000000..e7bd6df2b918
--- /dev/null
+++ b/extensions/source/oooimprovement/errormail.hxx
@@ -0,0 +1,54 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef EXTENSIONS_OOOIMPROVEMENT_ERRORMAIL_HXX
+#define EXTENSIONS_OOOIMPROVEMENT_ERRORMAIL_HXX
+
+#include <rtl/string.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+
+namespace oooimprovement
+{
+ #ifdef css
+ #error css defined globally
+ #endif
+ #define css ::com::sun::star
+ class Errormail
+ {
+ public:
+ Errormail(const css::uno::Reference<css::lang::XMultiServiceFactory>& sf);
+ // Errormail does NOT use CDATA so it can be included
+ // in a CDATA of another XML document without further
+ // quoting
+ ::rtl::OString getXml();
+ private:
+ css::uno::Reference<css::lang::XMultiServiceFactory> m_ServiceFactory;
+ };
+ #undef css
+}
+#endif
diff --git a/extensions/source/oooimprovement/invite_job.cxx b/extensions/source/oooimprovement/invite_job.cxx
new file mode 100644
index 000000000000..69036826432f
--- /dev/null
+++ b/extensions/source/oooimprovement/invite_job.cxx
@@ -0,0 +1,133 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+
+#include "invite_job.hxx"
+#include "config.hxx"
+#include "logstorage.hxx"
+#include <com/sun/star/oooimprovement/XCore.hpp>
+#include <rtl/process.h>
+
+
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::uno;
+using ::com::sun::star::oooimprovement::XCore;
+using ::rtl::OUString;
+
+namespace
+{
+ // dont show Invitation, when:
+ // -nofirststartwizard commandline switch is present
+ // [add additional conditions here]
+ static bool lcl_IsInvitationAllowed()
+ {
+ static OUString sNoFirstStartWizard = OUString::createFromAscii("-nofirststartwizard");
+ sal_Int32 nCount = rtl_getAppCommandArgCount();
+ for(sal_Int32 nCurrent=0; nCurrent<nCount; nCurrent++)
+ {
+ OUString sArg;
+ rtl_getAppCommandArg(nCurrent, &sArg.pData);
+ if(sNoFirstStartWizard == sArg)
+ return false;
+ }
+ return true;
+ }
+}
+
+namespace oooimprovement
+{
+// InviteJob::InviteJob(const Reference<XComponentContext>& context)
+// : m_ServiceFactory(Reference<XMultiServiceFactory>(
+// context->getServiceManager()->createInstanceWithContext(
+// OUString::createFromAscii("com.sun.star.lang.XMultiServiceFactory"), context),
+// UNO_QUERY))
+// { }
+
+ InviteJob::InviteJob(const Reference<XMultiServiceFactory>& sf)
+ : m_ServiceFactory(sf)
+ { }
+
+ InviteJob::~InviteJob()
+ { }
+
+ void SAL_CALL InviteJob::executeAsync(const Sequence<NamedValue>&, const Reference<XJobListener>& listener) throw(RuntimeException)
+ {
+ Config config(m_ServiceFactory);
+ {
+ LogStorage log_storage(m_ServiceFactory);
+ log_storage.assureExists();
+ }
+ if(config.getOfficeStartCounterdown() > 0)
+ config.decrementOfficeStartCounterdown(1);
+ else
+ {
+ if(lcl_IsInvitationAllowed() && !config.getShowedInvitation())
+ {
+ Reference<XCore> core(
+ m_ServiceFactory->createInstance(OUString::createFromAscii("com.sun.star.oooimprovement.Core")),
+ UNO_QUERY);
+ if(core.is()) core->inviteUser();
+ }
+ }
+ Any result;
+ listener->jobFinished(Reference<XAsyncJob>(this), result);
+ }
+
+ sal_Bool SAL_CALL InviteJob::supportsService(const OUString& service_name) throw(RuntimeException)
+ {
+ const Sequence<OUString> service_names(getSupportedServiceNames());
+ for (sal_Int32 idx = service_names.getLength()-1; idx>=0; --idx)
+ if(service_name == service_names[idx]) return sal_True;
+ return sal_False;
+ }
+
+ OUString SAL_CALL InviteJob::getImplementationName() throw(RuntimeException)
+ { return getImplementationName_static(); }
+
+ Sequence<OUString> SAL_CALL InviteJob::getSupportedServiceNames() throw(RuntimeException)
+ { return getSupportedServiceNames_static(); }
+
+ OUString SAL_CALL InviteJob::getImplementationName_static()
+ { return OUString::createFromAscii("com.sun.star.comp.extensions.oooimprovement.InviteJob"); }
+
+ Sequence<OUString> SAL_CALL InviteJob::getSupportedServiceNames_static()
+ {
+ Sequence<OUString> aServiceNames(1);
+ aServiceNames[0] = OUString::createFromAscii("com.sun.star.task.AsyncJob");
+ return aServiceNames;
+ }
+
+// Reference<XInterface> InviteJob::Create(const Reference<XComponentContext>& context)
+// { return *(new InviteJob(context)); }
+
+ Reference<XInterface> InviteJob::Create(const Reference<XMultiServiceFactory>& sm)
+ { return *(new InviteJob(sm)); }
+}
diff --git a/extensions/source/oooimprovement/invite_job.hxx b/extensions/source/oooimprovement/invite_job.hxx
new file mode 100644
index 000000000000..8679f092065d
--- /dev/null
+++ b/extensions/source/oooimprovement/invite_job.hxx
@@ -0,0 +1,82 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+
+
+#ifndef EXTENSIONS_OOOIMPROVEMENT_INVITEJOB_HXX
+#define EXTENSIONS_OOOIMPROVEMENT_INVITEJOB_HXX
+
+#include <com/sun/star/task/XAsyncJob.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <cppuhelper/implbase2.hxx>
+
+
+namespace oooimprovement
+{
+ #ifdef css
+ #error css defined globally
+ #endif
+ #define css ::com::sun::star
+ class InviteJob : public ::cppu::WeakImplHelper2<
+ css::task::XAsyncJob,
+ css::lang::XServiceInfo>
+ {
+ public:
+ // XServiceInfo - static version
+ static ::rtl::OUString SAL_CALL getImplementationName_static();
+ static css::uno::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames_static();
+ //static css::uno::Reference< css::uno::XInterface> SAL_CALL Create(
+ // const css::uno::Reference< css::uno::XComponentContext>& context);
+
+ static css::uno::Reference< css::uno::XInterface> SAL_CALL Create(const css::uno::Reference< css::lang::XMultiServiceFactory>& sm);
+
+ protected:
+ InviteJob(const css::uno::Reference< css::uno::XComponentContext>& context);
+ InviteJob(const css::uno::Reference< css::lang::XMultiServiceFactory>& sf);
+ virtual ~InviteJob();
+
+ // XAsyncJob
+ virtual void SAL_CALL executeAsync(
+ const css::uno::Sequence< css::beans::NamedValue>& args,
+ const css::uno::Reference< css::task::XJobListener>& listener)
+ throw(css::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName()
+ throw(css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService(const ::rtl::OUString& service_name)
+ throw(css::uno::RuntimeException);
+ virtual css::uno::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames()
+ throw(css::uno::RuntimeException);
+
+ private:
+ css::uno::Reference< css::lang::XMultiServiceFactory> m_ServiceFactory;
+ };
+ #undef css
+}
+#endif
diff --git a/extensions/source/oooimprovement/logpacker.cxx b/extensions/source/oooimprovement/logpacker.cxx
new file mode 100644
index 000000000000..71508ab05bcb
--- /dev/null
+++ b/extensions/source/oooimprovement/logpacker.cxx
@@ -0,0 +1,114 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "logpacker.hxx"
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <rtl/ustrbuf.hxx>
+
+
+using namespace com::sun::star::embed;
+using namespace com::sun::star::io;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::uno;
+using ::com::sun::star::ucb::XSimpleFileAccess;
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+
+
+namespace
+{
+ static const OUString getZipfileurl(const OUString& csvfileurl)
+ {
+ OUStringBuffer buf(csvfileurl);
+ buf.setLength(csvfileurl.getLength()-3);
+ buf.appendAscii("zip");
+ return buf.makeStringAndClear();
+ };
+
+ static sal_Int32 countLines(const Sequence<sal_Int8>& data)
+ {
+ sal_Int32 result = 0;
+ for(sal_Int32 idx = data.getLength()-1; idx>=0; --idx)
+ if(data[idx]==0x0a) result++;
+ return result;
+ };
+}
+
+namespace oooimprovement
+{
+ LogPacker::LogPacker(const Reference<XMultiServiceFactory>& sf)
+ : m_ServiceFactory(sf)
+ {}
+
+ sal_Int32 LogPacker::pack(const OUString& fileurl)
+ {
+ Reference<XSimpleFileAccess> file_access(
+ m_ServiceFactory->createInstance(OUString::createFromAscii("com.sun.star.ucb.SimpleFileAccess")),
+ UNO_QUERY_THROW);
+
+ Reference<XStorage> storage;
+ {
+ Reference<XSingleServiceFactory> storage_factory(
+ m_ServiceFactory->createInstance(OUString::createFromAscii("com.sun.star.embed.StorageFactory")),
+ UNO_QUERY_THROW);
+ Sequence<Any> storage_init_args(2);
+ storage_init_args[0] = Any(getZipfileurl(fileurl));
+ storage_init_args[1] = Any(ElementModes::WRITE);
+ storage = Reference<XStorage>(
+ storage_factory->createInstanceWithArguments(storage_init_args),
+ UNO_QUERY_THROW);
+ }
+
+ Reference<XOutputStream> zipped_stream = storage->openStreamElement(
+ OUString::createFromAscii("logdata.csv"),
+ ElementModes::WRITE)->getOutputStream();
+ Reference<XInputStream> unzipped_stream = file_access->openFileRead(fileurl);
+ const sal_Int32 bufsize = 1024;
+ sal_Int32 read_bytes;
+ sal_Int32 logged_events = -1; // ignore header row
+ Sequence<sal_Int8> buf(bufsize);
+ do
+ {
+ read_bytes = unzipped_stream->readBytes(buf, bufsize);
+ buf.realloc(read_bytes);
+ logged_events += countLines(buf);
+ zipped_stream->writeBytes(buf);
+ } while(read_bytes == bufsize);
+ unzipped_stream->closeInput();
+ zipped_stream->flush();
+ zipped_stream->closeOutput();
+ Reference<XTransactedObject>(storage, UNO_QUERY_THROW)->commit();
+ file_access->kill(fileurl);
+ return logged_events;
+ }
+}
diff --git a/extensions/source/oooimprovement/logpacker.hxx b/extensions/source/oooimprovement/logpacker.hxx
new file mode 100644
index 000000000000..486443095d95
--- /dev/null
+++ b/extensions/source/oooimprovement/logpacker.hxx
@@ -0,0 +1,51 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef EXTENSIONS_OOOIMPROVEMENT_LOGPACKER_HXX
+#define EXTENSIONS_OOOIMPROVEMENT_LOGPACKER_HXX
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <rtl/ustring.hxx>
+
+
+namespace oooimprovement
+{
+ #ifdef css
+ #error css defined globally
+ #endif
+ #define css ::com::sun::star
+ class LogPacker
+ {
+ public:
+ LogPacker(const css::uno::Reference< css::lang::XMultiServiceFactory>& sf);
+ sal_Int32 pack(const ::rtl::OUString& fileurl);
+ private:
+ const css::uno::Reference< css::lang::XMultiServiceFactory> m_ServiceFactory;
+ };
+ #undef css
+}
+#endif
diff --git a/extensions/source/oooimprovement/logstorage.cxx b/extensions/source/oooimprovement/logstorage.cxx
new file mode 100644
index 000000000000..7c337288460e
--- /dev/null
+++ b/extensions/source/oooimprovement/logstorage.cxx
@@ -0,0 +1,146 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "logstorage.hxx"
+#include "config.hxx"
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <com/sun/star/util/XStringSubstitution.hpp>
+
+
+using namespace com::sun::star::io;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::util;
+using ::com::sun::star::ucb::XSimpleFileAccess;
+using ::rtl::OUString;
+using ::std::vector;
+
+
+namespace
+{
+ using namespace oooimprovement;
+
+ static const OUString CSSU_PATHSUB = OUString::createFromAscii("com.sun.star.util.PathSubstitution");
+
+ static OUString getLogPathFromCfg(const Reference<XMultiServiceFactory>& sf)
+ {
+ Config config(sf);
+ OUString result=config.getLogPath();
+ Reference<XStringSubstitution> path_sub(
+ sf->createInstance(CSSU_PATHSUB),
+ UNO_QUERY);
+ if(path_sub.is())
+ result = path_sub->substituteVariables(result, sal_False);
+ return result;
+ }
+
+ static bool isZipfile(const OUString& fileurl)
+ {
+ static const OUString file_extension = OUString::createFromAscii(".zip");
+ return fileurl.match(file_extension, fileurl.getLength()-file_extension.getLength());
+ };
+
+ static bool isLogfile(const OUString& fileurl)
+ {
+ static const OUString file_extension = OUString::createFromAscii(".csv");
+ static const OUString current = OUString::createFromAscii("Current.csv");
+ return
+ fileurl.match(file_extension, fileurl.getLength()-file_extension.getLength())
+ && !fileurl.match(current, fileurl.getLength()-current.getLength());
+ };
+
+ static bool isZipOrLogFile(const OUString& fileurl)
+ {
+ return isZipfile(fileurl) || isLogfile(fileurl);
+ }
+
+ static Sequence<OUString> getAllLogStoragefiles(const Reference<XMultiServiceFactory>& sf)
+ {
+ Reference<XSimpleFileAccess> file_access(
+ sf->createInstance(OUString::createFromAscii("com.sun.star.ucb.SimpleFileAccess")),
+ UNO_QUERY_THROW);
+ return file_access->getFolderContents(
+ getLogPathFromCfg(sf),
+ false);
+ };
+
+ static vector<OUString> getLogStoragefiles(
+ const Reference<XMultiServiceFactory>& sf,
+ bool (*condition)(const OUString& path))
+ {
+ Sequence<OUString> candidates = getAllLogStoragefiles(sf);
+ vector<OUString> result;
+ result.reserve(candidates.getLength());
+ for(sal_Int32 idx=0; idx<candidates.getLength(); ++idx)
+ if(condition(candidates[idx]))
+ result.push_back(candidates[idx]);
+ return result;
+ };
+
+ static void assureLogStorageExists(const Reference<XMultiServiceFactory>& sf)
+ {
+ Reference<XSimpleFileAccess> file_access(
+ sf->createInstance(OUString::createFromAscii("com.sun.star.ucb.SimpleFileAccess")),
+ UNO_QUERY_THROW);
+ OUString log_path(getLogPathFromCfg(sf));
+ if(!file_access->isFolder(log_path))
+ file_access->createFolder(log_path);
+ };
+}
+
+namespace oooimprovement
+{
+
+ LogStorage::LogStorage(const Reference<XMultiServiceFactory>& sf)
+ : m_ServiceFactory(sf)
+ {}
+
+ void LogStorage::assureExists()
+ {
+ assureLogStorageExists(m_ServiceFactory);
+ }
+
+ void LogStorage::clear()
+ {
+ Reference<XSimpleFileAccess> file_access(
+ m_ServiceFactory->createInstance(OUString::createFromAscii("com.sun.star.ucb.SimpleFileAccess")),
+ UNO_QUERY_THROW);
+ vector<OUString> files_to_kill = getLogStoragefiles(m_ServiceFactory, &isZipOrLogFile);
+ for(vector<OUString>::iterator item = files_to_kill.begin();
+ item != files_to_kill.end();
+ item++)
+ file_access->kill(*item);
+ }
+
+ const vector<OUString> LogStorage::getUnzippedLogFiles() const
+ { return getLogStoragefiles(m_ServiceFactory, &isLogfile); }
+
+ const vector<OUString> LogStorage::getZippedLogFiles() const
+ { return getLogStoragefiles(m_ServiceFactory, &isZipfile); }
+}
diff --git a/extensions/source/oooimprovement/logstorage.hxx b/extensions/source/oooimprovement/logstorage.hxx
new file mode 100644
index 000000000000..2def4f5eb72a
--- /dev/null
+++ b/extensions/source/oooimprovement/logstorage.hxx
@@ -0,0 +1,55 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef EXTENSIONS_OOOIMPROVEMENT_LOGSTORAGE_HXX
+#define EXTENSIONS_OOOIMPROVEMENT_LOGSTORAGE_HXX
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <rtl/ustring.hxx>
+#include <vector>
+
+
+namespace oooimprovement
+{
+ #ifdef css
+ #error css defined globally
+ #endif
+ #define css ::com::sun::star
+ class LogStorage
+ {
+ public:
+ LogStorage(const css::uno::Reference< css::lang::XMultiServiceFactory>& sf);
+ void assureExists();
+ void clear();
+ const std::vector< ::rtl::OUString> getUnzippedLogFiles() const;
+ const std::vector< ::rtl::OUString> getZippedLogFiles() const;
+ private:
+ const css::uno::Reference< css::lang::XMultiServiceFactory> m_ServiceFactory;
+ };
+ #undef css
+}
+#endif
diff --git a/extensions/source/oooimprovement/makefile.mk b/extensions/source/oooimprovement/makefile.mk
new file mode 100644
index 000000000000..16e3f12f126c
--- /dev/null
+++ b/extensions/source/oooimprovement/makefile.mk
@@ -0,0 +1,112 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+
+PRJ=..$/..
+
+PRJNAME=extensions
+TARGET=oooimprovement
+ENABLE_EXCEPTIONS=TRUE
+
+PACKAGE=org.openoffice.Office
+ABSXCSROOT=$(SOLARXMLDIR)
+XCSROOT=..
+DTDDIR=$(ABSXCSROOT)
+XSLDIR=$(ABSXCSROOT)$/processing
+PROCESSOUT=$(MISC)$/$(TARGET)
+PROCESSORDIR=$(SOLARBINDIR)
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= \
+ $(SLO)$/myconfigurationhelper.obj \
+ $(SLO)$/config.obj \
+ $(SLO)$/corecontroller.obj \
+ $(SLO)$/errormail.obj \
+ $(SLO)$/invite_job.obj \
+ $(SLO)$/logpacker.obj \
+ $(SLO)$/logstorage.obj \
+ $(SLO)$/onlogrotate_job.obj \
+ $(SLO)$/oooimprovement_exports.obj \
+ $(SLO)$/soaprequest.obj \
+ $(SLO)$/soapsender.obj \
+
+SHL1STDLIBS= \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB) \
+ $(UNOTOOLSLIB) \
+
+SHL1TARGET= $(TARGET)$(DLLPOSTFIX)
+.IF "$(GUI)"=="OS2"
+SHL1TARGET= oooimp$(DLLPOSTFIX)
+.ENDIF
+
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+DEF1NAME= $(SHL1TARGET)
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+PACKAGEDIR=$(subst,.,$/ $(PACKAGE))
+SPOOLDIR=$(MISC)$/registry$/spool
+
+XCUFILES= \
+ Jobs.xcu \
+ Logging.xcu
+
+MYXCUFILES= \
+ $(SPOOLDIR)$/$(PACKAGEDIR)$/Jobs$/Jobs-oooimprovement.xcu \
+ $(SPOOLDIR)$/$(PACKAGEDIR)$/Logging$/Logging-oooimprovement.xcu
+
+
+# --- Targets ---
+
+.INCLUDE : target.mk
+
+ALLTAR : $(MYXCUFILES)
+
+XCU_SOURCEDIR:=.
+
+$(SPOOLDIR)$/$(PACKAGEDIR)$/Jobs$/Jobs-oooimprovement.xcu : $(XCU_SOURCEDIR)$/Jobs.xcu
+ @-$(MKDIRHIER) $(@:d)
+ @$(COPY) $< $@
+
+$(SPOOLDIR)$/$(PACKAGEDIR)$/Logging$/Logging-oooimprovement.xcu : $(XCU_SOURCEDIR)$/Logging.xcu
+ @-$(MKDIRHIER) $(@:d)
+ @$(COPY) $< $@
+
+ALLTAR : $(MISC)/oooimprovement.component
+
+$(MISC)/oooimprovement.component .ERRREMOVE : \
+ $(SOLARENV)/bin/createcomponent.xslt oooimprovement.component
+ $(XSLTPROC) --nonet --stringparam uri \
+ '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \
+ $(SOLARENV)/bin/createcomponent.xslt oooimprovement.component
diff --git a/extensions/source/oooimprovement/makefile.pmk b/extensions/source/oooimprovement/makefile.pmk
new file mode 100644
index 000000000000..f5c8da25b54a
--- /dev/null
+++ b/extensions/source/oooimprovement/makefile.pmk
@@ -0,0 +1,29 @@
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+XSLDIR=$(SOLARXMLDIR)$/processing
+XCSROOT=$(SOLARXMLDIR)
+ABSXCSROOT=$(SOLARXMLDIR)
+DTDDIR=$(SOLARXMLDIR)
+PROCESSOUT=$(MISC)$/$(CUSTID)
+PROCESSORDIR=$(SOLARBINDIR)
+
+# no validation by inspector class
+NO_INSPECTION=TRUE
+
diff --git a/extensions/source/oooimprovement/myconfigurationhelper.cxx b/extensions/source/oooimprovement/myconfigurationhelper.cxx
new file mode 100644
index 000000000000..d563b547f2bc
--- /dev/null
+++ b/extensions/source/oooimprovement/myconfigurationhelper.cxx
@@ -0,0 +1,178 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "myconfigurationhelper.hxx"
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <rtl/ustrbuf.hxx>
+#include <vector>
+
+
+namespace css = ::com::sun::star;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+using ::std::vector;
+
+
+namespace
+{
+ static const Sequence<Any> sequenceFromVector(const vector<Any>& vec)
+ {
+ Sequence<Any> result(vec.size());
+ for(size_t idx = 0; idx < vec.size(); ++idx)
+ result[idx] = vec[idx];
+ return result;
+ };
+
+ static const OUString noSuchElement(const OUString& path)
+ {
+ OUStringBuffer buf(256);
+ buf.appendAscii("The requested path \"");
+ buf.append(path);
+ buf.appendAscii("\" does not exists.");
+ return buf.makeStringAndClear();
+ };
+}
+
+namespace oooimprovement
+{
+ Reference<XInterface> MyConfigurationHelper::openConfig(
+ const Reference<XMultiServiceFactory> xSMGR,
+ const OUString& sPackage,
+ sal_Int32 eMode)
+ {
+ Reference<XMultiServiceFactory> xConfigProvider(
+ xSMGR->createInstance(OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")),
+ UNO_QUERY_THROW);
+
+ vector<Any> lParams;
+ css::beans::PropertyValue aParam;
+
+ // set root path
+ aParam.Name = OUString::createFromAscii("nodepath");
+ aParam.Value <<= sPackage;
+ lParams.push_back(makeAny(aParam));
+
+ // enable all locales mode
+ if ((eMode & MyConfigurationHelper::E_ALL_LOCALES)==MyConfigurationHelper::E_ALL_LOCALES)
+ {
+ aParam.Name = OUString::createFromAscii("locale");
+ aParam.Value <<= OUString::createFromAscii("*");
+ lParams.push_back(makeAny(aParam));
+ }
+
+ // enable lazy writing
+ sal_Bool bLazy = ((eMode & MyConfigurationHelper::E_LAZY_WRITE)==MyConfigurationHelper::E_LAZY_WRITE);
+ aParam.Name = OUString::createFromAscii("lazywrite");
+ aParam.Value = makeAny(bLazy);
+ lParams.push_back(makeAny(aParam));
+
+ // open it
+ Reference<XInterface> xCFG;
+
+ sal_Bool bReadOnly = ((eMode & MyConfigurationHelper::E_READONLY)==MyConfigurationHelper::E_READONLY);
+ if (bReadOnly)
+ xCFG = xConfigProvider->createInstanceWithArguments(
+ OUString::createFromAscii("com.sun.star.configuration.ConfigurationAccess"),
+ sequenceFromVector(lParams));
+ else
+ xCFG = xConfigProvider->createInstanceWithArguments(
+ OUString::createFromAscii("com.sun.star.configuration.ConfigurationUpdateAccess"),
+ sequenceFromVector(lParams));
+ return xCFG;
+ }
+
+ Any MyConfigurationHelper::readRelativeKey(
+ const Reference<XInterface> xCFG,
+ const OUString& sRelPath,
+ const OUString& sKey)
+ {
+ Reference<css::container::XHierarchicalNameAccess> xAccess(xCFG, UNO_QUERY_THROW);
+
+ Reference<css::beans::XPropertySet> xProps;
+ xAccess->getByHierarchicalName(sRelPath) >>= xProps;
+ if (!xProps.is())
+ throw css::container::NoSuchElementException(
+ noSuchElement(sRelPath),
+ Reference<XInterface>());
+ return xProps->getPropertyValue(sKey);
+ }
+
+ void MyConfigurationHelper::writeRelativeKey(
+ const Reference<XInterface> xCFG,
+ const OUString& sRelPath,
+ const OUString& sKey,
+ const Any& aValue)
+ {
+ Reference<css::container::XHierarchicalNameAccess> xAccess(xCFG, UNO_QUERY_THROW);
+
+ Reference<css::beans::XPropertySet> xProps;
+ xAccess->getByHierarchicalName(sRelPath) >>= xProps;
+ if (!xProps.is())
+ throw css::container::NoSuchElementException(
+ noSuchElement(sRelPath),
+ Reference<XInterface>());
+ xProps->setPropertyValue(sKey, aValue);
+ }
+
+ Any MyConfigurationHelper::readDirectKey(
+ const Reference<XMultiServiceFactory> xSMGR,
+ const OUString& sPackage,
+ const OUString& sRelPath,
+ const OUString& sKey,
+ sal_Int32 eMode)
+ {
+ Reference<XInterface> xCFG = MyConfigurationHelper::openConfig(xSMGR, sPackage, eMode);
+ return MyConfigurationHelper::readRelativeKey(xCFG, sRelPath, sKey);
+ }
+
+ void MyConfigurationHelper::writeDirectKey(
+ const Reference<XMultiServiceFactory> xSMGR,
+ const OUString& sPackage,
+ const OUString& sRelPath,
+ const OUString& sKey,
+ const Any& aValue,
+ sal_Int32 eMode)
+ {
+ Reference<XInterface> xCFG = MyConfigurationHelper::openConfig(xSMGR, sPackage, eMode);
+ MyConfigurationHelper::writeRelativeKey(xCFG, sRelPath, sKey, aValue);
+ MyConfigurationHelper::flush(xCFG);
+ }
+
+ void MyConfigurationHelper::flush(const Reference<XInterface>& xCFG)
+ {
+ Reference<css::util::XChangesBatch> xBatch(xCFG, UNO_QUERY_THROW);
+ xBatch->commitChanges();
+ }
+}
diff --git a/extensions/source/oooimprovement/myconfigurationhelper.hxx b/extensions/source/oooimprovement/myconfigurationhelper.hxx
new file mode 100644
index 000000000000..d196f415dc33
--- /dev/null
+++ b/extensions/source/oooimprovement/myconfigurationhelper.hxx
@@ -0,0 +1,214 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef EXTENSIONS_OOOIMPROVEMENT_CONFIGURATIONHELPER_HXX
+#define EXTENSIONS_OOOIMPROVEMENT_CONFIGURATIONHELPER_HXX
+
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#include <com/sun/star/util/XChangesBatch.hpp>
+#include <rtl/ustring.hxx>
+
+
+namespace oooimprovement
+{
+ #ifdef css
+ #error css defined globally
+ #endif
+ #define css ::com::sun::star
+ // Copy from comphelper module, we cant use that directly from an extension
+ class MyConfigurationHelper
+ {
+ public:
+ //-----------------------------------------------
+ /** specify all possible modes, which can be used to open a configuration access.
+ *
+ * @see openConfig()
+ * @see readDirectKey()
+ * @see writeDirectKey()
+ */
+ enum EConfigurationModes
+ {
+ /// opens configuration in read/write mode (without LAZY writing!)
+ E_STANDARD = 0,
+ /// configuration will be opened readonly
+ E_READONLY = 1,
+ /// all localized nodes will be interpreted as css::uno::XInterface instead of interpreting it as atomic value nodes
+ E_ALL_LOCALES = 2,
+ /// enable lazy writing
+ E_LAZY_WRITE = 4
+ };
+
+ //-----------------------------------------------
+ /** returns access to the specified configuration package.
+ *
+ * This method should be used, if e.g. more then one request to the same
+ * configuration package is needed. The configuration access can be cached
+ * outside and used inbetween.
+ *
+ * @param xSMGR
+ * the uno service manager, which should be used to create the
+ * configuration access.
+ *
+ * @param sPackage
+ * the name of the configuration package.
+ * e.g. <ul>
+ * <li>org.openoffice.Office.Common</li>
+ * <li>org.openoffice.Office.Common/Menu</li>
+ * </ul>
+ *
+ * @param eMode
+ * specify the open mode for the returned configuration access.
+ * It's interpreted as a flag field and can be any usefull combination
+ * of values of EConfigurationModes.
+ *
+ * @throw css::uno::Any exceptions the underlying configuration can throw.
+ * E.g. css::uno::Exception if the configuration could not be opened.
+ */
+ static css::uno::Reference< css::uno::XInterface> openConfig(
+ const css::uno::Reference< css::lang::XMultiServiceFactory> xSMGR,
+ const ::rtl::OUString& sPackage,
+ sal_Int32 eMode);
+
+ //-----------------------------------------------
+ /** reads the value of an existing(!) configuration key,
+ * which is searched relative to the specified configuration access.
+ *
+ * This method must be used in combination with openConfig().
+ * The cached configuration access must be provided here ... and
+ * all operations are made relativ to this access point.
+ *
+ * @param xCFG
+ * the configuration root, where sRelPath should be interpreted.
+ * as relativ path
+ *
+ * @param sRelPath
+ * path relative to xCFG parameter.
+ *
+ * @param sKey
+ * the configuration node, where we should read the value.
+ *
+ * @return [css.uno.css::uno::Any]
+ * the value of sKey.
+ *
+ * @throw css::uno::Any exceptions the underlying configuration can throw.
+ * E.g. css::container::NoSuchElementException if the specified
+ * key does not exists.
+ */
+ static css::uno::Any readRelativeKey(
+ const css::uno::Reference< css::uno::XInterface> xCFG,
+ const ::rtl::OUString& sRelPath,
+ const ::rtl::OUString& sKey);
+
+ //-----------------------------------------------
+ /** writes a new value for an existing(!) configuration key,
+ * which is searched relative to the specified configuration access.
+ *
+ * This method must be used in combination with openConfig().
+ * The cached configuration access must be provided here ... and
+ * all operations are made relativ to this access point.
+ *
+ * @param xCFG
+ * the configuration root, where sRelPath should be interpreted.
+ * as relativ path
+ *
+ * @param sRelPath
+ * path relative to xCFG parameter.
+ *
+ * @param sKey
+ * the configuration node, where we should write the new value.
+ *
+ * @param aValue
+ * the new value for sKey.
+ *
+ * @throw css::uno::Any exceptions the underlying configuration can throw.
+ * E.g. css::container::NoSuchElementException if the specified
+ * key does not exists or css::uno::Exception if the provided configuration
+ * access does not allow writing for this key.
+ */
+ static void writeRelativeKey(
+ const css::uno::Reference< css::uno::XInterface> xCFG,
+ const ::rtl::OUString& sRelPath,
+ const ::rtl::OUString& sKey,
+ const css::uno::Any& aValue);
+
+ //-----------------------------------------------
+ /** commit all changes made on the specified configuration access.
+ *
+ * This method must be used in combination with openConfig().
+ * The cached configuration access must be provided here.
+ *
+ * @param xCFG
+ * the configuration root, where changes should be commited.
+ *
+ * @throw css::uno::Any exceptions the underlying configuration can throw.
+ * E.g. uno::Exception if the provided configuration
+ * access does not allow writing for this set.
+ */
+ static void flush(const css::uno::Reference< css::uno::XInterface>& xCFG);
+
+ //-----------------------------------------------
+ /** does the same then openConfig() & readRelativeKey() together.
+ *
+ * This method should be used for reading one key at one code place only.
+ * Because it opens the specified configuration package, reads the key and
+ * closes the configuration again.
+ *
+ * So its not very usefull to use this method for reading multiple keys at the same time.
+ * (Excepting these keys exists inside different configuration packages ...))
+ */
+ static css::uno::Any readDirectKey(
+ const css::uno::Reference< css::lang::XMultiServiceFactory> xSMGR,
+ const ::rtl::OUString& sPackage,
+ const ::rtl::OUString& sRelPath,
+ const ::rtl::OUString& sKey,
+ sal_Int32 eMode);
+
+ //-----------------------------------------------
+ /** does the same then openConfig() / writeRelativeKey() & flush() together.
+ *
+ * This method should be used for writing one key at one code place only.
+ * Because it opens the specified configuration package, writes the key, flush
+ * all changes and closes the configuration again.
+ *
+ * So its not very usefull to use this method for writing multiple keys at the same time.
+ * (Excepting these keys exists inside different configuration packages ...))
+ */
+ static void writeDirectKey(
+ const css::uno::Reference< css::lang::XMultiServiceFactory> xSMGR,
+ const ::rtl::OUString& sPackage,
+ const ::rtl::OUString& sRelPath,
+ const ::rtl::OUString& sKey,
+ const css::uno::Any& aValue,
+ sal_Int32 eMode);
+ };
+ #undef css
+}
+#endif
diff --git a/extensions/source/oooimprovement/onlogrotate_job.cxx b/extensions/source/oooimprovement/onlogrotate_job.cxx
new file mode 100644
index 000000000000..e1f9cf717584
--- /dev/null
+++ b/extensions/source/oooimprovement/onlogrotate_job.cxx
@@ -0,0 +1,240 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "onlogrotate_job.hxx"
+#include "config.hxx"
+#include "logpacker.hxx"
+#include "logstorage.hxx"
+#include "soaprequest.hxx"
+#include "soapsender.hxx"
+
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <com/sun/star/frame/XDesktop.hpp>
+#include <com/sun/star/frame/XTerminateListener.hpp>
+#include <osl/conditn.hxx>
+#include <osl/thread.hxx>
+#include <osl/time.h>
+#include <cppuhelper/implbase1.hxx>
+#include <memory>
+
+
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::uno;
+using ::com::sun::star::frame::XTerminateListener;
+using ::com::sun::star::frame::XDesktop;
+using ::com::sun::star::ucb::XSimpleFileAccess;
+using ::rtl::OUString;
+using ::std::vector;
+
+namespace
+{
+ using namespace oooimprovement;
+
+ static void packLogs(const Reference<XMultiServiceFactory>& sf)
+ {
+ try
+ {
+ Config config(sf);
+ LogPacker log_packer(sf);
+ vector<OUString> csvfiles = LogStorage(sf).getUnzippedLogFiles();
+ for(
+ vector<OUString>::iterator item = csvfiles.begin();
+ item!=csvfiles.end();
+ item++)
+ config.incrementEventCount(log_packer.pack(*item));
+ } catch(...) {};
+ };
+
+ static void uploadLogs(const Reference<XMultiServiceFactory>& sf)
+ {
+ try
+ {
+ Config config(sf);
+ Reference<XSimpleFileAccess> file_access(
+ sf->createInstance(OUString::createFromAscii("com.sun.star.ucb.SimpleFileAccess")),
+ UNO_QUERY_THROW);
+ SoapSender sender(sf, config.getSoapUrl());
+ OUString soap_id = config.getSoapId();
+ vector<OUString> zipfiles = LogStorage(sf).getZippedLogFiles();
+ for(
+ vector<OUString>::iterator item = zipfiles.begin();
+ item!=zipfiles.end();
+ item++)
+ {
+ if(config.incrementFailedAttempts(1) > 25)
+ {
+ config.giveupUploading();
+ LogStorage(sf).clear();
+ return;
+ }
+ sender.send(SoapRequest(sf, soap_id, *item));
+ config.incrementReportCount(1);
+ file_access->kill(*item);
+ config.resetFailedAttempts();
+ }
+ } catch(...) {};
+ }
+
+ class OnLogRotateThread : public ::osl::Thread
+ {
+ public:
+ OnLogRotateThread(Reference<XMultiServiceFactory> sf);
+ virtual void SAL_CALL run();
+ void stop();
+
+ private:
+ Reference<XMultiServiceFactory> m_ServiceFactory;
+ ::osl::Condition m_Stop;
+ };
+
+ OnLogRotateThread::OnLogRotateThread(Reference<XMultiServiceFactory> sf)
+ : m_ServiceFactory(sf)
+ {
+ OSL_ASSERT(sf.is());
+ }
+
+ void SAL_CALL OnLogRotateThread::run()
+ {
+ TimeValue wait_intervall = {30,0};
+ if (m_Stop.wait(&wait_intervall) == ::osl::Condition::result_timeout)
+ {
+ try
+ {
+ if(Config(m_ServiceFactory).getInvitationAccepted())
+ {
+ packLogs(m_ServiceFactory);
+ uploadLogs(m_ServiceFactory);
+ }
+ else
+ LogStorage(m_ServiceFactory).clear();
+ }
+ catch(...) {}
+ }
+ }
+
+ void OnLogRotateThread::stop()
+ {
+ m_Stop.set();
+ }
+
+ class OnLogRotateThreadWatcher : public ::cppu::WeakImplHelper1<XTerminateListener>
+ {
+ public:
+ OnLogRotateThreadWatcher(Reference<XMultiServiceFactory> sf)
+ : m_Thread(new OnLogRotateThread(sf))
+ {
+ m_Thread->create();
+ }
+ virtual ~OnLogRotateThreadWatcher()
+ {
+ m_Thread->stop();
+ m_Thread->join();
+ };
+
+ // XTerminateListener
+ virtual void SAL_CALL queryTermination(const EventObject&) throw(RuntimeException)
+ { };
+ virtual void SAL_CALL notifyTermination(const EventObject&) throw(RuntimeException)
+ {
+ m_Thread->stop();
+ m_Thread->join();
+ };
+ // XEventListener
+ virtual void SAL_CALL disposing(const EventObject&) throw(RuntimeException)
+ {
+ m_Thread->stop();
+ m_Thread->join();
+ };
+ private:
+ ::std::auto_ptr<OnLogRotateThread> m_Thread;
+ };
+}
+
+namespace oooimprovement
+{
+ OnLogRotateJob::OnLogRotateJob(const Reference<XComponentContext>& context)
+ : m_ServiceFactory(Reference<XMultiServiceFactory>(
+ context->getServiceManager()->createInstanceWithContext(
+ OUString::createFromAscii("com.sun.star.lang.XMultiServiceFactory"), context),
+ UNO_QUERY))
+ { }
+
+ OnLogRotateJob::OnLogRotateJob(const Reference<XMultiServiceFactory>& sf)
+ : m_ServiceFactory(sf)
+ { }
+
+ OnLogRotateJob::~OnLogRotateJob()
+ { }
+
+ void SAL_CALL OnLogRotateJob::executeAsync(
+ const Sequence<NamedValue>&,
+ const Reference<XJobListener>& listener)
+ throw(RuntimeException)
+ {
+ Reference<XDesktop> xDesktop(
+ m_ServiceFactory->createInstance(OUString::createFromAscii("com.sun.star.frame.Desktop")),
+ UNO_QUERY);
+ if(xDesktop.is())
+ xDesktop->addTerminateListener(Reference<XTerminateListener>(new OnLogRotateThreadWatcher(m_ServiceFactory)));
+ Any result;
+ listener->jobFinished(Reference<XAsyncJob>(this), result);
+ }
+
+ sal_Bool SAL_CALL OnLogRotateJob::supportsService(const OUString& service_name) throw(RuntimeException)
+ {
+ const Sequence<OUString> service_names(getSupportedServiceNames());
+ for (sal_Int32 idx = service_names.getLength()-1; idx>=0; --idx)
+ if(service_name == service_names[idx]) return sal_True;
+ return sal_False;
+ }
+
+ OUString SAL_CALL OnLogRotateJob::getImplementationName() throw(RuntimeException)
+ { return getImplementationName_static(); }
+
+ Sequence<OUString> SAL_CALL OnLogRotateJob::getSupportedServiceNames() throw(RuntimeException)
+ { return getSupportedServiceNames_static(); }
+
+ OUString SAL_CALL OnLogRotateJob::getImplementationName_static()
+ { return OUString::createFromAscii("com.sun.star.comp.extensions.oooimprovement.OnLogRotateJob"); }
+
+ Sequence<OUString> SAL_CALL OnLogRotateJob::getSupportedServiceNames_static()
+ {
+ Sequence<OUString> aServiceNames(1);
+ aServiceNames[0] = OUString::createFromAscii("com.sun.star.task.AsyncJob");
+ return aServiceNames;
+ }
+
+ Reference<XInterface> OnLogRotateJob::Create(const Reference<XComponentContext>& context)
+ { return *(new OnLogRotateJob(context)); }
+
+ Reference<XInterface> OnLogRotateJob::Create(const Reference<XMultiServiceFactory>& sf)
+ { return *(new OnLogRotateJob(sf)); }
+}
diff --git a/extensions/source/oooimprovement/onlogrotate_job.hxx b/extensions/source/oooimprovement/onlogrotate_job.hxx
new file mode 100644
index 000000000000..8fa902ad4c78
--- /dev/null
+++ b/extensions/source/oooimprovement/onlogrotate_job.hxx
@@ -0,0 +1,83 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+
+
+#ifndef EXTENSIONS_OOOIMPROVEMENT_ONLOGROTATEJOB_HXX
+#define EXTENSIONS_OOOIMPROVEMENT_ONLOGROTATEJOB_HXX
+
+#include <com/sun/star/task/XAsyncJob.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <cppuhelper/implbase2.hxx>
+
+
+namespace oooimprovement
+{
+ #ifdef css
+ #error css defined globally
+ #endif
+ #define css ::com::sun::star
+ class OnLogRotateJob : public ::cppu::WeakImplHelper2<
+ ::com::sun::star::task::XAsyncJob,
+ ::com::sun::star::lang::XServiceInfo>
+ {
+ public:
+ // XServiceInfo - static version
+ static ::rtl::OUString SAL_CALL getImplementationName_static();
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames_static();
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> SAL_CALL Create(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& context);
+
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> SAL_CALL Create(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& sf);
+
+ protected:
+ OnLogRotateJob(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& context);
+ OnLogRotateJob(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& sm);
+ virtual ~OnLogRotateJob();
+
+ // XAsyncJob
+ virtual void SAL_CALL executeAsync(
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue>& args,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XJobListener>& listener)
+ throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName()
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService(const ::rtl::OUString& service_name)
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames()
+ throw(::com::sun::star::uno::RuntimeException);
+
+ private:
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_ServiceFactory;
+ };
+ #undef css
+}
+#endif
diff --git a/extensions/source/oooimprovement/oooimprovement.component b/extensions/source/oooimprovement/oooimprovement.component
new file mode 100644
index 000000000000..e133f932c199
--- /dev/null
+++ b/extensions/source/oooimprovement/oooimprovement.component
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--**********************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+**********************************************************************-->
+
+<component loader="com.sun.star.loader.SharedLibrary"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation
+ name="com.sun.star.comp.extensions.oooimprovement.CoreController">
+ <service name="com.sun.star.oooimprovement.CoreController"/>
+ </implementation>
+ <implementation name="com.sun.star.comp.extensions.oooimprovement.InviteJob"/>
+ <implementation
+ name="com.sun.star.comp.extensions.oooimprovement.OnLogRotateJob"/>
+</component>
diff --git a/extensions/source/oooimprovement/oooimprovement_exports.cxx b/extensions/source/oooimprovement/oooimprovement_exports.cxx
new file mode 100644
index 000000000000..b351f84680d7
--- /dev/null
+++ b/extensions/source/oooimprovement/oooimprovement_exports.cxx
@@ -0,0 +1,88 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "corecontroller.hxx"
+#include "invite_job.hxx"
+#include "onlogrotate_job.hxx"
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <cppuhelper/factory.hxx>
+#include <osl/mutex.hxx>
+#include <osl/thread.h>
+#include <rtl/ustrbuf.hxx>
+#include <rtl/ustring.hxx>
+
+
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::registry;
+using namespace ::com::sun::star::uno;
+using namespace ::oooimprovement;
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+
+
+namespace
+{
+ void writeInfo(const Reference<XRegistryKey>& reg_key,
+ const OUString& implementation_name,
+ const OUString& service_name)
+ {
+ OUStringBuffer buf(256);
+ buf.append(implementation_name);
+ buf.appendAscii("/UNO/SERVICES/");
+ buf.append(service_name);
+ reg_key->createKey(buf.makeStringAndClear());
+ }
+}
+
+extern "C"
+{
+ void SAL_CALL component_getImplementationEnvironment(const sal_Char** env_type_name, uno_Environment**)
+ { *env_type_name = CPPU_CURRENT_LANGUAGE_BINDING_NAME; }
+
+ void* SAL_CALL component_getFactory(const sal_Char* pImplName, void* pServiceManager, void*)
+ {
+ if ( !pServiceManager || !pImplName ) return 0;
+
+ Reference<XSingleServiceFactory> factory;
+ Reference<XMultiServiceFactory> sm(reinterpret_cast<XMultiServiceFactory*>(pServiceManager), UNO_QUERY);
+ OUString impl_name = OUString::createFromAscii(pImplName);
+ Sequence<OUString> names(1);
+ names[0] = impl_name;
+
+ if (impl_name.equals(CoreController::getImplementationName_static()))
+ factory = ::cppu::createSingleFactory(sm, impl_name, CoreController::Create, names);
+ if (impl_name.equals(OnLogRotateJob::getImplementationName_static()))
+ factory = ::cppu::createSingleFactory(sm, impl_name, OnLogRotateJob::Create, names);
+ if (impl_name.equals(InviteJob::getImplementationName_static()))
+ factory = ::cppu::createSingleFactory(sm, impl_name, InviteJob::Create, names);
+ if (!factory.is()) return 0;
+ factory->acquire();
+ return factory.get();
+ }
+}
diff --git a/extensions/source/oooimprovement/soaprequest.cxx b/extensions/source/oooimprovement/soaprequest.cxx
new file mode 100644
index 000000000000..ea1274bd18f6
--- /dev/null
+++ b/extensions/source/oooimprovement/soaprequest.cxx
@@ -0,0 +1,200 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "soaprequest.hxx"
+#include "errormail.hxx"
+#include "config.hxx"
+#include <boost/shared_ptr.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <rtl/strbuf.hxx>
+#include <rtl/ustring.hxx>
+
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::io;
+using boost::shared_ptr;
+using com::sun::star::io::XOutputStream;
+using com::sun::star::ucb::XSimpleFileAccess;
+using rtl::OUString;
+using rtl::OString;
+using rtl::OStringBuffer;
+
+
+namespace
+{
+ static unsigned long asUlong(sal_Int8 input)
+ {
+ return *reinterpret_cast<unsigned char *>(&input);
+ };
+
+ static Sequence<sal_Int8> base64_encode(const Sequence<sal_Int8>& input)
+ {
+ static const char base64_tab[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ Sequence<sal_Int8> result(4);
+ unsigned long value = asUlong(input[0]) << 16;
+ if(input.getLength() > 1) value |= asUlong(input[1]) << 8;
+ if(input.getLength() > 2) value |= asUlong(input[2]);
+
+ result[0] = static_cast<sal_Int8>(base64_tab[(value >> 18) & 0x3F]);
+ result[1] = static_cast<sal_Int8>(base64_tab[(value >> 12) & 0x3F]);
+ result[2] = static_cast<sal_Int8>('=');
+ result[3] = static_cast<sal_Int8>('=');
+
+ if (input.getLength() > 1)
+ {
+ result[2] = base64_tab[(value >> 6) & 0x3F];
+ if (input.getLength() > 2)
+ result[3] = base64_tab[(value >> 0) & 0x3F];
+ }
+ return result;
+ };
+
+ static OString replaceAll(const OString& str, sal_Char old, const OString& replacement)
+ {
+ OStringBuffer result;
+ sal_Int32 idx = 0;
+ do {
+ result.append(str.getToken(0, old, idx));
+ if(idx>=0) result.append(replacement);
+ } while(idx >= 0);
+ return result.makeStringAndClear();
+ };
+
+ static OString xmlEncode(const OString& input)
+ {
+ OString result = replaceAll(input, '&', OString("&amp;"));
+ result = replaceAll(result, '<', OString("&lt;"));
+ return replaceAll(result, '>', OString("&gt;"));
+ }
+
+ static shared_ptr<Sequence<sal_Int8> > createSequenceFromString(const OString& str)
+ {
+ const sal_Int32 size = str.getLength();
+ shared_ptr<Sequence<sal_Int8> > result(new Sequence<sal_Int8>(size));
+ for(sal_Int32 idx=0; idx < size; idx++)
+ (*result)[idx] = str[idx];
+ return result;
+ };
+
+ static void writeString(const Reference<XOutputStream>& target, const OString& str)
+ {
+ shared_ptr<Sequence<sal_Int8> > seq = createSequenceFromString(str);
+ target->writeBytes(*seq);
+ };
+
+ static void writeFile(const Reference<XMultiServiceFactory>& sf, const Reference<XOutputStream>& target, const OUString& fileurl)
+ {
+ Reference<XSimpleFileAccess> file_access(
+ sf->createInstance(OUString::createFromAscii("com.sun.star.ucb.SimpleFileAccess")),
+ UNO_QUERY);
+ Reference<XInputStream> file = file_access->openFileRead(fileurl);
+ const sal_Int32 bufsize = 3;
+ sal_Int32 bytes_read;
+ Sequence<sal_Int8> buf(bufsize);
+ do
+ {
+ bytes_read = file->readBytes(buf, bufsize);
+ if(bytes_read < buf.getLength()) buf.realloc(bytes_read);
+ if(bytes_read) target->writeBytes(base64_encode(buf));
+ } while(bytes_read == bufsize);
+ };
+
+ static const OString SOAP_START(
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"\n"
+ "xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\"\n"
+ "xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\"\n"
+ "xmlns:xsd=\"http://www.w3.org/1999/XMLSchema\"\n"
+ "xmlns:rds=\"urn:ReportDataService\"\n"
+ "xmlns:apache=\"http://xml.apache.org/xml-soap\"\n"
+ "SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\n"
+ "<SOAP-ENV:Body>\n"
+ "<rds:submitReport>\n");
+ static const OString SOAP_ITEMS_START("<hash xsi:type=\"apache:Map\">\n");
+ static const OString SOAP_ITEMS_END("</hash>\n");
+ static const OString SOAP_END(
+ "</rds:submitReport>\n"
+ "</SOAP-ENV:Body>\n"
+ "</SOAP-ENV:Envelope>\n");
+ static const OString SOAP_ITEM_END("]]></value></item>\n");
+
+ static const OString getSoapOfficeversion(const Reference<XMultiServiceFactory>& sf)
+ {
+ return ::rtl::OUStringToOString(oooimprovement::Config(sf).getCompleteProductname(), RTL_TEXTENCODING_ASCII_US);
+ };
+
+ static const OString getSoapSoapId(const Reference<XMultiServiceFactory>& sf, const OString& soap_id)
+ {
+ OStringBuffer buf;
+ buf.append("<body xsi:type=\"xsd:string\">");
+ buf.append(xmlEncode(soap_id)).append("\n");
+ buf.append(xmlEncode(getSoapOfficeversion(sf))).append("\n");
+ buf.append("</body>\n");
+ return buf.makeStringAndClear();
+ };
+
+ static const OString getSoapItemStart(const OString& key)
+ {
+ OStringBuffer buf =
+ "<item>\n"
+ "<key xsi:type=\"xsd:string\">" + key + "</key>\n"
+ "<value xsi:type=\"xsd:string\"><![CDATA[";
+ return buf.makeStringAndClear();
+ };
+}
+
+namespace oooimprovement
+{
+ SoapRequest::SoapRequest(const Reference<XMultiServiceFactory>& sf, const OUString& soap_id, const OUString& logfile)
+ : m_ServiceFactory(sf)
+ , m_SoapId(soap_id)
+ , m_Logfile(logfile)
+ {}
+
+ void SoapRequest::writeTo(const Reference<XOutputStream>& target) const
+ {
+ writeString(target, SOAP_START);
+ writeString(
+ target,
+ getSoapSoapId(m_ServiceFactory, rtl::OUStringToOString(m_SoapId, RTL_TEXTENCODING_ASCII_US)));
+ writeString(target, SOAP_ITEMS_START);
+ writeString(target, getSoapItemStart("reportmail.xml"));
+ writeString(target, Errormail(m_ServiceFactory).getXml());
+ writeString(target, SOAP_ITEM_END);
+ writeString(target, getSoapItemStart("data.zip"));
+ writeFile(m_ServiceFactory, target, m_Logfile);
+ writeString(target, SOAP_ITEM_END);
+ writeString(target, SOAP_ITEMS_END);
+ writeString(target, SOAP_END);
+ }
+}
diff --git a/extensions/source/oooimprovement/soaprequest.hxx b/extensions/source/oooimprovement/soaprequest.hxx
new file mode 100644
index 000000000000..9770093ac03c
--- /dev/null
+++ b/extensions/source/oooimprovement/soaprequest.hxx
@@ -0,0 +1,60 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef EXTENSIONS_OOOIMPROVEMENT_SOAPREQUEST_HXX
+#define EXTENSIONS_OOOIMPROVEMENT_SOAPREQUEST_HXX
+
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <rtl/ustring.hxx>
+
+
+namespace oooimprovement
+{
+ #ifdef css
+ #error css defined globally
+ #endif
+ #define css ::com::sun::star
+ class SoapRequest
+ {
+ public:
+ SoapRequest(
+ const css::uno::Reference< css::lang::XMultiServiceFactory>& sf,
+ const ::rtl::OUString& soap_id,
+ const ::rtl::OUString& logfile);
+ void writeTo(const css::uno::Reference< css::io::XOutputStream>& target) const;
+ private:
+ const css::uno::Reference< css::lang::XMultiServiceFactory> m_ServiceFactory;
+ // soap_id has to be a plain 7-Bit ASCII String for identification of
+ // automated test logs etc.
+ const ::rtl::OUString m_SoapId;
+ // logfile is the file-url to the file to include
+ const ::rtl::OUString m_Logfile;
+ };
+ #undef css
+}
+#endif
diff --git a/extensions/source/oooimprovement/soapsender.cxx b/extensions/source/oooimprovement/soapsender.cxx
new file mode 100644
index 000000000000..01d2af96c85d
--- /dev/null
+++ b/extensions/source/oooimprovement/soapsender.cxx
@@ -0,0 +1,160 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "soapsender.hxx"
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/util/XURLTransformer.hpp>
+#include <com/sun/star/io/XTempFile.hpp>
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <osl/socket.hxx>
+#include <rtl/strbuf.hxx>
+#include <boost/shared_ptr.hpp>
+
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::io;
+using boost::shared_ptr;
+using com::sun::star::io::XTempFile;
+using com::sun::star::ucb::XSimpleFileAccess;
+using com::sun::star::util::URL;
+using com::sun::star::util::XURLTransformer;
+using osl::ConnectorSocket;
+using rtl::OString;
+using rtl::OUString;
+using rtl::OStringBuffer;
+
+
+namespace
+{
+ static OString getHttpPostHeader(OString path, sal_Int32 length)
+ {
+ OStringBuffer result =
+ "POST " + path + " HTTP/1.0\r\n"
+ "Content-Type: text/xml; charset=\"utf-8\"\r\n"
+ "Content-Length: ";
+ result.append(length);
+ result.append("\r\nSOAPAction: \"\"\r\n\r\n");
+ return result.makeStringAndClear();
+ };
+}
+
+namespace oooimprovement
+{
+ SoapSender::SoapSender(const Reference<XMultiServiceFactory> sf, const OUString& url)
+ : m_ServiceFactory(sf)
+ , m_Url(url)
+ { }
+
+ void SoapSender::send(const SoapRequest& request) const
+ {
+ Reference<XTempFile> temp_file(
+ m_ServiceFactory->createInstance(OUString::createFromAscii("com.sun.star.io.TempFile")),
+ UNO_QUERY_THROW);
+ Reference<XSimpleFileAccess> file_access(
+ m_ServiceFactory->createInstance(OUString::createFromAscii("com.sun.star.ucb.SimpleFileAccess")),
+ UNO_QUERY_THROW);
+ Reference<XURLTransformer> url_trans(
+ m_ServiceFactory->createInstance(OUString::createFromAscii("com.sun.star.util.URLTransformer")),
+ UNO_QUERY_THROW);
+
+ // writing request to tempfile
+ {
+ Reference<XOutputStream> temp_stream = temp_file->getOutputStream();
+ request.writeTo(temp_stream);
+ temp_stream->flush();
+ temp_stream->closeOutput();
+ }
+
+ // parse Url
+ URL url;
+ {
+ url.Complete = m_Url;
+ url_trans->parseStrict(url);
+ }
+
+ // connect socket
+ shared_ptr<ConnectorSocket> socket(new ConnectorSocket(osl_Socket_FamilyInet, osl_Socket_ProtocolIp, osl_Socket_TypeStream));
+ {
+ ::osl::SocketAddr addr(url.Server, url.Port);
+ oslSocketResult result = socket->connect(addr);
+ if(result != osl_Socket_Ok)
+ throw RuntimeException(
+ OUString::createFromAscii("unable to connect to SOAP server"),
+ Reference<XInterface>());
+ }
+
+ // send header
+ {
+ OStringBuffer path_on_server =
+ OUStringToOString(url.Path, RTL_TEXTENCODING_ASCII_US) +
+ OUStringToOString(url.Name, RTL_TEXTENCODING_ASCII_US);
+ const OString header = getHttpPostHeader(path_on_server.makeStringAndClear(), file_access->getSize(temp_file->getUri()));
+ if(socket->write(header.getStr(), header.getLength()) != static_cast<sal_Int32>(header.getLength()))
+ throw RuntimeException(
+ OUString::createFromAscii("error while sending HTTP header"),
+ Reference<XInterface>());
+ }
+
+ // send soap request
+ {
+ Reference<XInputStream> temp_stream = file_access->openFileRead(temp_file->getUri());
+ const sal_Int32 bufsize = 1024;
+ sal_Int32 bytes_read;
+ Sequence<sal_Int8> buf(bufsize);
+ char buf2[bufsize];
+ do
+ {
+ bytes_read = temp_stream->readBytes(buf, bufsize);
+ buf.realloc(bytes_read);
+ for(sal_Int32 idx = 0; idx < bytes_read; idx++)
+ buf2[idx] = buf[idx];
+ if(socket->write(buf2, bytes_read) != bytes_read)
+ throw RuntimeException(
+ OUString::createFromAscii("error while sending SOAP request"),
+ Reference<XInterface>());
+ } while(bytes_read == bufsize);
+ }
+
+ // receive answer
+ {
+ const sal_Int32 bufsize = 1024;
+ char buf[bufsize];
+ sal_Int32 bytes_read = socket->read(buf, bufsize);
+ OString answer(buf, bytes_read);
+ const sal_Int32 returncode_start = answer.indexOf(' ');
+ if(returncode_start==-1 || !answer.copy(returncode_start, 4).equals(OString(" 200")))
+ throw RuntimeException(
+ OUString::createFromAscii("SOAP server returns a error"),
+ Reference<XInterface>());
+ }
+ }
+}
diff --git a/extensions/source/oooimprovement/soapsender.hxx b/extensions/source/oooimprovement/soapsender.hxx
new file mode 100644
index 000000000000..d826582bd0d7
--- /dev/null
+++ b/extensions/source/oooimprovement/soapsender.hxx
@@ -0,0 +1,56 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef EXTENSIONS_OOOIMPROVEMENT_SOAPSENDER_HXX
+#define EXTENSIONS_OOOIMPROVEMENT_SOAPSENDER_HXX
+
+#include "soaprequest.hxx"
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/util/URL.hpp>
+#include <rtl/ustring.hxx>
+
+
+namespace oooimprovement
+{
+ #ifdef css
+ #error css defined globally
+ #endif
+ #define css ::com::sun::star
+ class SoapSender
+ {
+ public:
+ SoapSender(
+ const css::uno::Reference< css::lang::XMultiServiceFactory> sf,
+ const ::rtl::OUString& url);
+ void send(const SoapRequest& request) const;
+ private:
+ const css::uno::Reference< css::lang::XMultiServiceFactory> m_ServiceFactory;
+ const ::rtl::OUString m_Url;
+ };
+ #undef css
+}
+#endif