* initial code dump into SVN; needs some work
[modest] / src / modest-proto.c
1 #include <string.h>
2 #include "modest-proto.h"
3
4
5 gboolean
6 modest_proto_is_valid (const gchar *proto)
7 {
8         int i;
9         static const gchar* protos[] = {
10                 MODEST_PROTO_SENDMAIL,
11                 MODEST_PROTO_SMTP,
12                 MODEST_PROTO_POP,
13                 MODEST_PROTO_IMAP,
14                 NULL
15         };
16         
17         if (!proto)
18                 return FALSE;
19
20         for (i = 0; protos[i]; ++i) {
21                 if (strcmp(protos[i], proto) == 0)
22                         return TRUE;
23         }
24         
25         return FALSE;
26 }
27
28
29         
30 ModestProtoType
31 modest_proto_type (const gchar *proto)
32 {
33         if (!modest_proto_is_valid(proto)) {
34                 g_warning ("invalid protocol %s", proto);
35                 return -1;
36         }
37         
38         /* trick */
39         if (proto[0] == 's')
40                 return MODEST_PROTO_TYPE_TRANSPORT;
41         else
42                 return MODEST_PROTO_TYPE_STORE;
43 }
44
45
46