RDK Documentation (Open Sourced RDK Components)
lighteningcastservice.cpp
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2017 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 #include "lighteningcastservice.h"
21 
22 
23 rtError rtLighteningCastRemoteObject::applicationStateChanged(const rtObjectRef& params) {
24  printf("rtLighteningCastRemoteObject::applicationStateChanged \n");
25  rtObjectRef AppObj = new rtMapObject;
26  AppObj = params;
27  rtString app, id, state, error;
28  AppObj.get("applicationName",app);
29 // AppObj.get("applicationId",id);
30  AppObj.get("state",state);
31 // AppObj.get("error",error);
32  printf("AppName : %s\nState : %s\n",app.cString(),state.cString());
33  return RT_OK;
34 }
35 
36 
37 rtCastError rtLighteningCastRemoteObject::launchApplication(const char* appName, const char* args) {
38  printf("rtLighteningCastRemoteObject::launchApplication App:%s args:%s\n",appName,args);
39  rtObjectRef AppObj = new rtMapObject;
40  AppObj.set("applicationName",appName);
41  AppObj.set("parameters",args);
42 
43  rtCastError error(RT_OK,CAST_ERROR_NONE);
44  RTCAST_ERROR_RT(error) = notify("onApplicationLaunchRequest",AppObj);
45  return error;
46 }
47 
48 rtCastError rtLighteningCastRemoteObject::stopApplication(const char* appName, const char* appID) {
49  printf("rtLighteningCastRemoteObject::stopApplication App:%s ID:%s\n",appName,appID);
50  rtObjectRef AppObj = new rtMapObject;
51  AppObj.set("applicationName",appName);
52  if(appID != NULL)
53  AppObj.set("applicationId",appID);
54 
55  rtCastError error(RT_OK,CAST_ERROR_NONE);
56  RTCAST_ERROR_RT(error) = notify("onApplicationStopRequest",AppObj);
57  return error;
58 }
59 
60 rtCastError rtLighteningCastRemoteObject::getApplicationState(const char* appName, const char* appID) {
61  printf("rtLighteningCastRemoteObject::getApplicationState App:%s ID:%s\n",appName,appID);
62  rtObjectRef AppObj = new rtMapObject;
63  AppObj.set("applicationName",appName);
64  if(appID != NULL)
65  AppObj.set("applicationId",appID);
66 
67  rtCastError error(RT_OK,CAST_ERROR_NONE);
68  RTCAST_ERROR_RT(error) = notify("onApplicationStateRequest",AppObj);
69  return error;
70 }
71 
72 
73 
74 rtDefineObject(rtCastRemoteObject, rtAbstractService);
75 rtDefineMethod(rtCastRemoteObject, applicationStateChanged);
rtCastError
Definition: rtcast.hpp:25
rtAbstractService
Definition: rtabstractservice.h:24
rtCastRemoteObject
Definition: rtcast.hpp:36