1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <dp_services.hxx>
23 #include <rtl/strbuf.hxx>
24 #include <sal/log.hxx>
26 #include <osl/thread.h>
27 #include <cppuhelper/compbase.hxx>
28 #include <comphelper/anytostring.hxx>
29 #include <comphelper/servicedecl.hxx>
30 #include <comphelper/unwrapargs.hxx>
31 #include <comphelper/logging.hxx>
32 #include <com/sun/star/deployment/DeploymentException.hpp>
33 #include <com/sun/star/logging/LogLevel.hpp>
34 #include <com/sun/star/ucb/XProgressHandler.hpp>
35 #include <com/sun/star/ucb/SimpleFileAccess.hpp>
36 #include <com/sun/star/io/IOException.hpp>
37 #include <com/sun/star/io/XSeekable.hpp>
39 #include <boost/optional.hpp>
41 using namespace ::com::sun::star
;
42 using namespace ::com::sun::star::uno
;
43 using namespace ::com::sun::star::logging
;
47 typedef ::cppu::WeakComponentImplHelper
<ucb::XProgressHandler
> t_log_helper
;
50 class ProgressLogImpl
: public ::dp_misc::MutexHolder
, public t_log_helper
52 std::unique_ptr
<comphelper::EventLogger
> m_logger
;
55 virtual void SAL_CALL
disposing() override
;
56 virtual ~ProgressLogImpl() override
;
59 ProgressLogImpl( Sequence
<Any
> const & args
,
60 Reference
<XComponentContext
> const & xContext
);
63 virtual void SAL_CALL
push( Any
const & Status
) override
;
64 virtual void SAL_CALL
update( Any
const & Status
) override
;
65 virtual void SAL_CALL
pop() override
;
69 ProgressLogImpl::~ProgressLogImpl()
74 void ProgressLogImpl::disposing()
79 ProgressLogImpl::ProgressLogImpl(
80 Sequence
<Any
> const & /* args */,
81 Reference
<XComponentContext
> const & xContext
)
82 : t_log_helper( getMutex() )
84 // Use the logger created by unopkg app
85 m_logger
.reset(new comphelper::EventLogger(xContext
, "unopkg"));
90 void ProgressLogImpl::push( Any
const & Status
)
95 void ProgressLogImpl::update( Any
const & Status
)
97 if (! Status
.hasValue())
103 sal_Int32 logLevel
= LogLevel::INFO
;
104 if (Status
>>= msg
) {
108 logLevel
= LogLevel::SEVERE
;
109 buf
.append( ::comphelper::anyToString(Status
) );
111 m_logger
->log(logLevel
, buf
.makeStringAndClear());
115 void ProgressLogImpl::pop()
119 namespace sdecl
= comphelper::service_decl
;
120 sdecl::class_
<ProgressLogImpl
, sdecl::with_args
<true> > const servicePLI
;
121 sdecl::ServiceDecl
const serviceDecl(
124 "com.sun.star.comp.deployment.ProgressLog",
125 "com.sun.star.comp.deployment.ProgressLog" );
127 } // namespace dp_log
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */