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