Changes in protocols/msn/msn.c [5ebff60:3058c30]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/msn.c
r5ebff60 r3058c30 30 30 int msn_chat_id; 31 31 GSList *msn_connections; 32 GSList *msn_switchboards;33 32 34 33 static char *set_eval_display_name(set_t *set, char *value); … … 41 40 s->flags |= SET_NOSAVE | ACC_SET_ONLINE_ONLY; 42 41 43 s = set_add(&acc->set, "server", MSN_NS_HOST, set_eval_account, acc);42 s = set_add(&acc->set, "server", NULL, set_eval_account, acc); 44 43 s->flags |= SET_NOSAVE | ACC_SET_OFFLINE_ONLY; 45 44 … … 48 47 49 48 set_add(&acc->set, "mail_notifications", "false", set_eval_bool, acc); 50 set_add(&acc->set, "switchboard_keepalives", "false", set_eval_bool, acc);51 49 52 50 acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE | … … 58 56 struct im_connection *ic = imcb_new(acc); 59 57 struct msn_data *md = g_new0(struct msn_data, 1); 58 char *server = set_getstr(&ic->acc->set, "server"); 60 59 61 60 ic->proto_data = md; 62 61 ic->flags |= OPT_PONGS | OPT_PONGED; 62 63 if (!server) { 64 server = "geo.gateway.messenger.live.com"; 65 } 63 66 64 67 if (strchr(acc->user, '@') == NULL) { … … 71 74 md->away_state = msn_away_state_list; 72 75 md->domaintree = g_tree_new(msn_domaintree_cmp); 73 md->ns->fd = -1; 76 md->fd = -1; 77 md->is_http = TRUE; 74 78 75 79 msn_connections = g_slist_prepend(msn_connections, ic); 76 80 77 81 imcb_log(ic, "Connecting"); 78 msn_ns_connect(ic, md->ns, 79 set_getstr(&ic->acc->set, "server"), 82 msn_ns_connect(ic, server, 80 83 set_getint(&ic->acc->set, "port")); 81 84 } … … 88 91 89 92 if (md) { 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); 93 msn_ns_close(md); 94 103 95 msn_soapq_flush(ic, FALSE); 104 96 … … 112 104 while (md->groups) { 113 105 struct msn_group *mg = md->groups->data; 106 md->groups = g_slist_remove(md->groups, mg); 114 107 g_free(mg->id); 115 108 g_free(mg->name); 116 109 g_free(mg); 117 md->groups = g_slist_remove(md->groups, mg);118 110 } 119 111 … … 127 119 while (md->grpq) { 128 120 struct msn_groupadd *ga = md->grpq->data; 121 md->grpq = g_slist_remove(md->grpq, ga); 129 122 g_free(ga->group); 130 123 g_free(ga->who); 131 124 g_free(ga); 132 md->grpq = g_slist_remove(md->grpq, ga);133 125 } 134 126 … … 152 144 { 153 145 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;156 146 157 147 #ifdef DEBUG 158 148 if (strcmp(who, "raw") == 0) { 159 149 msn_ns_write(ic, -1, "%s\r\n", message); 160 } else 150 return 0; 151 } 161 152 #endif 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 153 154 msn_ns_sendmessage(ic, bu, message); 177 155 return(0); 178 156 } … … 196 174 static void msn_set_away(struct im_connection *ic, char *state, char *message) 197 175 { 198 char *uux;199 176 struct msn_data *md = ic->proto_data; 177 char *nick, *psm, *idle, *statecode, *body, *buf; 200 178 201 179 if (state == NULL) { … … 205 183 } 206 184 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); 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); 233 202 } 234 203 … … 256 225 static void msn_chat_msg(struct groupchat *c, char *message, int flags) 257 226 { 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! */ 227 /* TODO: groupchats*/ 265 228 } 266 229 267 230 static void msn_chat_invite(struct groupchat *c, char *who, char *message) 268 231 { 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 } 232 /* TODO: groupchats*/ 274 233 } 275 234 276 235 static void msn_chat_leave(struct groupchat *c) 277 236 { 278 struct msn_switchboard *sb = msn_sb_by_chat(c); 279 280 if (sb) { 281 msn_sb_write(sb, "OUT\r\n"); 282 } 237 /* TODO: groupchats*/ 283 238 } 284 239 285 240 static struct groupchat *msn_chat_with(struct im_connection *ic, char *who) 286 241 { 287 struct msn_switchboard *sb;242 /* TODO: groupchats*/ 288 243 struct groupchat *c = imcb_chat_new(ic, who); 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 } 244 return c; 305 245 } 306 246 … … 322 262 static void msn_add_deny(struct im_connection *ic, char *who) 323 263 { 324 struct msn_switchboard *sb;325 326 264 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 }332 265 } 333 266 … … 462 395 ret->buddy_action = msn_buddy_action; 463 396 464 //ret->transfer_request = msn_ftp_transfer_request;465 466 397 register_protocol(ret); 467 398 }
Note: See TracChangeset
for help on using the changeset viewer.