Changeset 2067

Show
Ignore:
Timestamp:
05/31/07 19:13:38
Author:
murrayc
Message:

2007-05-31 Murray Cumming <murrayc@murrayc.com>

        • libtinymail-maemo/tny-maemo-conic-device.c:

(tny_maemo_conic_device_connect): Block until the result is received by
the on_connection_event() signal handler. This always seems to indicate
failure on Maemo Bora, but maybe it works properly in later versions.
It is OK for this to block because the Maemo connection dialog is totally
modal anyway, and because most applications will not be able to do anything
sensible while waiting, because the user is already waiting for an operation
that he has initiated.

        • libtinymail/tny-folder.c: (tny_folder_get_all_count): Warn when this

is not implemented. Maybe not very necessary, but I seem to have had this
in my local checkout and maybe things crash without the check. Can be removed
later if you like.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r2064 r2067  
     12007-05-31  Murray Cumming  <murrayc@murrayc.com> 
     2 
     3        * libtinymail-maemo/tny-maemo-conic-device.c: 
     4        (tny_maemo_conic_device_connect): Block until the result is received by   
     5        the on_connection_event() signal handler. This always seems to indicate  
     6        failure on Maemo Bora, but maybe it works properly in later versions. 
     7        It is OK for this to block because the Maemo connection dialog is totally  
     8        modal anyway, and because most applications will not be able to do anything  
     9        sensible while waiting, because the user is already waiting for an operation  
     10        that he has initiated. 
     11 
     12        * libtinymail/tny-folder.c: (tny_folder_get_all_count): Warn when this  
     13        is not implemented. Maybe not very necessary, but I seem to have had this  
     14        in my local checkout and maybe things crash without the check. Can be removed  
     15        later if you like. 
     16 
    1172007-05-29  Philip Van Hoof  <pvanhoof@gnome.org> 
    218 
  • trunk/libtinymail-maemo/tny-maemo-conic-device.c

    r2061 r2067  
    5454        gboolean        forced; /* Whether the is_online value is forced rather than real. */ 
    5555         
     56        /* When TRUE, we are waiting for the success or failure signal. */ 
     57        gboolean attempting_connection; 
     58         
    5659#ifdef MAEMO_CONIC_DUMMY         
    5760        gint dummy_env_check_timeout; 
     
    117120                priv->iap = g_strdup (con_ic_event_get_iap_id ((ConIcEvent*)(event))); 
    118121                is_online = TRUE; 
     122                 
     123                /* Set this to FALSE to stop blocking  
     124                 * tny_maemo_conic_device_connect(): */ 
     125                if (priv->attempting_connection) 
     126                        priv->attempting_connection = FALSE; 
     127                         
    119128                g_message ("new status: CONNECTED (%s)", priv->iap); 
    120129                break; 
     
    122131                priv->iap = NULL; 
    123132                is_online = FALSE; 
     133                 
     134                /* Set this to FALSE to stop blocking  
     135                 * tny_maemo_conic_device_connect(): */ 
     136                if (priv->attempting_connection) 
     137                        priv->attempting_connection = FALSE; 
     138                         
    124139                g_message ("new status: DISCONNECTED", priv->iap); 
    125140                break; 
     
    134149        priv->is_online = is_online; 
    135150        priv->forced = FALSE; /* is_online is now accurate. */ 
    136         g_message ("emitting signa CONNECTION_CHANGED: %s", is_online ? "online" : "offline"); 
     151        g_message ("emitting signal CONNECTION_CHANGED: %s", is_online ? "online" : "offline"); 
    137152        g_signal_emit (device, tny_device_signals [TNY_DEVICE_CONNECTION_CHANGED], 
    138153                       0, is_online); 
     
    146161 * @iap_id: the id of the Internet Access Point (IAP), or NULL for 'any; 
    147162 *  
    148  * try to connect to a specific IAP, or to any if @iap_id == NULL 
    149  * this calls con_ic_connection_connect(_by_id) 
    150  *  
    151  * Returns TRUE if sending the command worked, FALSE otherwise 
     163 * Try to connect to a specific IAP, or to any if @iap_id == NULL 
     164 * this calls con_ic_connection_connect(_by_id). 
     165 * This may show a dialog to allow the user to select a connection, or  
     166 * may otherwise take a significant amount of time. This function blocks until  
     167 * the connection has either succeeded or failed. 
     168 *  
     169 * Returns TRUE if a connection was made, FALSE otherwise. 
    152170 **/ 
    153171gboolean 
     
    165183         
    166184        if (iap_id) { 
     185                priv->attempting_connection = TRUE; 
     186                 
    167187                if (!con_ic_connection_connect_by_id (priv->cnx, iap_id, CON_IC_CONNECT_FLAG_NONE)) { 
    168188                        g_warning ("could not send connect_by_id dbus message"); 
    169189                        return FALSE; 
    170190                } 
    171         } else 
     191        } else { 
     192                priv->attempting_connection = TRUE; 
     193                 
    172194                if (!con_ic_connection_connect (priv->cnx, CON_IC_CONNECT_FLAG_NONE)) { 
    173195                        g_warning ("could not send connect dbus message"); 
    174196                        return FALSE; 
    175197                } 
    176          
    177         return TRUE; 
     198        } 
     199         
     200        /* Wait for the CON_IC_STATUS_CONNECTED (succeeded) or  
     201         * CON_IC_STATUS_DISCONNECTED event: */ 
     202          
     203        /* When the signal has been handled,  
     204         * attempting_connection will be reset to FALSE. */ 
     205        while (priv->attempting_connection) { 
     206                /* Iterate the main loop so that the signal can be called. */ 
     207                if (g_main_context_pending (NULL)) { 
     208                        g_main_context_iteration (NULL, FALSE); 
     209                } 
     210        } 
     211         
     212        return priv->is_online; 
    178213} 
    179214 
  • trunk/libtinymail/tny-folder.c

    r2030 r2067  
    813813#endif 
    814814 
     815        if (TNY_FOLDER_GET_IFACE (self)->get_all_count_func == NULL) { 
     816                g_warning ("get_all_count_func() not implemented in %s", G_OBJECT_TYPE_NAME(self)); 
     817        } 
     818 
    815819        return TNY_FOLDER_GET_IFACE (self)->get_all_count_func (self); 
    816820}