}
}
+static int __mc_notify_server_updated(const char *server_name, mc_server_state_e state)
+{
+ char *message = NULL;
+ GDBusConnection *bus = NULL;
+ GError *error = NULL;
+ gboolean emmiting = FALSE;
+
+ mc_secure_error("[No-error] __mc_notify_server_updated [%s:%d]", server_name, state);
+
+ mc_retvm_if(server_name == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "server_name is null!");
+
+ bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (!bus) {
+ mc_secure_error("Failed to get gdbus connection : %s", error ? error->message : "none");
+ g_error_free(error);
+ return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
+ }
+
+ message = g_strdup_printf("%s%s%d", server_name, MC_STRING_DELIMITER, state);
+ if (message == NULL) {
+ mc_secure_error("Error in message generation");
+ g_object_unref(bus);
+ return MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY;
+ }
+
+ /* Send the signal */
+ emmiting = g_dbus_connection_emit_signal(
+ bus,
+ NULL,
+ MC_DBUS_PATH,
+ MC_DBUS_UPDATE_INTERFACE,
+ MC_DBUS_SIGNAL_NAME_SERVER_STATE,
+ g_variant_new("(ss)", (const gchar *)"DEF_REQ_ID", message),
+ &error);
+ if (!emmiting) {
+ mc_secure_error("Failed to emit gdbus signal : %s", error ? error->message : "none");
+ g_error_free(error);
+ g_object_unref(bus);
+ MC_SAFE_G_FREE(message);
+ return MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
+ }
+
+ g_object_unref(bus);
+ MC_SAFE_G_FREE(message);
+
+ return MEDIA_CONTROLLER_ERROR_NONE;
+}
+
static int _mc_service_app_dead_handler(int pid, void *data)
{
mc_service_t *_service_data = (mc_service_t *)data;
if (app_data->pid == pid) {
mc_secure_debug("app_dead(appid) : %s", app_data->app_id);
- /* TODO: Delete application from database and
- * send notifiaction to deactivation message via dbus
- */
+ /* TODO: Delete application from database */
+
+ /* Sends notification for deactivated server via dbus */
+ if (app_data->priv_type == MC_PRIV_TYPE_SERVER) {
+ if (MEDIA_CONTROLLER_ERROR_NONE != __mc_notify_server_updated(app_data->app_id, MC_SERVER_STATE_DEACTIVATE))
+ mc_secure_error("Fail to notify deactivated server");
+ }
if (MEDIA_CONTROLLER_ERROR_NONE == __mc_list_remove_item(&_service_data->connected, i)) {
g_connection_cnt--;