]> saetta.ns0.it Git - solipa/libsolipa/commitdiff
Aggiunta la possibilità in SolipaMailUI di specificare più di un mail_gui
authorAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Fri, 6 May 2011 11:32:47 +0000 (13:32 +0200)
committerAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Fri, 6 May 2011 11:32:47 +0000 (13:32 +0200)
indirizzo nei campi to, cc e bcc.

src/mailui.c
tests/mailui.c

index 5ccf722aacc0e8843878a67bb2d9b7c2b3ef306b..59cf531949bee9afa1d00e423fb71deb82cef290 100644 (file)
@@ -358,6 +358,8 @@ solipa_mail_ui_send (SolipaMailUI *mailui)
        gchar *subject;
        gchar *body;
 
+       GSList *lst_addrs;
+
        CamelInternetAddress *addr;
 
        g_return_val_if_fail (IS_SOLIPA_MAIL_UI (mailui), FALSE);
@@ -385,10 +387,21 @@ solipa_mail_ui_send (SolipaMailUI *mailui)
 
        if (g_strcmp0 (g_strstrip (from), "") != 0)
                {
-                       addr = camel_internet_address_new ();
-                       camel_internet_address_add (addr, "Prova from", from);
-                       solipa_mail_set_from (smail, addr);
-                       camel_address_remove (CAMEL_ADDRESS (addr), -1);
+                       lst_addrs = solipa_mail_get_addresses_from_string (from);
+                       if (lst_addrs != NULL)
+                               {
+                                       addr = camel_internet_address_new ();
+                                       camel_internet_address_add (addr,
+                                                                   g_hash_table_lookup ((GHashTable *)lst_addrs->data, "name"),
+                                                                   g_hash_table_lookup ((GHashTable *)lst_addrs->data, "address"));
+                                       solipa_mail_set_from (smail, addr);
+                                       camel_address_remove (CAMEL_ADDRESS (addr), -1);
+                               }
+                       else
+                               {
+                                       g_warning ("Campo Da: mancante.");
+                                       return FALSE;
+                               }
                }
        else
                {
@@ -398,9 +411,25 @@ solipa_mail_ui_send (SolipaMailUI *mailui)
 
        if (g_strcmp0 (g_strstrip (to), "") != 0)
                {
-                       camel_internet_address_add (addr, "Prova to", to);
-                       solipa_mail_add_recipient (smail, addr, SOLIPA_MAIL_RECIPIENT_TYPE_TO);
-                       camel_address_remove (CAMEL_ADDRESS (addr), -1);
+                       lst_addrs = solipa_mail_get_addresses_from_string (to);
+                       if (lst_addrs != NULL)
+                               {
+                                       while (lst_addrs != NULL)
+                                               {
+                                                       camel_internet_address_add (addr,
+                                                                                   g_hash_table_lookup ((GHashTable *)lst_addrs->data, "name"),
+                                                                                   g_hash_table_lookup ((GHashTable *)lst_addrs->data, "address"));
+                                                       lst_addrs = g_slist_next (lst_addrs);
+                                               }
+
+                                       solipa_mail_add_recipient (smail, addr, SOLIPA_MAIL_RECIPIENT_TYPE_TO);
+                                       camel_address_remove (CAMEL_ADDRESS (addr), -1);
+                               }
+                       else
+                               {
+                                       g_warning ("Campo A: mancante.");
+                                       return FALSE;
+                               }
                }
        else
                {
@@ -410,16 +439,38 @@ solipa_mail_ui_send (SolipaMailUI *mailui)
 
        if (g_strcmp0 (g_strstrip (cc), "") != 0)
                {
-                       camel_internet_address_add (addr, "Prova cc", cc);
-                       solipa_mail_add_recipient (smail, addr, SOLIPA_MAIL_RECIPIENT_TYPE_CC);
-                       camel_address_remove (CAMEL_ADDRESS (addr), -1);
+                       lst_addrs = solipa_mail_get_addresses_from_string (cc);
+                       if (lst_addrs != NULL)
+                               {
+                                       while (lst_addrs != NULL)
+                                               {
+                                                       camel_internet_address_add (addr,
+                                                                                   g_hash_table_lookup ((GHashTable *)lst_addrs->data, "name"),
+                                                                                   g_hash_table_lookup ((GHashTable *)lst_addrs->data, "address"));
+                                                       lst_addrs = g_slist_next (lst_addrs);
+                                               }
+
+                                       solipa_mail_add_recipient (smail, addr, SOLIPA_MAIL_RECIPIENT_TYPE_CC);
+                                       camel_address_remove (CAMEL_ADDRESS (addr), -1);
+                               }
                }
 
        if (g_strcmp0 (g_strstrip (bcc), "") != 0)
                {
-                       camel_internet_address_add (addr, "Prova bcc", bcc);
-                       solipa_mail_add_recipient (smail, addr, SOLIPA_MAIL_RECIPIENT_TYPE_BCC);
-                       camel_address_remove (CAMEL_ADDRESS (addr), -1);
+                       lst_addrs = solipa_mail_get_addresses_from_string (bcc);
+                       if (lst_addrs != NULL)
+                               {
+                                       while (lst_addrs != NULL)
+                                               {
+                                                       camel_internet_address_add (addr,
+                                                                                   g_hash_table_lookup ((GHashTable *)lst_addrs->data, "name"),
+                                                                                   g_hash_table_lookup ((GHashTable *)lst_addrs->data, "address"));
+                                                       lst_addrs = g_slist_next (lst_addrs);
+                                               }
+
+                                       solipa_mail_add_recipient (smail, addr, SOLIPA_MAIL_RECIPIENT_TYPE_BCC);
+                                       camel_address_remove (CAMEL_ADDRESS (addr), -1);
+                               }
                }
 
        g_object_unref (addr);
index 22b3607757c034a22ebbe5f7dcd91f160d7b5472..8ebe31c18a111fb525ee9bdfe4880be925999d48 100644 (file)
@@ -98,10 +98,9 @@ main (int argc, char *argv[])
 
        g_object_set (G_OBJECT (mailui),
                      "smtp-uri", "smtp://mail.comune.scandicci.fi.it/",
-                     "from", "a.zagli@comune.scandicci.fi.it",
+                     "from", "Andrea Zagli <a.zagli@comune.scandicci.fi.it>",
                      "from-editable", FALSE,
                      "to", "a.zagli@comune.scandicci.fi.it",
-                     "cc-visible", FALSE,
                      "bcc-visible", FALSE,
                      "subject", "Da SolipaMailUI",
                      "body", "Il body della mail\n"