|
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: Rtc |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef RTC_H |
|
19 #define RTC_H |
|
20 |
|
21 #include <pthread.h> |
|
22 #include <map> |
|
23 #include <set> |
|
24 |
|
25 #include "logger.h" |
|
26 #include "scopedlocks.h" |
|
27 #include "javauid.h" |
|
28 #include "dynamiclibloader.h" |
|
29 |
|
30 #include "rtcinterface.h" |
|
31 #include "rtcplugininterface.h" |
|
32 #include "rtcruntimeinterface.h" |
|
33 |
|
34 #include "processmanagementeventsinterface.h" |
|
35 #include "commslistener.h" |
|
36 #include "eventconsumerinterface.h" |
|
37 #include "applicationmanagementeventsinterface.h" |
|
38 |
|
39 using namespace java::comms; |
|
40 using java::util::Uid; |
|
41 using java::util::DynamicLibLoader; |
|
42 |
|
43 namespace java |
|
44 { |
|
45 |
|
46 namespace captain |
|
47 { |
|
48 |
|
49 class CoreInterface; |
|
50 class ApplicationRuntimeEventsInterface; |
|
51 |
|
52 class Rtc : public RtcInterface, |
|
53 public ProcessManagementEventsInterface, |
|
54 public CommsListener, |
|
55 public EventConsumerInterface, |
|
56 public ApplicationManagementEventsInterface |
|
57 { |
|
58 public: |
|
59 Rtc(); |
|
60 virtual ~Rtc(); |
|
61 |
|
62 bool start(CoreInterface* aCore, |
|
63 ApplicationRuntimeEventsInterface* aRuntimeEventsDispatcher); |
|
64 bool stop(); |
|
65 |
|
66 // RtcInterface methods |
|
67 virtual bool launch(const rtcLaunchInfo& aLaunchInfo); |
|
68 virtual bool terminate(const rtcTerminateInfo& aTerminateInfo); |
|
69 |
|
70 virtual bool enable(const Uid& aUID); |
|
71 virtual bool disable(const Uid& aUID); |
|
72 |
|
73 virtual void setGlobalRuntimeArguments(const std::wstring& aArguments); |
|
74 virtual std::wstring getGlobalRuntimeArguments(); |
|
75 |
|
76 virtual void setGlobalApplicationArguments(const std::wstring& aArguments); |
|
77 virtual std::wstring getGlobalApplicationArguments(); |
|
78 |
|
79 // ProcessManagementEventsInterface methods |
|
80 virtual void pmcTerminated(const int& pid, const int& exitCode); |
|
81 |
|
82 // CommsListener methods |
|
83 virtual void processMessage(CommsMessage& aMessage); |
|
84 |
|
85 // EventConsumerInterface (needed for listening plugin events) |
|
86 virtual void event(const std::string& eventProvider, |
|
87 java::comms::CommsMessage& aMsg); |
|
88 |
|
89 // ApplicationManagementEventsInterface methods |
|
90 virtual void amAdded(const uids_t& aUids); |
|
91 virtual void amUpdated(const uids_t& aUids); |
|
92 virtual void amDeleted(const uids_t& aUids); |
|
93 |
|
94 // Other public interface methods |
|
95 void terminateRtcRuntimes(); |
|
96 bool routeMessage(CommsMessage& aMessage, const int& aRuntimeAddress); |
|
97 void routeMessageToAll(CommsMessage& aMessage); |
|
98 |
|
99 void launchPrewarm(); |
|
100 void stopPrewarm(); |
|
101 |
|
102 private: |
|
103 // Internal versions supporting CommsMessage based extra indiation options |
|
104 bool launch(const rtcLaunchInfo& aLaunchInfo, const int& aOptions, CommsMessage& aRequester); |
|
105 bool terminate(const rtcTerminateInfo& aTerminateInfo, const int& aOptions, CommsMessage& aRequester); |
|
106 void sendOperationFailed(CommsMessage& aRequester, const Uid& aUid, const int& aOptions); |
|
107 |
|
108 void initialiseRuntimePlugins(); |
|
109 void clearRuntimePlugins(); |
|
110 |
|
111 RtcRuntimeInterface* getRtcRuntime(const Uid& aUID); |
|
112 RtcRuntimeInterface* getOrCreateRtcRuntime(const rtcLaunchInfo& aLaunchInfo); |
|
113 RtcRuntimeInterface* getPrewarmedRtcRuntime(const rtcLaunchInfo& aLaunchInfo); |
|
114 |
|
115 void deleteRuntime(const Uid& aUid); |
|
116 |
|
117 void clearDisabledList(); |
|
118 |
|
119 void notifyLaunchers(const Uid& aUid, const int& aStatus, const int& aPid); |
|
120 void notifyTerminators(const Uid& aUid, const int& aStatus); |
|
121 |
|
122 bool isThereInstalledMidlets() const; |
|
123 |
|
124 CoreInterface* mCore; |
|
125 |
|
126 class rtcPluginData |
|
127 { |
|
128 public: |
|
129 // Statically linked plugins |
|
130 rtcPluginData(RtcPluginInterface* aInterface) |
|
131 :mInterface(aInterface) |
|
132 { |
|
133 } |
|
134 // Dynamically linked plugins |
|
135 rtcPluginData(RtcPluginInterface* aInterface, |
|
136 std::auto_ptr<DynamicLibLoader> aDllLoader) |
|
137 :mInterface(aInterface) |
|
138 { |
|
139 mDllLoader = aDllLoader; |
|
140 } |
|
141 |
|
142 virtual ~rtcPluginData() |
|
143 { |
|
144 delete mInterface; |
|
145 } |
|
146 |
|
147 RtcPluginInterface* mInterface; |
|
148 |
|
149 private: |
|
150 std::auto_ptr<DynamicLibLoader> mDllLoader; |
|
151 |
|
152 rtcPluginData(); |
|
153 rtcPluginData(const rtcPluginData&); |
|
154 rtcPluginData &operator=(const rtcPluginData&); |
|
155 }; |
|
156 |
|
157 typedef std::map<std::string, rtcPluginData*> plugins_t; |
|
158 plugins_t mPlugins; |
|
159 |
|
160 typedef std::map<Uid, RtcRuntimeInterface*> runtimes_t; |
|
161 runtimes_t mRuntimes; |
|
162 |
|
163 typedef std::set<Uid> disabledUIDs_t; |
|
164 disabledUIDs_t mDisabledUIDs; |
|
165 |
|
166 typedef std::multimap<Uid, CommsMessage> requesters_t; |
|
167 requesters_t mLaunchers; |
|
168 requesters_t mTerminators; |
|
169 |
|
170 std::wstring mGlobalRuntimeArguments; |
|
171 std::wstring mGlobalApplicationArguments; |
|
172 |
|
173 ApplicationRuntimeEventsInterface* mRuntimeEventsDispatcher; |
|
174 |
|
175 bool mSupportPreWarming; |
|
176 }; |
|
177 |
|
178 } // namespace captain |
|
179 } // namespace java |
|
180 |
|
181 #endif // RTC_H |
|
182 |