sl@0
|
1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include "outputframework.h"
|
sl@0
|
17 |
#include "uloggeroutputplugin.h" // MOutputPlugin, ...
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
namespace Ulogger
|
sl@0
|
21 |
{
|
sl@0
|
22 |
/** Static Factory Construction
|
sl@0
|
23 |
@param aOutputPlugin the output plugin reference. This plugin will be used to send data.
|
sl@0
|
24 |
@return a pointer to the created object
|
sl@0
|
25 |
@leave KErrNoMemory if not enough memory available
|
sl@0
|
26 |
*/
|
sl@0
|
27 |
EXPORT_C COutputFramework* COutputFramework::NewL(MOutputPlugin& aOutputPlugin, const RPointerArray<TPluginConfiguration>& aOutputSettings)
|
sl@0
|
28 |
{
|
sl@0
|
29 |
COutputFramework* me = new (ELeave) COutputFramework(aOutputPlugin);
|
sl@0
|
30 |
CleanupStack::PushL(me);
|
sl@0
|
31 |
me->ConstructL(aOutputSettings);
|
sl@0
|
32 |
CleanupStack::Pop();
|
sl@0
|
33 |
return me;
|
sl@0
|
34 |
}
|
sl@0
|
35 |
|
sl@0
|
36 |
/**
|
sl@0
|
37 |
Public Destructor
|
sl@0
|
38 |
*/
|
sl@0
|
39 |
EXPORT_C COutputFramework::~COutputFramework()
|
sl@0
|
40 |
{
|
sl@0
|
41 |
iOutputPlugin.CloseOutputPlugin();
|
sl@0
|
42 |
iOutputSettings.ResetAndDestroy();
|
sl@0
|
43 |
iOutputSettings.Close();
|
sl@0
|
44 |
}
|
sl@0
|
45 |
|
sl@0
|
46 |
/*!This function send data trough active output channel.
|
sl@0
|
47 |
@param aData reference to data
|
sl@0
|
48 |
@return KErrNone if successfull otherwise Symbian OS error code
|
sl@0
|
49 |
*/
|
sl@0
|
50 |
EXPORT_C TInt COutputFramework::SendData(const TDesC8& aData)
|
sl@0
|
51 |
{
|
sl@0
|
52 |
return iOutputPlugin.Write(aData);
|
sl@0
|
53 |
}
|
sl@0
|
54 |
|
sl@0
|
55 |
//Default constructor
|
sl@0
|
56 |
COutputFramework::COutputFramework(MOutputPlugin& aOutputPlugin)
|
sl@0
|
57 |
: iOutputPlugin(aOutputPlugin)
|
sl@0
|
58 |
{
|
sl@0
|
59 |
}
|
sl@0
|
60 |
|
sl@0
|
61 |
//Second stage constructL function
|
sl@0
|
62 |
//This will create a local mutex and initialize all the channels
|
sl@0
|
63 |
void COutputFramework::ConstructL(const RPointerArray<TPluginConfiguration>& aOutputSettings)
|
sl@0
|
64 |
{
|
sl@0
|
65 |
//copy settings
|
sl@0
|
66 |
for(TInt i=0; i<aOutputSettings.Count(); ++i)
|
sl@0
|
67 |
{
|
sl@0
|
68 |
TPluginConfiguration* pluginConfig = new TPluginConfiguration();
|
sl@0
|
69 |
pluginConfig->SetKey(aOutputSettings[i]->Key());
|
sl@0
|
70 |
pluginConfig->SetValue(aOutputSettings[i]->Value());
|
sl@0
|
71 |
iOutputSettings.AppendL(pluginConfig);
|
sl@0
|
72 |
}
|
sl@0
|
73 |
|
sl@0
|
74 |
User::LeaveIfError(iOutputPlugin.ConfigureOutputPlugin(iOutputSettings));
|
sl@0
|
75 |
}
|
sl@0
|
76 |
|
sl@0
|
77 |
/**Unconfigure active output channel and release all locked resources.
|
sl@0
|
78 |
*/
|
sl@0
|
79 |
EXPORT_C void COutputFramework::ReleaseOutputResources()
|
sl@0
|
80 |
{
|
sl@0
|
81 |
iOutputPlugin.CloseOutputPlugin();
|
sl@0
|
82 |
}
|
sl@0
|
83 |
|
sl@0
|
84 |
} // namespace
|