sdbus-modemmanager 1.0.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of sdbus-modemmanager might be problematic. Click here for more details.

@@ -0,0 +1,130 @@
1
+ from typing import List, Tuple
2
+
3
+ from sdbus import DbusInterfaceCommonAsync, dbus_method_async, dbus_property_async
4
+
5
+
6
+ class MMSimInterfaceAsync(DbusInterfaceCommonAsync, interface_name='org.freedesktop.ModemManager1.Sim'):
7
+ """The SIM interface handles communication with SIM, USIM, and RUIM (CDMA SIM) cards."""
8
+
9
+ @dbus_method_async(input_signature='s')
10
+ async def send_pin(self, pin: str) -> None:
11
+ """
12
+ Send the PIN to unlock the SIM card.
13
+
14
+ :param pin: A string containing the PIN code.
15
+ """
16
+ raise NotImplementedError
17
+
18
+ @dbus_method_async(input_signature='ss')
19
+ async def send_puk(self, puk: str, pin: str) -> None:
20
+ """
21
+ Send the PUK and a new PIN to unlock the SIM card.
22
+
23
+ :param puk: A string containing the PUK code.
24
+ :param pin: A string containing the PIN code.
25
+ """
26
+ raise NotImplementedError
27
+
28
+ @dbus_method_async(input_signature='sb')
29
+ async def enable_pin(self, pin: str, enable: bool) -> None:
30
+ """
31
+ Enable or disable the PIN checking.
32
+
33
+ :param pin: A string containing the PIN code.
34
+ :param enable: TRUE to enable PIN checking, FALSE otherwise.
35
+ """
36
+ raise NotImplementedError
37
+
38
+ @dbus_method_async(input_signature='ss')
39
+ async def change_pin(self, old_pin: str, new_pin: str) -> None:
40
+ """
41
+ Change the PIN code.
42
+
43
+ :param old_pin: A string containing the current PIN code.
44
+ :param new_pin: A string containing the new PIN code.
45
+ """
46
+ raise NotImplementedError
47
+
48
+ @dbus_method_async(input_signature='a(su)')
49
+ async def set_preferred_networks(self, preferred_networks: List[Tuple[str, int]]) -> None:
50
+ """
51
+ Stores the provided preferred network list to the SIM card.
52
+
53
+ Each entry contains an operator id string ("MCCMNC") consisting of 5 or 6 digits,
54
+ and an MMModemAccessTechnology mask to store to SIM card if supported.
55
+
56
+ :param preferred_networks: Operator id string and MMModemAccessTechnology mask.
57
+ """
58
+ raise NotImplementedError
59
+
60
+ @dbus_property_async(property_signature='b')
61
+ def active(self) -> bool:
62
+ """Boolean indicating whether the SIM is currently active."""
63
+ raise NotImplementedError
64
+
65
+ @dbus_property_async(property_signature='s')
66
+ def sim_identifier(self) -> str:
67
+ """
68
+ The ICCID of the SIM card.
69
+ This may be available before the PIN has been entered depending on the device itself.
70
+ """
71
+ raise NotImplementedError
72
+
73
+ @dbus_property_async(property_signature='s')
74
+ def imsi(self) -> str:
75
+ """The IMSI of the SIM card, if any."""
76
+ raise NotImplementedError
77
+
78
+ @dbus_property_async(property_signature='s')
79
+ def eid(self) -> str:
80
+ """The EID of the SIM card, if any."""
81
+ raise NotImplementedError
82
+
83
+ @dbus_property_async(property_signature='s')
84
+ def operator_identifier(self) -> str:
85
+ raise NotImplementedError
86
+
87
+ @dbus_property_async(property_signature='s')
88
+ def operator_name(self) -> str:
89
+ """The name of the network operator, as given by the SIM card, if known."""
90
+ raise NotImplementedError
91
+
92
+ @dbus_property_async(property_signature='as')
93
+ def emergency_numbers(self) -> List[str]:
94
+ """List of emergency numbers programmed in the SIM card."""
95
+ raise NotImplementedError
96
+
97
+ @dbus_property_async(property_signature='a(su)')
98
+ def preferred_networks(self) -> List[Tuple[str, int]]:
99
+ """
100
+ List of preferred networks with access technologies configured in the SIM card.
101
+
102
+ Each entry contains an operator id string ("MCCMNC") consisting of 5 or 6 digits,
103
+ and an MMModemAccessTechnology mask to store to SIM card if supported.
104
+ """
105
+ raise NotImplementedError
106
+
107
+ @dbus_property_async(property_signature='ay')
108
+ def gid1(self) -> bytes:
109
+ """Group identifier level 1."""
110
+ raise NotImplementedError
111
+
112
+ @dbus_property_async(property_signature='ay')
113
+ def gid2(self) -> bytes:
114
+ """Group identifier level 2."""
115
+ raise NotImplementedError
116
+
117
+ @dbus_property_async(property_signature='u')
118
+ def sim_type(self) -> int:
119
+ """Indicates whether the current primary SIM is a ESIM or a physical SIM, given as MMSimType value."""
120
+ raise NotImplementedError
121
+
122
+ @dbus_property_async(property_signature='u')
123
+ def esim_status(self) -> int:
124
+ """If current SIM is ESIM then this indicates whether there is a profile or not, given as MMSimEsimStatus value."""
125
+ raise NotImplementedError
126
+
127
+ @dbus_property_async(property_signature='u')
128
+ def removability(self) -> int:
129
+ """Indicates whether the current SIM is a removable SIM or not, given as a MMSimRemovability value."""
130
+ raise NotImplementedError
@@ -0,0 +1,97 @@
1
+ from typing import Any, Tuple
2
+
3
+ from sdbus import DbusInterfaceCommonAsync, dbus_method_async, dbus_property_async
4
+
5
+
6
+ class MMSmsInterfaceAsync(DbusInterfaceCommonAsync, interface_name='org.freedesktop.ModemManager1.Sms'):
7
+ """The SMS interface defines operations and properties of a single SMS message."""
8
+
9
+ @dbus_method_async()
10
+ async def send(self) -> None:
11
+ """If the message has not yet been sent, queue it for delivery."""
12
+ raise NotImplementedError
13
+
14
+ @dbus_method_async(input_signature='u')
15
+ async def store(self, storage: int) -> None:
16
+ """Store the message in the device if not already done."""
17
+ raise NotImplementedError
18
+
19
+ @dbus_property_async(property_signature='u')
20
+ def state(self) -> int:
21
+ """A MMSmsState value, describing the state of the message."""
22
+ raise NotImplementedError
23
+
24
+ @dbus_property_async(property_signature='u')
25
+ def pdu_type(self) -> int:
26
+ """A MMSmsPduType value, describing the type of PDUs used in the SMS message."""
27
+ raise NotImplementedError
28
+
29
+ @dbus_property_async(property_signature='s')
30
+ def number(self) -> str:
31
+ """Number to which the message is addressed."""
32
+ raise NotImplementedError
33
+
34
+ @dbus_property_async(property_signature='s')
35
+ def text(self) -> str:
36
+ """Message text, in UTF-8."""
37
+ raise NotImplementedError
38
+
39
+ @dbus_property_async(property_signature='ay')
40
+ def data(self) -> bytes:
41
+ """Message data."""
42
+ raise NotImplementedError
43
+
44
+ @dbus_property_async(property_signature='s')
45
+ def s_m_s_c(self) -> str:
46
+ """Indicates the SMS service center number."""
47
+ raise NotImplementedError
48
+
49
+ @dbus_property_async(property_signature='(uv)')
50
+ def validity(self) -> Tuple[int, Tuple[str, Any]]:
51
+ """Indicates when the SMS expires in the SMSC."""
52
+ raise NotImplementedError
53
+
54
+ @dbus_property_async(property_signature='i')
55
+ def Class(self) -> int:
56
+ """3GPP message class (-1..3)."""
57
+ raise NotImplementedError
58
+
59
+ @dbus_property_async(property_signature='u')
60
+ def teleservice_id(self) -> int:
61
+ """A MMSmsCdmaTeleserviceId value."""
62
+ raise NotImplementedError
63
+
64
+ @dbus_property_async(property_signature='u')
65
+ def service_category(self) -> int:
66
+ """A MMSmsCdmaServiceCategory value."""
67
+ raise NotImplementedError
68
+
69
+ @dbus_property_async(property_signature='b')
70
+ def delivery_report_request(self) -> bool:
71
+ """True if delivery report request is required, False otherwise."""
72
+ raise NotImplementedError
73
+
74
+ @dbus_property_async(property_signature='u')
75
+ def message_reference(self) -> int:
76
+ """Message Reference of the last PDU sent/received within this SMS."""
77
+ raise NotImplementedError
78
+
79
+ @dbus_property_async(property_signature='s')
80
+ def timestamp(self) -> str:
81
+ """Time when the first PDU of the SMS message arrived the SMSC, in ISO8601 format."""
82
+ raise NotImplementedError
83
+
84
+ @dbus_property_async(property_signature='s')
85
+ def discharge_timestamp(self) -> str:
86
+ """Time when the first PDU of the SMS message left the SMSC, in ISO8601 format."""
87
+ raise NotImplementedError
88
+
89
+ @dbus_property_async(property_signature='u')
90
+ def delivery_state(self) -> int:
91
+ """A MMSmsDeliveryState value, describing the state of the delivery reported in the Status Report message."""
92
+ raise NotImplementedError
93
+
94
+ @dbus_property_async(property_signature='u')
95
+ def storage(self) -> int:
96
+ """A MMSmsStorage value, describing the storage where this message is kept."""
97
+ raise NotImplementedError
@@ -0,0 +1,204 @@
1
+ from typing import Dict, List, Optional
2
+
3
+ from sdbus.sd_bus_internals import SdBus
4
+
5
+ from .enums import MMCallDirection, MMCallState, MMCallStateReason
6
+ from .interfaces_bearer import MMBearerInterfaceAsync
7
+ from .interfaces_call import MMCallInterfaceAsync
8
+ from .interfaces_modem import MMModemInterfaceAsync, MMModemMessagingInterfaceAsync, MMModemSimpleInterfaceAsync, MMModemSignalInterfaceAsync, MMModemsInterfaceAsync, MMModemVoiceInterfaceAsync
9
+ from .interfaces_root import MMInterfaceAsync
10
+ from .interfaces_sim import MMSimInterfaceAsync
11
+ from .interfaces_sms import MMSmsInterfaceAsync
12
+
13
+ MODEM_MANAGER_SERVICE_NAME = 'org.freedesktop.ModemManager1'
14
+
15
+
16
+ class MM(MMInterfaceAsync):
17
+ """Modem Manger main object
18
+
19
+ Implements :py:class:`ModemManagerInterfaceAsync`
20
+
21
+ Service name ``'org.freedesktop.ModemManager1'``
22
+ and object path ``/org/freedesktop/ModemManager1`` is predetermined.
23
+ """
24
+
25
+ def __init__(self, bus: Optional[SdBus] = None) -> None:
26
+ """
27
+ :param bus: You probably want to set default bus to system bus \
28
+ or pass system bus directly.
29
+ """
30
+ super().__init__()
31
+ self._connect(MODEM_MANAGER_SERVICE_NAME, '/org/freedesktop/ModemManager1', bus)
32
+
33
+
34
+ class MMSms(MMSmsInterfaceAsync):
35
+
36
+ def __init__(
37
+ self,
38
+ object_path: str,
39
+ bus: Optional[SdBus] = None,
40
+ ) -> None:
41
+ """
42
+ :param bus: You probably want to set default bus to system bus \
43
+ or pass system bus directly.
44
+ """
45
+ super().__init__()
46
+ self._connect(MODEM_MANAGER_SERVICE_NAME, object_path, bus)
47
+
48
+
49
+ class MMModemMessaging(MMModemMessagingInterfaceAsync):
50
+
51
+ def __init__(self, object_path: str, bus: Optional[SdBus] = None) -> None:
52
+ super().__init__()
53
+ self._connect(MODEM_MANAGER_SERVICE_NAME, object_path, bus)
54
+
55
+ async def create_sms(self, number: str, text: str = None, data: bytes = None) -> MMSms:
56
+ """Creates a new message object."""
57
+ args = {"number": ("s", number)}
58
+ if text:
59
+ args["text"] = ("s", text)
60
+ elif data:
61
+ args["data"] = ("ay", data)
62
+
63
+ return MMSms(self.create(properties=args))
64
+
65
+ async def delete_sms(self, sms: MMSms) -> None:
66
+ """Delete an SMS message."""
67
+ self.delete(sms._remote_object_path)
68
+
69
+
70
+ class MMModemSignal(MMModemSignalInterfaceAsync):
71
+
72
+ def __init__(self, object_path: str, bus: Optional[SdBus] = None) -> None:
73
+ """
74
+ :param bus: You probably want to set default bus to system bus \
75
+ or pass system bus directly.
76
+ """
77
+ super().__init__()
78
+ self._connect(MODEM_MANAGER_SERVICE_NAME, object_path, bus)
79
+
80
+
81
+ class MMModemSimple(MMModemSimpleInterfaceAsync):
82
+
83
+ def __init__(self, object_path: str, bus: Optional[SdBus] = None) -> None:
84
+ super().__init__()
85
+ self._connect(MODEM_MANAGER_SERVICE_NAME, object_path, bus)
86
+
87
+
88
+ class MMModemVoice(MMModemVoiceInterfaceAsync):
89
+
90
+ def __init__(self, object_path: str, bus: Optional[SdBus] = None) -> None:
91
+ super().__init__()
92
+ self._connect(MODEM_MANAGER_SERVICE_NAME, object_path, bus)
93
+
94
+ async def get_calls(self):
95
+ return [MMCall(path) for path in self.call_object_paths]
96
+
97
+
98
+ class MMModem(MMModemInterfaceAsync):
99
+
100
+ def __init__(
101
+ self,
102
+ object_path: str,
103
+ bus: Optional[SdBus] = None,
104
+ ) -> None:
105
+ """
106
+ :param bus: You probably want to set default bus to system bus \
107
+ or pass system bus directly.
108
+ """
109
+ super().__init__()
110
+ self._connect(MODEM_MANAGER_SERVICE_NAME, object_path, bus)
111
+ self.messaging = MMModemMessaging(object_path=object_path, bus=bus)
112
+ self.simple = MMModemSimple(object_path=object_path, bus=bus)
113
+ self.signal = MMModemSignal(object_path=object_path, bus=bus)
114
+ self.voice = MMModemVoice(object_path=object_path, bus=bus)
115
+ self.sim: Optional[MMSim] = None
116
+ self.bearers: List[MMBearer] = []
117
+
118
+ async def set_sim(self, object_path: str):
119
+ self.sim = MMSim(object_path=object_path)
120
+
121
+ async def set_bearers(self, object_paths: List[str]):
122
+ for p in object_paths:
123
+ b = MMBearer(p)
124
+ self.bearers.append(b)
125
+
126
+
127
+ class MMModems(MMModemsInterfaceAsync):
128
+ modems: List[MMModem] = []
129
+
130
+ def __init__(self, bus: Optional[SdBus] = None) -> None:
131
+ super().__init__()
132
+ self._connect(service_name=MODEM_MANAGER_SERVICE_NAME, object_path='/org/freedesktop/ModemManager1', bus=bus)
133
+
134
+ async def get_modems(self) -> List[MMModem]:
135
+ objects = await self.get_managed_objects()
136
+ for k, v in objects.items():
137
+ m: MMModem = MMModem(object_path=k)
138
+ self.modems.append(m)
139
+ return self.modems
140
+
141
+ async def get_first(self) -> Optional[MMModem]:
142
+ if len(self.modems) <= 0:
143
+ await self.get_modems()
144
+ return self.modems[0] if len(self.modems) >= 1 else None
145
+
146
+
147
+ class MMSim(MMSimInterfaceAsync):
148
+
149
+ def __init__(
150
+ self,
151
+ object_path: str,
152
+ bus: Optional[SdBus] = None,
153
+ ) -> None:
154
+ """
155
+ :param bus: You probably want to set default bus to system bus \
156
+ or pass system bus directly.
157
+ """
158
+ super().__init__()
159
+ self._connect(MODEM_MANAGER_SERVICE_NAME, object_path, bus)
160
+
161
+
162
+ class MMBearer(MMBearerInterfaceAsync):
163
+
164
+ def __init__(
165
+ self,
166
+ object_path: str,
167
+ bus: Optional[SdBus] = None,
168
+ ) -> None:
169
+ """
170
+ :param bus: You probably want to set default bus to system bus \
171
+ or pass system bus directly.
172
+ """
173
+ super().__init__()
174
+ self._connect(MODEM_MANAGER_SERVICE_NAME, object_path, bus)
175
+
176
+
177
+ class MMCall(MMCallInterfaceAsync):
178
+
179
+ def __init__(
180
+ self,
181
+ object_path: str,
182
+ bus: Optional[SdBus] = None,
183
+ ) -> None:
184
+ """
185
+ :param bus: You probably want to set default bus to system bus \
186
+ or pass system bus directly.
187
+ """
188
+ super().__init__()
189
+ self._connect(MODEM_MANAGER_SERVICE_NAME, object_path, bus)
190
+
191
+ @property
192
+ def state_text(self) -> str:
193
+ """A MMCallState name, describing the state of the call."""
194
+ return MMCallState(self.state).name
195
+
196
+ @property
197
+ def state_reason_text(self) -> str:
198
+ """A MMCallStateReason name, describing why the state is changed."""
199
+ return MMCallStateReason(self.state_reason).name
200
+
201
+ @property
202
+ def direction_text(self) -> str:
203
+ """A MMCallDirection name, describing the direction of the call."""
204
+ return MMCallDirection(self.direction).name
File without changes
@@ -0,0 +1,49 @@
1
+ from __future__ import annotations
2
+
3
+ from .enums import MMModemState, MMModemMode, MMModemPowerState, MMCallDirection, MMCallState, MMCallStateReason
4
+ from .interfaces_bearer import MMBearerInterface
5
+ from .interfaces_call import MMCallInterface
6
+ from .interfaces_modem import MMModemInterface, MMModemMessagingInterface, MMModemSimpleInterface, MMModemSignalInterface, MMModemsInterface, MMModemVoiceInterface
7
+ from .interfaces_root import MMInterface
8
+ from .interfaces_sim import MMSimInterface
9
+ from .interfaces_sms import MMSmsInterface
10
+ from .objects import MM, MMBearer, MMCall, MMModem, MMModems, MMModemMessaging, MMModemSignal, MMModemSimple, MMModemVoice, MMSim, MMSms
11
+
12
+ __all__ = (
13
+ # .enums
14
+ 'MMModemState',
15
+ 'MMModemMode',
16
+ 'MMModemPowerState',
17
+ 'MMCallDirection',
18
+ 'MMCallState',
19
+ 'MMCallStateReason',
20
+ # .interfaces_bearer
21
+ ' MMBearerInterface',
22
+ # .interfaces_call
23
+ 'MMCallInterface',
24
+ # .interfaces_modem
25
+ 'MMModemInterface',
26
+ 'MMModemMessagingInterface',
27
+ 'MMModemSimpleInterface',
28
+ 'MMModemSignalInterface',
29
+ 'MMModemsInterface',
30
+ 'MMModemVoiceInterface',
31
+ # .interfaces_root
32
+ 'MMInterface',
33
+ # .interfaces_sim
34
+ 'MMSimInterface',
35
+ # .interfaces_sms
36
+ 'MMSmsInterface',
37
+ # .objects
38
+ 'MM',
39
+ 'MMModems',
40
+ 'MMModem',
41
+ 'MMModemMessaging',
42
+ 'MMModemSimple',
43
+ 'MMModemSignal',
44
+ 'MMModemVoice',
45
+ 'MMSim',
46
+ 'MMSms',
47
+ 'MMBearer',
48
+ 'MMCall',
49
+ )