Changes in protocols/msn/msn.c [a830512:46dca11]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/msn.c
ra830512 r46dca11 113 113 { 114 114 struct msn_switchboard *sb; 115 struct msn_data *md = ic->proto_data; 115 116 116 117 if( ( sb = msn_sb_by_handle( ic, who ) ) ) … … 121 122 { 122 123 struct msn_message *m; 124 char buf[1024]; 123 125 124 126 /* Create a message. We have to arrange a usable switchboard, and send the message later. */ … … 127 129 m->text = g_strdup( message ); 128 130 129 return msn_sb_write_msg( ic, m ); 131 /* FIXME: *CHECK* the reliability of using spare sb's! */ 132 if( ( sb = msn_sb_spare( ic ) ) ) 133 { 134 debug( "Trying to use a spare switchboard to message %s", who ); 135 136 sb->who = g_strdup( who ); 137 g_snprintf( buf, sizeof( buf ), "CAL %d %s\r\n", ++sb->trId, who ); 138 if( msn_sb_write( sb, buf, strlen( buf ) ) ) 139 { 140 /* He/She should join the switchboard soon, let's queue the message. */ 141 sb->msgq = g_slist_append( sb->msgq, m ); 142 return( 1 ); 143 } 144 } 145 146 debug( "Creating a new switchboard to message %s", who ); 147 148 /* If we reach this line, there was no spare switchboard, so let's make one. */ 149 g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId ); 150 if( !msn_write( ic, buf, strlen( buf ) ) ) 151 { 152 g_free( m->who ); 153 g_free( m->text ); 154 g_free( m ); 155 156 return( 0 ); 157 } 158 159 /* And queue the message to md. We'll pick it up when the switchboard comes up. */ 160 md->msgq = g_slist_append( md->msgq, m ); 161 162 /* FIXME: If the switchboard creation fails, the message will not be sent. */ 163 164 return( 1 ); 130 165 } 131 166 … … 217 252 { 218 253 struct msn_switchboard *sb; 254 struct msn_data *md = ic->proto_data; 255 char buf[1024]; 219 256 220 257 if( ( sb = msn_sb_by_handle( ic, who ) ) ) … … 226 263 { 227 264 struct msn_message *m; 265 266 if( ( sb = msn_sb_spare( ic ) ) ) 267 { 268 debug( "Trying to reuse an existing switchboard as a groupchat with %s", who ); 269 g_snprintf( buf, sizeof( buf ), "CAL %d %s\r\n", ++sb->trId, who ); 270 if( msn_sb_write( sb, buf, strlen( buf ) ) ) 271 return msn_sb_to_chat( sb ); 272 } 273 274 /* If the stuff above failed for some reason: */ 275 debug( "Creating a new switchboard to groupchat with %s", who ); 276 277 /* Request a new switchboard. */ 278 g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId ); 279 if( !msn_write( ic, buf, strlen( buf ) ) ) 280 return( 0 ); 228 281 229 282 /* Create a magic message. This is quite hackish, but who cares? :-P */ … … 232 285 m->text = g_strdup( GROUPCHAT_SWITCHBOARD_MESSAGE ); 233 286 234 msn_sb_write_msg( ic, m ); 235 287 /* Queue the magic message and cross your fingers. */ 288 md->msgq = g_slist_append( md->msgq, m ); 289 290 /* FIXME: Can I try to return something here already? */ 236 291 return NULL; 237 292 }
Note: See TracChangeset
for help on using the changeset viewer.