29 class CLogonMonitor; |
29 class CLogonMonitor; |
30 |
30 |
31 _LIT(KMMFControllerProxyServerName, "MMFControllerProxyServer-"); |
31 _LIT(KMMFControllerProxyServerName, "MMFControllerProxyServer-"); |
32 |
32 |
33 /** |
33 /** |
34 @internalComponent |
34 @publishedAll |
|
35 @released |
|
36 |
|
37 Signals that the message is destined for the controller |
35 */ |
38 */ |
36 #define KMMFControllerProxyVersion TVersion(7,1,1) |
39 const TInt KMMFObjectHandleController = -2; |
37 |
|
38 /** |
|
39 @internalComponent |
|
40 */ |
|
41 const TInt KMMFControllerProxyMaxHeapSize = 0x1000000;//16MB |
|
42 |
|
43 /** |
|
44 @internalComponent |
|
45 */ |
|
46 const TInt KMMFControllerProxyMaxCachedMessages = 10; |
|
47 |
|
48 /** |
|
49 @internalComponent |
|
50 |
|
51 Signals that the message is destined for the controller proxy |
|
52 */ |
|
53 const TInt KMMFObjectHandleControllerProxy = -1; |
|
54 |
40 |
55 /** |
41 /** |
56 @publishedAll |
42 @publishedAll |
57 @released |
43 @released |
58 |
44 |
59 Signals that the message is destined for the controller |
|
60 */ |
|
61 const TInt KMMFObjectHandleController = -2; |
|
62 |
|
63 /** |
|
64 @publishedAll |
|
65 @released |
|
66 |
|
67 Null, or invalid, object handle |
45 Null, or invalid, object handle |
68 */ |
46 */ |
69 const TInt KMMFObjectHandleNull = 0; |
47 const TInt KMMFObjectHandleNull = 0; |
70 /** |
|
71 @internalComponent |
|
72 |
|
73 The first valid object handle. The MMF Object container will |
|
74 begin iterating from here when generating object handles. |
|
75 */ |
|
76 const TInt KMMFObjectHandleFirstValid = 1; |
|
77 |
|
78 /** |
|
79 @internalComponent |
|
80 */ |
|
81 const TInt KMmfControllerThreadShutdownTimeout = 20000000; // 20 seconds |
|
82 |
|
83 /** |
|
84 @internalComponent |
|
85 |
|
86 The UID and messages associated with the controller proxy interface. |
|
87 */ |
|
88 const TUid KUidInterfaceMMFControllerProxy = {0x101F77E7}; |
|
89 |
|
90 /** |
|
91 @internalComponent |
|
92 |
|
93 Struct to allow RMMFController to pass several parameters to new CControllerProxyServer threads. |
|
94 */ |
|
95 struct TControllerProxyServerParams |
|
96 { |
|
97 RServer2* iServer; |
|
98 TBool iUsingSharedHeap; |
|
99 }; |
|
100 |
|
101 |
|
102 /** |
|
103 @internalComponent |
|
104 */ |
|
105 enum TMMFControllerProxyMessages |
|
106 { |
|
107 EMMFControllerProxyLoadControllerPluginByUid, |
|
108 EMMFControllerProxyReceiveEvents, |
|
109 EMMFControllerProxyCancelReceiveEvents |
|
110 }; |
|
111 |
|
112 |
48 |
113 /** |
49 /** |
114 @publishedAll |
50 @publishedAll |
115 @released |
51 @released |
116 |
52 |
930 @since 7.0s |
817 @since 7.0s |
931 */ |
818 */ |
932 virtual TInt SendEventToClient(const TMMFEvent& aEvent) = 0; |
819 virtual TInt SendEventToClient(const TMMFEvent& aEvent) = 0; |
933 }; |
820 }; |
934 |
821 |
935 /** |
822 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS |
936 @internalComponent |
823 #include <mmf/common/mmfcontrollerframeworkclasses.h> |
937 |
|
938 Used to hold on to an TMMFMessage so we can complete it asynchronously to |
|
939 send an event to the client. |
|
940 |
|
941 @since 7.0s |
|
942 */ |
|
943 class CMMFEventReceiver : public CBase |
|
944 { |
|
945 public: |
|
946 |
|
947 /** |
|
948 Constructs a new event receiver. |
|
949 |
|
950 This method may leave with one of the system-wide error codes. |
|
951 |
|
952 @param aMessage |
|
953 The message to be completed when an event occurs. |
|
954 |
|
955 @return A pointer to the newly created event receiver. |
|
956 |
|
957 @since 7.0s |
|
958 */ |
|
959 static CMMFEventReceiver* NewL(const TMMFMessage& aMessage); |
|
960 |
|
961 /** |
|
962 Destructor. |
|
963 |
|
964 Completes the message with KErrCancel if the message hasn't already been completed. |
|
965 |
|
966 @since 7.0s |
|
967 */ |
|
968 ~CMMFEventReceiver(); |
|
969 |
|
970 /** |
|
971 Sends an event to the client. |
|
972 |
|
973 @param aEvent |
|
974 The event. |
|
975 |
|
976 @since 7.0s |
|
977 */ |
|
978 void SendEvent(const TMMFEvent& aEvent); |
|
979 private: |
|
980 |
|
981 /** |
|
982 Constructor. |
|
983 |
|
984 @param aMessage |
|
985 The message to be completed when an event occurs. |
|
986 |
|
987 @since 7.0s |
|
988 */ |
|
989 CMMFEventReceiver(const TMMFMessage& aMessage); |
|
990 private: |
|
991 /** |
|
992 The message to be completed when an event occurs. |
|
993 */ |
|
994 TMMFMessage iMessage; |
|
995 }; |
|
996 |
|
997 |
|
998 |
|
999 /** |
|
1000 @internalComponent |
|
1001 |
|
1002 The controller proxy server. |
|
1003 |
|
1004 The main server inside the controller thread, responsible for creating and destroying the single |
|
1005 session used to transmit messages from the client to the server. |
|
1006 |
|
1007 Every controller plugin runs in its own thread, and has its own controller proxy server. |
|
1008 |
|
1009 @since 7.0s |
|
1010 */ |
|
1011 class CMMFControllerProxyServer : public CMmfIpcServer |
|
1012 { |
|
1013 public: |
|
1014 /** |
|
1015 Construct the server. |
|
1016 |
|
1017 This method may leave with one of the system-wide error codes. |
|
1018 |
|
1019 @return The newly created server. |
|
1020 |
|
1021 @since 7.0s |
|
1022 */ |
|
1023 static CMMFControllerProxyServer* NewL(RServer2* aServer2 ); |
|
1024 |
|
1025 /** |
|
1026 Destructor. |
|
1027 |
|
1028 @since 7.0s |
|
1029 */ |
|
1030 ~CMMFControllerProxyServer(); |
|
1031 |
|
1032 /** |
|
1033 Static thread function. |
|
1034 |
|
1035 The address of this function is passed into RThread::Create. |
|
1036 |
|
1037 Unpackages the startup parameters and calls DoStartThreadL(). |
|
1038 |
|
1039 @param aAny |
|
1040 A pointer to the packaged startup parameters. |
|
1041 |
|
1042 @return One of the system-wide error codes. |
|
1043 |
|
1044 @since 7.0s |
|
1045 */ |
|
1046 IMPORT_C static TInt StartThread(TAny* aParam); |
|
1047 |
|
1048 /** |
|
1049 Called by the active scheduler when the ServiceL of the session leaves. |
|
1050 Completes the message with the error and restarts the server. |
|
1051 |
|
1052 @param aError |
|
1053 The error that the session ServiceL left with. |
|
1054 |
|
1055 @return KErrNone |
|
1056 @since 7.0s |
|
1057 */ |
|
1058 TInt RunError(TInt aError); |
|
1059 |
|
1060 /** |
|
1061 Signals that the session has been created. |
|
1062 |
|
1063 Stops the shutdown timer. |
|
1064 |
|
1065 @since 7.0s |
|
1066 */ |
|
1067 void SessionCreated(); |
|
1068 |
|
1069 /** |
|
1070 Signals that the session has been destroyed. |
|
1071 Causes the server to shut down immediately. |
|
1072 |
|
1073 @since 7.0s |
|
1074 */ |
|
1075 void SessionDestroyed(); |
|
1076 private: |
|
1077 |
|
1078 /** |
|
1079 Thread startup code. |
|
1080 |
|
1081 Creates the cleanup stack, installs the active scheduler and creates the server. |
|
1082 Once all this is completed successfully, it signals the success back to the client. |
|
1083 |
|
1084 This function may leave with one of the system-wide error codes. |
|
1085 |
|
1086 @param aParams |
|
1087 Used to signal startup success back to the client. |
|
1088 |
|
1089 @since 7.0s |
|
1090 */ |
|
1091 static void DoStartThreadL(TAny* aParam); |
|
1092 |
|
1093 /** |
|
1094 Creates a new session. Only one session may be created with the ControllerProxyServer. |
|
1095 |
|
1096 This function may leave with one of the system-wide error codes. |
|
1097 |
|
1098 @param aVersion |
|
1099 The version number of the session. |
|
1100 |
|
1101 @return A pointer to the new session. |
|
1102 |
|
1103 @since 7.0s |
|
1104 */ |
|
1105 CMmfIpcSession* NewSessionL(const TVersion& aVersion) const; |
|
1106 |
|
1107 /** |
|
1108 Constructor. |
|
1109 |
|
1110 @since 7.0s |
|
1111 */ |
|
1112 CMMFControllerProxyServer(); |
|
1113 |
|
1114 /** |
|
1115 Second phase constructor. |
|
1116 |
|
1117 @since 7.0s |
|
1118 */ |
|
1119 void ConstructL(RServer2* aServer2); |
|
1120 |
|
1121 /** |
|
1122 Renaming Controller Proxy Server name |
|
1123 |
|
1124 @since 9.2 |
|
1125 */ |
|
1126 static void RenameControllerProxyThread(); |
|
1127 |
|
1128 private: |
|
1129 /** |
|
1130 The timer used to shut down the server in case the client fails to connect a session. |
|
1131 */ |
|
1132 CMMFControllerProxyShutdown* iShutdownTimer; |
|
1133 /** |
|
1134 Indicates whether we have a session connected. Only one session is allowed to connect to the server. |
|
1135 */ |
|
1136 TBool iHaveSession; |
|
1137 }; |
|
1138 |
|
1139 class CMMFController; |
|
1140 |
|
1141 /** |
|
1142 @internalComponent |
|
1143 |
|
1144 The controller proxy session. |
|
1145 |
|
1146 Only one session can be connected to a controller proxy server. |
|
1147 |
|
1148 @since 7.0s |
|
1149 */ |
|
1150 class CMMFControllerProxySession : public CMmfIpcSession, public MAsyncEventHandler |
|
1151 { |
|
1152 public: |
|
1153 |
|
1154 /** |
|
1155 Construct the session. |
|
1156 |
|
1157 This method may leave with one of the system-wide error codes. |
|
1158 |
|
1159 @return The newly created server. |
|
1160 |
|
1161 @since 7.0s |
|
1162 */ |
|
1163 static CMMFControllerProxySession* NewL(); |
|
1164 |
|
1165 /** |
|
1166 Second phase constructor called by the CServer base class. |
|
1167 |
|
1168 This function may leave with one of the system-wide error codes. |
|
1169 |
|
1170 @param aServer |
|
1171 A reference to the server to which this session is attached. |
|
1172 |
|
1173 @since 7.0s |
|
1174 */ |
|
1175 void CreateL(const CMmfIpcServer& aServer); |
|
1176 |
|
1177 /** |
|
1178 Destructor. |
|
1179 */ |
|
1180 ~CMMFControllerProxySession(); |
|
1181 |
|
1182 /** |
|
1183 Called by the CServer baseclass when a request has been made by the client. |
|
1184 |
|
1185 This function may leave with on of the system-wide error codes. If |
|
1186 a leave occurs, the message will be automatically completed by the |
|
1187 RunError() of the Controller Proxy Server. |
|
1188 |
|
1189 @param aMessage |
|
1190 The request to be handled. The controller proxy session will create |
|
1191 a TMMFMessage from this, and pass on the request to the controller |
|
1192 base class to handle. |
|
1193 |
|
1194 @since 7.0s |
|
1195 */ |
|
1196 void ServiceL(const RMmfIpcMessage& aMessage); |
|
1197 |
|
1198 /** |
|
1199 Derived from MAsyncEventHandler. |
|
1200 |
|
1201 @see MAsyncEventHandler |
|
1202 |
|
1203 @since 7.0s |
|
1204 */ |
|
1205 TInt SendEventToClient(const TMMFEvent& aEvent); |
|
1206 private: |
|
1207 /** |
|
1208 Constructor |
|
1209 */ |
|
1210 CMMFControllerProxySession(); |
|
1211 |
|
1212 /** |
|
1213 Handle a request from the client to register to receive events from the controller framework. |
|
1214 |
|
1215 This function may leave with one of the system-wide error codes. |
|
1216 |
|
1217 @param aMessage |
|
1218 The request to be handled. |
|
1219 |
|
1220 @return ETrue if the message is to be completed now, EFalse if the message will be completed |
|
1221 later. |
|
1222 */ |
|
1223 TBool ReceiveEventsL(TMMFMessage& aMessage); |
|
1224 |
|
1225 /** |
|
1226 Handle a request from the client to stop receiving events from the controller framework. |
|
1227 |
|
1228 This function may leave with one of the system-wide error codes. |
|
1229 |
|
1230 @param aMessage |
|
1231 The request to be handled. |
|
1232 |
|
1233 @return ETrue if the message is to be completed now, EFalse if the message will be completed later. |
|
1234 */ |
|
1235 TBool CancelReceiveEvents(TMMFMessage& aMessage); |
|
1236 |
|
1237 /** |
|
1238 Handle a request from the client to load a controller plugin. |
|
1239 |
|
1240 This function may leave with one of the system-wide error codes. |
|
1241 |
|
1242 @param aMessage |
|
1243 The request to be handled. |
|
1244 |
|
1245 @return ETrue if the message is to be completed now, EFalse if the message will be completed later. |
|
1246 */ |
|
1247 TBool LoadControllerL(TMMFMessage& aMessage); |
|
1248 private: |
|
1249 /** |
|
1250 The controller plugin. |
|
1251 */ |
|
1252 CMMFController* iController; |
|
1253 /** |
|
1254 A pointer to the server. |
|
1255 */ |
|
1256 CMMFControllerProxyServer* iServer; |
|
1257 /** |
|
1258 The event receiver. Used to send events to the client. |
|
1259 */ |
|
1260 CMMFEventReceiver* iEventReceiver; |
|
1261 /** |
|
1262 The events waiting to be sent to the client. |
|
1263 */ |
|
1264 RArray<TMMFEvent> iEvents; |
|
1265 }; |
|
1266 |
|
1267 |
|
1268 #endif |
824 #endif |
|
825 |
|
826 #endif |