void prplcb_conv_new(PurpleConversation *conv) { if (conv->type == PURPLE_CONV_TYPE_CHAT) { struct im_connection *ic = purple_ic_by_pa(conv->account); struct groupchat *gc; gc = bee_chat_by_title(ic->bee, ic, conv->name); if (!gc) { gc = imcb_chat_new(ic, conv->name); if (conv->title != NULL) { imcb_chat_name_hint(gc, conv->title); } } /* don't set the topic if it's just the name */ if (conv->title != NULL && strcmp(conv->name, conv->title) != 0) { imcb_chat_topic(gc, NULL, conv->title, 0); } conv->ui_data = gc; gc->data = conv; /* libpurple brokenness: Whatever. Show that we join right away, there's no clear "This is you!" signaling in _add_users so don't even try. */ imcb_chat_add_buddy(gc, gc->ic->acc->user); } }
static void skype_parse_chatmessage(struct im_connection *ic, char *line) { struct skype_data *sd = ic->proto_data; char *id = strchr(line, ' '); if (!++id) return; char *info = strchr(id, ' '); if (!info) return; *info = '\0'; info++; if (!strcmp(info, "STATUS RECEIVED") || !strncmp(info, "EDITED_TIMESTAMP", 16)) { /* New message ID: * (1) Request its from field * (2) Request its body * (3) Request its type * (4) Query chatname */ skype_printf(ic, "GET CHATMESSAGE %s FROM_HANDLE\n", id); if (!strcmp(info, "STATUS RECEIVED")) skype_printf(ic, "GET CHATMESSAGE %s BODY\n", id); else sd->is_edit = 1; skype_printf(ic, "GET CHATMESSAGE %s TYPE\n", id); skype_printf(ic, "GET CHATMESSAGE %s CHATNAME\n", id); } else if (!strncmp(info, "FROM_HANDLE ", 12)) { info += 12; /* New from field value. Store * it, then we can later use it * when we got the message's * body. */ g_free(sd->handle); sd->handle = g_strdup_printf("*****@*****.**", info); } else if (!strncmp(info, "EDITED_BY ", 10)) { info += 10; /* This is the same as * FROM_HANDLE, except that we * never request these lines * from Skype, we just get * them. */ g_free(sd->handle); sd->handle = g_strdup_printf("*****@*****.**", info); } else if (!strncmp(info, "BODY ", 5)) { info += 5; sd->body = g_list_append(sd->body, g_strdup(info)); } else if (!strncmp(info, "TYPE ", 5)) { info += 5; g_free(sd->type); sd->type = g_strdup(info); } else if (!strncmp(info, "CHATNAME ", 9)) { info += 9; if (sd->handle && sd->body && sd->type) { struct groupchat *gc = bee_chat_by_title(ic->bee, ic, info); int i; for (i = 0; i < g_list_length(sd->body); i++) { char *body = g_list_nth_data(sd->body, i); if (!strcmp(sd->type, "SAID") || !strcmp(sd->type, "EMOTED")) { skype_parse_chatmessage_said_emoted(ic, gc, body); } else if (!strcmp(sd->type, "SETTOPIC") && gc) imcb_chat_topic(gc, sd->handle, body, 0); else if (!strcmp(sd->type, "LEFT") && gc) imcb_chat_remove_buddy(gc, sd->handle, NULL); } g_list_free(sd->body); sd->body = NULL; } } }