diff options
author | Pekka Pessi <Pekka.Pessi@nokia.com> | 2011-02-01 20:32:39 +0200 |
---|---|---|
committer | Pekka Pessi <Pekka.Pessi@nokia.com> | 2011-02-01 21:21:07 +0200 |
commit | 02afe5741229a998a2a1c55c18c473e0662d1a20 (patch) | |
tree | 1478ac52ad439728a75702248f65ba0f077fb50c | |
parent | bb07605ef81547a77bef438ac53fe10d89537584 (diff) |
Remove sms-glib
-rw-r--r-- | Makefile.am | 4 | ||||
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | modem/Makefile.am | 7 | ||||
-rw-r--r-- | modem/tests/Makefile.am | 1 | ||||
-rw-r--r-- | sms-glib/Makefile.am | 18 | ||||
-rw-r--r-- | sms-glib/debug.c | 71 | ||||
-rw-r--r-- | sms-glib/debug.h | 71 | ||||
-rw-r--r-- | sms-glib/deliver.c | 505 | ||||
-rw-r--r-- | sms-glib/deliver.h | 90 | ||||
-rw-r--r-- | sms-glib/enums.h | 103 | ||||
-rw-r--r-- | sms-glib/errors.c | 35 | ||||
-rw-r--r-- | sms-glib/errors.h | 40 | ||||
-rw-r--r-- | sms-glib/message.c | 121 | ||||
-rw-r--r-- | sms-glib/message.h | 67 | ||||
-rw-r--r-- | sms-glib/param-spec.c | 120 | ||||
-rw-r--r-- | sms-glib/param-spec.h | 41 | ||||
-rw-r--r-- | sms-glib/status-report.c | 521 | ||||
-rw-r--r-- | sms-glib/status-report.h | 86 | ||||
-rw-r--r-- | sms-glib/submit.c | 450 | ||||
-rw-r--r-- | sms-glib/submit.h | 98 | ||||
-rw-r--r-- | sms-glib/utils.c | 133 | ||||
-rw-r--r-- | sms-glib/utils.h | 41 | ||||
-rw-r--r-- | src/Makefile.am | 2 |
23 files changed, 3 insertions, 2625 deletions
diff --git a/Makefile.am b/Makefile.am index 06c8324..58d0f20 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,10 +8,10 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = tests ring-extensions sms-glib modem src docs tools scripts +SUBDIRS = tests ring-extensions modem src docs tools scripts TAGS: - find src sms-glib modem ring-extensions -name '*.[hc]' | \ + find src modem ring-extensions -name '*.[hc]' | \ xargs etags EXTRA_DIST = \ diff --git a/configure.ac b/configure.ac index 62651da..af7fedc 100644 --- a/configure.ac +++ b/configure.ac @@ -92,11 +92,10 @@ AC_CHECK_LIB([mlocknice], [mln_lock_data],, AC_SUBST([testdir],'${libdir}/tests/telepathy-ring-tests') AC_SUBST([includemodemdir],'${includedir}/modem-glib') -AC_SUBST([includesmsdir],'${includedir}/sms-glib') AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([modem/Makefile modem/tests/Makefile \ src/Makefile tests/Makefile docs/Makefile \ - scripts/Makefile sms-glib/Makefile \ + scripts/Makefile \ tools/Makefile ring-extensions/Makefile]) AC_OUTPUT diff --git a/modem/Makefile.am b/modem/Makefile.am index 6b84cf8..3dbab7a 100644 --- a/modem/Makefile.am +++ b/modem/Makefile.am @@ -80,10 +80,3 @@ CLEANFILES = ${BUILT_SOURCES} # ----------------------------------------------------------------------------- # include Makefile-tests.am - -noinst_LTLIBRARIES += libtest-modem-sms.la - -libtest_modem_sms_la_SOURCES = \ - $(nodist_libmodem_sms_glib_la_SOURCES) - -libtest_modem_sms_la_LIBADD = libmodem-glib.la diff --git a/modem/tests/Makefile.am b/modem/tests/Makefile.am index ffc882b..edd48e6 100644 --- a/modem/tests/Makefile.am +++ b/modem/tests/Makefile.am @@ -19,7 +19,6 @@ test_modem_SOURCES = \ test_modem_LDADD = \ ../libmodem-glib.la \ - ../../sms-glib/libsms-glib.la \ ../../tests/libtestcommon.la \ @TP_LIBS@ @DBUS_LIBS@ @GLIB_LIBS@ \ @CHECK_LIBS@ diff --git a/sms-glib/Makefile.am b/sms-glib/Makefile.am deleted file mode 100644 index 7950720..0000000 --- a/sms-glib/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -AM_CFLAGS = $(ERROR_CFLAGS) -I$(top_srcdir) \ - @GLIB_CFLAGS@ - -AM_CFLAGS += -DENABLE_DEBUG=1 - -lib_LTLIBRARIES = libsms-glib.la - -sms_g_includedir = $(includesmsdir)/sms-glib - -sms_g_include_HEADERS = \ - message.h deliver.h status-report.h submit.h \ - enums.h utils.h errors.h - -libsms_glib_la_SOURCES = \ - message.c deliver.c status-report.c submit.c utils.c \ - errors.c param-spec.h param-spec.c debug.h debug.c - -libsms_glib_la_LIBADD = @GLIB_LIBS@ diff --git a/sms-glib/debug.c b/sms-glib/debug.c deleted file mode 100644 index 39ad263..0000000 --- a/sms-glib/debug.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * sms-glib/debug.c - Debugging facilities - * - * Copyright (C) 2008-2010 Nokia Corporation - * @author Pekka Pessi <first.surname@nokia.com> - * - * This work is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This work 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this work; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "config.h" - -char const sms_g_log_domain[] = "sms-glib"; -#include "debug.h" - -#include <stdarg.h> -#include <string.h> - -static SMSGDebugFlags sms_g_debug_flags = 0; - -static const GDebugKey sms_g_debug_keys[] = { - { "submit", SMS_G_DEBUG_SUBMIT }, - { "deliver", SMS_G_DEBUG_DELIVER }, - { "status-report", SMS_G_DEBUG_STATUS_REPORT }, -}; - -void sms_g_debug_set_flags(int new_flags) -{ - sms_g_debug_flags |= new_flags; -} - -gboolean sms_g_debug_flag_is_set(int flag) -{ - return (sms_g_debug_flags & flag) != 0; -} - -void sms_g_debug(int flag, const gchar *format, ...) -{ - if (flag & sms_g_debug_flags) { - va_list args; - va_start(args, format); - g_logv(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, args); - va_end(args); - } -} - -void sms_g_debug_set_flags_from_env(void) -{ -#if ENABLE_DEBUG - const gchar *flags_string; - - flags_string = g_getenv("SMS_DEBUG"); - - if (flags_string) { - sms_g_debug_set_flags(g_parse_debug_string (flags_string, - sms_g_debug_keys, - G_N_ELEMENTS(sms_g_debug_keys))); - } -#endif /* ENABLE_DEBUG */ -} diff --git a/sms-glib/debug.h b/sms-glib/debug.h deleted file mode 100644 index 2cadf2d..0000000 --- a/sms-glib/debug.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * sms-glib/debug.h - Debugging facilities - * - * Copyright (C) 2008-2010 Nokia Corporation - * @author Pekka Pessi <first.surname@nokia.com> - * - * This work is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This work 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this work; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef _SMS_GLIB_DEBUG_H_ -#define _SMS_GLIB_DEBUG_H_ - -/* Include this file first */ -#define G_LOG_DOMAIN sms_g_log_domain - -extern char const sms_g_log_domain[]; - -#include <glib.h> -#include <sms-glib/utils.h> - -G_BEGIN_DECLS - -typedef enum -{ - SMS_G_DEBUG_DELIVER = 1 << 0, - SMS_G_DEBUG_STATUS_REPORT = 1 << 1, - SMS_G_DEBUG_SUBMIT = 1 << 2, -} SMSGDebugFlags; - -gboolean sms_g_debug_flag_is_set(int flag); -void sms_g_debug_set_flags(int flag); - -void sms_g_debug(int flag, const gchar *format, ...) - G_GNUC_PRINTF (2, 3); - -G_END_DECLS - -#ifdef ENABLE_DEBUG - -#define DEBUG(format, ...) \ - sms_g_debug(SMS_G_DEBUG_FLAG, "%s: " format, G_STRFUNC, ##__VA_ARGS__) - -#define DEBUGGING sms_g_debug_flag_is_set(SMS_G_DEBUG_FLAG) - -#else /* ENABLE_DEBUG */ - -#define DEBUG(format, ...) -#define DEBUGGING (0) - -#endif /* ENABLE_DEBUG */ - -#define GERROR_MSG_FMT "%s (%d@%s)" - -#define GERROR_MSG_CODE(e) \ - (e ? e->message : "no error"), \ - (e ? e->code : 0), \ - (e ? g_quark_to_string(e->domain) : "") - -#endif /* _SMS_GLIB_DEBUG_H_ */ diff --git a/sms-glib/deliver.c b/sms-glib/deliver.c deleted file mode 100644 index c5d12d6..0000000 --- a/sms-glib/deliver.c +++ /dev/null @@ -1,505 +0,0 @@ -/* - * sms-glib/deliver.c - SMSGDeliver class implementation - * - * Copyright (C) 2008-2010 Nokia Corporation - * @author Pekka Pessi <first.surname@nokia.com> - * - * This work is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This work 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this work; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "config.h" - -#define SMS_G_DEBUG_FLAG SMS_G_DEBUG_DELIVER - -#include "debug.h" - -#include "sms-glib/errors.h" -#include "sms-glib/enums.h" -#include "sms-glib/utils.h" -#include "sms-glib/message.h" -#include "sms-glib/deliver.h" -#include "sms-glib/param-spec.h" - -#include <stdlib.h> -#include <string.h> -#include <stdio.h> - -G_DEFINE_TYPE_WITH_CODE( - SMSGDeliver, sms_g_deliver, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE(SMS_G_TYPE_MESSAGE, NULL)); - -/* Properties */ -enum -{ - PROP_NONE, - PROP_MESSAGE_TYPE, - PROP_MO, - PROP_CONTENT_TYPE, - PROP_SMSC, - PROP_MESSAGE_TOKEN, - PROP_ORIGINATOR, - PROP_TEXT, - PROP_BINARY, - PROP_SMS_CLASS, - PROP_TIME_SENT, - PROP_TIME_RECEIVED, - PROP_TIME_DELIVERED, - PROP_MWI_TYPE, - PROP_MWI_ACTIVE, - PROP_MWI_DISCARD, - PROP_MWI_LINE, - PROP_MWI_MESSAGES, - LAST_PROPERTY -}; - -/* private data */ -struct _SMSGDeliverPrivate -{ - gchar *text; - gchar *originator; - gchar *message_token; /* Message ID */ - gchar *content_type; /* Content-type */ - gchar *smsc; - gchar *mwi_type; - GArray binary[1]; - - int sms_class; - - gint64 timestamp, received, delivered; -}; - -/* ---------------------------------------------------------------------- */ -/* GObject interface */ - -static void -sms_g_deliver_init(SMSGDeliver *self) -{ - DEBUG("enter"); - - self->priv = G_TYPE_INSTANCE_GET_PRIVATE( - self, SMS_G_TYPE_DELIVER, SMSGDeliverPrivate); - - DEBUG("return"); -} - -static void -sms_g_deliver_set_property(GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - SMSGDeliver *self = SMS_G_DELIVER(object); - SMSGDeliverPrivate *priv = self->priv; - - switch(property_id) { - case PROP_CONTENT_TYPE: - priv->content_type = g_value_dup_string(value); - break; - - case PROP_SMSC: - priv->smsc = g_value_dup_string(value); - break; - - case PROP_MESSAGE_TOKEN: - priv->message_token = g_value_dup_string(value); - break; - - case PROP_ORIGINATOR: - priv->originator = g_value_dup_string(value); - break; - - case PROP_TEXT: - priv->text = g_value_dup_string(value); - break; - - case PROP_TIME_RECEIVED: - priv->received = g_value_get_int64(value); - break; - - case PROP_TIME_DELIVERED: - priv->delivered = g_value_get_int64(value); - break; - - case PROP_MWI_TYPE: - priv->mwi_type = g_value_dup_string(value); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - break; - } -} - -static void -sms_g_deliver_get_property(GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - SMSGDeliver *self = SMS_G_DELIVER(object); - SMSGDeliverPrivate *priv = self->priv; - - switch(property_id) { - case PROP_MESSAGE_TYPE: - g_value_set_uint(value, SMS_G_TP_MTI_DELIVER); - break; - - case PROP_MO: - g_value_set_boolean(value, FALSE); - break; - - case PROP_CONTENT_TYPE: - g_value_set_string(value, priv->content_type); - break; - - case PROP_ORIGINATOR: - g_value_set_string(value, priv->originator); - break; - - case PROP_TEXT: - g_value_set_string(value, priv->text); - break; - - case PROP_BINARY: - g_value_set_boxed(value, priv->binary); - break; - - case PROP_SMSC: - g_value_set_string(value, priv->smsc ? priv->smsc : ""); - break; - - case PROP_SMS_CLASS: - g_value_set_int(value, sms_g_deliver_get_sms_class(self)); - break; - - case PROP_MESSAGE_TOKEN: - g_value_set_string(value, priv->message_token); - break; - - case PROP_TIME_SENT: - g_value_set_int64(value, priv->timestamp); - break; - - case PROP_TIME_RECEIVED: - g_value_set_int64(value, priv->received); - break; - - case PROP_TIME_DELIVERED: - g_value_set_int64(value, priv->delivered); - break; - - case PROP_MWI_TYPE: - g_value_set_string(value, priv->mwi_type); - break; - - /* TODO: */ - case PROP_MWI_ACTIVE: - g_value_set_boolean(value, FALSE); - break; - - case PROP_MWI_DISCARD: - g_value_set_boolean(value, FALSE); - break; - - case PROP_MWI_LINE: - g_value_set_uint(value, 0); - break; - - case PROP_MWI_MESSAGES: - g_value_set_uint(value, 0); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - break; - } -} - - -static void -sms_g_deliver_finalize(GObject *object) -{ - SMSGDeliver *self = SMS_G_DELIVER(object); - SMSGDeliverPrivate *priv = self->priv; - - DEBUG("SMSGDeliver: enter"); - - g_free(priv->text); - g_free(priv->originator); - g_free(priv->message_token); - g_free(priv->smsc); - g_free (priv->content_type); - g_free(priv->mwi_type); - - G_OBJECT_CLASS(sms_g_deliver_parent_class)->finalize(object); -} - - -static void -sms_g_deliver_class_init(SMSGDeliverClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS(klass); - - DEBUG("enter"); - - g_type_class_add_private(klass, sizeof (SMSGDeliverPrivate)); - - object_class->get_property = sms_g_deliver_get_property; - object_class->set_property = sms_g_deliver_set_property; - object_class->finalize = sms_g_deliver_finalize; - - /* Properties */ - g_object_class_override_property( - object_class, PROP_MESSAGE_TYPE, "message-type"); - - g_object_class_override_property( - object_class, PROP_MO, "mobile-originated"); - - g_object_class_override_property( - object_class, PROP_CONTENT_TYPE, "content-type"); - - g_object_class_install_property( - object_class, PROP_SMSC, - sms_g_param_spec_smsc(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property( - object_class, PROP_MESSAGE_TOKEN, - sms_g_param_spec_message_token(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property( - object_class, PROP_ORIGINATOR, - g_param_spec_string("originator", - "SMS Originator Address", - "ISDN Address for SMS originator", - NULL, /* default value */ - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property( - object_class, PROP_TEXT, - g_param_spec_string("text", - "Text Content", - "Text content", - NULL, /* default value */ - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property( - object_class, PROP_BINARY, - g_param_spec_boxed("binary", - "Binary content", - "Binary content", - SMS_G_TYPE_BYTE_ARRAY, /* GByteArray */ - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property( - object_class, PROP_SMS_CLASS, - sms_g_param_spec_sms_class(G_PARAM_READABLE)); - - g_object_class_install_property( - object_class, PROP_TIME_SENT, - sms_g_param_spec_time_sent(G_PARAM_READABLE)); - - g_object_class_install_property( - object_class, PROP_TIME_RECEIVED, - sms_g_param_spec_time_received(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property( - object_class, PROP_TIME_DELIVERED, - sms_g_param_spec_time_delivered(G_PARAM_READWRITE)); - - g_object_class_install_property( - object_class, PROP_MWI_TYPE, - g_param_spec_string("mwi-type", - "Message Waiting Indicator", - "Type of Message Waiting Indicator", - NULL, /* default value */ - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property( - object_class, PROP_MWI_ACTIVE, - g_param_spec_boolean("mwi-active", - "Message Waiting Indicator should be Active", - "When true, activate message waiting indicator for mwi-type, " - "when false, deactivate message waiting indicator.", - 0, /* default value */ - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property( - object_class, PROP_MWI_DISCARD, - g_param_spec_boolean("mwi-discard", - "Discard Message After Setting MWI", - "When true, this message can be discarded after mwi has been set. ", - 0, /* default value */ - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property( - object_class, PROP_MWI_LINE, - g_param_spec_uint("mwi-line", - "Message Waiting Indication Line", - "Line for Message Waiting Indication", - 0, 3, 0, /* default value */ - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property( - object_class, PROP_MWI_MESSAGES, - g_param_spec_uint("mwi-messages", - "Number of Waiting Messages", - "Number of Waiting Messages", - 0, 255, 0, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); -} - -/* --------------------------------------------------------------------------------- */ -/* sms_g_deliver interface */ - -gchar const * -sms_g_deliver_get_content_type(SMSGDeliver const *self) -{ - return SMS_G_IS_DELIVER(self) ? self->priv->content_type : NULL; -} - -gboolean -sms_g_deliver_is_type(SMSGDeliver const *self, gchar const *type) -{ - gchar const *self_type = sms_g_deliver_get_content_type(self); - - return self_type && type && g_ascii_strcasecmp(self_type, type) == 0; -} - -gboolean sms_g_deliver_is_text(SMSGDeliver const *self) -{ - return sms_g_deliver_is_type(self, "text/plain"); -} - -gboolean sms_g_deliver_is_vcard(SMSGDeliver const *self) -{ - return sms_g_deliver_is_type(self, "text/x-vcard"); -} - -gboolean sms_g_deliver_is_vcalendar(SMSGDeliver const *self) -{ - return sms_g_deliver_is_type(self, "text/x-vcalendar"); -} - -int sms_g_deliver_get_sms_class(SMSGDeliver const *self) -{ - if (SMS_G_IS_DELIVER(self) && self->priv->sms_class) - return self->priv->sms_class & 3; - else - return -1; -} - -/**sms_g_deliver_get_timestamp: - * @self: The SMSGDeliver object - * - * Returns: Timestamp from SMS Service Centre. - */ -time_t sms_g_deliver_get_timestamp(SMSGDeliver const *self) -{ - return (time_t)self->priv->timestamp; -} - -/**sms_g_deliver_get_received: - * @self: The SMSGDeliver object - * - * Returns: Timestamp when this message was received. - */ -time_t sms_g_deliver_get_received(SMSGDeliver const *self) -{ - return (time_t)self->priv->received; -} - -/**sms_g_deliver_get_received: - * @self: The SMSGDeliver object - * - * Returns: Timestamp when this message was delivered. - */ -time_t sms_g_deliver_get_delivered(SMSGDeliver const *self) -{ - return (time_t)self->priv->delivered; -} - -/** - * sms_g_deliver_get_originator: - * @self: The SMSGDeliver object - * - * Returns: Originator address. - */ -char const *sms_g_deliver_get_originator(SMSGDeliver const *self) -{ - return self->priv->originator; -} - -char const *sms_g_deliver_get_smsc(SMSGDeliver const *self) -{ - return self->priv->smsc ? self->priv->smsc : ""; -} - -char const *sms_g_deliver_get_message_token(SMSGDeliver const *self) -{ - return self->priv->message_token; -} - -char const *sms_g_deliver_get_text(SMSGDeliver const *self) -{ - return SMS_G_IS_DELIVER(self) ? self->priv->text : NULL; -} - -GArray const *sms_g_deliver_get_binary(SMSGDeliver const *self) -{ - return self->priv->binary ? self->priv->binary : NULL; -} - -SMSGDeliver * -sms_g_deliver_incoming(gchar const *message, - gchar const *message_token, - gchar const *originator, - gchar const *smsc, - gchar const *content_type, - gchar const *mwi_type, - GError **return_error) -{ - SMSGDeliver *object; - - if (!sms_g_validate_sms_address(smsc, return_error)) { - DEBUG("invalid SMSC number (%s)", smsc); - return NULL; - } - - if (!sms_g_validate_message_id(message_token, return_error)) { - DEBUG("invalid message id (%s)", message_token); - return NULL; - } - - object = g_object_new(SMS_G_TYPE_DELIVER, - "text", message, - "originator", originator, - "service-centre", smsc, - "message-token", message_token, - "content-type", content_type, - "time-received", sms_g_received_timestamp(), - "mwi-type", mwi_type, - NULL); - - return object; -} diff --git a/sms-glib/deliver.h b/sms-glib/deliver.h deleted file mode 100644 index 1b3c254..0000000 --- a/sms-glib/deliver.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * sms-deliver.h - wrapper class for SMS DELIVER messages - * - * Copyright (C) 2008-2010 Nokia Corporation - * @author Pekka Pessi <first.surname@nokia.com> - * - * This work is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This work 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this work; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __SMS_G_DELIVER_H__ -#define __SMS_G_DELIVER_H__ - -#include <glib-object.h> - -G_BEGIN_DECLS - -typedef struct _SMSGDeliver SMSGDeliver; -typedef struct _SMSGDeliverClass SMSGDeliverClass; -typedef struct _SMSGDeliverPrivate SMSGDeliverPrivate; - -struct _SMSGDeliverClass { - GObjectClass parent_class; -}; - -struct _SMSGDeliver { - GObject parent; - SMSGDeliverPrivate *priv; -}; - -GType sms_g_deliver_get_type(void); - -/* TYPE MACROS */ -#define SMS_G_TYPE_DELIVER \ - (sms_g_deliver_get_type()) -#define SMS_G_DELIVER(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), SMS_G_TYPE_DELIVER, SMSGDeliver)) -#define SMS_G_DELIVER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), SMS_G_TYPE_DELIVER, SMSGDeliverClass)) -#define SMS_G_IS_DELIVER(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), SMS_G_TYPE_DELIVER)) -#define SMS_G_IS_DELIVER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), SMS_G_TYPE_DELIVER)) -#define SMS_G_DELIVER_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), SMS_G_TYPE_DELIVER, SMSGDeliverClass)) - -/* SMSGDeliver interface */ - -gchar const *sms_g_deliver_get_content_type(SMSGDeliver const *self); - -gboolean sms_g_deliver_is_type(SMSGDeliver const *self, gchar const *type); - -gboolean sms_g_deliver_is_text(SMSGDeliver const *self); /* text/plain */ -gboolean sms_g_deliver_is_vcard(SMSGDeliver const *self); /* text/x-vcard */ -gboolean sms_g_deliver_is_vcalendar(SMSGDeliver const *self); /* text/x-vcalendar */ - -char const *sms_g_deliver_get_smsc(SMSGDeliver const *self); -char const *sms_g_deliver_get_text(SMSGDeliver const *self); -int sms_g_deliver_get_sms_class(SMSGDeliver const *self); -time_t sms_g_deliver_get_timestamp(SMSGDeliver const *self); -time_t sms_g_deliver_get_received(SMSGDeliver const *self); -time_t sms_g_deliver_get_delivered(SMSGDeliver const *self); -char const *sms_g_deliver_get_originator(SMSGDeliver const *self); -GArray const *sms_g_deliver_get_binary(SMSGDeliver const *self); -char const *sms_g_deliver_get_message_token(SMSGDeliver const *self); - -SMSGDeliver *sms_g_deliver_incoming(gchar const *message, - gchar const *message_token, - gchar const *originator, - gchar const *smsc, - gchar const *content_type, - gchar const *mwi_type, - GError **return_error); - -void sms_g_deliver_report(SMSGDeliver *self); - -G_END_DECLS - -#endif /* #ifndef __SMS_G_DELIVER_H__*/ diff --git a/sms-glib/enums.h b/sms-glib/enums.h deleted file mode 100644 index a0d4ccc..0000000 --- a/sms-glib/enums.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * sms-glib/enums.h - - * - * Copyright (C) 2008-2010 Nokia Corporation - * @author Pekka Pessi <first.surname@nokia.com> - * - * This work is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This work 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this work; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef SMS_GLIB_ENUMS_H -#define SMS_GLIB_ENUMS_H - -G_BEGIN_DECLS - -typedef enum { - sms_port_vcard = 0xe2, - sms_port_vcalendar = 0xe4, - sms_port_wap_vcard = 0x23f4, - sms_port_wap_vcalendar = 0x23f5, -} SMSGPortNumber; - -enum { - SMS_G_SUBMIT_MIN_LEN = 7, - SMS_G_DELIVER_MIN_LEN = 13, - SMS_G_STATUS_REPORT_MIN_LEN = 19, -}; - -/* Mask in first byte */ -enum { - SMS_G_TP_MTI_MASK = 0x03, - SMS_G_TP_MMS_MASK = 0x04, - SMS_G_TP_VPF_MASK = 0x18, /* in SMS-SUBMIT */ - SMS_G_TP_SRI_MASK = 0x20, /* in SMS-DELIVER */ - SMS_G_TP_SRR_MASK = 0x20, /* in SMS-SUBMIT */ - SMS_G_TP_SRQ_MASK = 0x20, /* in SMS-STATUS-REPORT */ - SMS_G_TP_UDHI_MASK = 0x40, - SMS_G_TP_RP_MASK = 0x80 /* in SMS-DELIVER/DELIVER */ -}; - - -enum { - SMS_G_TP_MMS = 0x04, - SMS_G_TP_SRI = 0x20, /* in SMS-DELIVER */ - SMS_G_TP_SRR = 0x20, /* in SMS-SUBMIT */ - SMS_G_TP_SRQ = 0x20, /* in SMS-STATUS-REPORT */ - SMS_G_TP_UDHI = 0x40, - SMS_G_TP_RP = 0x80 /* in SMS-DELIVER/DELIVER */ -}; - -enum { - SMS_G_TP_MTI_DELIVER = 0, - SMS_G_TP_MTI_DELIVER_REPORT = 0, - SMS_G_TP_MTI_SUBMIT = 1, - SMS_G_TP_MTI_SUBMIT_REPORT = 1, - SMS_G_TP_MTI_STATUS_REPORT = 2, - SMS_G_TP_MTI_COMMAND = 2 -}; - -enum { - SMS_G_TP_FCS_UNSUPPORTED_INTERWORKING = 0x80, - SMS_G_TP_FCS_UNSUPPORTED_TYPE_0 = 0x81, - SMS_G_TP_FCS_UNSUPPORTED_REPLACE = 0x82, - SMS_G_TP_FCS_PID_ERROR = 0x8f, - SMS_G_TP_FCS_UNSUPPORTED_ALPHABET = 0x90, - SMS_G_TP_FCS_UNSUPPORTED_CLASS = 0x91, - SMS_G_TP_FCS_DCS_ERROR = 0x9f, - SMS_G_TP_FCS_NO_COMMAND_ACTION = 0xa0, - SMS_G_TP_FCS_UNSUPPORTED_COMMAND = 0xa1, - SMS_G_TP_FCS_COMMAND_ERROR = 0xaf, - - SMS_G_TP_FCS_SC_BUSY = 0xc0, - SMS_G_TP_FCS_NO_SC_SUBSCRIPTION = 0xc1, - SMS_G_TP_FCS_INVALID_DESTINATION = 0xc2, - SMS_G_TP_FCS_BARRED_DESTINATION = 0xc3, - SMS_G_TP_FCS_REJECTED_DUPLICATE = 0xc4, - SMS_G_TP_FCS_UNSUPPORTED_VPF = 0xc5, - SMS_G_TP_FCS_UNSUPPORTED_VALIDITY = 0xc6, - - SMS_G_TP_FCS_SIM_STORAGE_FULL = 0xd0, - SMS_G_TP_FCS_NO_SIM_STORAGE = 0xd1, - SMS_G_TP_FCS_MS_ERROR = 0xd2, - SMS_G_TP_FCS_MEMORY_EXCEEDED = 0xd3, - SMS_G_TP_FCS_SIM_ATK_BUSY = 0xd4, - SMS_G_TP_FCS_SIM_DOWNLOAD_ERROR = 0xD5, - - SMS_G_TP_FCS_UNSPECIFIED = 0xff, -}; - -G_END_DECLS - -#endif /* SMS_GLIB_ENUMS_H */ diff --git a/sms-glib/errors.c b/sms-glib/errors.c deleted file mode 100644 index 73ca3d9..0000000 --- a/sms-glib/errors.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * sms-glib/errors.c - - * - * Copyright (C) 2008-2010 Nokia Corporation - * @author Pekka Pessi <first.surname@nokia.com> - * - * This work is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This work 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this work; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "config.h" - -#include <sms-glib/errors.h> -#include <glib/gstrfuncs.h> - -#include <stdarg.h> - -GQuark sms_g_errors_quark(void) -{ - static GQuark quark = 0; - if (G_UNLIKELY(quark == 0)) - quark = g_quark_from_static_string("SMSGErrors"); - return quark; -} diff --git a/sms-glib/errors.h b/sms-glib/errors.h deleted file mode 100644 index caf9bb1..0000000 --- a/sms-glib/errors.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * sms-glib/errors.h - - * - * Copyright (C) 2008-2010 Nokia Corporation - * @author Pekka Pessi <first.surname@nokia.com> - * - * This work is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This work 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this work; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __SMS_GLIB_ERRORS_H__ -#define __SMS_GLIB_ERRORS_H__ - -#include <glib-object.h> - -G_BEGIN_DECLS - -/** The error domain for sms-glib */ -#define SMS_G_ERRORS sms_g_errors_quark () - -GQuark sms_g_errors_quark(void); - -typedef enum { - SMS_G_ERROR_INVALID_PARAM = 0 -} SMSGErrors; - -G_END_DECLS - -#endif diff --git a/sms-glib/message.c b/sms-glib/message.c deleted file mode 100644 index 7ddc97e..0000000 --- a/sms-glib/message.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * sms-glib/message.c - SMS Message interface - * - * Copyright (C) 2008-2010 Nokia Corporation - * @author Pekka Pessi <first.surname@nokia.com> - * - * This work is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This work 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this work; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "config.h" - -#include "sms-glib/message.h" -#include "sms-glib/param-spec.h" -#include "sms-glib/enums.h" - -static void -sms_g_message_base_init(gpointer iface) -{ - static gboolean init; - - if (init) - return; - - init = TRUE; - - g_object_interface_install_property( - iface, g_param_spec_uint("message-type", - "SMS Message Type", - "Message Type for SMS", - SMS_G_TP_MTI_DELIVER_REPORT, /* min */ - SMS_G_TP_MTI_COMMAND, /* max */ - SMS_G_TP_MTI_SUBMIT, /* default value */ - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - - g_object_interface_install_property( - iface, g_param_spec_boolean("mobile-originated", - "SMS Message Originated from Mobile", - "Message Originated from Mobile", - FALSE, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - - g_object_interface_install_property( - iface, g_param_spec_string("content-type", - "MIME Type", - "MIME type for message contents", - "*/*", - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT | - G_PARAM_STATIC_STRINGS)); -} - - -GType -sms_g_message_get_type (void) -{ - static GType type; - - if (G_UNLIKELY(type == 0)) { - static const GTypeInfo info = { - .class_size = sizeof (SMSGMessageIface), - .base_init = sms_g_message_base_init, - }; - - type = g_type_register_static (G_TYPE_INTERFACE, "SMSGMessage", &info, 0); - } - - return type; -} - -/* ------------------------------------------------------------------------- */ - -static gpointer sms_g_byte_array_copy(gpointer boxed_byte_array); -static void sms_g_byte_array_free(gpointer boxed_byte_array); - -/** GType for GByteArray */ -GType -sms_g_byte_array_get_type (void) -{ - static GType type; - - if (G_UNLIKELY(type == 0)) { - type = g_boxed_type_register_static("SMSGByteArray", - sms_g_byte_array_copy, - sms_g_byte_array_free); - } - - return type; -} - -static gpointer -sms_g_byte_array_copy(gpointer boxed_byte_array) -{ - GByteArray const *s = boxed_byte_array; - GByteArray *d; - - if (s == NULL) - return NULL; - - d = g_byte_array_sized_new(s->len); - g_byte_array_append(d, s->data, s->len); - - return (gpointer)d; -} - -static void -sms_g_byte_array_free(gpointer boxed_byte_array) -{ - g_byte_array_free(boxed_byte_array, TRUE); -} diff --git a/sms-glib/message.h b/sms-glib/message.h deleted file mode 100644 index 766bb41..0000000 --- a/sms-glib/message.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * sms-glib/message.h - SMS message interface - * - * Copyright (C) 2008-2010 Nokia Corporation - * @author Pekka Pessi <first.surname@nokia.com> - * - * This work is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This work 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this work; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __SMS_G_MESSAGE_H__ -#define __SMS_G_MESSAGE_H__ - -#include <glib-object.h> - -G_BEGIN_DECLS - -typedef struct _SMSGMessage SMSGMessage; -typedef struct _SMSGMessageIface SMSGMessageIface; - -GType sms_g_message_get_type(void); - -/* TYPE MACROS */ -#define SMS_G_TYPE_MESSAGE \ - (sms_g_message_get_type()) -#define SMS_G_MESSAGE(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), SMS_G_TYPE_MESSAGE, SMSGMessage)) -#define SMS_G_IS_MESSAGE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), SMS_G_TYPE_MESSAGE)) -#define SMS_G_MESSAGE_GET_INTERFACE(obj) \ - (G_TYPE_INSTANCE_GET_INTERFACE((obj), SMS_G_TYPE_MESSAGE, SMSGMessageIface)) - -struct _SMSGMessageIface { - GTypeInterface parent; -}; - -enum { - /* Mobile-terminated */ - SMS_MESSAGE_TYPE_DELIVER = 0, - SMS_MESSAGE_TYPE_SUBMIT_REPORT = 1, - SMS_MESSAGE_TYPE_STATUS_REPORT = 2, - - /* Mobile-originated */ - SMS_MESSAGE_TYPE_DELIVER_REPORT = 0, - SMS_MESSAGE_TYPE_SUBMIT = 1, - SMS_MESSAGE_TYPE_COMMAND = 2 -}; - -/* GByteArray */ -#define SMS_G_TYPE_BYTE_ARRAY sms_g_byte_array_get_type() - -GType sms_g_byte_array_get_type(void); - -G_END_DECLS - -#endif /* #ifndef __SMS_G_MESSAGE_H__*/ diff --git a/sms-glib/param-spec.c b/sms-glib/param-spec.c deleted file mode 100644 index 0eef6e7..0000000 --- a/sms-glib/param-spec.c +++ /dev/null @@ -1,120 +0,0 @@ -/* - * sms-glib/param-spec.c - - * - * Copyright (C) 2008-2010 Nokia Corporation - * @author Pekka Pessi <first.surname@nokia.com> - * - * This work is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This work 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this work; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "config.h" - -#include "sms-glib/param-spec.h" -#include "sms-glib/enums.h" - -GParamSpec *sms_g_param_spec_smsc(guint flags) -{ - return - g_param_spec_string("service-centre", - "SMS Service Centre", - "ISDN Address for SMS Service Centre", - "", /* default value */ - flags | G_PARAM_STATIC_STRINGS); -} - -GParamSpec *sms_g_param_spec_validity_period(guint flags) -{ - return - g_param_spec_uint("validity-period", - "SMS Validity Period", - "Period while SMS service centre " - "keep trying to deliver SMS.", - /* anything above 0 gets rounded up to 5 minutes */ - 0, /* 0 means no validity period */ - 63 * 7 * 24 * 60 * 60, /* max - 63 weeks */ - 0, /* no validity period - it is up to service centre */ - flags | G_PARAM_STATIC_STRINGS); -} - -GParamSpec *sms_g_param_spec_reduced_charset(guint flags) -{ - return - g_param_spec_boolean("reduced-charset", - "SMS reduced character set support", - "Whether SMS should be encoded with " - "a reduced character set", - FALSE, - flags | G_PARAM_STATIC_STRINGS); -} - -GParamSpec *sms_g_param_spec_sms_class(guint flags) -{ - return - g_param_spec_int("class", - "Short Message Class", - "Short Message Class (0-3), -1 indicates classless", - -1 /* min */, 3 /* max */, -1 /* default value */, - flags | G_PARAM_STATIC_STRINGS); -} - -GParamSpec *sms_g_param_spec_message_token(guint flags) -{ - return - g_param_spec_string("message-token", - "Message Token", - "Unique identifier for this object", - "", /* default value */ - flags | G_PARAM_STATIC_STRINGS); -} - -GParamSpec *sms_g_param_spec_time_sent(guint flags) -{ - return - g_param_spec_int64("time-sent", - "Time when this message was sent", - "Timestamp set by Short Message Service Centre", - G_MININT64, G_MAXINT64, 0, /* min, max, default value */ - flags | G_PARAM_STATIC_STRINGS); -} - -GParamSpec *sms_g_param_spec_time_original(guint flags) -{ - return - g_param_spec_int64("time-original", - "Timestamp when original sent", - "Timestamp when the original message was received by server", - G_MININT64, G_MAXINT64, 0, /* min, max, default value */ - flags | G_PARAM_STATIC_STRINGS); -} - -GParamSpec *sms_g_param_spec_time_received(guint flags) -{ - return - g_param_spec_int64("time-received", - "Timestamp when received", - "Timestamp when the message was originally received", - G_MININT64, G_MAXINT64, 0, /* min, max, default value */ - flags | G_PARAM_STATIC_STRINGS); -} - -GParamSpec *sms_g_param_spec_time_delivered(guint flags) -{ - return - g_param_spec_int64("time-delivered", - "Timestamp when delivered", - "Timestamp when the message was originally delivered", - G_MININT64, G_MAXINT64, 0, /* min, max, default value */ - flags | G_PARAM_STATIC_STRINGS); -} diff --git a/sms-glib/param-spec.h b/sms-glib/param-spec.h deleted file mode 100644 index 8b2adef..0000000 --- a/sms-glib/param-spec.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * sms-glib/param-spec.h - common parameters for SMS Glib objects - * - * Copyright (C) 2008-2010 Nokia Corporation - * @author Pekka Pessi <first.surname@nokia.com> - * - * This work is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This work 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this work; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef _SMS_G_PARAM_SPEC_H_ -#define _SMS_G_PARAM_SPEC_H_ - -#include <glib-object.h> - -G_BEGIN_DECLS - -GParamSpec *sms_g_param_spec_message_token(guint flags); -GParamSpec *sms_g_param_spec_smsc(guint flags); -GParamSpec *sms_g_param_spec_validity_period(guint flags); -GParamSpec *sms_g_param_spec_reduced_charset(guint flags); -GParamSpec *sms_g_param_spec_sms_class(guint flags); -GParamSpec *sms_g_param_spec_time_sent(guint flags); -GParamSpec *sms_g_param_spec_time_original(guint flags); -GParamSpec *sms_g_param_spec_time_received(guint flags); -GParamSpec *sms_g_param_spec_time_delivered(guint flags); - -G_END_DECLS - -#endif /* #ifndef _SMS_G_PARAM_SPEC_H_ */ diff --git a/sms-glib/status-report.c b/sms-glib/status-report.c deleted file mode 100644 index d5d649c..0000000 --- a/sms-glib/status-report.c +++ /dev/null @@ -1,521 +0,0 @@ -/* - * sms-glib/status-report.c - SMSGStatusReport class implementation - * - * Copyright (C) 2008-2010 Nokia Corporation - * @author Pekka Pessi <first.surname@nokia.com> - * - * This work is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This work 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this work; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "config.h" - -#define SMS_G_DEBUG_FLAG SMS_G_DEBUG_STATUS_REPORT - -#include "debug.h" - -#undef SMS_G_STATUS_REPORT - -#include "sms-glib/errors.h" -#include "sms-glib/enums.h" -#include "sms-glib/message.h" -#include "sms-glib/status-report.h" -#include "sms-glib/utils.h" -#include "sms-glib/param-spec.h" - -#include <limits.h> - -#include <stdlib.h> -#include <string.h> -#include <stdio.h> -#include <unistd.h> -#include <errno.h> - -static void sms_g_status_report_init_message_iface(gpointer, gpointer); - -G_DEFINE_TYPE_WITH_CODE( - SMSGStatusReport, sms_g_status_report, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE(SMS_G_TYPE_MESSAGE, - sms_g_status_report_init_message_iface); - ); - -/* Properties */ -enum -{ - PROP_NONE, - PROP_MESSAGE_TYPE, - PROP_MO, - PROP_CONTENT_TYPE, - PROP_SRQ, - PROP_REFERENCE, - PROP_RECIPIENT, - PROP_TIME_ORIGINAL, - PROP_TIME_SENT, - PROP_TIME_RECEIVED, - PROP_TIME_DELIVERED, - PROP_STATUS, - PROP_SMSC, - PROP_MESSAGE_TOKEN, - PROP_DELIVERY_TOKEN, - LAST_PROPERTY -}; - -/* private data */ -struct _SMSGStatusReportPrivate -{ - gchar *message_token; /* Message ID */ - gchar *delivery_token; /* Path of message that report concerns */ - gchar *smsc; - gchar *recipient; - - gint64 original, discharge, received, delivered; - - guint8 reference, status; - - unsigned srq:1, dispose_has_run:1, :0; -}; - -/* ---------------------------------------------------------------------- */ - -/* ---------------------------------------------------------------------- */ -/* GObject interface */ - -static void -sms_g_status_report_init(SMSGStatusReport *self) -{ - self->priv = G_TYPE_INSTANCE_GET_PRIVATE( - self, SMS_G_TYPE_STATUS_REPORT, SMSGStatusReportPrivate); -} - -static void -sms_g_status_report_get_property(GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - SMSGStatusReport *self = SMS_G_STATUS_REPORT(object); - SMSGStatusReportPrivate *priv = self->priv; - - switch(property_id) { - case PROP_MESSAGE_TYPE: - g_value_set_uint(value, SMS_G_TP_MTI_STATUS_REPORT); - break; - - case PROP_MO: - g_value_set_boolean(value, FALSE); - break; - - case PROP_CONTENT_TYPE: - g_value_set_static_string(value, "sms-status-report"); - break; - - case PROP_SRQ: - g_value_set_boolean(value, priv->srq); - break; - - case PROP_REFERENCE: - g_value_set_uchar(value, priv->reference); - break; - - case PROP_RECIPIENT: - g_value_set_string(value, priv->recipient); - break; - - case PROP_TIME_ORIGINAL: - g_value_set_int64(value, priv->original); - break; - - case PROP_TIME_SENT: - g_value_set_int64(value, priv->discharge); - break; - - case PROP_TIME_RECEIVED: - g_value_set_int64(value, priv->received); - break; - - case PROP_TIME_DELIVERED: - g_value_set_int64(value, priv->delivered); - break; - - case PROP_STATUS: - g_value_set_uchar(value, priv->status); - break; - - case PROP_SMSC: - g_value_set_string(value, priv->smsc ? priv->smsc : ""); - break; - - case PROP_MESSAGE_TOKEN: - g_value_set_string(value, priv->message_token); - break; - - case PROP_DELIVERY_TOKEN: - g_value_set_string(value, priv->delivery_token); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - break; - } -} - -static void -sms_g_status_report_set_property(GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - SMSGStatusReport *self = SMS_G_STATUS_REPORT(object); - SMSGStatusReportPrivate *priv = self->priv; - gpointer old; - - switch(property_id) { - case PROP_CONTENT_TYPE: - /* Writeable in interface but not meaningfully writeable here */ - break; - - case PROP_SMSC: - priv->smsc = g_value_dup_string(value); - break; - - case PROP_SRQ: - priv->srq = g_value_get_boolean(value); - break; - - case PROP_REFERENCE: - priv->reference = g_value_get_uchar(value); - break; - - case PROP_RECIPIENT: - priv->recipient = g_value_dup_string(value); - break; - - case PROP_TIME_ORIGINAL: - priv->original = g_value_get_int64(value); - break; - - case PROP_TIME_SENT: - priv->discharge = g_value_get_int64(value); - break; - - case PROP_TIME_RECEIVED: - priv->received = g_value_get_int64(value); - break; - - case PROP_TIME_DELIVERED: - priv->delivered = g_value_get_int64(value); - break; - - case PROP_STATUS: - priv->status = g_value_get_uchar(value); - break; - - case PROP_MESSAGE_TOKEN: - priv->message_token = g_value_dup_string(value); - break; - - case PROP_DELIVERY_TOKEN: - old = priv->delivery_token; - priv->delivery_token = g_value_dup_string(value); - if (old) g_free(old); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - break; - } -} - - -static void -sms_g_status_report_dispose(GObject *object) -{ - SMSGStatusReport *self = SMS_G_STATUS_REPORT(object); - SMSGStatusReportPrivate *priv = self->priv; - - DEBUG("SMSGStatusReport: enter: %s", priv->dispose_has_run ? "already" : "disposing"); - - if (priv->dispose_has_run) - return; - priv->dispose_has_run = TRUE; - - if (G_OBJECT_CLASS(sms_g_status_report_parent_class)->dispose) - G_OBJECT_CLASS(sms_g_status_report_parent_class)->dispose(object); -} - - -static void -sms_g_status_report_finalize(GObject *object) -{ - SMSGStatusReport *self = SMS_G_STATUS_REPORT(object); - SMSGStatusReportPrivate *priv = self->priv; - - DEBUG("SMSGStatusReport: enter"); - - g_free(priv->message_token), priv->message_token = NULL; - g_free(priv->delivery_token), priv->delivery_token = NULL; - g_free(priv->smsc), priv->smsc = NULL; - g_free(priv->recipient), priv->recipient = NULL; - - G_OBJECT_CLASS(sms_g_status_report_parent_class)->finalize(object); -} - - -static void -sms_g_status_report_class_init(SMSGStatusReportClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS(klass); - - DEBUG("enter"); - - g_type_class_add_private(klass, sizeof (SMSGStatusReportPrivate)); - - object_class->get_property = sms_g_status_report_get_property; - object_class->set_property = sms_g_status_report_set_property; - object_class->dispose = sms_g_status_report_dispose; - object_class->finalize = sms_g_status_report_finalize; - - /* Properties */ - g_object_class_override_property( - object_class, PROP_MESSAGE_TYPE, "message-type"); - g_object_class_override_property( - object_class, PROP_MO, "mobile-originated"); - g_object_class_override_property( - object_class, PROP_CONTENT_TYPE, "content-type"); - - g_object_class_install_property( - object_class, PROP_SRQ, - g_param_spec_boolean("srq", - "Status Report Qualifier", - "True if this STATUS-REPORT is sent in reponse to SMS-COMMAND", - FALSE, /* default value */ - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property( - object_class, PROP_REFERENCE, - g_param_spec_uchar("reference", - "Message Reference", - "Message rerefence identifying original message", - 0, 255, 0, /* min, max, default value */ - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property( - object_class, PROP_RECIPIENT, - g_param_spec_string("recipient", - "SMS Recipient Address", - "Address for SMS recipient", - NULL, /* default value */ - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property( - object_class, PROP_TIME_ORIGINAL, - sms_g_param_spec_time_original(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property( - object_class, PROP_TIME_SENT, - sms_g_param_spec_time_sent(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property( - object_class, PROP_TIME_RECEIVED, - sms_g_param_spec_time_received(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property( - object_class, PROP_TIME_DELIVERED, - sms_g_param_spec_time_delivered(G_PARAM_READWRITE)); - - g_object_class_install_property( - object_class, PROP_STATUS, - g_param_spec_uchar("status", - "Status of previously sent SMS", - "TP-FailureCauseStatus indicating status of " - "previously sent Short Message", - 0, 255, 0, /* min, max, default value */ - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property( - object_class, PROP_SMSC, - sms_g_param_spec_smsc(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property( - object_class, PROP_MESSAGE_TOKEN, - sms_g_param_spec_message_token(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property( - object_class, PROP_DELIVERY_TOKEN, - g_param_spec_string("delivery-token", - "Report Path", - "Unique identifier of message which status is reported", - "", /* default value */ - G_PARAM_READWRITE | G_PARAM_CONSTRUCT | - G_PARAM_STATIC_STRINGS)); - - DEBUG("return"); -} - -/* --------------------------------------------------------------------------------- */ -/* sms_g_message interface */ - -static void -sms_g_status_report_init_message_iface(gpointer ifacep, - gpointer data) -{ - (void)ifacep, (void)data; -} - -/* --------------------------------------------------------------------------------- */ -/* sms_g_status_report interface */ - -SMSGStatusReport * -sms_g_status_report_incoming(GPtrArray const *tpdus, - gchar const *smsc, - gchar const *message_token, - GError **return_error) -{ - SMSGStatusReport *object; - gint64 t_received; - - if (!sms_g_validate_sms_address(smsc, return_error)) { - DEBUG("invalid SMSC number (%s)", smsc); - return NULL; - } - - if (!sms_g_validate_message_id(message_token, return_error)) { - DEBUG("invalid message id (%s)", message_token); - return NULL; - } - - t_received = sms_g_received_timestamp(); - -#if nomore - DEBUG("SMS-STATUS-REPORT from %s\n" - "\tsrq = %u\n" - "\treference = %u\n" - "\trecipient = %s\n" - "\ttimestamp = %lld (zone=%d)\n" - "\tdischarge = %lld\n" - "\treceived = %lld\n" - "\tstatus = %u\n" - "\tmessage_id = %s\n", - smsc, - tpdu->status_report, - tpdu->msg_reference, - tpdu->addr_value.str, - t_scts, tpdu->smsc_time.offset, - t_discharge, - t_received, - tpdu->status, - message_token); -#endif - - object = (SMSGStatusReport *) - g_object_new(SMS_G_TYPE_STATUS_REPORT, - "service-centre", smsc, - /*"time-original", t_scts, - "time-sent", t_discharge,*/ - "time-received", t_received, - "message-token", message_token, - NULL); - - return object; -} - -char const *sms_g_status_report_get_smsc(SMSGStatusReport const *self) -{ - if (SMS_G_IS_STATUS_REPORT(self) && self->priv->smsc) - return self->priv->smsc; - else - return ""; -} - -gboolean sms_g_status_report_get_srq(SMSGStatusReport const *self) -{ - if (SMS_G_IS_STATUS_REPORT(self)) - return self->priv->srq; - else - return FALSE; -} - -guint8 sms_g_status_report_get_reference(SMSGStatusReport const *self) -{ - if (SMS_G_IS_STATUS_REPORT(self)) - return self->priv->reference; - else - return FALSE; -} - -char const *sms_g_status_report_get_recipient(SMSGStatusReport const *self) -{ - if (SMS_G_IS_STATUS_REPORT(self) && self->priv->recipient) - return self->priv->recipient; - else - return ""; -} - -guint8 sms_g_status_report_get_status(SMSGStatusReport const *self) -{ - if (SMS_G_IS_STATUS_REPORT(self)) - return self->priv->status; - else - return SMS_G_TP_FCS_UNSPECIFIED; -} - -/** Return "message-token" property. - * - * The "message-token" is the message-id created for incoming SMS-STATUS-REPORT by - * libsms. - */ -char const *sms_g_status_report_get_message_token(SMSGStatusReport const *self) -{ - if (SMS_G_IS_STATUS_REPORT(self)) - return self->priv->message_token; - else - return ""; -} - -/** Return "delivery-token" property. */ -char const *sms_g_status_report_get_delivery_token(SMSGStatusReport const *self) -{ - if (SMS_G_IS_STATUS_REPORT(self)) - return self->priv->delivery_token; - else - return ""; -} - -/** Return true if TP-Status indicates transaction completed. */ -gboolean sms_g_status_report_is_status_completed(SMSGStatusReport const *self) -{ - return SMS_G_IS_STATUS_REPORT(self) && (self->priv->status & 0xe0) == 0x00; -} - -/** Return true if TP-Status indicates that SMSC still tries to send message. */ -gboolean sms_g_status_report_is_status_still_trying(SMSGStatusReport const *self) -{ - return SMS_G_IS_STATUS_REPORT(self) && (self->priv->status & 0xe0) == 0x20; -} - -/** Return true if TP-Status is permanent. */ -gboolean sms_g_status_report_is_status_permanent(SMSGStatusReport const *self) -{ - return SMS_G_IS_STATUS_REPORT(self) && (self->priv->status & 0xe0) == 0x40; -} - -/** Return true if TP-Status indicates temporary error. */ -gboolean sms_g_status_report_is_status_temporary(SMSGStatusReport const *self) -{ - return SMS_G_IS_STATUS_REPORT(self) && (self->priv->status & 0xe0) == 0x60; -} diff --git a/sms-glib/status-report.h b/sms-glib/status-report.h deleted file mode 100644 index f8c78d3..0000000 --- a/sms-glib/status-report.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * sms-status-report.h - wrapper class for SMS-STATUS-REPORT - * - * Copyright (C) 2008-2010 Nokia Corporation - * @author Pekka Pessi <first.surname@nokia.com> - * - * This work is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This work 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this work; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __SMS_G_STATUS_REPORT_H__ -#define __SMS_G_STATUS_REPORT_H__ - -#include <glib-object.h> -#include <time.h> - -G_BEGIN_DECLS - -typedef struct _SMSGStatusReport SMSGStatusReport; -typedef struct _SMSGStatusReportClass SMSGStatusReportClass; -typedef struct _SMSGStatusReportPrivate SMSGStatusReportPrivate; - -struct _SMSGStatusReportClass { - GObjectClass parent_class; -}; - -struct _SMSGStatusReport { - GObject parent; - SMSGStatusReportPrivate *priv; -}; - -GType sms_g_status_report_get_type(void); - -/* TYPE MACROS */ -#define SMS_G_TYPE_STATUS_REPORT \ - (sms_g_status_report_get_type()) -#define SMS_G_STATUS_REPORT(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), SMS_G_TYPE_STATUS_REPORT, SMSGStatusReport)) -#define SMS_G_STATUS_REPORT_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), SMS_G_TYPE_STATUS_REPORT, SMSGStatusReportClass)) -#define SMS_G_IS_STATUS_REPORT(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), SMS_G_TYPE_STATUS_REPORT)) -#define SMS_G_IS_STATUS_REPORT_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), SMS_G_TYPE_STATUS_REPORT)) -#define SMS_G_STATUS_REPORT_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), SMS_G_TYPE_STATUS_REPORT, SMSGStatusReportClass)) - -/* SMSGStatusReport interface */ - -SMSGStatusReport *sms_g_status_report_incoming(GPtrArray const *tpdus, - gchar const *smsc, - gchar const *message_token, - GError **return_error); - -gchar const *sms_g_status_report_get_smsc(SMSGStatusReport const *self); - -gboolean sms_g_status_report_get_srq(SMSGStatusReport const *self); -guint8 sms_g_status_report_get_reference(SMSGStatusReport const *self); -gchar const *sms_g_status_report_get_recipient(SMSGStatusReport const *self); -time_t sms_g_status_report_get_timestamp(SMSGStatusReport const *self); -time_t sms_g_status_report_get_discharge(SMSGStatusReport const *self); -time_t sms_g_status_report_get_received(SMSGStatusReport const *self); -time_t sms_g_status_report_get_delivered(SMSGStatusReport const *self); -guint8 sms_g_status_report_get_status(SMSGStatusReport const *self); -char const *sms_g_status_report_get_message_token(SMSGStatusReport const *self); -char const *sms_g_status_report_get_delivery_token(SMSGStatusReport const *self); - -gboolean sms_g_status_report_is_status_completed(SMSGStatusReport const *self); -gboolean sms_g_status_report_is_status_still_trying(SMSGStatusReport const *self); -gboolean sms_g_status_report_is_status_permanent(SMSGStatusReport const *self); -gboolean sms_g_status_report_is_status_temporary(SMSGStatusReport const *self); - -G_END_DECLS - -#endif /* #ifndef __SMS_G_STATUS_REPORT_H__*/ diff --git a/sms-glib/submit.c b/sms-glib/submit.c deleted file mode 100644 index aa49ed6..0000000 --- a/sms-glib/submit.c +++ /dev/null @@ -1,450 +0,0 @@ -/* - * sms-glib/submit.c - SMSGSubmit class implementation - * - * Copyright (C) 2008-2010 Nokia Corporation - * @author Pekka Pessi <first.surname@nokia.com> - * - * This work is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This work 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this work; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "config.h" - -#define SMS_G_DEBUG_FLAG SMS_G_DEBUG_SUBMIT - -#include "debug.h" - -#include "sms-glib/errors.h" -#include "sms-glib/enums.h" -#include "sms-glib/message.h" -#include "sms-glib/submit.h" -#include "sms-glib/param-spec.h" - -#include <stdlib.h> -#include <string.h> -#include <stdio.h> - -G_DEFINE_TYPE_WITH_CODE( - SMSGSubmit, sms_g_submit, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE(SMS_G_TYPE_MESSAGE, NULL); - ); - -/* Properties */ -enum { - PROP_NONE, - PROP_MESSAGE_TYPE, - PROP_MO, - PROP_CONTENT_TYPE, - PROP_DESTINATION, - PROP_SMSC, - PROP_CLASS, - PROP_STATUS_REPORT_REQUEST, - PROP_VALIDITY_PERIOD, - PROP_REDUCED_CHARSET, - LAST_PROPERTY -}; - -/* private data */ -struct _SMSGSubmitPrivate -{ - GPtrArray aay[1]; - gpointer ptrarray[256]; - GByteArray ay[256]; - - gchar *content_type; - gchar *destination; - gchar *smsc; - guint validity_period; - unsigned sms_class:5; - - unsigned reduced_charset:1; - unsigned status_report_request:1; - unsigned constructed:1; -}; - -/* ---------------------------------------------------------------------- */ - -/* ---------------------------------------------------------------------- */ -/* GObject interface */ - -static void -sms_g_submit_init(SMSGSubmit *self) -{ - self->priv = G_TYPE_INSTANCE_GET_PRIVATE( - self, SMS_G_TYPE_SUBMIT, SMSGSubmitPrivate); -} - -static void -sms_g_submit_get_property(GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - SMSGSubmit *self = SMS_G_SUBMIT(object); - SMSGSubmitPrivate *priv = self->priv; - - switch(property_id) { - case PROP_MESSAGE_TYPE: - g_value_set_uint(value, SMS_G_TP_MTI_SUBMIT); - break; - - case PROP_MO: - g_value_set_boolean(value, TRUE); - break; - - case PROP_CONTENT_TYPE: - g_value_set_string(value, priv->content_type); - break; - - case PROP_DESTINATION: - g_value_set_string(value, sms_g_submit_get_destination(self)); - break; - - case PROP_STATUS_REPORT_REQUEST: - g_value_set_boolean(value, priv->status_report_request); - break; - - case PROP_SMSC: - g_value_set_string(value, sms_g_submit_get_smsc(self)); - break; - - case PROP_CLASS: - g_value_set_int(value, sms_g_submit_get_sms_class(self)); - break; - - case PROP_VALIDITY_PERIOD: - g_value_set_uint(value, priv->validity_period); - break; - - case PROP_REDUCED_CHARSET: - g_value_set_boolean(value, priv->reduced_charset); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - break; - } -} - -static void -sms_g_submit_set_property(GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - SMSGSubmit *self = SMS_G_SUBMIT(object); - SMSGSubmitPrivate *priv = self->priv; - - switch(property_id) { - case PROP_DESTINATION: - g_free(priv->destination); - priv->destination = g_value_dup_string(value); - return; - - case PROP_CONTENT_TYPE: - priv->content_type = g_value_dup_string(value); - break; - - case PROP_STATUS_REPORT_REQUEST: - priv->status_report_request = g_value_get_boolean(value); - return; - - case PROP_SMSC: - g_free(priv->smsc); - priv->smsc = g_value_dup_string(value); - break; - - case PROP_CLASS: - if (g_value_get_int(value) >= 0) - priv->sms_class = g_value_get_int(value); - else - priv->sms_class = 0; - return; - - case PROP_VALIDITY_PERIOD: - priv->validity_period = g_value_get_uint(value); - break; - - case PROP_REDUCED_CHARSET: - priv->reduced_charset = g_value_get_boolean(value); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); - } -} - -static void -sms_g_submit_constructed(GObject *object) -{ - if (G_OBJECT_CLASS(sms_g_submit_parent_class)->constructed) - G_OBJECT_CLASS(sms_g_submit_parent_class)->constructed(object); - - SMS_G_SUBMIT(object)->priv->constructed = 1; -} - -static void -sms_g_submit_finalize(GObject *object) -{ - SMSGSubmit *self = SMS_G_SUBMIT(object); - SMSGSubmitPrivate *priv = self->priv; - - DEBUG("enter"); - - g_free(priv->destination); - g_free(priv->content_type); - g_free(priv->smsc); - - G_OBJECT_CLASS(sms_g_submit_parent_class)->finalize(object); -} - - -static void -sms_g_submit_class_init(SMSGSubmitClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS(klass); - - DEBUG("enter"); - - g_type_class_add_private(klass, sizeof (SMSGSubmitPrivate)); - - object_class->get_property = sms_g_submit_get_property; - object_class->set_property = sms_g_submit_set_property; - object_class->constructed = sms_g_submit_constructed; - object_class->finalize = sms_g_submit_finalize; - - /* No Signals */ - - /* Properties */ - g_object_class_override_property( - object_class, PROP_MESSAGE_TYPE, "message-type"); - - g_object_class_override_property( - object_class, PROP_MO, "mobile-originated"); - - g_object_class_override_property( - object_class, PROP_CONTENT_TYPE, "content-type"); - - g_object_class_install_property( - object_class, PROP_DESTINATION, - g_param_spec_string("destination", - "SMS Destination Address", - "Address for SMS destination", - NULL, /* default value */ - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property( - object_class, PROP_STATUS_REPORT_REQUEST, - g_param_spec_boolean("status-report-request", - "Request status report", - "Request for SMS-STATUS-REPORT in SMS-SUBMIT.", - FALSE, /* default value */ - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property( - object_class, PROP_SMSC, - sms_g_param_spec_smsc(G_PARAM_READWRITE)); - - g_object_class_install_property( - object_class, PROP_CLASS, - sms_g_param_spec_sms_class(G_PARAM_READWRITE)); - - g_object_class_install_property( - object_class, PROP_VALIDITY_PERIOD, - sms_g_param_spec_validity_period(G_PARAM_READWRITE)); - - g_object_class_install_property( - object_class, PROP_REDUCED_CHARSET, - sms_g_param_spec_reduced_charset(G_PARAM_READWRITE)); - - DEBUG("return"); -} - -/* --------------------------------------------------------------------------------- */ -/* sms_g_submit interface */ - -gchar const *sms_g_submit_get_destination(SMSGSubmit const *self) -{ - if (SMS_G_IS_SUBMIT(self) && self->priv->destination) - return self->priv->destination; - else - return ""; -} - -void sms_g_submit_set_destination(SMSGSubmit *self, gchar const *destination) -{ - g_object_set((GObject *)self, "destination", destination, NULL); -} - -char const *sms_g_submit_get_smsc(SMSGSubmit const *self) -{ - if (SMS_G_IS_SUBMIT(self) && self->priv->smsc) - return self->priv->smsc; - else - return ""; -} - -void sms_g_submit_set_smsc(SMSGSubmit *self, gchar const *smsc) -{ - g_object_set((GObject *)self, "service-centre", smsc, NULL); -} - -gint sms_g_submit_get_sms_class(SMSGSubmit const *self) -{ - if (SMS_G_IS_SUBMIT(self) && self->priv->sms_class) - return self->priv->sms_class & 3; - else - return -1; -} - -void sms_g_submit_set_sms_class(SMSGSubmit *self, gint sms_class) -{ - g_object_set((GObject *)self, "class", sms_class, NULL); -} - -gboolean sms_g_submit_get_status_report_request(SMSGSubmit *self) -{ - if (SMS_G_IS_SUBMIT(self)) - return self->priv->status_report_request; - else - return FALSE; -} - -void sms_g_submit_set_status_report_request(SMSGSubmit *self, gboolean srr) -{ - g_object_set((GObject *)self, "status-report-request", srr, NULL); -} - -guint sms_g_submit_get_validity_period(SMSGSubmit const *self) -{ - if (SMS_G_IS_SUBMIT(self)) - return self->priv->validity_period; - else - return 0; -} - -void sms_g_submit_set_validity_period(SMSGSubmit *self, guint validity_period) -{ - return g_object_set((GObject *)self, "validity-period", validity_period, NULL); -} - -gboolean sms_g_submit_get_reduced_charset(SMSGSubmit const *self) -{ - if (SMS_G_IS_SUBMIT(self)) - return self->priv->reduced_charset; - else - return FALSE; -} - -void sms_g_submit_set_reduced_charset(SMSGSubmit *self, gboolean reduced_charset) -{ - return g_object_set((GObject *)self, "reduced-charset", reduced_charset, NULL); -} - -SMSGSubmit * -sms_g_submit_new(void) -{ - return sms_g_submit_new_type("*/*"); -} - -SMSGSubmit * -sms_g_submit_new_type(char const *content_type) -{ - return (SMSGSubmit *) g_object_new(SMS_G_TYPE_SUBMIT, - "content-type", content_type, - NULL); -} - -/* ---------------------------------------------------------------------- */ - -static -GPtrArray const * -sms_g_submit_any(SMSGSubmit *self, - gchar const *text, - GArray const *binary, - GError **gerror) -{ - SMSGSubmitPrivate *priv; - - if (text == NULL && binary == NULL) { - g_set_error(gerror, SMS_G_ERRORS, SMS_G_ERROR_INVALID_PARAM, - "No data to encode"); - return NULL; - } - - priv = self->priv; - - if (priv->destination == NULL) { - g_set_error(gerror, SMS_G_ERRORS, SMS_G_ERROR_INVALID_PARAM, - "No destination address"); - return NULL; - } - - return priv->aay; -} - -GPtrArray const * -sms_g_submit_text(SMSGSubmit *self, - gchar const *text, - GError **gerror) -{ - return sms_g_submit_any(self, text, NULL, gerror); -} - -GPtrArray const * -sms_g_submit_binary(SMSGSubmit *self, - GArray const *binary, - GError **gerror) -{ - return sms_g_submit_any(self, NULL, binary, gerror); -} - -GPtrArray const * -sms_g_submit_bytes(SMSGSubmit *self, - gconstpointer data, - guint size, - GError **gerror) - -{ - GArray array = { (gpointer)data, size }; - return sms_g_submit_any(self, NULL, &array, gerror); -} - -GPtrArray const * -sms_g_submit_get_data(SMSGSubmit const *self) -{ - if (SMS_G_IS_SUBMIT(self) && self->priv->aay->pdata) - return self->priv->aay; /* Encoded */ - else - return NULL; /* Not encoded */ -} - -gpointer const * -sms_g_submit_get_pdata(SMSGSubmit const *self) -{ - if (SMS_G_IS_SUBMIT(self) && self->priv->aay->pdata) - return self->priv->aay->pdata; /* Encoded */ - else - return NULL; /* Not encoded */ -} - -guint sms_g_submit_get_len(SMSGSubmit const *self) -{ - if (SMS_G_IS_SUBMIT(self) && self->priv->aay->pdata) - return self->priv->aay->len; - else - return 0; -} diff --git a/sms-glib/submit.h b/sms-glib/submit.h deleted file mode 100644 index 073afb7..0000000 --- a/sms-glib/submit.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * sms-glib/submit.h - SMS Submit - * - * Copyright (C) 2008-2010 Nokia Corporation - * @author Pekka Pessi <first.surname@nokia.com> - * - * This work is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This work 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this work; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __SMS_G_SUBMIT_H__ -#define __SMS_G_SUBMIT_H__ - -#include <glib-object.h> - -G_BEGIN_DECLS - -typedef struct _SMSGSubmit SMSGSubmit; -typedef struct _SMSGSubmitClass SMSGSubmitClass; -typedef struct _SMSGSubmitPrivate SMSGSubmitPrivate; - -struct _SMSGSubmitClass { - GObjectClass parent_class; -}; - -struct _SMSGSubmit { - GObject parent; - SMSGSubmitPrivate *priv; -}; - -GType sms_g_submit_get_type(void); - -/* TYPE MACROS */ -#define SMS_G_TYPE_SUBMIT \ - (sms_g_submit_get_type()) -#define SMS_G_SUBMIT(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), SMS_G_TYPE_SUBMIT, SMSGSubmit)) -#define SMS_G_SUBMIT_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), SMS_G_TYPE_SUBMIT, SMSGSubmitClass)) -#define SMS_G_IS_SUBMIT(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), SMS_G_TYPE_SUBMIT)) -#define SMS_G_IS_SUBMIT_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), SMS_G_TYPE_SUBMIT)) -#define SMS_G_SUBMIT_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), SMS_G_TYPE_SUBMIT, SMSGSubmitClass)) - -/* SMSGSubmit interface */ - -void sms_g_submit_set_status_report_request(SMSGSubmit *self, gboolean); -void sms_g_submit_set_destination(SMSGSubmit *self, gchar const *); -void sms_g_submit_set_smsc(SMSGSubmit *self, gchar const *); -void sms_g_submit_set_sms_class(SMSGSubmit *self, gint); -void sms_g_submit_set_validity_period(SMSGSubmit *self, guint); -void sms_g_submit_set_reduced_charset(SMSGSubmit *self, gboolean); - -gboolean sms_g_submit_get_status_report_request(SMSGSubmit *self); -gchar const *sms_g_submit_get_destination(SMSGSubmit const *self); -gchar const *sms_g_submit_get_smsc(SMSGSubmit const *self); -gint sms_g_submit_get_sms_class(SMSGSubmit const *self); -guint sms_g_submit_get_validity_period(SMSGSubmit const *self); -gboolean sms_g_submit_get_reduced_charset(SMSGSubmit const *self); - -SMSGSubmit *sms_g_submit_new(void); - -SMSGSubmit *sms_g_submit_new_type(char const *content_type); - -GPtrArray const *sms_g_submit_text(SMSGSubmit *self, - gchar const *text, - GError **gerror); - -GPtrArray const *sms_g_submit_binary(SMSGSubmit *self, - GArray const *binary, - GError **gerror); - -GPtrArray const *sms_g_submit_bytes(SMSGSubmit *self, - gconstpointer data, - guint size, - GError **gerror); - -GPtrArray const *sms_g_submit_get_data(SMSGSubmit const *self); - -gpointer const *sms_g_submit_get_pdata(SMSGSubmit const *self); -guint sms_g_submit_get_len(SMSGSubmit const *self); - -G_END_DECLS - -#endif /* #ifndef __SMS_G_SUBMIT_H__*/ diff --git a/sms-glib/utils.c b/sms-glib/utils.c deleted file mode 100644 index 111cebf..0000000 --- a/sms-glib/utils.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - * sms-glib/utils.c - SMS-related utilites - * - * Copyright (C) 2008-2010 Nokia Corporation - * @author Pekka Pessi <first.surname@nokia.com> - * - * This work is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This work 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this work; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "config.h" - -#include "sms-glib/errors.h" -#include "sms-glib/enums.h" -#include "sms-glib/utils.h" - -#include <stdlib.h> -#include <string.h> -#include <stdio.h> - -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> - -static gchar const * -_sms_g_is_valid_sms_address(gchar const *address) -{ - size_t len; - - if (address == NULL) - return "NULL"; - - if (address[0] == '+') { - address++; - } - - len = strspn(address, "0123456789"); - - if (address[len]) - return "invalid character"; - - if (len == 0) - return "too short"; - - if (len > 20) - return "too long"; - - return NULL; -} - -/** Return TRUE if @a address is a valid SMS address. - * - * A valid SMS address is a phone number with at most 20 digits either in - * national or in international format (starting with +). - * - * @param address - ISDN address of address - * - * @retval TRUE - address is a valid Short Message Service Centre address - * @retval FALSE - address is NULL, does not contain valid phone number, or it - * is too long. - */ -gboolean -sms_g_is_valid_sms_address(gchar const *address) -{ - return !_sms_g_is_valid_sms_address(address); -} - -/** Validate a SMS address @a address. - * - * A valid SMS address is a phone number with at most 20 digits either in - * national or in international format (starting with +). - * - * @param address - ISDN address of address - * @param error - return value for GError describing the ADDRESS validation error - * - * @retval TRUE - address is a valid Short Message Service Centre address - * @retval FALSE - address is NULL, does not contain valid phone number, or it - * is too long. - */ -gboolean -sms_g_validate_sms_address(gchar const *address, GError **error) -{ - gchar const *reason = _sms_g_is_valid_sms_address(address); - - if (reason) - g_set_error(error, SMS_G_ERRORS, SMS_G_ERROR_INVALID_PARAM, - "Invalid SMS address \"%s\": %s", address, reason); - - return !reason; -} - -static gchar const * -_sms_g_is_valid_message_id(gchar const *message_id) -{ - if (message_id == NULL) return "NULL"; - if (strlen(message_id) == 0) return "empty"; - return NULL; -} - -gboolean -sms_g_is_valid_message_id(gchar const *message_id) -{ - return !_sms_g_is_valid_message_id(message_id); -} - -gboolean -sms_g_validate_message_id(gchar const *message_id, GError **error) -{ - gchar const *reason = _sms_g_is_valid_message_id(message_id); - - if (reason) - g_set_error(error, SMS_G_ERRORS, SMS_G_ERROR_INVALID_PARAM, - "Invalid message_id %s: %s", message_id, reason); - - return !reason; -} - -gint64 -sms_g_received_timestamp(void) -{ - return (gint64)time(NULL); -} diff --git a/sms-glib/utils.h b/sms-glib/utils.h deleted file mode 100644 index 99c0346..0000000 --- a/sms-glib/utils.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * sms-utils.h - utilities for SMS glibrary - * - * Copyright (C) 2008-2010 Nokia Corporation - * @author Pekka Pessi <first.surname@nokia.com> - * - * This work is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This work 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this work; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __SMS_UTILS_H__ -#define __SMS_UTILS_H__ - -#include <glib-object.h> - -G_BEGIN_DECLS - -void sms_g_debug_set_flags_from_env(void); - -gboolean sms_g_is_valid_sms_address(gchar const *smsc); -gboolean sms_g_validate_sms_address(gchar const *smsc, GError **error); - -gboolean sms_g_is_valid_message_id(gchar const *message_id); -gboolean sms_g_validate_message_id(gchar const *message_id, GError **error); - -gint64 sms_g_received_timestamp(void); - -G_END_DECLS - -#endif /* #ifndef __SMS_UTILS_H__*/ diff --git a/src/Makefile.am b/src/Makefile.am index 9c4b157..acbb922 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -33,7 +33,6 @@ test_ring_SOURCES = tests/test-ring.h tests/test-ring.c tests/test-ring-util.c test_ring_LDADD = \ libtpring.la $(TP_EXTLIB) \ ../modem/libmodem-glib.la \ - ../sms-glib/libsms-glib.la \ ../tests/libtestcommon.la \ @TP_LIBS@ @DBUS_LIBS@ @GLIB_LIBS@ \ @CHECK_LIBS@ -lpthread @@ -65,7 +64,6 @@ TP_EXTLIB += $(top_builddir)/ring-extensions/libtpextensions.a telepathy_ring_LDADD = \ libtpring.la $(TP_EXTLIB) \ ../modem/libmodem-glib.la \ - ../sms-glib/libsms-glib.la \ @TP_LIBS@ @DBUS_LIBS@ @GLIB_LIBS@ \ -lpthread |