xref: /aosp_15_r20/external/autotest/client/cros/cellular/pseudomodem/messaging.py (revision 9c5db1993ded3edbeafc8092d69fe5de2ee02df7)
1# Lint as: python2, python3
2# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6import dbus
7import dbus.service
8
9from autotest_lib.client.cros.cellular.pseudomodem import utils
10
11from autotest_lib.client.cros.cellular import mm1_constants
12
13# TODO(armansito): Have this class implement all Messaging methods
14# and make Modems have a reference to an instance of Messaging
15# OR have Modem implement this
16
17class Messaging(dbus.service.Interface):
18    """
19    Python binding for the org.freedesktop.ModemManager1.Modem.Messaging
20    interface. The Messaging interfaces handles sending SMS messages and
21    notification of new incoming messages.
22
23    """
24
25    @utils.log_dbus_method()
26    @dbus.service.method(mm1_constants.I_MODEM_MESSAGING, out_signature='ao')
27    def List(self):
28        """
29        Retrieves all SMS messages.
30        This method should only be used once and subsequent information
31        retrieved either by listening for the "Added" and "Completed" signals,
32        or by querying the specific SMS object of interest.
33
34        @returns: The list of SMS object paths.
35
36        """
37        raise NotImplementedError()
38
39
40    @utils.log_dbus_method()
41    @dbus.service.method(mm1_constants.I_MODEM_MESSAGING, in_signature='o')
42    def Delete(self, path):
43        """
44        Deletes an SMS message.
45
46        @param path: The object path of the SMS to delete.
47        Emits:
48            Deleted
49
50        """
51        raise NotImplementedError()
52
53
54    @utils.log_dbus_method()
55    @dbus.service.method(mm1_constants.I_MODEM_MESSAGING,
56                         in_signature='a{sv}', out_signature='o')
57    def Create(self, properties):
58        """
59        Creates a new message object. The 'Number' and 'Text' properties are
60        mandatory, others are optional. If the SMSC is not specified and one is
61        required, the default SMSC is used.
62
63        @param properties: Message properties from the SMS D-Bus interface.
64        @returns: The object path of the new message object.
65
66        """
67        raise NotImplementedError()
68
69
70    @dbus.service.signal(mm1_constants.I_MODEM_MESSAGING, signature='ob')
71    def Added(self, path, received):
72        """
73        Emitted when any part of a new SMS has been received or added (but not
74        for subsequent parts, if any). For messages received from the network,
75        not all parts may have been received and the message may not be
76        complete.
77
78        Check the 'State' property to determine if the message is complete. The
79        "Completed" signal will also be emitted when the message is complete.
80
81        @param path: Object path of the new SMS.
82        @param received: True if the message was received from the network, as
83                         opposed to being added locally.
84
85        """
86        raise NotImplementedError()
87
88
89    @dbus.service.signal(mm1_constants.I_MODEM_MESSAGING, signature='o')
90    def Completed(self, path):
91        """
92        Emitted when the complete-ness status of an SMS message changes.
93
94        An SMS may not necessarily be complete when the first part is received;
95        this signal will be emitted when all parts have been received, even for
96        single-part messages.
97
98        @param path: Object path of the new SMS.
99
100        """
101        raise NotImplementedError()
102
103
104    @dbus.service.signal(mm1_constants.I_MODEM_MESSAGING, signature='o')
105    def Deleted(self, path):
106        """
107        Emitted when a message has been deleted.
108
109        @param path: Object path of the now deleted SMS.
110
111        """
112        raise NotImplementedError()
113