Changeset 2109

Show
Ignore:
Timestamp:
06/08/07 16:16:25
Author:
pvanhoof
Message:

Bugfixes for SMTP and the folder monitr

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r2107 r2109  
    1010        * Total and ~unread even when the folder was never refreshed 
    1111        * Support for the Content-Disposition header in mime parts 
     12        * Some bugfixes in the SMTP support 
     13        * Bugfix in the TnyFolderMonitor 
    1214 
    13152007-06-08  Jose Dapena Paz  <jdapena@igalia.com> 
  • trunk/libtinymail-camel/camel-lite/camel/camel-service.c

    r2073 r2109  
    441441                        camel_operation_unregister (service->connect_op); 
    442442 
    443                 camel_operation_unref (service->connect_op); 
     443                if (service->connect_op) 
     444                        camel_operation_unref (service->connect_op); 
    444445                service->connect_op = NULL; 
    445446                CAMEL_SERVICE_UNLOCK (service, connect_op_lock); 
  • trunk/libtinymail-camel/camel-lite/camel/providers/smtp/camel-smtp-transport.c

    r1943 r2109  
    125125} 
    126126 
     127static void 
     128camel_smtp_transport_finalize (CamelSmtpTransport *self) 
     129{ 
     130        g_print ("debug\n"); 
     131} 
     132 
    127133CamelType 
    128134camel_smtp_transport_get_type (void) 
     
    138144                                            NULL, 
    139145                                            (CamelObjectInitFunc) camel_smtp_transport_init, 
    140                                             NULL); 
     146                                            (CamelObjectFinalizeFunc) camel_smtp_transport_finalize); 
    141147        } 
    142148         
     
    495501                                                "authentication type %s."), 
    496502                                              service->url->host, service->url->authmech); 
     503 
     504                        camel_session_alert_user (session, CAMEL_SESSION_ALERT_ERROR,  
     505                                camel_exception_get_description (ex), FALSE); 
     506 
    497507                        camel_service_disconnect (service, TRUE, NULL); 
    498508                        return FALSE; 
     
    13941404        } 
    13951405        g_free (cmdbuf); 
    1396          
    1397         do { 
    1398                 /* Check for "221" */ 
     1406 
     1407        if (FALSE && transport->istream && CAMEL_STREAM_BUFFER (transport->istream)) 
     1408        { 
     1409                do { 
     1410                        /* Check for "221" */ 
     1411                        if (respbuf)  
     1412                                g_free (respbuf); 
     1413                        respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (transport->istream)); 
     1414                         
     1415                        d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)")); 
     1416                         
     1417                        if (!respbuf || strncmp (respbuf, "221", 3)) { 
     1418                                smtp_set_exception (transport, FALSE, respbuf, _("QUIT command failed"), ex); 
     1419                                g_free (respbuf); 
     1420                                return FALSE; 
     1421                        } 
     1422                } while (*(respbuf+3) == '-'); /* if we got "221-" then loop again */ 
     1423        } 
     1424 
     1425        if (respbuf) 
    13991426                g_free (respbuf); 
    1400                 respbuf = camel_stream_buffer_read_line (CAMEL_STREAM_BUFFER (transport->istream)); 
    1401                  
    1402                 d(fprintf (stderr, "received: %s\n", respbuf ? respbuf : "(null)")); 
    1403                  
    1404                 if (!respbuf || strncmp (respbuf, "221", 3)) { 
    1405                         smtp_set_exception (transport, FALSE, respbuf, _("QUIT command failed"), ex); 
    1406                         g_free (respbuf); 
    1407                         return FALSE; 
    1408                 } 
    1409         } while (*(respbuf+3) == '-'); /* if we got "221-" then loop again */ 
    1410         g_free (respbuf); 
    1411          
     1427 
    14121428        return TRUE; 
    14131429} 
  • trunk/libtinymail-camel/tny-camel-send-queue.c

    r2069 r2109  
    186186                        tny_list_prepend (hassent, G_OBJECT (header)); 
    187187                        msg = tny_folder_get_msg (outbox, header, &err); 
    188                         g_object_unref (G_OBJECT (header));     
     188                        g_object_unref (G_OBJECT (header)); 
    189189 
    190190                        if (err == NULL)  
     
    192192                                tny_transport_account_send (priv->trans_account, msg, &err); 
    193193 
    194                                 if (err != NULL) 
     194                                if (err != NULL) { 
    195195                                        emit_error (self, msg, err, i, priv->total); 
    196  
    197                         } else  
     196                                        priv->do_continue = FALSE; 
     197                                } 
     198                        } else  { 
    198199                                emit_error (self, msg, err, i, priv->total); 
     200                                priv->do_continue = FALSE; 
     201                        } 
    199202 
    200203                        g_mutex_lock (priv->todo_lock); 
     
    207210                                        { 
    208211                                                emit_error (self, msg, newerr, i, priv->total); 
     212                                                priv->do_continue = FALSE; 
    209213                                                g_error_free (newerr); 
    210214                                        } 
  • trunk/libtinymail-camel/tny-camel-transport-account.c

    r1997 r2109  
    292292        } 
    293293 
    294         camel_service_disconnect (apriv->service, FALSE, &ex); 
     294        camel_service_disconnect (apriv->service, TRUE, &ex); 
    295295        apriv->connected = FALSE; 
    296296 
  • trunk/libtinymail/tny-folder-monitor.c

    r1920 r2109  
    165165                header = TNY_HEADER (tny_iterator_get_current (iter)); 
    166166                id = tny_header_get_uid (header); 
    167                 if (id && (!strcmp (id, uid))) 
     167                if (id && uid && (!strcmp (id, uid))) 
    168168                {  
    169169                        found = TRUE;  
  • trunk/tests/c-demo/tny-demoui-summary-view.c

    r2097 r2109  
    6868#include <tny-merge-folder.h> 
    6969 
     70#include <tny-camel-send-queue.h> 
     71 
    7072#define GO_ONLINE_TXT _("Go online") 
    7173#define GO_OFFLINE_TXT _("Go offline") 
     
    103105        TnyFolderMonitor *monitor; GMutex *monitor_lock; 
    104106        gboolean handle_recon; 
     107        TnySendQueue *send_queue; 
    105108}; 
    106109 
     
    214217 
    215218        TnyList *accounts = TNY_LIST (mailbox_model); 
     219        TnyList *saccounts = tny_simple_list_new (); 
    216220 
    217221        maccounts = tny_gtk_account_list_model_new (); 
    218  
    219222 
    220223        clear_header_view (priv); 
     
    234237        tny_account_store_get_accounts (account_store, TNY_LIST (maccounts), 
    235238                        TNY_ACCOUNT_STORE_STORE_ACCOUNTS); 
     239 
    236240        gtk_combo_box_set_model (priv->account_view, maccounts); 
     241 
     242        tny_account_store_get_accounts (account_store, saccounts, 
     243                        TNY_ACCOUNT_STORE_TRANSPORT_ACCOUNTS); 
     244 
     245        if (tny_list_get_length (saccounts) > 0) 
     246        { 
     247                TnyIterator *iter = tny_list_create_iterator (saccounts); 
     248                TnyTransportAccount *tacc = (TnyTransportAccount *)tny_iterator_get_current (iter); 
     249                if (priv->send_queue) 
     250                        g_object_unref (priv->send_queue); 
     251                priv->send_queue = tny_camel_send_queue_new ((TnyCamelTransportAccount *) tacc); 
     252                g_object_unref (tacc); 
     253                g_object_unref (iter); 
     254        } 
     255        g_object_unref (saccounts); 
    237256 
    238257        /* Here we use the TnyFolderStoreTreeModel as a GtkTreeModel */ 
     
    402421on_header_view_key_press_event (GtkTreeView *header_view, GdkEventKey *event, gpointer user_data) 
    403422{ 
     423        TnyDemouiSummaryView *self = (TnyDemouiSummaryView *) user_data; 
     424        TnyDemouiSummaryViewPriv *priv = TNY_DEMOUI_SUMMARY_VIEW_GET_PRIVATE (self); 
     425 
     426 
     427        if (event->keyval == GDK_Home && priv->send_queue) 
     428        { 
     429                GtkTreeSelection *selection = gtk_tree_view_get_selection (header_view); 
     430                GtkTreeModel *model; 
     431                GtkTreeIter iter; 
     432 
     433                if (gtk_tree_selection_get_selected (selection, &model, &iter)) 
     434                { 
     435                        TnyHeader *header; 
     436 
     437                        gtk_tree_model_get (model, &iter,  
     438                                TNY_GTK_HEADER_LIST_MODEL_INSTANCE_COLUMN,  
     439                                &header, -1); 
     440 
     441                        if (header) 
     442                        { 
     443                                GError *err = NULL; 
     444                                TnyMsg *msg; 
     445                                TnyFolder *folder; 
     446 
     447                                GtkWidget *entry1, *entry2; 
     448                                GtkWidget *dialog; 
     449 
     450                                folder = tny_header_get_folder (header); 
     451                                if (folder) { 
     452                                        msg = tny_folder_get_msg (folder, header, &err); 
     453                                        g_object_unref (folder); 
     454                                } 
     455 
     456                                if (!msg || err != NULL) 
     457                                { 
     458                                        g_warning ("Can't forward message: %s\n", err->message); 
     459                                        if (msg)  
     460                                                g_object_unref (msg); 
     461                                        g_object_unref (header); 
     462                                        return; 
     463                                } 
     464 
     465                                dialog = gtk_dialog_new_with_buttons (_("Forward a message"), 
     466                                                  NULL, GTK_DIALOG_MODAL, 
     467                                                  GTK_STOCK_OK, 
     468                                                  GTK_RESPONSE_YES, 
     469                                                  GTK_STOCK_CANCEL, 
     470                                                  GTK_RESPONSE_REJECT, 
     471                                                  NULL); 
     472 
     473                                entry1 = gtk_entry_new (); 
     474                                gtk_entry_set_text (GTK_ENTRY (entry1), _("To: ")); 
     475                                gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), entry1); 
     476                                gtk_widget_show (entry1); 
     477 
     478                                entry2 = gtk_entry_new (); 
     479                                gtk_entry_set_text (GTK_ENTRY (entry2), _("From: ")); 
     480                                gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), entry2); 
     481                                gtk_widget_show (entry2); 
     482 
     483                                if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES) 
     484                                { 
     485                                        TnyHeader *nheader = tny_msg_get_header (msg); 
     486                                        const gchar *to = gtk_entry_get_text (GTK_ENTRY (entry1)); 
     487                                        const gchar *from = gtk_entry_get_text (GTK_ENTRY (entry2)); 
     488 
     489                                        tny_header_set_to (nheader, to); 
     490                                        tny_header_set_to (nheader, from); 
     491 
     492                                        g_object_unref (nheader); 
     493                                        tny_send_queue_add (priv->send_queue, msg, NULL); 
     494                                } 
     495 
     496                                gtk_widget_destroy (dialog); 
     497 
     498                                g_object_unref (msg); 
     499                                g_object_unref (G_OBJECT (header)); 
     500                        } 
     501                } 
     502        } 
     503 
    404504        if (event->keyval == GDK_Delete) 
    405505        { 
     
    768868                                if (G_LIKELY (msg)) 
    769869                                { 
    770  
    771 /* DEBUG                 
    772                                         TnyAccountStore *astore = priv->account_store; 
    773                                         TnyList *accs = tny_simple_list_new (); 
    774                                         tny_account_store_get_accounts (astore, accs, TNY_ACCOUNT_STORE_TRANSPORT_ACCOUNTS); 
    775                                         TnyIterator *iter = tny_list_create_iterator (accs); 
    776                                         TnyCamelTransportAccount *acc = (TnyCamelTransportAccount *) tny_iterator_get_current (iter); 
    777  
    778                                         g_print ("--> %s\n", tny_account_get_name (TNY_ACCOUNT (acc))); 
    779                  
    780                                         if (!queue) 
    781                                                 queue = tny_camel_send_queue_new (acc); 
    782                  
    783                                         tny_send_queue_add (queue, msg, NULL); 
    784  
    785                                         g_object_unref (G_OBJECT (acc)); 
    786                                         g_object_unref (G_OBJECT (iter)); 
    787                                         g_object_unref (G_OBJECT (accs)); 
    788 */ 
    789  
    790870                                        msgwin = tny_gtk_msg_window_new ( 
    791871                                                tny_platform_factory_new_msg_view (platfact)); 
     
    796876                                        gtk_widget_show (GTK_WIDGET (msgwin)); 
    797877                                } else { 
    798  
    799  
    800  
    801878                                        msgwin = tny_gtk_msg_window_new ( 
    802879                                                tny_platform_factory_new_msg_view (platfact)); 
     
    11471224 
    11481225                        dialog = gtk_dialog_new_with_buttons (_("Create a folder"), 
    1149                                                                                                  GTK_WINDOW (gtk_widget_get_parent (GTK_WIDGET (self))), 
    1150                                                                                                  GTK_DIALOG_MODAL, 
    1151                                                                                                  GTK_STOCK_OK, 
    1152                                                                                                  GTK_RESPONSE_ACCEPT, 
    1153                                                                                                  GTK_STOCK_CANCEL, 
    1154                                                                                                  GTK_RESPONSE_REJECT, 
    1155                                                                                                  NULL); 
     1226                                          GTK_WINDOW (gtk_widget_get_parent (GTK_WIDGET (self))), 
     1227                                          GTK_DIALOG_MODAL, 
     1228                                          GTK_STOCK_OK, 
     1229                                          GTK_RESPONSE_ACCEPT, 
     1230                                          GTK_STOCK_CANCEL, 
     1231                                          GTK_RESPONSE_REJECT, 
     1232                                          NULL); 
    11561233 
    11571234                        entry = gtk_entry_new (); 
     
    14041481        priv->monitor = NULL; 
    14051482 
     1483        priv->send_queue = NULL; 
    14061484        priv->last_mailbox_correct_select_set = FALSE; 
    14071485        priv->online_button = gtk_toggle_button_new_with_label (GO_ONLINE_TXT);