Modified webpage: now tinymail repository is in gitorious.
[modest] / src / modest-pair.c
index 25f14ca..208ce9a 100644 (file)
@@ -28,6 +28,8 @@
  */
 
 #include "modest-pair.h"
  */
 
 #include "modest-pair.h"
+#include <string.h> /* For strcmp() */
+#include <stdio.h>
 
 ModestPair*
 modest_pair_new     (gpointer first, gpointer second, gboolean own)
 
 ModestPair*
 modest_pair_new     (gpointer first, gpointer second, gboolean own)
@@ -70,3 +72,22 @@ modest_pair_list_free (ModestPairList *pairs)
        }
        g_slist_free (pairs);
 }
        }
        g_slist_free (pairs);
 }
+
+static gint on_pair_compare_as_string(gconstpointer a, gconstpointer b)
+{
+       const ModestPair* pair_a = (const ModestPair*)a;
+  const gchar* target = (const gchar*)b;
+  
+       return strcmp ((const gchar*)pair_a->first, target);
+}
+
+ModestPair* modest_pair_list_find_by_first_as_string  (ModestPairList *pairs, 
+       const gchar* first)
+{
+       GSList *matching = g_slist_find_custom (pairs, (gconstpointer)first, 
+               on_pair_compare_as_string);
+       if (matching)
+               return (ModestPair*)matching->data;
+       else
+               return NULL;
+}