/
shutdownfeedback.c
90 lines (70 loc) · 2.38 KB
/
shutdownfeedback.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/**
@file shutdownfeedback.c
Play vibra when shutting down
<p>
Copyright (c) 2014 - 2020 Jolla Ltd.
Copyright (c) 2020 Open Mobile Platform LLC.
@author Pekka Lundstrom <pekka.lundstrom@jolla.com>
@author Simo Piiroinen <simo.piiroinen@jollamobile.com>
This file is part of Dsme.
Dsme is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License
version 2.1 as published by the Free Software Foundation.
Dsme is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with Dsme. If not, see <http://www.gnu.org/licenses/>.
*/
#include "dbusproxy.h"
#include "dsme_dbus.h"
#include "../include/dsme/modules.h"
#include "../include/dsme/logging.h"
#include <dsme/state.h>
#include <dsme/protocol.h>
#include "vibrafeedback.h"
#define PFIX "shutdownfeedback: "
static const char pwroff_event_name[] = "pwroff";
DSME_HANDLER(DSM_MSGTYPE_STATE_CHANGE_IND, conn, msg)
{
if ((msg->state == DSME_STATE_SHUTDOWN) ||
(msg->state == DSME_STATE_REBOOT)) {
//dsme_log(LOG_DEBUG, PFIX"shutdown/reboot state received");
dsme_play_vibra(pwroff_event_name);
}
}
DSME_HANDLER(DSM_MSGTYPE_REBOOT_REQ, conn, msg)
{
// dsme_log(LOG_DEBUG, PFIX"reboot reques received");
}
DSME_HANDLER(DSM_MSGTYPE_SHUTDOWN_REQ, conn, msg)
{
//dsme_log(LOG_DEBUG, PFIX"shutdown reques received");
}
DSME_HANDLER(DSM_MSGTYPE_DBUS_CONNECTED, conn, msg)
{
dsme_log(LOG_INFO, PFIX"DBUS_CONNECTED");
dsme_ini_vibrafeedback();
}
DSME_HANDLER(DSM_MSGTYPE_DBUS_DISCONNECT, conn, msg)
{
dsme_log(LOG_INFO, PFIX"DBUS_DISCONNECT");
}
module_fn_info_t message_handlers[] = {
DSME_HANDLER_BINDING(DSM_MSGTYPE_SHUTDOWN_REQ),
DSME_HANDLER_BINDING(DSM_MSGTYPE_REBOOT_REQ),
DSME_HANDLER_BINDING(DSM_MSGTYPE_STATE_CHANGE_IND),
DSME_HANDLER_BINDING(DSM_MSGTYPE_DBUS_CONNECTED),
DSME_HANDLER_BINDING(DSM_MSGTYPE_DBUS_DISCONNECT),
{0}
};
void module_init(module_t* handle)
{
dsme_log(LOG_DEBUG, "shutdownfeedback.so loaded");
}
void module_fini(void)
{
dsme_fini_vibrafeedback();
dsme_log(LOG_DEBUG, "shutdownfeedback.so unloaded");
}