Skip to content

Commit

Permalink
[display] Expose blanking pause allowed -policy on dbus. JB#41340
Browse files Browse the repository at this point in the history
Whether blanking pause is allowed or not depends on many variables.
Which makes it difficult for clients to know when they can expect
blanking pause requests they make to have any effect.

Expose the policy decision made within mce on D-Bus - so that:
- clients can track just one boolean state
- no changes are needed later on even if the policy should change

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Mar 16, 2018
1 parent 23e65ae commit 2f4b083
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 1 deletion.
3 changes: 3 additions & 0 deletions mce.conf
Expand Up @@ -115,6 +115,9 @@
<allow send_destination="com.nokia.mce"
send_interface="com.nokia.mce.request"
send_member="req_display_cancel_blanking_pause"/>
<allow send_destination="com.nokia.mce"
send_interface="com.nokia.mce.request"
send_member="get_display_blanking_pause_allowed"/>
<allow send_destination="com.nokia.mce"
send_interface="com.nokia.mce.request"
send_member="get_display_blanking_inhibit"/>
Expand Down
79 changes: 79 additions & 0 deletions modules/display.c
Expand Up @@ -846,7 +846,9 @@ static void mdy_governor_setting_cb(GConfClient *const client, co
* ------------------------------------------------------------------------- */

static gboolean mdy_dbus_send_blanking_pause_status(DBusMessage *const method_call);
static gboolean mdy_dbus_send_blanking_pause_allowed_status(DBusMessage *const method_call);
static gboolean mdy_dbus_handle_blanking_pause_get_req(DBusMessage *const msg);
static gboolean mdy_dbus_handle_blanking_pause_allowed_get_req(DBusMessage *const msg);

static gboolean mdy_dbus_send_blanking_inhibit_status(DBusMessage *const method_call);
static gboolean mdy_dbus_handle_blanking_inhibit_get_req(DBusMessage *const msg);
Expand Down Expand Up @@ -4109,6 +4111,8 @@ static void mdy_blanking_pause_evaluate_allowed(void)

if( blanking_pause_allowed != TRISTATE_TRUE )
mdy_blanking_remove_pause_clients();

mdy_dbus_send_blanking_pause_allowed_status(0);
}
}

Expand Down Expand Up @@ -8729,6 +8733,50 @@ static gboolean mdy_dbus_send_blanking_pause_status(DBusMessage *const method_ca
return TRUE;
}

/** Send a blanking pause allowed reply or signal
*
* @param method_call A DBusMessage to reply to; or NULL to send signal
*
* @return TRUE
*/
static gboolean mdy_dbus_send_blanking_pause_allowed_status(DBusMessage *const method_call)
{
static int prev = -1;
bool curr = blanking_pause_allowed;
dbus_bool_t data = curr;
DBusMessage *msg = 0;

if( method_call ) {
msg = dbus_new_method_reply(method_call);
mce_log(LL_DEBUG, "Sending blanking pause allowed reply: %s",
data ? "true" : "false");
}
else if( prev == curr ) {
/* Omit no-change signals */
goto EXIT;
}
else {
prev = curr;
msg = dbus_new_signal(MCE_SIGNAL_PATH, MCE_SIGNAL_IF,
MCE_PREVENT_BLANK_ALLOWED_SIG);
mce_log(LL_DEVEL, "Sending blanking pause allowed signal: %s",
data ? "true" : "false");
}

if( !dbus_message_append_args(msg,
DBUS_TYPE_BOOLEAN, &data,
DBUS_TYPE_INVALID) )
goto EXIT;

dbus_send_message(msg), msg = 0;

EXIT:
if( msg )
dbus_message_unref(msg);

return TRUE;
}

/** D-Bus callback for the get blanking pause status method call
*
* @param msg The D-Bus message
Expand All @@ -8745,6 +8793,22 @@ static gboolean mdy_dbus_handle_blanking_pause_get_req(DBusMessage *const msg)
return TRUE;
}

/** D-Bus callback for the get blanking pause allowed method call
*
* @param msg The D-Bus message
*
* @return TRUE
*/
static gboolean mdy_dbus_handle_blanking_pause_allowed_get_req(DBusMessage *const msg)
{
mce_log(LL_DEVEL, "Received blanking pause allowed get request from %s",
mce_dbus_get_message_sender_ident(msg));

mdy_dbus_send_blanking_pause_allowed_status(msg);

return TRUE;
}

/** Send a blanking inhibit status reply or signal
*
* @param method_call A DBusMessage to reply to; or NULL to send signal
Expand Down Expand Up @@ -9624,6 +9688,13 @@ static mce_dbus_handler_t mdy_dbus_handlers[] =
.args =
" <arg name=\"blanking_pause\" type=\"s\"/>\n"
},
{
.interface = MCE_SIGNAL_IF,
.name = MCE_PREVENT_BLANK_ALLOWED_SIG,
.type = DBUS_MESSAGE_TYPE_SIGNAL,
.args =
" <arg name=\"allowed\" type=\"b\"/>\n"
},
{
.interface = MCE_SIGNAL_IF,
.name = MCE_BLANKING_INHIBIT_SIG,
Expand Down Expand Up @@ -9668,6 +9739,14 @@ static mce_dbus_handler_t mdy_dbus_handlers[] =
.args =
" <arg direction=\"out\" name=\"blanking_pause\" type=\"s\"/>\n"
},
{
.interface = MCE_REQUEST_IF,
.name = MCE_PREVENT_BLANK_ALLOWED_GET,
.type = DBUS_MESSAGE_TYPE_METHOD_CALL,
.callback = mdy_dbus_handle_blanking_pause_allowed_get_req,
.args =
" <arg direction=\"out\" name=\"allowed\" type=\"b\"/>\n"
},
{
.interface = MCE_REQUEST_IF,
.name = MCE_BLANKING_INHIBIT_GET,
Expand Down
2 changes: 1 addition & 1 deletion rpm/mce.spec
Expand Up @@ -19,7 +19,7 @@ BuildRequires: pkgconfig(dbus-glib-1)
BuildRequires: pkgconfig(dsme) >= 0.58
BuildRequires: pkgconfig(libiphb)
BuildRequires: pkgconfig(glib-2.0) >= 2.36.0
BuildRequires: pkgconfig(mce) >= 1.24.0
BuildRequires: pkgconfig(mce) >= 1.25.0
BuildRequires: pkgconfig(libngf0) >= 0.24
BuildRequires: pkgconfig(libsystemd-daemon)
BuildRequires: kernel-headers >= 2.6.32
Expand Down

0 comments on commit 2f4b083

Please sign in to comment.