@@ -27,9 +27,10 @@ RFCURLObserver* RFCURLObserver::getInstance() {
27
27
}
28
28
29
29
30
- void RFCURLObserver::triggerRFC (TTSConfiguration *config)
30
+ void RFCURLObserver::triggerRFC (TTSConfiguration *config,std::string token )
31
31
{
32
32
m_defaultConfig = config;
33
+ m_token = token;
33
34
fetchURLFromConfig ();
34
35
std::thread notificationThread (&RFCURLObserver::registerNotification, this );
35
36
notificationThread.detach (); // Detach the thread to run independently
@@ -49,65 +50,9 @@ void RFCURLObserver::fetchURLFromConfig() {
49
50
}
50
51
}
51
52
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
-
102
53
void RFCURLObserver::registerNotification () {
103
54
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);
111
56
while (!m_eventRegistered) {
112
57
if (m_systemService->Subscribe <JsonObject>(3000 , " onDeviceMgtUpdateReceived" ,
113
58
&RFCURLObserver::onDeviceMgtUpdateReceivedHandler, this ) == Core::ERROR_NONE) {
0 commit comments