aboutsummaryrefslogtreecommitdiffstats
path: root/capplet/settings/mail-guess-servers.c
diff options
context:
space:
mode:
Diffstat (limited to 'capplet/settings/mail-guess-servers.c')
-rw-r--r--capplet/settings/mail-guess-servers.c77
1 files changed, 38 insertions, 39 deletions
diff --git a/capplet/settings/mail-guess-servers.c b/capplet/settings/mail-guess-servers.c
index 468c1c0099..a9e477abd7 100644
--- a/capplet/settings/mail-guess-servers.c
+++ b/capplet/settings/mail-guess-servers.c
@@ -11,7 +11,7 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
*
*
* Authors:
@@ -46,22 +46,23 @@
#include "mail-guess-servers.h"
-static char *
+static gchar *
xml_to_gchar (xmlChar *xml, EmailProvider *provider)
{
- char *gxml = NULL;
- char *tmp;
- char *repl = NULL, *sec_part;
+ gchar *gxml = NULL;
+ gchar *tmp;
+ gchar *repl = NULL;
+ const gchar *sec_part;
- tmp = xml ? strstr((char *) xml, "\%EMAIL") : NULL;
+ tmp = xml ? strstr((gchar *) xml, "\%EMAIL") : NULL;
if (!tmp) {
- gxml = xml ? g_strdup((char *) xml) : NULL ;
+ gxml = xml ? g_strdup((gchar *) xml) : NULL;
} else {
decodepart:
*tmp = 0;
tmp+=6;
- if(*tmp == 'A')
+ if (*tmp == 'A')
repl = provider->email;
else if (*tmp == 'L')
repl = provider->username;
@@ -71,25 +72,25 @@ xml_to_gchar (xmlChar *xml, EmailProvider *provider)
sec_part++;
if (!*sec_part)
sec_part = "";
-
- gxml = g_strdup_printf("%s%s%s", gxml ? gxml : (char *)xml, repl, sec_part);
+
+ gxml = g_strdup_printf("%s%s%s", gxml ? gxml : (gchar *)xml, repl, sec_part);
tmp = strstr (gxml, "\%EMAIL");
- if(tmp) {
+ if (tmp) {
goto decodepart;
}
}
xmlFree(xml);
-
+
return gxml;
}
static SoupMessage *
-get_url (SoupSession *session, const char *url)
+get_url (SoupSession *session, const gchar *url)
{
- const char *name;
+ const gchar *name;
SoupMessage *msg;
- const char *header;
+ const gchar *header;
msg = soup_message_new (SOUP_METHOD_GET, url);
soup_message_set_flags (msg, SOUP_MESSAGE_NO_REDIRECT);
@@ -98,7 +99,6 @@ get_url (SoupSession *session, const char *url)
name = soup_message_get_uri (msg)->path;
-
if (SOUP_STATUS_IS_REDIRECTION (msg->status_code)) {
header = soup_message_headers_get_one (msg->response_headers,
"Location");
@@ -112,8 +112,7 @@ get_url (SoupSession *session, const char *url)
return NULL;
}
-
-static void
+static void
handle_incoming (xmlNodePtr head, EmailProvider *provider)
{
xmlNodePtr node = head->children;
@@ -128,16 +127,16 @@ handle_incoming (xmlNodePtr head, EmailProvider *provider)
} else if (strcmp ((gchar *)node->name, "socketType") == 0) {
provider->recv_socket_type = xml_to_gchar(xmlNodeGetContent(node), provider);
} else if (strcmp ((gchar *)node->name, "username") == 0) {
- provider->recv_username = xml_to_gchar(xmlNodeGetContent(node), provider);
+ provider->recv_username = xml_to_gchar(xmlNodeGetContent(node), provider);
} else if (strcmp ((gchar *)node->name, "authentication") == 0) {
- provider->recv_auth = xml_to_gchar(xmlNodeGetContent(node), provider);
+ provider->recv_auth = xml_to_gchar(xmlNodeGetContent(node), provider);
}
node = node->next;
}
}
-static void
+static void
handle_outgoing (xmlNodePtr head, EmailProvider *provider)
{
xmlNodePtr node = head->children;
@@ -152,9 +151,9 @@ handle_outgoing (xmlNodePtr head, EmailProvider *provider)
} else if (strcmp ((gchar *)node->name, "socketType") == 0) {
provider->send_socket_type = xml_to_gchar(xmlNodeGetContent(node), provider);
} else if (strcmp ((gchar *)node->name, "username") == 0) {
- provider->send_username = xml_to_gchar(xmlNodeGetContent(node), provider);
+ provider->send_username = xml_to_gchar(xmlNodeGetContent(node), provider);
} else if (strcmp ((gchar *)node->name, "authentication") == 0) {
- provider->send_auth = xml_to_gchar(xmlNodeGetContent(node), provider);
+ provider->send_auth = xml_to_gchar(xmlNodeGetContent(node), provider);
}
node = node->next;
@@ -162,7 +161,7 @@ handle_outgoing (xmlNodePtr head, EmailProvider *provider)
}
static gboolean
-parse_message (const char *msg, int length, EmailProvider *provider)
+parse_message (const gchar *msg, gint length, EmailProvider *provider)
{
xmlDocPtr doc;
xmlNodePtr node, top;
@@ -204,7 +203,7 @@ parse_message (const char *msg, int length, EmailProvider *provider)
} else if (strcmp ((gchar *)node->name, "outgoingServer") == 0) {
/* Handle Outgoing */
handle_outgoing (node, provider);
- }
+ }
node = node->next;
}
@@ -241,13 +240,13 @@ is_online (void)
static gboolean
guess_when_online (EmailProvider *provider)
{
- const char *cafile = NULL;
- char *url;
+ const gchar *cafile = NULL;
+ gchar *url;
SoupURI *proxy = NULL, *parsed;
SoupMessage *msg;
SoupSession *session;
- url = g_strdup_printf("%s/%s", "https://live.mozillamessaging.com/autoconfig", provider->domain);
+ url = g_strdup_printf("%s/%s", "https://live.mozillamessaging.com/autoconfig", provider->domain);
parsed = soup_uri_new (url);
soup_uri_free (parsed);
@@ -257,7 +256,7 @@ guess_when_online (EmailProvider *provider)
NULL);
if (proxy) {
- g_object_set (G_OBJECT (session),
+ g_object_set (G_OBJECT (session),
SOUP_SESSION_PROXY_URI, proxy,
NULL);
}
@@ -267,7 +266,7 @@ guess_when_online (EmailProvider *provider)
return FALSE;
parse_soup_message (msg, provider);
-
+
g_object_unref (msg);
g_object_unref(session);
g_free(url);
@@ -276,8 +275,8 @@ guess_when_online (EmailProvider *provider)
}
-static char *
-get_filename_for_offline_autoconfig (const char *domain)
+static gchar *
+get_filename_for_offline_autoconfig (const gchar *domain)
{
return g_build_filename (EVOLUTION_PRIVDATADIR, "mail-autoconfig", domain, NULL);
}
@@ -285,8 +284,8 @@ get_filename_for_offline_autoconfig (const char *domain)
static gboolean
guess_when_offline (EmailProvider *provider)
{
- char *filename;
- char *contents;
+ gchar *filename;
+ gchar *contents;
gsize length;
gboolean success;
@@ -299,7 +298,7 @@ guess_when_offline (EmailProvider *provider)
if (!g_file_get_contents (filename, &contents, &length, NULL)) /* NULL-GError */
goto out;
- success = parse_message (contents, (int) length, provider);
+ success = parse_message (contents, (gint) length, provider);
out:
g_free (filename);
@@ -318,8 +317,8 @@ mail_guess_servers(EmailProvider *provider)
}
#ifdef TEST
-int
-main (int argc, char **argv)
+gint
+main (gint argc, gchar **argv)
{
EmailProvider *provider;
g_thread_init (NULL);
@@ -333,10 +332,10 @@ main (int argc, char **argv)
mail_guess_servers (provider);
- printf("Recv: %s\n%s(%s), %s by %s \n Send: %s\n%s(%s), %s by %s\n via %s to %s\n",
+ printf("Recv: %s\n%s(%s), %s by %s \n Send: %s\n%s(%s), %s by %s\n via %s to %s\n",
provider->recv_type, provider->recv_hostname, provider->recv_port, provider->recv_username, provider->recv_auth,
provider->send_type, provider->send_hostname, provider->send_port, provider->send_username, provider->send_auth,
- provider->recv_socket_type, provider->send_socket_type);
+ provider->recv_socket_type, provider->send_socket_type);
return 0;
}
#endif