os/persistentdata/traceservices/tracefw/ulogger/src/pluginframework/outputframework.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/traceservices/tracefw/ulogger/src/pluginframework/outputframework.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,84 @@
1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include "outputframework.h"
1.20 +#include "uloggeroutputplugin.h" // MOutputPlugin, ...
1.21 +
1.22 +
1.23 +namespace Ulogger
1.24 +{
1.25 +/** Static Factory Construction
1.26 +@param aOutputPlugin the output plugin reference. This plugin will be used to send data.
1.27 +@return a pointer to the created object
1.28 +@leave KErrNoMemory if not enough memory available
1.29 +*/
1.30 +EXPORT_C COutputFramework* COutputFramework::NewL(MOutputPlugin& aOutputPlugin, const RPointerArray<TPluginConfiguration>& aOutputSettings)
1.31 + {
1.32 + COutputFramework* me = new (ELeave) COutputFramework(aOutputPlugin);
1.33 + CleanupStack::PushL(me);
1.34 + me->ConstructL(aOutputSettings);
1.35 + CleanupStack::Pop();
1.36 + return me;
1.37 + }
1.38 +
1.39 +/**
1.40 +Public Destructor
1.41 +*/
1.42 +EXPORT_C COutputFramework::~COutputFramework()
1.43 + {
1.44 + iOutputPlugin.CloseOutputPlugin();
1.45 + iOutputSettings.ResetAndDestroy();
1.46 + iOutputSettings.Close();
1.47 + }
1.48 +
1.49 +/*!This function send data trough active output channel.
1.50 +@param aData reference to data
1.51 +@return KErrNone if successfull otherwise Symbian OS error code
1.52 +*/
1.53 +EXPORT_C TInt COutputFramework::SendData(const TDesC8& aData)
1.54 + {
1.55 + return iOutputPlugin.Write(aData);
1.56 + }
1.57 +
1.58 +//Default constructor
1.59 +COutputFramework::COutputFramework(MOutputPlugin& aOutputPlugin)
1.60 +: iOutputPlugin(aOutputPlugin)
1.61 + {
1.62 + }
1.63 +
1.64 +//Second stage constructL function
1.65 +//This will create a local mutex and initialize all the channels
1.66 +void COutputFramework::ConstructL(const RPointerArray<TPluginConfiguration>& aOutputSettings)
1.67 + {
1.68 + //copy settings
1.69 + for(TInt i=0; i<aOutputSettings.Count(); ++i)
1.70 + {
1.71 + TPluginConfiguration* pluginConfig = new TPluginConfiguration();
1.72 + pluginConfig->SetKey(aOutputSettings[i]->Key());
1.73 + pluginConfig->SetValue(aOutputSettings[i]->Value());
1.74 + iOutputSettings.AppendL(pluginConfig);
1.75 + }
1.76 +
1.77 + User::LeaveIfError(iOutputPlugin.ConfigureOutputPlugin(iOutputSettings));
1.78 + }
1.79 +
1.80 +/**Unconfigure active output channel and release all locked resources.
1.81 +*/
1.82 +EXPORT_C void COutputFramework::ReleaseOutputResources()
1.83 + {
1.84 + iOutputPlugin.CloseOutputPlugin();
1.85 + }
1.86 +
1.87 +} // namespace