2007-08-29 Armin Burgmeier <armin@openismus.com>
authorArmin Burgmeier <armin@openismus.com>
Wed, 29 Aug 2007 21:35:54 +0000 (21:35 +0000)
committerArmin Burgmeier <armin@openismus.com>
Wed, 29 Aug 2007 21:35:54 +0000 (21:35 +0000)
* src/modest-protocol-info.h:
* src/modest-protocol-info.c: Added
modest_protocol_info_get_auth_protocol() to translate an
authentication protocol name to the corresponding enum value.

* src/maemo/modest-maemo-utils.c: Fixed supported auth protocol list
generation using the newly added function.

* src/maemo/modest-account-settings-dialog.c: Use the current element
when traversing through the list of supported authentication methods,
not always the first.

pmo-trunk-r3144

ChangeLog2
src/maemo/modest-account-settings-dialog.c
src/maemo/modest-maemo-utils.c
src/modest-protocol-info.c
src/modest-protocol-info.h

index 28a0782..b1272c9 100644 (file)
@@ -1,3 +1,17 @@
+2007-08-29  Armin Burgmeier  <armin@openismus.com>
+
+       * src/modest-protocol-info.h:
+       * src/modest-protocol-info.c: Added
+       modest_protocol_info_get_auth_protocol() to translate an
+       authentication protocol name to the corresponding enum value.
+
+       * src/maemo/modest-maemo-utils.c: Fixed supported auth protocol list
+       generation using the newly added function.
+
+       * src/maemo/modest-account-settings-dialog.c: Use the current element
+       when traversing through the list of supported authentication methods,
+       not always the first.
+
 2007-08-29   Murray Cumming  <murrayc@murrayc.com>
 
        * src/maemo/easysetup/modest-easysetup-wizard.c:
index 9b1beb2..f2e01a3 100644 (file)
@@ -1048,7 +1048,7 @@ check_data (ModestAccountSettingsDialog *self)
                                GList* method;
                                for (method = list_auth_methods; method != NULL; method = g_list_next(method))
                                {
-                                       ModestAuthProtocol proto = (ModestAuthProtocol)(GPOINTER_TO_INT(list_auth_methods->data));
+                                       ModestAuthProtocol proto = (ModestAuthProtocol)(GPOINTER_TO_INT(method->data));
                                        // Allow secure methods, e.g MD5 only
                                        if (modest_protocol_info_auth_is_secure(proto))
                                        {
index c21f44b..6b83f2b 100644 (file)
@@ -342,12 +342,11 @@ on_camel_account_get_supported_secure_authentication (
                                }
 
                                printf("DEBUG: %s: auth_name=%s\n", __FUNCTION__, auth_name);
-                               ModestPair *matching = modest_pair_list_find_by_first_as_string (pairs, 
-                                       auth_name);
-                               if (matching)
-                               {
-                                       result = g_list_append (result, GINT_TO_POINTER((ModestConnectionProtocol)matching->first));
-                               }
+
+                               ModestAuthProtocol proto = modest_protocol_info_get_auth_protocol (auth_name);
+                               if(proto != MODEST_PROTOCOL_AUTH_NONE)
+                                               result = g_list_prepend(result, GINT_TO_POINTER(proto));
+
                                tny_iterator_next(iter);
                        }
                        g_object_unref (iter);
index b0ce303..5a579aa 100644 (file)
@@ -66,7 +66,6 @@ static const ProtocolInfo AuthProtocolMap[] = {
        { MODEST_PROTOCOL_AUTH_CRAMMD5,       MODEST_ACCOUNT_AUTH_MECH_VALUE_CRAMMD5, N_("Cram MD5") }
 };
 
-
 static ModestPairList*
 get_protocol_pair_list (const ProtocolInfo* map, guint size)
 {
@@ -85,6 +84,28 @@ get_protocol_pair_list (const ProtocolInfo* map, guint size)
        return proto_list;
 }
 
+static gint
+get_protocol_by_name (const ProtocolInfo* map,
+                      guint size,
+                      const gchar* query_name,
+                      gint default_value,
+                      gboolean case_sensitive)
+{
+       guint i;
+
+       g_return_val_if_fail (map, default_value);
+
+       for(i = 0; i < size; ++i)
+       {
+               if((case_sensitive && strcmp(map[i].name, query_name) == 0) ||
+                  (!case_sensitive && g_ascii_strcasecmp(map[i].name, query_name) == 0))
+               {
+                       return map[i].proto;
+               }
+       }
+
+       return default_value;
+}
 
 ModestPairList*
 modest_protocol_info_get_transport_store_protocol_pair_list ()
@@ -107,27 +128,25 @@ modest_protocol_info_get_connection_protocol_pair_list ()
                G_N_ELEMENTS(ConnectionProtocolMap));
 }
        
-
 ModestTransportStoreProtocol
 modest_protocol_info_get_transport_store_protocol (const gchar* name)
 {
-       const ProtocolInfo *map = TransportStoreProtocolMap;
-       const guint size = G_N_ELEMENTS(TransportStoreProtocolMap);
-       int i;
-       
-       g_return_val_if_fail (name, MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN);
-       
-       g_return_val_if_fail (map, MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN);
-
-       for (i = 0; i != size; ++i) {
-               const ProtocolInfo info = map[i];
-               if (strcmp(name, info.name) == 0)
-                       return info.proto;
-       }
-       
-       return MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN;
+       return get_protocol_by_name(TransportStoreProtocolMap,
+                                   G_N_ELEMENTS(TransportStoreProtocolMap),
+                                   name,
+                                   MODEST_PROTOCOL_TRANSPORT_STORE_UNKNOWN,
+                                   TRUE);
 }
 
+ModestAuthProtocol
+modest_protocol_info_get_auth_protocol (const gchar* name)
+{
+       return get_protocol_by_name(AuthProtocolMap,
+                                   G_N_ELEMENTS(AuthProtocolMap),
+                                   name,
+                                   MODEST_PROTOCOL_AUTH_NONE,
+                                   FALSE);
+}
 
 
 /* get either the name or the display_name for the protocol */
index c358d1d..77f16d9 100644 (file)
@@ -108,8 +108,7 @@ modest_protocol_info_get_connection_protocol_pair_list ();
        
 /**
  * modest_protocol_info_get_transport_store_protocol:
- * @name: the name of the  ModestTransportStoreProtocol
- * @proto_type: the type of protocol you want to have
+ * @name: the name of the  #ModestTransportStoreProtocol
  *
  * return the id of the protocol with the given name
  *  
@@ -119,6 +118,17 @@ ModestTransportStoreProtocol
 modest_protocol_info_get_transport_store_protocol (const gchar* name);
 
 /**
+ * modest_protocol_info_get_auth_protocol:
+ * @name: The name of the #ModestAuthProtocol
+ *
+ * Returns the ID of the protocol with the given name
+ *
+ * Returns: The ID of the protocol or MODEST_PROTOCOL_AUTH_NONE
+ */
+ModestAuthProtocol
+modest_protocol_info_get_auth_protocol (const gchar* name);
+
+/**
  * modest_protocol_info_get_transport_store_protocol_name:
  * @proto: the protocol you are looking for
  *