From: <svn...@op...> - 2009-06-19 11:00:07
|
Author: bellmich Date: Fri Jun 19 12:59:56 2009 New Revision: 1097 URL: http://libsyncml.opensync.org/changeset/1097 Log: content type must have a type and version in SyncML Modified: trunk/libsyncml/dev_inf_api/sml_dev_inf_content_type.c Modified: trunk/libsyncml/dev_inf_api/sml_dev_inf_content_type.c ============================================================================== --- trunk/libsyncml/dev_inf_api/sml_dev_inf_content_type.c Fri Jun 19 12:05:52 2009 (r1096) +++ trunk/libsyncml/dev_inf_api/sml_dev_inf_content_type.c Fri Jun 19 12:59:56 2009 (r1097) @@ -19,6 +19,7 @@ */ #include "sml_dev_inf_content_type.h" +#include <libsyncml/syncml.h> G_DEFINE_TYPE (SmlDevInfContentType, sml_dev_inf_content_type, G_TYPE_OBJECT) @@ -98,7 +99,7 @@ g_param_spec_string ("CTType", "", "", - NULL, + "text/plain", G_PARAM_READABLE)); /** * SmlDevInfContentType:VerCT: @@ -110,7 +111,7 @@ g_param_spec_string ("VerCT", "", "", - NULL, + "1.0", G_PARAM_READABLE)); } @@ -136,9 +137,14 @@ GError **error) { g_type_init(); + SmlDevInfContentType* self = g_object_new (SML_TYPE_DEV_INF_CONTENT_TYPE, NULL); - self->priv->cttype = g_strdup(cttype); - self->priv->verct = g_strdup(verct); + if (cttype != NULL) { + self->priv->cttype = g_strdup(cttype); + } + if (verct != NULL) { + self->priv->verct = g_strdup(verct); + } return self; } @@ -186,6 +192,10 @@ sml_dev_inf_content_type_set_cttype (SmlDevInfContentType *self, const gchar* cttype, GError **error) { g_return_val_if_fail (SML_IS_DEV_INF_CONTENT_TYPE (self), FALSE); + if (cttype == NULL) { + *error = g_error_new(SML_ERROR, SML_ERROR_GENERIC, "The CTType must always be set for a SmlDevInfContentType object."); + return FALSE; + } if (self->priv->cttype) { g_free(self->priv->cttype); self->priv->cttype = NULL; @@ -208,6 +218,10 @@ sml_dev_inf_content_type_set_verct (SmlDevInfContentType *self, const gchar* verct, GError **error) { g_return_val_if_fail (SML_IS_DEV_INF_CONTENT_TYPE (self), FALSE); + if (verct == NULL) { + *error = g_error_new(SML_ERROR, SML_ERROR_GENERIC, "The VerCT must always be set for a SmlDevInfContentType object."); + return FALSE; + } if (self->priv->verct) { g_free(self->priv->verct); self->priv->verct = NULL; |