From: Andrea Zagli Date: Sun, 20 Feb 2011 11:50:46 +0000 (+0100) Subject: Richiamta manualmente la funzione WSAStartup sotto win32. X-Git-Tag: 0.0.3~3 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=refs%2Fheads%2Fevolution-data-server-2.32;p=solipa%2Flibsolipa Richiamta manualmente la funzione WSAStartup sotto win32. --- diff --git a/src/mail.c b/src/mail.c index 0c60223..033cfb3 100644 --- a/src/mail.c +++ b/src/mail.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Andrea Zagli + * Copyright (C) 2010-2011 Andrea Zagli * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -24,6 +24,10 @@ #include "mail.h" +#ifdef G_OS_WIN32 + #include +#endif + static void solipa_mail_class_init (SolipaMailClass *class); static void solipa_mail_init (SolipaMail *solipa_mail); @@ -393,6 +397,34 @@ solipa_mail_send (SolipaMail *mail, const gchar *url) return; } +#ifdef G_OS_WIN32 + /* devo richiamare manualmente l'inizializzazione dei socket in windows + * perché libcamel non lo fa */ + WORD wVersionRequested; + WSADATA wsaData; + + wVersionRequested = MAKEWORD(2, 2); + + int err = WSAStartup (wVersionRequested, &wsaData); + + if (err != 0) + { + /* Tell the user that we could not find a usable */ + /* Winsock DLL. */ + g_warning ("WSAStartup failed with error: %d", err); + return; + } + + if (LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2) + { + /* Tell the user that we could not find a usable */ + /* WinSock DLL. */ + g_warning ("Could not find a usable version of Winsock.dll."); + WSACleanup (); + return; + } +#endif + error = NULL; trans = camel_session_get_service (solipa_get_camel_session (priv->solipa), url, CAMEL_PROVIDER_TRANSPORT, &error); if (trans == NULL || error != NULL) @@ -432,6 +464,10 @@ solipa_mail_send (SolipaMail *mail, const gchar *url) noconnect: g_object_unref (trans); + +#ifdef G_OS_WIN32 + WSACleanup (); +#endif } /* PRIVATE */ diff --git a/src/utils.c b/src/utils.c index 3042b77..ca68a6d 100644 --- a/src/utils.c +++ b/src/utils.c @@ -210,7 +210,7 @@ solipa_gtktreemodel_to_csv (GtkTreeModel *model, const gchar *filename, if (fields_name_first_row) { - /* nomi dei campi come priga riga */ + /* nomi dei campi come prima riga */ row = g_strdup (""); for (i = 0; i < n_columns; i++) { diff --git a/tests/mail.c b/tests/mail.c index 26f6673..0d78930 100644 --- a/tests/mail.c +++ b/tests/mail.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Andrea Zagli + * Copyright (C) 2010-2011 Andrea Zagli * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -40,7 +40,7 @@ main (int argc, char **argv) camel_address_remove (CAMEL_ADDRESS (addr), -1); - camel_internet_address_add (addr, "tux", "tux@sid-sviluppo.miodominio.it"); + camel_internet_address_add (addr, "pippo", "pippo@localhost"); solipa_mail_add_recipient (smail, addr, SOLIPA_MAIL_RECIPIENT_TYPE_TO); g_object_unref (addr); @@ -49,7 +49,7 @@ main (int argc, char **argv) strmail = solipa_mail_get_as_string (smail); g_message ("The email text:\n%s", strmail); - solipa_mail_send (smail, "smtp://10.0.0.102/"); + solipa_mail_send (smail, "smtp://localhost/"); return 0; }