Skip to content

Commit 9945e0f

Browse files
committed
RDKEMW-1061: RDK-E Add COMRPC
Reason for change: Create the interface file for HdmiCecSource Test Procedure: Risks: low Priority: P1 Signed-off-by:Hayden Gfeller [email protected]
1 parent 13f2766 commit 9945e0f

File tree

4 files changed

+59
-13
lines changed

4 files changed

+59
-13
lines changed

HdmiCecSource/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
17+
1718
set(PLUGIN_NAME HdmiCecSource)
1819
set(MODULE_NAME ${NAMESPACE}${PLUGIN_NAME})
1920
set(PLUGIN_IMPLEMENTATION ${MODULE_NAME}Implementation)

HdmiCecSource/HdmiCecSource.cpp

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,9 @@ namespace WPEFramework
5151
{
5252
SERVICE_REGISTRATION(HdmiCecSource, API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH);
5353

54-
HdmiCecSource* HdmiCecSource::_instance = nullptr;
55-
5654
const string HdmiCecSource::Initialize(PluginHost::IShell *service)
5755
{
58-
LOGWARN("Initlaizing CEC_2");
56+
LOGWARN("Initlaizing HdmiCecSource plugin \n");
5957

6058
profileType = searchRdkProfile();
6159

@@ -65,36 +63,47 @@ namespace WPEFramework
6563
return (std::string("Not supported"));
6664
}
6765

68-
string msg;
66+
string msg = "";
67+
68+
ASSERT(nullptr != service);
69+
ASSERT(nullptr == _service);
70+
ASSERT(nullptr == _hdmiCecSource);
71+
ASSERT(0 == _connectionId);
72+
73+
6974
_service = service;
7075
_service->AddRef();
7176
_service->Register(&_notification);
72-
HdmiCecSource::_instance = this;
7377
_hdmiCecSource = _service->Root<Exchange::IHdmiCecSource>(_connectionId, 5000, _T("HdmiCecSourceImplementation"));
7478

7579
if(nullptr != _hdmiCecSource)
7680
{
7781
_hdmiCecSource->Configure(service);
7882
_hdmiCecSource->Register(&_notification);
7983
Exchange::JHdmiCecSource::Register(*this, _hdmiCecSource);
80-
msg = "HdmiCecSource plugin is available";
8184
LOGINFO("HdmiCecSource plugin is available. Successfully activated HdmiCecSource Plugin");
8285
}
8386
else
8487
{
8588
msg = "HdmiCecSource plugin is not available";
8689
LOGINFO("HdmiCecSource plugin is not available. Failed to activate HdmiCecSource Plugin");
87-
return msg;
90+
}
91+
92+
if (0 != msg.length())
93+
{
94+
Deinitialize(service);
8895
}
8996

9097
// On success return empty, to indicate there is no error text.
9198
return msg;
9299
}
93100

94101

95-
void HdmiCecSource::Deinitialize(PluginHost::IShell* /* service */)
102+
void HdmiCecSource::Deinitialize(PluginHost::IShell* service)
96103
{
97-
LOGWARN("Deinitialize CEC_2");
104+
LOGWARN("Deinitialize HdmiCecSource plugin \n");
105+
106+
ASSERT(nullptr != service);
98107

99108

100109
profileType = searchRdkProfile();
@@ -116,12 +125,48 @@ namespace WPEFramework
116125
}
117126
HdmiCecSource::_notification.OnActiveSourceStatusUpdated(false);
118127

119-
HdmiCecSource::_instance = nullptr;
128+
if(nullptr != _hdmiCecSource)
129+
{
130+
_hdmiCecSource->Unregister(&_notification);
131+
Exchange::JHdmiCecSource::Unregister(*this, _hdmiCecSource);
132+
_hdmiCecSource->Release();
133+
_hdmiCecSource = nullptr;
134+
135+
RPC::IRemoteConnection* connection = _service->RemoteConnection(_connectionId);
136+
if (connection != nullptr)
137+
{
138+
try{
139+
connection->Terminate();
140+
}
141+
catch(const std::exception& e)
142+
{
143+
std::string errorMessage = "Failed to terminate connection: ";
144+
errorMessage += e.what();
145+
LOGWARN("%s",errorMessage.c_str());
146+
}
147+
148+
connection->Release();
149+
}
150+
}
151+
152+
_connectionId = 0;
153+
_service->Release();
154+
_service = nullptr;
155+
LOGINFO("HdmiCecSource plugin is deactivated. Successfully deactivated HdmiCecSource Plugin");
120156
}
121157

122158
string HdmiCecSource::Information() const
123159
{
124-
return(string());
160+
return("This HdmiCecSource PLugin Facilitates the HDMI CEC Source Control");
161+
}
162+
163+
void HdmiCecSource::Deactivated(RPC::IRemoteConnection* connection)
164+
{
165+
if (connection->Id() == _connectionId)
166+
{
167+
ASSERT(_service != nullptr);
168+
Core::IWorkerPool::Instance().Submit(PluginHost::IShell::Job::Create(_service, PluginHost::IShell::DEACTIVATED, PluginHost::IShell::FAILURE));
169+
}
125170
}
126171

127172
} // namespace Plugin

HdmiCecSource/HdmiCecSource.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ namespace WPEFramework {
143143
// We do not allow this plugin to be copied !!
144144
HdmiCecSource(const HdmiCecSource&) = delete;
145145
HdmiCecSource& operator=(const HdmiCecSource&) = delete;
146-
static HdmiCecSource* _instance;
147146

148147
HdmiCecSource()
149148
: PluginHost::IPlugin()

HdmiCecSource/HdmiCecSourceImplementation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,7 @@ namespace WPEFramework
13101310
}
13111311
}
13121312

1313-
uint32_t HdmiCecSourceImplementation::GetDeviceList(IHdmiCecSourceDeviceListIterator*& deviceList, bool &success)
1313+
uint32_t HdmiCecSourceImplementation::GetDeviceList(uint32_t &numberofdevices, IHdmiCecSourceDeviceListIterator*& deviceList, bool &success)
13141314
{ //sample servicemanager response:
13151315
std::vector<Exchange::IHdmiCecSource::HdmiCecSourceDevices> localDevices;
13161316
Exchange::IHdmiCecSource::HdmiCecSourceDevices actual_hdmicecdevices = {0};
@@ -1320,6 +1320,7 @@ namespace WPEFramework
13201320

13211321
success = true;
13221322
LOGINFO("getDeviceListWrapper m_numberOfDevices :%d \n", HdmiCecSourceImplementation::_instance->m_numberOfDevices);
1323+
numberofdevices = HdmiCecSourceImplementation::_instance->m_numberOfDevices;
13231324
try
13241325
{
13251326
int i = 0;

0 commit comments

Comments
 (0)