Changeset a830512 for protocols/msn
- Timestamp:
- 2008-08-10T09:15:26Z (16 years ago)
- Branches:
- master
- Children:
- 3b32017, 87f525e
- Parents:
- 4230221
- Location:
- protocols/msn
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/msn.c
r4230221 ra830512 113 113 { 114 114 struct msn_switchboard *sb; 115 struct msn_data *md = ic->proto_data;116 115 117 116 if( ( sb = msn_sb_by_handle( ic, who ) ) ) … … 122 121 { 123 122 struct msn_message *m; 124 char buf[1024];125 123 126 124 /* Create a message. We have to arrange a usable switchboard, and send the message later. */ … … 129 127 m->text = g_strdup( message ); 130 128 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 ); 129 return msn_sb_write_msg( ic, m ); 165 130 } 166 131 … … 252 217 { 253 218 struct msn_switchboard *sb; 254 struct msn_data *md = ic->proto_data;255 char buf[1024];256 219 257 220 if( ( sb = msn_sb_by_handle( ic, who ) ) ) … … 263 226 { 264 227 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 );281 228 282 229 /* Create a magic message. This is quite hackish, but who cares? :-P */ … … 285 232 m->text = g_strdup( GROUPCHAT_SWITCHBOARD_MESSAGE ); 286 233 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? */ 234 msn_sb_write_msg( ic, m ); 235 291 236 return NULL; 292 237 } -
protocols/msn/msn.h
r4230221 ra830512 23 23 Suite 330, Boston, MA 02111-1307 USA 24 24 */ 25 26 #ifndef _MSN_H 27 #define _MSN_H 25 28 26 29 /* Some hackish magicstrings to make special-purpose messages/switchboards. … … 176 179 void msn_sb_destroy( struct msn_switchboard *sb ); 177 180 gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond ); 181 int msn_sb_write_msg( struct im_connection *ic, struct msn_message *m ); 182 183 #endif //_MSN_H -
protocols/msn/sb.c
r4230221 ra830512 44 44 return( 0 ); 45 45 } 46 47 return( 1 ); 48 } 49 50 int msn_sb_write_msg( struct im_connection *ic, struct msn_message *m ) 51 { 52 struct msn_data *md = ic->proto_data; 53 struct msn_switchboard *sb; 54 char buf[1024]; 55 56 /* FIXME: *CHECK* the reliability of using spare sb's! */ 57 if( ( sb = msn_sb_spare( ic ) ) ) 58 { 59 debug( "Trying to use a spare switchboard to message %s", m->who ); 60 61 sb->who = g_strdup( m->who ); 62 g_snprintf( buf, sizeof( buf ), "CAL %d %s\r\n", ++sb->trId, m->who ); 63 if( msn_sb_write( sb, buf, strlen( buf ) ) ) 64 { 65 /* He/She should join the switchboard soon, let's queue the message. */ 66 sb->msgq = g_slist_append( sb->msgq, m ); 67 return( 1 ); 68 } 69 } 70 71 debug( "Creating a new switchboard to message %s", m->who ); 72 73 /* If we reach this line, there was no spare switchboard, so let's make one. */ 74 g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId ); 75 if( !msn_write( ic, buf, strlen( buf ) ) ) 76 { 77 g_free( m->who ); 78 g_free( m->text ); 79 g_free( m ); 80 81 return( 0 ); 82 } 83 84 /* And queue the message to md. We'll pick it up when the switchboard comes up. */ 85 md->msgq = g_slist_append( md->msgq, m ); 86 87 /* FIXME: If the switchboard creation fails, the message will not be sent. */ 46 88 47 89 return( 1 );
Note: See TracChangeset
for help on using the changeset viewer.