Skip to content

Commit

Permalink
Merge branch 'main' into main_XRE-15671
Browse files Browse the repository at this point in the history
  • Loading branch information
bobseamon authored Sep 10, 2020
2 parents 84d1cb7 + 424dc12 commit 039c987
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 4 deletions.
11 changes: 11 additions & 0 deletions ControlService/ControlService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ namespace WPEFramework {
ControlService::_instance = this;

registerMethod("getApiVersionNumber", &ControlService::getApiVersionNumber, this);
registerMethod("getQuirks", &ControlService::getQuirks, this);

registerMethod("getAllRemoteData", &ControlService::getAllRemoteDataWrapper, this);
registerMethod("getSingleRemoteData", &ControlService::getSingleRemoteDataWrapper, this);
Expand Down Expand Up @@ -722,6 +723,15 @@ namespace WPEFramework {
returnResponse(true);
}

uint32_t ControlService::getQuirks(const JsonObject& parameters, JsonObject& response)
{
LOGINFOMETHOD();
JsonArray array;
array.Add("DELIA-43686");
response["quirks"] = array;
returnResponse(true);
}

uint32_t ControlService::getAllRemoteDataWrapper(const JsonObject& parameters, JsonObject& response)
{
LOGINFOMETHOD();
Expand Down Expand Up @@ -1953,6 +1963,7 @@ namespace WPEFramework {
remoteInfo["linkQuality"] = JsonValue((int)ctrlStatus.status.link_quality);
remoteInfo["bHasCheckedIn"] = JsonValue((bool)ctrlStatus.status.checkin_for_device_update);
remoteInfo["bIrdbDownloadSupported"] = JsonValue((bool)ctrlStatus.status.ir_db_code_download_supported);
remoteInfo["securityType"] = JsonValue((int)ctrlStatus.status.security_type);

remoteInfo["bHasBattery"] = JsonValue((bool)ctrlStatus.status.has_battery);
remoteInfo["batteryChangedTimestamp"] = JsonValue((long long)(ctrlStatus.status.time_battery_changed * 1000LL));
Expand Down
1 change: 1 addition & 0 deletions ControlService/ControlService.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ namespace WPEFramework {

//Begin methods
uint32_t getApiVersionNumber(const JsonObject& parameters, JsonObject& response);
uint32_t getQuirks(const JsonObject& parameters, JsonObject& response);

uint32_t getAllRemoteDataWrapper(const JsonObject& parameters, JsonObject& response);
uint32_t getSingleRemoteDataWrapper(const JsonObject& parameters, JsonObject& response);
Expand Down
57 changes: 55 additions & 2 deletions ControlService/test/controlSvcTestClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <stdio.h>
#include <unistd.h>

#define SYSSRV_CALLSIGN "org.rdk.ControlService"
#define SYSSRV_CALLSIGN "org.rdk.ControlService.1"
#define SERVER_DETAILS "127.0.0.1:9998"

using namespace std;
Expand Down Expand Up @@ -318,12 +318,65 @@ int main(int argc, char** argv)

Core::SystemInfo::SetEnvironment(_T("THUNDER_ACCESS"), (_T(SERVER_DETAILS)));

// Security Token
std::cout << "Retrieving security token" << std::endl;
std::string sToken;

FILE *pSecurity = popen("/usr/bin/WPEFrameworkSecurityUtility", "r");
if(pSecurity) {
JsonObject pSecurityJson;
std::string pSecurityOutput;
int pSecurityOutputTrimIndex;
std::array<char, 256> pSecurityBuffer;

while(fgets(pSecurityBuffer.data(), 256, pSecurity) != NULL) {
pSecurityOutput += pSecurityBuffer.data();
}
pclose(pSecurity);

pSecurityOutputTrimIndex = pSecurityOutput.find('{');
if(pSecurityOutputTrimIndex == std::string::npos) {
std::cout << "Security Utility returned unexpected output" << std::endl;
} else {
if(pSecurityOutputTrimIndex > 0) {
std::cout << "Trimming output from Security Utility" << std::endl;
pSecurityOutput = pSecurityOutput.substr(pSecurityOutputTrimIndex);
}
pSecurityJson.FromString(pSecurityOutput);
if(pSecurityJson["success"].Boolean() == true) {
std::cout << "Security Token retrieved successfully!" << std::endl;
sToken = "token=" + pSecurityJson["token"].String();
} else {
std::cout << "Security Token retrieval failed!" << std::endl;
}
}
} else {
std::cout << "Failed to open security utility" << std::endl;
}
// End Security Token

std::cout << "Using callsign: " << SYSSRV_CALLSIGN << std::endl;

if (NULL == remoteObject) {
remoteObject = new JSONRPC::LinkType<Core::JSON::IElement>(_T(SYSSRV_CALLSIGN), _T(""));
remoteObject = new JSONRPC::Client(_T(SYSSRV_CALLSIGN), _T(""), false, sToken);
if (NULL == remoteObject) {
std::cout << "JSONRPC::Client initialization failed" << std::endl;

} else {

{
// Create a controller client
static auto& controllerClient = *new WPEFramework::JSONRPC::LinkType<WPEFramework::Core::JSON::IElement>("", "", false, sToken);
// In case the plugin isn't activated already, try to start it, BEFORE registering for the events!
string strres;
JsonObject params;
params["callsign"] = SYSSRV_CALLSIGN;
JsonObject result;
ret = controllerClient.Invoke(2000, "activate", params, result);
result.ToString(strres);
std::cout<<"\nstartup result : "<< strres <<"\n";
}

/* Register handlers for Event reception. */
std::cout << "\nSubscribing to event handlers\n" << std::endl;
if (remoteObject->Subscribe<Core::JSON::String>(1000, _T("onControl"),
Expand Down
57 changes: 55 additions & 2 deletions RemoteActionMapping/test/ramTestClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

#include <vector>

#define SYSSRV_CALLSIGN "org.rdk.RemoteActionMapping"
#define SYSSRV_CALLSIGN "org.rdk.RemoteActionMapping.1"
#define SERVER_DETAILS "127.0.0.1:9998"

using namespace std;
Expand Down Expand Up @@ -501,12 +501,65 @@ int main(int argc, char** argv)

Core::SystemInfo::SetEnvironment(_T("THUNDER_ACCESS"), (_T(SERVER_DETAILS)));

// Security Token
std::cout << "Retrieving security token" << std::endl;
std::string sToken;

FILE *pSecurity = popen("/usr/bin/WPEFrameworkSecurityUtility", "r");
if(pSecurity) {
JsonObject pSecurityJson;
std::string pSecurityOutput;
int pSecurityOutputTrimIndex;
std::array<char, 256> pSecurityBuffer;

while(fgets(pSecurityBuffer.data(), 256, pSecurity) != NULL) {
pSecurityOutput += pSecurityBuffer.data();
}
pclose(pSecurity);

pSecurityOutputTrimIndex = pSecurityOutput.find('{');
if(pSecurityOutputTrimIndex == std::string::npos) {
std::cout << "Security Utility returned unexpected output" << std::endl;
} else {
if(pSecurityOutputTrimIndex > 0) {
std::cout << "Trimming output from Security Utility" << std::endl;
pSecurityOutput = pSecurityOutput.substr(pSecurityOutputTrimIndex);
}
pSecurityJson.FromString(pSecurityOutput);
if(pSecurityJson["success"].Boolean() == true) {
std::cout << "Security Token retrieved successfully!" << std::endl;
sToken = "token=" + pSecurityJson["token"].String();
} else {
std::cout << "Security Token retrieval failed!" << std::endl;
}
}
} else {
std::cout << "Failed to open security utility" << std::endl;
}
// End Security Token

std::cout << "Using callsign: " << SYSSRV_CALLSIGN << std::endl;

if (NULL == remoteObject) {
remoteObject = new JSONRPC::LinkType<Core::JSON::IElement>(_T(SYSSRV_CALLSIGN), _T(""));
remoteObject = new JSONRPC::Client(_T(SYSSRV_CALLSIGN), _T(""), false, sToken);
if (NULL == remoteObject) {
std::cout << "JSONRPC::Client initialization failed" << std::endl;

} else {

{
// Create a controller client
static auto& controllerClient = *new WPEFramework::JSONRPC::LinkType<WPEFramework::Core::JSON::IElement>("", "", false, sToken);
// In case the plugin isn't activated already, try to start it, BEFORE registering for the events!
string strres;
JsonObject params;
params["callsign"] = SYSSRV_CALLSIGN;
JsonObject result;
ret = controllerClient.Invoke(2000, "activate", params, result);
result.ToString(strres);
std::cout<<"\nstartup result : "<< strres <<"\n";
}

/* Register handlers for Event reception. */
std::cout << "\nSubscribing to event handlers\n" << std::endl;
if (remoteObject->Subscribe<Core::JSON::String>(1000, _T("onIRCodeLoad"),
Expand Down

0 comments on commit 039c987

Please sign in to comment.