fc642eb63ed89b61d83875e88f1d8c2997a51517
[platform/core/system/deviced.git] / plugins / iot-headless / display / core.c
1 /*
2  * deviced
3  *
4  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the License);
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 #include <shared/common.h>
20 #include <shared/devices.h>
21 #include <libsyscommon/libgdbus.h>
22
23 static GVariant *dbus_lockstate(GDBusConnection *conn,
24         const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
25         GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
26 {
27         return g_variant_new("(i)", 0);
28 }
29
30 static GVariant *dbus_unlockstate(GDBusConnection *conn,
31         const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
32         GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
33 {
34         return g_variant_new("(i)", 0);
35 }
36
37 static const dbus_method_s dbus_methods[] = {
38         { "lockstate",     "sssi",   "i", dbus_lockstate },
39         { "unlockstate",     "ss",   "i", dbus_unlockstate },
40 };
41
42 static const dbus_interface_u dbus_interface = {
43         .oh = NULL,
44         .name = DEVICED_INTERFACE_DISPLAY,
45         .methods = dbus_methods,
46         .nr_methods = ARRAY_SIZE(dbus_methods),
47 };
48
49 static void display_init(void *data)
50 {
51         gdbus_add_object(NULL, DEVICED_PATH_DISPLAY, &dbus_interface);
52 }
53
54 static const struct device_ops display_device_ops = {
55         .priority = DEVICE_PRIORITY_HIGH,
56         DECLARE_NAME_LEN("display"),
57         .init     = display_init,
58 };
59
60 DEVICE_OPS_REGISTER(&display_device_ops)