@@ -27,9 +27,10 @@ RFCURLObserver* RFCURLObserver::getInstance() {
2727}
2828
2929
30- void RFCURLObserver::triggerRFC (TTSConfiguration *config)
30+ void RFCURLObserver::triggerRFC (TTSConfiguration *config,std::string token )
3131{
3232 m_defaultConfig = config;
33+ m_token = token;
3334 fetchURLFromConfig ();
3435 std::thread notificationThread (&RFCURLObserver::registerNotification, this );
3536 notificationThread.detach (); // Detach the thread to run independently
@@ -49,65 +50,9 @@ void RFCURLObserver::fetchURLFromConfig() {
4950 }
5051}
5152
52- string RFCURLObserver::getSecurityToken () {
53- std::string token = " token=" ;
54- int tokenLength = 0 ;
55- unsigned char buffer[MAX_SECURITY_TOKEN_SIZE] = {0 };
56- static std::string endpoint;
57-
58- if (endpoint.empty ()) {
59- Core::SystemInfo::GetEnvironment (_T (" THUNDER_ACCESS" ), endpoint);
60- TTSLOG_INFO (" Thunder RPC Endpoint read from env - %s" , endpoint.c_str ());
61- }
62-
63- if (endpoint.empty ()) {
64- Core::File file (" /etc/WPEFramework/config.json" );
65- if (file.Open (true )) {
66- JsonObject config;
67- if (config.IElement ::FromFile (file)) {
68- Core::JSON::String port = config.Get (" port" );
69- Core::JSON::String binding = config.Get (" binding" );
70- if (!binding.Value ().empty () && !port.Value ().empty ())
71- endpoint = binding.Value () + " :" + port.Value ();
72- }
73- file.Close ();
74- }
75- if (endpoint.empty ())
76- endpoint = _T (" 127.0.0.1:9998" );
77-
78- TTSLOG_INFO (" Thunder RPC Endpoint read from config file - %s" , endpoint.c_str ());
79- Core::SystemInfo::SetEnvironment (_T (" THUNDER_ACCESS" ), endpoint);
80- }
81-
82- string payload = " http://localhost" ;
83- if (payload.empty ()) {
84- tokenLength = GetSecurityToken (sizeof (buffer), buffer);
85- } else {
86- int buffLength = std::min (sizeof (buffer), payload.length ());
87- ::memcpy (buffer, payload.c_str(), buffLength);
88- tokenLength = GetToken (sizeof (buffer), buffLength, buffer);
89- }
90-
91- if (tokenLength > 0 ) {
92- token.append ((char *)buffer);
93- } else {
94- token.clear ();
95- }
96-
97- TTSLOG_INFO (" Thunder token - %s" , token.empty () ? " " : token.c_str ());
98- return token;
99- }
100-
101-
10253void RFCURLObserver::registerNotification () {
10354 if (m_systemService == nullptr && !m_eventRegistered) {
104- std::string token = getSecurityToken ();
105- if (token.empty ()) {
106- m_systemService = new WPEFramework::JSONRPC::LinkType<Core::JSON::IElement>(_T (SYSTEMSERVICE_CALLSIGN_VER)," " );
107- } else {
108- m_systemService = new WPEFramework::JSONRPC::LinkType<Core::JSON::IElement>(_T (SYSTEMSERVICE_CALLSIGN_VER)," " , false , token);
109- }
110-
55+ m_systemService = new WPEFramework::JSONRPC::LinkType<Core::JSON::IElement>(_T (SYSTEMSERVICE_CALLSIGN_VER)," " , false , m_token);
11156 while (!m_eventRegistered) {
11257 if (m_systemService->Subscribe <JsonObject>(3000 , " onDeviceMgtUpdateReceived" ,
11358 &RFCURLObserver::onDeviceMgtUpdateReceivedHandler, this ) == Core::ERROR_NONE) {
0 commit comments