diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-02-05 14:55:13 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-02-06 13:05:31 +0000 |
commit | 77e52ce80eb8705a039b7070515b89efb48863a5 (patch) | |
tree | e92458d20c6885bb216d1c44b0c7d0fbaf1456ee | |
parent | 0cfbd8ff018ce0387a6c517428cc1bd762d450b1 (diff) |
mcd_keyfile_get_variant: add support for int16, uint16
If we're opportunistically migrating parameters according to
CM-specified types, we need to cope with uint16 ('q') for port numbers.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=71093
Reviewed-by: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
-rw-r--r-- | src/mcd-storage.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/mcd-storage.c b/src/mcd-storage.c index 481c3dcd..90f62475 100644 --- a/src/mcd-storage.c +++ b/src/mcd-storage.c @@ -914,6 +914,29 @@ mcd_keyfile_get_variant (GKeyFile *keyfile, } break; + case G_VARIANT_CLASS_INT16: + { + GError *e = NULL; + gint v_int = g_key_file_get_integer (keyfile, group, + key, &e); + + if (e != NULL) + { + g_propagate_error (error, e); + } + else if (v_int < G_MININT16 || v_int > G_MAXINT16) + { + g_set_error (error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT, + "integer %d out of range [%d,%d]", + v_int, G_MININT16, G_MAXINT16); + } + else + { + ret = g_variant_new_int16 (v_int); + } + } + break; + case G_VARIANT_CLASS_INT32: { GError *e = NULL; @@ -948,6 +971,28 @@ mcd_keyfile_get_variant (GKeyFile *keyfile, } break; + case G_VARIANT_CLASS_UINT16: + { + GError *e = NULL; + gint v_int = g_key_file_get_integer (keyfile, group, + key, &e); + + if (e != NULL) + { + g_propagate_error (error, e); + } + else if (v_int < 0 || (unsigned) v_int > G_MAXUINT16) + { + g_set_error (error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT, + "integer %d out of range [0,%d]", v_int, G_MAXUINT16); + } + else + { + ret = g_variant_new_uint16 (v_int); + } + } + break; + case G_VARIANT_CLASS_UINT32: { GError *e = NULL; |