|
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file SS_PROTPROV.CPP |
|
18 */ |
|
19 |
|
20 #include "ss_protprov.h" |
|
21 #include <comms-infras/ss_log.h> |
|
22 #include <ss_glob.h> |
|
23 #include <comms-infras/ss_sapshim.h> |
|
24 #include "SS_rslv.H" |
|
25 #include <comms-infras/ss_roles.h> |
|
26 |
|
27 |
|
28 #ifdef _DEBUG |
|
29 // Panic category for "absolutely impossible!" vanilla ASSERT()-type panics from this module |
|
30 // (if it could happen through user error then you should give it an explicit, documented, category + code) |
|
31 _LIT(KSpecAssert_ESockSSocksprtpr, "ESockSSocksprtpr"); |
|
32 #endif |
|
33 |
|
34 using namespace ESock; |
|
35 |
|
36 CProtocolFamilyFactoryContainer* CProtocolFamilyFactoryContainer::NewL() |
|
37 /** Create a new instance of a protocol family factory container |
|
38 |
|
39 @exception Leaves in out of memory conditions |
|
40 @return Pointer to new instance of a protocol family factory container |
|
41 */ |
|
42 { |
|
43 return new (ELeave) CProtocolFamilyFactoryContainer(); |
|
44 } |
|
45 |
|
46 CProtocolFamilyFactoryContainer::CProtocolFamilyFactoryContainer() |
|
47 :CCommsFactoryContainer((CCommsFactoryContainer::TContaineeType)CProtocolFamilyFactoryContainer::EId) |
|
48 { |
|
49 LOG_NODE_CREATE(KESockDataFactTag, CProtocolFamilyFactoryContainer); |
|
50 } |
|
51 |
|
52 CProtocolFamilyFactoryContainer::~CProtocolFamilyFactoryContainer() |
|
53 { |
|
54 LOG_NODE_DESTROY(KESockDataFactTag, CProtocolFamilyFactoryContainer); |
|
55 } |
|
56 |
|
57 EXPORT_C CProtocolFamilyFactoryBase* CProtocolFamilyFactoryContainer::FindOrCreateL(const TDesC8& aName, TUid aFactoryId) |
|
58 /** Search for a protocol family factory based on the Factory ID |
|
59 |
|
60 @param aFactoryId Id of the factory to match against |
|
61 @see TProtocolFamilyImplementations |
|
62 @return Pointer to th protocol family factory with matching ID |
|
63 */ |
|
64 { |
|
65 LOG( ESockLog::Printf(_L("CProtocolFamilyFactoryContainer::FindOrCreateL() %08x:\tId=%d"), this, aFactoryId); ); |
|
66 CProtocolFamilyFactoryBase* pFactory = const_cast<CProtocolFamilyFactoryBase*>( |
|
67 static_cast<const CProtocolFamilyFactoryBase*> |
|
68 ((CCommsFactoryContainer::FindFactory(aFactoryId)))); |
|
69 return pFactory ? pFactory : CProtocolFamilyFactoryBase::NewL( aName, *this ); |
|
70 } |
|
71 |
|
72 CProtocolFamilyFactoryBase* CProtocolFamilyFactoryContainer::Get(TInt aIndex) const |
|
73 { |
|
74 return static_cast<CProtocolFamilyFactoryBase*>(Factory( aIndex )); |
|
75 } |
|
76 |
|
77 |
|
78 //========================================================== |
|
79 |
|
80 EXPORT_C CProtocolFamilyFactoryBase* CProtocolFamilyFactoryBase::NewL(const TDesC8& aName, CProtocolFamilyFactoryContainer& aParentContainer) |
|
81 /** Create a new instance of a protocol family Factory (Uses the base class |
|
82 that uses ECOM to load the DLL that implements the specialised protocol family factory |
|
83 @param aName Unique String Identifier of the desired factory implementation |
|
84 @param aParentContainer Container to add the factory to |
|
85 @return New instance of the factory |
|
86 @exception KErrNoMemory in out of memory conditions or KErrNotFound if the DLL cannot be found |
|
87 */ |
|
88 { |
|
89 const TUid requestedUid = { KProtocolFamilyInterfaceUid }; |
|
90 return static_cast<CProtocolFamilyFactoryBase*>(CCommsFactoryBase::NewL(aName, requestedUid, aParentContainer)); |
|
91 } |
|
92 |
|
93 |
|
94 EXPORT_C CProtocolFamilyFactoryBase::CProtocolFamilyFactoryBase(TUid aFactoryId, CProtocolFamilyFactoryContainer& aParentContainer) |
|
95 /** Sub-connection provider factory constructor |
|
96 |
|
97 @param aFactoryId Unique Integer Identifier of the factory |
|
98 @param aParentContainer Container to add the factory to |
|
99 */ |
|
100 : CCommsFactoryBase(aFactoryId, aParentContainer) |
|
101 { |
|
102 } |
|
103 |
|
104 EXPORT_C CProtocolBase* CProtocolFamilyFactoryBase::FindProtocol( TUint aProtocolId ) |
|
105 { |
|
106 TSglQueIter<CProtocolRef> i(*SockManGlobals::Get()->iProtocols); |
|
107 // Run the queue looking for a match. |
|
108 do |
|
109 { |
|
110 if(((CProtocolRef *)i)->Info().iProtocol == aProtocolId) |
|
111 { |
|
112 return ((CProtocolRef *)i)->Protocol(); |
|
113 } |
|
114 i++; |
|
115 } |
|
116 while((CProtocolRef *)i); |
|
117 return NULL; |
|
118 } |
|
119 |
|
120 EXPORT_C ACommsFactoryNodeId* CProtocolFamilyFactoryBase::DoCreateObjectL(TFactoryQueryBase& /* aQuery */) |
|
121 { |
|
122 __ASSERT_DEBUG(0, User::Panic(KSpecAssert_ESockSSocksprtpr, 1)); |
|
123 User::Leave(KErrNotSupported); |
|
124 return NULL; |
|
125 } |
|
126 |
|
127 |