|
1 // Copyright (c) 2005-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 #include <comms-infras/ss_mcprnodemessages.h> |
|
17 #include <comms-infras/ss_mmcommsprov.h> |
|
18 #include <comms-infras/ss_protflow.h> |
|
19 #include <comms-infras/ss_subconnflow.h> |
|
20 #include "SS_conn.H" |
|
21 #include <comms-infras/ss_log.h> |
|
22 #include <ss_glob.h> |
|
23 #include <ecom/ecom.h> |
|
24 |
|
25 |
|
26 #ifdef _DEBUG |
|
27 // Panic category for "absolutely impossible!" vanilla ASSERT()-type panics from this module |
|
28 // (if it could happen through user error then you should give it an explicit, documented, category + code) |
|
29 _LIT(KSpecAssert_ESockSSocks_prt2, "ESockSSocks_prt2"); |
|
30 #endif |
|
31 |
|
32 using namespace ESock; |
|
33 using namespace Factories; |
|
34 using namespace Messages; |
|
35 |
|
36 CProtocolIntfFactoryContainer::CProtocolIntfFactoryContainer() |
|
37 :CCommsFactoryContainer((CCommsFactoryContainer::TContaineeType)CProtocolIntfFactoryContainer::EId) |
|
38 { |
|
39 LOG_NODE_CREATE(KESockDataFactTag, CProtocolIntfFactoryContainer); |
|
40 } |
|
41 |
|
42 CProtocolIntfFactoryContainer::~CProtocolIntfFactoryContainer() |
|
43 { |
|
44 LOG_NODE_DESTROY(KESockDataFactTag, CProtocolIntfFactoryContainer); |
|
45 } |
|
46 |
|
47 CProtocolIntfFactoryContainer* CProtocolIntfFactoryContainer::NewL() |
|
48 /** Create a new instance of a sub-connection factory container |
|
49 |
|
50 @exception Leaves in out of memory conditions |
|
51 @return Pointer to new instance of a sub-connection factory container |
|
52 */ |
|
53 { |
|
54 return new (ELeave) CProtocolIntfFactoryContainer(); |
|
55 } |
|
56 |
|
57 |
|
58 EXPORT_C CProtocolIntfFactoryBase* CProtocolIntfFactoryContainer::FindOrCreateFactoryL(TUid aFactoryUid) |
|
59 { |
|
60 CProtocolIntfFactoryBase* factory = static_cast<CProtocolIntfFactoryBase*>(FindFactory(aFactoryUid)); |
|
61 if (NULL==factory) |
|
62 { |
|
63 CSubConnectionFlowFactoryBase* flowFactory = static_cast <CSubConnectionFlowFactoryBase* > (SockManGlobals::Get()->iSubConnectionFlowFactories->FindOrCreateFactoryL(aFactoryUid)); |
|
64 if (NULL==flowFactory) |
|
65 { |
|
66 User::Leave(KErrNotFound); |
|
67 } |
|
68 factory = flowFactory->CreateProtocolIntfFactoryL(*this); |
|
69 } |
|
70 __ASSERT_DEBUG(factory, User::Panic(KSpecAssert_ESockSSocks_prt2, 1)); |
|
71 return static_cast<CProtocolIntfFactoryBase*>(factory); |
|
72 } |
|
73 |
|
74 EXPORT_C CProtocolIntfBase* CProtocolIntfFactoryContainer::FindOrCreateProtocolIntfL( TUid aFactoryId, TFactoryQueryBase& aQuery) |
|
75 /** |
|
76 @internalTechnology |
|
77 @released Since 9.2 */ |
|
78 { |
|
79 CProtocolIntfFactoryBase* factory = CProtocolIntfFactoryContainer::FindOrCreateFactoryL(aFactoryId); |
|
80 __ASSERT_DEBUG(factory, User::Panic(KSpecAssert_ESockSSocks_prt2, 2)); |
|
81 return static_cast<CProtocolIntfBase*>(factory->FindOrCreateProtocolIntfL( aQuery )); |
|
82 } |
|
83 |
|
84 |
|
85 EXPORT_C CProtocolIntfFactoryBase::CProtocolIntfFactoryBase(TUid aFactoryId, CProtocolIntfFactoryContainer& aParentContainer) |
|
86 /** Sub-connection flow factory constructor |
|
87 |
|
88 @param aFactoryId Unique Integer Identifier of the sub-connection provider factory |
|
89 @param aParentContainer Container to add the factory to */ |
|
90 : CFactoryBase(aFactoryId, aParentContainer) |
|
91 { |
|
92 } |
|
93 |
|
94 EXPORT_C CProtocolIntfBase* CProtocolIntfFactoryBase::FindOrCreateProtocolIntfL(TFactoryQueryBase& aQuery) |
|
95 { |
|
96 CProtocolIntfBase* prov = FindProtocolIntf(aQuery); |
|
97 return prov ? prov : CreateProtocolIntfL(aQuery); |
|
98 } |
|
99 |
|
100 EXPORT_C CProtocolIntfBase* CProtocolIntfFactoryBase::FindProtocolIntf(TFactoryQueryBase& aQuery) |
|
101 { |
|
102 return static_cast<CProtocolIntfBase*>(FindObject(aQuery)); |
|
103 } |
|
104 |
|
105 EXPORT_C CProtocolIntfBase* CProtocolIntfFactoryBase::CreateProtocolIntfL(TFactoryQueryBase& aQuery) |
|
106 { |
|
107 //at this point we are either: |
|
108 //1. Given aSubConnectionProviderBase => control side initialised sub-connection<->flow creation |
|
109 //2. aSubConnectionProviderBase == NULL => data side initialised sub-connection<->flow creation for |
|
110 // implicit connection |
|
111 //in all other cases we should find a proper sub-connection flow already created |
|
112 CProtocolIntfBase* pintf = DoCreateProtocolIntfL(aQuery); |
|
113 LOG( ESockLog::Printf(KESockDataFactTag, _L8("CProtocolIntfFactoryBase %08x:\t\tCreateProtocolIntfL(): pintf %08x"), this, pintf) ); |
|
114 CleanupStack::PushL(pintf); |
|
115 AddManagedObjectL(*pintf); |
|
116 CleanupStack::Pop(pintf); |
|
117 return pintf; |
|
118 } |
|
119 |
|
120 EXPORT_C CProtocolIntfBase::CProtocolIntfBase(CProtocolIntfFactoryBase& aFactory,const Messages::TNodeId& aCprId) |
|
121 : AFactoryObject(aFactory), |
|
122 iCprId(aCprId) |
|
123 { |
|
124 } |
|
125 |
|
126 EXPORT_C CProtocolIntfBase::~CProtocolIntfBase() |
|
127 { |
|
128 // All Flows must have been deleted as it is last Flow deleted causes |
|
129 // the ProtocolIntf to be deleted. |
|
130 __ASSERT_DEBUG(iFlowCount == 0, User::Panic(KSpecAssert_ESockSSocks_prt2, 3)); |
|
131 } |
|
132 |
|
133 |
|
134 TBool CProtocolIntfBase::FlowBeingDeleted(CSubConnectionFlowBase& aFlow) |
|
135 /** |
|
136 Called when one of the Flows associated with this ProtocolIntf is being |
|
137 deleted. Called from the context of the Flow. |
|
138 |
|
139 @return ETrue if this is the last Flow on this ProtocolIntf and the intf deletes itslef, else EFalse. |
|
140 */ |
|
141 { |
|
142 __ASSERT_DEBUG(iFlowCount > 0, User::Panic(KSpecAssert_ESockSSocks_prt2, 4)); |
|
143 DoFlowBeingDeleted(aFlow); |
|
144 TBool b = --iFlowCount == 0; |
|
145 if (b) |
|
146 { |
|
147 DeleteMeNow(); |
|
148 } |
|
149 return b; |
|
150 } |
|
151 |
|
152 void CProtocolIntfBase::FlowCreated(CSubConnectionFlowBase& aFlow) |
|
153 { |
|
154 __ASSERT_DEBUG(iFlowCount >= 0, User::Panic(KSpecAssert_ESockSSocks_prt2, 5)); |
|
155 DoFlowCreated(aFlow); |
|
156 ++iFlowCount; |
|
157 } |
|
158 |
|
159 |