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 |
|
sl@0
|
17 |
#include "pluginallocator.h"
|
sl@0
|
18 |
#include "uloggeroutputplugin.h"
|
sl@0
|
19 |
#include <e32cmn.h>
|
sl@0
|
20 |
#include <ecom/ecom.h>
|
sl@0
|
21 |
|
sl@0
|
22 |
namespace Ulogger
|
sl@0
|
23 |
{
|
sl@0
|
24 |
|
sl@0
|
25 |
/*!Default constructor.
|
sl@0
|
26 |
*/
|
sl@0
|
27 |
CPluginAllocator::CPluginAllocator()
|
sl@0
|
28 |
{
|
sl@0
|
29 |
iOutputPluginBase = NULL;
|
sl@0
|
30 |
iInputPluginBase = NULL;
|
sl@0
|
31 |
}
|
sl@0
|
32 |
|
sl@0
|
33 |
|
sl@0
|
34 |
/*!Destructor.
|
sl@0
|
35 |
*/
|
sl@0
|
36 |
EXPORT_C CPluginAllocator::~CPluginAllocator()
|
sl@0
|
37 |
{
|
sl@0
|
38 |
if(iOutputPluginBase)
|
sl@0
|
39 |
{
|
sl@0
|
40 |
delete iOutputPluginBase;
|
sl@0
|
41 |
iOutputPluginBase = NULL;
|
sl@0
|
42 |
}
|
sl@0
|
43 |
iOutputLib.Close();
|
sl@0
|
44 |
|
sl@0
|
45 |
if((iOutputLibName.Compare(iInputLibName)!=0) && iInputPluginBase)
|
sl@0
|
46 |
{
|
sl@0
|
47 |
delete iInputPluginBase;
|
sl@0
|
48 |
iInputPluginBase = NULL;
|
sl@0
|
49 |
}
|
sl@0
|
50 |
iInputLib.Close();
|
sl@0
|
51 |
|
sl@0
|
52 |
REComSession::FinalClose();
|
sl@0
|
53 |
}
|
sl@0
|
54 |
|
sl@0
|
55 |
|
sl@0
|
56 |
/*!Standard Symbian OS construction method which leaves object on CleanupStack.
|
sl@0
|
57 |
*/
|
sl@0
|
58 |
EXPORT_C CPluginAllocator* CPluginAllocator::NewLC(const TPtrC8& aOutputPluginName, const TPtrC8& aInputPluginName)
|
sl@0
|
59 |
{
|
sl@0
|
60 |
CPluginAllocator* obj = new (ELeave) CPluginAllocator();
|
sl@0
|
61 |
CleanupStack::PushL(obj);
|
sl@0
|
62 |
obj->ConstructL(aOutputPluginName, aInputPluginName);
|
sl@0
|
63 |
return obj;
|
sl@0
|
64 |
}
|
sl@0
|
65 |
|
sl@0
|
66 |
|
sl@0
|
67 |
/*!Standard Symbian OS construction method which does not leaves object on CleanupStack.
|
sl@0
|
68 |
*/
|
sl@0
|
69 |
EXPORT_C CPluginAllocator* CPluginAllocator::NewL(const TPtrC8& aOutputPluginName, const TPtrC8& aInputPluginName)
|
sl@0
|
70 |
{
|
sl@0
|
71 |
CPluginAllocator* obj = CPluginAllocator::NewLC(aOutputPluginName, aInputPluginName);
|
sl@0
|
72 |
CleanupStack::Pop(); //obj
|
sl@0
|
73 |
return obj;
|
sl@0
|
74 |
}
|
sl@0
|
75 |
|
sl@0
|
76 |
|
sl@0
|
77 |
/*!Standard Symbian OS construction method.
|
sl@0
|
78 |
*/
|
sl@0
|
79 |
EXPORT_C void CPluginAllocator::ConstructL(const TPtrC8& aOutputPluginName, const TPtrC8& aInputPluginName)
|
sl@0
|
80 |
{
|
sl@0
|
81 |
//create output and control channels
|
sl@0
|
82 |
User::LeaveIfError(this->CreateChannelsL(aOutputPluginName, aInputPluginName));
|
sl@0
|
83 |
}
|
sl@0
|
84 |
|
sl@0
|
85 |
/*!This function create Output channel according to aOutputSettings.
|
sl@0
|
86 |
*/
|
sl@0
|
87 |
TInt CPluginAllocator::CreateChannelsL(const TPtrC8& aOutputPluginName, const TPtrC8& aInputPluginName)
|
sl@0
|
88 |
{
|
sl@0
|
89 |
TInt retVal = KErrNone;
|
sl@0
|
90 |
|
sl@0
|
91 |
iOutputLibName.Copy(aOutputPluginName);
|
sl@0
|
92 |
iInputLibName.Copy(aInputPluginName);
|
sl@0
|
93 |
|
sl@0
|
94 |
//create output plugin
|
sl@0
|
95 |
iOutputPluginBase = (CPlugin*)(CPlugin::NewL(aOutputPluginName));
|
sl@0
|
96 |
|
sl@0
|
97 |
//create control plugin
|
sl@0
|
98 |
if(iOutputLibName.Compare(iInputLibName) == 0)
|
sl@0
|
99 |
{
|
sl@0
|
100 |
//share implementation
|
sl@0
|
101 |
if(aInputPluginName.Length()>0)
|
sl@0
|
102 |
iInputPluginBase = iOutputPluginBase;
|
sl@0
|
103 |
}
|
sl@0
|
104 |
else
|
sl@0
|
105 |
{
|
sl@0
|
106 |
//create new instance of control plugin
|
sl@0
|
107 |
//ulogger can work without control plugin as this is optional functionality
|
sl@0
|
108 |
if(aInputPluginName.Length()>0)
|
sl@0
|
109 |
iInputPluginBase = (CPlugin*)(CPlugin::NewL(aInputPluginName));
|
sl@0
|
110 |
}
|
sl@0
|
111 |
|
sl@0
|
112 |
return retVal;
|
sl@0
|
113 |
}
|
sl@0
|
114 |
|
sl@0
|
115 |
|
sl@0
|
116 |
EXPORT_C MOutputPlugin* CPluginAllocator::GetOutputPlugin()
|
sl@0
|
117 |
{
|
sl@0
|
118 |
if(iOutputPluginBase)
|
sl@0
|
119 |
return (MOutputPlugin*)iOutputPluginBase->GetInterfaceL(MOutputPlugin::iInterfaceId);
|
sl@0
|
120 |
else
|
sl@0
|
121 |
return NULL;
|
sl@0
|
122 |
}
|
sl@0
|
123 |
|
sl@0
|
124 |
EXPORT_C MInputPlugin* CPluginAllocator::GetInputPlugin()
|
sl@0
|
125 |
{
|
sl@0
|
126 |
if(iInputPluginBase)
|
sl@0
|
127 |
return (MInputPlugin*)iInputPluginBase->GetInterfaceL(MInputPlugin::iInterfaceId);
|
sl@0
|
128 |
else
|
sl@0
|
129 |
return NULL;
|
sl@0
|
130 |
}
|
sl@0
|
131 |
|
sl@0
|
132 |
EXPORT_C void CPluginAllocator::ListAllImplementationsL(RImplInfoPtrArray& aImplInfoArray)
|
sl@0
|
133 |
{
|
sl@0
|
134 |
REComSession::ListImplementationsL(KCPluginUid, aImplInfoArray);
|
sl@0
|
135 |
}
|
sl@0
|
136 |
|
sl@0
|
137 |
} //</namespace Ulogger>
|