libmm-glib: provide accessors for the 'Data' property in the SMS interface
This commit is contained in:
@@ -20,6 +20,8 @@
|
|||||||
* Copyright (C) 2012 Google, Inc.
|
* Copyright (C) 2012 Google, Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "string.h"
|
||||||
|
|
||||||
#include "mm-helpers.h"
|
#include "mm-helpers.h"
|
||||||
#include "mm-sms.h"
|
#include "mm-sms.h"
|
||||||
#include "mm-modem.h"
|
#include "mm-modem.h"
|
||||||
@@ -99,6 +101,71 @@ mm_sms_dup_text (MMSms *self)
|
|||||||
mm_gdbus_sms_dup_text (self));
|
mm_gdbus_sms_dup_text (self));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mm_sms_get_data:
|
||||||
|
* @self: A #MMSms.
|
||||||
|
* @data_len: (out) Size of the output data, if any given.
|
||||||
|
*
|
||||||
|
* TODO
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): The data, or %NULL if it couldn't be retrieved. The returned value should be freed with g_free().
|
||||||
|
*/
|
||||||
|
const guint8 *
|
||||||
|
mm_sms_get_data (MMSms *self,
|
||||||
|
gsize *data_len)
|
||||||
|
{
|
||||||
|
GVariant *data;
|
||||||
|
|
||||||
|
g_return_val_if_fail (MM_GDBUS_IS_SMS (self), NULL);
|
||||||
|
|
||||||
|
data = mm_gdbus_sms_get_data (MM_GDBUS_SMS (self));
|
||||||
|
return (data ?
|
||||||
|
g_variant_get_fixed_array (
|
||||||
|
mm_gdbus_sms_get_data (MM_GDBUS_SMS (self)),
|
||||||
|
data_len,
|
||||||
|
sizeof (guchar)):
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mm_sms_dup_data:
|
||||||
|
* @self: A #MMSms.
|
||||||
|
* @data_len: (out) Size of the output data, if any given.
|
||||||
|
*
|
||||||
|
* TODO
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): The data, or %NULL if it couldn't be retrieved. The returned value should be freed with g_free().
|
||||||
|
*/
|
||||||
|
guint8 *
|
||||||
|
mm_sms_dup_data (MMSms *self,
|
||||||
|
gsize *data_len)
|
||||||
|
{
|
||||||
|
guint8 *out;
|
||||||
|
GVariant *data_variant;
|
||||||
|
const guint8 *orig_data;
|
||||||
|
gsize orig_data_len = 0;
|
||||||
|
|
||||||
|
g_return_val_if_fail (MM_GDBUS_IS_SMS (self), NULL);
|
||||||
|
|
||||||
|
/* Get a ref to ensure the variant is valid as long as we use it */
|
||||||
|
data_variant = mm_gdbus_sms_dup_data (MM_GDBUS_SMS (self));
|
||||||
|
if (!data_variant)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
orig_data = (g_variant_get_fixed_array (
|
||||||
|
mm_gdbus_sms_get_data (MM_GDBUS_SMS (self)),
|
||||||
|
&orig_data_len,
|
||||||
|
sizeof (guchar)));
|
||||||
|
|
||||||
|
out = g_new (guint8, orig_data_len);
|
||||||
|
memcpy (out, orig_data, orig_data_len);
|
||||||
|
g_variant_unref (data_variant);
|
||||||
|
|
||||||
|
if (data_len)
|
||||||
|
*data_len = orig_data_len;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mm_sms_get_number:
|
* mm_sms_get_number:
|
||||||
* @self: A #MMSms.
|
* @self: A #MMSms.
|
||||||
|
@@ -73,24 +73,28 @@ gboolean mm_sms_store_sync (MMSms *self,
|
|||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
const gchar *mm_sms_get_text (MMSms *self);
|
const gchar *mm_sms_get_text (MMSms *self);
|
||||||
gchar *mm_sms_dup_text (MMSms *self);
|
gchar *mm_sms_dup_text (MMSms *self);
|
||||||
const gchar *mm_sms_get_number (MMSms *self);
|
const guint8 *mm_sms_get_data (MMSms *self,
|
||||||
gchar *mm_sms_dup_number (MMSms *self);
|
gsize *data_len);
|
||||||
const gchar *mm_sms_get_smsc (MMSms *self);
|
guint8 *mm_sms_dup_data (MMSms *self,
|
||||||
gchar *mm_sms_dup_smsc (MMSms *self);
|
gsize *data_len);
|
||||||
const gchar *mm_sms_get_timestamp (MMSms *self);
|
const gchar *mm_sms_get_number (MMSms *self);
|
||||||
gchar *mm_sms_dup_timestamp (MMSms *self);
|
gchar *mm_sms_dup_number (MMSms *self);
|
||||||
const gchar *mm_sms_get_discharge_timestamp (MMSms *self);
|
const gchar *mm_sms_get_smsc (MMSms *self);
|
||||||
gchar *mm_sms_dup_discharge_timestamp (MMSms *self);
|
gchar *mm_sms_dup_smsc (MMSms *self);
|
||||||
guint mm_sms_get_validity (MMSms *self);
|
const gchar *mm_sms_get_timestamp (MMSms *self);
|
||||||
guint mm_sms_get_class (MMSms *self);
|
gchar *mm_sms_dup_timestamp (MMSms *self);
|
||||||
guint mm_sms_get_message_reference (MMSms *self);
|
const gchar *mm_sms_get_discharge_timestamp (MMSms *self);
|
||||||
gboolean mm_sms_get_delivery_report_request (MMSms *self);
|
gchar *mm_sms_dup_discharge_timestamp (MMSms *self);
|
||||||
guint mm_sms_get_delivery_state (MMSms *self);
|
guint mm_sms_get_validity (MMSms *self);
|
||||||
MMSmsState mm_sms_get_state (MMSms *self);
|
guint mm_sms_get_class (MMSms *self);
|
||||||
MMSmsStorage mm_sms_get_storage (MMSms *self);
|
guint mm_sms_get_message_reference (MMSms *self);
|
||||||
MMSmsPduType mm_sms_get_pdu_type (MMSms *self);
|
gboolean mm_sms_get_delivery_report_request (MMSms *self);
|
||||||
|
guint mm_sms_get_delivery_state (MMSms *self);
|
||||||
|
MMSmsState mm_sms_get_state (MMSms *self);
|
||||||
|
MMSmsStorage mm_sms_get_storage (MMSms *self);
|
||||||
|
MMSmsPduType mm_sms_get_pdu_type (MMSms *self);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user