|
1 // Copyright (c) 2006-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 // IPProto Connection Provider factory class definition. |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 */ |
|
22 |
|
23 #include "ItfInfoConfigExt.h" |
|
24 #include "IPProtoCPRFactory.h" |
|
25 #include "IPProtoCPR.h" |
|
26 #include <in_sock.h> |
|
27 #include <elements/nm_interfaces.h> |
|
28 |
|
29 #include <comms-infras/ss_legacyinterfaces.h> |
|
30 #include <comms-infras/ss_msgintercept.h> |
|
31 |
|
32 using namespace Messages; |
|
33 using namespace ESock; |
|
34 using namespace Factories; |
|
35 |
|
36 //-========================================================= |
|
37 // |
|
38 // CIPProtoConnectionProviderFactory methods |
|
39 // |
|
40 //-========================================================= |
|
41 CIPProtoConnectionProviderFactory* CIPProtoConnectionProviderFactory::NewL(TAny* aParentContainer) |
|
42 { |
|
43 return new (ELeave) CIPProtoConnectionProviderFactory(TUid::Uid(CIPProtoConnectionProviderFactory::iUid), *reinterpret_cast<ESock::CConnectionFactoryContainer*>(aParentContainer)); |
|
44 } |
|
45 |
|
46 CIPProtoConnectionProviderFactory::CIPProtoConnectionProviderFactory(TUid aFactoryId, ESock::CConnectionFactoryContainer& aParentContainer) |
|
47 : ESock::CConnectionProviderFactoryBase(aFactoryId, aParentContainer), |
|
48 TIfStaticFetcherNearestInHierarchy(this) |
|
49 { |
|
50 } |
|
51 |
|
52 class TEnumerateConnectionsQuery : public MFactoryQuery |
|
53 { |
|
54 public: |
|
55 TEnumerateConnectionsQuery(RPointerArray<TSourcedConnectionInfo>& aConnectionInfoPtrArray) |
|
56 :iConnectionInfoPtrArray(aConnectionInfoPtrArray) |
|
57 {} |
|
58 |
|
59 virtual TMatchResult Match(TFactoryObjectInfo& aObjectInfo); |
|
60 inline TInt Error() {return iError;} |
|
61 private: |
|
62 RPointerArray<TSourcedConnectionInfo>& iConnectionInfoPtrArray; |
|
63 TInt iError; |
|
64 }; |
|
65 |
|
66 MFactoryQuery::TMatchResult TEnumerateConnectionsQuery::Match(TFactoryObjectInfo& aObjectInfo) |
|
67 { |
|
68 //This is a legacy feature |
|
69 CIPProtoConnectionProvider* prov = static_cast<CIPProtoConnectionProvider*>(aObjectInfo.iInfo.iFactoryObject); |
|
70 iError = KErrNone; |
|
71 if (prov) |
|
72 { |
|
73 RNodeInterface* dc = prov->GetFirstClient<TDefaultClientMatchPolicy>(TClientType(TCFClientType::EData, TCFClientType::EDefault)); |
|
74 if (dc && /*dc->Flags() & RNodeInterface::EStarted &&*/ |
|
75 !(dc->Flags() & TClientType::ELeaving)) |
|
76 { |
|
77 const TItfInfoConfigExt* ext = static_cast<const TItfInfoConfigExt*>(prov->AccessPointConfig().FindExtension(STypeId::CreateSTypeId(KIpProtoConfigExtUid, EItfInfoConfigExt))); |
|
78 ASSERT(ext); |
|
79 if (ext) |
|
80 { |
|
81 TSourcedConnectionInfo* copy; |
|
82 copy = new ESock::TSourcedConnectionInfo(ext->iConnectionInfo.iIapId, ext->iConnectionInfo.iNetId, EConnectionGeneric, prov->Id()); |
|
83 if(copy == NULL) |
|
84 { |
|
85 iError = KErrNoMemory; |
|
86 return MFactoryQuery::ECancel; |
|
87 } |
|
88 |
|
89 TInt err = iConnectionInfoPtrArray.Append(copy); |
|
90 if(err != KErrNone) |
|
91 { |
|
92 delete copy; |
|
93 iError = err; |
|
94 return MFactoryQuery::ECancel; |
|
95 } |
|
96 } |
|
97 } |
|
98 } |
|
99 return MFactoryQuery::EContinue; |
|
100 } |
|
101 |
|
102 void CIPProtoConnectionProviderFactory::EnumerateConnectionsL(RPointerArray<ESock::TSourcedConnectionInfo>& aConnectionInfoPtrArray) |
|
103 { |
|
104 TEnumerateConnectionsQuery query(aConnectionInfoPtrArray); |
|
105 Find(query); |
|
106 User::LeaveIfError(query.Error()); |
|
107 } |
|
108 |
|
109 void CIPProtoConnectionProviderFactory::ReturnInterfacePtrL(ESock::MLinkCprFactApiExt*& aInterface) |
|
110 { |
|
111 aInterface = this; |
|
112 } |
|
113 |
|
114 NetInterfaces::TInterfaceControl* CIPProtoConnectionProviderFactory::DoFetchInterfaceControlL(TSupportedCommsApiExt aInterfaceId) |
|
115 { |
|
116 ASSERT(aInterfaceId == ESock::MLinkCprFactApiExt::KInterfaceId); |
|
117 (void)aInterfaceId; |
|
118 return this; |
|
119 } |
|
120 |
|
121 ESock::ACommsFactoryNodeId* CIPProtoConnectionProviderFactory::DoCreateObjectL(ESock::TFactoryQueryBase& /* aQuery */) |
|
122 { |
|
123 CConnectionProviderBase* provider = CIPProtoConnectionProvider::NewL(*this); |
|
124 |
|
125 ESOCK_DEBUG_REGISTER_GENERAL_NODE(iUid, provider); |
|
126 |
|
127 return provider; |
|
128 } |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |