Commit Graph
3052 Commits
Author SHA1 Message Date
Aleksander Morgado fbe01c8d6a sms: 'Text' and 'Data' will never be given at the same time
When receiving an SMS, if the encoding is either GSM7 or UCS2, we will treat the
contents of the SMS as text; and if the encoding is either 8BIT or unknown, we
will just dump the contents of the SMS as data.

When creating an SMS, the user is not allowed to give both text and data, only
one can be given. We will use by default 8BIT when data is given, and guess the
best encoding if text is given.

Note that it's still possible to have SMS with neither text nor data, as in
delivery status reports.

This commit also handles the split of the input data in order to make it fit
into singlepart or multipart messages.
2012-09-14 07:05:26 +02:00
Aleksander Morgado 15be01d4fa sms: fix error return when a mandatory parameter missing in dictionary 2012-09-14 07:05:26 +02:00
Aleksander Morgado baf3ed0c64 sms-part: don't keep track of the whole TP-DCS value
We already retrieve the bits we use from it, class and encoding.
2012-09-14 07:05:25 +02:00
Aleksander Morgado 64f728b375 sms-part: read message class only if TP-DCS available 2012-09-14 07:05:25 +02:00
Aleksander Morgado 815decb034 broadband-modem: properly avoid duplicate CMTI indications
We will look for the part being notified in the CMTI indication directly in the
list of processed parts; and if we have it there already we won't re-process it.

Still, we may get several CMTI indications for the same part one after the
other, so it may still happen that the second CMTI comes *before* we have parsed
and created the part in the SMS list. For that case, the SMS list will reject
taking the part if there is already a part with the same storage+index already
processed.

This fix removes the `known_sms_parts' hash table, which was being handled
incorrectly.

This should fix https://bugzilla.gnome.org/show_bug.cgi?id=675175
2012-09-14 07:05:25 +02:00
Aleksander Morgado 8cbf3b7826 broadband-modem: fix SMS list object type 2012-09-14 07:05:25 +02:00
Aleksander Morgado 91b324ed40 broadband-modem: select and lock proper storage when reading CMTI indications 2012-09-14 07:05:25 +02:00
Aleksander Morgado f6147e0d6b cli: print new SMS properties in SMS status report 2012-09-14 07:05:25 +02:00
Aleksander Morgado 744b9fba67 libmm-glib: added methods to retrieve new SMS properties 2012-09-14 07:05:25 +02:00
Aleksander Morgado 1111bfa806 api: new `DeliveryState' property in the SMS interface
Given only for STATUS REPORT SMS messages.
2012-09-14 07:05:25 +02:00
Aleksander Morgado bdf0f9484b sms: allow parts with neither text nor data only in Status Report PDUs 2012-09-14 07:05:25 +02:00
Aleksander Morgado 83ab63138c sms: fix double free when parsing PDUs
If we get an error when telling the SMS list to take the new PDU, the caller is
the one responsible for freeing the part, so avoid doing it twice.

Relevant valgrind log:
==7287== Invalid read of size 8
==7287==    at 0x437CE1: mm_sms_part_free (mm-sms-part.c:344)
==7287==    by 0x454D11: mm_iface_modem_messaging_take_part (mm-iface-modem-messaging.c:359)
==7287==    by 0x461234: cds_received (mm-broadband-modem.c:4626)
==7287==    by 0x48A305: parse_unsolicited (mm-at-serial-port.c:256)
==7287==    by 0x48723D: parse_response (mm-serial-port.c:731)
==7287==    by 0x48759B: data_available (mm-serial-port.c:801)
==7287==    by 0x36ADC47694: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3200.4)
==7287==    by 0x36ADC479C7: ??? (in /usr/lib64/libglib-2.0.so.0.3200.4)
==7287==    by 0x36ADC47DC1: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3200.4)
==7287==    by 0x421398: main (main.c:150)
==7287==  Address 0x9840b78 is 24 bytes inside a block of size 104 free'd
==7287==    at 0x4A079AE: free (vg_replace_malloc.c:427)
==7287==    by 0x36ADC4D37E: g_free (in /usr/lib64/libglib-2.0.so.0.3200.4)
==7287==    by 0x36ADC61CCE: g_slice_free1 (in /usr/lib64/libglib-2.0.so.0.3200.4)
==7287==    by 0x437D5A: mm_sms_part_free (mm-sms-part.c:351)
==7287==    by 0x36ADC449EC: g_list_foreach (in /usr/lib64/libglib-2.0.so.0.3200.4)
==7287==    by 0x36ADC44A0A: g_list_free_full (in /usr/lib64/libglib-2.0.so.0.3200.4)
==7287==    by 0x43D8A1: finalize (mm-sms.c:1629)
==7287==    by 0x36AE8145DA: g_object_unref (in /usr/lib64/libgobject-2.0.so.0.3200.4)
==7287==    by 0x43CD52: mm_sms_singlepart_new (mm-sms.c:1376)
==7287==    by 0x43E223: take_singlepart (mm-sms-list.c:236)
==7287==    by 0x43E60D: mm_sms_list_take_part (mm-sms-list.c:338)
==7287==    by 0x454CC7: mm_iface_modem_messaging_take_part (mm-iface-modem-messaging.c:353)
2012-09-14 07:05:25 +02:00
Aleksander Morgado 2871e3e821 sms-part: don't read out of the pdu buffer
... or Valgrind will complain:

==4834== Invalid read of size 1
==4834==    at 0x43904C: mm_sms_part_new_from_binary_pdu (mm-sms-part.c:783)
==4834==    by 0x4382C9: mm_sms_part_new_from_pdu (mm-sms-part.c:485)
==4834==    by 0x461D85: sms_pdu_part_list_ready (mm-broadband-modem.c:5004)
==4834==    by 0x3161A6CFB6: g_simple_async_result_complete (in /usr/lib64/libgio-2.0.so.0.3200.4)
==4834==    by 0x432F82: at_command_parse_response (mm-base-modem-at.c:490)
==4834==    by 0x489F96: handle_response (mm-at-serial-port.c:161)
==4834==    by 0x486D0A: mm_serial_port_got_response (mm-serial-port.c:588)
==4834==    by 0x48758B: data_available (mm-serial-port.c:804)
==4834==    by 0x36ADC47694: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3200.4)
==4834==    by 0x36ADC479C7: ??? (in /usr/lib64/libglib-2.0.so.0.3200.4)
==4834==    by 0x36ADC47DC1: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3200.4)
==4834==    by 0x421398: main (main.c:150)
==4834==  Address 0x927e489 is 0 bytes after a block of size 25 alloc'd
==4834==    at 0x4A06F18: calloc (vg_replace_malloc.c:566)
==4834==    by 0x36ADC4D2C6: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.3200.4)
==4834==    by 0x4844B2: utils_hexstr2bin (mm-utils.c:63)
==4834==    by 0x438284: mm_sms_part_new_from_pdu (mm-sms-part.c:476)
==4834==    by 0x461D85: sms_pdu_part_list_ready (mm-broadband-modem.c:5004)
==4834==    by 0x3161A6CFB6: g_simple_async_result_complete (in /usr/lib64/libgio-2.0.so.0.3200.4)
==4834==    by 0x432F82: at_command_parse_response (mm-base-modem-at.c:490)
==4834==    by 0x489F96: handle_response (mm-at-serial-port.c:161)
==4834==    by 0x486D0A: mm_serial_port_got_response (mm-serial-port.c:588)
==4834==    by 0x48758B: data_available (mm-serial-port.c:804)
==4834==    by 0x36ADC47694: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3200.4)
==4834==    by 0x36ADC479C7: ??? (in /usr/lib64/libglib-2.0.so.0.3200.4)
2012-09-14 07:05:25 +02:00
Aleksander Morgado 2b01c93c57 api: make read-only all SMS properties for now
We don't support yet modifying these properties on the fly (e.g. we would need
to re-construct the internal PDU list when the text changes).
2012-09-14 07:05:25 +02:00
Aleksander Morgado 628f7e41a4 sms-list: don't look for duplicate parts if index is unknown 2012-09-14 07:05:25 +02:00
Aleksander Morgado 4f1991e2ba api: new `MessageReference' property in the SMS interface
Message reference allows to match a sent SMS with its corresponding delivery
report, if requested.
2012-09-14 07:05:25 +02:00
Aleksander Morgado 320984a4a0 api: new `DischargeTimestamp' property for Status Report SMS messages 2012-09-14 07:05:25 +02:00
Aleksander Morgado f1a73a5719 sms-part: always treat TP-DCS as a bitmask 2012-09-14 07:05:25 +02:00
Aleksander Morgado 6c7766afed sms-part: always treat TP-MTI as a bitmask 2012-09-14 07:05:24 +02:00
Aleksander Morgado ef5842f4da sms-part: implement parsing SUBMIT and STATUS REPORT PDUs 2012-09-14 07:05:24 +02:00
Aleksander Morgado 7faa48ea94 api: new `PduType' property in the SMS interface
It will help deciding the type of message.
2012-09-14 07:05:24 +02:00
Aleksander Morgado 5b6e080472 test: set text encoding when testing PDU creator 2012-09-14 07:05:24 +02:00
Aleksander Morgado 6c5bead94b test: print all logs in SMS part tests
They are extremely helpful for debugging issues.
2012-09-14 07:05:24 +02:00
Aleksander Morgado f7caa7c9bc test: new tests to parse SUBMIT PDUs 2012-09-14 07:05:24 +02:00
Aleksander Morgado f139bbe485 test: new tests to parse non-stored PDUs 2012-09-14 07:05:24 +02:00
Aleksander Morgado af4f23a1d2 test: new tester for +CDS unsolicited messages 2012-09-14 07:05:24 +02:00
Aleksander Morgado 8acaf7baa7 broadband-modem: process not-stored SMS part indications 2012-09-14 07:05:24 +02:00
Aleksander Morgado 7be32700fb broadband-modem: minor improvement when reading from match info 2012-09-14 07:05:24 +02:00
Aleksander Morgado 7c9beae013 cli: print delivery report request information in SMS status 2012-09-14 07:05:24 +02:00
Aleksander Morgado bda572faa7 libmm-glib,sms: new `mm_sms_get_delivery_report_request()' 2012-09-14 07:05:24 +02:00
Aleksander Morgado 2508d01bdf libmm-glib,sms: fix values returned on error 2012-09-14 07:05:24 +02:00
Aleksander Morgado 1c119be834 api: new `Sms.DeliveryReportRequest' property
Also allowing the 'delivery-report-request' key in the `Messaging.CreateSms()'
method.
2012-09-14 07:05:24 +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 54178a7959 cli: include default SMS storage info in `--messaging-status'
$> sudo mmcli -m 1 --messaging-status

/org/freedesktop/ModemManager1/Modem/1
  ----------------------------
  Messaging | supported storages: 'sm, mt, me, sr'
            |    default storage: 'me'
2012-09-14 07:05:23 +02:00
Aleksander Morgado fdb9db8d28 libmm-glib: new `mm_modem_messaging_get_default_storage()' method 2012-09-14 07:05:23 +02:00
Aleksander Morgado 4f7534452d option,hso: properly parse returned IMEI 2012-09-14 07:05:23 +02:00
Aleksander Morgado 43650043ea sms: select proper storage when sending SMS from storage
We need to select the correct 'mem2' storage before trying to send from storage.
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 584fc77bb3 cli: include the `--messaging' prefix in all Messaging-related actions
Just for consistency with other interfaces, which also provide interface
specific prefixes in their mmcli actions.
2012-09-14 07:05:23 +02:00
Aleksander Morgado 47b459603a cli: new `--messaging-status' action
Currently shows the list of supported SMS storages.
2012-09-14 07:05:23 +02:00
Aleksander Morgado c7e81d7470 libmm-glib: new `mm_modem_messaging_get_supported_storages()' method 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 b7e1c6d36d libmm-common: new helpers to work with arrays of `MMSmsStorage' values 2012-09-14 07:05:23 +02:00
Aleksander Morgado d75bfa2db9 broadband-modem: allow locking/unlocking either 'mem1' or 'mem2' or both
So that e.g. listing all SMS in a given storage ('mem1' lock) doesn't collide
with storing a new SMS ('mem2' lock).
2012-09-14 07:05:23 +02:00
Aleksander Morgado e6f827ed33 sms: select proper storage when deleting SMS 2012-09-14 07:05:23 +02:00
Aleksander Morgado f0e873b26e cli: new `--store-in-storage' action to be able to select where to store the SMS
Expects the storage as the enum nickname string, e.g:
   "me" for MM_SMS_STORAGE_ME
or
   "sm" for MM_SMS_STORAGE_SM
2012-09-14 07:05:23 +02:00
Aleksander Morgado 667026f0c8 api: Sms.Store() now requires the specific memory storage where to store the SMS
... or MM_SMS_STORAGE_UNKNOWN to store it in the default storage.
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 a5650ca091 broadband-modem: lock/unlock the 'mem1' storage when reading initial SMS lists 2012-09-14 07:05:22 +02:00