cli, plugins: factorize usage of iso8601 datetime format
Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com> Includes updates by Aleksander Morgado to fix coding style issues.
This commit is contained in:

committed by
Aleksander Morgado

parent
0510e9aef8
commit
9d82d30978
@@ -603,7 +603,7 @@ mmcli_output_start_date (guint64 value)
|
|||||||
{
|
{
|
||||||
/* Merge value and recent flag in a single item in human output */
|
/* Merge value and recent flag in a single item in human output */
|
||||||
if (selected_type == MMC_OUTPUT_TYPE_HUMAN) {
|
if (selected_type == MMC_OUTPUT_TYPE_HUMAN) {
|
||||||
output_item_new_take_single (MMC_F_BEARER_STATS_START_DATE, mm_format_iso8601 (value));
|
output_item_new_take_single (MMC_F_BEARER_STATS_START_DATE, mm_new_iso8601_time_from_unix_time (value));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1661,45 +1661,70 @@ mm_get_string_unquoted_from_match_info (GMatchInfo *match_info,
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar *
|
/*
|
||||||
mm_format_iso8601 (guint64 timestamp)
|
* The following implementation is taken from glib g_date_time_format_iso8601 code
|
||||||
|
* https://gitlab.gnome.org/GNOME/glib/-/blob/main/glib/gdatetime.c#L3490
|
||||||
|
*/
|
||||||
|
static gchar *
|
||||||
|
date_time_format_iso8601 (GDateTime *dt)
|
||||||
{
|
{
|
||||||
gchar *format_date = NULL;
|
|
||||||
GDateTime *datetime = NULL;
|
|
||||||
|
|
||||||
datetime = g_date_time_new_from_unix_utc ((gint64)timestamp);
|
|
||||||
|
|
||||||
#if GLIB_CHECK_VERSION (2, 62, 0)
|
#if GLIB_CHECK_VERSION (2, 62, 0)
|
||||||
format_date = g_date_time_format_iso8601 (datetime);
|
return g_date_time_format_iso8601 (dt);
|
||||||
#else
|
#else
|
||||||
{
|
GString *outstr = NULL;
|
||||||
GString *outstr = NULL;
|
g_autofree gchar *main_date = NULL;
|
||||||
gchar *main_date = NULL;
|
gint64 offset = 0;
|
||||||
gint64 offset = 0;
|
|
||||||
|
|
||||||
main_date = g_date_time_format (datetime, "%Y-%m-%dT%H:%M:%S");
|
main_date = g_date_time_format (dt, "%Y-%m-%dT%H:%M:%S");
|
||||||
outstr = g_string_new (main_date);
|
outstr = g_string_new (main_date);
|
||||||
g_free (main_date);
|
|
||||||
|
|
||||||
/* Timezone. Format it as `%:::z` unless the offset is zero, in which case
|
/* Timezone. Format it as `%:::z` unless the offset is zero, in which case
|
||||||
* we can simply use `Z`. */
|
* we can simply use `Z`. */
|
||||||
offset = g_date_time_get_utc_offset (datetime);
|
offset = g_date_time_get_utc_offset (dt);
|
||||||
|
if (offset == 0) {
|
||||||
|
g_string_append_c (outstr, 'Z');
|
||||||
|
} else {
|
||||||
|
g_autofree gchar *time_zone = NULL;
|
||||||
|
|
||||||
if (offset == 0) {
|
time_zone = g_date_time_format (dt, "%:::z");
|
||||||
g_string_append_c (outstr, 'Z');
|
g_string_append (outstr, time_zone);
|
||||||
} else {
|
|
||||||
gchar *time_zone;
|
|
||||||
|
|
||||||
time_zone = g_date_time_format (datetime, "%:::z");
|
|
||||||
g_string_append (outstr, time_zone);
|
|
||||||
g_free (time_zone);
|
|
||||||
}
|
|
||||||
|
|
||||||
format_date = g_string_free (outstr, FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return g_string_free (outstr, FALSE);
|
||||||
#endif
|
#endif
|
||||||
g_date_time_unref (datetime);
|
}
|
||||||
return format_date;
|
|
||||||
|
gchar *
|
||||||
|
mm_new_iso8601_time_from_unix_time (guint64 timestamp)
|
||||||
|
{
|
||||||
|
g_autoptr(GDateTime) dt = NULL;
|
||||||
|
|
||||||
|
dt = g_date_time_new_from_unix_utc ((gint64)timestamp);
|
||||||
|
|
||||||
|
return date_time_format_iso8601 (dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
gchar *
|
||||||
|
mm_new_iso8601_time (guint year,
|
||||||
|
guint month,
|
||||||
|
guint day,
|
||||||
|
guint hour,
|
||||||
|
guint minute,
|
||||||
|
guint second,
|
||||||
|
gboolean have_offset,
|
||||||
|
gint offset_minutes)
|
||||||
|
{
|
||||||
|
g_autoptr(GDateTime) dt = NULL;
|
||||||
|
|
||||||
|
if (have_offset) {
|
||||||
|
g_autoptr(GTimeZone) tz = NULL;
|
||||||
|
|
||||||
|
tz = g_time_zone_new_offset (offset_minutes * 60);
|
||||||
|
dt = g_date_time_new (tz, year, month, day, hour, minute, second);
|
||||||
|
} else
|
||||||
|
dt = g_date_time_new_utc (year, month, day, hour, minute, second);
|
||||||
|
|
||||||
|
return date_time_format_iso8601 (dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@@ -190,7 +190,16 @@ gboolean mm_get_double_from_match_info (GMatchInfo *match_info,
|
|||||||
gdouble *out);
|
gdouble *out);
|
||||||
gchar *mm_get_string_unquoted_from_match_info (GMatchInfo *match_info,
|
gchar *mm_get_string_unquoted_from_match_info (GMatchInfo *match_info,
|
||||||
guint32 match_index);
|
guint32 match_index);
|
||||||
gchar *mm_format_iso8601 (guint64 timestamp);
|
|
||||||
|
gchar *mm_new_iso8601_time_from_unix_time (guint64 timestamp);
|
||||||
|
gchar *mm_new_iso8601_time (guint year,
|
||||||
|
guint month,
|
||||||
|
guint day,
|
||||||
|
guint hour,
|
||||||
|
guint minute,
|
||||||
|
guint second,
|
||||||
|
gboolean have_offset,
|
||||||
|
gint offset_minutes);
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/* Type checkers and conversion utilities */
|
/* Type checkers and conversion utilities */
|
||||||
|
@@ -598,6 +598,24 @@ hexstr_wrong_digits_some (void)
|
|||||||
common_hexstr2bin_test_failure ("012345k7");
|
common_hexstr2bin_test_failure ("012345k7");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
date_time_iso8601 (void)
|
||||||
|
{
|
||||||
|
gchar *date = NULL;
|
||||||
|
|
||||||
|
date = mm_new_iso8601_time_from_unix_time (1634307342);
|
||||||
|
g_assert_cmpstr (date, ==, "2021-10-15T14:15:42Z");
|
||||||
|
g_free (date);
|
||||||
|
|
||||||
|
date = mm_new_iso8601_time (2021, 10, 15, 16, 15, 42, FALSE, 0);
|
||||||
|
g_assert_cmpstr (date, ==, "2021-10-15T16:15:42Z");
|
||||||
|
g_free (date);
|
||||||
|
|
||||||
|
date = mm_new_iso8601_time (2021, 10, 15, 16, 15, 42, TRUE, 120);
|
||||||
|
g_assert_cmpstr (date, ==, "2021-10-15T16:15:42+02");
|
||||||
|
g_free (date);
|
||||||
|
}
|
||||||
|
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
|
|
||||||
int main (int argc, char **argv)
|
int main (int argc, char **argv)
|
||||||
@@ -644,5 +662,6 @@ int main (int argc, char **argv)
|
|||||||
g_test_add_func ("/MM/Common/HexStr/wrong-digits-all", hexstr_wrong_digits_all);
|
g_test_add_func ("/MM/Common/HexStr/wrong-digits-all", hexstr_wrong_digits_all);
|
||||||
g_test_add_func ("/MM/Common/HexStr/wrong-digits-some", hexstr_wrong_digits_some);
|
g_test_add_func ("/MM/Common/HexStr/wrong-digits-some", hexstr_wrong_digits_some);
|
||||||
|
|
||||||
|
g_test_add_func ("/MM/Common/DateTime/iso8601", date_time_iso8601);
|
||||||
return g_test_run ();
|
return g_test_run ();
|
||||||
}
|
}
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
#include "mm-errors-types.h"
|
#include "mm-errors-types.h"
|
||||||
#include "mm-modem-helpers-cinterion.h"
|
#include "mm-modem-helpers-cinterion.h"
|
||||||
#include "mm-modem-helpers.h"
|
#include "mm-modem-helpers.h"
|
||||||
|
#include "mm-common-helpers.h"
|
||||||
#include "mm-port-serial-at.h"
|
#include "mm-port-serial-at.h"
|
||||||
|
|
||||||
/* Setup relationship between the 3G band bitmask in the modem and the bitmask
|
/* Setup relationship between the 3G band bitmask in the modem and the bitmask
|
||||||
|
@@ -1359,7 +1359,7 @@ static void
|
|||||||
test_ctzu_urc_simple (void)
|
test_ctzu_urc_simple (void)
|
||||||
{
|
{
|
||||||
const gchar *urc = "\r\n+CTZU: \"19/07/09,11:15:40\",+08\r\n";
|
const gchar *urc = "\r\n+CTZU: \"19/07/09,11:15:40\",+08\r\n";
|
||||||
const gchar *expected_iso8601 = "2019-07-09T11:15:40+02:00";
|
const gchar *expected_iso8601 = "2019-07-09T11:15:40+02";
|
||||||
gint expected_offset = 120;
|
gint expected_offset = 120;
|
||||||
gint expected_dst_offset = -1; /* not given */
|
gint expected_dst_offset = -1; /* not given */
|
||||||
|
|
||||||
@@ -1370,7 +1370,7 @@ static void
|
|||||||
test_ctzu_urc_full (void)
|
test_ctzu_urc_full (void)
|
||||||
{
|
{
|
||||||
const gchar *urc = "\r\n+CTZU: \"19/07/09,11:15:40\",+08,1\r\n";
|
const gchar *urc = "\r\n+CTZU: \"19/07/09,11:15:40\",+08,1\r\n";
|
||||||
const gchar *expected_iso8601 = "2019-07-09T11:15:40+02:00";
|
const gchar *expected_iso8601 = "2019-07-09T11:15:40+02";
|
||||||
gint expected_offset = 120;
|
gint expected_offset = 120;
|
||||||
gint expected_dst_offset = 60;
|
gint expected_dst_offset = 60;
|
||||||
|
|
||||||
|
@@ -23,6 +23,7 @@
|
|||||||
#include <libmm-glib.h>
|
#include <libmm-glib.h>
|
||||||
|
|
||||||
#include "mm-log-object.h"
|
#include "mm-log-object.h"
|
||||||
|
#include "mm-common-helpers.h"
|
||||||
#include "mm-modem-helpers.h"
|
#include "mm-modem-helpers.h"
|
||||||
#include "mm-modem-helpers-huawei.h"
|
#include "mm-modem-helpers-huawei.h"
|
||||||
#include "mm-huawei-enums-types.h"
|
#include "mm-huawei-enums-types.h"
|
||||||
|
@@ -1072,32 +1072,32 @@ typedef struct {
|
|||||||
|
|
||||||
static const NwtimeTest nwtime_tests[] = {
|
static const NwtimeTest nwtime_tests[] = {
|
||||||
{ "^NWTIME: 14/08/05,04:00:21+40,00", TRUE, TRUE, FALSE,
|
{ "^NWTIME: 14/08/05,04:00:21+40,00", TRUE, TRUE, FALSE,
|
||||||
"2014-08-05T04:00:21+10:00", 600, 0, NWT_UNKNOWN },
|
"2014-08-05T04:00:21+10", 600, 0, NWT_UNKNOWN },
|
||||||
{ "^NWTIME: 14/08/05,04:00:21+40,00", TRUE, FALSE, TRUE,
|
{ "^NWTIME: 14/08/05,04:00:21+40,00", TRUE, FALSE, TRUE,
|
||||||
"2014-08-05T04:00:21+10:00", 600, 0, NWT_UNKNOWN },
|
"2014-08-05T04:00:21+10", 600, 0, NWT_UNKNOWN },
|
||||||
{ "^NWTIME: 14/08/05,04:00:21+40,00", TRUE, TRUE, TRUE,
|
{ "^NWTIME: 14/08/05,04:00:21+40,00", TRUE, TRUE, TRUE,
|
||||||
"2014-08-05T04:00:21+10:00", 600, 0, NWT_UNKNOWN },
|
"2014-08-05T04:00:21+10", 600, 0, NWT_UNKNOWN },
|
||||||
|
|
||||||
{ "^NWTIME: 14/08/05,04:00:21+20,00", TRUE, TRUE, FALSE,
|
{ "^NWTIME: 14/08/05,04:00:21+20,00", TRUE, TRUE, FALSE,
|
||||||
"2014-08-05T04:00:21+05:00", 300, 0, NWT_UNKNOWN },
|
"2014-08-05T04:00:21+05", 300, 0, NWT_UNKNOWN },
|
||||||
{ "^NWTIME: 14/08/05,04:00:21+20,00", TRUE, FALSE, TRUE,
|
{ "^NWTIME: 14/08/05,04:00:21+20,00", TRUE, FALSE, TRUE,
|
||||||
"2014-08-05T04:00:21+05:00", 300, 0, NWT_UNKNOWN },
|
"2014-08-05T04:00:21+05", 300, 0, NWT_UNKNOWN },
|
||||||
{ "^NWTIME: 14/08/05,04:00:21+20,00", TRUE, TRUE, TRUE,
|
{ "^NWTIME: 14/08/05,04:00:21+20,00", TRUE, TRUE, TRUE,
|
||||||
"2014-08-05T04:00:21+05:00", 300, 0, NWT_UNKNOWN },
|
"2014-08-05T04:00:21+05", 300, 0, NWT_UNKNOWN },
|
||||||
|
|
||||||
{ "^NWTIME: 14/08/05,04:00:21+40,01", TRUE, TRUE, FALSE,
|
{ "^NWTIME: 14/08/05,04:00:21+40,01", TRUE, TRUE, FALSE,
|
||||||
"2014-08-05T04:00:21+11:00", 600, 60, NWT_UNKNOWN },
|
"2014-08-05T04:00:21+11", 600, 60, NWT_UNKNOWN },
|
||||||
{ "^NWTIME: 14/08/05,04:00:21+40,01", TRUE, FALSE, TRUE,
|
{ "^NWTIME: 14/08/05,04:00:21+40,01", TRUE, FALSE, TRUE,
|
||||||
"2014-08-05T04:00:21+11:00", 600, 60, NWT_UNKNOWN },
|
"2014-08-05T04:00:21+11", 600, 60, NWT_UNKNOWN },
|
||||||
{ "^NWTIME: 14/08/05,04:00:21+40,01", TRUE, TRUE, TRUE,
|
{ "^NWTIME: 14/08/05,04:00:21+40,01", TRUE, TRUE, TRUE,
|
||||||
"2014-08-05T04:00:21+11:00", 600, 60, NWT_UNKNOWN },
|
"2014-08-05T04:00:21+11", 600, 60, NWT_UNKNOWN },
|
||||||
|
|
||||||
{ "^NWTIME: 14/08/05,04:00:21+40,02", TRUE, TRUE, FALSE,
|
{ "^NWTIME: 14/08/05,04:00:21+40,02", TRUE, TRUE, FALSE,
|
||||||
"2014-08-05T04:00:21+12:00", 600, 120, NWT_UNKNOWN },
|
"2014-08-05T04:00:21+12", 600, 120, NWT_UNKNOWN },
|
||||||
{ "^NWTIME: 14/08/05,04:00:21+40,02", TRUE, FALSE, TRUE,
|
{ "^NWTIME: 14/08/05,04:00:21+40,02", TRUE, FALSE, TRUE,
|
||||||
"2014-08-05T04:00:21+12:00", 600, 120, NWT_UNKNOWN },
|
"2014-08-05T04:00:21+12", 600, 120, NWT_UNKNOWN },
|
||||||
{ "^NWTIME: 14/08/05,04:00:21+40,02", TRUE, TRUE, TRUE,
|
{ "^NWTIME: 14/08/05,04:00:21+40,02", TRUE, TRUE, TRUE,
|
||||||
"2014-08-05T04:00:21+12:00", 600, 120, NWT_UNKNOWN },
|
"2014-08-05T04:00:21+12", 600, 120, NWT_UNKNOWN },
|
||||||
|
|
||||||
{ "^TIME: XX/XX/XX,XX:XX:XX+XX,XX", FALSE, TRUE, FALSE,
|
{ "^TIME: XX/XX/XX,XX:XX:XX+XX,XX", FALSE, TRUE, FALSE,
|
||||||
NULL, NWT_UNKNOWN, NWT_UNKNOWN, NWT_UNKNOWN },
|
NULL, NWT_UNKNOWN, NWT_UNKNOWN, NWT_UNKNOWN },
|
||||||
@@ -1155,8 +1155,8 @@ typedef struct {
|
|||||||
} TimeTest;
|
} TimeTest;
|
||||||
|
|
||||||
static const TimeTest time_tests[] = {
|
static const TimeTest time_tests[] = {
|
||||||
{ "^TIME: 14/08/05 04:00:21", TRUE, "2014-08-05T04:00:21" },
|
{ "^TIME: 14/08/05 04:00:21", TRUE, "2014-08-05T04:00:21Z" },
|
||||||
{ "^TIME: 2014/08/05 04:00:21", TRUE, "2014-08-05T04:00:21" },
|
{ "^TIME: 2014/08/05 04:00:21", TRUE, "2014-08-05T04:00:21Z" },
|
||||||
{ "^TIME: 14-08-05 04:00:21", FALSE, NULL },
|
{ "^TIME: 14-08-05 04:00:21", FALSE, NULL },
|
||||||
{ "^TIME: 14-08-05,04:00:21", FALSE, NULL },
|
{ "^TIME: 14-08-05,04:00:21", FALSE, NULL },
|
||||||
{ "^TIME: 14/08/05 04:00:21 AEST", FALSE, NULL },
|
{ "^TIME: 14/08/05 04:00:21 AEST", FALSE, NULL },
|
||||||
|
@@ -32,6 +32,7 @@
|
|||||||
#include "mm-iface-modem-3gpp.h"
|
#include "mm-iface-modem-3gpp.h"
|
||||||
#include "mm-iface-modem-3gpp-profile-manager.h"
|
#include "mm-iface-modem-3gpp-profile-manager.h"
|
||||||
#include "mm-iface-modem-time.h"
|
#include "mm-iface-modem-time.h"
|
||||||
|
#include "mm-common-helpers.h"
|
||||||
#include "mm-base-modem-at.h"
|
#include "mm-base-modem-at.h"
|
||||||
#include "mm-bearer-list.h"
|
#include "mm-bearer-list.h"
|
||||||
#include "mm-broadband-bearer-icera.h"
|
#include "mm-broadband-bearer-icera.h"
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
#include "mm-broadband-modem-novatel.h"
|
#include "mm-broadband-modem-novatel.h"
|
||||||
#include "mm-errors-types.h"
|
#include "mm-errors-types.h"
|
||||||
#include "mm-modem-helpers.h"
|
#include "mm-modem-helpers.h"
|
||||||
|
#include "mm-common-helpers.h"
|
||||||
#include "libqcdm/src/commands.h"
|
#include "libqcdm/src/commands.h"
|
||||||
#include "libqcdm/src/result.h"
|
#include "libqcdm/src/result.h"
|
||||||
#include "mm-log-object.h"
|
#include "mm-log-object.h"
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
#include "mm-base-modem-at.h"
|
#include "mm-base-modem-at.h"
|
||||||
#include "mm-log-object.h"
|
#include "mm-log-object.h"
|
||||||
#include "mm-modem-helpers.h"
|
#include "mm-modem-helpers.h"
|
||||||
|
#include "mm-common-helpers.h"
|
||||||
#include "mm-errors-types.h"
|
#include "mm-errors-types.h"
|
||||||
#include "mm-iface-modem.h"
|
#include "mm-iface-modem.h"
|
||||||
#include "mm-iface-modem-3gpp.h"
|
#include "mm-iface-modem-3gpp.h"
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
#include <libmm-glib.h>
|
#include <libmm-glib.h>
|
||||||
|
|
||||||
#include "mm-sms-part.h"
|
#include "mm-sms-part.h"
|
||||||
|
#include "mm-common-helpers.h"
|
||||||
#include "mm-modem-helpers.h"
|
#include "mm-modem-helpers.h"
|
||||||
#include "mm-helper-enums-types.h"
|
#include "mm-helper-enums-types.h"
|
||||||
#include "mm-log-object.h"
|
#include "mm-log-object.h"
|
||||||
@@ -384,38 +385,6 @@ mm_filter_current_bands (const GArray *supported_bands,
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
gchar *
|
|
||||||
mm_new_iso8601_time (guint year,
|
|
||||||
guint month,
|
|
||||||
guint day,
|
|
||||||
guint hour,
|
|
||||||
guint minute,
|
|
||||||
guint second,
|
|
||||||
gboolean have_offset,
|
|
||||||
gint offset_minutes)
|
|
||||||
{
|
|
||||||
GString *str;
|
|
||||||
|
|
||||||
str = g_string_sized_new (30);
|
|
||||||
g_string_append_printf (str, "%04d-%02d-%02dT%02d:%02d:%02d",
|
|
||||||
year, month, day, hour, minute, second);
|
|
||||||
if (have_offset) {
|
|
||||||
if (offset_minutes >=0 ) {
|
|
||||||
g_string_append_printf (str, "+%02d:%02d",
|
|
||||||
offset_minutes / 60,
|
|
||||||
offset_minutes % 60);
|
|
||||||
} else {
|
|
||||||
offset_minutes *= -1;
|
|
||||||
g_string_append_printf (str, "-%02d:%02d",
|
|
||||||
offset_minutes / 60,
|
|
||||||
offset_minutes % 60);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return g_string_free (str, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
GArray *
|
GArray *
|
||||||
mm_filter_supported_modes (const GArray *all,
|
mm_filter_supported_modes (const GArray *all,
|
||||||
const GArray *supported_combinations,
|
const GArray *supported_combinations,
|
||||||
|
@@ -71,15 +71,6 @@ guint mm_netmask_to_cidr (const gchar *netmask);
|
|||||||
GArray *mm_filter_current_bands (const GArray *supported_bands,
|
GArray *mm_filter_current_bands (const GArray *supported_bands,
|
||||||
const GArray *current_bands);
|
const GArray *current_bands);
|
||||||
|
|
||||||
gchar *mm_new_iso8601_time (guint year,
|
|
||||||
guint month,
|
|
||||||
guint day,
|
|
||||||
guint hour,
|
|
||||||
guint minute,
|
|
||||||
guint second,
|
|
||||||
gboolean have_offset,
|
|
||||||
gint offset_minutes);
|
|
||||||
|
|
||||||
GArray *mm_filter_supported_modes (const GArray *all,
|
GArray *mm_filter_supported_modes (const GArray *all,
|
||||||
const GArray *supported_combinations,
|
const GArray *supported_combinations,
|
||||||
gpointer log_object);
|
gpointer log_object);
|
||||||
|
@@ -23,6 +23,7 @@
|
|||||||
#define _LIBMM_INSIDE_MM
|
#define _LIBMM_INSIDE_MM
|
||||||
#include <libmm-glib.h>
|
#include <libmm-glib.h>
|
||||||
|
|
||||||
|
#include "mm-common-helpers.h"
|
||||||
#include "mm-helper-enums-types.h"
|
#include "mm-helper-enums-types.h"
|
||||||
#include "mm-sms-part-3gpp.h"
|
#include "mm-sms-part-3gpp.h"
|
||||||
#include "mm-charsets.h"
|
#include "mm-charsets.h"
|
||||||
|
@@ -3562,25 +3562,25 @@ typedef struct {
|
|||||||
|
|
||||||
static const CclkTest cclk_tests[] = {
|
static const CclkTest cclk_tests[] = {
|
||||||
{ "+CCLK: \"14/08/05,04:00:21\"", TRUE, TRUE, FALSE,
|
{ "+CCLK: \"14/08/05,04:00:21\"", TRUE, TRUE, FALSE,
|
||||||
"2014-08-05T04:00:21+00:00", 0 },
|
"2014-08-05T04:00:21Z", 0 },
|
||||||
{ "+CCLK: \"14/08/05,04:00:21\"", TRUE, FALSE, TRUE,
|
{ "+CCLK: \"14/08/05,04:00:21\"", TRUE, FALSE, TRUE,
|
||||||
"2014-08-05T04:00:21+00:00", 0 },
|
"2014-08-05T04:00:21+00:00", 0 },
|
||||||
{ "+CCLK: \"14/08/05,04:00:21\"", TRUE, TRUE, TRUE,
|
{ "+CCLK: \"14/08/05,04:00:21\"", TRUE, TRUE, TRUE,
|
||||||
"2014-08-05T04:00:21+00:00", 0 },
|
"2014-08-05T04:00:21Z", 0 },
|
||||||
|
|
||||||
{ "+CCLK: \"14/08/05,04:00:21+40\"", TRUE, TRUE, FALSE,
|
{ "+CCLK: \"14/08/05,04:00:21+40\"", TRUE, TRUE, FALSE,
|
||||||
"2014-08-05T04:00:21+10:00", 600 },
|
"2014-08-05T04:00:21+10", 600 },
|
||||||
{ "+CCLK: \"14/08/05,04:00:21+40\"", TRUE, FALSE, TRUE,
|
{ "+CCLK: \"14/08/05,04:00:21+40\"", TRUE, FALSE, TRUE,
|
||||||
"2014-08-05T04:00:21+10:00", 600 },
|
"2014-08-05T04:00:21+10:00", 600 },
|
||||||
{ "+CCLK: \"14/08/05,04:00:21+40\"", TRUE, TRUE, TRUE,
|
{ "+CCLK: \"14/08/05,04:00:21+40\"", TRUE, TRUE, TRUE,
|
||||||
"2014-08-05T04:00:21+10:00", 600 },
|
"2014-08-05T04:00:21+10", 600 },
|
||||||
|
|
||||||
{ "+CCLK: \"15/02/28,20:30:40-32\"", TRUE, TRUE, FALSE,
|
{ "+CCLK: \"15/02/28,20:30:40-32\"", TRUE, TRUE, FALSE,
|
||||||
"2015-02-28T20:30:40-08:00", -480 },
|
"2015-02-28T20:30:40-08", -480 },
|
||||||
{ "+CCLK: \"15/02/28,20:30:40-32\"", TRUE, FALSE, TRUE,
|
{ "+CCLK: \"15/02/28,20:30:40-32\"", TRUE, FALSE, TRUE,
|
||||||
"2015-02-28T20:30:40-08:00", -480 },
|
"2015-02-28T20:30:40-08", -480 },
|
||||||
{ "+CCLK: \"15/02/28,20:30:40-32\"", TRUE, TRUE, TRUE,
|
{ "+CCLK: \"15/02/28,20:30:40-32\"", TRUE, TRUE, TRUE,
|
||||||
"2015-02-28T20:30:40-08:00", -480 },
|
"2015-02-28T20:30:40-08", -480 },
|
||||||
|
|
||||||
{ "+CCLK: 17/07/26,11:42:15+01", TRUE, TRUE, FALSE,
|
{ "+CCLK: 17/07/26,11:42:15+01", TRUE, TRUE, FALSE,
|
||||||
"2017-07-26T11:42:15+00:15", 15 },
|
"2017-07-26T11:42:15+00:15", 15 },
|
||||||
@@ -3590,11 +3590,11 @@ static const CclkTest cclk_tests[] = {
|
|||||||
"2017-07-26T11:42:15+00:15", 15 },
|
"2017-07-26T11:42:15+00:15", 15 },
|
||||||
|
|
||||||
{ "+CCLK: \"15/02/28,20:30:40-32\"", TRUE, TRUE, FALSE,
|
{ "+CCLK: \"15/02/28,20:30:40-32\"", TRUE, TRUE, FALSE,
|
||||||
"2015-02-28T20:30:40-08:00", -480 },
|
"2015-02-28T20:30:40-08", -480 },
|
||||||
{ "+CCLK: \"15/02/28,20:30:40-32\"", TRUE, FALSE, TRUE,
|
{ "+CCLK: \"15/02/28,20:30:40-32\"", TRUE, FALSE, TRUE,
|
||||||
"2015-02-28T20:30:40-08:00", -480 },
|
"2015-02-28T20:30:40-08:00", -480 },
|
||||||
{ "+CCLK: \"15/02/28,20:30:40-32\"", TRUE, TRUE, TRUE,
|
{ "+CCLK: \"15/02/28,20:30:40-32\"", TRUE, TRUE, TRUE,
|
||||||
"2015-02-28T20:30:40-08:00", -480 },
|
"2015-02-28T20:30:40-08", -480 },
|
||||||
|
|
||||||
{ "+CCLK: 17/07/26,11:42:15+01", TRUE, TRUE, FALSE,
|
{ "+CCLK: 17/07/26,11:42:15+01", TRUE, TRUE, FALSE,
|
||||||
"2017-07-26T11:42:15+00:15", 15 },
|
"2017-07-26T11:42:15+00:15", 15 },
|
||||||
|
@@ -119,7 +119,7 @@ test_pdu1 (void)
|
|||||||
pdu, sizeof (pdu),
|
pdu, sizeof (pdu),
|
||||||
"+12404492164", /* smsc */
|
"+12404492164", /* smsc */
|
||||||
"+16175927198", /* number */
|
"+16175927198", /* number */
|
||||||
"2011-02-28T11:50:50-05:00", /* timestamp */
|
"2011-02-28T11:50:50-05", /* timestamp */
|
||||||
FALSE,
|
FALSE,
|
||||||
"Here's a longer message [{with some extended characters}] "
|
"Here's a longer message [{with some extended characters}] "
|
||||||
"thrown in, such as £ and ΩΠΨ and §¿ as well.", /* text */
|
"thrown in, such as £ and ΩΠΨ and §¿ as well.", /* text */
|
||||||
@@ -140,7 +140,7 @@ test_pdu2 (void)
|
|||||||
pdu, sizeof (pdu),
|
pdu, sizeof (pdu),
|
||||||
"+79037011111", /* smsc */
|
"+79037011111", /* smsc */
|
||||||
"InternetSMS", /* number */
|
"InternetSMS", /* number */
|
||||||
"2011-03-29T19:20:04+04:00", /* timestamp */
|
"2011-03-29T19:20:04+04", /* timestamp */
|
||||||
FALSE,
|
FALSE,
|
||||||
"тест", /* text */
|
"тест", /* text */
|
||||||
NULL, 0);
|
NULL, 0);
|
||||||
@@ -160,7 +160,7 @@ test_pdu3 (void)
|
|||||||
pdu, sizeof (pdu),
|
pdu, sizeof (pdu),
|
||||||
"+12345678901", /* smsc */
|
"+12345678901", /* smsc */
|
||||||
"+18005551212", /* number */
|
"+18005551212", /* number */
|
||||||
"2011-01-01T12:34:56+00:00", /* timestamp */
|
"2011-01-01T12:34:56Z", /* timestamp */
|
||||||
FALSE,
|
FALSE,
|
||||||
"hellohello", /* text */
|
"hellohello", /* text */
|
||||||
NULL, 0);
|
NULL, 0);
|
||||||
@@ -181,7 +181,7 @@ test_pdu3_nzpid (void)
|
|||||||
pdu, sizeof (pdu),
|
pdu, sizeof (pdu),
|
||||||
"+12345678901", /* smsc */
|
"+12345678901", /* smsc */
|
||||||
"+18005551212", /* number */
|
"+18005551212", /* number */
|
||||||
"2011-01-01T12:34:56+00:00", /* timestamp */
|
"2011-01-01T12:34:56Z", /* timestamp */
|
||||||
FALSE,
|
FALSE,
|
||||||
"hellohello", /* text */
|
"hellohello", /* text */
|
||||||
NULL, 0);
|
NULL, 0);
|
||||||
@@ -202,7 +202,7 @@ test_pdu3_mms (void)
|
|||||||
pdu, sizeof (pdu),
|
pdu, sizeof (pdu),
|
||||||
"+12345678901", /* smsc */
|
"+12345678901", /* smsc */
|
||||||
"+18005551212", /* number */
|
"+18005551212", /* number */
|
||||||
"2011-01-01T12:34:56+00:00", /* timestamp */
|
"2011-01-01T12:34:56Z", /* timestamp */
|
||||||
FALSE,
|
FALSE,
|
||||||
"hellohello", /* text */
|
"hellohello", /* text */
|
||||||
NULL, 0);
|
NULL, 0);
|
||||||
@@ -223,7 +223,7 @@ test_pdu3_natl (void)
|
|||||||
pdu, sizeof (pdu),
|
pdu, sizeof (pdu),
|
||||||
"+12345678901", /* smsc */
|
"+12345678901", /* smsc */
|
||||||
"18005551212", /* number, no plus */
|
"18005551212", /* number, no plus */
|
||||||
"2011-01-01T12:34:56+00:00", /* timestamp */
|
"2011-01-01T12:34:56Z", /* timestamp */
|
||||||
FALSE,
|
FALSE,
|
||||||
"hellohello", /* text */
|
"hellohello", /* text */
|
||||||
NULL, 0);
|
NULL, 0);
|
||||||
@@ -245,7 +245,7 @@ test_pdu3_8bit (void)
|
|||||||
pdu, sizeof (pdu),
|
pdu, sizeof (pdu),
|
||||||
"+12345678901", /* smsc */
|
"+12345678901", /* smsc */
|
||||||
"+18005551212", /* number */
|
"+18005551212", /* number */
|
||||||
"2011-01-01T12:34:56+00:00", /* timestamp */
|
"2011-01-01T12:34:56Z", /* timestamp */
|
||||||
FALSE,
|
FALSE,
|
||||||
NULL, /* text */
|
NULL, /* text */
|
||||||
expected_data, /* data */
|
expected_data, /* data */
|
||||||
@@ -293,7 +293,7 @@ test_pdu_dcsf1 (void)
|
|||||||
pdu, sizeof (pdu),
|
pdu, sizeof (pdu),
|
||||||
"+33609001390", /* smsc */
|
"+33609001390", /* smsc */
|
||||||
"1800", /* number */
|
"1800", /* number */
|
||||||
"2011-06-24T13:08:15+02:00", /* timestamp */
|
"2011-06-24T13:08:15+02", /* timestamp */
|
||||||
FALSE,
|
FALSE,
|
||||||
"Info SFR - Confidentiel, à ne jamais transmettre -\r\n"
|
"Info SFR - Confidentiel, à ne jamais transmettre -\r\n"
|
||||||
"Voici votre nouveau mot de passe : sw2ced pour gérer "
|
"Voici votre nouveau mot de passe : sw2ced pour gérer "
|
||||||
@@ -317,7 +317,7 @@ test_pdu_dcsf_8bit (void)
|
|||||||
pdu, sizeof (pdu),
|
pdu, sizeof (pdu),
|
||||||
"+12345678901", /* smsc */
|
"+12345678901", /* smsc */
|
||||||
"+18005551212", /* number */
|
"+18005551212", /* number */
|
||||||
"2011-01-01T12:34:56+00:00", /* timestamp */
|
"2011-01-01T12:34:56Z", /* timestamp */
|
||||||
FALSE,
|
FALSE,
|
||||||
NULL, /* text */
|
NULL, /* text */
|
||||||
expected_data, /* data */
|
expected_data, /* data */
|
||||||
@@ -363,7 +363,7 @@ test_pdu_udhi (void)
|
|||||||
hexpdu,
|
hexpdu,
|
||||||
"+31653131316", /* smsc */
|
"+31653131316", /* smsc */
|
||||||
"1002", /* number */
|
"1002", /* number */
|
||||||
"2011-06-29T23:32:19+02:00", /* timestamp */
|
"2011-06-29T23:32:19+02", /* timestamp */
|
||||||
TRUE,
|
TRUE,
|
||||||
"Welkom, bel om uw Voicemail te beluisteren naar +31612001233"
|
"Welkom, bel om uw Voicemail te beluisteren naar +31612001233"
|
||||||
" (PrePay: *100*1233#). Voicemail ontvangen is altijd gratis."
|
" (PrePay: *100*1233#). Voicemail ontvangen is altijd gratis."
|
||||||
@@ -388,7 +388,7 @@ test_pdu_multipart (void)
|
|||||||
hexpdu1,
|
hexpdu1,
|
||||||
"+12063130025", /* smsc */
|
"+12063130025", /* smsc */
|
||||||
"+16175046925", /* number */
|
"+16175046925", /* number */
|
||||||
"2012-04-25T19:56:50-04:00", /* timestamp */
|
"2012-04-25T19:56:50-04", /* timestamp */
|
||||||
TRUE, /* multipart! */
|
TRUE, /* multipart! */
|
||||||
"This is a very long test designed to exercise multi part capability. It should "
|
"This is a very long test designed to exercise multi part capability. It should "
|
||||||
"show up as one message, not as two, as the underlying encoding represents ", /* text */
|
"show up as one message, not as two, as the underlying encoding represents ", /* text */
|
||||||
@@ -398,7 +398,7 @@ test_pdu_multipart (void)
|
|||||||
hexpdu2,
|
hexpdu2,
|
||||||
"+12063130026", /* smsc */
|
"+12063130026", /* smsc */
|
||||||
"+16175046925", /* number */
|
"+16175046925", /* number */
|
||||||
"2012-04-25T19:56:51-04:00", /* timestamp */
|
"2012-04-25T19:56:51-04", /* timestamp */
|
||||||
TRUE, /* multipart! */
|
TRUE, /* multipart! */
|
||||||
"that the parts are related to one another. ", /* text */
|
"that the parts are related to one another. ", /* text */
|
||||||
NULL, 0);
|
NULL, 0);
|
||||||
@@ -431,7 +431,7 @@ test_pdu_not_stored (void)
|
|||||||
hexpdu1,
|
hexpdu1,
|
||||||
"+34656000311", /* smsc */
|
"+34656000311", /* smsc */
|
||||||
"639337937", /* number */
|
"639337937", /* number */
|
||||||
"2012-09-11T07:40:36+02:00", /* timestamp */
|
"2012-09-11T07:40:36+02", /* timestamp */
|
||||||
FALSE, /* multipart! */
|
FALSE, /* multipart! */
|
||||||
NULL, /* text */
|
NULL, /* text */
|
||||||
NULL, 0);
|
NULL, 0);
|
||||||
|
Reference in New Issue
Block a user