Changeset 1911
- Timestamp:
- 05/08/07 11:41:03
- Files:
-
- trunk/ChangeLog (modified) (1 diff)
- trunk/libtinymail-acap/tny-acap-account-store.c (modified) (1 diff)
- trunk/libtinymail-camel/tny-camel-account.c (modified) (1 diff)
- trunk/libtinymail-camel/tny-session-camel.c (modified) (3 diffs)
- trunk/libtinymail-gnome-desktop/tny-gnome-account-store.c (modified) (1 diff)
- trunk/libtinymail-gpe/tny-gpe-account-store.c (modified) (1 diff)
- trunk/libtinymail-maemo/tny-maemo-account-store.c (modified) (3 diffs)
- trunk/libtinymail-olpc/tny-olpc-account-store.c (modified) (1 diff)
- trunk/libtinymail/tny-account-store.c (modified) (4 diffs)
- trunk/libtinymail/tny-account-store.h (modified) (2 diffs)
- trunk/tests/shared/account-store.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ChangeLog
r1906 r1911 1 2007-05-08 Murray Cumming <murrayc@murrayc.com 2 3 * libtinymail/tny-account-store.c: 4 * libtinymail/tny-account-store.h: Change the alert_func vfunc to 5 provide a GError instead of a human-readable error string. 6 (tny_account_store_alert): The documentation for this vfunc invoker seems to 7 refer to the vfunc (as is also normal in GTK+), so document how the GError 8 should be used and point out that the application should translate the 9 message and show an appropriate dialog. 10 This does not seem to require the definition of a new GError domain - 11 the existing one seems suitable. 12 13 * libtinymail-acap/tny-acap-account-store.c: 14 (tny_acap_account_store_alert): 15 * libtinymail-camel/tny-camel-account.c: 16 (tny_camel_account_set_online_default): 17 * libtinymail-camel/tny-session-camel.c: 18 (tny_session_camel_alert_user), (foreach_account_set_connectivity): 19 * libtinymail-gnome-desktop/tny-gnome-account-store.c: 20 (tny_gnome_account_store_alert): 21 * libtinymail-gpe/tny-gpe-account-store.c: 22 (tny_gpe_account_store_alert): 23 * libtinymail-maemo/tny-maemo-account-store.c: 24 (tny_maemo_account_store_alert): 25 * libtinymail-olpc/tny-olpc-account-store.c: 26 (tny_olpc_account_store_alert): 27 * tests/shared/account-store.c: (tny_test_account_store_alert): 28 Use the GError instead of the message string. 29 1 30 2007-05-08 Philip Van Hoof <pvanhoof@gnome.org> 2 31 trunk/libtinymail-acap/tny-acap-account-store.c
r1855 r1911 48 48 49 49 static gboolean 50 tny_acap_account_store_alert (TnyAccountStore *self, TnyAlertType type, const gchar *prompt)51 { 52 TnyAcapAccountStorePriv *priv = TNY_ACAP_ACCOUNT_STORE_GET_PRIVATE (self); 53 return tny_account_store_alert (priv->real, type, prompt);50 tny_acap_account_store_alert (TnyAccountStore *self, TnyAlertType type, const GError *error) 51 { 52 TnyAcapAccountStorePriv *priv = TNY_ACAP_ACCOUNT_STORE_GET_PRIVATE (self); 53 return tny_account_store_alert (priv->real, type, error); 54 54 } 55 55 trunk/libtinymail-camel/tny-camel-account.c
r1886 r1911 840 840 tny_camel_account_set_online_default (TnyCamelAccount *self, gboolean online, GError **err) 841 841 { 842 /* Note that the human-readable GError:message strings here are only for debugging. 843 * They should never be shown to the user. The application should make its own 844 * decisions about how to show these errors in the UI, and should make sure that 845 * they are translated in the user's locale. 846 */ 847 842 848 TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 843 849 CamelException ex = CAMEL_EXCEPTION_INITIALISER; trunk/libtinymail-camel/tny-session-camel.c
r1866 r1911 170 170 171 171 static gboolean 172 tny_session_camel_alert_user (CamelSession *session, CamelSessionAlertType type, const char *prompt, gboolean cancel)172 tny_session_camel_alert_user (CamelSession *session, CamelSessionAlertType type, const GError *error, gboolean cancel) 173 173 { 174 174 TnySessionCamel *self = (TnySessionCamel *)session; … … 199 199 retval = tny_account_store_alert ( 200 200 (TnyAccountStore*) self->priv->account_store, 201 tnytype, (const gchar *) prompt);201 tnytype, error); 202 202 tny_lockable_unlock (self->priv->ui_lock); 203 203 } … … 415 415 if (err != NULL) 416 416 { 417 tny_session_camel_alert_user (session, CAMEL_SESSION_ALERT_ERROR, err ->message, FALSE);417 tny_session_camel_alert_user (session, CAMEL_SESSION_ALERT_ERROR, err, FALSE); 418 418 g_error_free (err); 419 419 } trunk/libtinymail-gnome-desktop/tny-gnome-account-store.c
r1866 r1911 100 100 101 101 static gboolean 102 tny_gnome_account_store_alert (TnyAccountStore *self, TnyAlertType type, const gchar *prompt)102 tny_gnome_account_store_alert (TnyAccountStore *self, TnyAlertType type, const GError *error) 103 103 { 104 104 GtkMessageType gtktype; trunk/libtinymail-gpe/tny-gpe-account-store.c
r1855 r1911 98 98 99 99 static gboolean 100 tny_gpe_account_store_alert (TnyAccountStore *self, TnyAlertType type, const gchar *prompt)100 tny_gpe_account_store_alert (TnyAccountStore *self, TnyAlertType type, const GError *error) 101 101 { 102 102 GtkMessageType gtktype; trunk/libtinymail-maemo/tny-maemo-account-store.c
r1861 r1911 34 34 35 35 #include <tny-account-store.h> 36 #include <tny-error.h> 36 37 #include <tny-maemo-account-store.h> 37 38 #include <tny-account.h> … … 98 99 99 100 static gboolean 100 tny_maemo_account_store_alert (TnyAccountStore *self, TnyAlertType type, const gchar *prompt)101 tny_maemo_account_store_alert (TnyAccountStore *self, TnyAlertType type, const GError *error) 101 102 { 102 103 GtkMessageType gtktype; 103 gboolean retval = FALSE;104 104 GtkWidget *dialog; 105 105 … … 118 118 } 119 119 120 const gchar *prompt = NULL; 121 switch (error->code) 122 { 123 /* Currently, this seems to be the only possible error. 124 * It originates from _tny_camel_account_try_connect(), 125 * and maybe from similar functions. 126 * The error->message text originates from 127 * camel-imap-store.c:imap_auth_loop(). 128 */ 129 case TNY_ACCOUNT_ERROR_TRY_CONNECT: 130 /* Use a Logical ID: */ 131 prompt = _("Account not yet fully configured"); 132 break; 133 default: 134 g_warning ("%s: Unhandled GError code.", __FUNCTION__); 135 prompt = NULL; 136 break; 137 } 138 139 if (!prompt) 140 return FALSE; 141 142 /* TODO: Show more appropriate explicitly named buttons in the dialog, 143 * and just show one button if there is no choice to be made. */ 144 gboolean retval = FALSE; 120 145 dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, 121 146 gtktype, GTK_BUTTONS_YES_NO, prompt); trunk/libtinymail-olpc/tny-olpc-account-store.c
r1855 r1911 96 96 97 97 static gboolean 98 tny_olpc_account_store_alert (TnyAccountStore *self, TnyAlertType type, const gchar *prompt)98 tny_olpc_account_store_alert (TnyAccountStore *self, TnyAlertType type, const GError *error) 99 99 { 100 100 GtkMessageType gtktype; trunk/libtinymail/tny-account-store.c
r1866 r1911 81 81 * @self: a #TnyAccountStore object 82 82 * @type: the message type (severity) 83 * @ prompt: the prompt84 * 85 * This jump-to-the-ui method implements showing a message dialog with @prompt86 * a s prompt and @type as message type. It will return TRUE if the reply was83 * @error: A GError, of domain TNY_ACCOUNT_ERROR, which should be used to determine what to show to the user. 84 * 85 * This jump-to-the-ui method implements showing a message dialog appropriate for the @error 86 * and @type as message type. It will return TRUE if the reply was 87 87 * affirmative or FALSE if not. 88 88 * 89 89 * Implementors: when implementing a platform-specific library, you must 90 * implement this method. For example in G tk+ by using the #GtkDialog API. The91 * implementation will for examplebe used to ask the user about accepting SSL90 * implement this method. For example in GTK+ by using the #GtkDialog API. The 91 * implementation will, for example, be used to ask the user about accepting SSL 92 92 * certificates. The two possible answers that must be supported are 93 * "Yes" and "No" which must result in a TRUE or a FALSE return value. 94 * 95 * Example implementation for Gtk+: 93 * "Yes" and "No" which must result in a TRUE or a FALSE return value, though 94 * your implementation should attempt to use explicit button names such as 95 * "Accept Certificate" and "Reject Certificate". Likewise, the dialog should be 96 * arranged according the the user interface guidelines of your target platform. 97 * 98 * Example implementation for GTK+: 96 99 * <informalexample><programlisting> 97 100 * static gboolean 98 * tny_gnome_account_store_alert (TnyAccountStore *self, TnyAlertType type, const gchar *prompt)101 * tny_gnome_account_store_alert (TnyAccountStore *self, TnyAlertType type, const GError *error) 99 102 * { 100 103 * GtkMessageType gtktype; 101 * gboolean retval = FALSE;102 104 * GtkWidget *dialog; 103 105 * switch (type) … … 114 116 * break; 115 117 * } 118 * 119 * const gchar *prompt = NULL; 120 * switch (error->code) 121 * { 122 * case TNY_ACCOUNT_ERROR_TRY_CONNECT: 123 * prompt = _("Account not yet fully configured"); 124 * break; 125 * default: 126 * g_warning ("%s: Unhandled GError code.", __FUNCTION__); 127 * prompt = NULL; 128 * break; 129 * } 130 * 131 * if (!prompt) 132 * return FALSE; 133 * 134 * gboolean retval = FALSE; 116 135 * dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, 117 136 * gtktype, GTK_BUTTONS_YES_NO, prompt); … … 127 146 **/ 128 147 gboolean 129 tny_account_store_alert (TnyAccountStore *self, TnyAlertType type, const gchar *prompt)148 tny_account_store_alert (TnyAccountStore *self, TnyAlertType type, const GError *error) 130 149 { 131 150 gboolean retval; … … 138 157 #endif 139 158 140 retval = TNY_ACCOUNT_STORE_GET_IFACE (self)->alert_func (self, type, prompt);159 retval = TNY_ACCOUNT_STORE_GET_IFACE (self)->alert_func (self, type, error); 141 160 142 161 #ifdef DBC /* ensure */ trunk/libtinymail/tny-account-store.h
r1855 r1911 79 79 const gchar* (*get_cache_dir_func) (TnyAccountStore *self); 80 80 TnyDevice* (*get_device_func) (TnyAccountStore *self); 81 gboolean (*alert_func) (TnyAccountStore *self, TnyAlertType type, const gchar *prompt);81 gboolean (*alert_func) (TnyAccountStore *self, TnyAlertType type, const GError *error); 82 82 TnyAccount* (*find_account_func) (TnyAccountStore *self, const gchar *url_string); 83 83 }; … … 90 90 const gchar* tny_account_store_get_cache_dir (TnyAccountStore *self); 91 91 TnyDevice* tny_account_store_get_device (TnyAccountStore *self); 92 gboolean tny_account_store_alert (TnyAccountStore *self, TnyAlertType type, const gchar *prompt);92 gboolean tny_account_store_alert (TnyAccountStore *self, TnyAlertType type, const GError *error); 93 93 TnyAccount* tny_account_store_find_account (TnyAccountStore *self, const gchar *url_string); 94 94 trunk/tests/shared/account-store.c
r1857 r1911 66 66 67 67 static gboolean 68 tny_test_account_store_alert (TnyAccountStore *self, TnyAlertType type, const gchar *prompt)68 tny_test_account_store_alert (TnyAccountStore *self, TnyAlertType type, const GError *error) 69 69 { 70 70 return TRUE;
