Commit Graph

61 Commits

Author SHA1 Message Date
Aleksander Morgado
4e0f849bb9 iface-modem-messaging: if sms list doesn't exist, free part
If the device goes away while we are listing SMS messages, it may
happen that we ask the messaging interface to take a part and the
sms list object has already been disposed. Make sure the part is freed
in that case, so that we avoid memory leaks.

  ==19138== 6,914 (1,232 direct, 5,682 indirect) bytes in 11 blocks are definitely lost in loss record 5,282 of 5,287
  ==19138==    at 0x483A77F: malloc (vg_replace_malloc.c:307)
  ==19138==    by 0x5023349: g_malloc (in /usr/lib/libglib-2.0.so.0.6600.0)
  ==19138==    by 0x50446FF: g_slice_alloc (in /usr/lib/libglib-2.0.so.0.6600.0)
  ==19138==    by 0x5044D6A: g_slice_alloc0 (in /usr/lib/libglib-2.0.so.0.6600.0)
  ==19138==    by 0x2577FC: mm_sms_part_new (mm-sms-part.c:180)
  ==19138==    by 0x2504D0: mm_sms_part_3gpp_new_from_binary_pdu (mm-sms-part-3gpp.c:385)
  ==19138==    by 0x21A15C: add_sms_part (mm-broadband-modem-mbim.c:5169)
  ==19138==    by 0x21A31F: sms_read_query_ready (mm-broadband-modem-mbim.c:5215)
  ==19138==    by 0x4E600F3: ??? (in /usr/lib/libgio-2.0.so.0.6600.0)
  ==19138==    by 0x4E64638: ??? (in /usr/lib/libgio-2.0.so.0.6600.0)
  ==19138==    by 0x4D3870D: transaction_task_complete_and_free (mbim-device.c:236)
  ==19138==    by 0x4D396B9: process_message (mbim-device.c:616)
2020-09-19 20:53:25 +02:00
Aleksander Morgado
71d8bb2ec8 iface-modem-messaging: avoid cast-align errors
We can safely cast the data in a GArray to gpointer first, and then
to the pointer type we require.

  mm-iface-modem-messaging.c: In function 'load_supported_storages_ready':
  mm-iface-modem-messaging.c:1154:53: error: cast increases required alignment of target type [-Werror=cast-align]
           mem1 = mm_common_build_sms_storages_string ((MMSmsStorage *)storage_ctx->supported_mem1->data,
                                                       ^
  mm-iface-modem-messaging.c:1156:53: error: cast increases required alignment of target type [-Werror=cast-align]
           mem2 = mm_common_build_sms_storages_string ((MMSmsStorage *)storage_ctx->supported_mem2->data,
                                                       ^
  mm-iface-modem-messaging.c:1158:53: error: cast increases required alignment of target type [-Werror=cast-align]
           mem3 = mm_common_build_sms_storages_string ((MMSmsStorage *)storage_ctx->supported_mem3->data,
                                                       ^
2020-05-19 13:44:23 +02:00
Aleksander Morgado
135b5c8065 iface-modem-messaging: port to use object logging 2020-04-08 16:35:08 +02:00
Aleksander Morgado
189f1a2fb0 iface-modem-messaging: fix warnings with -Wimplicit-fallthrough
mm-iface-modem-messaging.c: In function ‘interface_disabling_step’:
  mm-iface-modem-messaging.c:615:18: error: this statement may fall through [-Werror=implicit-fallthrough=]
    615 |         ctx->step++;
        |         ~~~~~~~~~^~
  mm-iface-modem-messaging.c:617:5: note: here
    617 |     case DISABLING_STEP_DISABLE_UNSOLICITED_EVENTS:
        |     ^~~~
  ...
2020-01-30 11:59:14 +01:00
Aleksander Morgado
032eab4ba7 iface-modem-messaging: fix warnings with -Wswitch-default
mm-iface-modem-messaging.c: In function ‘interface_disabling_step’:
  mm-iface-modem-messaging.c:612:5: error: switch missing default case [-Werror=switch-default]
    612 |     switch (ctx->step) {
        |     ^~~~~~
  ...
2020-01-30 11:59:14 +01:00
Aleksander Morgado
7753eb0013 iface-modem-messaging: flush sms list update before notifying added/removed
So that clients are able to have the full updated list before the list
update notification.
2019-05-08 20:26:05 +02:00
Aleksander Morgado
a2705abb24 iface-modem-messaging: if only one storage supported, select it right away
Some plugins or implementations (e.g. notably MBIM) may report a
single storage as supported and no way to update the current default
storage. In this specific case, we will initialize the default storage
to that single one supported right away, regardless of whether
selecting others is implemented or not.
2018-09-25 17:51:38 +00:00
Lubomir Rintel
b39dd2ec05 all: drop unused variables
Keeps build with GCC 8 happy.

mm-base-call.c:758:18: warning: variable 'response' set but not used [-Wunused-but-set-variable]
mm-base-call.c:822:18: warning: variable 'response' set but not used [-Wunused-but-set-variable]
mm-base-sms.c:908:18: warning: variable 'response' set but not used [-Wunused-but-set-variable]
mm-sms-list.c:331:25: warning: variable 'ctx' set but not used [-Wunused-but-set-variable]
mm-iface-modem-messaging.c:1210:21: warning: variable 'storage_ctx' set but not used [-Wunused-but-set-variable]
huawei/mm-plugin-huawei.c:183:18: warning: variable 'response' set but not used [-Wunused-but-set-variable]
ublox/mm-plugin-ublox.c:161:24: warning: variable 'response' set but not used [-Wunused-but-set-variable]
ublox/mm-plugin-ublox.c:159:24: warning: variable 'ctx' set but not used [-Wunused-but-set-variable]
icera/mm-modem-helpers-icera.c:218:25: warning: variable 'first_free' set but not used [-Wunused-but-set-variable]
novatel/mm-common-novatel.c:50:18: warning: variable 'response' set but not used [-Wunused-but-set-variable]
2018-04-24 18:11:15 +02:00
Ben Chan
0fb0184a2f iface-modem-messaging: port mm_iface_modem_messaging_disable to use GTask 2017-06-28 10:21:27 +02:00
Ben Chan
1603e6e4bd iface-modem-messaging: port mm_iface_modem_messaging_enable to use GTask 2017-06-28 10:21:27 +02:00
Ben Chan
6aa4e05108 iface-modem-messaging: port mm_iface_modem_messaging_initialize to use GTask 2017-06-28 10:21:27 +02:00
Carlo Lobrano
eee6896648 broadband-modem: fixed wrong MEM1 value passed to +CPMS
In functions

- mm_broadband_modem_lock_sms_storages
- modem_messaging_set_default_storage

return with error when using current_sms_mem1_storage as +CPMS value, but
current_sms_mem1_storage value is UNKNOWN.
2017-03-28 11:02:58 +02:00
Carlo Lobrano
be317e8b80 broadband-modem: fix +CPMS empty parameter support
* Add new async virtual method init_current_storages to
  MMIfaceModemMessaging
* Add logic of init_current_storages to MMBroadbandModem
* Add step "INIT_CURRENT_STORAGES" in MMIfaceModemMessaging
  initialization in order to load and store current SMS
  storages for mem1 and mem2.
* Add usage of current sms storage value for mem1 in place
  of an empty string parameter when the command AT+CPMS
  is used.

https://bugs.freedesktop.org/show_bug.cgi?id=93135
2016-03-09 14:43:08 +01:00
Aleksander Morgado
a29382be70 sms: rename 'MMSms' to 'MMBaseSms'
Just so that we don't have same header names in src/ and /libmm-glib.
2014-07-06 16:55:29 +02:00
Aleksander Morgado
ed623f6628 iface-modem-messaging: don't skip MT storage when reading if it's the only one 2014-06-16 18:03:38 +02:00
Aleksander Morgado
f7546ad824 introspection,api: new 'Messages' property in the Messaging interface
https://bugzilla.gnome.org/show_bug.cgi?id=712276
2013-11-21 11:36:21 +01:00
Aleksander Morgado
ef5aae5125 iface-modem-messaging: never add UNKNOWN to the lists of supported storages 2013-08-19 09:44:20 +02:00
Dan Williams
18436a8f77 iface-modem-messaging: fix INSTANCE_CAST() vs. GET_INTERFACE() confusion
Yeah, GObject is pretty obscure here.  But to get the implementation's
override function, we want GET_INTERFACE, otherwise we're looking at
some random memory location that's sometimes NULL.  And then we crash.
2013-02-06 15:50:22 -06:00
Aleksander Morgado
b43575fdf9 iface-modem-messaging: fix storage string when reporting errors 2012-11-02 14:19:15 +01:00
Aleksander Morgado
c16bcdf68c core: make sure objects retrieved with g_object_get() are valid in the ifaces
The interfaces usually retrieve objects (e.g. skeletons) from the Modem object
using g_object_get(), but we didn't make sure that these objects were actually
valid before using them.

This should clean up errors happening when the modem gets unplugged and still
some actions are ongoing.

Should fix https://bugzilla.gnome.org/show_bug.cgi?id=685933
2012-10-11 11:41:15 +02:00
Aleksander Morgado
c250fa3797 libmm-glib: remove the `libmm-common.h' header
Both the ModemManager daemon and the mmcli will now include `libmm-glib.h' only.

We also handle two new special `_LIBMM_INSIDE_MM' and `LIBMM_INSIDE_MMCLI'
symbols, which if included before the `libmm-glib.h' library allow us to:

 * Don't include the libmm-glib high level API in the ModemManager daemon, as
   the object names would clash with those in the core.

 * Define some of the methods of helper objects to be included only if compiling
   ModemManager daemon or the mmcli.
2012-10-04 10:17:12 +02:00
Aleksander Morgado
e212f6b6ed sms: create SMS parts only when storing or sending
When a user creates an SMS object, we will expose all its properties in DBus
properly, but we will not create the internal list of SMS parts.

The list of SMS parts will be created when the SMS is stored or sent, whatever
comes first. When the message is sent and it was previously stored, the list of
parts is not re-created.

If the message requires multiple parts, the multipart reference is computed as
follows:
 * If the SMS was not stored and is being sent, we just use a random number.
 * If the SMS is being stored, we will use a multipart reference which is not
   being used already in another SMS to the same destination.
2012-09-14 07:05:26 +02:00
Aleksander Morgado
b42b5795e3 iface-modem-messaging: automatically detect the best default storage
Instead of letting the plugins specify a default storage to use, just look at
the supported ones and use the best one.

"MT is preferred over "ME" or "SM", as "MT=ME+SM"
2012-09-14 07:05:23 +02:00
Aleksander Morgado
bddcc2fb07 iface-modem-messaging: instead of mem1,mem2,mem3 use just a new default storage
There is no point in specifying a default 'mem1' memory storage, which is used
for reading/listing/deleting, as those are operations that need a specific
'mem1' set each time.

Also, there is no point in specifying separate default 'mem2' and 'mem3' memory
storages, specially because now we allow Sms.Store() to specify a storage.

So, we will now only have a 'default' memory storage, which is applicable for
both 'mem2' and 'mem3' (storing, sending from storage and deleting).
2012-09-14 07:05:23 +02:00
Aleksander Morgado
67081f02c8 api: new `SupportedStorages' property in the Messaging interface
We will list which are the storages allowed to use when receiving/storing SMS
messages.
2012-09-14 07:05:23 +02:00
Aleksander Morgado
96928909b9 iface-modem-messaging: setting preferred storages is a one-time operation
Selection specific storages to run actions on them can now be done with the
broadband-modem-specific lock|unlock_sms_storages() methods.
2012-09-14 07:05:22 +02:00
Aleksander Morgado
2481d97d52 iface-modem-messaging: load initial SMS parts after having set default storages
We really want the 'mem3' storage set as soon as possible.
2012-09-14 07:05:22 +02:00
Aleksander Morgado
83dc9e3e1d iface-modem-messaging: new methods to check support for storage actions
We can now check whether a specific storage is valid for receiving or storing.
2012-09-14 07:05:22 +02:00
Aleksander Morgado
a90d149ce4 sms: SMS objects need to be create by `create_modem()' in the Messaging iface
So that plugins can subclass the generic SMS object.
2012-09-06 19:58:01 +02:00
Aleksander Morgado
11740e9075 iface-modem-messaging: plug memleak 2012-09-06 13:16:29 +02:00
Aleksander Morgado
dd8dcbb899 messaging: don't treat as fatal error if we cannot read from a given storage 2012-07-22 13:33:07 +02:00
Ben Chan
717977d0b5 iface-modem-messaging: check if supported storage is allocated before use
load_supported_storages may fail, which results in unallocated storage
memory. This patch modifies load_initial_sms_parts_from_storages and
is_storage_supported to handle that gracefully.
2012-07-17 08:02:13 +02:00
Aleksander Morgado
9eebb75ca3 iface-modem-messaging: let initialization and enabling sequences get cancelled 2012-03-16 14:53:24 +01:00
Aleksander Morgado
cc6d4a97fb base-modem: new port getters and peekers
* mm_base_modem_peek_port_* () will return either a port object (no new
reference), or NULL if none available.

You would usually peek() a port if you're going to use it just in the current
method, as there is no way to that reference to get invalid (we're single
threaded).

 * mm_base_modem_get_port_* () will return either NEW references to valid
port objects, or NULL if none available.

And, you would usually get() a port, whenever you want the port object to be
valid even out of the current method, for example when keeping it in the
context of an async operation.

Also, we need to consider that the primary AT port MAY BE NULL when you
peek() or get() it. This is due to the fact that we may be releasing ports
(due to device disconnection) in the middle of async operations.
2012-03-16 14:53:23 +01:00
Aleksander Morgado
cd63df938f libmm-common: `MMSimpleStatus' won't be considered internal any more
Renamed `MMCommonSimpleProperties' to `MMSimpleStatus', and removed the
`MMSimpleStatusProperties' provided in libmm-glib. We'll just use the original
one from libmm-common always.
2012-03-16 14:53:20 +01:00
Aleksander Morgado
ef9fb0bfac libmm-common: `MMSmsProperties' won't be considered internal any more
Renamed `MMCommonSmsProperties' to `MMSmsProperties', and removed the
`MMSmsProperties' provided in libmm-glib. We'll just use the original one
from libmm-common always.
2012-03-16 14:53:19 +01:00
Aleksander Morgado
333779bda9 iface-modem-messaging: include policy authorization checks 2012-03-16 14:53:16 +01:00
Aleksander Morgado
3dd5ec64cc iface-modem-messaging: need to enable/disable SMS indications 2012-03-15 14:15:06 +01:00
Aleksander Morgado
21a722b616 core: don't pass primary port to interface initializations
They will all get it themselves.
2012-03-15 14:15:05 +01:00
Aleksander Morgado
978801ee7b sms: specify storage where the SMS is kept 2012-03-15 14:15:04 +01:00
Aleksander Morgado
50d474056d iface-modem-messaging: once all messages initially loaded, set default storages 2012-03-15 14:15:03 +01:00
Aleksander Morgado
f7c41b8e48 iface-modem-messaging: use defaults when no specific storage specified 2012-03-15 14:15:03 +01:00
Aleksander Morgado
9e3f66393f iface-modem-messaging: load initial parts from all available storages 2012-03-15 14:15:03 +01:00
Aleksander Morgado
69ecae2dc4 iface-modem-messaging: new method to set preferred SMS storages 2012-03-15 14:15:03 +01:00
Aleksander Morgado
f6ef117d32 iface-modem-messaging: new properties to define preferred mem1/mem2/mem3 storages 2012-03-15 14:15:03 +01:00
Aleksander Morgado
7fb1234015 iface-modem-messaging: load supported SMS storages during initialization 2012-03-15 14:15:03 +01:00
Aleksander Morgado
6bb4f9cb57 iface-modem-messaging: handle the flag to use PDU mode as a property 2012-03-15 14:15:02 +01:00
Aleksander Morgado
b61c94016a api,dbus: remove the option to send the SMS in the Create() call
An SMS must be first created with the Messaging interface, and then sent using the
Send() method from the SMS-specific interface.
2012-03-15 14:15:02 +01:00
Aleksander Morgado
714e4ca44b sms: export uncomplete multipart messages as well
Uncompleted multipart SMS will be exported to DBus, where only the "state"
property is valid, so that we allow completely removing those uncompleted
multipart SMS which will never get completed due to one reason or another.
2012-03-15 14:15:02 +01:00
Aleksander Morgado
ad3b3d0ba7 iface-modem-messaging: don't allow method calls if not enabled 2012-03-15 14:15:02 +01:00