G_DEFINE_TYPE (SolipaCamelSession, solipa_camel_session, CAMEL_TYPE_SESSION)
+CamelCertTrust
+solipa_camel_session_trust_prompt (CamelSession *session,
+ CamelService *service,
+ GTlsCertificate *certificate,
+ GTlsCertificateFlags errors);
+
static void
solipa_camel_session_class_init (SolipaCamelSessionClass *class)
{
+ CamelSessionClass *camel_session_class = CAMEL_SESSION_CLASS (class);
+
+ camel_session_class->trust_prompt = solipa_camel_session_trust_prompt;
}
static void
return session;
}
+
+CamelCertTrust
+solipa_camel_session_trust_prompt (CamelSession *session,
+ CamelService *service,
+ GTlsCertificate *certificate,
+ GTlsCertificateFlags errors)
+{
+ return CAMEL_CERT_TRUST_TEMPORARY;
+}
\ No newline at end of file
CamelInternetAddress *recipients_bcc;
gboolean with_notification;
+ gboolean use_tls;
gchar *body_plain;
gchar *body_html;
GError *error;
GFileInfo *file_info;
CamelStream *cstream;
+ GInputStream *istream;
attachs = priv->attachments;
while (attachs != NULL)
camel_data_wrapper_set_mime_type (dw, g_content_type_get_mime_type (g_file_info_get_content_type (file_info)));
error = NULL;
+#ifdef CAMEL38
+ istream = (GInputStream *)g_file_read (file, NULL, &error);
+ error = NULL;
+ camel_data_wrapper_construct_from_input_stream_sync (dw, istream, NULL, &error);
+ g_object_unref (istream);
+#elif defined CAMEL3
cstream = camel_stream_fs_new_with_name ((gchar *)attachs->data, O_RDONLY, 0, &error);
error = NULL;
-#ifdef CAMEL3
camel_data_wrapper_construct_from_stream_sync (dw, cstream, NULL, &error);
+ g_object_unref (cstream);
#else
camel_data_wrapper_construct_from_stream (dw, cstream, &error);
-#endif
g_object_unref (cstream);
+#endif
part = camel_mime_part_new ();
camel_medium_set_content (CAMEL_MEDIUM (part), dw);
camel_multipart_add_part (mp, part);
g_object_unref (part);
- }
+ }
}
g_object_unref (file);
priv->with_notification = with_notification;
}
+void solipa_mail_enable_tls (SolipaMail *mail, gboolean use_tls)
+{
+ SolipaMailPrivate *priv;
+
+ priv = SOLIPA_MAIL_GET_PRIVATE (mail);
+
+ priv->use_tls = use_tls;
+}
+
void
solipa_mail_send (SolipaMail *mail, const gchar *url)
{
error != NULL && error->message != NULL ? error->message : "no details");
return;
}
-#ifdef CAMEL38
- trans = camel_session_ref_service_by_url (solipa_get_camel_session (priv->solipa), camel_url, CAMEL_PROVIDER_TRANSPORT);
-#else
- trans = camel_session_get_service_by_url (solipa_get_camel_session (priv->solipa), camel_url, CAMEL_PROVIDER_TRANSPORT);
-#endif
+
+ error = NULL;
+ trans = camel_session_add_service (solipa_get_camel_session (priv->solipa), url, camel_url->protocol, CAMEL_PROVIDER_TRANSPORT, &error);
+ if (trans == NULL || error != NULL)
+ {
+ g_warning ("Cannot add service: %s",
+ error != NULL && error->message != NULL ? error->message : "no details");
+ return;
+ }
+ CamelSettings *settings = camel_service_ref_settings (trans);
+ camel_network_settings_set_host (CAMEL_NETWORK_SETTINGS (settings), camel_url->host);
+ camel_network_settings_set_user (CAMEL_NETWORK_SETTINGS (settings), "");
+ if (camel_url->port == 0)
+ {
+ camel_network_settings_set_port (CAMEL_NETWORK_SETTINGS (settings), 25);
+ }
+ else
+ {
+ camel_network_settings_set_port (CAMEL_NETWORK_SETTINGS (settings), camel_url->port);
+ }
+ if (priv->use_tls)
+ {
+ camel_network_settings_set_security_method (CAMEL_NETWORK_SETTINGS (settings), CAMEL_NETWORK_SECURITY_METHOD_STARTTLS_ON_STANDARD_PORT);
+ }
+ else
+ {
+ camel_network_settings_set_security_method (CAMEL_NETWORK_SETTINGS (settings), CAMEL_NETWORK_SECURITY_METHOD_NONE);
+ }
+ camel_service_set_settings (trans, settings);
#else
trans = camel_session_get_service (solipa_get_camel_session (priv->solipa), url, CAMEL_PROVIDER_TRANSPORT, &error);
#endif
gchar *from;
gchar *to;
gchar *url;
+ gboolean notification;
+ gboolean tls;
GError *error;
{ "from", 'f', 0, G_OPTION_ARG_STRING, &from, "Indirizzo FROM", NULL },
{ "to", 't', 0, G_OPTION_ARG_STRING, &to, "Indirizzo TO", NULL },
{ "url", 'u', 0, G_OPTION_ARG_STRING, &url, "Url smtp server", NULL },
+ { "notification", 'n', 0, G_OPTION_ARG_INT, ¬ification, "Richiedere notifica", NULL },
+ { "tls", 's', 0, G_OPTION_ARG_INT, &tls, "Utilizzare TLS", NULL },
{ NULL }
};
from = NULL;
to = NULL;
url = NULL;
+ notification = FALSE;
+ tls = FALSE;
/* gestione degli argomenti della riga di comando */
context = g_option_context_new ("");
solipa_mail_add_recipient (smail, addr, SOLIPA_MAIL_RECIPIENT_TYPE_TO);
g_object_unref (addr);
- solipa_mail_set_notification (smail, TRUE);
+ solipa_mail_set_notification (smail, notification);
+ solipa_mail_enable_tls (smail, tls);
solipa_mail_set_body (smail, "This is the text\nof the email\n that i'm trying to send to myself.\n\nBye bye\n\nSee you later.",
"<html>\n"