Changeset be609ff for protocols/nogaim.c


Ignore:
Timestamp:
2010-03-12T19:10:16Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
dde9d571
Parents:
08e5bb2 (diff), 8b6b740 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merging mainline.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/nogaim.c

    r08e5bb2 rbe609ff  
    22  * BitlBee -- An IRC to other IM-networks gateway                     *
    33  *                                                                    *
    4   * Copyright 2002-2006 Wilmer van der Gaast and others                *
     4  * Copyright 2002-2010 Wilmer van der Gaast and others                *
    55  \********************************************************************/
    66
     
    268268        ic->flags |= OPT_LOGGED_IN;
    269269       
    270         /* Also necessary when we're not away, at least for some of the
    271            protocols. */
    272         imc_set_away( ic, u->away );
     270        /* Necessary to send initial presence status, even if we're not away. */
     271        imc_away_send_update( ic );
    273272       
    274273        /* Apparently we're connected successfully, so reset the
     
    10701069}
    10711070
    1072 static char *imc_away_alias_find( GList *gcm, char *away );
    1073 
    1074 int imc_set_away( struct im_connection *ic, char *away )
    1075 {
    1076         GList *m, *ms;
    1077         char *s;
    1078        
    1079         if( !away ) away = "";
    1080         ms = m = ic->acc->prpl->away_states( ic );
    1081        
    1082         while( m )
    1083         {
    1084                 if( *away )
    1085                 {
    1086                         if( g_strncasecmp( m->data, away, strlen( m->data ) ) == 0 )
    1087                                 break;
    1088                 }
    1089                 else
    1090                 {
    1091                         if( g_strcasecmp( m->data, "Available" ) == 0 )
    1092                                 break;
    1093                         if( g_strcasecmp( m->data, "Online" ) == 0 )
    1094                                 break;
    1095                 }
    1096                 m = m->next;
    1097         }
    1098        
    1099         if( m )
    1100         {
    1101                 ic->acc->prpl->set_away( ic, m->data, *away ? away : NULL );
    1102         }
    1103         else
    1104         {
    1105                 s = imc_away_alias_find( ms, away );
    1106                 if( s )
    1107                 {
    1108                         ic->acc->prpl->set_away( ic, s, away );
    1109                         if( set_getbool( &ic->irc->set, "debug" ) )
    1110                                 imcb_log( ic, "Setting away state to %s", s );
    1111                 }
    1112                 else
    1113                         ic->acc->prpl->set_away( ic, GAIM_AWAY_CUSTOM, away );
    1114         }
    1115        
    1116         return( 1 );
     1071static char *imc_away_state_find( GList *gcm, char *away, char **message );
     1072
     1073int imc_away_send_update( struct im_connection *ic )
     1074{
     1075        char *away, *msg = NULL;
     1076       
     1077        away = set_getstr( &ic->acc->set, "away" ) ?
     1078             : set_getstr( &ic->irc->set, "away" );
     1079        if( away && *away )
     1080        {
     1081                GList *m = ic->acc->prpl->away_states( ic );
     1082                msg = ic->acc->flags & ACC_FLAG_AWAY_MESSAGE ? away : NULL;
     1083                away = imc_away_state_find( m, away, &msg ) ? : m->data;
     1084        }
     1085        else if( ic->acc->flags & ACC_FLAG_STATUS_MESSAGE )
     1086        {
     1087                away = NULL;
     1088                msg = set_getstr( &ic->acc->set, "status" ) ?
     1089                    : set_getstr( &ic->irc->set, "status" );
     1090        }
     1091       
     1092        ic->acc->prpl->set_away( ic, away, msg );
     1093       
     1094        return 1;
    11171095}
    11181096
     
    11291107};
    11301108
    1131 static char *imc_away_alias_find( GList *gcm, char *away )
     1109static char *imc_away_state_find( GList *gcm, char *away, char **message )
    11321110{
    11331111        GList *m;
    11341112        int i, j;
    11351113       
     1114        for( m = gcm; m; m = m->next )
     1115                if( g_strncasecmp( m->data, away, strlen( m->data ) ) == 0 )
     1116                {
     1117                        /* At least the Yahoo! module works better if message
     1118                           contains no data unless it adds something to what
     1119                           we have in state already. */
     1120                        if( strlen( m->data ) == strlen( away ) )
     1121                                *message = NULL;
     1122                       
     1123                        return m->data;
     1124                }
     1125       
    11361126        for( i = 0; *imc_away_alias_list[i]; i ++ )
    11371127        {
     1128                int keep_message;
     1129               
    11381130                for( j = 0; imc_away_alias_list[i][j]; j ++ )
    11391131                        if( g_strncasecmp( away, imc_away_alias_list[i][j], strlen( imc_away_alias_list[i][j] ) ) == 0 )
     1132                        {
     1133                                keep_message = strlen( away ) != strlen( imc_away_alias_list[i][j] );
    11401134                                break;
     1135                        }
    11411136               
    11421137                if( !imc_away_alias_list[i][j] )        /* If we reach the end, this row */
     
    11461141                for( j = 0; imc_away_alias_list[i][j]; j ++ )
    11471142                {
    1148                         m = gcm;
    1149                         while( m )
    1150                         {
     1143                        for( m = gcm; m; m = m->next )
    11511144                                if( g_strcasecmp( imc_away_alias_list[i][j], m->data ) == 0 )
    1152                                         return( imc_away_alias_list[i][j] );
    1153                                 m = m->next;
    1154                         }
    1155                 }
    1156         }
    1157        
    1158         return( NULL );
     1145                                {
     1146                                        if( !keep_message )
     1147                                                *message = NULL;
     1148                                       
     1149                                        return imc_away_alias_list[i][j];
     1150                                }
     1151                }
     1152               
     1153                /* No need to look further, apparently this state doesn't
     1154                   have any good alias for this protocol. */
     1155                break;
     1156        }
     1157       
     1158        return NULL;
    11591159}
    11601160
Note: See TracChangeset for help on using the changeset viewer.