comparison libpurple/protocols/mxit/multimx.c @ 32819:2c6510167895 default tip

propagate from branch 'im.pidgin.pidgin.2.x.y' (head 3315c5dfbd0ad16511bdcf865e5b07c02d07df24) to branch 'im.pidgin.pidgin' (head cbd1eda6bcbf0565ae7766396bb8f6f419cb6a9a)
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sat, 02 Jun 2012 02:30:49 +0000
parents 4b15c5c68aa4
children
comparison
equal deleted inserted replaced
32818:01ff09d4a463 32819:2c6510167895
275 void multimx_invite(struct MXitSession* session, struct contact* contact, const char* creator) 275 void multimx_invite(struct MXitSession* session, struct contact* contact, const char* creator)
276 { 276 {
277 GHashTable *components; 277 GHashTable *components;
278 struct multimx* multimx = NULL; 278 struct multimx* multimx = NULL;
279 279
280 purple_debug_info(MXIT_PLUGIN_ID, "Groupchat invite to '%s' by '%s'\n", contact->alias, creator); 280 purple_debug_info(MXIT_PLUGIN_ID, "Groupchat invite to '%s' (roomid='%s') by '%s'\n", contact->alias, contact->username, creator);
281
282 /* Check if the room already exists (ie, already joined or invite pending) */
283 if (find_room_by_username(session, contact->username) != NULL)
284 return;
281 285
282 /* Create a new room */ 286 /* Create a new room */
283 multimx = room_create(session, contact->username, contact->alias, STATE_INVITED); 287 multimx = room_create(session, contact->username, contact->alias, STATE_INVITED);
284 288
285 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); 289 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
305 309
306 /* Find matching MultiMX group */ 310 /* Find matching MultiMX group */
307 multimx = find_room_by_username(session, contact->username); 311 multimx = find_room_by_username(session, contact->username);
308 if (multimx == NULL) { 312 if (multimx == NULL) {
309 multimx = room_create(session, contact->username, contact->alias, TRUE); 313 multimx = room_create(session, contact->username, contact->alias, TRUE);
310 } 314 }
311 else if (multimx->state == STATE_INVITED) { 315 else if (multimx->state == STATE_INVITED) {
312 /* After successfully accepting an invitation */ 316 /* After successfully accepting an invitation */
313 multimx->state = STATE_JOINED; 317 multimx->state = STATE_JOINED;
314 } 318 }
315 319
452 * @param gc The connection object 456 * @param gc The connection object
453 * @param components The list of chat configuration values 457 * @param components The list of chat configuration values
454 */ 458 */
455 void mxit_chat_join(PurpleConnection *gc, GHashTable *components) 459 void mxit_chat_join(PurpleConnection *gc, GHashTable *components)
456 { 460 {
457 struct MXitSession* session = (struct MXitSession*) gc->proto_data; 461 struct MXitSession* session = purple_connection_get_protocol_data(gc);
458 const char* roomname = NULL; 462 const char* roomname = NULL;
459 struct multimx* multimx = NULL; 463 struct multimx* multimx = NULL;
460 464
461 purple_debug_info(MXIT_PLUGIN_ID, "mxit_chat_join\n"); 465 purple_debug_info(MXIT_PLUGIN_ID, "mxit_chat_join\n");
462 466
494 * @param gc The connection object 498 * @param gc The connection object
495 * @param components The list of chat configuration values 499 * @param components The list of chat configuration values
496 */ 500 */
497 void mxit_chat_reject(PurpleConnection *gc, GHashTable* components) 501 void mxit_chat_reject(PurpleConnection *gc, GHashTable* components)
498 { 502 {
499 struct MXitSession* session = (struct MXitSession*) gc->proto_data; 503 struct MXitSession* session = purple_connection_get_protocol_data(gc);
500 const char* roomname = NULL; 504 const char* roomname = NULL;
501 struct multimx* multimx = NULL; 505 struct multimx* multimx = NULL;
502 506
503 purple_debug_info(MXIT_PLUGIN_ID, "mxit_chat_reject\n"); 507 purple_debug_info(MXIT_PLUGIN_ID, "mxit_chat_reject\n");
504 508
537 * @param msg The invitation message entered by the user 541 * @param msg The invitation message entered by the user
538 * @param name The username of the person to invite 542 * @param name The username of the person to invite
539 */ 543 */
540 void mxit_chat_invite(PurpleConnection *gc, int id, const char *msg, const char *username) 544 void mxit_chat_invite(PurpleConnection *gc, int id, const char *msg, const char *username)
541 { 545 {
542 struct MXitSession* session = (struct MXitSession*) gc->proto_data; 546 struct MXitSession* session = purple_connection_get_protocol_data(gc);
543 struct multimx* multimx = NULL; 547 struct multimx* multimx = NULL;
544 PurpleBuddy* buddy; 548 PurpleBuddy* buddy;
545 PurpleConversation *convo; 549 PurpleConversation *convo;
546 char* tmp; 550 char* tmp;
547 551
583 * @param gc The connection object 587 * @param gc The connection object
584 * @param id The chat room ID 588 * @param id The chat room ID
585 */ 589 */
586 void mxit_chat_leave(PurpleConnection *gc, int id) 590 void mxit_chat_leave(PurpleConnection *gc, int id)
587 { 591 {
588 struct MXitSession* session = (struct MXitSession*) gc->proto_data; 592 struct MXitSession* session = purple_connection_get_protocol_data(gc);
589 struct multimx* multimx = NULL; 593 struct multimx* multimx = NULL;
590 594
591 purple_debug_info(MXIT_PLUGIN_ID, "Groupchat %i leave\n", id); 595 purple_debug_info(MXIT_PLUGIN_ID, "Groupchat %i leave\n", id);
592 596
593 /* Find matching multimx group */ 597 /* Find matching multimx group */
614 * @param flags The message flags 618 * @param flags The message flags
615 * @return Indicates success / failure 619 * @return Indicates success / failure
616 */ 620 */
617 int mxit_chat_send(PurpleConnection *gc, int id, const char *message, PurpleMessageFlags flags) 621 int mxit_chat_send(PurpleConnection *gc, int id, const char *message, PurpleMessageFlags flags)
618 { 622 {
619 struct MXitSession* session = (struct MXitSession*) gc->proto_data; 623 struct MXitSession* session = purple_connection_get_protocol_data(gc);
620 struct multimx* multimx = NULL; 624 struct multimx* multimx = NULL;
621 const char* nickname; 625 const char* nickname;
622 626
623 purple_debug_info(MXIT_PLUGIN_ID, "Groupchat %i message send: '%s'\n", id, message); 627 purple_debug_info(MXIT_PLUGIN_ID, "Groupchat %i message send: '%s'\n", id, message);
624 628