X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fmodest-proto.c;fp=src%2Fmodest-proto.c;h=d0d7702cfd765c48b334d9ba8edf9c324681f876;hb=434ec10090daec7d9d80c1f419b9113d15d58fd4;hp=0000000000000000000000000000000000000000;hpb=0b0d512054c942e25923292d82cf33ad880053e8;p=modest diff --git a/src/modest-proto.c b/src/modest-proto.c new file mode 100644 index 0000000..d0d7702 --- /dev/null +++ b/src/modest-proto.c @@ -0,0 +1,46 @@ +#include +#include "modest-proto.h" + + +gboolean +modest_proto_is_valid (const gchar *proto) +{ + int i; + static const gchar* protos[] = { + MODEST_PROTO_SENDMAIL, + MODEST_PROTO_SMTP, + MODEST_PROTO_POP, + MODEST_PROTO_IMAP, + NULL + }; + + if (!proto) + return FALSE; + + for (i = 0; protos[i]; ++i) { + if (strcmp(protos[i], proto) == 0) + return TRUE; + } + + return FALSE; +} + + + +ModestProtoType +modest_proto_type (const gchar *proto) +{ + if (!modest_proto_is_valid(proto)) { + g_warning ("invalid protocol %s", proto); + return -1; + } + + /* trick */ + if (proto[0] == 's') + return MODEST_PROTO_TYPE_TRANSPORT; + else + return MODEST_PROTO_TYPE_STORE; +} + + +