ModemManagerQt

modem.h
1/*
2 SPDX-FileCopyrightText: 2008, 2011 Will Stephenson <wstephenson@kde.org>
3 SPDX-FileCopyrightText: 2010 Lamarque Souza <lamarque@kde.org>
4 SPDX-FileCopyrightText: 2013 Daniel Nicoletti <dantti12@gmail.com>
5 SPDX-FileCopyrightText: 2013 Lukas Tinkl <ltinkl@redhat.com>
6 SPDX-FileCopyrightText: 2013-2015 Jan Grulich <jgrulich@redhat.com>
7
8 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
9*/
10
11#ifndef MODEMMANAGERQT_MODEM_H
12#define MODEMMANAGERQT_MODEM_H
13
14#include <ModemManager/ModemManager.h>
15
16#include <modemmanagerqt_export.h>
17
18#include <QDBusObjectPath>
19#include <QObject>
20#include <QSharedPointer>
21
22#include "bearer.h"
23#include "generictypes.h"
24#include "interface.h"
25
26namespace ModemManager
27{
28class ModemPrivate;
29
30/**
31 * This class represents bearer properties used for creating of new bearers
32 */
33class MODEMMANAGERQT_EXPORT BearerProperties
34{
35public:
36 /**
37 * Constructs an empty BearerProperties object
38 */
40
41 /**
42 * Destroys this BearerProperties object.
43 */
45
46 /**
47 * Constructs a BearerProperties object that is a copy of the object @p other.
48 */
50
51 /**
52 * Returns Access Point Name
53 */
54 QString apn() const;
55
56 /**
57 * Sets Access Point Name
58 */
59 void setApn(const QString &apn);
60
61 /**
62 * Returns addressing type
63 */
64 MMBearerIpFamily ipType() const;
65
66 /**
67 * Sets addressing type
68 */
69 void setIpType(MMBearerIpFamily ipType);
70
71 /**
72 * Returns used authentication method
73 */
74 MMBearerAllowedAuth allowedAuthentication() const;
75
76 /**
77 * Sets the authentication method to use
78 */
79 void setAllowedAuthentication(MMBearerAllowedAuth allowedAuth);
80
81 /**
82 * Returns user name
83 */
84 QString user() const;
85
86 /**
87 * Sets user name
88 */
89 void setUser(const QString &user);
90
91 /**
92 * Returns password
93 */
94 QString password() const;
95
96 /**
97 * Sets password
98 */
99 void setPassword(const QString &password);
100
101 /**
102 * Returns whether connection is allowed during roaming
103 */
104 bool allowRoaming() const;
105
106 /**
107 * Sets whether connection is allowed during roaming
108 */
109 void setAllowRoaming(bool allow);
110
111 /**
112 * Returns protocol of the Rm interface
113 */
114 MMModemCdmaRmProtocol rmProtocol() const;
115
116 /**
117 * Sets protocol of the Rm interface
118 */
119 void setRmProtocol(MMModemCdmaRmProtocol rmProtocol);
120
121 /**
122 * Returns telephone number to dial
123 */
124 QString number() const;
125
126 /**
127 * Sets telephone number to dial
128 */
129 void setNumber(const QString &number);
130
131 /**
132 * Makes a copy of the IpConfig object @p other.
133 */
134 BearerProperties &operator=(const BearerProperties &other);
135
136private:
137 class Private;
138 Private *const d;
139};
140
141/**
142 * @brief The Modem class
143 *
144 * The Modem interface controls the status and actions in a given modem object.
145 */
146class MODEMMANAGERQT_EXPORT Modem : public Interface
147{
148 Q_OBJECT
149 Q_DECLARE_PRIVATE(Modem)
150
151 Q_FLAGS(MMModemCapability)
152 Q_FLAGS(MMModemAccessTechnology)
153 Q_FLAGS(MMModemMode)
154 Q_FLAGS(MMBearerIpFamily)
155
156public:
157 Q_DECLARE_FLAGS(Capabilities, MMModemCapability)
158 Q_DECLARE_FLAGS(AccessTechnologies, MMModemAccessTechnology)
159 Q_DECLARE_FLAGS(ModemModes, MMModemMode)
160 Q_DECLARE_FLAGS(IpBearerFamilies, MMBearerIpFamily)
161
163 typedef QList<Ptr> List;
164
165 explicit Modem(const QString &path, QObject *parent = nullptr);
166 ~Modem() override;
167
168 QString uni() const;
169 /**
170 * @return @p true if the modem is fully functional, @p false when in low power mode or disabled
171 * @see setEnabled()
172 */
173 bool isEnabled() const;
174 bool isValid() const;
175
176 /**
177 * Enable or disable the modem.
178 *
179 * When enabled, the modem's radio is powered on and data sessions, voice calls, location services, and Short Message Service may be available.
180 *
181 * When disabled, the modem enters low-power state and no network-related operations are available.
182 */
183 QDBusPendingReply<void> setEnabled(bool enable);
184
185 /**
186 * Create a new packet data bearer using the given characteristics.
187 *
188 * This request may fail if the modem does not support additional bearers, if too many bearers are already defined, or if properties are invalid.
189 *
190 */
191 QDBusPendingReply<QDBusObjectPath> createBearer(const ModemManager::BearerProperties &bearerProperties);
192
193 /**
194 * Delete an existing packet data bearer.
195 *
196 * If the bearer is currently active and providing packet data server, it will be disconnected and that packet data service will terminate.
197 * @param bearer path to the bearer to delete
198 */
199 QDBusPendingReply<void> deleteBearer(const QString &bearer);
200
201 /**
202 * @return the configured packet data bearers (EPS Bearers, PDP Contexts, or CDMA2000 Packet Data Sessions).
203 */
204 ModemManager::Bearer::List listBearers() const;
205
206 /**
207 * @return the configured packet data bearer on given path
208 */
209 ModemManager::Bearer::Ptr findBearer(const QString &bearer) const;
210
211 /**
212 * Clear non-persistent configuration and state, and return the device to a newly-powered-on state.
213 *
214 * This command may power-cycle the device.
215 */
217
218 /**
219 * Clear the modem's configuration (including persistent configuration and state), and return the device to a factory-default state.
220 *
221 * If not required by the modem, @p code may be ignored.
222 *
223 * This command may or may not power-cycle the device.
224 * @param code Carrier-supplied code required to reset the modem.
225 */
226 QDBusPendingReply<void> factoryReset(const QString &code);
227
228 /**
229 * Set the power @p state of the modem. This action can only be run when the modem is in MM_MODEM_STATE_DISABLED state.
230 */
231 QDBusPendingReply<void> setPowerState(MMModemPowerState state);
232
233 /**
234 * Set the capabilities of the device. A restart of the modem may be required.
235 * @param caps QFlags of MMModemCapability values, to specify the capabilities to use.
236 */
237 QDBusPendingReply<void> setCurrentCapabilities(Capabilities caps);
238
239 /**
240 * Set the access technologies (e.g. 2G/3G/4G preference) the device is currently allowed to use when connecting to a network.
241 *
242 * The given combination should be supported by the modem, as specified in supportedModes()
243 * @param mode
244 */
245 QDBusPendingReply<void> setCurrentModes(const CurrentModesType &mode);
246
247 /**
248 * Set the radio frequency and technology bands the device is currently allowed to use when connecting to a network.
249 * @param bands List of MMModemBand values, to specify the bands to be used.
250 */
251 QDBusPendingReply<void> setCurrentBands(const QList<MMModemBand> &bands);
252
253 QDBusPendingReply<QString> command(const QString &cmd, uint timeout);
254
255 /**
256 * @return The path of the SIM object available in this device, if any.
257 */
258 QString simPath() const;
259
260 /**
261 * @return List of MMModemCapability values, specifying the combinations of generic family of access technologies the modem supports.
262 *
263 * If the modem doesn't allow changing the current capabilities, a single entry with MM_MODEM_CAPABILITY_ANY will be given.
264 */
265 QList<MMModemCapability> supportedCapabilities() const;
266
267 /**
268 * @return QFlags of MMModemCapability values, specifying the generic family of
269 * access technologies the modem currently supports without a firmware
270 * reload or reinitialization.
271 */
272 Capabilities currentCapabilities() const;
273
274 /**
275 * @return The maximum number of defined packet data bearers the modem supports.
276 *
277 * This is not the number of active/connected bearers the modem supports,
278 * but simply the number of bearers that may be defined at any given time.
279 * For example, POTS and CDMA2000-only devices support only one bearer,
280 * while GSM/UMTS devices typically support three or more, and any
281 * LTE-capable device (whether LTE-only, GSM/UMTS-capable, and/or
282 * CDMA2000-capable) also typically support three or more.
283 */
284 uint maxBearers() const;
285
286 /**
287 * @return The maximum number of active packet data bearers the modem supports.
288 *
289 * POTS and CDMA2000-only devices support one active bearer, while GSM/UMTS
290 * and LTE-capable devices (including LTE/CDMA devices) typically support at
291 * least two active bearers.
292 */
293 uint maxActiveBearers() const;
294
295 /**
296 * @return The equipment manufacturer, as reported by the modem.
297 */
298 QString manufacturer() const;
299
300 /**
301 * @return The equipment model, as reported by the modem.
302 */
303 QString model() const;
304
305 /**
306 * @return The revision identification of the software, as reported by the modem.
307 */
308 QString revision() const;
309
310 /**
311 * @return A best-effort device identifier based on various device
312 * information like model name, firmware revision, USB/PCI/PCMCIA IDs, and
313 * other properties.
314 *
315 * This ID is not guaranteed to be unique and may be shared between
316 * identical devices with the same firmware, but is intended to be "unique
317 * enough" for use as a casual device identifier for various user experience
318 * operations.
319 *
320 * This is not the device's IMEI or ESN since those may not be available
321 * before unlocking the device via a PIN.
322 */
323 QString deviceIdentifier() const;
324
325 /**
326 * @return The physical modem device reference (ie, USB, PCI, PCMCIA device), which may be dependent upon the operating system.
327 *
328 * In Linux for example, this points to a sysfs path of the usb_device object.
329 */
330 QString device() const;
331
332 /**
333 * @return The Operating System device drivers handling communication with the modem hardware.
334 */
335 QStringList drivers() const;
336
337 /**
338 * @return The name of the plugin handling this modem.
339 */
340 QString plugin() const;
341
342 /**
343 * @return The name of the primary port using to control the modem.
344 */
345 QString primaryPort() const;
346
347 /**
348 * @return The list of ports in the modem, given as an array of string and unsigned integer pairs.
349 * The string is the port name or path, and the integer is the port type given as a MMModemPortType value.
350 *
351 * @since 1.1.94
352 */
353 PortList ports() const;
354
355 /**
356 * @return The identity of the device.
357 *
358 * This will be the IMEI number for GSM devices and the hex-format ESN/MEID for CDMA devices.
359 */
360 QString equipmentIdentifier() const;
361
362 /**
363 * @return Current lock state of the device, given as a MMModemLock value.
364 */
365 MMModemLock unlockRequired() const;
366
367 /**
368 * @return A dictionary in which the keys are MMModemLock flags, and the
369 * values are integers giving the number of PIN tries remaining before the
370 * code becomes blocked (requiring a PUK) or permanently blocked. Dictionary
371 * entries exist only for the codes for which the modem is able to report
372 * retry counts.
373 */
374 UnlockRetriesMap unlockRetries() const;
375
376 /**
377 * @return Overall state of the modem, given as a MMModemState value.
378 *
379 * If the device's state cannot be determined, MM_MODEM_STATE_UNKNOWN will be reported.
380 */
381 MMModemState state() const;
382
383 /**
384 * @return Error specifying why the modem is in MM_MODEM_STATE_FAILED state, given as a MMModemStateFailedReason value.
385 */
386 MMModemStateFailedReason stateFailedReason() const;
387
388 /**
389 * @return QFlags of MMModemAccessTechnology values, specifying the current
390 * network access technologies used by the device to communicate with the
391 * network.
392 *
393 * If the device's access technology cannot be determined, MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN will be reported.
394 */
395 AccessTechnologies accessTechnologies() const;
396
397 /**
398 * @return Signal quality in percent (0 - 100) of the dominant access
399 * technology the device is using to communicate with the network. Always 0
400 * for POTS devices.
401 *
402 * The additional boolean value indicates if the quality value given was recently taken.
403 */
404 SignalQualityPair signalQuality() const;
405
406 /**
407 * @return List of numbers (e.g. MSISDN in 3GPP) being currently handled by this modem.
408 */
409 QStringList ownNumbers() const;
410
411 /**
412 * @return A MMModemPowerState value specifying the current power state of the modem.
413 */
414 MMModemPowerState powerState() const;
415
416 /**
417 * @return This property exposes the supported mode combinations, given as an list of unsigned integer pairs, where:
418 * The first integer is a bitmask of MMModemMode values, specifying the allowed modes.
419 * The second integer is a single MMModemMode, which specifies the preferred access technology, among the ones defined in the allowed modes.
420 */
421 SupportedModesType supportedModes() const;
422
423 /**
424 * @return A pair of MMModemMode values, where the first one is a bitmask
425 * specifying the access technologies (eg 2G/3G/4G) the device is currently
426 * allowed to use when connecting to a network, and the second one is the
427 * preferred mode of those specified as allowed.
428 *
429 * The pair must be one of those specified in supportedModes()
430 */
431 CurrentModesType currentModes() const;
432
433 /**
434 * @return List of MMModemBand values, specifying the radio frequency and technology bands supported by the device.
435 *
436 * For POTS devices, only the MM_MODEM_BAND_ANY mode will be returned.
437 */
438 QList<MMModemBand> supportedBands() const;
439
440 /**
441 * @return List of MMModemBand values, specifying the radio frequency and
442 * technology bands the device is currently using when connecting to a
443 * network.
444 *
445 * It must be a subset of supportedBands()
446 */
447 QList<MMModemBand> currentBands() const;
448
449 /**
450 * @return QFlags of MMBearerIpFamily values, specifying the IP families supported by the device.
451 */
452 IpBearerFamilies supportedIpFamilies() const;
453
454 /**
455 * Sets the timeout in milliseconds for all async method DBus calls.
456 * -1 means the default DBus timeout (usually 25 seconds).
457 */
458 void setTimeout(int timeout);
459
460 /**
461 * Returns the current value of the DBus timeout in milliseconds.
462 * -1 means the default DBus timeout (usually 25 seconds).
463 */
464 int timeout() const;
465
466Q_SIGNALS:
467 void bearerAdded(const QString &bearer);
468 void bearerRemoved(const QString &bearer);
469 void bearersChanged();
470
471 void simPathChanged(const QString &oldPath, const QString &newPath);
472 void supportedCapabilitiesChanged(const QList<MMModemCapability> &supportedCapabilities);
473 void currentCapabilitiesChanged(const QFlags<MMModemCapability> &currentCapabilities);
474 void maxBearersChanged(uint maxBearers);
475 void maxActiveBearersChanged(uint maxActiveBearers);
476 void manufacturerChanged(const QString &manufacturer);
477 void modelChanged(const QString &model);
478 void revisionChanged(const QString &revision);
479 void deviceIdentifierChanged(const QString &deviceIdentifier);
480 void deviceChanged(const QString &device);
481 void driversChanged(const QStringList &drivers);
482 void pluginChanged(const QString &plugin);
483 void primaryPortChanged(const QString &primaryPort);
484 void portsChanged(const ModemManager::PortList &ports);
485 void equipmentIdentifierChanged(const QString &equipmentIdentifier);
486 void unlockRequiredChanged(MMModemLock unlockRequired);
487 void unlockRetriesChanged(const ModemManager::UnlockRetriesMap &unlockRetries);
488 void stateFailedReasonChanged(MMModemStateFailedReason stateFailedReason);
489 void accessTechnologiesChanged(QFlags<MMModemAccessTechnology> accessTechnologies);
490 void signalQualityChanged(ModemManager::SignalQualityPair signalQuality);
491 void ownNumbersChanged(const QStringList &ownNumbers);
492 void powerStateChanged(MMModemPowerState powerState);
493 void supportedModesChanged(ModemManager::SupportedModesType supportedModes);
494 void currentModesChanged(ModemManager::CurrentModesType currentModes);
495 void supportedBandsChanged(const QList<MMModemBand> &supportedBands);
496 void currentBandsChanged(const QList<MMModemBand> &supportedBands);
497 void supportedIpFamiliesChanged(QFlags<MMBearerIpFamily> supportedIpFamilies);
498 void stateChanged(MMModemState oldState, MMModemState newState, MMModemStateChangeReason reason);
499};
500
501Q_DECLARE_OPERATORS_FOR_FLAGS(Modem::Capabilities)
502Q_DECLARE_OPERATORS_FOR_FLAGS(Modem::AccessTechnologies)
503Q_DECLARE_OPERATORS_FOR_FLAGS(Modem::ModemModes)
504Q_DECLARE_OPERATORS_FOR_FLAGS(Modem::IpBearerFamilies)
505
506} // namespace ModemManager
507
508#endif
This class represents bearer properties used for creating of new bearers.
Definition modem.h:34
The Modem class.
Definition modem.h:147
This namespace allows to query the underlying system to discover the available modem interfaces respo...
Definition bearer.cpp:20
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:15:10 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.