|
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 PUSHCONTROLLERSTARTER_H |
|
20 #define PUSHCONTROLLERSTARTER_H |
|
21 |
|
22 #include <memory> |
|
23 #include "dynamiclibloader.h" |
|
24 |
|
25 namespace java |
|
26 { |
|
27 namespace util |
|
28 { |
|
29 class Uid; |
|
30 } |
|
31 namespace runtime |
|
32 { |
|
33 class MidpStarterPushSupport; |
|
34 } |
|
35 namespace comms |
|
36 { |
|
37 class CommsClientEndpoint; |
|
38 } |
|
39 namespace push |
|
40 { |
|
41 |
|
42 /** |
|
43 * Runtime Starter uses this interface to start and stop Push Controller. |
|
44 */ |
|
45 |
|
46 class PushControllerStarter; |
|
47 |
|
48 typedef PushControllerStarter& (*GetPushStarter)(); |
|
49 |
|
50 class PushControllerStarter |
|
51 { |
|
52 public: |
|
53 virtual ~PushControllerStarter() {} |
|
54 |
|
55 /** |
|
56 * Reads push connections from the Java Storage, loads Server Connection Plugins |
|
57 * and start to listen push connections. |
|
58 * @param aUid UID of the application. |
|
59 * @param aAppStateController PushController informs application state changes |
|
60 * via this object. Note: Ownership of this object is not given to the user. |
|
61 * @throws ExceptionBase exception in the following situation: |
|
62 * - Initialization of all push connections failed. |
|
63 */ |
|
64 virtual void startListen(const java::util::Uid& aUid, |
|
65 java::runtime::MidpStarterPushSupport* aAppStateController) = 0; |
|
66 |
|
67 /** |
|
68 * Updates push registrations of running application. This must be called when dynamic push |
|
69 * connection has been registered/unregistered from the other MIDlet. This operation does not |
|
70 * throw exceptions. |
|
71 * @param aUid UID of the application. |
|
72 * @param aAppStateController PushController informs application state changes |
|
73 * via this object. Note: Ownership of this object is not given to the user. |
|
74 */ |
|
75 virtual void updatePushRegs(const java::util::Uid& aUid, |
|
76 java::runtime::MidpStarterPushSupport* aAppStateController) = 0; |
|
77 |
|
78 /** |
|
79 * Closes all connections (push and normal server connections) |
|
80 * and unloads Server Connection Plugins. This operation does not throw exceptions. |
|
81 * Note: It is not allowed to use PushControllerStarter object after calling this |
|
82 * operation. |
|
83 */ |
|
84 virtual void close() = 0; |
|
85 |
|
86 /** |
|
87 * This inline method will load the shared library which contains the |
|
88 * implementation of the starting the MIDP push controller. |
|
89 * |
|
90 * It is important that the user of this method is aware that the |
|
91 * implementation is available ONLY when the instance of |
|
92 * DynamicLibLoader is not deleted. When the user is absolutely sure |
|
93 * that no code is run from the loaded shared library, user should delete |
|
94 * the instance of DynamicLibLoader. The deletion will lead to |
|
95 * unloading the shared library. |
|
96 * |
|
97 * @param[out] loader User must store this argument as long as it needs |
|
98 * to run any code in the shared library. No other |
|
99 APIs of the loader is needed to use. |
|
100 * @param[in] runtimeStarter A reference to runtimeStarter. To be removed. |
|
101 * @return Instance implementing PushControllerFactory in success case, 0 |
|
102 in error cases. |
|
103 */ |
|
104 static PushControllerStarter& |
|
105 getPushControllerStarter(std::auto_ptr<java::util::DynamicLibLoader>& loader); |
|
106 |
|
107 }; |
|
108 |
|
109 inline PushControllerStarter& |
|
110 PushControllerStarter::getPushControllerStarter( |
|
111 std::auto_ptr<java::util::DynamicLibLoader>& loader) |
|
112 { |
|
113 |
|
114 //Create an instance of DynamicLibLoader, load the javajvmstarter |
|
115 //shared library and locate method createVmStarter. If loadAndGetFunction |
|
116 //succeeds were are certain that loader will contain valid object |
|
117 //and also functionPtr points to valid method. |
|
118 if (0 == loader.get()) |
|
119 { |
|
120 loader.reset(new java::util::DynamicLibLoader("javapushcontroller")); |
|
121 } |
|
122 //Cast the function ptr |
|
123 //reinterpret_cast<GetPushStarter> would be better, but can't be used in Maemo |
|
124 GetPushStarter getPushStarter = (GetPushStarter) |
|
125 (loader->getFunction("getPushControllerStarter")); |
|
126 |
|
127 //Call the method which will return and instace of VmStarterInterface. |
|
128 return getPushStarter(); |
|
129 } |
|
130 |
|
131 }//end namespace push |
|
132 }//end namespace java |
|
133 |
|
134 #endif // PUSHCONTROLLERSTARTER_H |
|
135 |