Changeset 2204

Show
Ignore:
Timestamp:
06/18/07 13:29:38
Author:
pvanhoof
Message:

API changes in the error-happened signal

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r2201 r2204  
    33        * Fixed the From and the Error reporting when sending messages 
    44        * Fixed the support for Yahoo's SMTP 
     5        * Added some more information to the error-happened signal for 
     6        TnySendQueue 
     7 
     8        * This was a major API change 
    59 
    6102007-06-17  Philip Van Hoof  <pvanhoof@gnome.org> 
  • trunk/libtinymail-camel/tny-camel-send-queue.c

    r2200 r2204  
    4848typedef struct { 
    4949        TnySendQueue *self; 
    50         TnyMsg *msg; 
     50        TnyMsg *msg;  
     51        TnyHeader *header; 
    5152        GError *error; 
    5253        gint i, total; 
     
    5859        ErrorInfo *info = data; 
    5960        g_signal_emit (info->self, tny_send_queue_signals [TNY_SEND_QUEUE_ERROR_HAPPENED],  
    60                                 0, info->msg, info->error); 
     61                                0, info->header, info->msg, info->error); 
    6162        return FALSE; 
    6263} 
     
    7879 
    7980static void 
    80 emit_error (TnySendQueue *self, TnyMsg *msg, GError *error, int i, int total) 
     81emit_error (TnySendQueue *self, TnyHeader *header, TnyMsg *msg, GError *error, int i, int total) 
    8182{ 
    8283        ErrorInfo *info = g_slice_new0 (ErrorInfo); 
     
    8889        if (msg) 
    8990                info->msg = TNY_MSG (g_object_ref (G_OBJECT (msg))); 
     91        if (header) 
     92                info->header = TNY_HEADER (g_object_ref (G_OBJECT (header))); 
    9093 
    9194        info->i = i; 
     
    122125                if (terror != NULL) 
    123126                { 
    124                         emit_error (self, NULL, terror, i, priv->total); 
     127                        emit_error (self, NULL, NULL, terror, i, priv->total); 
    125128                        g_error_free (terror); 
    126129                        g_object_unref (G_OBJECT (list)); 
     
    155158                        if (ferror != NULL) 
    156159                        { 
    157                                 emit_error (self, msg, ferror, i, priv->total); 
     160                                emit_error (self, NULL, NULL, ferror, i, priv->total); 
    158161                                g_error_free (ferror); 
    159162                                g_object_unref (G_OBJECT (headers)); 
     
    191194                        tny_list_prepend (hassent, G_OBJECT (header)); 
    192195                        msg = tny_folder_get_msg (outbox, header, &err); 
    193                         g_object_unref (G_OBJECT (header)); 
     196 
     197                        /* hassent is owner now */ 
     198                        g_object_unref (G_OBJECT (header));  
    194199 
    195200                        if (err == NULL)  
     
    198203 
    199204                                if (err != NULL) { 
    200                                         emit_error (self, msg, err, i, priv->total); 
     205                                        emit_error (self, header, msg, err, i, priv->total); 
    201206                                        priv->do_continue = FALSE; 
    202207                                } 
    203208                        } else  { 
    204                                 emit_error (self, msg, err, i, priv->total); 
     209                                emit_error (self, header, msg, err, i, priv->total); 
    205210                                priv->do_continue = FALSE; 
    206211                        } 
     
    214219                                        if (newerr != NULL)  
    215220                                        { 
    216                                                 emit_error (self, msg, newerr, i, priv->total); 
     221                                                emit_error (self, header, msg, newerr, i, priv->total); 
    217222                                                priv->do_continue = FALSE; 
    218223                                                g_error_free (newerr); 
  • trunk/libtinymail/tny-header.c

    r2182 r2204  
    553553                type = g_type_register_static (G_TYPE_INTERFACE, 
    554554                        "TnyHeader", &info, 0); 
     555                g_type_interface_add_prerequisite (type, G_TYPE_OBJECT); 
     556 
    555557        } 
    556558 
  • trunk/libtinymail/tny-send-queue.c

    r2199 r2204  
    163163 * TnySendQueue::error-happened 
    164164 * @self: the object on which the signal is emitted 
    165  * @arg1: The message that was supposed to be sent or NULL 
    166  * @arg2: a GError containing the error that happened 
    167  * @arg5: user data 
     165 * @arg1: The header of the message that was supposed to be sent or NULL 
     166 * @arg2: The message that was supposed to be sent or NULL 
     167 * @arg3: a GError containing the error that happened 
     168 * @arg4: user data 
    168169 * 
    169170 * 
     
    176177                        G_STRUCT_OFFSET (TnySendQueueIface, error_happened), 
    177178                        NULL, NULL, 
    178                         tny_marshal_VOID__POINTER_POINTER
    179                         G_TYPE_NONE, 2, TNY_TYPE_MSG, G_TYPE_POINTER); 
     179                        tny_marshal_VOID__POINTER_POINTER_POINTER
     180                        G_TYPE_NONE, 3, TNY_TYPE_HEADER, TNY_TYPE_MSG, G_TYPE_POINTER); 
    180181 
    181182                initialized = TRUE; 
  • trunk/libtinymail/tny-signals-marshal.list

    r2198 r2204  
    1 VOID:POINTER,POINTER 
     1VOID:POINTER,POINTER,POINTER 
  • trunk/tests/c-demo/tny-demoui-summary-view.c

    r2201 r2204  
    192192} 
    193193 
     194 
     195typedef struct 
     196{ 
     197        TnySummaryView *self; 
     198        TnyMsg *msg; 
     199        TnyHeader *header; 
     200} OnResponseInfo; 
     201 
    194202static void 
    195203on_response (GtkDialog *dialog, gint arg1, gpointer user_data) 
    196204{ 
     205        OnResponseInfo *info = (OnResponseInfo *) user_data; 
     206        TnySummaryView *self = info->self; 
     207        TnyDemouiSummaryViewPriv *priv = TNY_DEMOUI_SUMMARY_VIEW_GET_PRIVATE (self); 
     208        TnyHeader *header = info->header; 
     209        TnyMsg *msg = info->msg; 
     210 
     211        if (arg1 == GTK_RESPONSE_YES) 
     212        { 
     213                TnyFolder *outbox = tny_send_queue_get_outbox (priv->send_queue); 
     214                tny_folder_remove_msg (outbox, header, NULL); 
     215                tny_folder_sync (outbox, TRUE, NULL); 
     216                g_object_unref (outbox); 
     217        } 
     218 
     219        g_object_unref (msg); 
     220        g_object_unref (header); 
     221        g_object_unref (self); 
     222 
    197223        gtk_widget_destroy (GTK_WIDGET (dialog)); 
     224        g_slice_free (OnResponseInfo, info); 
    198225} 
    199226 
    200227static void  
    201 on_send_queue_error_happened (TnySendQueue *self, TnyMsg *msg, GError *err, gpointer user_data) 
    202 
     228on_send_queue_error_happened (TnySendQueue *self, TnyHeader *header, TnyMsg *msg, GError *err, gpointer user_data) 
     229
     230        gchar *str = g_strdup_printf ("%s. Do you want to remove the message (%s)?", 
     231                err->message, tny_header_get_subject (header)); 
     232        OnResponseInfo *info = g_slice_new (OnResponseInfo); 
    203233        GtkWidget *dialog = gtk_message_dialog_new (NULL, 0, 
    204                 GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, err->message); 
    205         g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (on_response), NULL); 
     234                GTK_MESSAGE_ERROR, GTK_BUTTONS_YES_NO, str); 
     235        g_free (str); 
     236        info->self = g_object_ref (user_data); 
     237        info->msg = g_object_ref (msg); 
     238        info->header = g_object_ref (header); 
     239        g_signal_connect (G_OBJECT (dialog), "response", 
     240                G_CALLBACK (on_response), info); 
    206241        gtk_widget_show_all (dialog); 
    207  
    208242        return; 
    209243} 
    210244 
    211245static void  
    212 reload_accounts (TnyDemouiSummaryViewPriv *priv) 
    213 
     246reload_accounts (TnySummaryView *self) 
     247
     248        TnyDemouiSummaryViewPriv *priv = TNY_DEMOUI_SUMMARY_VIEW_GET_PRIVATE (self); 
    214249        TnyAccountStore *account_store = priv->account_store; 
    215250        GtkTreeModel *sortable, *maccounts, *mailbox_model; 
     
    267302                priv->send_queue = tny_camel_send_queue_new ((TnyCamelTransportAccount *) tacc); 
    268303                g_signal_connect (G_OBJECT (priv->send_queue), "error-happened", 
    269                         G_CALLBACK (on_send_queue_error_happened), priv); 
     304                        G_CALLBACK (on_send_queue_error_happened), self); 
    270305                g_object_unref (tacc); 
    271306                g_object_unref (iter); 
     
    289324accounts_reloaded (TnyAccountStore *store, gpointer user_data) 
    290325{ 
    291         TnyDemouiSummaryViewPriv *priv = user_data; 
    292         reload_accounts (priv); 
     326        reload_accounts ((TnySummaryView *)user_data); 
    293327        return; 
    294328} 
     
    427461        priv->accounts_reloaded_signal = g_signal_connect ( 
    428462                G_OBJECT (account_store), "accounts_reloaded", 
    429                 G_CALLBACK (accounts_reloaded), priv); 
    430  
    431         reload_accounts (priv); 
     463                G_CALLBACK (accounts_reloaded), self); 
     464 
     465        reload_accounts ((TnySummaryView *) self); 
    432466 
    433467        g_object_unref (G_OBJECT (device));