|
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 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalComponent |
|
19 */ |
|
20 |
|
21 |
|
22 #ifndef CAGENTADAPTER_H |
|
23 #define CAGENTADAPTER_H |
|
24 |
|
25 |
|
26 #include <comms-infras/nifagt.h> |
|
27 #include <comms-infras/ss_nodemessages.h> //TStateChange |
|
28 #include <comms-infras/ss_nodemessages_legacy.h> |
|
29 #include <comms-infras/ss_nodemessages_legacy_internal.h> |
|
30 #include <comms-infras/ss_legacyinterfaces.h> |
|
31 #include <comms-infras/responsemsg.h> |
|
32 #include <comms-infras/nifprvar_internal.h> |
|
33 |
|
34 class CAgentSubConnectionProvider; |
|
35 class CNifAgentBase; |
|
36 class CAgentCprDataAccess; |
|
37 class CAgentAdapterSessionNotifier; |
|
38 |
|
39 namespace ESock |
|
40 { |
|
41 class MPlatsecApiExt; |
|
42 } |
|
43 |
|
44 /** |
|
45 This is the Agent Adapter for new style NIFs/SCPRs/CPRs |
|
46 It is created and owned by Link Layer MCPRs and passed to the left in |
|
47 the BindTo messages. It is controlled ONLY by the SCPR. |
|
48 |
|
49 @internalTechnology |
|
50 @prototype |
|
51 */ |
|
52 NONSHARABLE_CLASS(CAgentAdapter) : public CBase, private MNifAgentNotify, |
|
53 public ESock::MLinkCprServiceChangeNotificationApiExt |
|
54 { |
|
55 friend class CAgentCprDataAccess; |
|
56 friend class CAgentConnectionProvider; |
|
57 friend class CAgentAdapterSessionNotifier; |
|
58 |
|
59 public: |
|
60 enum TAgentState |
|
61 { |
|
62 EDisconnected, |
|
63 EConnecting, |
|
64 EConnected, |
|
65 EDisconnecting, |
|
66 EReconnecting |
|
67 }; |
|
68 |
|
69 static CAgentAdapter* NewL(CAgentSubConnectionProvider& aAgentScpr, const TDesC& aAgentName); |
|
70 ~CAgentAdapter(); |
|
71 |
|
72 void ConnectAgent(TAgentConnectType aConnectType); |
|
73 void DisconnectAgent(TInt aReason); |
|
74 void PromptForReconnect(); |
|
75 void Authenticate(TDes& aUsername, TDes& aPassword); |
|
76 void CancelAuthenticate(); |
|
77 |
|
78 // Database Access Methods |
|
79 TInt ReadNifName(TDes8& aNifName); |
|
80 TInt ReadPortName(TDes8& aPortName); |
|
81 TInt ReadIfParams(TDes8& aIfParams); |
|
82 TInt ReadIfNetworks(TDes8& aIfNetworks); |
|
83 |
|
84 TInt ReadNifName(TDes16& aNifName); |
|
85 TInt ReadPortName(TDes16& aPortName); |
|
86 TInt ReadIfParams(TDes16& aIfParams); |
|
87 TInt ReadIfNetworks(TDes16& aIfNetworks); |
|
88 |
|
89 TInt ReadExcessData(TDes8& aBuffer); |
|
90 TInt QueryIsDialIn(); |
|
91 |
|
92 TInt NotificationToAgent(TFlowToAgentEventType aEvent, TAny* aInfo); |
|
93 |
|
94 inline const TAgentState AgentState() const; |
|
95 |
|
96 TInt Control(TUint aOptionLevel, TUint aOptionName, TDes8& aOption, ESock::MPlatsecApiExt* aPlatsecItf); |
|
97 void ClientAttachControl(); |
|
98 |
|
99 // From MLinkCprServiceChangeNotificationApiExt Interface |
|
100 void RequestServiceChangeNotificationL(const Messages::TNodeId& aSender, ESock::RLegacyResponseMsg& aResponse); |
|
101 void CancelServiceChangeNotification(const Messages::TNodeId& aSender); |
|
102 |
|
103 #ifdef SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW |
|
104 inline CNifAgentBase * Agent() const; |
|
105 #endif //SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW |
|
106 |
|
107 protected: |
|
108 CAgentAdapter(CAgentSubConnectionProvider& aAgentScpr); |
|
109 inline CAgentSubConnectionProvider& AgentScpr() const; |
|
110 |
|
111 private: |
|
112 // MNifAgentNotify Interface |
|
113 virtual void ConnectComplete(TInt aStatus); |
|
114 virtual void ReconnectComplete(TInt aStatus); |
|
115 virtual void AuthenticateComplete(TInt aStatus); |
|
116 virtual void DisconnectComplete(); |
|
117 virtual void AgentProgress(TInt aStage, TInt aError); |
|
118 virtual TInt Notification(TAgentToNifEventType aEvent, TAny* aInfo = NULL); |
|
119 virtual void AgentEvent(TNetworkAdaptorEventType aEventType, TUint aEvent, const TDesC8& aEventData, TAny* aSource=0); |
|
120 virtual void ServiceStarted(); |
|
121 |
|
122 // MNifAgentNotify Interface (Empty implementations) |
|
123 virtual TInt IncomingConnectionReceived(); |
|
124 virtual void ServiceClosed(); |
|
125 virtual void AgentProgress(TSubConnectionUniqueId aSubConnectionUniqueId, TInt aStage, TInt aError); |
|
126 |
|
127 CNifFactory* FindOrCreateAgentFactoryL(const TDesC& aFilename); |
|
128 void CreateAgentL(const TDesC& aAgentName); |
|
129 |
|
130 private: |
|
131 CAgentSubConnectionProvider& iAgentScpr; |
|
132 CNifAgentBase* iAgent; |
|
133 CNifAgentFactory* iFactory; |
|
134 TAgentState iAgentState; |
|
135 TAgentConnectType iAgentConnectType; |
|
136 Elements::TStateChange iLastProgress; |
|
137 RPointerArray<CAgentAdapterSessionNotifier> iAgentAdapterSessionNotifiers; |
|
138 }; |
|
139 |
|
140 |
|
141 CAgentSubConnectionProvider& CAgentAdapter::AgentScpr() const |
|
142 { |
|
143 return iAgentScpr; |
|
144 } |
|
145 |
|
146 |
|
147 const CAgentAdapter::TAgentState CAgentAdapter::AgentState() const |
|
148 { |
|
149 return iAgentState; |
|
150 } |
|
151 |
|
152 #ifdef SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW |
|
153 /** |
|
154 * Returns the agent |
|
155 * @param none |
|
156 * @return Interface of the Nifman/Agent |
|
157 **/ |
|
158 CNifAgentBase *CAgentAdapter::Agent() const |
|
159 { |
|
160 return iAgent; |
|
161 } |
|
162 #endif //SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW |
|
163 |
|
164 /** |
|
165 * This class is an Adapter to allow CAgentBase to Notify for |
|
166 * ServiceChangeNotification post-399. |
|
167 * |
|
168 * @internalTechnology |
|
169 * @prototype */ |
|
170 NONSHARABLE_CLASS(CAgentAdapterSessionNotifier) : public CBase, |
|
171 public MAgentSessionNotify |
|
172 { |
|
173 private: |
|
174 // Phase #1 Constructor |
|
175 CAgentAdapterSessionNotifier (CAgentAdapter* aCreator, |
|
176 const Messages::TNodeId& aSender); |
|
177 |
|
178 // Phase #2 Constructor |
|
179 void ConstructL (ESock::RLegacyResponseMsg& aResponseMsg); |
|
180 public: |
|
181 // 2-Phase Static Constructor |
|
182 static CAgentAdapterSessionNotifier* NewL(CAgentAdapter* aCreator, |
|
183 const Messages::TNodeId& aSender, |
|
184 ESock::RLegacyResponseMsg& aResponseMsg); |
|
185 |
|
186 // 2-Phase Static Constructor. In this case it builds an "empty" Notifier. |
|
187 static CAgentAdapterSessionNotifier* NewL(CAgentAdapter* aCreator, |
|
188 const Messages::TNodeId& aSender); |
|
189 |
|
190 // Virtual Destructor |
|
191 virtual ~CAgentAdapterSessionNotifier(); |
|
192 |
|
193 // Operator to allow the usage of Find(...) inside a R(Pointer)Array container |
|
194 virtual TBool operator== (const CAgentAdapterSessionNotifier& aOtherInstanceOfThisClass) const; |
|
195 |
|
196 // Return an Id that identify this Agent Session |
|
197 virtual const Messages::TNodeId& NodeId() const; |
|
198 |
|
199 // Implementation of MAgentSessionNotify interface |
|
200 virtual void ServiceChangeNotification(TUint32 aId, const TDesC& aType); |
|
201 |
|
202 virtual void CancelServiceChangeNotification(TInt aReason = KErrCancel); |
|
203 |
|
204 private: |
|
205 /** This identify "who" asked for being notified. */ |
|
206 Messages::TNodeId iSender; |
|
207 /** The RResponseMsg to use to answer(notify) the request. */ |
|
208 ESock::RLegacyResponseMsg* iResponseMsg; |
|
209 /** The AgentAdapter which has created this object. |
|
210 * This Pointer allows this CAgentAdapterSessionNotifier to remove |
|
211 * itself from the Array in the Creator (Queue of S.C. Notifications) */ |
|
212 CAgentAdapter* iCreator; |
|
213 }; |
|
214 |
|
215 #endif |
|
216 // CAGENTADAPTER_H |
|
217 |