Changes in protocols/msn/msn.c [3058c30:5ebff60]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/msn.c
r3058c30 r5ebff60 30 30 int msn_chat_id; 31 31 GSList *msn_connections; 32 GSList *msn_switchboards; 32 33 33 34 static char *set_eval_display_name(set_t *set, char *value); … … 40 41 s->flags |= SET_NOSAVE | ACC_SET_ONLINE_ONLY; 41 42 42 s = set_add(&acc->set, "server", NULL, set_eval_account, acc);43 s = set_add(&acc->set, "server", MSN_NS_HOST, set_eval_account, acc); 43 44 s->flags |= SET_NOSAVE | ACC_SET_OFFLINE_ONLY; 44 45 … … 47 48 48 49 set_add(&acc->set, "mail_notifications", "false", set_eval_bool, acc); 50 set_add(&acc->set, "switchboard_keepalives", "false", set_eval_bool, acc); 49 51 50 52 acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE | … … 56 58 struct im_connection *ic = imcb_new(acc); 57 59 struct msn_data *md = g_new0(struct msn_data, 1); 58 char *server = set_getstr(&ic->acc->set, "server");59 60 60 61 ic->proto_data = md; 61 62 ic->flags |= OPT_PONGS | OPT_PONGED; 62 63 if (!server) {64 server = "geo.gateway.messenger.live.com";65 }66 63 67 64 if (strchr(acc->user, '@') == NULL) { … … 74 71 md->away_state = msn_away_state_list; 75 72 md->domaintree = g_tree_new(msn_domaintree_cmp); 76 md->fd = -1; 77 md->is_http = TRUE; 73 md->ns->fd = -1; 78 74 79 75 msn_connections = g_slist_prepend(msn_connections, ic); 80 76 81 77 imcb_log(ic, "Connecting"); 82 msn_ns_connect(ic, server, 78 msn_ns_connect(ic, md->ns, 79 set_getstr(&ic->acc->set, "server"), 83 80 set_getint(&ic->acc->set, "port")); 84 81 } … … 91 88 92 89 if (md) { 93 msn_ns_close(md); 94 90 /** Disabling MSN ft support for now. 91 while( md->filetransfers ) { 92 imcb_file_canceled( md->filetransfers->data, "Closing connection" ); 93 } 94 */ 95 96 msn_ns_close(md->ns); 97 98 while (md->switchboards) { 99 msn_sb_destroy(md->switchboards->data); 100 } 101 102 msn_msgq_purge(ic, &md->msgq); 95 103 msn_soapq_flush(ic, FALSE); 96 104 … … 104 112 while (md->groups) { 105 113 struct msn_group *mg = md->groups->data; 106 md->groups = g_slist_remove(md->groups, mg);107 114 g_free(mg->id); 108 115 g_free(mg->name); 109 116 g_free(mg); 117 md->groups = g_slist_remove(md->groups, mg); 110 118 } 111 119 … … 119 127 while (md->grpq) { 120 128 struct msn_groupadd *ga = md->grpq->data; 121 md->grpq = g_slist_remove(md->grpq, ga);122 129 g_free(ga->group); 123 130 g_free(ga->who); 124 131 g_free(ga); 132 md->grpq = g_slist_remove(md->grpq, ga); 125 133 } 126 134 … … 144 152 { 145 153 struct bee_user *bu = bee_user_by_handle(ic->bee, ic, who); 154 struct msn_buddy_data *bd = bu ? bu->data : NULL; 155 struct msn_switchboard *sb; 146 156 147 157 #ifdef DEBUG 148 158 if (strcmp(who, "raw") == 0) { 149 159 msn_ns_write(ic, -1, "%s\r\n", message); 150 return 0; 151 } 160 } else 152 161 #endif 153 154 msn_ns_sendmessage(ic, bu, message); 162 if (bd && bd->flags & MSN_BUDDY_FED) { 163 msn_ns_sendmessage(ic, bu, message); 164 } else if ((sb = msn_sb_by_handle(ic, who))) { 165 return(msn_sb_sendmessage(sb, message)); 166 } else { 167 struct msn_message *m; 168 169 /* Create a message. We have to arrange a usable switchboard, and send the message later. */ 170 m = g_new0(struct msn_message, 1); 171 m->who = g_strdup(who); 172 m->text = g_strdup(message); 173 174 return msn_sb_write_msg(ic, m); 175 } 176 155 177 return(0); 156 178 } … … 174 196 static void msn_set_away(struct im_connection *ic, char *state, char *message) 175 197 { 198 char *uux; 176 199 struct msn_data *md = ic->proto_data; 177 char *nick, *psm, *idle, *statecode, *body, *buf;178 200 179 201 if (state == NULL) { … … 183 205 } 184 206 185 statecode = (char *) md->away_state->code; 186 nick = set_getstr(&ic->acc->set, "display_name"); 187 psm = message ? message : ""; 188 idle = (strcmp(statecode, "IDL") == 0) ? "false" : "true"; 189 190 body = g_markup_printf_escaped(MSN_PUT_USER_BODY, 191 nick, psm, psm, md->uuid, statecode, md->uuid, idle, statecode, 192 MSN_CAP1, MSN_CAP2, MSN_CAP1, MSN_CAP2 193 ); 194 195 buf = g_strdup_printf(MSN_PUT_HEADERS, ic->acc->user, ic->acc->user, md->uuid, 196 "/user", "application/user+xml", 197 strlen(body), body); 198 msn_ns_write(ic, -1, "PUT %d %zd\r\n%s", ++md->trId, strlen(buf), buf); 199 200 g_free(buf); 201 g_free(body); 207 if (!msn_ns_write(ic, -1, "CHG %d %s %d:%02d\r\n", ++md->trId, md->away_state->code, MSN_CAP1, MSN_CAP2)) { 208 return; 209 } 210 211 uux = g_markup_printf_escaped("<EndpointData><Capabilities>%d:%02d" 212 "</Capabilities></EndpointData>", 213 MSN_CAP1, MSN_CAP2); 214 msn_ns_write(ic, -1, "UUX %d %zd\r\n%s", ++md->trId, strlen(uux), uux); 215 g_free(uux); 216 217 uux = g_markup_printf_escaped("<PrivateEndpointData><EpName>%s</EpName>" 218 "<Idle>%s</Idle><ClientType>%d</ClientType>" 219 "<State>%s</State></PrivateEndpointData>", 220 md->uuid, 221 strcmp(md->away_state->code, "IDL") ? "false" : "true", 222 1, /* ? */ 223 md->away_state->code); 224 msn_ns_write(ic, -1, "UUX %d %zd\r\n%s", ++md->trId, strlen(uux), uux); 225 g_free(uux); 226 227 uux = g_markup_printf_escaped("<Data><DDP></DDP><PSM>%s</PSM>" 228 "<CurrentMedia></CurrentMedia>" 229 "<MachineGuid>%s</MachineGuid></Data>", 230 message ? message : "", md->uuid); 231 msn_ns_write(ic, -1, "UUX %d %zd\r\n%s", ++md->trId, strlen(uux), uux); 232 g_free(uux); 202 233 } 203 234 … … 225 256 static void msn_chat_msg(struct groupchat *c, char *message, int flags) 226 257 { 227 /* TODO: groupchats*/ 258 struct msn_switchboard *sb = msn_sb_by_chat(c); 259 260 if (sb) { 261 msn_sb_sendmessage(sb, message); 262 } 263 /* FIXME: Error handling (although this can't happen unless something's 264 already severely broken) disappeared here! */ 228 265 } 229 266 230 267 static void msn_chat_invite(struct groupchat *c, char *who, char *message) 231 268 { 232 /* TODO: groupchats*/ 269 struct msn_switchboard *sb = msn_sb_by_chat(c); 270 271 if (sb) { 272 msn_sb_write(sb, "CAL %d %s\r\n", ++sb->trId, who); 273 } 233 274 } 234 275 235 276 static void msn_chat_leave(struct groupchat *c) 236 277 { 237 /* TODO: groupchats*/ 278 struct msn_switchboard *sb = msn_sb_by_chat(c); 279 280 if (sb) { 281 msn_sb_write(sb, "OUT\r\n"); 282 } 238 283 } 239 284 240 285 static struct groupchat *msn_chat_with(struct im_connection *ic, char *who) 241 286 { 242 /* TODO: groupchats*/287 struct msn_switchboard *sb; 243 288 struct groupchat *c = imcb_chat_new(ic, who); 244 return c; 289 290 if ((sb = msn_sb_by_handle(ic, who))) { 291 debug("Converting existing switchboard to %s to a groupchat", who); 292 return msn_sb_to_chat(sb); 293 } else { 294 struct msn_message *m; 295 296 /* Create a magic message. This is quite hackish, but who cares? :-P */ 297 m = g_new0(struct msn_message, 1); 298 m->who = g_strdup(who); 299 m->text = g_strdup(GROUPCHAT_SWITCHBOARD_MESSAGE); 300 301 msn_sb_write_msg(ic, m); 302 303 return c; 304 } 245 305 } 246 306 … … 262 322 static void msn_add_deny(struct im_connection *ic, char *who) 263 323 { 324 struct msn_switchboard *sb; 325 264 326 msn_buddy_list_add(ic, MSN_BUDDY_BL, who, who, NULL); 327 328 /* If there's still a conversation with this person, close it. */ 329 if ((sb = msn_sb_by_handle(ic, who))) { 330 msn_sb_destroy(sb); 331 } 265 332 } 266 333 … … 395 462 ret->buddy_action = msn_buddy_action; 396 463 464 //ret->transfer_request = msn_ftp_transfer_request; 465 397 466 register_protocol(ret); 398 467 }
Note: See TracChangeset
for help on using the changeset viewer.