Ignore:
Timestamp:
2010-06-11T11:34:39Z (13 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
1c8e5f7
Parents:
5266354
Message:

Create new MSN groups when necessary.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/msn_util.c

    r5266354 r70ac477  
    5555        struct msn_data *md = ic->proto_data;
    5656        char buf[1024], *realname, groupid[8];
    57        
    58         realname = msn_http_encode( realname_ );
    5957       
    6058        *groupid = '\0';
     
    6866                                break;
    6967                        }
    70         }
    71        
     68               
     69                if( *groupid == '\0' )
     70                {
     71                        /* Have to create this group, it doesn't exist yet. */
     72                        struct msn_groupadd *ga;
     73                        GSList *l;
     74                       
     75                        for( l = md->grpq; l; l = l->next )
     76                        {
     77                                ga = l->data;
     78                                if( g_strcasecmp( ga->group, group ) == 0 )
     79                                        break;
     80                        }
     81                       
     82                        ga = g_new0( struct msn_groupadd, 1 );
     83                        ga->who = g_strdup( who );
     84                        ga->group = g_strdup( group );
     85                        md->grpq = g_slist_prepend( md->grpq, ga );
     86                       
     87                        if( l == NULL )
     88                        {
     89                                char *groupname = msn_http_encode( group );
     90                                g_snprintf( buf, sizeof( buf ), "ADG %d %s %d\r\n", ++md->trId, groupname, 0 );
     91                                g_free( groupname );
     92                                return msn_write( ic, buf, strlen( buf ) );
     93                        }
     94                        else
     95                        {
     96                                /* This can happen if the user's doing lots of adds to a
     97                                   new group at once; we're still waiting for the server
     98                                   to confirm group creation. */
     99                                return 1;
     100                        }
     101                }
     102        }
     103       
     104        realname = msn_http_encode( realname_ );
    72105        g_snprintf( buf, sizeof( buf ), "ADD %d %s %s %s%s\r\n", ++md->trId, list, who, realname, groupid );
    73         if( msn_write( ic, buf, strlen( buf ) ) )
    74         {
    75                 g_free( realname );
    76                
    77                 return( 1 );
    78         }
    79        
    80106        g_free( realname );
    81107       
    82         return( 0 );
     108        return msn_write( ic, buf, strlen( buf ) );
    83109}
    84110
Note: See TracChangeset for help on using the changeset viewer.