1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3*cdf0e10cSrcweir * 4*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 5*cdf0e10cSrcweir * 6*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 7*cdf0e10cSrcweir * 8*cdf0e10cSrcweir * This file is part of OpenOffice.org. 9*cdf0e10cSrcweir * 10*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 11*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 12*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 13*cdf0e10cSrcweir * 14*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 15*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 16*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 18*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 19*cdf0e10cSrcweir * 20*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 21*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 22*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 23*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 24*cdf0e10cSrcweir * 25*cdf0e10cSrcweir ***********************************************************************/ 26*cdf0e10cSrcweir 27*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 28*cdf0e10cSrcweir #include "precompiled_comphelper.hxx" 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir #include <comphelper/uieventslogger.hxx> 31*cdf0e10cSrcweir #include <boost/shared_ptr.hpp> 32*cdf0e10cSrcweir #include <com/sun/star/frame/XDesktop.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/frame/XTerminateListener.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/lang/XEventListener.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiComponentFactory.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/logging/LogLevel.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/logging/XCsvLogFormatter.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/logging/XLogHandler.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/logging/XLogger.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/logging/XLoggerPool.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/oooimprovement/XCoreController.hpp> 43*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx> 44*cdf0e10cSrcweir #include <com/sun/star/util/XStringSubstitution.hpp> 45*cdf0e10cSrcweir #include <comphelper/configurationhelper.hxx> 46*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 47*cdf0e10cSrcweir #include <map> 48*cdf0e10cSrcweir #include <osl/file.hxx> 49*cdf0e10cSrcweir #include <osl/mutex.hxx> 50*cdf0e10cSrcweir #include <osl/time.h> 51*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir using namespace com::sun::star::beans; 55*cdf0e10cSrcweir using namespace com::sun::star::frame; 56*cdf0e10cSrcweir using namespace com::sun::star::lang; 57*cdf0e10cSrcweir using namespace com::sun::star::logging; 58*cdf0e10cSrcweir using namespace com::sun::star::oooimprovement; 59*cdf0e10cSrcweir using namespace com::sun::star::uno; 60*cdf0e10cSrcweir using namespace com::sun::star::util; 61*cdf0e10cSrcweir using namespace cppu; 62*cdf0e10cSrcweir using namespace osl; 63*cdf0e10cSrcweir using namespace rtl; 64*cdf0e10cSrcweir using namespace std; 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir namespace 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir static void lcl_SetupOriginAppAbbr(map<OUString, OUString>& abbrs) 70*cdf0e10cSrcweir { 71*cdf0e10cSrcweir abbrs[OUString::createFromAscii("com.sun.star.text.TextDocument")] = OUString::createFromAscii("W"); // Writer 72*cdf0e10cSrcweir abbrs[OUString::createFromAscii("com.sun.star.sheet.SpreadsheetDocument")] = OUString::createFromAscii("C"); // Calc 73*cdf0e10cSrcweir abbrs[OUString::createFromAscii("com.sun.star.presentation.PresentationDocument")] = OUString::createFromAscii("I"); // Impress 74*cdf0e10cSrcweir abbrs[OUString::createFromAscii("com.sun.star.drawing.DrawingDocument")] = OUString::createFromAscii("D"); // Draw 75*cdf0e10cSrcweir }; 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir static void lcl_SetupOriginWidgetAbbr(map<OUString,OUString>& abbrs) 78*cdf0e10cSrcweir { 79*cdf0e10cSrcweir abbrs[OUString::createFromAscii("ButtonToolbarController")] = OUString::createFromAscii("0"); 80*cdf0e10cSrcweir abbrs[OUString::createFromAscii("ComplexToolbarController")] = OUString::createFromAscii("1"); 81*cdf0e10cSrcweir abbrs[OUString::createFromAscii("ControlMenuController")] = OUString::createFromAscii("2"); 82*cdf0e10cSrcweir abbrs[OUString::createFromAscii("FontMenuController")] = OUString::createFromAscii("3"); 83*cdf0e10cSrcweir abbrs[OUString::createFromAscii("FontSizeMenuController")] = OUString::createFromAscii("4"); 84*cdf0e10cSrcweir abbrs[OUString::createFromAscii("FooterMenuController")] = OUString::createFromAscii("5"); 85*cdf0e10cSrcweir abbrs[OUString::createFromAscii("GenericToolbarController")] = OUString::createFromAscii("6"); 86*cdf0e10cSrcweir abbrs[OUString::createFromAscii("HeaderMenuController")] = OUString::createFromAscii("7"); 87*cdf0e10cSrcweir abbrs[OUString::createFromAscii("LanguageSelectionMenuController")] = OUString::createFromAscii("8"); 88*cdf0e10cSrcweir abbrs[OUString::createFromAscii("LangSelectionStatusbarController")] = OUString::createFromAscii("9"); 89*cdf0e10cSrcweir abbrs[OUString::createFromAscii("MacrosMenuController")] = OUString::createFromAscii("10"); 90*cdf0e10cSrcweir abbrs[OUString::createFromAscii("MenuBarManager")] = OUString::createFromAscii("11"); 91*cdf0e10cSrcweir abbrs[OUString::createFromAscii("NewMenuController")] = OUString::createFromAscii("12"); 92*cdf0e10cSrcweir abbrs[OUString::createFromAscii("ObjectMenuController")] = OUString::createFromAscii("13"); 93*cdf0e10cSrcweir abbrs[OUString::createFromAscii("RecentFilesMenuController")] = OUString::createFromAscii("14"); 94*cdf0e10cSrcweir abbrs[OUString::createFromAscii("ToolbarsMenuController")] = OUString::createFromAscii("15"); 95*cdf0e10cSrcweir abbrs[OUString::createFromAscii("SfxToolBoxControl")] = OUString::createFromAscii("16"); 96*cdf0e10cSrcweir abbrs[OUString::createFromAscii("SfxAsyncExec")] = OUString::createFromAscii("17"); 97*cdf0e10cSrcweir abbrs[OUString::createFromAscii("AcceleratorExecute")] = OUString::createFromAscii("18"); 98*cdf0e10cSrcweir }; 99*cdf0e10cSrcweir } 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir namespace comphelper 102*cdf0e10cSrcweir { 103*cdf0e10cSrcweir // declaration of implementation 104*cdf0e10cSrcweir class UiEventsLogger_Impl; 105*cdf0e10cSrcweir class UiEventsLogger_Impl : public UiEventsLogger 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir private: 108*cdf0e10cSrcweir //typedefs and friends 109*cdf0e10cSrcweir friend class UiEventsLogger; 110*cdf0e10cSrcweir typedef UiEventsLogger_Impl* ptr; 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir // instance methods and data 113*cdf0e10cSrcweir UiEventsLogger_Impl(); 114*cdf0e10cSrcweir void initializeLogger(); 115*cdf0e10cSrcweir void logDispatch(const ::com::sun::star::util::URL& url, 116*cdf0e10cSrcweir const Sequence<PropertyValue>& args); 117*cdf0e10cSrcweir void logRotated(); 118*cdf0e10cSrcweir void logVcl(const ::rtl::OUString& parent_id, 119*cdf0e10cSrcweir sal_Int32 window_type, 120*cdf0e10cSrcweir const ::rtl::OUString& id, 121*cdf0e10cSrcweir const ::rtl::OUString& method, 122*cdf0e10cSrcweir const ::rtl::OUString& param); 123*cdf0e10cSrcweir void rotate(); 124*cdf0e10cSrcweir void hotRotate(); 125*cdf0e10cSrcweir void prepareLogHandler(); 126*cdf0e10cSrcweir void checkIdleTimeout(); 127*cdf0e10cSrcweir OUString getCurrentPath(); 128*cdf0e10cSrcweir OUString getRotatedPath(); 129*cdf0e10cSrcweir void disposing(); 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir bool m_Active; 132*cdf0e10cSrcweir TimeValue m_LastLogEventTime; 133*cdf0e10cSrcweir const OUString m_LogPath; 134*cdf0e10cSrcweir const TimeValue m_IdleTimeout; 135*cdf0e10cSrcweir sal_Int32 m_SessionLogEventCount; 136*cdf0e10cSrcweir Reference<XLogger> m_Logger; 137*cdf0e10cSrcweir Reference<XLogHandler> m_LogHandler; 138*cdf0e10cSrcweir Reference<XCsvLogFormatter> m_Formatter; 139*cdf0e10cSrcweir map<OUString, OUString> m_OriginAppAbbr; 140*cdf0e10cSrcweir map<OUString, OUString> m_OriginWidgetAbbr; 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir // static methods and data 144*cdf0e10cSrcweir static ptr getInstance(); 145*cdf0e10cSrcweir static void prepareMutex(); 146*cdf0e10cSrcweir static bool shouldActivate(); 147*cdf0e10cSrcweir static bool getEnabledFromCoreController(); 148*cdf0e10cSrcweir static bool getEnabledFromCfg(); 149*cdf0e10cSrcweir static TimeValue getIdleTimeoutFromCfg(); 150*cdf0e10cSrcweir static OUString getLogPathFromCfg(); 151*cdf0e10cSrcweir static sal_Int32 findIdx(const Sequence<PropertyValue>& args, const OUString& key); 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir static ptr instance; 154*cdf0e10cSrcweir static Mutex * singleton_mutex; 155*cdf0e10cSrcweir static const sal_Int32 COLUMNS; 156*cdf0e10cSrcweir static const OUString CFG_ENABLED; 157*cdf0e10cSrcweir static const OUString CFG_IDLETIMEOUT; 158*cdf0e10cSrcweir static const OUString CFG_LOGGING; 159*cdf0e10cSrcweir static const OUString CFG_LOGPATH; 160*cdf0e10cSrcweir static const OUString CFG_OOOIMPROVEMENT; 161*cdf0e10cSrcweir static const OUString ETYPE_DISPATCH; 162*cdf0e10cSrcweir static const OUString ETYPE_ROTATED; 163*cdf0e10cSrcweir static const OUString ETYPE_VCL; 164*cdf0e10cSrcweir static const OUString CSSL_CSVFORMATTER; 165*cdf0e10cSrcweir static const OUString CSSL_FILEHANDLER; 166*cdf0e10cSrcweir static const OUString CSSL_LOGGERPOOL; 167*cdf0e10cSrcweir static const OUString CSSO_CORECONTROLLER; 168*cdf0e10cSrcweir static const OUString CSST_JOBEXECUTOR; 169*cdf0e10cSrcweir static const OUString CSSU_PATHSUB; 170*cdf0e10cSrcweir static const OUString LOGGERNAME; 171*cdf0e10cSrcweir static const OUString LOGORIGINAPP; 172*cdf0e10cSrcweir static const OUString LOGORIGINWIDGET; 173*cdf0e10cSrcweir static const OUString UNKNOWN_ORIGIN; 174*cdf0e10cSrcweir static const OUString FN_CURRENTLOG; 175*cdf0e10cSrcweir static const OUString FN_ROTATEDLOG; 176*cdf0e10cSrcweir static const OUString LOGROTATE_EVENTNAME; 177*cdf0e10cSrcweir static const OUString URL_UNO; 178*cdf0e10cSrcweir static const OUString URL_SPECIAL; 179*cdf0e10cSrcweir static const OUString URL_FILE; 180*cdf0e10cSrcweir }; 181*cdf0e10cSrcweir } 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir namespace comphelper 184*cdf0e10cSrcweir { 185*cdf0e10cSrcweir // consts 186*cdf0e10cSrcweir const sal_Int32 UiEventsLogger_Impl::COLUMNS = 9; 187*cdf0e10cSrcweir const OUString UiEventsLogger_Impl::CFG_ENABLED = OUString::createFromAscii("EnablingAllowed"); 188*cdf0e10cSrcweir const OUString UiEventsLogger_Impl::CFG_IDLETIMEOUT = OUString::createFromAscii("IdleTimeout"); 189*cdf0e10cSrcweir const OUString UiEventsLogger_Impl::CFG_LOGGING = OUString::createFromAscii("/org.openoffice.Office.Logging"); 190*cdf0e10cSrcweir const OUString UiEventsLogger_Impl::CFG_LOGPATH = OUString::createFromAscii("LogPath"); 191*cdf0e10cSrcweir const OUString UiEventsLogger_Impl::CFG_OOOIMPROVEMENT = OUString::createFromAscii("OOoImprovement"); 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir const OUString UiEventsLogger_Impl::CSSL_CSVFORMATTER = OUString::createFromAscii("com.sun.star.logging.CsvFormatter"); 194*cdf0e10cSrcweir const OUString UiEventsLogger_Impl::CSSL_FILEHANDLER = OUString::createFromAscii("com.sun.star.logging.FileHandler"); 195*cdf0e10cSrcweir const OUString UiEventsLogger_Impl::CSSL_LOGGERPOOL = OUString::createFromAscii("com.sun.star.logging.LoggerPool"); 196*cdf0e10cSrcweir const OUString UiEventsLogger_Impl::CSSO_CORECONTROLLER = OUString::createFromAscii("com.sun.star.oooimprovement.CoreController"); 197*cdf0e10cSrcweir const OUString UiEventsLogger_Impl::CSSU_PATHSUB = OUString::createFromAscii("com.sun.star.util.PathSubstitution"); 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir const OUString UiEventsLogger_Impl::ETYPE_DISPATCH = OUString::createFromAscii("dispatch"); 200*cdf0e10cSrcweir const OUString UiEventsLogger_Impl::ETYPE_ROTATED = OUString::createFromAscii("rotated"); 201*cdf0e10cSrcweir const OUString UiEventsLogger_Impl::ETYPE_VCL = OUString::createFromAscii("vcl"); 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir const OUString UiEventsLogger_Impl::LOGGERNAME = OUString::createFromAscii("org.openoffice.oooimprovement.Core.UiEventsLogger"); 204*cdf0e10cSrcweir const OUString UiEventsLogger_Impl::LOGORIGINWIDGET = OUString::createFromAscii("comphelper.UiEventsLogger.LogOriginWidget"); 205*cdf0e10cSrcweir const OUString UiEventsLogger_Impl::LOGORIGINAPP = OUString::createFromAscii("comphelper.UiEventsLogger.LogOriginApp"); 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir const OUString UiEventsLogger_Impl::UNKNOWN_ORIGIN = OUString::createFromAscii("unknown origin"); 208*cdf0e10cSrcweir const OUString UiEventsLogger_Impl::FN_CURRENTLOG = OUString::createFromAscii("Current"); 209*cdf0e10cSrcweir const OUString UiEventsLogger_Impl::FN_ROTATEDLOG = OUString::createFromAscii("OOoImprove"); 210*cdf0e10cSrcweir const OUString UiEventsLogger_Impl::LOGROTATE_EVENTNAME = OUString::createFromAscii("onOOoImprovementLogRotated"); 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir const OUString UiEventsLogger_Impl::URL_UNO = OUString::createFromAscii(".uno:"); 213*cdf0e10cSrcweir const OUString UiEventsLogger_Impl::URL_SPECIAL = OUString::createFromAscii(".special:"); 214*cdf0e10cSrcweir const OUString UiEventsLogger_Impl::URL_FILE = OUString::createFromAscii("file:"); 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir // public UiEventsLogger interface 218*cdf0e10cSrcweir sal_Bool UiEventsLogger::isEnabled() 219*cdf0e10cSrcweir { 220*cdf0e10cSrcweir if ( UiEventsLogger_Impl::getEnabledFromCfg() ) 221*cdf0e10cSrcweir { 222*cdf0e10cSrcweir try { 223*cdf0e10cSrcweir UiEventsLogger_Impl::prepareMutex(); 224*cdf0e10cSrcweir Guard<Mutex> singleton_guard(UiEventsLogger_Impl::singleton_mutex); 225*cdf0e10cSrcweir return UiEventsLogger_Impl::getInstance()->m_Active; 226*cdf0e10cSrcweir } catch(...) { return false; } // never throws 227*cdf0e10cSrcweir } // if ( ) 228*cdf0e10cSrcweir return sal_False; 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir sal_Int32 UiEventsLogger::getSessionLogEventCount() 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir try { 234*cdf0e10cSrcweir UiEventsLogger_Impl::prepareMutex(); 235*cdf0e10cSrcweir Guard<Mutex> singleton_guard(UiEventsLogger_Impl::singleton_mutex); 236*cdf0e10cSrcweir return UiEventsLogger_Impl::getInstance()->m_SessionLogEventCount; 237*cdf0e10cSrcweir } catch(...) { return 0; } // never throws 238*cdf0e10cSrcweir } 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir void UiEventsLogger::appendDispatchOrigin( 241*cdf0e10cSrcweir Sequence<PropertyValue>& args, 242*cdf0e10cSrcweir const OUString& originapp, 243*cdf0e10cSrcweir const OUString& originwidget) 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir sal_Int32 old_length = args.getLength(); 246*cdf0e10cSrcweir args.realloc(old_length+2); 247*cdf0e10cSrcweir args[old_length].Name = UiEventsLogger_Impl::LOGORIGINAPP; 248*cdf0e10cSrcweir args[old_length].Value = static_cast<Any>(originapp); 249*cdf0e10cSrcweir args[old_length+1].Name = UiEventsLogger_Impl::LOGORIGINWIDGET; 250*cdf0e10cSrcweir args[old_length+1].Value = static_cast<Any>(originwidget); 251*cdf0e10cSrcweir } 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir Sequence<PropertyValue> UiEventsLogger::purgeDispatchOrigin( 254*cdf0e10cSrcweir const Sequence<PropertyValue>& args) 255*cdf0e10cSrcweir { 256*cdf0e10cSrcweir Sequence<PropertyValue> result(args.getLength()); 257*cdf0e10cSrcweir sal_Int32 target_idx=0; 258*cdf0e10cSrcweir for(sal_Int32 source_idx=0; source_idx<args.getLength(); source_idx++) 259*cdf0e10cSrcweir if(args[source_idx].Name != UiEventsLogger_Impl::LOGORIGINAPP 260*cdf0e10cSrcweir && args[source_idx].Name != UiEventsLogger_Impl::LOGORIGINWIDGET) 261*cdf0e10cSrcweir result[target_idx++] = args[source_idx]; 262*cdf0e10cSrcweir result.realloc(target_idx); 263*cdf0e10cSrcweir return result; 264*cdf0e10cSrcweir } 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir void UiEventsLogger::logDispatch( 267*cdf0e10cSrcweir const URL& url, 268*cdf0e10cSrcweir const Sequence<PropertyValue>& args) 269*cdf0e10cSrcweir { 270*cdf0e10cSrcweir try { 271*cdf0e10cSrcweir UiEventsLogger_Impl::prepareMutex(); 272*cdf0e10cSrcweir Guard<Mutex> singleton_guard(UiEventsLogger_Impl::singleton_mutex); 273*cdf0e10cSrcweir UiEventsLogger_Impl::getInstance()->logDispatch(url, args); 274*cdf0e10cSrcweir } catch(...) { } // never throws 275*cdf0e10cSrcweir } 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir void UiEventsLogger::logVcl( 278*cdf0e10cSrcweir const OUString& parent_id, 279*cdf0e10cSrcweir sal_Int32 window_type, 280*cdf0e10cSrcweir const OUString& id, 281*cdf0e10cSrcweir const OUString& method, 282*cdf0e10cSrcweir const OUString& param) 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir try { 285*cdf0e10cSrcweir UiEventsLogger_Impl::prepareMutex(); 286*cdf0e10cSrcweir Guard<Mutex> singleton_guard(UiEventsLogger_Impl::singleton_mutex); 287*cdf0e10cSrcweir UiEventsLogger_Impl::getInstance()->logVcl(parent_id, window_type, id, method, param); 288*cdf0e10cSrcweir } catch(...) { } // never throws 289*cdf0e10cSrcweir } 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir void UiEventsLogger::logVcl( 292*cdf0e10cSrcweir const OUString& parent_id, 293*cdf0e10cSrcweir sal_Int32 window_type, 294*cdf0e10cSrcweir const OUString& id, 295*cdf0e10cSrcweir const OUString& method, 296*cdf0e10cSrcweir sal_Int32 param) 297*cdf0e10cSrcweir { 298*cdf0e10cSrcweir OUStringBuffer buf; 299*cdf0e10cSrcweir UiEventsLogger::logVcl(parent_id, window_type, id, method, buf.append(param).makeStringAndClear()); 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir void UiEventsLogger::logVcl( 303*cdf0e10cSrcweir const OUString& parent_id, 304*cdf0e10cSrcweir sal_Int32 window_type, 305*cdf0e10cSrcweir const OUString& id, 306*cdf0e10cSrcweir const OUString& method) 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir OUString empty; 309*cdf0e10cSrcweir UiEventsLogger::logVcl(parent_id, window_type, id, method, empty); 310*cdf0e10cSrcweir } 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir void UiEventsLogger::disposing() 313*cdf0e10cSrcweir { 314*cdf0e10cSrcweir // we dont want to create an instance just to dispose it 315*cdf0e10cSrcweir UiEventsLogger_Impl::prepareMutex(); 316*cdf0e10cSrcweir Guard<Mutex> singleton_guard(UiEventsLogger_Impl::singleton_mutex); 317*cdf0e10cSrcweir if(UiEventsLogger_Impl::instance!=UiEventsLogger_Impl::ptr()) 318*cdf0e10cSrcweir UiEventsLogger_Impl::getInstance()->disposing(); 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir void UiEventsLogger::reinit() 322*cdf0e10cSrcweir { 323*cdf0e10cSrcweir UiEventsLogger_Impl::prepareMutex(); 324*cdf0e10cSrcweir Guard<Mutex> singleton_guard(UiEventsLogger_Impl::singleton_mutex); 325*cdf0e10cSrcweir if(UiEventsLogger_Impl::instance) 326*cdf0e10cSrcweir { 327*cdf0e10cSrcweir UiEventsLogger_Impl::instance->disposing(); 328*cdf0e10cSrcweir delete UiEventsLogger_Impl::instance; 329*cdf0e10cSrcweir UiEventsLogger_Impl::instance = NULL; 330*cdf0e10cSrcweir } 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir // private UiEventsLogger_Impl methods 334*cdf0e10cSrcweir UiEventsLogger_Impl::UiEventsLogger_Impl() 335*cdf0e10cSrcweir : m_Active(UiEventsLogger_Impl::shouldActivate()) 336*cdf0e10cSrcweir , m_LogPath(UiEventsLogger_Impl::getLogPathFromCfg()) 337*cdf0e10cSrcweir , m_IdleTimeout(UiEventsLogger_Impl::getIdleTimeoutFromCfg()) 338*cdf0e10cSrcweir , m_SessionLogEventCount(0) 339*cdf0e10cSrcweir { 340*cdf0e10cSrcweir lcl_SetupOriginAppAbbr(m_OriginAppAbbr); 341*cdf0e10cSrcweir lcl_SetupOriginWidgetAbbr(m_OriginWidgetAbbr); 342*cdf0e10cSrcweir m_LastLogEventTime.Seconds = m_LastLogEventTime.Nanosec = 0; 343*cdf0e10cSrcweir if(m_Active) rotate(); 344*cdf0e10cSrcweir if(m_Active) initializeLogger(); 345*cdf0e10cSrcweir } 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir void UiEventsLogger_Impl::logDispatch( 348*cdf0e10cSrcweir const URL& url, 349*cdf0e10cSrcweir const Sequence<PropertyValue>& args) 350*cdf0e10cSrcweir { 351*cdf0e10cSrcweir if(!m_Active) return; 352*cdf0e10cSrcweir if(!url.Complete.match(URL_UNO) 353*cdf0e10cSrcweir && !url.Complete.match(URL_FILE) 354*cdf0e10cSrcweir && !url.Complete.match(URL_SPECIAL)) 355*cdf0e10cSrcweir { 356*cdf0e10cSrcweir return; 357*cdf0e10cSrcweir } 358*cdf0e10cSrcweir checkIdleTimeout(); 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir Sequence<OUString> logdata = Sequence<OUString>(COLUMNS); 361*cdf0e10cSrcweir logdata[0] = ETYPE_DISPATCH; 362*cdf0e10cSrcweir sal_Int32 originapp_idx = findIdx(args, LOGORIGINAPP); 363*cdf0e10cSrcweir if(originapp_idx!=-1) 364*cdf0e10cSrcweir { 365*cdf0e10cSrcweir OUString app; 366*cdf0e10cSrcweir args[originapp_idx].Value >>= app; 367*cdf0e10cSrcweir map<OUString, OUString>::iterator abbr_it = m_OriginAppAbbr.find(app); 368*cdf0e10cSrcweir if(abbr_it != m_OriginAppAbbr.end()) 369*cdf0e10cSrcweir app = abbr_it->second; 370*cdf0e10cSrcweir logdata[1] = app; 371*cdf0e10cSrcweir } 372*cdf0e10cSrcweir else 373*cdf0e10cSrcweir logdata[1] = UNKNOWN_ORIGIN; 374*cdf0e10cSrcweir sal_Int32 originwidget_idx = findIdx(args, LOGORIGINWIDGET); 375*cdf0e10cSrcweir if(originwidget_idx!=-1) 376*cdf0e10cSrcweir { 377*cdf0e10cSrcweir OUString widget; 378*cdf0e10cSrcweir args[originwidget_idx].Value >>= widget; 379*cdf0e10cSrcweir map<OUString, OUString>::iterator widget_it = m_OriginWidgetAbbr.find(widget); 380*cdf0e10cSrcweir if(widget_it != m_OriginWidgetAbbr.end()) 381*cdf0e10cSrcweir widget = widget_it->second; 382*cdf0e10cSrcweir logdata[2] = widget; 383*cdf0e10cSrcweir } 384*cdf0e10cSrcweir else 385*cdf0e10cSrcweir logdata[2] = UNKNOWN_ORIGIN; 386*cdf0e10cSrcweir if(url.Complete.match(URL_FILE)) 387*cdf0e10cSrcweir logdata[3] = URL_FILE; 388*cdf0e10cSrcweir else 389*cdf0e10cSrcweir logdata[3] = url.Main; 390*cdf0e10cSrcweir OSL_TRACE("UiEventsLogger Logging: %s,%s,%s,%s,%s,%s,%s,%s", 391*cdf0e10cSrcweir OUStringToOString(logdata[0],RTL_TEXTENCODING_UTF8).getStr(), 392*cdf0e10cSrcweir OUStringToOString(logdata[1],RTL_TEXTENCODING_UTF8).getStr(), 393*cdf0e10cSrcweir OUStringToOString(logdata[2],RTL_TEXTENCODING_UTF8).getStr(), 394*cdf0e10cSrcweir OUStringToOString(logdata[3],RTL_TEXTENCODING_UTF8).getStr(), 395*cdf0e10cSrcweir OUStringToOString(logdata[4],RTL_TEXTENCODING_UTF8).getStr(), 396*cdf0e10cSrcweir OUStringToOString(logdata[5],RTL_TEXTENCODING_UTF8).getStr(), 397*cdf0e10cSrcweir OUStringToOString(logdata[6],RTL_TEXTENCODING_UTF8).getStr(), 398*cdf0e10cSrcweir OUStringToOString(logdata[7],RTL_TEXTENCODING_UTF8).getStr(), 399*cdf0e10cSrcweir OUStringToOString(logdata[8],RTL_TEXTENCODING_UTF8).getStr()); 400*cdf0e10cSrcweir m_Logger->log(LogLevel::INFO, m_Formatter->formatMultiColumn(logdata)); 401*cdf0e10cSrcweir m_SessionLogEventCount++; 402*cdf0e10cSrcweir } 403*cdf0e10cSrcweir 404*cdf0e10cSrcweir void UiEventsLogger_Impl::logRotated() 405*cdf0e10cSrcweir { 406*cdf0e10cSrcweir Sequence<OUString> logdata = Sequence<OUString>(COLUMNS); 407*cdf0e10cSrcweir logdata[0] = ETYPE_ROTATED; 408*cdf0e10cSrcweir OSL_TRACE("UiEventsLogger Logging: %s,%s,%s,%s,%s,%s,%s,%s", 409*cdf0e10cSrcweir OUStringToOString(logdata[0],RTL_TEXTENCODING_UTF8).getStr(), 410*cdf0e10cSrcweir OUStringToOString(logdata[1],RTL_TEXTENCODING_UTF8).getStr(), 411*cdf0e10cSrcweir OUStringToOString(logdata[2],RTL_TEXTENCODING_UTF8).getStr(), 412*cdf0e10cSrcweir OUStringToOString(logdata[3],RTL_TEXTENCODING_UTF8).getStr(), 413*cdf0e10cSrcweir OUStringToOString(logdata[4],RTL_TEXTENCODING_UTF8).getStr(), 414*cdf0e10cSrcweir OUStringToOString(logdata[5],RTL_TEXTENCODING_UTF8).getStr(), 415*cdf0e10cSrcweir OUStringToOString(logdata[6],RTL_TEXTENCODING_UTF8).getStr(), 416*cdf0e10cSrcweir OUStringToOString(logdata[7],RTL_TEXTENCODING_UTF8).getStr(), 417*cdf0e10cSrcweir OUStringToOString(logdata[8],RTL_TEXTENCODING_UTF8).getStr()); 418*cdf0e10cSrcweir m_Logger->log(LogLevel::INFO, m_Formatter->formatMultiColumn(logdata)); 419*cdf0e10cSrcweir } 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir void UiEventsLogger_Impl::logVcl( 422*cdf0e10cSrcweir const OUString& parent_id, 423*cdf0e10cSrcweir sal_Int32 window_type, 424*cdf0e10cSrcweir const OUString& id, 425*cdf0e10cSrcweir const OUString& method, 426*cdf0e10cSrcweir const OUString& param) 427*cdf0e10cSrcweir { 428*cdf0e10cSrcweir if(!m_Active) return; 429*cdf0e10cSrcweir checkIdleTimeout(); 430*cdf0e10cSrcweir 431*cdf0e10cSrcweir OUStringBuffer buf; 432*cdf0e10cSrcweir Sequence<OUString> logdata = Sequence<OUString>(COLUMNS); 433*cdf0e10cSrcweir logdata[0] = ETYPE_VCL; 434*cdf0e10cSrcweir logdata[4] = parent_id; 435*cdf0e10cSrcweir logdata[5] = buf.append(window_type).makeStringAndClear(); 436*cdf0e10cSrcweir logdata[6] = id; 437*cdf0e10cSrcweir logdata[7] = method; 438*cdf0e10cSrcweir logdata[8] = param; 439*cdf0e10cSrcweir OSL_TRACE("UiEventsLogger Logging: %s,%s,%s,%s,%s,%s,%s,%s", 440*cdf0e10cSrcweir OUStringToOString(logdata[0],RTL_TEXTENCODING_UTF8).getStr(), 441*cdf0e10cSrcweir OUStringToOString(logdata[1],RTL_TEXTENCODING_UTF8).getStr(), 442*cdf0e10cSrcweir OUStringToOString(logdata[2],RTL_TEXTENCODING_UTF8).getStr(), 443*cdf0e10cSrcweir OUStringToOString(logdata[3],RTL_TEXTENCODING_UTF8).getStr(), 444*cdf0e10cSrcweir OUStringToOString(logdata[4],RTL_TEXTENCODING_UTF8).getStr(), 445*cdf0e10cSrcweir OUStringToOString(logdata[5],RTL_TEXTENCODING_UTF8).getStr(), 446*cdf0e10cSrcweir OUStringToOString(logdata[6],RTL_TEXTENCODING_UTF8).getStr(), 447*cdf0e10cSrcweir OUStringToOString(logdata[7],RTL_TEXTENCODING_UTF8).getStr(), 448*cdf0e10cSrcweir OUStringToOString(logdata[8],RTL_TEXTENCODING_UTF8).getStr()); 449*cdf0e10cSrcweir m_Logger->log(LogLevel::INFO, m_Formatter->formatMultiColumn(logdata)); 450*cdf0e10cSrcweir m_SessionLogEventCount++; 451*cdf0e10cSrcweir } 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir void UiEventsLogger_Impl::rotate() 454*cdf0e10cSrcweir { 455*cdf0e10cSrcweir FileBase::RC result = File::move(getCurrentPath(), getRotatedPath()); 456*cdf0e10cSrcweir if(result!=FileBase::E_None && result!=FileBase::E_NOENT) 457*cdf0e10cSrcweir m_Active = false; 458*cdf0e10cSrcweir } 459*cdf0e10cSrcweir 460*cdf0e10cSrcweir void UiEventsLogger_Impl::hotRotate() 461*cdf0e10cSrcweir { 462*cdf0e10cSrcweir logRotated(); 463*cdf0e10cSrcweir m_Logger->removeLogHandler(m_LogHandler); 464*cdf0e10cSrcweir m_LogHandler = NULL; 465*cdf0e10cSrcweir rotate(); 466*cdf0e10cSrcweir prepareLogHandler(); 467*cdf0e10cSrcweir if(m_Formatter.is() && m_LogHandler.is() && m_Logger.is()) 468*cdf0e10cSrcweir { 469*cdf0e10cSrcweir m_LogHandler->setFormatter(Reference<XLogFormatter>(m_Formatter, UNO_QUERY)); 470*cdf0e10cSrcweir m_LogHandler->setLevel(LogLevel::ALL); 471*cdf0e10cSrcweir m_Logger->addLogHandler(m_LogHandler); 472*cdf0e10cSrcweir } 473*cdf0e10cSrcweir else 474*cdf0e10cSrcweir m_Active = false; 475*cdf0e10cSrcweir } 476*cdf0e10cSrcweir 477*cdf0e10cSrcweir void UiEventsLogger_Impl::prepareLogHandler() 478*cdf0e10cSrcweir { 479*cdf0e10cSrcweir Reference<XMultiServiceFactory> sm = getProcessServiceFactory(); 480*cdf0e10cSrcweir 481*cdf0e10cSrcweir Sequence<Any> init_args = Sequence<Any>(1); 482*cdf0e10cSrcweir init_args[0] = static_cast<Any>(getCurrentPath()); 483*cdf0e10cSrcweir Reference< XInterface > temp = 484*cdf0e10cSrcweir sm->createInstanceWithArguments(CSSL_FILEHANDLER, init_args); 485*cdf0e10cSrcweir m_LogHandler = Reference<XLogHandler>(temp, UNO_QUERY); 486*cdf0e10cSrcweir } 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir void UiEventsLogger_Impl::checkIdleTimeout() 489*cdf0e10cSrcweir { 490*cdf0e10cSrcweir TimeValue now; 491*cdf0e10cSrcweir osl_getSystemTime(&now); 492*cdf0e10cSrcweir if(now.Seconds - m_LastLogEventTime.Seconds > m_IdleTimeout.Seconds && m_SessionLogEventCount>0) 493*cdf0e10cSrcweir hotRotate(); 494*cdf0e10cSrcweir m_LastLogEventTime = now; 495*cdf0e10cSrcweir } 496*cdf0e10cSrcweir 497*cdf0e10cSrcweir OUString UiEventsLogger_Impl::getCurrentPath() 498*cdf0e10cSrcweir { 499*cdf0e10cSrcweir OUStringBuffer current_path(m_LogPath); 500*cdf0e10cSrcweir current_path.appendAscii("/"); 501*cdf0e10cSrcweir current_path.append(FN_CURRENTLOG); 502*cdf0e10cSrcweir current_path.appendAscii(".csv"); 503*cdf0e10cSrcweir return current_path.makeStringAndClear(); 504*cdf0e10cSrcweir } 505*cdf0e10cSrcweir 506*cdf0e10cSrcweir OUString UiEventsLogger_Impl::getRotatedPath() 507*cdf0e10cSrcweir { 508*cdf0e10cSrcweir OUStringBuffer rotated_path(m_LogPath); 509*cdf0e10cSrcweir rotated_path.appendAscii("/"); 510*cdf0e10cSrcweir rotated_path.append(FN_ROTATEDLOG); 511*cdf0e10cSrcweir rotated_path.appendAscii("-"); 512*cdf0e10cSrcweir { 513*cdf0e10cSrcweir // ISO 8601 514*cdf0e10cSrcweir char tsrotated_pathfer[20]; 515*cdf0e10cSrcweir oslDateTime now; 516*cdf0e10cSrcweir TimeValue now_tv; 517*cdf0e10cSrcweir osl_getSystemTime(&now_tv); 518*cdf0e10cSrcweir osl_getDateTimeFromTimeValue(&now_tv, &now); 519*cdf0e10cSrcweir const size_t rotated_pathfer_size = sizeof(tsrotated_pathfer); 520*cdf0e10cSrcweir snprintf(tsrotated_pathfer, rotated_pathfer_size, "%04i-%02i-%02iT%02i_%02i_%02i", 521*cdf0e10cSrcweir now.Year, 522*cdf0e10cSrcweir now.Month, 523*cdf0e10cSrcweir now.Day, 524*cdf0e10cSrcweir now.Hours, 525*cdf0e10cSrcweir now.Minutes, 526*cdf0e10cSrcweir now.Seconds); 527*cdf0e10cSrcweir rotated_path.appendAscii(tsrotated_pathfer); 528*cdf0e10cSrcweir rotated_path.appendAscii(".csv"); 529*cdf0e10cSrcweir } 530*cdf0e10cSrcweir return rotated_path.makeStringAndClear(); 531*cdf0e10cSrcweir } 532*cdf0e10cSrcweir 533*cdf0e10cSrcweir void UiEventsLogger_Impl::initializeLogger() 534*cdf0e10cSrcweir { 535*cdf0e10cSrcweir Reference<XMultiServiceFactory> sm = getProcessServiceFactory(); 536*cdf0e10cSrcweir 537*cdf0e10cSrcweir // getting the Core Uno proxy object 538*cdf0e10cSrcweir // It will call disposing and make sure we clear all our references 539*cdf0e10cSrcweir { 540*cdf0e10cSrcweir Reference<XTerminateListener> xCore( 541*cdf0e10cSrcweir sm->createInstance(OUString::createFromAscii("com.sun.star.oooimprovement.Core")), 542*cdf0e10cSrcweir UNO_QUERY); 543*cdf0e10cSrcweir Reference<XDesktop> xDesktop( 544*cdf0e10cSrcweir sm->createInstance(OUString::createFromAscii("com.sun.star.frame.Desktop")), 545*cdf0e10cSrcweir UNO_QUERY); 546*cdf0e10cSrcweir if(!(xCore.is() && xDesktop.is())) 547*cdf0e10cSrcweir { 548*cdf0e10cSrcweir m_Active = false; 549*cdf0e10cSrcweir return; 550*cdf0e10cSrcweir } 551*cdf0e10cSrcweir xDesktop->addTerminateListener(xCore); 552*cdf0e10cSrcweir } 553*cdf0e10cSrcweir // getting the LoggerPool 554*cdf0e10cSrcweir Reference<XLoggerPool> pool; 555*cdf0e10cSrcweir { 556*cdf0e10cSrcweir Reference<XInterface> temp = 557*cdf0e10cSrcweir sm->createInstance(CSSL_LOGGERPOOL); 558*cdf0e10cSrcweir pool = Reference<XLoggerPool>(temp, UNO_QUERY); 559*cdf0e10cSrcweir } 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir // getting the Logger 562*cdf0e10cSrcweir m_Logger = pool->getNamedLogger(LOGGERNAME); 563*cdf0e10cSrcweir 564*cdf0e10cSrcweir // getting the FileHandler 565*cdf0e10cSrcweir prepareLogHandler(); 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir // getting the Formatter 568*cdf0e10cSrcweir { 569*cdf0e10cSrcweir Reference<XInterface> temp = 570*cdf0e10cSrcweir sm->createInstance(CSSL_CSVFORMATTER); 571*cdf0e10cSrcweir m_Formatter = Reference<XCsvLogFormatter>(temp, UNO_QUERY); 572*cdf0e10cSrcweir } 573*cdf0e10cSrcweir 574*cdf0e10cSrcweir if(m_Formatter.is() && m_LogHandler.is() && m_Logger.is()) 575*cdf0e10cSrcweir { 576*cdf0e10cSrcweir Sequence<OUString> columns = Sequence<OUString>(COLUMNS); 577*cdf0e10cSrcweir columns[0] = OUString::createFromAscii("eventtype"); 578*cdf0e10cSrcweir columns[1] = OUString::createFromAscii("originapp"); 579*cdf0e10cSrcweir columns[2] = OUString::createFromAscii("originwidget"); 580*cdf0e10cSrcweir columns[3] = OUString::createFromAscii("uno url"); 581*cdf0e10cSrcweir columns[4] = OUString::createFromAscii("parent id"); 582*cdf0e10cSrcweir columns[5] = OUString::createFromAscii("window type"); 583*cdf0e10cSrcweir columns[6] = OUString::createFromAscii("id"); 584*cdf0e10cSrcweir columns[7] = OUString::createFromAscii("method"); 585*cdf0e10cSrcweir columns[8] = OUString::createFromAscii("parameter"); 586*cdf0e10cSrcweir m_Formatter->setColumnnames(columns); 587*cdf0e10cSrcweir m_LogHandler->setFormatter(Reference<XLogFormatter>(m_Formatter, UNO_QUERY)); 588*cdf0e10cSrcweir m_Logger->setLevel(LogLevel::ALL); 589*cdf0e10cSrcweir m_LogHandler->setLevel(LogLevel::ALL); 590*cdf0e10cSrcweir m_Logger->addLogHandler(m_LogHandler); 591*cdf0e10cSrcweir } 592*cdf0e10cSrcweir else 593*cdf0e10cSrcweir m_Active = false; 594*cdf0e10cSrcweir } 595*cdf0e10cSrcweir 596*cdf0e10cSrcweir // private static UiEventsLogger_Impl 597*cdf0e10cSrcweir bool UiEventsLogger_Impl::shouldActivate() 598*cdf0e10cSrcweir { 599*cdf0e10cSrcweir return getEnabledFromCfg() && getEnabledFromCoreController(); 600*cdf0e10cSrcweir } 601*cdf0e10cSrcweir 602*cdf0e10cSrcweir OUString UiEventsLogger_Impl::getLogPathFromCfg() 603*cdf0e10cSrcweir { 604*cdf0e10cSrcweir OUString result; 605*cdf0e10cSrcweir Reference<XMultiServiceFactory> sm = getProcessServiceFactory(); 606*cdf0e10cSrcweir 607*cdf0e10cSrcweir ConfigurationHelper::readDirectKey( 608*cdf0e10cSrcweir sm, 609*cdf0e10cSrcweir CFG_LOGGING, CFG_OOOIMPROVEMENT, CFG_LOGPATH, 610*cdf0e10cSrcweir ConfigurationHelper::E_READONLY 611*cdf0e10cSrcweir ) >>= result; 612*cdf0e10cSrcweir 613*cdf0e10cSrcweir Reference<XStringSubstitution> path_sub( 614*cdf0e10cSrcweir sm->createInstance(CSSU_PATHSUB), 615*cdf0e10cSrcweir UNO_QUERY); 616*cdf0e10cSrcweir if(path_sub.is()) 617*cdf0e10cSrcweir result = path_sub->substituteVariables(result, sal_False); 618*cdf0e10cSrcweir return result; 619*cdf0e10cSrcweir } 620*cdf0e10cSrcweir 621*cdf0e10cSrcweir TimeValue UiEventsLogger_Impl::getIdleTimeoutFromCfg() 622*cdf0e10cSrcweir { 623*cdf0e10cSrcweir sal_Int32 timeoutminutes = 360; 624*cdf0e10cSrcweir Reference<XMultiServiceFactory> sm = getProcessServiceFactory(); 625*cdf0e10cSrcweir 626*cdf0e10cSrcweir ConfigurationHelper::readDirectKey( 627*cdf0e10cSrcweir sm, 628*cdf0e10cSrcweir CFG_LOGGING, CFG_OOOIMPROVEMENT, CFG_IDLETIMEOUT, 629*cdf0e10cSrcweir ConfigurationHelper::E_READONLY 630*cdf0e10cSrcweir ) >>= timeoutminutes; 631*cdf0e10cSrcweir TimeValue result; 632*cdf0e10cSrcweir result.Seconds = static_cast<sal_uInt32>(timeoutminutes)*60; 633*cdf0e10cSrcweir result.Nanosec = 0; 634*cdf0e10cSrcweir return result; 635*cdf0e10cSrcweir } 636*cdf0e10cSrcweir 637*cdf0e10cSrcweir bool UiEventsLogger_Impl::getEnabledFromCfg() 638*cdf0e10cSrcweir { 639*cdf0e10cSrcweir sal_Bool result = false; 640*cdf0e10cSrcweir Reference<XMultiServiceFactory> sm = getProcessServiceFactory(); 641*cdf0e10cSrcweir ConfigurationHelper::readDirectKey( 642*cdf0e10cSrcweir sm, 643*cdf0e10cSrcweir CFG_LOGGING, CFG_OOOIMPROVEMENT, CFG_ENABLED, 644*cdf0e10cSrcweir ::comphelper::ConfigurationHelper::E_READONLY 645*cdf0e10cSrcweir ) >>= result; 646*cdf0e10cSrcweir return result; 647*cdf0e10cSrcweir } 648*cdf0e10cSrcweir 649*cdf0e10cSrcweir bool UiEventsLogger_Impl::getEnabledFromCoreController() 650*cdf0e10cSrcweir { 651*cdf0e10cSrcweir Reference<XMultiServiceFactory> sm = getProcessServiceFactory(); 652*cdf0e10cSrcweir Reference<XCoreController> core_c( 653*cdf0e10cSrcweir sm->createInstance(OUString::createFromAscii("com.sun.star.oooimprovement.CoreController")), 654*cdf0e10cSrcweir UNO_QUERY); 655*cdf0e10cSrcweir if(!core_c.is()) return false; 656*cdf0e10cSrcweir return core_c->enablingUiEventsLoggerAllowed(1); 657*cdf0e10cSrcweir } 658*cdf0e10cSrcweir 659*cdf0e10cSrcweir UiEventsLogger_Impl::ptr UiEventsLogger_Impl::instance = UiEventsLogger_Impl::ptr(); 660*cdf0e10cSrcweir UiEventsLogger_Impl::ptr UiEventsLogger_Impl::getInstance() 661*cdf0e10cSrcweir { 662*cdf0e10cSrcweir if(instance == NULL) 663*cdf0e10cSrcweir instance = UiEventsLogger_Impl::ptr(new UiEventsLogger_Impl()); 664*cdf0e10cSrcweir return instance; 665*cdf0e10cSrcweir } 666*cdf0e10cSrcweir 667*cdf0e10cSrcweir Mutex * UiEventsLogger_Impl::singleton_mutex = NULL; 668*cdf0e10cSrcweir void UiEventsLogger_Impl::prepareMutex() 669*cdf0e10cSrcweir { 670*cdf0e10cSrcweir if(singleton_mutex == NULL) 671*cdf0e10cSrcweir { 672*cdf0e10cSrcweir Guard<Mutex> global_guard(Mutex::getGlobalMutex()); 673*cdf0e10cSrcweir if(singleton_mutex == NULL) 674*cdf0e10cSrcweir singleton_mutex = new Mutex(); 675*cdf0e10cSrcweir } 676*cdf0e10cSrcweir } 677*cdf0e10cSrcweir 678*cdf0e10cSrcweir sal_Int32 UiEventsLogger_Impl::findIdx(const Sequence<PropertyValue>& args, const OUString& key) 679*cdf0e10cSrcweir { 680*cdf0e10cSrcweir for(sal_Int32 i=0; i<args.getLength(); i++) 681*cdf0e10cSrcweir if(args[i].Name == key) 682*cdf0e10cSrcweir return i; 683*cdf0e10cSrcweir return -1; 684*cdf0e10cSrcweir } 685*cdf0e10cSrcweir 686*cdf0e10cSrcweir void UiEventsLogger_Impl::disposing() 687*cdf0e10cSrcweir { 688*cdf0e10cSrcweir m_Active = false; 689*cdf0e10cSrcweir m_Logger.clear() ; 690*cdf0e10cSrcweir m_LogHandler.clear(); 691*cdf0e10cSrcweir m_Formatter.clear(); 692*cdf0e10cSrcweir } 693*cdf0e10cSrcweir } 694