|
1 /* |
|
2 * Copyright (c) 2007-2010 Sebastian Brannstrom, Lars Persson, EmbedDev AB |
|
3 * |
|
4 * All rights reserved. |
|
5 * This component and the accompanying materials are made available |
|
6 * under the terms of the License "Eclipse Public License v1.0" |
|
7 * which accompanies this distribution, and is available |
|
8 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
9 * |
|
10 * Initial Contributors: |
|
11 * EmbedDev AB - initial contribution. |
|
12 * |
|
13 * Contributors: |
|
14 * |
|
15 * Description: |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef PODCAST_CONNECTIONENGINE_H |
|
20 #define PODCAST_CONNECTIONENGINE_H |
|
21 |
|
22 |
|
23 // Connect using mobility extension |
|
24 #include <in_sock.h> |
|
25 #include <connpref.h> |
|
26 #include <commdbconnpref.h> |
|
27 #include <comms-infras/cs_mobility_apiext.h> |
|
28 |
|
29 // Using connection manager settings UI |
|
30 #include <cmapplicationsettingsui.h> |
|
31 class CPodcastModel; |
|
32 |
|
33 class MConnectionObserver |
|
34 { |
|
35 public: |
|
36 virtual void ConnectCompleteL(TInt aErrorCode) = 0; |
|
37 virtual void Disconnected() = 0; |
|
38 }; |
|
39 |
|
40 /** |
|
41 * This class helps to connect using three available methods |
|
42 * SNAP, Mobility extension and Connection manager UI |
|
43 */ |
|
44 class CConnectionEngine:public CActive, public MMobilityProtocolResp |
|
45 { |
|
46 public: |
|
47 enum TConnectionType |
|
48 { |
|
49 EUserSelectConnection, |
|
50 ESNAPConnection, |
|
51 EMobilityConnection, |
|
52 EDefaultConnection, |
|
53 EIAPConnection |
|
54 }; |
|
55 |
|
56 enum TConnectionState |
|
57 { |
|
58 ENotConnected, |
|
59 EConnecting, |
|
60 EConnected |
|
61 }; |
|
62 |
|
63 static CConnectionEngine* NewL(CPodcastModel& aPodcastModel); |
|
64 ~CConnectionEngine(); |
|
65 void StartL(TConnectionType aConnectionType); |
|
66 RConnection& Connection(); |
|
67 TConnectionState ConnectionState(); |
|
68 void AddObserver(MConnectionObserver* aObserver); |
|
69 RSocketServ& SockServ(); |
|
70 private: // Methods |
|
71 CConnectionEngine(CPodcastModel& aPodcastModel); |
|
72 void ConstructL(); |
|
73 protected: |
|
74 // From CActive |
|
75 void RunL(); |
|
76 void DoCancel(); |
|
77 TInt RunError( TInt aError ); |
|
78 protected: |
|
79 // From MMobilityProtocolResp |
|
80 void PreferredCarrierAvailable( TAccessPointInfo aOldAPInfo, |
|
81 TAccessPointInfo aNewAPInfo, |
|
82 TBool aIsUpgrade, |
|
83 TBool aIsSeamless ); |
|
84 |
|
85 void NewCarrierActive( TAccessPointInfo aNewAPInfo, TBool aIsSeamless ); |
|
86 void Error( TInt aError ); |
|
87 protected: |
|
88 // UI Setting |
|
89 TBool ConnectionSettingL(); |
|
90 |
|
91 void ReportConnection(TInt aError); |
|
92 private: |
|
93 RConnection iConnection; |
|
94 RSocketServ iSocketServer; |
|
95 // Connect using mobility extension |
|
96 CActiveCommsMobilityApiExt* iMobility; |
|
97 |
|
98 // Using connection manager settings UI |
|
99 TCmSettingSelection iUserSelection; |
|
100 |
|
101 // Connect using Commdb |
|
102 TCommDbConnPref iCommdbPreference; |
|
103 |
|
104 // Connect using SNAP setting |
|
105 TConnSnapPref iSnapPreference; |
|
106 |
|
107 TConnectionType iConnectionType; |
|
108 TConnectionState iConnectionState; |
|
109 RPointerArray<MConnectionObserver> iObserverArray; |
|
110 CPodcastModel &iPodcastModel; // reference to the model |
|
111 }; |
|
112 |
|
113 #endif // PODCAST_CONNECTIONENGINE_H |