|
1 // Copyright (c) 1999-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 // Declares CWapSmsProtocolFamily, CWapSmsProtocol, |
|
15 // CWapSmsProviderWrite and CWapSmsProvider |
|
16 // |
|
17 // |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalAll |
|
22 */ |
|
23 |
|
24 #ifndef WS_MAIN_H__ |
|
25 #define WS_MAIN_H__ |
|
26 |
|
27 #include <f32file.h> |
|
28 #include "es_wsms.h" |
|
29 #include <es_sock.h> |
|
30 #include <es_prot.h> |
|
31 #include <es_mbufif.h> |
|
32 #include "smsstacklog.h" |
|
33 #include <e32cmn.h> |
|
34 |
|
35 #include "nbbackuprestoreint.h" |
|
36 |
|
37 /** |
|
38 * @internalComponent |
|
39 */ |
|
40 const TUint KWapSmsMajorVersionNumber=7; |
|
41 const TUint KWapSmsMinorVersionNumber=0; |
|
42 const TUint KWapSmsBuildVersionNumber=0; |
|
43 |
|
44 |
|
45 class CWapSapMessageSender; |
|
46 class CWapProtocolObserver; |
|
47 class CSmsProtocol; |
|
48 class CSmsMessage; |
|
49 class CWapSmsProviderWrite; |
|
50 class CBackupAndRestore; |
|
51 |
|
52 |
|
53 /** |
|
54 * @internalComponent |
|
55 */ |
|
56 class CWapSmsProtocolFamily : public CProtocolFamilyBase |
|
57 { |
|
58 private: |
|
59 CWapSmsProtocolFamily(); |
|
60 public: |
|
61 static CWapSmsProtocolFamily * NewL(); |
|
62 TInt Install(); |
|
63 TInt Remove(); |
|
64 CProtocolBase * NewProtocolL(TUint aSockType,TUint aProtocol); |
|
65 TUint ProtocolList(TServerProtocolDesc *& aProtocolList); |
|
66 }; |
|
67 |
|
68 /** |
|
69 * @internalComponent |
|
70 */ |
|
71 extern "C" |
|
72 { |
|
73 IMPORT_C CProtocolFamilyBase* InstallWapSms(); // Force export |
|
74 } |
|
75 |
|
76 class CWapSmsProvider; |
|
77 class CWapDatagram; |
|
78 class CWapReassemblyStore; |
|
79 |
|
80 |
|
81 /** |
|
82 * @internalComponent |
|
83 */ |
|
84 class CWapSmsProtocol : public CProtocolBase, |
|
85 public MNBBackupAndRestoreObserver |
|
86 { |
|
87 public: |
|
88 virtual ~CWapSmsProtocol(); |
|
89 static CWapSmsProtocol *NewL(); |
|
90 |
|
91 // Calls from the socket server which we implement |
|
92 CServProviderBase *NewSAPL(TUint aSocketType); |
|
93 void InitL(TDesC& aTag); |
|
94 void StartL(void); |
|
95 void Identify(TServerProtocolDesc *)const; |
|
96 |
|
97 virtual CHostResolvProvdBase *NewHostResolverL(); |
|
98 virtual CServiceResolvProvdBase *NewServiceResolverL(); |
|
99 virtual CNetDBProvdBase* NewNetDatabaseL(); |
|
100 |
|
101 void BindL(CProtocolBase *aProtocol, TUint aId); |
|
102 virtual void BindToL(CProtocolBase *protocol); |
|
103 TInt Send(TDes8 &, TSockAddr *to,TSockAddr *from,CProtocolBase* aSourceProtocol); |
|
104 TInt GetOption(TUint aLevel,TUint aName,TDes8 &aOption,CProtocolBase* aSourceProtocol); |
|
105 TInt SetOption(TUint aLevel,TUint aName,const TDesC8 &aOption,CProtocolBase* aSourceProtocol); |
|
106 void Error(TInt aError,CProtocolBase* aSourceProtocol); |
|
107 public: |
|
108 void ProcessSmsL(const CSmsMessage& aSmsMessage); |
|
109 CSmsProtocol* SmsProtocol(); |
|
110 TInt AddrAlreadyUsedByWAP(const TWapAddr& aAddr, const CWapSmsProvider* aSap); |
|
111 TBool AllocateLocalAddress(TWapAddr& aAddr); |
|
112 TBool FindAndDeleteMsg(CWapDatagram& aDatagram); |
|
113 TInt CheckSarL(const TWapAddr& aAddr,CWapSmsProvider* aSap); |
|
114 private: |
|
115 CWapSmsProtocol(); |
|
116 void BindObserversToSmsL(); |
|
117 void RemoveObserversFromSmsProtocol(); |
|
118 void AddSAP(CWapSmsProvider* aSAP, TUint aSockType); |
|
119 CWapSmsProvider* LookupSAP(CWapDatagram* aMsg); |
|
120 |
|
121 virtual void HandleBackupOrRestoreStartingL(); |
|
122 virtual void HandleBackupOrRestoreCompleteL(); |
|
123 |
|
124 private: |
|
125 |
|
126 RFs iFs; |
|
127 CWapReassemblyStore* iWapStore; |
|
128 TDblQue<CWapSmsProvider> iSAPList; |
|
129 CSmsProtocol* iSmsProtocol; |
|
130 CWapProtocolObserver* iObserver[3]; |
|
131 TInt iNextSapPort; |
|
132 |
|
133 CBackupAndRestore* iBackupRestoreSession; |
|
134 }; |
|
135 |
|
136 |
|
137 /** |
|
138 * @internalComponent |
|
139 */ |
|
140 class CWapSmsProviderWrite : public CActive |
|
141 { |
|
142 public: |
|
143 |
|
144 static CWapSmsProviderWrite* NewL(CWapSmsProvider& aWapSmsProvider); |
|
145 ~CWapSmsProviderWrite(); |
|
146 void Start(RMBufChain& aBufChain, TSockAddr& aAddr); |
|
147 |
|
148 private: |
|
149 CWapSmsProviderWrite(CWapSmsProvider& aWapSmsProvider); |
|
150 void RunL(); |
|
151 void DoCancel(); |
|
152 TInt RunError(TInt aError); |
|
153 private: |
|
154 |
|
155 CWapSmsProvider& iWapSmsProvider; |
|
156 TWapAddr iWapAddr; |
|
157 |
|
158 HBufC8* iDes; |
|
159 CWapSapMessageSender* iMsgSender; |
|
160 }; |
|
161 |
|
162 |
|
163 /** |
|
164 * @internalComponent |
|
165 */ |
|
166 class CWapSmsProvider : public CServProviderBase |
|
167 { |
|
168 |
|
169 friend class CWapSmsProviderWrite; |
|
170 |
|
171 public: |
|
172 |
|
173 enum TWapSmsMessageType |
|
174 { |
|
175 ESmartMessage, |
|
176 EWapDatagram |
|
177 }; |
|
178 |
|
179 public: |
|
180 static CWapSmsProvider* NewL(CWapSmsProtocol* aProtocol); |
|
181 virtual ~CWapSmsProvider(); |
|
182 |
|
183 public: |
|
184 void Start(); |
|
185 public: // Not Implemented |
|
186 void RemName(TSockAddr& /*aAddr*/)const{BULLSEYE_OFF BULLSEYE_RESTORE} |
|
187 TInt SetRemName(TSockAddr& /*aAddr*/){BULLSEYE_OFF return KErrNotSupported; BULLSEYE_RESTORE} |
|
188 void ActiveOpen() {BULLSEYE_OFF BULLSEYE_RESTORE} |
|
189 void ActiveOpen(const TDesC8& /*aConnectionData*/){BULLSEYE_OFF BULLSEYE_RESTORE} |
|
190 TInt PassiveOpen(TUint /*aQueSize*/){BULLSEYE_OFF return KErrNotSupported; BULLSEYE_RESTORE} |
|
191 TInt PassiveOpen(TUint /*aQueSize*/,const TDesC8& /*aConnectionData*/){BULLSEYE_OFF return KErrNotSupported; BULLSEYE_RESTORE} |
|
192 void Shutdown(TCloseType /*option*/,const TDesC8& /*aDisconnectionData*/){BULLSEYE_OFF BULLSEYE_RESTORE} |
|
193 void AutoBind(){} |
|
194 public: |
|
195 void LocalName(TSockAddr& aAddr) const; |
|
196 TInt SetLocalName(TSockAddr& aAddr); |
|
197 TInt GetOption(TUint level,TUint name,TDes8& aOption)const; |
|
198 void Ioctl(TUint level,TUint name,TDes8* aOption); |
|
199 void CancelIoctl(TUint aLevel,TUint aName); |
|
200 TInt SetOption(TUint level,TUint name,const TDesC8 &aOption); |
|
201 TInt Write(RMBufChain& aBufChain,TUint options, TSockAddr* aAddr=NULL); |
|
202 TInt GetData(RMBufChain& aBufChain, TUint aLength, TUint options,TSockAddr* aAddr=NULL); |
|
203 void Shutdown(TCloseType option); |
|
204 TBool IsNewStyleClient() {return iIsNewStyleClient;} |
|
205 public: |
|
206 void Error(TInt aError, TUint aOperationMask); |
|
207 void AddToQueue(CWapDatagram* aMsg); |
|
208 void NewData(CWapDatagram* aMsg); |
|
209 void Deliver(TDes& aDesc); |
|
210 TBool MatchesLocalAddress(const TWapAddr& aAddr); |
|
211 TWapSmsStatusReportScheme GetStatusReportScheme(); |
|
212 TWapSmsDataCodingScheme GetDataCodingScheme(); |
|
213 |
|
214 public: |
|
215 TWapSmsMessageType MessageType() { return iMessageType; } |
|
216 static TInt LinkOffset(); |
|
217 |
|
218 protected: |
|
219 CWapSmsProvider(CWapSmsProtocol* aProtocol); |
|
220 virtual TInt SecurityCheck(MProvdSecurityChecker* aSecurityChecker); |
|
221 private: |
|
222 |
|
223 TSglQue<CWapDatagram> iRecvdMsgQueue; |
|
224 TWapSmsDataCodingScheme iDataCodingScheme; |
|
225 TWapSmsMessageType iMessageType; |
|
226 TDblQueLink iSAPLink; |
|
227 TWapAddr iLocalAddress; |
|
228 CWapSmsProtocol* iProtocol; |
|
229 TUint iName; // The integer "name" of the current ioctl request |
|
230 TBool iSendPending; |
|
231 TBool iIoctlOutstanding; // Bool value to indicate the outstanding ioctl |
|
232 TBool iIsNewStyleClient; // Indicate if it is new client (BC) |
|
233 CWapSmsProviderWrite* iWapSmsProviderWrite; |
|
234 MProvdSecurityChecker* iSecurityChecker; //< ESOCK security checker object |
|
235 TWapSmsStatusReportScheme iStatusReportScheme; |
|
236 }; |
|
237 |
|
238 |
|
239 #endif // WS_MAIN_H__ |