diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2014-07-06 16:20:47 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2014-07-06 16:55:29 +0200 |
commit | a29382be70ead81b31a1e7f14ad6fc0984082536 (patch) | |
tree | 14ac8af146599289be0f01f8130335d17c08f071 | |
parent | 3ca267b01f5496e1d03f31801a14a383acbd33a2 (diff) | |
download | ModemManager-a29382be70ead81b31a1e7f14ad6fc0984082536.tar.gz |
sms: rename 'MMSms' to 'MMBaseSms'
Just so that we don't have same header names in src/ and /libmm-glib.
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/mm-base-sms.c (renamed from src/mm-sms.c) | 276 | ||||
-rw-r--r-- | src/mm-base-sms.h | 126 | ||||
-rw-r--r-- | src/mm-broadband-modem-mbim.c | 2 | ||||
-rw-r--r-- | src/mm-broadband-modem-qmi.c | 2 | ||||
-rw-r--r-- | src/mm-broadband-modem.c | 4 | ||||
-rw-r--r-- | src/mm-iface-modem-messaging.c | 12 | ||||
-rw-r--r-- | src/mm-iface-modem-messaging.h | 6 | ||||
-rw-r--r-- | src/mm-sms-list.c | 80 | ||||
-rw-r--r-- | src/mm-sms-list.h | 2 | ||||
-rw-r--r-- | src/mm-sms-mbim.c | 48 | ||||
-rw-r--r-- | src/mm-sms-mbim.h | 8 | ||||
-rw-r--r-- | src/mm-sms-qmi.c | 66 | ||||
-rw-r--r-- | src/mm-sms-qmi.h | 8 | ||||
-rw-r--r-- | src/mm-sms.h | 129 |
15 files changed, 384 insertions, 389 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 15521c737..7e7693f58 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -187,8 +187,8 @@ ModemManager_SOURCES = \ mm-base-modem-at.c \ mm-base-modem.h \ mm-base-modem.c \ - mm-sms.h \ - mm-sms.c \ + mm-base-sms.h \ + mm-base-sms.c \ mm-sms-list.h \ mm-sms-list.c \ mm-iface-modem.h \ diff --git a/src/mm-sms.c b/src/mm-base-sms.c index a31579ffb..bc38a1c5d 100644 --- a/src/mm-sms.c +++ b/src/mm-base-sms.c @@ -26,17 +26,17 @@ #define _LIBMM_INSIDE_MM #include <libmm-glib.h> +#include "mm-base-sms.h" #include "mm-broadband-modem.h" #include "mm-iface-modem.h" #include "mm-iface-modem-messaging.h" -#include "mm-sms.h" #include "mm-sms-part-3gpp.h" #include "mm-base-modem-at.h" #include "mm-base-modem.h" #include "mm-log.h" #include "mm-modem-helpers.h" -G_DEFINE_TYPE (MMSms, mm_sms, MM_GDBUS_TYPE_SMS_SKELETON); +G_DEFINE_TYPE (MMBaseSms, mm_base_sms, MM_GDBUS_TYPE_SMS_SKELETON) enum { PROP_0, @@ -51,7 +51,7 @@ enum { static GParamSpec *properties[PROP_LAST]; -struct _MMSmsPrivate { +struct _MMBaseSmsPrivate { /* The connection to the system bus */ GDBusConnection *connection; /* The modem which owns this SMS */ @@ -95,7 +95,7 @@ get_validity_relative (GVariant *tuple) } static gboolean -generate_3gpp_submit_pdus (MMSms *self, +generate_3gpp_submit_pdus (MMBaseSms *self, GError **error) { guint i; @@ -233,7 +233,7 @@ generate_3gpp_submit_pdus (MMSms *self, } static gboolean -generate_cdma_submit_pdus (MMSms *self, +generate_cdma_submit_pdus (MMBaseSms *self, GError **error) { const gchar *text; @@ -292,7 +292,7 @@ generate_cdma_submit_pdus (MMSms *self, } static gboolean -generate_submit_pdus (MMSms *self, +generate_submit_pdus (MMBaseSms *self, GError **error) { MMBaseModem *modem; @@ -301,7 +301,7 @@ generate_submit_pdus (MMSms *self, /* First; decide which kind of PDU we'll generate, based on the current modem caps */ g_object_get (self, - MM_SMS_MODEM, &modem, + MM_BASE_SMS_MODEM, &modem, NULL); g_assert (modem != NULL); @@ -320,7 +320,7 @@ generate_submit_pdus (MMSms *self, /* Store SMS (DBus call handling) */ typedef struct { - MMSms *self; + MMBaseSms *self; MMBaseModem *modem; GDBusMethodInvocation *invocation; MMSmsStorage storage; @@ -336,13 +336,13 @@ handle_store_context_free (HandleStoreContext *ctx) } static void -handle_store_ready (MMSms *self, +handle_store_ready (MMBaseSms *self, GAsyncResult *res, HandleStoreContext *ctx) { GError *error = NULL; - if (!MM_SMS_GET_CLASS (self)->store_finish (self, res, &error)) { + if (!MM_BASE_SMS_GET_CLASS (self)->store_finish (self, res, &error)) { /* On error, clear up the parts we generated */ g_list_free_full (self->priv->parts, (GDestroyNotify)mm_sms_part_free); self->priv->parts = NULL; @@ -361,7 +361,7 @@ handle_store_ready (MMSms *self, } static gboolean -prepare_sms_to_be_stored (MMSms *self, +prepare_sms_to_be_stored (MMBaseSms *self, GError **error) { GList *l; @@ -410,9 +410,9 @@ handle_store_auth_ready (MMBaseModem *modem, } /* First of all, check if we already have the SMS stored. */ - if (mm_sms_get_storage (ctx->self) != MM_SMS_STORAGE_UNKNOWN) { + if (mm_base_sms_get_storage (ctx->self) != MM_SMS_STORAGE_UNKNOWN) { /* Check if SMS stored in some other storage */ - if (mm_sms_get_storage (ctx->self) == ctx->storage) + if (mm_base_sms_get_storage (ctx->self) == ctx->storage) /* Good, same storage */ mm_gdbus_sms_complete_store (MM_GDBUS_SMS (ctx->self), ctx->invocation); else @@ -421,7 +421,7 @@ handle_store_auth_ready (MMBaseModem *modem, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "SMS is already stored in storage '%s', cannot store it in storage '%s'", - mm_sms_storage_get_string (mm_sms_get_storage (ctx->self)), + mm_sms_storage_get_string (mm_base_sms_get_storage (ctx->self)), mm_sms_storage_get_string (ctx->storage)); handle_store_context_free (ctx); return; @@ -444,8 +444,8 @@ handle_store_auth_ready (MMBaseModem *modem, } /* If not stored, check if we do support doing it */ - if (!MM_SMS_GET_CLASS (ctx->self)->store || - !MM_SMS_GET_CLASS (ctx->self)->store_finish) { + if (!MM_BASE_SMS_GET_CLASS (ctx->self)->store || + !MM_BASE_SMS_GET_CLASS (ctx->self)->store_finish) { g_dbus_method_invocation_return_error (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED, @@ -454,14 +454,14 @@ handle_store_auth_ready (MMBaseModem *modem, return; } - MM_SMS_GET_CLASS (ctx->self)->store (ctx->self, - ctx->storage, - (GAsyncReadyCallback)handle_store_ready, - ctx); + MM_BASE_SMS_GET_CLASS (ctx->self)->store (ctx->self, + ctx->storage, + (GAsyncReadyCallback)handle_store_ready, + ctx); } static gboolean -handle_store (MMSms *self, +handle_store (MMBaseSms *self, GDBusMethodInvocation *invocation, guint32 storage) { @@ -471,7 +471,7 @@ handle_store (MMSms *self, ctx->self = g_object_ref (self); ctx->invocation = g_object_ref (invocation); g_object_get (self, - MM_SMS_MODEM, &ctx->modem, + MM_BASE_SMS_MODEM, &ctx->modem, NULL); ctx->storage = (MMSmsStorage)storage; @@ -495,7 +495,7 @@ handle_store (MMSms *self, /* Send SMS (DBus call handling) */ typedef struct { - MMSms *self; + MMBaseSms *self; MMBaseModem *modem; GDBusMethodInvocation *invocation; } HandleSendContext; @@ -510,13 +510,13 @@ handle_send_context_free (HandleSendContext *ctx) } static void -handle_send_ready (MMSms *self, +handle_send_ready (MMBaseSms *self, GAsyncResult *res, HandleSendContext *ctx) { GError *error = NULL; - if (!MM_SMS_GET_CLASS (self)->send_finish (self, res, &error)) { + if (!MM_BASE_SMS_GET_CLASS (self)->send_finish (self, res, &error)) { /* On error, clear up the parts we generated */ g_list_free_full (self->priv->parts, (GDestroyNotify)mm_sms_part_free); self->priv->parts = NULL; @@ -530,7 +530,7 @@ handle_send_ready (MMSms *self, /* Update state */ mm_gdbus_sms_set_state (MM_GDBUS_SMS (ctx->self), MM_SMS_STATE_SENT); /* Grab last message reference */ - l = g_list_last (mm_sms_get_parts (ctx->self)); + l = g_list_last (mm_base_sms_get_parts (ctx->self)); mm_gdbus_sms_set_message_reference (MM_GDBUS_SMS (ctx->self), mm_sms_part_get_message_reference ((MMSmsPart *)l->data)); } @@ -541,7 +541,7 @@ handle_send_ready (MMSms *self, } static gboolean -prepare_sms_to_be_sent (MMSms *self, +prepare_sms_to_be_sent (MMBaseSms *self, GError **error) { GList *l; @@ -612,8 +612,8 @@ handle_send_auth_ready (MMBaseModem *modem, } /* Check if we do support doing it */ - if (!MM_SMS_GET_CLASS (ctx->self)->send || - !MM_SMS_GET_CLASS (ctx->self)->send_finish) { + if (!MM_BASE_SMS_GET_CLASS (ctx->self)->send || + !MM_BASE_SMS_GET_CLASS (ctx->self)->send_finish) { g_dbus_method_invocation_return_error (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED, @@ -622,13 +622,13 @@ handle_send_auth_ready (MMBaseModem *modem, return; } - MM_SMS_GET_CLASS (ctx->self)->send (ctx->self, - (GAsyncReadyCallback)handle_send_ready, - ctx); + MM_BASE_SMS_GET_CLASS (ctx->self)->send (ctx->self, + (GAsyncReadyCallback)handle_send_ready, + ctx); } static gboolean -handle_send (MMSms *self, +handle_send (MMBaseSms *self, GDBusMethodInvocation *invocation) { HandleSendContext *ctx; @@ -637,7 +637,7 @@ handle_send (MMSms *self, ctx->self = g_object_ref (self); ctx->invocation = g_object_ref (invocation); g_object_get (self, - MM_SMS_MODEM, &ctx->modem, + MM_BASE_SMS_MODEM, &ctx->modem, NULL); mm_base_modem_authorize (ctx->modem, @@ -651,30 +651,30 @@ handle_send (MMSms *self, /*****************************************************************************/ void -mm_sms_export (MMSms *self) +mm_base_sms_export (MMBaseSms *self) { static guint id = 0; gchar *path; path = g_strdup_printf (MM_DBUS_SMS_PREFIX "/%d", id++); g_object_set (self, - MM_SMS_PATH, path, + MM_BASE_SMS_PATH, path, NULL); g_free (path); } void -mm_sms_unexport (MMSms *self) +mm_base_sms_unexport (MMBaseSms *self) { g_object_set (self, - MM_SMS_PATH, NULL, + MM_BASE_SMS_PATH, NULL, NULL); } /*****************************************************************************/ static void -mm_sms_dbus_export (MMSms *self) +sms_dbus_export (MMBaseSms *self) { GError *error = NULL; @@ -700,7 +700,7 @@ mm_sms_dbus_export (MMSms *self) } static void -mm_sms_dbus_unexport (MMSms *self) +sms_dbus_unexport (MMBaseSms *self) { /* Only unexport if currently exported */ if (g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (self))) @@ -710,25 +710,25 @@ mm_sms_dbus_unexport (MMSms *self) /*****************************************************************************/ const gchar * -mm_sms_get_path (MMSms *self) +mm_base_sms_get_path (MMBaseSms *self) { return self->priv->path; } MMSmsStorage -mm_sms_get_storage (MMSms *self) +mm_base_sms_get_storage (MMBaseSms *self) { return mm_gdbus_sms_get_storage (MM_GDBUS_SMS (self)); } gboolean -mm_sms_is_multipart (MMSms *self) +mm_base_sms_is_multipart (MMBaseSms *self) { return self->priv->is_multipart; } guint -mm_sms_get_multipart_reference (MMSms *self) +mm_base_sms_get_multipart_reference (MMBaseSms *self) { g_return_val_if_fail (self->priv->is_multipart, 0); @@ -736,13 +736,13 @@ mm_sms_get_multipart_reference (MMSms *self) } gboolean -mm_sms_multipart_is_complete (MMSms *self) +mm_base_sms_multipart_is_complete (MMBaseSms *self) { return (g_list_length (self->priv->parts) == self->priv->max_parts); } gboolean -mm_sms_multipart_is_assembled (MMSms *self) +mm_base_sms_multipart_is_assembled (MMBaseSms *self) { return self->priv->is_assembled; } @@ -757,8 +757,8 @@ cmp_sms_part_index (MMSmsPart *part, } gboolean -mm_sms_has_part_index (MMSms *self, - guint index) +mm_base_sms_has_part_index (MMBaseSms *self, + guint index) { return !!g_list_find_custom (self->priv->parts, GUINT_TO_POINTER (index), @@ -766,7 +766,7 @@ mm_sms_has_part_index (MMSms *self, } GList * -mm_sms_get_parts (MMSms *self) +mm_base_sms_get_parts (MMBaseSms *self) { return self->priv->parts; } @@ -830,7 +830,7 @@ sms_get_store_or_send_command (MMSmsPart *part, /* Store the SMS */ typedef struct { - MMSms *self; + MMBaseSms *self; MMBaseModem *modem; GSimpleAsyncResult *result; MMSmsStorage storage; @@ -855,7 +855,7 @@ sms_store_context_complete_and_free (SmsStoreContext *ctx) } static gboolean -sms_store_finish (MMSms *self, +sms_store_finish (MMBaseSms *self, GAsyncResult *res, GError **error) { @@ -989,7 +989,7 @@ store_lock_sms_storages_ready (MMBroadbandModem *modem, } static void -sms_store (MMSms *self, +sms_store (MMBaseSms *self, MMSmsStorage storage, GAsyncReadyCallback callback, gpointer user_data) @@ -1025,7 +1025,7 @@ sms_store (MMSms *self, /* Send the SMS */ typedef struct { - MMSms *self; + MMBaseSms *self; MMBaseModem *modem; GSimpleAsyncResult *result; gboolean need_unlock; @@ -1050,7 +1050,7 @@ sms_send_context_complete_and_free (SmsSendContext *ctx) } static gboolean -sms_send_finish (MMSms *self, +sms_send_finish (MMBaseSms *self, GAsyncResult *res, GError **error) { @@ -1256,7 +1256,7 @@ send_lock_sms_storages_ready (MMBroadbandModem *modem, } static void -sms_send (MMSms *self, +sms_send (MMBaseSms *self, GAsyncReadyCallback callback, gpointer user_data) { @@ -1272,14 +1272,14 @@ sms_send (MMSms *self, ctx->modem = g_object_ref (self->priv->modem); /* If the SMS is STORED, try to send from storage */ - ctx->from_storage = (mm_sms_get_storage (self) != MM_SMS_STORAGE_UNKNOWN); + ctx->from_storage = (mm_base_sms_get_storage (self) != MM_SMS_STORAGE_UNKNOWN); if (ctx->from_storage) { /* When sending from storage, first lock storage to use */ g_assert (MM_IS_BROADBAND_MODEM (self->priv->modem)); mm_broadband_modem_lock_sms_storages ( MM_BROADBAND_MODEM (self->priv->modem), MM_SMS_STORAGE_UNKNOWN, /* none required for mem1 */ - mm_sms_get_storage (self), + mm_base_sms_get_storage (self), (GAsyncReadyCallback)send_lock_sms_storages_ready, ctx); return; @@ -1296,7 +1296,7 @@ sms_send (MMSms *self, /*****************************************************************************/ typedef struct { - MMSms *self; + MMBaseSms *self; MMBaseModem *modem; GSimpleAsyncResult *result; gboolean need_unlock; @@ -1318,7 +1318,7 @@ sms_delete_parts_context_complete_and_free (SmsDeletePartsContext *ctx) } static gboolean -sms_delete_finish (MMSms *self, +sms_delete_finish (MMBaseSms *self, GAsyncResult *res, GError **error) { @@ -1409,7 +1409,7 @@ delete_lock_sms_storages_ready (MMBroadbandModem *modem, } static void -sms_delete (MMSms *self, +sms_delete (MMBaseSms *self, GAsyncReadyCallback callback, gpointer user_data) { @@ -1423,7 +1423,7 @@ sms_delete (MMSms *self, ctx->self = g_object_ref (self); ctx->modem = g_object_ref (self->priv->modem); - if (mm_sms_get_storage (self) == MM_SMS_STORAGE_UNKNOWN) { + if (mm_base_sms_get_storage (self) == MM_SMS_STORAGE_UNKNOWN) { mm_dbg ("Not removing parts from non-stored SMS"); g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE); sms_delete_parts_context_complete_and_free (ctx); @@ -1433,7 +1433,7 @@ sms_delete (MMSms *self, /* Select specific storage to delete from */ mm_broadband_modem_lock_sms_storages ( MM_BROADBAND_MODEM (self->priv->modem), - mm_sms_get_storage (self), + mm_base_sms_get_storage (self), MM_SMS_STORAGE_UNKNOWN, /* none required for mem2 */ (GAsyncReadyCallback)delete_lock_sms_storages_ready, ctx); @@ -1442,14 +1442,14 @@ sms_delete (MMSms *self, /*****************************************************************************/ gboolean -mm_sms_delete_finish (MMSms *self, - GAsyncResult *res, - GError **error) +mm_base_sms_delete_finish (MMBaseSms *self, + GAsyncResult *res, + GError **error) { - if (MM_SMS_GET_CLASS (self)->delete_finish) { + if (MM_BASE_SMS_GET_CLASS (self)->delete_finish) { gboolean deleted; - deleted = MM_SMS_GET_CLASS (self)->delete_finish (self, res, error); + deleted = MM_BASE_SMS_GET_CLASS (self)->delete_finish (self, res, error); if (deleted) /* We do change the state of this SMS back to UNKNOWN, as it is no * longer stored in the device */ @@ -1462,13 +1462,13 @@ mm_sms_delete_finish (MMSms *self, } void -mm_sms_delete (MMSms *self, +mm_base_sms_delete (MMBaseSms *self, GAsyncReadyCallback callback, gpointer user_data) { - if (MM_SMS_GET_CLASS (self)->delete && - MM_SMS_GET_CLASS (self)->delete_finish) { - MM_SMS_GET_CLASS (self)->delete (self, callback, user_data); + if (MM_BASE_SMS_GET_CLASS (self)->delete && + MM_BASE_SMS_GET_CLASS (self)->delete_finish) { + MM_BASE_SMS_GET_CLASS (self)->delete (self, callback, user_data); return; } @@ -1483,7 +1483,7 @@ mm_sms_delete (MMSms *self, /*****************************************************************************/ static gboolean -assemble_sms (MMSms *self, +assemble_sms (MMBaseSms *self, GError **error) { GList *l; @@ -1627,9 +1627,9 @@ cmp_sms_part_sequence (MMSmsPart *a, } gboolean -mm_sms_multipart_take_part (MMSms *self, - MMSmsPart *part, - GError **error) +mm_base_sms_multipart_take_part (MMBaseSms *self, + MMSmsPart *part, + GError **error) { if (!self->priv->is_multipart) { g_set_error (error, @@ -1675,12 +1675,12 @@ mm_sms_multipart_take_part (MMSms *self, (GCompareFunc)cmp_sms_part_sequence); /* We only populate contents when the multipart SMS is complete */ - if (mm_sms_multipart_is_complete (self)) { + if (mm_base_sms_multipart_is_complete (self)) { GError *inner_error = NULL; if (!assemble_sms (self, &inner_error)) { /* We DO NOT propagate the error. The part was properly taken - * so ownership passed to the MMSms object. */ + * so ownership passed to the MMBaseSms object. */ mm_warn ("Couldn't assemble SMS: '%s'", inner_error->message); g_error_free (inner_error); @@ -1695,22 +1695,22 @@ mm_sms_multipart_take_part (MMSms *self, return TRUE; } -MMSms * -mm_sms_new (MMBaseModem *modem) +MMBaseSms * +mm_base_sms_new (MMBaseModem *modem) { - return MM_SMS (g_object_new (MM_TYPE_SMS, - MM_SMS_MODEM, modem, - NULL)); + return MM_BASE_SMS (g_object_new (MM_TYPE_BASE_SMS, + MM_BASE_SMS_MODEM, modem, + NULL)); } -MMSms * -mm_sms_singlepart_new (MMBaseModem *modem, - MMSmsState state, - MMSmsStorage storage, - MMSmsPart *part, - GError **error) +MMBaseSms * +mm_base_sms_singlepart_new (MMBaseModem *modem, + MMSmsState state, + MMSmsStorage storage, + MMSmsPart *part, + GError **error) { - MMSms *self; + MMBaseSms *self; g_assert (MM_IS_IFACE_MODEM_MESSAGING (modem)); @@ -1731,21 +1731,21 @@ mm_sms_singlepart_new (MMBaseModem *modem, g_clear_object (&self); } else /* Only export once properly created */ - mm_sms_export (self); + mm_base_sms_export (self); return self; } -MMSms * -mm_sms_multipart_new (MMBaseModem *modem, - MMSmsState state, - MMSmsStorage storage, - guint reference, - guint max_parts, - MMSmsPart *first_part, - GError **error) +MMBaseSms * +mm_base_sms_multipart_new (MMBaseModem *modem, + MMSmsState state, + MMSmsStorage storage, + guint reference, + guint max_parts, + MMSmsPart *first_part, + GError **error) { - MMSms *self; + MMBaseSms *self; g_assert (MM_IS_IFACE_MODEM_MESSAGING (modem)); @@ -1757,17 +1757,17 @@ mm_sms_multipart_new (MMBaseModem *modem, /* Create an SMS object as defined by the interface */ self = mm_iface_modem_messaging_create_sms (MM_IFACE_MODEM_MESSAGING (modem)); g_object_set (self, - MM_SMS_IS_MULTIPART, TRUE, - MM_SMS_MAX_PARTS, max_parts, - MM_SMS_MULTIPART_REFERENCE, reference, - "state", state, - "storage", storage, - "validity", g_variant_new ("(uv)", - MM_SMS_VALIDITY_TYPE_UNKNOWN, - g_variant_new_boolean (FALSE)), + MM_BASE_SMS_IS_MULTIPART, TRUE, + MM_BASE_SMS_MAX_PARTS, max_parts, + MM_BASE_SMS_MULTIPART_REFERENCE, reference, + "state", state, + "storage", storage, + "validity", g_variant_new ("(uv)", + MM_SMS_VALIDITY_TYPE_UNKNOWN, + g_variant_new_boolean (FALSE)), NULL); - if (!mm_sms_multipart_take_part (self, first_part, error)) + if (!mm_base_sms_multipart_take_part (self, first_part, error)) g_clear_object (&self); /* We do export uncomplete multipart messages, in order to be able to @@ -1776,17 +1776,17 @@ mm_sms_multipart_new (MMBaseModem *modem, * Only the STATE of the SMS object will be valid in the exported DBus * interface.*/ if (self) - mm_sms_export (self); + mm_base_sms_export (self); return self; } -MMSms * -mm_sms_new_from_properties (MMBaseModem *modem, - MMSmsProperties *properties, - GError **error) +MMBaseSms * +mm_base_sms_new_from_properties (MMBaseModem *modem, + MMSmsProperties *properties, + GError **error) { - MMSms *self; + MMBaseSms *self; const gchar *text; GByteArray *data; @@ -1846,7 +1846,7 @@ mm_sms_new_from_properties (MMBaseModem *modem, NULL); /* Only export once properly created */ - mm_sms_export (self); + mm_base_sms_export (self); return self; } @@ -1859,7 +1859,7 @@ set_property (GObject *object, const GValue *value, GParamSpec *pspec) { - MMSms *self = MM_SMS (object); + MMBaseSms *self = MM_BASE_SMS (object); switch (prop_id) { case PROP_PATH: @@ -1868,9 +1868,9 @@ set_property (GObject *object, /* Export when we get a DBus connection AND we have a path */ if (!self->priv->path) - mm_sms_dbus_unexport (self); + sms_dbus_unexport (self); else if (self->priv->connection) - mm_sms_dbus_export (self); + sms_dbus_export (self); break; case PROP_CONNECTION: g_clear_object (&self->priv->connection); @@ -1878,9 +1878,9 @@ set_property (GObject *object, /* Export when we get a DBus connection AND we have a path */ if (!self->priv->connection) - mm_sms_dbus_unexport (self); + sms_dbus_unexport (self); else if (self->priv->path) - mm_sms_dbus_export (self); + sms_dbus_export (self); break; case PROP_MODEM: g_clear_object (&self->priv->modem); @@ -1889,7 +1889,7 @@ set_property (GObject *object, /* Bind the modem's connection (which is set when it is exported, * and unset when unexported) to the SMS's connection */ g_object_bind_property (self->priv->modem, MM_BASE_MODEM_CONNECTION, - self, MM_SMS_CONNECTION, + self, MM_BASE_SMS_CONNECTION, G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); } break; @@ -1914,7 +1914,7 @@ get_property (GObject *object, GValue *value, GParamSpec *pspec) { - MMSms *self = MM_SMS (object); + MMBaseSms *self = MM_BASE_SMS (object); switch (prop_id) { case PROP_PATH: @@ -1942,12 +1942,10 @@ get_property (GObject *object, } static void -mm_sms_init (MMSms *self) +mm_base_sms_init (MMBaseSms *self) { /* Initialize private data */ - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - MM_TYPE_SMS, - MMSmsPrivate); + self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, MM_TYPE_BASE_SMS, MMBaseSmsPrivate); /* Defaults */ self->priv->max_parts = 1; } @@ -1955,37 +1953,37 @@ mm_sms_init (MMSms *self) static void finalize (GObject *object) { - MMSms *self = MM_SMS (object); + MMBaseSms *self = MM_BASE_SMS (object); g_list_free_full (self->priv->parts, (GDestroyNotify)mm_sms_part_free); g_free (self->priv->path); - G_OBJECT_CLASS (mm_sms_parent_class)->finalize (object); + G_OBJECT_CLASS (mm_base_sms_parent_class)->finalize (object); } static void dispose (GObject *object) { - MMSms *self = MM_SMS (object); + MMBaseSms *self = MM_BASE_SMS (object); if (self->priv->connection) { /* If we arrived here with a valid connection, make sure we unexport * the object */ - mm_sms_dbus_unexport (self); + sms_dbus_unexport (self); g_clear_object (&self->priv->connection); } g_clear_object (&self->priv->modem); - G_OBJECT_CLASS (mm_sms_parent_class)->dispose (object); + G_OBJECT_CLASS (mm_base_sms_parent_class)->dispose (object); } static void -mm_sms_class_init (MMSmsClass *klass) +mm_base_sms_class_init (MMBaseSmsClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (object_class, sizeof (MMSmsPrivate)); + g_type_class_add_private (object_class, sizeof (MMBaseSmsPrivate)); /* Virtual methods */ object_class->get_property = get_property; @@ -2001,7 +1999,7 @@ mm_sms_class_init (MMSmsClass *klass) klass->delete_finish = sms_delete_finish; properties[PROP_CONNECTION] = - g_param_spec_object (MM_SMS_CONNECTION, + g_param_spec_object (MM_BASE_SMS_CONNECTION, "Connection", "GDBus connection to the system bus.", G_TYPE_DBUS_CONNECTION, @@ -2009,7 +2007,7 @@ mm_sms_class_init (MMSmsClass *klass) g_object_class_install_property (object_class, PROP_CONNECTION, properties[PROP_CONNECTION]); properties[PROP_PATH] = - g_param_spec_string (MM_SMS_PATH, + g_param_spec_string (MM_BASE_SMS_PATH, "Path", "DBus path of the SMS", NULL, @@ -2017,7 +2015,7 @@ mm_sms_class_init (MMSmsClass *klass) g_object_class_install_property (object_class, PROP_PATH, properties[PROP_PATH]); properties[PROP_MODEM] = - g_param_spec_object (MM_SMS_MODEM, + g_param_spec_object (MM_BASE_SMS_MODEM, "Modem", "The Modem which owns this SMS", MM_TYPE_BASE_MODEM, @@ -2025,7 +2023,7 @@ mm_sms_class_init (MMSmsClass *klass) g_object_class_install_property (object_class, PROP_MODEM, properties[PROP_MODEM]); properties[PROP_IS_MULTIPART] = - g_param_spec_boolean (MM_SMS_IS_MULTIPART, + g_param_spec_boolean (MM_BASE_SMS_IS_MULTIPART, "Is multipart", "Flag specifying if the SMS is multipart", FALSE, @@ -2033,7 +2031,7 @@ mm_sms_class_init (MMSmsClass *klass) g_object_class_install_property (object_class, PROP_IS_MULTIPART, properties[PROP_IS_MULTIPART]); properties[PROP_MAX_PARTS] = - g_param_spec_uint (MM_SMS_MAX_PARTS, + g_param_spec_uint (MM_BASE_SMS_MAX_PARTS, "Max parts", "Maximum number of parts composing this SMS", 1,255, 1, @@ -2041,7 +2039,7 @@ mm_sms_class_init (MMSmsClass *klass) g_object_class_install_property (object_class, PROP_MAX_PARTS, properties[PROP_MAX_PARTS]); properties[PROP_MULTIPART_REFERENCE] = - g_param_spec_uint (MM_SMS_MULTIPART_REFERENCE, + g_param_spec_uint (MM_BASE_SMS_MULTIPART_REFERENCE, "Multipart reference", "Common reference for all parts in the multipart SMS", 0, G_MAXUINT, 0, diff --git a/src/mm-base-sms.h b/src/mm-base-sms.h new file mode 100644 index 000000000..0d4b5bc55 --- /dev/null +++ b/src/mm-base-sms.h @@ -0,0 +1,126 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details: + * + * Author: Aleksander Morgado <aleksander@lanedo.com> + * + * Copyright (C) 2012 Google, Inc. + */ + +#ifndef MM_BASE_SMS_H +#define MM_BASE_SMS_H + +#include <glib.h> +#include <glib-object.h> + +#define _LIBMM_INSIDE_MM +#include <libmm-glib.h> + +#include "mm-sms-part.h" +#include "mm-base-modem.h" + +#define MM_TYPE_BASE_SMS (mm_base_sms_get_type ()) +#define MM_BASE_SMS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BASE_SMS, MMBaseSms)) +#define MM_BASE_SMS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BASE_SMS, MMBaseSmsClass)) +#define MM_IS_BASE_SMS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BASE_SMS)) +#define MM_IS_BASE_SMS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BASE_SMS)) +#define MM_BASE_SMS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BASE_SMS, MMBaseSmsClass)) + +typedef struct _MMBaseSms MMBaseSms; +typedef struct _MMBaseSmsClass MMBaseSmsClass; +typedef struct _MMBaseSmsPrivate MMBaseSmsPrivate; + +#define MM_BASE_SMS_PATH "sms-path" +#define MM_BASE_SMS_CONNECTION "sms-connection" +#define MM_BASE_SMS_MODEM "sms-modem" +#define MM_BASE_SMS_IS_MULTIPART "sms-is-multipart" +#define MM_BASE_SMS_MAX_PARTS "sms-max-parts" +#define MM_BASE_SMS_MULTIPART_REFERENCE "sms-multipart-reference" + +struct _MMBaseSms { + MmGdbusSmsSkeleton parent; + MMBaseSmsPrivate *priv; +}; + +struct _MMBaseSmsClass { + MmGdbusSmsSkeletonClass parent; + + /* Store the SMS */ + void (* store) (MMBaseSms *self, + MMSmsStorage storage, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* store_finish) (MMBaseSms *self, + GAsyncResult *res, + GError **error); + + /* Send the SMS */ + void (* send) (MMBaseSms *self, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* send_finish) (MMBaseSms *self, + GAsyncResult *res, + GError **error); + + /* Delete the SMS */ + void (* delete) (MMBaseSms *self, + GAsyncReadyCallback callback, + gpointer user_data); + gboolean (* delete_finish) (MMBaseSms *self, + GAsyncResult *res, + GError **error); +}; + +GType mm_base_sms_get_type (void); + +/* This one can be overriden by plugins */ +MMBaseSms *mm_base_sms_new (MMBaseModem *modem); +MMBaseSms *mm_base_sms_new_from_properties (MMBaseModem *modem, + MMSmsProperties *properties, + GError **error); +MMBaseSms *mm_base_sms_singlepart_new (MMBaseModem *modem, + MMSmsState state, + MMSmsStorage storage, + MMSmsPart *part, + GError **error); +MMBaseSms *mm_base_sms_multipart_new (MMBaseModem *modem, + MMSmsState state, + MMSmsStorage storage, + guint reference, + guint max_parts, + MMSmsPart *first_part, + GError **error); +gboolean mm_base_sms_multipart_take_part (MMBaseSms *self, + MMSmsPart *part, + GError **error); + +void mm_base_sms_export (MMBaseSms *self); +void mm_base_sms_unexport (MMBaseSms *self); +const gchar *mm_base_sms_get_path (MMBaseSms *self); +MMSmsStorage mm_base_sms_get_storage (MMBaseSms *self); + +gboolean mm_base_sms_has_part_index (MMBaseSms *self, + guint index); +GList *mm_base_sms_get_parts (MMBaseSms *self); + +gboolean mm_base_sms_is_multipart (MMBaseSms *self); +guint mm_base_sms_get_multipart_reference (MMBaseSms *self); +gboolean mm_base_sms_multipart_is_complete (MMBaseSms *self); +gboolean mm_base_sms_multipart_is_assembled (MMBaseSms *self); + +void mm_base_sms_delete (MMBaseSms *self, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean mm_base_sms_delete_finish (MMBaseSms *self, + GAsyncResult *res, + GError **error); + +#endif /* MM_BASE_SMS_H */ diff --git a/src/mm-broadband-modem-mbim.c b/src/mm-broadband-modem-mbim.c index f65896560..1a5c34b70 100644 --- a/src/mm-broadband-modem-mbim.c +++ b/src/mm-broadband-modem-mbim.c @@ -2811,7 +2811,7 @@ enable_unsolicited_events_messaging (MMIfaceModemMessaging *self, /*****************************************************************************/ /* Create SMS (Messaging interface) */ -static MMSms * +static MMBaseSms * messaging_create_sms (MMIfaceModemMessaging *self) { return mm_sms_mbim_new (MM_BASE_MODEM (self)); diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c index ef5bb5696..872b00534 100644 --- a/src/mm-broadband-modem-qmi.c +++ b/src/mm-broadband-modem-qmi.c @@ -7610,7 +7610,7 @@ messaging_enable_unsolicited_events (MMIfaceModemMessaging *_self, /*****************************************************************************/ /* Create SMS (Messaging interface) */ -static MMSms * +static MMBaseSms * messaging_create_sms (MMIfaceModemMessaging *_self) { MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self); diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c index fd4852cb9..7089737cd 100644 --- a/src/mm-broadband-modem.c +++ b/src/mm-broadband-modem.c @@ -6193,10 +6193,10 @@ modem_messaging_load_initial_sms_parts (MMIfaceModemMessaging *self, /*****************************************************************************/ /* Create SMS (Messaging interface) */ -static MMSms * +static MMBaseSms * modem_messaging_create_sms (MMIfaceModemMessaging *self) { - return mm_sms_new (MM_BASE_MODEM (self)); + return mm_base_sms_new (MM_BASE_MODEM (self)); } /*****************************************************************************/ diff --git a/src/mm-iface-modem-messaging.c b/src/mm-iface-modem-messaging.c index 06770f392..d2ef6e863 100644 --- a/src/mm-iface-modem-messaging.c +++ b/src/mm-iface-modem-messaging.c @@ -88,7 +88,7 @@ mm_iface_modem_messaging_bind_simple_status (MMIfaceModemMessaging *self, /*****************************************************************************/ -MMSms * +MMBaseSms * mm_iface_modem_messaging_create_sms (MMIfaceModemMessaging *self) { g_assert (MM_IFACE_MODEM_MESSAGING_GET_INTERFACE (self)->create_sms != NULL); @@ -271,7 +271,7 @@ handle_create_auth_ready (MMBaseModem *self, MMSmsList *list = NULL; GError *error = NULL; MMSmsProperties *properties; - MMSms *sms; + MMBaseSms *sms; if (!mm_base_modem_authorize_finish (self, res, &error)) { g_dbus_method_invocation_take_error (ctx->invocation, error); @@ -300,9 +300,9 @@ handle_create_auth_ready (MMBaseModem *self, return; } - sms = mm_sms_new_from_properties (MM_BASE_MODEM (self), - properties, - &error); + sms = mm_base_sms_new_from_properties (MM_BASE_MODEM (self), + properties, + &error); if (!sms) { g_object_unref (properties); g_dbus_method_invocation_take_error (ctx->invocation, error); @@ -330,7 +330,7 @@ handle_create_auth_ready (MMBaseModem *self, /* Complete the DBus call */ mm_gdbus_modem_messaging_complete_create (ctx->skeleton, ctx->invocation, - mm_sms_get_path (sms)); + mm_base_sms_get_path (sms)); g_object_unref (sms); g_object_unref (properties); diff --git a/src/mm-iface-modem-messaging.h b/src/mm-iface-modem-messaging.h index 7ded66452..c27e100cb 100644 --- a/src/mm-iface-modem-messaging.h +++ b/src/mm-iface-modem-messaging.h @@ -23,7 +23,7 @@ #include <libmm-glib.h> #include "mm-sms-part.h" -#include "mm-sms.h" +#include "mm-base-sms.h" #define MM_TYPE_IFACE_MODEM_MESSAGING (mm_iface_modem_messaging_get_type ()) #define MM_IFACE_MODEM_MESSAGING(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_IFACE_MODEM_MESSAGING, MMIfaceModemMessaging)) @@ -123,7 +123,7 @@ struct _MMIfaceModemMessaging { GError **error); /* Create SMS objects */ - MMSms * (* create_sms) (MMIfaceModemMessaging *self); + MMBaseSms * (* create_sms) (MMIfaceModemMessaging *self); }; GType mm_iface_modem_messaging_get_type (void); @@ -176,7 +176,7 @@ gboolean mm_iface_modem_messaging_is_storage_supported_for_receiving (MMIfaceMod GError **error); /* SMS creation */ -MMSms *mm_iface_modem_messaging_create_sms (MMIfaceModemMessaging *self); +MMBaseSms *mm_iface_modem_messaging_create_sms (MMIfaceModemMessaging *self); /* Look for a new valid multipart reference */ guint8 mm_iface_modem_messaging_get_local_multipart_reference (MMIfaceModemMessaging *self, diff --git a/src/mm-sms-list.c b/src/mm-sms-list.c index dea6fd5d5..e98bd8c28 100644 --- a/src/mm-sms-list.c +++ b/src/mm-sms-list.c @@ -26,7 +26,7 @@ #include "mm-iface-modem-messaging.h" #include "mm-sms-list.h" -#include "mm-sms.h" +#include "mm-base-sms.h" #include "mm-log.h" G_DEFINE_TYPE (MMSmsList, mm_sms_list, G_TYPE_OBJECT); @@ -65,12 +65,12 @@ mm_sms_list_has_local_multipart_reference (MMSmsList *self, g_assert (reference != 0); for (l = self->priv->list; l; l = g_list_next (l)) { - MMSms *sms = MM_SMS (l->data); + MMBaseSms *sms = MM_BASE_SMS (l->data); - if (mm_sms_is_multipart (sms) && + if (mm_base_sms_is_multipart (sms) && mm_gdbus_sms_get_pdu_type (MM_GDBUS_SMS (sms)) == MM_SMS_PDU_TYPE_SUBMIT && - mm_sms_get_storage (sms) != MM_SMS_STORAGE_UNKNOWN && - mm_sms_get_multipart_reference (sms) == reference && + mm_base_sms_get_storage (sms) != MM_SMS_STORAGE_UNKNOWN && + mm_base_sms_get_multipart_reference (sms) == reference && g_str_equal (mm_gdbus_sms_get_number (MM_GDBUS_SMS (sms)), number)) { /* Yes, the SMS list has an SMS with the same destination number * and multipart reference */ @@ -103,7 +103,7 @@ mm_sms_list_get_paths (MMSmsList *self) const gchar *path; /* Don't try to add NULL paths (not yet exported SMS objects) */ - path = mm_sms_get_path (MM_SMS (l->data)); + path = mm_base_sms_get_path (MM_BASE_SMS (l->data)); if (path) path_list[i++] = g_strdup (path); } @@ -138,21 +138,21 @@ mm_sms_list_delete_sms_finish (MMSmsList *self, } static guint -cmp_sms_by_path (MMSms *sms, +cmp_sms_by_path (MMBaseSms *sms, const gchar *path) { - return g_strcmp0 (mm_sms_get_path (sms), path); + return g_strcmp0 (mm_base_sms_get_path (sms), path); } static void -delete_ready (MMSms *sms, +delete_ready (MMBaseSms *sms, GAsyncResult *res, DeleteSmsContext *ctx) { GError *error = NULL; GList *l; - if (!mm_sms_delete_finish (sms, res, &error)) { + if (!mm_base_sms_delete_finish (sms, res, &error)) { /* We report the error */ g_simple_async_result_take_error (ctx->result, error); delete_sms_context_complete_and_free (ctx); @@ -164,14 +164,14 @@ delete_ready (MMSms *sms, ctx->path, (GCompareFunc)cmp_sms_by_path); if (l) { - g_object_unref (MM_SMS (l->data)); + g_object_unref (MM_BASE_SMS (l->data)); ctx->self->priv->list = g_list_delete_link (ctx->self->priv->list, l); } /* We don't need to unref the SMS any more, but we can use the * reference we got in the method, which is the one kept alive * during the async operation. */ - mm_sms_unexport (sms); + mm_base_sms_unexport (sms); g_signal_emit (ctx->self, signals[SIGNAL_DELETED], 0, @@ -213,33 +213,33 @@ mm_sms_list_delete_sms (MMSmsList *self, user_data, mm_sms_list_delete_sms); - mm_sms_delete (MM_SMS (l->data), - (GAsyncReadyCallback)delete_ready, - ctx); + mm_base_sms_delete (MM_BASE_SMS (l->data), + (GAsyncReadyCallback)delete_ready, + ctx); } /*****************************************************************************/ void mm_sms_list_add_sms (MMSmsList *self, - MMSms *sms) + MMBaseSms *sms) { self->priv->list = g_list_prepend (self->priv->list, g_object_ref (sms)); g_signal_emit (self, signals[SIGNAL_ADDED], 0, - mm_sms_get_path (sms), + mm_base_sms_get_path (sms), FALSE); } /*****************************************************************************/ static guint -cmp_sms_by_concat_reference (MMSms *sms, +cmp_sms_by_concat_reference (MMBaseSms *sms, gpointer user_data) { - if (!mm_sms_is_multipart (sms)) + if (!mm_base_sms_is_multipart (sms)) return -1; - return (GPOINTER_TO_UINT (user_data) - mm_sms_get_multipart_reference (sms)); + return (GPOINTER_TO_UINT (user_data) - mm_base_sms_get_multipart_reference (sms)); } typedef struct { @@ -248,11 +248,11 @@ typedef struct { } PartIndexAndStorage; static guint -cmp_sms_by_part_index_and_storage (MMSms *sms, +cmp_sms_by_part_index_and_storage (MMBaseSms *sms, PartIndexAndStorage *ctx) { - return !(mm_sms_get_storage (sms) == ctx->storage && - mm_sms_has_part_index (sms, ctx->part_index)); + return !(mm_base_sms_get_storage (sms) == ctx->storage && + mm_base_sms_has_part_index (sms, ctx->part_index)); } static gboolean @@ -262,19 +262,19 @@ take_singlepart (MMSmsList *self, MMSmsStorage storage, GError **error) { - MMSms *sms; + MMBaseSms *sms; - sms = mm_sms_singlepart_new (self->priv->modem, - state, - storage, - part, - error); + sms = mm_base_sms_singlepart_new (self->priv->modem, + state, + storage, + part, + error); if (!sms) return FALSE; self->priv->list = g_list_prepend (self->priv->list, sms); g_signal_emit (self, signals[SIGNAL_ADDED], 0, - mm_sms_get_path (sms), + mm_base_sms_get_path (sms), state == MM_SMS_STATE_RECEIVED); return TRUE; } @@ -287,7 +287,7 @@ take_multipart (MMSmsList *self, GError **error) { GList *l; - MMSms *sms; + MMBaseSms *sms; guint concat_reference; concat_reference = mm_sms_part_get_concat_reference (part); @@ -296,22 +296,22 @@ take_multipart (MMSmsList *self, (GCompareFunc)cmp_sms_by_concat_reference); if (l) /* Try to take the part */ - return mm_sms_multipart_take_part (MM_SMS (l->data), part, error); + return mm_base_sms_multipart_take_part (MM_BASE_SMS (l->data), part, error); /* Create new Multipart */ - sms = mm_sms_multipart_new (self->priv->modem, - state, - storage, - concat_reference, - mm_sms_part_get_concat_max (part), - part, - error); + sms = mm_base_sms_multipart_new (self->priv->modem, + state, + storage, + concat_reference, + mm_sms_part_get_concat_max (part), + part, + error); if (!sms) return FALSE; self->priv->list = g_list_prepend (self->priv->list, sms); g_signal_emit (self, signals[SIGNAL_ADDED], 0, - mm_sms_get_path (sms), + mm_base_sms_get_path (sms), (state == MM_SMS_STATE_RECEIVED || state == MM_SMS_STATE_RECEIVING)); diff --git a/src/mm-sms-list.h b/src/mm-sms-list.h index b98e71fb1..293706578 100644 --- a/src/mm-sms-list.h +++ b/src/mm-sms-list.h @@ -72,7 +72,7 @@ gboolean mm_sms_list_take_part (MMSmsList *self, GError **error); void mm_sms_list_add_sms (MMSmsList *self, - MMSms *sms); + MMBaseSms *sms); void mm_sms_list_delete_sms (MMSmsList *self, const gchar *sms_path, diff --git a/src/mm-sms-mbim.c b/src/mm-sms-mbim.c index e91f1266e..3bdd68a93 100644 --- a/src/mm-sms-mbim.c +++ b/src/mm-sms-mbim.c @@ -31,7 +31,7 @@ #include "mm-log.h" #include "mm-sms-part-3gpp.h" -G_DEFINE_TYPE (MMSmsMbim, mm_sms_mbim, MM_TYPE_SMS) +G_DEFINE_TYPE (MMSmsMbim, mm_sms_mbim, MM_TYPE_BASE_SMS) /*****************************************************************************/ @@ -44,7 +44,7 @@ peek_device (gpointer self, MMBaseModem *modem = NULL; g_object_get (G_OBJECT (self), - MM_SMS_MODEM, &modem, + MM_BASE_SMS_MODEM, &modem, NULL); g_assert (MM_IS_BASE_MODEM (modem)); @@ -74,7 +74,7 @@ peek_device (gpointer self, /* Send the SMS */ typedef struct { - MMSms *self; + MMBaseSms *self; MMBaseModem *modem; MbimDevice *device; GSimpleAsyncResult *result; @@ -93,7 +93,7 @@ sms_send_context_complete_and_free (SmsSendContext *ctx) } static gboolean -sms_send_finish (MMSms *self, +sms_send_finish (MMBaseSms *self, GAsyncResult *res, GError **error) { @@ -180,7 +180,7 @@ sms_send_next_part (SmsSendContext *ctx) } static void -sms_send (MMSms *self, +sms_send (MMBaseSms *self, GAsyncReadyCallback callback, gpointer user_data) { @@ -199,17 +199,17 @@ sms_send (MMSms *self, ctx->self = g_object_ref (self); ctx->device = g_object_ref (device); g_object_get (self, - MM_SMS_MODEM, &ctx->modem, + MM_BASE_SMS_MODEM, &ctx->modem, NULL); - ctx->current = mm_sms_get_parts (self);; + ctx->current = mm_base_sms_get_parts (self);; sms_send_next_part (ctx); } /*****************************************************************************/ typedef struct { - MMSms *self; + MMBaseSms *self; MMBaseModem *modem; MbimDevice *device; GSimpleAsyncResult *result; @@ -229,7 +229,7 @@ sms_delete_parts_context_complete_and_free (SmsDeletePartsContext *ctx) } static gboolean -sms_delete_finish (MMSms *self, +sms_delete_finish (MMBaseSms *self, GAsyncResult *res, GError **error) { @@ -308,7 +308,7 @@ delete_next_part (SmsDeletePartsContext *ctx) } static void -sms_delete (MMSms *self, +sms_delete (MMBaseSms *self, GAsyncReadyCallback callback, gpointer user_data) { @@ -326,22 +326,22 @@ sms_delete (MMSms *self, ctx->self = g_object_ref (self); ctx->device = g_object_ref (device); g_object_get (self, - MM_SMS_MODEM, &ctx->modem, + MM_BASE_SMS_MODEM, &ctx->modem, NULL); /* Go on deleting parts */ - ctx->current = mm_sms_get_parts (self); + ctx->current = mm_base_sms_get_parts (self); delete_next_part (ctx); } /*****************************************************************************/ -MMSms * +MMBaseSms * mm_sms_mbim_new (MMBaseModem *modem) { - return MM_SMS (g_object_new (MM_TYPE_SMS_MBIM, - MM_SMS_MODEM, modem, - NULL)); + return MM_BASE_SMS (g_object_new (MM_TYPE_SMS_MBIM, + MM_BASE_SMS_MODEM, modem, + NULL)); } static void @@ -352,12 +352,12 @@ mm_sms_mbim_init (MMSmsMbim *self) static void mm_sms_mbim_class_init (MMSmsMbimClass *klass) { - MMSmsClass *sms_class = MM_SMS_CLASS (klass); - - sms_class->store = NULL; - sms_class->store_finish = NULL; - sms_class->send = sms_send; - sms_class->send_finish = sms_send_finish; - sms_class->delete = sms_delete; - sms_class->delete_finish = sms_delete_finish; + MMBaseSmsClass *base_sms_class = MM_BASE_SMS_CLASS (klass); + + base_sms_class->store = NULL; + base_sms_class->store_finish = NULL; + base_sms_class->send = sms_send; + base_sms_class->send_finish = sms_send_finish; + base_sms_class->delete = sms_delete; + base_sms_class->delete_finish = sms_delete_finish; } diff --git a/src/mm-sms-mbim.h b/src/mm-sms-mbim.h index 93dc77302..f2f6f3ac1 100644 --- a/src/mm-sms-mbim.h +++ b/src/mm-sms-mbim.h @@ -22,7 +22,7 @@ #define _LIBMM_INSIDE_MM #include <libmm-glib.h> -#include "mm-sms.h" +#include "mm-base-sms.h" #define MM_TYPE_SMS_MBIM (mm_sms_mbim_get_type ()) #define MM_SMS_MBIM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_SMS_MBIM, MMSmsMbim)) @@ -35,15 +35,15 @@ typedef struct _MMSmsMbim MMSmsMbim; typedef struct _MMSmsMbimClass MMSmsMbimClass; struct _MMSmsMbim { - MMSms parent; + MMBaseSms parent; }; struct _MMSmsMbimClass { - MMSmsClass parent; + MMBaseSmsClass parent; }; GType mm_sms_mbim_get_type (void); -MMSms *mm_sms_mbim_new (MMBaseModem *modem); +MMBaseSms *mm_sms_mbim_new (MMBaseModem *modem); #endif /* MM_SMS_MBIM_H */ diff --git a/src/mm-sms-qmi.c b/src/mm-sms-qmi.c index 2e1fef755..6f6048446 100644 --- a/src/mm-sms-qmi.c +++ b/src/mm-sms-qmi.c @@ -33,7 +33,7 @@ #include "mm-sms-part-cdma.h" #include "mm-log.h" -G_DEFINE_TYPE (MMSmsQmi, mm_sms_qmi, MM_TYPE_SMS); +G_DEFINE_TYPE (MMSmsQmi, mm_sms_qmi, MM_TYPE_BASE_SMS) /*****************************************************************************/ @@ -49,7 +49,7 @@ ensure_qmi_client (MMSmsQmi *self, MMPortQmi *port; g_object_get (self, - MM_SMS_MODEM, &modem, + MM_BASE_SMS_MODEM, &modem, NULL); g_assert (MM_IS_BASE_MODEM (modem)); @@ -115,7 +115,7 @@ check_sms_type_support (MMSmsQmi *self, /* Store the SMS */ typedef struct { - MMSms *self; + MMBaseSms *self; MMBaseModem *modem; QmiClientWms *client; GSimpleAsyncResult *result; @@ -135,7 +135,7 @@ sms_store_context_complete_and_free (SmsStoreContext *ctx) } static gboolean -sms_store_finish (MMSms *self, +sms_store_finish (MMBaseSms *self, GAsyncResult *res, GError **error) { @@ -177,7 +177,7 @@ store_ready (QmiClientWms *client, qmi_message_wms_raw_write_output_unref (output); /* Set the index in the part we hold */ - parts = mm_sms_get_parts (ctx->self); + parts = mm_base_sms_get_parts (ctx->self); mm_sms_part_set_index ((MMSmsPart *)parts->data, (guint)idx); /* Go on with next one */ @@ -250,7 +250,7 @@ sms_store_next_part (SmsStoreContext *ctx) } static void -sms_store (MMSms *self, +sms_store (MMBaseSms *self, MMSmsStorage storage, GAsyncReadyCallback callback, gpointer user_data) @@ -275,10 +275,10 @@ sms_store (MMSms *self, ctx->client = g_object_ref (client); ctx->storage = storage; g_object_get (self, - MM_SMS_MODEM, &ctx->modem, + MM_BASE_SMS_MODEM, &ctx->modem, NULL); - ctx->current = mm_sms_get_parts (self); + ctx->current = mm_base_sms_get_parts (self); /* Check whether we support the given SMS type */ if (!check_sms_type_support (MM_SMS_QMI (self), ctx->modem, (MMSmsPart *)ctx->current->data, &error)) { @@ -295,7 +295,7 @@ sms_store (MMSms *self, /* Send the SMS */ typedef struct { - MMSms *self; + MMBaseSms *self; MMBaseModem *modem; QmiClientWms *client; GSimpleAsyncResult *result; @@ -315,7 +315,7 @@ sms_send_context_complete_and_free (SmsSendContext *ctx) } static gboolean -sms_send_finish (MMSms *self, +sms_send_finish (MMBaseSms *self, GAsyncResult *res, GError **error) { @@ -534,7 +534,7 @@ sms_send_from_storage (SmsSendContext *ctx) qmi_message_wms_send_from_memory_storage_input_set_information ( input, - mm_sms_storage_to_qmi_storage_type (mm_sms_get_storage (ctx->self)), + mm_sms_storage_to_qmi_storage_type (mm_base_sms_get_storage (ctx->self)), mm_sms_part_get_index ((MMSmsPart *)ctx->current->data), (MM_SMS_PART_IS_3GPP ((MMSmsPart *)ctx->current->data) ? QMI_WMS_MESSAGE_MODE_GSM_WCDMA : @@ -569,7 +569,7 @@ sms_send_next_part (SmsSendContext *ctx) } static void -sms_send (MMSms *self, +sms_send (MMBaseSms *self, GAsyncReadyCallback callback, gpointer user_data) { @@ -592,13 +592,13 @@ sms_send (MMSms *self, ctx->self = g_object_ref (self); ctx->client = g_object_ref (client); g_object_get (self, - MM_SMS_MODEM, &ctx->modem, + MM_BASE_SMS_MODEM, &ctx->modem, NULL); /* If the SMS is STORED, try to send from storage */ - ctx->from_storage = (mm_sms_get_storage (self) != MM_SMS_STORAGE_UNKNOWN); + ctx->from_storage = (mm_base_sms_get_storage (self) != MM_SMS_STORAGE_UNKNOWN); - ctx->current = mm_sms_get_parts (self); + ctx->current = mm_base_sms_get_parts (self); /* Check whether we support the given SMS type */ if (!check_sms_type_support (MM_SMS_QMI (self), ctx->modem, (MMSmsPart *)ctx->current->data, &error)) { @@ -613,7 +613,7 @@ sms_send (MMSms *self, /*****************************************************************************/ typedef struct { - MMSms *self; + MMBaseSms *self; MMBaseModem *modem; QmiClientWms *client; GSimpleAsyncResult *result; @@ -633,7 +633,7 @@ sms_delete_parts_context_complete_and_free (SmsDeletePartsContext *ctx) } static gboolean -sms_delete_finish (MMSms *self, +sms_delete_finish (MMBaseSms *self, GAsyncResult *res, GError **error) { @@ -703,7 +703,7 @@ delete_next_part (SmsDeletePartsContext *ctx) input = qmi_message_wms_delete_input_new (); qmi_message_wms_delete_input_set_memory_storage ( input, - mm_sms_storage_to_qmi_storage_type (mm_sms_get_storage (ctx->self)), + mm_sms_storage_to_qmi_storage_type (mm_base_sms_get_storage (ctx->self)), NULL); qmi_message_wms_delete_input_set_memory_index ( input, @@ -725,7 +725,7 @@ delete_next_part (SmsDeletePartsContext *ctx) } static void -sms_delete (MMSms *self, +sms_delete (MMBaseSms *self, GAsyncReadyCallback callback, gpointer user_data) { @@ -746,22 +746,22 @@ sms_delete (MMSms *self, ctx->self = g_object_ref (self); ctx->client = g_object_ref (client); g_object_get (self, - MM_SMS_MODEM, &ctx->modem, + MM_BASE_SMS_MODEM, &ctx->modem, NULL); /* Go on deleting parts */ - ctx->current = mm_sms_get_parts (self); + ctx->current = mm_base_sms_get_parts (self); delete_next_part (ctx); } /*****************************************************************************/ -MMSms * +MMBaseSms * mm_sms_qmi_new (MMBaseModem *modem) { - return MM_SMS (g_object_new (MM_TYPE_SMS_QMI, - MM_SMS_MODEM, modem, - NULL)); + return MM_BASE_SMS (g_object_new (MM_TYPE_SMS_QMI, + MM_BASE_SMS_MODEM, modem, + NULL)); } static void @@ -772,12 +772,12 @@ mm_sms_qmi_init (MMSmsQmi *self) static void mm_sms_qmi_class_init (MMSmsQmiClass *klass) { - MMSmsClass *sms_class = MM_SMS_CLASS (klass); - - sms_class->store = sms_store; - sms_class->store_finish = sms_store_finish; - sms_class->send = sms_send; - sms_class->send_finish = sms_send_finish; - sms_class->delete = sms_delete; - sms_class->delete_finish = sms_delete_finish; + MMBaseSmsClass *base_sms_class = MM_BASE_SMS_CLASS (klass); + + base_sms_class->store = sms_store; + base_sms_class->store_finish = sms_store_finish; + base_sms_class->send = sms_send; + base_sms_class->send_finish = sms_send_finish; + base_sms_class->delete = sms_delete; + base_sms_class->delete_finish = sms_delete_finish; } diff --git a/src/mm-sms-qmi.h b/src/mm-sms-qmi.h index bceb300fa..64a2f300a 100644 --- a/src/mm-sms-qmi.h +++ b/src/mm-sms-qmi.h @@ -24,7 +24,7 @@ #define _LIBMM_INSIDE_MM #include <libmm-glib.h> -#include "mm-sms.h" +#include "mm-base-sms.h" #define MM_TYPE_SMS_QMI (mm_sms_qmi_get_type ()) #define MM_SMS_QMI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_SMS_QMI, MMSmsQmi)) @@ -37,15 +37,15 @@ typedef struct _MMSmsQmi MMSmsQmi; typedef struct _MMSmsQmiClass MMSmsQmiClass; struct _MMSmsQmi { - MMSms parent; + MMBaseSms parent; }; struct _MMSmsQmiClass { - MMSmsClass parent; + MMBaseSmsClass parent; }; GType mm_sms_qmi_get_type (void); -MMSms *mm_sms_qmi_new (MMBaseModem *modem); +MMBaseSms *mm_sms_qmi_new (MMBaseModem *modem); #endif /* MM_SMS_QMI_H */ diff --git a/src/mm-sms.h b/src/mm-sms.h deleted file mode 100644 index 0a3339f86..000000000 --- a/src/mm-sms.h +++ /dev/null @@ -1,129 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details: - * - * Author: Aleksander Morgado <aleksander@lanedo.com> - * - * Copyright (C) 2012 Google, Inc. - */ - -#ifndef MM_SMS_H -#define MM_SMS_H - -#include <glib.h> -#include <glib-object.h> - -#define _LIBMM_INSIDE_MM -#include <libmm-glib.h> - -#include "mm-sms-part.h" -#include "mm-base-modem.h" - -#define MM_TYPE_SMS (mm_sms_get_type ()) -#define MM_SMS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_SMS, MMSms)) -#define MM_SMS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_SMS, MMSmsClass)) -#define MM_IS_SMS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_SMS)) -#define MM_IS_SMS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_SMS)) -#define MM_SMS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_SMS, MMSmsClass)) - -typedef struct _MMSms MMSms; -typedef struct _MMSmsClass MMSmsClass; -typedef struct _MMSmsPrivate MMSmsPrivate; - -#define MM_SMS_PATH "sms-path" -#define MM_SMS_CONNECTION "sms-connection" -#define MM_SMS_MODEM "sms-modem" -#define MM_SMS_IS_MULTIPART "sms-is-multipart" -#define MM_SMS_MAX_PARTS "sms-max-parts" -#define MM_SMS_MULTIPART_REFERENCE "sms-multipart-reference" - -struct _MMSms { - MmGdbusSmsSkeleton parent; - MMSmsPrivate *priv; -}; - -struct _MMSmsClass { - MmGdbusSmsSkeletonClass parent; - - /* Store the SMS */ - void (* store) (MMSms *self, - MMSmsStorage storage, - GAsyncReadyCallback callback, - gpointer user_data); - gboolean (* store_finish) (MMSms *self, - GAsyncResult *res, - GError **error); - - /* Send the SMS */ - void (* send) (MMSms *self, - GAsyncReadyCallback callback, - gpointer user_data); - gboolean (* send_finish) (MMSms *self, - GAsyncResult *res, - GError **error); - - /* Delete the SMS */ - void (* delete) (MMSms *self, - GAsyncReadyCallback callback, - gpointer user_data); - gboolean (* delete_finish) (MMSms *self, - GAsyncResult *res, - GError **error); -}; - -GType mm_sms_get_type (void); - -/* This one can be overriden by plugins */ -MMSms *mm_sms_new (MMBaseModem *modem); - -MMSms *mm_sms_new_from_properties (MMBaseModem *modem, - MMSmsProperties *properties, - GError **error); - -MMSms *mm_sms_singlepart_new (MMBaseModem *modem, - MMSmsState state, - MMSmsStorage storage, - MMSmsPart *part, - GError **error); - -MMSms *mm_sms_multipart_new (MMBaseModem *modem, - MMSmsState state, - MMSmsStorage storage, - guint reference, - guint max_parts, - MMSmsPart *first_part, - GError **error); -gboolean mm_sms_multipart_take_part (MMSms *self, - MMSmsPart *part, - GError **error); - -void mm_sms_export (MMSms *self); -void mm_sms_unexport (MMSms *self); -const gchar *mm_sms_get_path (MMSms *self); -MMSmsStorage mm_sms_get_storage (MMSms *self); - -gboolean mm_sms_has_part_index (MMSms *self, - guint index); -GList *mm_sms_get_parts (MMSms *self); - -gboolean mm_sms_is_multipart (MMSms *self); -guint mm_sms_get_multipart_reference (MMSms *self); -gboolean mm_sms_multipart_is_complete (MMSms *self); -gboolean mm_sms_multipart_is_assembled (MMSms *self); - -void mm_sms_delete (MMSms *self, - GAsyncReadyCallback callback, - gpointer user_data); -gboolean mm_sms_delete_finish (MMSms *self, - GAsyncResult *res, - GError **error); - -#endif /* MM_SMS_H */ |