Kaydet (Commit) 1b38e7bd authored tarafından Oliver Bolte's avatar Oliver Bolte

CWS-TOOLING: integrate CWS oooimprovement2

2009-01-28 14:35:33 +0100 b_michaelsen  r267059 : #i98555# fixed help url
2009-01-27 12:47:40 +0100 b_michaelsen  r266982 : #159112# fixed enabling vcl part of usage tracking in an running session
2009-01-27 12:28:58 +0100 b_michaelsen  r266980 : #159129# deiniting eventlogger in vcl if it was inited, not if it was enabled (the logger can be disabled inbetween
2009-01-27 12:22:45 +0100 b_michaelsen  r266978 : whitespace fixes
2009-01-27 10:32:02 +0100 b_michaelsen  r266962 : #i94949# disposing of uploader thread
2009-01-23 17:00:57 +0100 b_michaelsen  r266839 : #159112# enabling/disabling of usage tracking takes effect without restart
2009-01-23 16:58:59 +0100 b_michaelsen  r266837 : #159112# enabling/disabling of usage tracking takes effect without restart
2009-01-23 01:08:49 +0100 b_michaelsen  r266761 : #159081# fixed buildid in oooimprovement
2009-01-22 22:51:16 +0100 b_michaelsen  r266759 : #i90370# including build id
2009-01-22 15:37:05 +0100 b_michaelsen  r266727 : #i90370# fixing precompiled headers for win32
2009-01-22 15:34:05 +0100 b_michaelsen  r266722 : #i90370# initializing startup counter
2009-01-22 15:30:52 +0100 b_michaelsen  r266720 : #i90370# enabling startup counter
2009-01-21 13:52:56 +0100 b_michaelsen  r266666 : #i98143# adjusted smoketest for usage tracking
2009-01-20 18:34:12 +0100 b_michaelsen  r266617 : #i90370#
2009-01-20 15:08:45 +0100 is  r266587 : #i90370# new improvement feature
2009-01-20 14:42:39 +0100 b_michaelsen  r266583 : #i90370# changing delivered job registration location
2009-01-20 12:35:31 +0100 is  r266567 : #i90370# new improvement feature
2009-01-20 12:33:51 +0100 is  r266566 : #i90370# new improvement feature
2009-01-20 12:33:20 +0100 is  r266565 : #i90370# new improvement feature
2009-01-20 11:47:13 +0100 b_michaelsen  r266559 : #i90370# updating Usage Tracking Info Url
2009-01-20 11:28:37 +0100 b_michaelsen  r266558 : #i90370# packing Usage Tracking config schema (xcs)
2009-01-20 11:19:00 +0100 b_michaelsen  r266557 : #i90370# adding Usage Tracking config schema (xcs)
2009-01-19 18:16:34 +0100 b_michaelsen  r266518 : #i90370# adding job registration (xcu)
2009-01-19 17:26:02 +0100 b_michaelsen  r266513 : #i90370# adding liboooimprovement
üst b0c0a556
......@@ -24,6 +24,7 @@ ex extensions\source\dbpilots nmake - all ex_dbpilots ex_i
ex extensions\source\abpilot nmake - all ex_abpilot ex_inc NULL
ex extensions\source\logging nmake - all ex_logging ex_inc NULL
ex extensions\source\oooimprovecore nmake - all ex_oooimprovecore ex_inc NULL
ex extensions\source\oooimprovement nmake - all ex_oooimprovement ex_inc NULL
ex extensions\source\preload nmake - all ex_preload ex_inc NULL
ex extensions\source\config\ldap nmake - all ex_ldap ex_inc NULL
ex extensions\source\nsplugin\source nmake - u ex_nsplugin ex_inc NULL
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE oor:component-data SYSTEM "../../../../component-update.dtd">
<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>
This diff is collapsed.
/*************************************************************************
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: config.hxx,v $
*
* $Revision: 1.3 $
*
* 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 getInvitationAccepted();
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 sal_Int32 getFailedAttempts();
const sal_Int32 getOfficeStartCounterdown();
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
/*************************************************************************
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: corecontroller.cxx,v $
*
* $Revision: 1.1 $
*
* 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<XComponentContext>& context)
: m_ServiceFactory(Reference<XMultiServiceFactory>(
context->getServiceManager()->createInstanceWithContext(
OUString::createFromAscii("com.sun.star.lang.XMultiServiceFactory"), context),
UNO_QUERY))
{ }
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.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.getShowedInvitation())
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<XComponentContext>& context)
{ return *(new CoreController(context)); }
Reference<XInterface> SAL_CALL CoreController::Create(const Reference<XMultiServiceFactory>& sm)
{ return *(new CoreController(sm)); }
}
/*************************************************************************
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: corecontroller.hxx,v $
*
* $Revision: 1.1 $
*
* 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
/*************************************************************************
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: errormail.cxx,v $
*
* $Revision: 1.3 $
*
* 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>
#ifdef UNIX
#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";
#else
return "Unknown";
#endif
};
#ifdef UNIX
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 =
"<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();
}
}
/*************************************************************************
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: errormail.hxx,v $
*
* $Revision: 1.1 $
*
* 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
/*************************************************************************
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: invite_job.cxx,v $
*
* $Revision: 1.3 $
*
* 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.XAsyncJob");
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)); }
}
/*************************************************************************
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: invite_job.hxx,v $
*
* $Revision: 1.1 $
*
* 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
/*************************************************************************
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: logpacker.cxx,v $
*
* $Revision: 1.1 $
*
* 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;
}
}
/*************************************************************************
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: logpacker.hxx,v $
*
* $Revision: 1.1 $
*
* 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
/*************************************************************************
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: logstorage.cxx,v $
*
* $Revision: 1.2 $
*
* 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); }
}
/*************************************************************************
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: logstorage.hxx,v $
*
* $Revision: 1.2 $
*
* 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
#*************************************************************************
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# Copyright 2008 by Sun Microsystems, Inc.
#
# OpenOffice.org - a multi-platform office productivity suite
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.6 $
#
# 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)
SHL1LIBS= $(SLB)$/$(TARGET).lib
SHL1DEF= $(MISC)$/$(SHL1TARGET).def
DEF1NAME= $(SHL1TARGET)
SHL1VERSIONMAP= oooimprovement.map
PACKAGEDIR=$(subst,.,$/ $(PACKAGE))
SPOOLDIR=$(MISC)$/registry$/spool
XCUFILES= \
Jobs.xcu
MYXCUFILES= \
$(SPOOLDIR)$/$(PACKAGEDIR)$/Jobs$/Jobs-oooimprovement.xcu
# --- Targets ---
.INCLUDE : target.mk
ALLTAR : $(MYXCUFILES)
XCU_SOURCEDIR:=.
$(SPOOLDIR)$/$(PACKAGEDIR)$/Jobs$/Jobs-oooimprovement.xcu : $(XCU_SOURCEDIR)$/Jobs.xcu
@-$(MKDIRHIER) $(@:d)
@$(COPY) $< $@
# 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
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: myconfigurationhelper.cxx,v $
* $Revision: 1.1 $
*
* 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);
}
Reference<XInterface> MyConfigurationHelper::makeSureSetNodeExists(
const Reference<XInterface> xCFG,
const OUString& sRelPathToSet,
const OUString& sSetNode)
{
Reference<css::container::XHierarchicalNameAccess> xAccess(xCFG, UNO_QUERY_THROW);
Reference<css::container::XNameAccess> xSet;
xAccess->getByHierarchicalName(sRelPathToSet) >>= xSet;
if (!xSet.is())
throw css::container::NoSuchElementException(
noSuchElement(sRelPathToSet),
Reference<XInterface>());
Reference<XInterface> xNode;
if (xSet->hasByName(sSetNode))
xSet->getByName(sSetNode) >>= xNode;
else
{
Reference<XSingleServiceFactory> xNodeFactory(xSet, UNO_QUERY_THROW);
xNode = xNodeFactory->createInstance();
Reference<css::container::XNameContainer> xSetReplace(xSet, UNO_QUERY_THROW);
xSetReplace->insertByName(sSetNode, makeAny(xNode));
}
return xNode;
}
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();
}
}
/*************************************************************************
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: onlogrotate_job.cxx,v $
*
* $Revision: 1.4 $
*
* 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 <osl/mutex.hxx>
#include <osl/thread.hxx>
#include <osl/time.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::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 disposing();
private:
Reference<XMultiServiceFactory> m_ServiceFactory;
::osl::Mutex m_ServiceFactoryMutex;
};
OnLogRotateThread::OnLogRotateThread(Reference<XMultiServiceFactory> sf)
: m_ServiceFactory(sf)
{ }
void SAL_CALL OnLogRotateThread::run()
{
{
::osl::Thread::yield();
TimeValue wait_intervall = {30,0};
osl_waitThread(&wait_intervall);
}
{
::osl::Guard< ::osl::Mutex> service_factory_guard(m_ServiceFactoryMutex);
if(m_ServiceFactory.is())
{
if(Config(m_ServiceFactory).getInvitationAccepted())
{
packLogs(m_ServiceFactory);
uploadLogs(m_ServiceFactory);
}
else
LogStorage(m_ServiceFactory).clear();
}
m_ServiceFactory.clear();
}
}
void OnLogRotateThread::disposing()
{
::osl::Guard< ::osl::Mutex> service_factory_guard(m_ServiceFactoryMutex);
m_ServiceFactory.clear();
}
}
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)
{
OnLogRotateThread* thread = new OnLogRotateThread(m_ServiceFactory);
thread->create();
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.XAsyncJob");
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)); }
}
/*************************************************************************
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: onlogrotate_job.hxx,v $
*
* $Revision: 1.1 $
*
* 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
UDK_3_0_0 {
global:
GetVersionInfo;
component_getImplementationEnvironment;
component_getFactory;
component_writeInfo;
local:
*;
};
/*************************************************************************
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: onlogrotate_job.cxx,v $
*
* $Revision: 1.4 $
*
* 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; }
sal_Bool SAL_CALL component_writeInfo(void*, void* p_reg_key)
{
if (!p_reg_key) return sal_False;
try
{
Reference<XRegistryKey> reg_key(reinterpret_cast<XRegistryKey*>(p_reg_key), UNO_QUERY);
writeInfo(reg_key,
CoreController::getImplementationName_static(),
CoreController::getSupportedServiceNames_static()[0]);
writeInfo(reg_key,
OnLogRotateJob::getImplementationName_static(),
OnLogRotateJob::getSupportedServiceNames_static()[0]);
writeInfo(reg_key,
InviteJob::getImplementationName_static(),
InviteJob::getSupportedServiceNames_static()[0]);
return sal_True;
}
catch(const InvalidRegistryException&)
{ OSL_ENSURE( sal_False, "### InvalidRegistryException!" ); }
return sal_False;
}
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();
}
}
/*************************************************************************
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: soaprequest.cxx,v $
*
* $Revision: 1.1 $
*
* 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 <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 getSoapSoapId(const OString& soap_id)
{
OStringBuffer buf =
"<body xsi:type=\"xsd:string\">" + xmlEncode(soap_id) + "</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(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);
}
}
/*************************************************************************
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: soaprequest.hxx,v $
*
* $Revision: 1.1 $
*
* 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
/*************************************************************************
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: soapsender.cxx,v $
*
* $Revision: 1.1 $
*
* 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>());
}
}
}
/*************************************************************************
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: soapsender.hxx,v $
*
* $Revision: 1.1 $
*
* 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
......@@ -189,6 +189,21 @@ destpath = "/opt"
packageversion = "%OOOPACKAGEVERSION"
End
Start
module = "gid_Module_Oooimprovement"
solarispackagename = "%BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-oooimprovement"
solarisrequires = "%BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core01"
packagename = "%BASISPACKAGEPREFIX%OOOBASEVERSION-oooimprovement"
freebsdrequires = "%BASISPACKAGEPREFIX%OOOBASEVERSION-core01"
requires = "%BASISPACKAGEPREFIX%OOOBASEVERSION-core01"
copyright = "1999-2009 by OpenOffice.org"
solariscopyright = "solariscopyrightfile"
vendor = "OpenOffice.org"
description = "Usage tracking module for OpenOffice.org %OOOBASEVERSION"
destpath = "/opt"
packageversion = "%OOOPACKAGEVERSION"
End
Start
module = "gid_Module_Optional_Testtool"
solarispackagename = "%BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-testtool"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment