|
1 /* |
|
2 * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Creator and user of ASY threads |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CASYPROXYMAINSERVICE_H |
|
20 #define CASYPROXYMAINSERVICE_H |
|
21 |
|
22 // INCLUDES |
|
23 #include "AccSrvProxy.h" |
|
24 #include <AsyMainServiceBase.h> |
|
25 #include <AsyServiceUids.h> |
|
26 #include <AsyCmdTypes.h> |
|
27 #include <e32std.h> |
|
28 #include <e32base.h> |
|
29 |
|
30 // CONSTANTS |
|
31 |
|
32 // Common first part of unique thread's name |
|
33 _LIT(KASYThreadName, "ASYThread - "); |
|
34 |
|
35 // MACROS |
|
36 |
|
37 // DATA TYPES |
|
38 struct TASYProxyThreadParam |
|
39 { |
|
40 RSemaphore* iSemaphore; // Semaphore for thread |
|
41 TUid iThreadMainServiceUid; // MainService Uid |
|
42 TUid iThreadHandlerUid; // Handler Uid |
|
43 }; |
|
44 |
|
45 // FUNCTION PROTOTYPES |
|
46 |
|
47 // FORWARD DECLARATIONS |
|
48 |
|
49 // CLASS DECLARATION |
|
50 class CASYProxyASYHandler; |
|
51 |
|
52 /** |
|
53 * Creates ASY to it's own thread |
|
54 * CASYMainServiceBase -object to it's own thread |
|
55 * CASYCommandHandlerBase -object to it's own thread |
|
56 * |
|
57 * @lib ASYProxy.dll |
|
58 * @since S60 3.1 |
|
59 */ |
|
60 class CASYProxyMainService : public CActive |
|
61 { |
|
62 public: // Constructors and destructor |
|
63 |
|
64 /** |
|
65 * Two-phased constructor. |
|
66 */ |
|
67 static CASYProxyMainService* NewL( CASYProxyASYHandler* aAsyHandler ); |
|
68 |
|
69 /** |
|
70 * Destructor. |
|
71 */ |
|
72 virtual ~CASYProxyMainService(); |
|
73 |
|
74 public: // New functions |
|
75 |
|
76 /** |
|
77 * Thread's entry point |
|
78 * @since S60 3.1 |
|
79 * @param aParameter Pointer of parameter passed to thread |
|
80 * Please see the TASYProxyThreadParam struct for more info |
|
81 * @return Error code of thread creating |
|
82 * KErrNone if succesfully |
|
83 */ |
|
84 static TInt ThreadEntryPoint( TAny* aParameter ); |
|
85 |
|
86 /** |
|
87 * Starts the thread creating |
|
88 * @since S60 3.1 |
|
89 * @param aMainServiceUid Implementation uid for CASYMainServiceBase -object |
|
90 * @param aHandlerUid Implementation uid for CASYCommandHandlerBase -object |
|
91 * @param aHeapSize Heap memory size for ASY thread |
|
92 * @param aStackSize Stack memory size for ASY thread |
|
93 * @return void |
|
94 */ |
|
95 void StartThreadL( const TUid aMainServiceUid, |
|
96 const TUid aHandlerUid, |
|
97 const TInt aHeapSize, |
|
98 const TInt aStackSize ); |
|
99 |
|
100 // Add Cancel for this method |
|
101 |
|
102 public: // Functions from base classes |
|
103 |
|
104 protected: // New functions |
|
105 |
|
106 protected: // Functions from base classes |
|
107 |
|
108 private: |
|
109 |
|
110 /** |
|
111 * C++ default constructor. |
|
112 */ |
|
113 CASYProxyMainService( CASYProxyASYHandler* aAsyHandler ); |
|
114 |
|
115 /** |
|
116 * By default Symbian 2nd phase constructor is private. |
|
117 */ |
|
118 void ConstructL(); |
|
119 |
|
120 /** |
|
121 * From CActive Handles an active object's request completion event. |
|
122 */ |
|
123 void RunL(); |
|
124 |
|
125 /** |
|
126 * From CActive Handles RunL's leave cases |
|
127 */ |
|
128 TInt RunError( TInt aError ); |
|
129 |
|
130 /** |
|
131 * From CActive Implements cancellation of an outstanding request. |
|
132 */ |
|
133 void DoCancel(); |
|
134 |
|
135 /** |
|
136 * Creates CActiveScheduler object and begins ASY creating |
|
137 */ |
|
138 static TInt DoStartThreadL( const TUid aMainServiceUid, |
|
139 const TUid aHandlerUid ); |
|
140 |
|
141 /** |
|
142 * Create ASYs |
|
143 */ |
|
144 static TInt CreateAsyServicesLC( const TUid aMainServiceUid, |
|
145 const TUid aHandlerUid ); |
|
146 |
|
147 public: // Data |
|
148 |
|
149 protected: // Data |
|
150 |
|
151 private: // Data |
|
152 |
|
153 // Handle to created thread |
|
154 RThread iThread; |
|
155 |
|
156 // Pointer to ASY handler |
|
157 CASYProxyASYHandler* iAsyHandler; // Not owned |
|
158 |
|
159 public: // Friend classes |
|
160 |
|
161 protected: // Friend classes |
|
162 |
|
163 private: // Friend classes |
|
164 }; |
|
165 |
|
166 #endif // CASYPROXYMAINSERVICE_H |
|
167 |
|
168 // End of File |