コード例 #1
0
ファイル: mmcli-sms.c プロジェクト: telemaco/ModemManager
static void
print_sms_info (MMSms *sms)
{
    /* Not the best thing to do, as we may be doing _get() calls twice, but
     * easiest to maintain */
#undef VALIDATE
#define VALIDATE(str) (str ? str : "unknown")

    g_print ("SMS '%s'\n",
             mm_sms_get_path (sms));
    g_print ("  -------------------------\n"
             "  Content    |      text: '%s'\n"
             "             |    number: '%s'\n"
             "  -------------------------\n"
             "  Properties |     state: '%s'\n"
             "             |      smsc: '%s'\n"
             "             | timestamp: '%s'\n"
             "             |  validity: '%u'\n"
             "             |     class: '%u'\n"
             "             |   storage: '%s'\n",
             VALIDATE (mm_sms_get_text (sms)),
             VALIDATE (mm_sms_get_number (sms)),
             mm_sms_state_get_string (mm_sms_get_state (sms)),
             VALIDATE (mm_sms_get_smsc (sms)),
             VALIDATE (mm_sms_get_timestamp (sms)),
             mm_sms_get_validity (sms),
             mm_sms_get_class (sms),
             mm_sms_storage_get_string (mm_sms_get_storage (sms)));
}
コード例 #2
0
ファイル: mmcli-sms.c プロジェクト: bruceborden/ModemManager
static void
print_sms_info (MMSms *sms)
{
    MMSmsPduType pdu_type;
    const guint8 *data;
    gsize data_size;

    /* Not the best thing to do, as we may be doing _get() calls twice, but
     * easiest to maintain */
#undef VALIDATE
#define VALIDATE(str) (str ? str : "unknown")

    pdu_type = mm_sms_get_pdu_type (sms);

    g_print ("SMS '%s'\n",
             mm_sms_get_path (sms));
    g_print ("  -----------------------------------\n"
             "  Content    |              number: '%s'\n",
             VALIDATE (mm_sms_get_number (sms)));

    if (mm_sms_get_text (sms))
        g_print ("             |                text: '%s'\n",
                 VALIDATE (mm_sms_get_text (sms)));

    data = mm_sms_get_data (sms, &data_size);
    if (data) {
        gchar *data_hex;

        data_hex = mm_utils_bin2hexstr (data, data_size);
        g_print ("             |                data: '%s'\n",
                 VALIDATE (data_hex));
        g_free (data_hex);
    }

    g_print ("  -----------------------------------\n"
             "  Properties |            PDU type: '%s'\n"
             "             |               state: '%s'\n",
             mm_sms_pdu_type_get_string (pdu_type),
             mm_sms_state_get_string (mm_sms_get_state (sms)));

    if (mm_sms_get_validity_type (sms) == MM_SMS_VALIDITY_TYPE_RELATIVE)
        g_print ("             | validity (relative): '%u'\n",
                 mm_sms_get_validity_relative (sms));

    g_print ("             |             storage: '%s'\n",
             mm_sms_storage_get_string (mm_sms_get_storage (sms)));

    /* Print properties which are set, regardless of the pdu type */

    if (mm_sms_get_smsc (sms))
        g_print ("             |                smsc: '%s'\n",
                 mm_sms_get_smsc (sms));

    if (mm_sms_get_class (sms) >= 0)
        g_print ("             |               class: '%d'\n",
                 mm_sms_get_class (sms));

    if (mm_sms_get_teleservice_id (sms) != MM_SMS_CDMA_TELESERVICE_ID_UNKNOWN)
        g_print ("             |      teleservice id: '%s'\n",
                 mm_sms_cdma_teleservice_id_get_string (mm_sms_get_teleservice_id (sms)));

    if (mm_sms_get_service_category (sms) != MM_SMS_CDMA_SERVICE_CATEGORY_UNKNOWN)
        g_print ("             |    service category: '%s'\n",
                 mm_sms_cdma_service_category_get_string (mm_sms_get_service_category (sms)));

    /* Delivery report request just in 3GPP submit PDUs */
    if (pdu_type == MM_SMS_PDU_TYPE_SUBMIT)
        g_print ("             |     delivery report: '%s'\n",
                 mm_sms_get_delivery_report_request (sms) ? "requested" : "not requested");

    if (mm_sms_get_message_reference (sms) != 0)
        g_print ("             |   message reference: '%u'\n",
                 mm_sms_get_message_reference (sms));

    if (mm_sms_get_timestamp (sms))
        g_print ("             |           timestamp: '%s'\n",
                 mm_sms_get_timestamp (sms));

    if (mm_sms_get_delivery_state (sms) != MM_SMS_DELIVERY_STATE_UNKNOWN)
        g_print ("             |      delivery state: '%s' (0x%X)\n",
                 VALIDATE (mm_sms_delivery_state_get_string_extended (mm_sms_get_delivery_state (sms))),
                 mm_sms_get_delivery_state (sms));

    if (mm_sms_get_discharge_timestamp (sms))
        g_print ("             | discharge timestamp: '%s'\n",
                 mm_sms_get_discharge_timestamp (sms));
}