|
1 // Copyright (c) 2007-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 #ifndef PBAPSERVER_H |
|
17 #define PBAPSERVER_H |
|
18 |
|
19 #include <e32std.h> |
|
20 #include <obex.h> |
|
21 #include <btsdp.h> |
|
22 #include <bt_sock.h> |
|
23 |
|
24 #include "pbapfolderclient.h" |
|
25 #include "pbapexporter.h" |
|
26 #include "pbaperrorreporter.h" |
|
27 #include "pbapvcardexporterutil.h" |
|
28 #include "pbappanic.h" |
|
29 |
|
30 // forward declarations |
|
31 class CObexServer; |
|
32 class CContactDatabase; |
|
33 class CVirtualFolders; |
|
34 class CPbapVCardExporter; |
|
35 class CPbapContactDbViews; |
|
36 class RFs; |
|
37 class CPbapLogWrapper; |
|
38 class CPbapAuthPasswordGetter; |
|
39 |
|
40 |
|
41 const TUint KPbapServerShutdownDelay = 5000000; |
|
42 |
|
43 enum TPbapAvailability |
|
44 { |
|
45 EPbapUnavailable = 0, |
|
46 EPbapAvailable = 0xff |
|
47 }; |
|
48 |
|
49 /** |
|
50 server shutdown timer |
|
51 */ |
|
52 class CPbapServerShutdown : public CTimer |
|
53 { |
|
54 public: |
|
55 static CPbapServerShutdown* NewL(); |
|
56 inline void Start(); |
|
57 |
|
58 private: |
|
59 inline CPbapServerShutdown(); |
|
60 inline void ConstructL(); |
|
61 void RunL(); |
|
62 }; |
|
63 |
|
64 |
|
65 /** |
|
66 PBAP server |
|
67 */ |
|
68 class CPbapServer : public CPolicyServer, |
|
69 public MObexServerNotifyAsync, |
|
70 public MObexAuthChallengeHandler, |
|
71 public MVirtualFolderClient, |
|
72 public MPbapExporter, |
|
73 public MPbapErrorReporter |
|
74 { |
|
75 public: |
|
76 static CPbapServer* NewL(); |
|
77 ~CPbapServer(); |
|
78 |
|
79 void AddSession(); |
|
80 void DropSession(); |
|
81 |
|
82 void StartObexL(); |
|
83 void ReleaseObex(); |
|
84 |
|
85 void SetPasswordL(HBufC* aPassword); |
|
86 |
|
87 void HandlePasswordRetrieved(TInt aError, const TDesC& aPassword); |
|
88 |
|
89 private: |
|
90 CPbapServer(); |
|
91 |
|
92 void ConstructL(); |
|
93 void OpenContactsDbL(); |
|
94 void CreateLogEngineClientL(); |
|
95 |
|
96 void RegisterWithSdpL(TUint aRfcommChannel); |
|
97 void ReleaseSdpRegistration(); |
|
98 void UpdateAvailability(TPbapAvailability aAvailablility); |
|
99 void DoUpdateAvailabilityL(TPbapAvailability aAvailablility); |
|
100 |
|
101 void BuildVirtualFolderTreeL(); |
|
102 CVirtualFolders* TelecomSubTreeL(); |
|
103 |
|
104 #ifdef __INCLUDE_SIM1_FOLDERS__ |
|
105 CVirtualFolders* SIMTelecomSubTreeL(); |
|
106 #endif // __INCLUDE_SIM1_FOLDERS__ |
|
107 |
|
108 CVirtualFolders* ResolvePath(TDes& aPathInObjectOut, TBool aAbsolute) const; |
|
109 |
|
110 void DoGetRequestIndicationL(CObexBaseObject* aRequiredObject); |
|
111 |
|
112 void CleanupGetRequest(); |
|
113 void CleanupOnDisconnect(); |
|
114 |
|
115 void ReportObexError(TInt aSymbianError); |
|
116 |
|
117 static TInt RestartObex(TAny* aAny); |
|
118 void DoRestartObex(); |
|
119 |
|
120 private: |
|
121 // from CServer2 |
|
122 CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const; |
|
123 |
|
124 private: |
|
125 // from MObexServerNotifyAsync |
|
126 virtual void ErrorIndication(TInt aError); |
|
127 virtual void TransportUpIndication(); |
|
128 virtual void TransportDownIndication(); |
|
129 virtual void ObexConnectIndication(const TObexConnectInfo& aRemoteInfo, const TDesC8& aInfo); |
|
130 virtual void ObexDisconnectIndication(const TDesC8& aInfo); |
|
131 virtual void PutRequestIndication(); |
|
132 virtual TInt PutPacketIndication(); |
|
133 virtual void PutCompleteIndication(); |
|
134 virtual void GetRequestIndication(CObexBaseObject* aRequiredObject); |
|
135 virtual TInt GetPacketIndication(); |
|
136 virtual void GetCompleteIndication(); |
|
137 virtual void SetPathIndication(const CObex::TSetPathInfo& aPathInfo, const TDesC8& aInfo); |
|
138 virtual void AbortIndication(); |
|
139 virtual void CancelIndicationCallback(); |
|
140 |
|
141 private: |
|
142 // from MObexAuthChallengeHandler |
|
143 virtual void GetUserPasswordL(const TDesC &aRealm); |
|
144 |
|
145 private: |
|
146 // from MVirtualFolderClient |
|
147 virtual CContactDatabase& ContactDB() const; |
|
148 virtual MPbapExporter& Exporter(); |
|
149 virtual MPbapErrorReporter& ErrorReporter(); |
|
150 virtual CPbapContactDbViews& ContactDbViews(); |
|
151 virtual CPbapLogWrapper& LogClient() const; |
|
152 |
|
153 private: |
|
154 // from MPbapExporter |
|
155 virtual void StartExport(); |
|
156 virtual void ExportListingBeginL(); |
|
157 virtual void ExportListingEntryL(TInt aHandle, const TDesC& aName); |
|
158 virtual void ExportListingEndL(); |
|
159 virtual void ExportCallHistoryL(const CLogEvent& aEvent, TVCardVersion aFormat, TUint64 aFilter); |
|
160 virtual void ExportContactL(TContactItemId aContactId, TVCardVersion aFormat, TUint64 aFilter); |
|
161 virtual void ExportEmptyVCardL(TVCardVersion aFormat); |
|
162 virtual void ExportPhonebookSizeL(TInt aCount); |
|
163 virtual void ExportNewMissedCallsL(TInt aCount); |
|
164 virtual void FinaliseExportL(); |
|
165 virtual void CancelExport(); |
|
166 |
|
167 private: |
|
168 // from MPbapErrorReporter |
|
169 virtual void SendServiceUnavailableError(); |
|
170 virtual void SendPreconditionFailedError(); |
|
171 virtual void SendNotFoundError(); |
|
172 |
|
173 private: |
|
174 TBool iActiveSession; |
|
175 CPbapServerShutdown* iShutdown; |
|
176 |
|
177 CObexServer* iObex; |
|
178 CPbapAuthPasswordGetter* iPasswordGetter; |
|
179 HBufC* iPassword; |
|
180 CObexBufObject* iOutboundObject; |
|
181 CBufFlat* iOutboundBuffer; |
|
182 RBufWriteStream iBufStreamer; |
|
183 RBuf8 iAppHeaderDetails; |
|
184 TBool iExportInProgress; |
|
185 |
|
186 CContactDatabase* iContacts; |
|
187 CPbapVCardExporterUtil* iVCardExporter; |
|
188 CPbapContactDbViews* iContactViews; |
|
189 |
|
190 RFs iFs; |
|
191 CPbapLogWrapper* iLogWrapper; |
|
192 |
|
193 CVirtualFolders* iFolderTree; |
|
194 |
|
195 RSdp iSdpServer; |
|
196 RSdpDatabase iSdpDatabase; |
|
197 TSdpServRecordHandle iSdpRecordHandle; |
|
198 |
|
199 RSocketServ iSocketServ; |
|
200 RBTPhysicalLinkAdapter iPhysLinkAdaptor; |
|
201 |
|
202 CAsyncCallBack* iAsyncRestartObex; |
|
203 |
|
204 private: |
|
205 CVirtualFolders* iCurrentFolder; //not owned |
|
206 CVirtualFolders* iGetRequestFolder; //not owned |
|
207 }; |
|
208 |
|
209 #endif //PBAPSERVER_H |