Beispiel #1
0
void linphone_core_message_received(LinphoneCore *lc, const char *from, const char *raw_msg,const char* external_url) {
    MSList *elem;
    LinphoneChatRoom *cr=NULL;
    LinphoneAddress *addr;
    char *cleanfrom;
    LinphoneChatMessage* msg;
    addr=linphone_address_new(from);
    linphone_address_clean(addr);
    for(elem=lc->chatrooms; elem!=NULL; elem=ms_list_next(elem)) {
        cr=(LinphoneChatRoom*)elem->data;
        if (linphone_chat_room_matches(cr,addr)) {
            break;
        }
        cr=NULL;
    }
    cleanfrom=linphone_address_as_string(addr);
    if (cr==NULL) {
        /* create a new chat room */
        cr=linphone_core_create_chat_room(lc,cleanfrom);
    }
    msg = linphone_chat_room_create_message(cr, raw_msg);
    linphone_chat_message_set_from(msg, cr->peer_url);
    if (external_url) {
        linphone_chat_message_set_external_body_url(msg, external_url);
    }
    linphone_address_destroy(addr);
    linphone_chat_room_message_received(cr,lc,msg);
    ms_free(cleanfrom);
}
Beispiel #2
0
/**
 * Retrieve an existing chat room whose peer is the supplied address, if exists.
 * @param lc the linphone core
 * @param add a linphone address.
 * @returns the matching chatroom, or NULL if no such chatroom exists.
**/
LinphoneChatRoom *linphone_core_get_chat_room(LinphoneCore *lc, const LinphoneAddress *addr){
	LinphoneChatRoom *cr=NULL;
	MSList *elem;
	for(elem=lc->chatrooms;elem!=NULL;elem=ms_list_next(elem)){
		cr=(LinphoneChatRoom*)elem->data;
		if (linphone_chat_room_matches(cr,addr)){
			break;
		}
		cr=NULL;
	}
	return cr;
}