[evolution-kolab] libekolab: added port number getter util function



commit 8f37e2ffbf22dc83a4d218b5f764cd33ab5ce604
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Wed Jun 6 14:22:23 2012 +0200

    libekolab: added port number getter util function
    
    * added function to get the port number from an
      ESource with minimal sanity checking

 src/libekolab/kolab-util-backend.c |   23 +++++++++++++++++++++++
 src/libekolab/kolab-util-backend.h |    1 +
 2 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/src/libekolab/kolab-util-backend.c b/src/libekolab/kolab-util-backend.c
index 0db2bca..a757cf2 100644
--- a/src/libekolab/kolab-util-backend.c
+++ b/src/libekolab/kolab-util-backend.c
@@ -217,6 +217,29 @@ kolab_util_misc_tls_variant_from_property (const gchar *tls_variant)
 	return tvid;
 } /* kolab_util_misc_tls_variant_from_property () */
 
+gint
+kolab_util_misc_port_number_from_property (const gchar *port_number_prop)
+{
+	gint port = 0;
+
+	if (port_number_prop == NULL)
+		return -1;
+
+	port = kolab_util_misc_generic_integer_from_property (port_number_prop, -1);
+	if (port > 99999) {
+		g_warning ("%s()[%u] configured port number exceeds 5 digits, clamping to 99999!",
+		           __func__, __LINE__);
+		port = 99999;
+	}
+	if (port < 0) {
+		g_warning ("%s()[%u] configured port number is negative, clamping to 0!",
+		           __func__, __LINE__);
+		port = 0;
+	}
+
+	return port;
+}
+
 KolabReqPkcs11
 kolab_util_misc_req_pkcs11_from_property (const gchar *req_pkcs11_prop)
 {
diff --git a/src/libekolab/kolab-util-backend.h b/src/libekolab/kolab-util-backend.h
index 4b4ae7f..cd55fb5 100644
--- a/src/libekolab/kolab-util-backend.h
+++ b/src/libekolab/kolab-util-backend.h
@@ -82,6 +82,7 @@ gchar *kolab_util_backend_get_relative_path_from_uri (const gchar *uri);
 gchar *kolab_util_backend_get_protocol_from_uri (const gchar *uri);
 KolabSyncStrategyID kolab_util_misc_sync_value_from_property (const gchar *sync_prop);
 KolabTLSVariantID kolab_util_misc_tls_variant_from_property (const gchar *tls_variant);
+gint kolab_util_misc_port_number_from_property (const gchar *port_number_prop);
 KolabReqPkcs11 kolab_util_misc_req_pkcs11_from_property (const gchar *req_pkcs11_prop);
 void kolab_util_backend_koma_table_cleanup_cb (gpointer data, GObject *object, gboolean is_last_ref);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]