|
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: RtcBasePlugin |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef RTCBASEPLUGIN_H |
|
19 #define RTCBASEPLUGIN_H |
|
20 |
|
21 #include <list> |
|
22 |
|
23 #include "scopedlocks.h" |
|
24 #include "commsmessage.h" |
|
25 |
|
26 #include "rtcinterface.h" |
|
27 #include "timerserverinterface.h" |
|
28 #include "rtcruntimeinterface.h" |
|
29 #include "pmcinterface.h" |
|
30 |
|
31 using java::comms::CommsMessage; |
|
32 |
|
33 namespace java |
|
34 { |
|
35 namespace captain |
|
36 { |
|
37 |
|
38 class CoreInterface; |
|
39 class ApplicationRuntimeEventsInterface; |
|
40 |
|
41 class RtcBasePlugin : public RtcRuntimeInterface, |
|
42 public TimerServerEventsInterface |
|
43 { |
|
44 public: |
|
45 RtcBasePlugin(const Uid& aUID, CoreInterface* aCore); |
|
46 virtual ~RtcBasePlugin(); |
|
47 |
|
48 virtual bool launch(const rtcLaunchInfo& aLaunchInfo); |
|
49 virtual int pid() const |
|
50 { |
|
51 return mPid; |
|
52 } |
|
53 virtual Uid uid() const |
|
54 { |
|
55 return mUID; |
|
56 } |
|
57 virtual bool isRunning() const; |
|
58 virtual int runtimeAddress() const |
|
59 { |
|
60 return mRuntimeAddress; |
|
61 } |
|
62 |
|
63 virtual bool terminate(const rtcTerminateInfo& aTerminateInfo); |
|
64 |
|
65 virtual void runningInd(const int& aRuntimeAddress, const int& aStatus); |
|
66 virtual void terminatedInd(const int& aStatus); |
|
67 |
|
68 // ProcessManagementEventsInterface |
|
69 virtual void pmcTerminated(const int& pid, const int& exitCode); |
|
70 |
|
71 // TimerServerEventsInterface methods |
|
72 virtual void timerTimeout(const int& aTimerId); |
|
73 |
|
74 // CommsListener, called by Host Rtc not by comms |
|
75 virtual void processMessage(CommsMessage& message); |
|
76 |
|
77 protected: |
|
78 enum ApplicationState |
|
79 { |
|
80 APPLICATION_STATE_IDLE_C, |
|
81 APPLICATION_STATE_LAUNCHED_C, |
|
82 APPLICATION_STATE_RUNNING_C, |
|
83 APPLICATION_STATE_EXITING_C |
|
84 }; |
|
85 const char* E2S_state(const RtcBasePlugin::ApplicationState& state) |
|
86 { |
|
87 switch (state) |
|
88 { |
|
89 case APPLICATION_STATE_IDLE_C: |
|
90 return "IDLE_C"; |
|
91 case APPLICATION_STATE_LAUNCHED_C: |
|
92 return "LAUNCHED_C"; |
|
93 case APPLICATION_STATE_RUNNING_C: |
|
94 return "RUNNING_C"; |
|
95 case APPLICATION_STATE_EXITING_C: |
|
96 return "EXITING_C"; |
|
97 } |
|
98 |
|
99 return "UKNOWN!"; |
|
100 } |
|
101 |
|
102 virtual void switchState(const ApplicationState& newState); |
|
103 |
|
104 virtual void runtime_init(); |
|
105 virtual bool runtime_launch(const int& aLaunchType); |
|
106 virtual bool runtime_relaunch(const int& aLaunchType); |
|
107 virtual bool runtime_terminate(); |
|
108 |
|
109 // Currently only platform/runtime specific part |
|
110 virtual cmdLine_t& generateCommandLine(const int& aLaunchType, |
|
111 cmdLine_t& aParams) = 0; |
|
112 |
|
113 int sendMessageToRuntime(const int& aModuleId, CommsMessage& aMessage); |
|
114 |
|
115 void startTimer(const int& timeout); |
|
116 void stopTimer(); |
|
117 |
|
118 enum PendingOperation |
|
119 { |
|
120 PENDING_OPERATION_NONE_C, |
|
121 PENDING_OPERATION_LAUNCH_NORMAL_C, |
|
122 PENDING_OPERATION_LAUNCH_PUSH_C, |
|
123 PENDING_OPERATION_LAUNCH_AUTO_INVOCATION_C, |
|
124 PENDING_OPERATION_LAUNCH_BACKGROUND_C, |
|
125 PENDING_OPERATION_LAUNCH_DEBUG_C, |
|
126 PENDING_OPERATION_TERMINATE_C |
|
127 }; |
|
128 |
|
129 void setPendingLaunch(const int& aType); |
|
130 void setPendingTerminate(); |
|
131 |
|
132 void handlePendingOperations(); |
|
133 |
|
134 Uid mUID; |
|
135 CoreInterface* mCore; |
|
136 ApplicationState mState; |
|
137 int mRuntimeAddress; |
|
138 int mPid; |
|
139 int mTimerId; |
|
140 PendingOperation mPendingOperation; |
|
141 std::wstring mRuntimeArguments; |
|
142 std::wstring mApplicationArguments; |
|
143 }; |
|
144 |
|
145 } // namespace captain |
|
146 } // namespace java |
|
147 |
|
148 #endif // RTCBASEPLUGIN_H |
|
149 |