|
1 /* |
|
2 * Copyright (c) 2008 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef PUSHCONTROLLERSTARTERIMPL_H |
|
20 #define PUSHCONTROLLERSTARTERIMPL_H |
|
21 |
|
22 #include <memory> |
|
23 #include <list> |
|
24 #include <string> |
|
25 #include <exception> |
|
26 |
|
27 #include "comms.h" |
|
28 #include "commslistener.h" |
|
29 #include "pushcontrollerstarter.h" |
|
30 #include "pushconstant.h" |
|
31 #include "serverconnectionfactory.h" |
|
32 #include "connectionlistener.h" |
|
33 #include "pendingconnectionlistener.h" |
|
34 #include "dynamiclibloader.h" |
|
35 #include "pushserverconnpluginmanager.h" |
|
36 #include "pushregistry.h" |
|
37 #include "javauid.h" |
|
38 #include "monitor.h" |
|
39 |
|
40 namespace java |
|
41 { |
|
42 |
|
43 namespace runtime |
|
44 { |
|
45 class ApplicationBasicInfo; |
|
46 class RuntimeInfo; |
|
47 } |
|
48 namespace comms |
|
49 { |
|
50 class CommsMessage; |
|
51 class CommsClientEndpoint; |
|
52 } |
|
53 namespace util |
|
54 { |
|
55 class Uid; |
|
56 } |
|
57 namespace push |
|
58 { |
|
59 |
|
60 class PushServerConnection; |
|
61 |
|
62 /** |
|
63 * This class provides implementation for PushControllerStarter and PushRegistry |
|
64 * interfaces. |
|
65 */ |
|
66 |
|
67 class PushControllerStarterImpl : public PushControllerStarter, public ConnectionListener, |
|
68 public java::comms::CommsListener, public PushRegistry, |
|
69 public PushControllerErrorHandlerInterface, |
|
70 public PendingConnectionListener, |
|
71 public ConnManagedInterface |
|
72 { |
|
73 public: |
|
74 |
|
75 PushControllerStarterImpl(); |
|
76 |
|
77 virtual ~PushControllerStarterImpl(); |
|
78 |
|
79 //Method of PushControllerStarter. |
|
80 virtual void startListen(const java::util::Uid& aUid, |
|
81 java::runtime::MidpStarterPushSupport* aAppStateController); |
|
82 virtual void updatePushRegs(const java::util::Uid& aUid, |
|
83 java::runtime::MidpStarterPushSupport* aAppStateController); |
|
84 virtual void close(); |
|
85 |
|
86 //Methhod of ConnectionListener. |
|
87 virtual void msgArrived(const std::wstring& aInfo); |
|
88 virtual void error(const std::wstring& aUri, int aErrCode, const std::string& aErrText); |
|
89 |
|
90 //Methods of CommsListener. |
|
91 virtual void processMessage(java::comms::CommsMessage& aMessage); |
|
92 |
|
93 //Implementation methods of PushRegistry java class. |
|
94 |
|
95 /** |
|
96 * See comments from PushRegistry::registerDynamicPushConn() operation. |
|
97 */ |
|
98 virtual void registerDynamicPushConn(const std::wstring& aUri, |
|
99 const std::wstring& aMidlet, |
|
100 const std::wstring& aFilter, |
|
101 const java::util::Uid& aUid, |
|
102 bool aIsUidOfThisMidlet); |
|
103 |
|
104 /** |
|
105 * See comments from PushRegistry::listConnections() operation. |
|
106 */ |
|
107 virtual void listConnections(bool aAvailable,const java::util::Uid& aUid, |
|
108 std::list<std::wstring>& aUriList); |
|
109 |
|
110 /** |
|
111 * See comments from PushRegistry::getFilter() operation. |
|
112 */ |
|
113 virtual std::wstring getFilter(const std::wstring& aUri, |
|
114 const java::util::Uid& aSuiteUid); |
|
115 |
|
116 /** |
|
117 * See comments from PushRegistry::getClassNameOfMidlet() operation. |
|
118 */ |
|
119 virtual std::wstring getClassNameOfMidlet(const std::wstring& aUri, |
|
120 const java::util::Uid& aSuiteUid); |
|
121 |
|
122 /** |
|
123 * See comments from PushRegistry::isPushConnection() operation. |
|
124 */ |
|
125 virtual bool isPushConnection(const std::wstring& aUri,const java::util::Uid& aUid); |
|
126 |
|
127 /** |
|
128 * See comments from PushRegistry::isPushConnection() operation. |
|
129 */ |
|
130 virtual void unregisterDynamicPushConn(const std::wstring& aUri, |
|
131 const java::util::Uid& aUid, |
|
132 bool aIsUidOfThisMidlet); |
|
133 |
|
134 /** |
|
135 * @param aMidlet validation of this argument must be done in the java side. |
|
136 */ |
|
137 virtual long long registerAlarm(const long long& aAlarmTimeInMilliSecs, |
|
138 const java::util::Uid& aSuiteUid, |
|
139 const std::wstring& aClassNameOfMidlet, |
|
140 bool aIsUidOfThisMidlet); |
|
141 |
|
142 //Methods of PushControllerErrorHandlerInterface interface. |
|
143 virtual void sendAllConnsFailedMsg(); |
|
144 virtual void closeRuntime(); |
|
145 |
|
146 //Method of PendingConnectionListener interface. |
|
147 virtual void setPendingStatus(const std::wstring& aUri,bool aMsgIsWaitingHandling); |
|
148 |
|
149 //Method of ConnManagedInterface. |
|
150 virtual void connCompleted(const std::wstring& aUri); |
|
151 |
|
152 private: |
|
153 |
|
154 enum EState |
|
155 { |
|
156 INITIAL_STATE = 0, |
|
157 LOADING_PUSH_CONNS, |
|
158 PUSH_CONNS_LOADED |
|
159 }; |
|
160 |
|
161 //Datamembers. |
|
162 std::auto_ptr<PushServerConnPluginManager> mSrvConnPluginMgr; |
|
163 java::util::Uid mUid; |
|
164 java::runtime::MidpStarterPushSupport* mAppStateController; |
|
165 EState mState; |
|
166 pthread_t mThreadId; |
|
167 mutable java::util::ScopedMutex mMutex; |
|
168 std::auto_ptr<java::util::Monitor> mMonitor; |
|
169 std::auto_ptr<java::util::Monitor> mConnCompletedMonitor; |
|
170 bool mIsUpdate; |
|
171 int mNumOfPendingUpdates; |
|
172 |
|
173 //Internal operations. |
|
174 bool sendGetAllPushRegsMsg(bool aThrowingExceptionAllowed); |
|
175 void handleListOfAllPushRegistrationsMsg(java::comms::CommsMessage& aMessage); |
|
176 java::comms::CommsClientEndpoint& getComms(); |
|
177 void validateUid(const java::util::Uid& aUid,java::comms::CommsMessage& aMessage, |
|
178 const std::string& aFile,const std::string& aFunction,int aLine); |
|
179 void checkErrorParamsOfCommsMsg(java::comms::CommsMessage& aMessage); |
|
180 void validateCommonParamsOfReplyCommsMsg(int aRetValue,int aMsgId, |
|
181 java::comms::CommsMessage& aMsg, |
|
182 const java::util::Uid& aUid); |
|
183 void loadPushConns(const java::util::Uid& aUid); |
|
184 std::wstring sendPushDataQuery(const std::wstring& aUri, |
|
185 const java::util::Uid& aSuiteUid, |
|
186 const EPushInfoQueryParams& aQueryCondition); |
|
187 void sendRegDynPushConnMsg(const std::wstring& aUri, |
|
188 const std::wstring& aMidlet, |
|
189 const std::wstring& aFilter, |
|
190 const java::util::Uid& aUid, |
|
191 int aIsUidOfThisMidlet); |
|
192 PushServerConnPluginManager& getPushServerConnPluginManager(); |
|
193 void setState(const EState& aState); |
|
194 EState getState() const; |
|
195 void registerCommsListener(); |
|
196 void updatePushRegs2(const java::util::Uid& aUid, |
|
197 java::runtime::MidpStarterPushSupport* aAppStateController, |
|
198 bool aThrowingExceptionAllowed); |
|
199 void startToWaitCompletionOfOper(); |
|
200 |
|
201 //Not implemented. |
|
202 PushControllerStarterImpl(const PushControllerStarterImpl &x); |
|
203 PushControllerStarterImpl &operator=(const PushControllerStarterImpl &x); |
|
204 |
|
205 }; |
|
206 }//end namespace push |
|
207 }//end namespace java |
|
208 |
|
209 #endif // PUSHCONTROLLERSTARTERIMPL_H |