mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-20 12:38:09 +00:00
Merge branch 'master' of git.linphone.org:linphone
This commit is contained in:
commit
25852f630b
10 changed files with 344 additions and 57 deletions
|
|
@ -46,12 +46,35 @@ const char *multipart_boundary=MULTIPART_BOUNDARY;
|
|||
static size_t linphone_chat_message_compute_filepart_header_size(const char *filename, const char *content_type) {
|
||||
return strlen(FILEPART_HEADER_1)+strlen(filename)+strlen(FILEPART_HEADER_2)+strlen(content_type)+strlen(FILEPART_HEADER_3);
|
||||
}
|
||||
static void process_io_error(void *data, const belle_sip_io_error_event_t *event){
|
||||
|
||||
static void process_io_error_upload(void *data, const belle_sip_io_error_event_t *event){
|
||||
LinphoneChatMessage* msg=(LinphoneChatMessage *)data;
|
||||
msg->cb(msg, LinphoneChatMessageStateNotDelivered, msg->chat_room->lc);
|
||||
ms_error("I/O Error during file upload to %s - msg [%p] chat room[%p]", msg->chat_room->lc->file_transfer_server, msg, msg->chat_room);
|
||||
if (msg->cb) {
|
||||
msg->cb(msg, LinphoneChatMessageStateNotDelivered, msg->chat_room->lc);
|
||||
}
|
||||
}
|
||||
static void process_auth_requested(void *data, belle_sip_auth_event_t *event){
|
||||
printf("We have a auth requested!\n");
|
||||
static void process_auth_requested_upload(void *data, belle_sip_auth_event_t *event){
|
||||
LinphoneChatMessage* msg=(LinphoneChatMessage *)data;
|
||||
ms_error("Error during file upload : auth requested to connect %s - msg [%p] chat room[%p]", msg->chat_room->lc->file_transfer_server, msg, msg->chat_room);
|
||||
if (msg->cb) {
|
||||
msg->cb(msg, LinphoneChatMessageStateNotDelivered, msg->chat_room->lc);
|
||||
}
|
||||
}
|
||||
|
||||
static void process_io_error_download(void *data, const belle_sip_io_error_event_t *event){
|
||||
LinphoneChatMessage* msg=(LinphoneChatMessage *)data;
|
||||
ms_error("I/O Error during file download %s - msg [%p] chat room[%p]", msg->external_body_url, msg, msg->chat_room);
|
||||
if (msg->cb) {
|
||||
msg->cb(msg, LinphoneChatMessageStateFileTransferError, msg->chat_room->lc);
|
||||
}
|
||||
}
|
||||
static void process_auth_requested_download(void *data, belle_sip_auth_event_t *event){
|
||||
LinphoneChatMessage* msg=(LinphoneChatMessage *)data;
|
||||
ms_error("Error during file download : auth requested to get %s - msg [%p] chat room[%p]", msg->external_body_url, msg, msg->chat_room);
|
||||
if (msg->cb) {
|
||||
msg->cb(msg, LinphoneChatMessageStateFileTransferError, msg->chat_room->lc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -154,12 +177,17 @@ static void linphone_chat_message_process_response_from_post_file(void *data, co
|
|||
belle_sip_free(content_type);
|
||||
belle_sip_message_set_body_handler(BELLE_SIP_MESSAGE(req),BELLE_SIP_BODY_HANDLER(bh));
|
||||
cbs.process_response=linphone_chat_message_process_response_from_post_file;
|
||||
cbs.process_io_error=process_io_error;
|
||||
cbs.process_auth_requested=process_auth_requested;
|
||||
cbs.process_io_error=process_io_error_upload;
|
||||
cbs.process_auth_requested=process_auth_requested_upload;
|
||||
l=belle_http_request_listener_create_from_callbacks(&cbs,msg);
|
||||
msg->http_request=req; /* update the reference to the http request to be able to cancel it during upload */
|
||||
belle_http_provider_send_request(msg->chat_room->lc->http_provider,req,l);
|
||||
}
|
||||
if (code == 200 ) { /* file has been uplaoded correctly, get server reply and send it */
|
||||
if (code == 200 ) { /* file has been uploaded correctly, get server reply and send it */
|
||||
/* TODO Check that the transfer has not been cancelled, note this shall be removed once the belle sip API will provide a cancel request as we shall never reach this part if the transfer is actually cancelled */
|
||||
if (msg->http_request == NULL) {
|
||||
return;
|
||||
}
|
||||
const char *body = belle_sip_message_get_body((belle_sip_message_t *)event->response);
|
||||
msg->message = ms_strdup(body);
|
||||
linphone_content_uninit(msg->file_transfer_information);
|
||||
|
|
@ -272,7 +300,8 @@ LinphoneChatRoom* linphone_core_get_or_create_chat_room(LinphoneCore* lc, const
|
|||
|
||||
static void linphone_chat_room_delete_composing_idle_timer(LinphoneChatRoom *cr) {
|
||||
if (cr->composing_idle_timer) {
|
||||
sal_cancel_timer(cr->lc->sal, cr->composing_idle_timer);
|
||||
if(cr->lc->sal)
|
||||
sal_cancel_timer(cr->lc->sal, cr->composing_idle_timer);
|
||||
belle_sip_object_unref(cr->composing_idle_timer);
|
||||
cr->composing_idle_timer = NULL;
|
||||
}
|
||||
|
|
@ -280,7 +309,8 @@ static void linphone_chat_room_delete_composing_idle_timer(LinphoneChatRoom *cr)
|
|||
|
||||
static void linphone_chat_room_delete_composing_refresh_timer(LinphoneChatRoom *cr) {
|
||||
if (cr->composing_refresh_timer) {
|
||||
sal_cancel_timer(cr->lc->sal, cr->composing_refresh_timer);
|
||||
if(cr->lc->sal)
|
||||
sal_cancel_timer(cr->lc->sal, cr->composing_refresh_timer);
|
||||
belle_sip_object_unref(cr->composing_refresh_timer);
|
||||
cr->composing_refresh_timer = NULL;
|
||||
}
|
||||
|
|
@ -288,7 +318,8 @@ static void linphone_chat_room_delete_composing_refresh_timer(LinphoneChatRoom *
|
|||
|
||||
static void linphone_chat_room_delete_remote_composing_refresh_timer(LinphoneChatRoom *cr) {
|
||||
if (cr->remote_composing_refresh_timer) {
|
||||
sal_cancel_timer(cr->lc->sal, cr->remote_composing_refresh_timer);
|
||||
if(cr->lc->sal)
|
||||
sal_cancel_timer(cr->lc->sal, cr->remote_composing_refresh_timer);
|
||||
belle_sip_object_unref(cr->remote_composing_refresh_timer);
|
||||
cr->remote_composing_refresh_timer = NULL;
|
||||
}
|
||||
|
|
@ -335,9 +366,10 @@ static void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatM
|
|||
NULL,
|
||||
NULL);
|
||||
cbs.process_response=linphone_chat_message_process_response_from_post_file;
|
||||
cbs.process_io_error=process_io_error;
|
||||
cbs.process_auth_requested=process_auth_requested;
|
||||
cbs.process_io_error=process_io_error_upload;
|
||||
cbs.process_auth_requested=process_auth_requested_upload;
|
||||
l=belle_http_request_listener_create_from_callbacks(&cbs,msg); /* give msg to listener to be able to start the actual file upload when server answer a 204 No content */
|
||||
msg->http_request = req; /* keep a reference on the request to be able to cancel it */
|
||||
belle_http_provider_send_request(cr->lc->http_provider,req,l);
|
||||
linphone_chat_message_unref(msg);
|
||||
return;
|
||||
|
|
@ -371,8 +403,8 @@ static void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatM
|
|||
content_type=ms_strdup_printf("message/external-body; access-type=URL; URL=\"%s\"",msg->external_body_url);
|
||||
sal_message_send(op,identity,cr->peer,content_type, NULL);
|
||||
ms_free(content_type);
|
||||
} else {
|
||||
if (msg->content_type == NULL) {
|
||||
} else { /* the message is either text or have a file transfer using RCS recommendation */
|
||||
if (msg->content_type == NULL) { /* if no content type is specified, it is a text message */
|
||||
sal_text_send(op, identity, cr->peer,msg->message);
|
||||
} else {
|
||||
sal_message_send(op, identity, cr->peer, msg->content_type, msg->message);
|
||||
|
|
@ -450,7 +482,7 @@ void linphone_core_message_received(LinphoneCore *lc, SalOp *op, const SalMessag
|
|||
/* create a new chat room */
|
||||
cr=linphone_core_create_chat_room(lc,cleanfrom);
|
||||
}
|
||||
if (sal_msg->content_type != NULL) { /* content_type field is, for now, used only for rcs file transfer bu twe shall strcmp it with "application/vnd.gsma.rcs-ft-http+xml" */
|
||||
if (sal_msg->content_type != NULL) { /* content_type field is, for now, used only for rcs file transfer but we shall strcmp it with "application/vnd.gsma.rcs-ft-http+xml" */
|
||||
xmlChar *file_url = NULL;
|
||||
xmlDocPtr xmlMessageBody;
|
||||
xmlNodePtr cur;
|
||||
|
|
@ -668,6 +700,7 @@ LinphoneChatMessage* linphone_chat_room_create_message(LinphoneChatRoom *cr, con
|
|||
msg->is_read=TRUE;
|
||||
msg->content_type = NULL; /* this property is used only when transfering file */
|
||||
msg->file_transfer_information = NULL; /* this property is used only when transfering file */
|
||||
msg->http_request = NULL;
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
|
@ -857,6 +890,7 @@ const char* linphone_chat_message_state_to_string(const LinphoneChatMessageState
|
|||
case LinphoneChatMessageStateInProgress:return "LinphoneChatMessageStateInProgress";
|
||||
case LinphoneChatMessageStateDelivered:return "LinphoneChatMessageStateDelivered";
|
||||
case LinphoneChatMessageStateNotDelivered:return "LinphoneChatMessageStateNotDelivered";
|
||||
case LinphoneChatMessageStateFileTransferError:return "LinphoneChatMessageStateFileTransferError";
|
||||
default: return "Unknown state";
|
||||
}
|
||||
|
||||
|
|
@ -953,9 +987,12 @@ const LinphoneContent *linphone_chat_message_get_file_transfer_information(const
|
|||
}
|
||||
|
||||
static void on_recv_body(belle_sip_user_body_handler_t *bh, belle_sip_message_t *msg, void *data, size_t offset, const uint8_t *buffer, size_t size){
|
||||
//printf("Receive %ld bytes\n\n%s\n\n", size, (char *)buffer);
|
||||
LinphoneChatMessage* chatMsg=(LinphoneChatMessage *)data;
|
||||
LinphoneCore *lc = chatMsg->chat_room->lc;
|
||||
/* TODO: while belle sip doesn't implement the cancel http request method, test if a request is still linked to the message before forwarding the data to callback */
|
||||
if (chatMsg->http_request == NULL) {
|
||||
return;
|
||||
}
|
||||
/* call back given by application level */
|
||||
if (lc->vtable.file_transfer_received != NULL) {
|
||||
lc->vtable.file_transfer_received(lc, chatMsg, chatMsg->file_transfer_information, (char *)buffer, size);
|
||||
|
|
@ -1035,8 +1072,9 @@ static void linphone_chat_process_response_from_get_file(void *data, const belle
|
|||
* Start the download of the file from remote server
|
||||
*
|
||||
* @param message #LinphoneChatMessage
|
||||
* @param status_cb LinphoneChatMessageStateChangeCb status callback invoked when file is downloaded or could not be downloaded
|
||||
*/
|
||||
void linphone_chat_message_start_file_download(const LinphoneChatMessage *message) {
|
||||
void linphone_chat_message_start_file_download(LinphoneChatMessage *message, LinphoneChatMessageStateChangedCb status_cb) {
|
||||
belle_http_request_listener_callbacks_t cbs={0};
|
||||
belle_http_request_listener_t *l;
|
||||
belle_generic_uri_t *uri;
|
||||
|
|
@ -1055,12 +1093,31 @@ void linphone_chat_message_start_file_download(const LinphoneChatMessage *messag
|
|||
|
||||
cbs.process_response_headers=linphone_chat_process_response_headers_from_get_file;
|
||||
cbs.process_response=linphone_chat_process_response_from_get_file;
|
||||
cbs.process_io_error=process_io_error;
|
||||
cbs.process_auth_requested=process_auth_requested;
|
||||
cbs.process_io_error=process_io_error_download;
|
||||
cbs.process_auth_requested=process_auth_requested_download;
|
||||
l=belle_http_request_listener_create_from_callbacks(&cbs, (void *)message);
|
||||
belle_sip_object_data_set(BELLE_SIP_OBJECT(req),"message",(void *)message,NULL);
|
||||
message->http_request = req; /* keep a reference on the request to be able to cancel the download */
|
||||
message->cb = status_cb;
|
||||
message->state = LinphoneChatMessageStateInProgress; /* start the download, status is In Progress */
|
||||
belle_http_provider_send_request(message->chat_room->lc->http_provider,req,l);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel an ongoing file transfer attached to this message.(upload or download)
|
||||
* @param msg #LinphoneChatMessage
|
||||
*/
|
||||
void linphone_chat_room_cancel_file_transfer(LinphoneChatMessage *msg) {
|
||||
ms_message("Cancelled file transfer %s - msg [%p] chat room[%p]", (msg->external_body_url==NULL)?msg->chat_room->lc->file_transfer_server:msg->external_body_url, msg, msg->chat_room);
|
||||
/* TODO: here we shall call the cancel http request from bellesip API when it is available passing msg->http_request */
|
||||
/* waiting for this API, just set to NULL the reference to the request in the message and any request */
|
||||
msg->http_request = NULL;
|
||||
if (msg->cb) {
|
||||
msg->cb(msg, LinphoneChatMessageStateNotDelivered, msg->chat_room->lc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set origin of the message
|
||||
*@param message #LinphoneChatMessage obj
|
||||
|
|
@ -1288,11 +1345,11 @@ LinphoneChatMessage* linphone_chat_room_create_file_transfer_message(LinphoneCha
|
|||
linphone_chat_message_set_to(msg, linphone_chat_room_get_peer_address(cr));
|
||||
linphone_chat_message_set_from(msg, linphone_address_new(linphone_core_get_identity(cr->lc)));
|
||||
msg->content_type=NULL; /* this will be set to application/vnd.gsma.rcs-ft-http+xml when we will transfer the xml reply from server to the peers */
|
||||
msg->http_request=NULL; /* this will store the http request during file upload to the server */
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -115,16 +115,6 @@ static void file_transfer_send(LinphoneCore *lc, LinphoneChatMessage *message,
|
|||
|
||||
}
|
||||
|
||||
/*
|
||||
* Call back called when a message is received
|
||||
*/
|
||||
static void message_received(LinphoneCore *lc, LinphoneChatRoom *cr, LinphoneChatMessage *msg) {
|
||||
const LinphoneContent *file_transfer_info = linphone_chat_message_get_file_transfer_information(msg);
|
||||
printf ("Do you really want to download %s (size %ld)?[Y/n]\nOk, let's go\n", file_transfer_info->name, (long int)file_transfer_info->size);
|
||||
|
||||
linphone_chat_message_start_file_download(msg);
|
||||
|
||||
}
|
||||
/*
|
||||
* Call back to get delivery status of a message
|
||||
* */
|
||||
|
|
@ -136,6 +126,16 @@ static void linphone_file_transfer_state_changed(LinphoneChatMessage* msg,Linpho
|
|||
free(to);
|
||||
}
|
||||
|
||||
/*
|
||||
* Call back called when a message is received
|
||||
*/
|
||||
static void message_received(LinphoneCore *lc, LinphoneChatRoom *cr, LinphoneChatMessage *msg) {
|
||||
const LinphoneContent *file_transfer_info = linphone_chat_message_get_file_transfer_information(msg);
|
||||
printf ("Do you really want to download %s (size %ld)?[Y/n]\nOk, let's go\n", file_transfer_info->name, (long int)file_transfer_info->size);
|
||||
|
||||
linphone_chat_message_start_file_download(msg, linphone_file_transfer_state_changed);
|
||||
|
||||
}
|
||||
|
||||
LinphoneCore *lc;
|
||||
int main(int argc, char *argv[]){
|
||||
|
|
|
|||
|
|
@ -701,7 +701,6 @@ void linphone_call_set_compatible_incoming_call_parameters(LinphoneCall *call, c
|
|||
|
||||
LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *from, LinphoneAddress *to, SalOp *op){
|
||||
LinphoneCall *call=ms_new0(LinphoneCall,1);
|
||||
char *from_str;
|
||||
const SalMediaDescription *md;
|
||||
LinphoneFirewallPolicy fpol;
|
||||
|
||||
|
|
@ -721,12 +720,13 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro
|
|||
/*the following sends an option request back to the caller so that
|
||||
we get a chance to discover our nat'd address before answering.*/
|
||||
call->ping_op=sal_op_new(lc->sal);
|
||||
from_str=linphone_address_as_string_uri_only(from);
|
||||
|
||||
linphone_configure_op(lc, call->ping_op, from, NULL, FALSE);
|
||||
|
||||
sal_op_set_route(call->ping_op,sal_op_get_network_origin(op));
|
||||
sal_op_set_user_pointer(call->ping_op,call);
|
||||
sal_op_set_realm(call->ping_op,linphone_proxy_config_get_realm(linphone_core_lookup_known_proxy(call->core, to)));
|
||||
sal_ping(call->ping_op,linphone_core_find_best_identity(lc,from),from_str);
|
||||
ms_free(from_str);
|
||||
|
||||
sal_ping(call->ping_op,sal_op_get_from(call->ping_op), sal_op_get_to(call->ping_op));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1258,7 +1258,8 @@ typedef enum _LinphoneChatMessageState {
|
|||
LinphoneChatMessageStateIdle, /**< Initial state */
|
||||
LinphoneChatMessageStateInProgress, /**< Delivery in progress */
|
||||
LinphoneChatMessageStateDelivered, /**< Message succesffully delivered an acknoleged by remote end point */
|
||||
LinphoneChatMessageStateNotDelivered /**< Message was not delivered */
|
||||
LinphoneChatMessageStateNotDelivered, /**< Message was not delivered */
|
||||
LinphoneChatMessageStateFileTransferError /**< Message was received(and acknowledged) but cannot get file from server */
|
||||
} LinphoneChatMessageState;
|
||||
|
||||
/**
|
||||
|
|
@ -1331,7 +1332,8 @@ LINPHONE_PUBLIC const LinphoneAddress* linphone_chat_message_get_to(const Linpho
|
|||
LINPHONE_PUBLIC const char* linphone_chat_message_get_external_body_url(const LinphoneChatMessage* message);
|
||||
LINPHONE_PUBLIC void linphone_chat_message_set_external_body_url(LinphoneChatMessage* message,const char* url);
|
||||
LINPHONE_PUBLIC const LinphoneContent* linphone_chat_message_get_file_transfer_information(const LinphoneChatMessage* message);
|
||||
LINPHONE_PUBLIC void linphone_chat_message_start_file_download(const LinphoneChatMessage*message);
|
||||
LINPHONE_PUBLIC void linphone_chat_message_start_file_download(LinphoneChatMessage* message, LinphoneChatMessageStateChangedCb status_cb);
|
||||
LINPHONE_PUBLIC void linphone_chat_room_cancel_file_transfer(LinphoneChatMessage* msg);
|
||||
LINPHONE_PUBLIC const char* linphone_chat_message_get_appdata(const LinphoneChatMessage* message);
|
||||
LINPHONE_PUBLIC void linphone_chat_message_set_appdata(LinphoneChatMessage* message, const char* data);
|
||||
LINPHONE_PUBLIC const char* linphone_chat_message_get_text(const LinphoneChatMessage* message);
|
||||
|
|
|
|||
|
|
@ -3033,6 +3033,19 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneProxyConfigImpl_getQual
|
|||
return jvalue;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneProxyConfigImpl_setRealm(JNIEnv *env, jobject thiz, jlong ptr, jstring jrealm) {
|
||||
if (jrealm){
|
||||
const char *realm=env->GetStringUTFChars(jrealm, NULL);
|
||||
linphone_proxy_config_set_realm((LinphoneProxyConfig *)ptr, realm);
|
||||
env->ReleaseStringUTFChars(jrealm,realm);
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneProxyConfigImpl_getRealm(JNIEnv *env, jobject thiz, jlong ptr) {
|
||||
jstring jvalue = env->NewStringUTF(linphone_proxy_config_get_realm((LinphoneProxyConfig *)ptr));
|
||||
return jvalue;
|
||||
}
|
||||
|
||||
extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getDuration(JNIEnv* env,jobject thiz,jlong ptr) {
|
||||
return (jint)linphone_call_get_duration((LinphoneCall *) ptr);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,8 +163,9 @@ struct _LinphoneChatMessage {
|
|||
bool_t is_read;
|
||||
unsigned int storage_id;
|
||||
SalOp *op;
|
||||
LinphoneContent *file_transfer_information;
|
||||
char *content_type;
|
||||
LinphoneContent *file_transfer_information; /**< used to store file transfer information when the message is of file transfer type */
|
||||
char *content_type; /**< is used to specified the type of message to be sent, used only for file transfer message */
|
||||
belle_http_request_t *http_request; /**< keep a reference to the http_request in case of file transfer in order to be able to cancel the transfer */
|
||||
};
|
||||
|
||||
BELLE_SIP_DECLARE_VPTR(LinphoneChatMessage);
|
||||
|
|
|
|||
|
|
@ -412,6 +412,7 @@ void _linphone_proxy_config_unregister(LinphoneProxyConfig *obj) {
|
|||
static void linphone_proxy_config_register(LinphoneProxyConfig *obj){
|
||||
if (obj->reg_sendregister){
|
||||
LinphoneAddress* proxy=linphone_address_new(obj->reg_proxy);
|
||||
LinphoneAddress* to=linphone_address_new(obj->reg_identity);
|
||||
char* proxy_string;
|
||||
LinphoneAddress *contact;
|
||||
ms_message("LinphoneProxyConfig [%p] about to register (LinphoneCore version: %s)",obj,linphone_core_get_version());
|
||||
|
|
@ -420,12 +421,18 @@ static void linphone_proxy_config_register(LinphoneProxyConfig *obj){
|
|||
if (obj->op)
|
||||
sal_op_release(obj->op);
|
||||
obj->op=sal_op_new(obj->lc->sal);
|
||||
|
||||
linphone_configure_op(obj->lc, obj->op, to, NULL, FALSE);
|
||||
linphone_address_destroy(to);
|
||||
|
||||
if ((contact=guess_contact_for_register(obj))) {
|
||||
sal_op_set_contact_address(obj->op,contact);
|
||||
linphone_address_destroy(contact);
|
||||
}
|
||||
|
||||
sal_op_set_user_pointer(obj->op,obj);
|
||||
sal_op_set_realm(obj->op, obj->realm);
|
||||
|
||||
|
||||
if (sal_register(obj->op,proxy_string,obj->reg_identity,obj->expires)==0) {
|
||||
linphone_proxy_config_set_state(obj,LinphoneRegistrationProgress,"Registration in progress");
|
||||
} else {
|
||||
|
|
@ -967,11 +974,15 @@ int linphone_proxy_config_send_publish(LinphoneProxyConfig *proxy, LinphonePrese
|
|||
|
||||
if (proxy->state==LinphoneRegistrationOk || proxy->state==LinphoneRegistrationCleared){
|
||||
if (proxy->publish_op==NULL){
|
||||
LinphoneAddress *to=linphone_address_new(linphone_proxy_config_get_identity(proxy));
|
||||
proxy->publish_op=sal_op_new(proxy->lc->sal);
|
||||
sal_op_set_route(proxy->publish_op,proxy->reg_proxy);
|
||||
sal_op_set_from(proxy->publish_op,linphone_proxy_config_get_identity(proxy));
|
||||
sal_op_set_to(proxy->publish_op,linphone_proxy_config_get_identity(proxy));
|
||||
sal_op_set_realm(proxy->publish_op,linphone_proxy_config_get_realm(proxy));
|
||||
|
||||
linphone_configure_op(proxy->lc, proxy->publish_op,
|
||||
to, NULL, FALSE);
|
||||
|
||||
if (to!=NULL){
|
||||
linphone_address_destroy(to);
|
||||
}
|
||||
if (lp_config_get_int(proxy->lc->config,"sip","publish_msg_with_contact",0)){
|
||||
SalAddress *addr=sal_address_new(linphone_proxy_config_get_identity(proxy));
|
||||
sal_op_set_contact_address(proxy->publish_op,addr);
|
||||
|
|
|
|||
|
|
@ -224,6 +224,19 @@ public interface LinphoneProxyConfig {
|
|||
*/
|
||||
String getQualityReportingCollector();
|
||||
|
||||
/**
|
||||
* Set the outbound proxy realm. It is used in digest authentication to avoid
|
||||
* re-authentication if a previous token has already been provided.
|
||||
* @param The new outbound proxy realm.
|
||||
*/
|
||||
void setRealm(String realm);
|
||||
|
||||
/**
|
||||
* Get the outbound proxy realm.
|
||||
* @return The outbound proxy realm.
|
||||
*/
|
||||
String getRealm();
|
||||
|
||||
/**
|
||||
* Set optional contact parameters that will be added to the contact information sent in the registration.
|
||||
* @param contact_params a string containing the additional parameters in text form, like "myparam=something;myparam2=something_else"
|
||||
|
|
@ -287,12 +300,12 @@ public interface LinphoneProxyConfig {
|
|||
* @return the publish expiration time in second. Default value is the registration expiration value.
|
||||
*/
|
||||
public int getPublishExpires();
|
||||
|
||||
|
||||
/**
|
||||
* attached a user data to a proxy config
|
||||
**/
|
||||
void setUserData(Object obj);
|
||||
|
||||
|
||||
/**
|
||||
* Returns user data from a proxy config. return null if any
|
||||
* @return an Object.
|
||||
|
|
|
|||
|
|
@ -321,6 +321,7 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
|
|||
isValid();
|
||||
return getQualityReportingInterval(nativePtr);
|
||||
}
|
||||
|
||||
private native void setQualityReportingCollector(long nativePtr, String collector);
|
||||
@Override
|
||||
public void setQualityReportingCollector(String collector) {
|
||||
|
|
@ -334,6 +335,21 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
|
|||
isValid();
|
||||
return getQualityReportingCollector(nativePtr);
|
||||
}
|
||||
|
||||
private native void setRealm(long nativePtr, String realm);
|
||||
@Override
|
||||
public void setRealm(String realm) {
|
||||
isValid();
|
||||
setRealm(nativePtr, realm);
|
||||
}
|
||||
private native String getRealm(long nativePtr);
|
||||
@Override
|
||||
public String getRealm() {
|
||||
|
||||
isValid();
|
||||
return getRealm(nativePtr);
|
||||
}
|
||||
|
||||
private native void setPublishExpires(long nativePtr, int expires);
|
||||
@Override
|
||||
public void setPublishExpires(int expires) {
|
||||
|
|
|
|||
|
|
@ -46,11 +46,11 @@ void message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMess
|
|||
ms_free(from);
|
||||
counters = get_stats(lc);
|
||||
counters->number_of_LinphoneMessageReceived++;
|
||||
if (linphone_chat_message_get_file_transfer_information(message))
|
||||
counters->number_of_LinphoneMessageReceivedWithFile++;
|
||||
if (counters->last_received_chat_message) linphone_chat_message_unref(counters->last_received_chat_message);
|
||||
linphone_chat_message_ref(counters->last_received_chat_message=message);
|
||||
if (linphone_chat_message_get_external_body_url(message)) {
|
||||
if (linphone_chat_message_get_file_transfer_information(message)) {
|
||||
counters->number_of_LinphoneMessageReceivedWithFile++;
|
||||
} else if (linphone_chat_message_get_external_body_url(message)) {
|
||||
counters->number_of_LinphoneMessageExtBodyReceived++;
|
||||
if (message_external_body_url) {
|
||||
CU_ASSERT_STRING_EQUAL(linphone_chat_message_get_external_body_url(message),message_external_body_url);
|
||||
|
|
@ -75,7 +75,7 @@ void file_transfer_received(LinphoneCore *lc, LinphoneChatMessage *message, cons
|
|||
/*next chunk*/
|
||||
file = (FILE*)linphone_chat_message_get_user_data(message);
|
||||
|
||||
if (size==0) { /* tranfer complerte */
|
||||
if (size==0) { /* tranfer complete */
|
||||
stats* counters = get_stats(lc);
|
||||
linphone_chat_room_destroy(linphone_chat_message_get_chat_room(message));
|
||||
linphone_chat_message_destroy(message);
|
||||
|
|
@ -124,7 +124,7 @@ void file_transfer_progress_indication(LinphoneCore *lc, LinphoneChatMessage *me
|
|||
const LinphoneAddress* to_address = linphone_chat_message_get_to(message);
|
||||
char *address = linphone_chat_message_is_outgoing(message)?linphone_address_as_string(to_address):linphone_address_as_string(from_address);
|
||||
stats* counters = get_stats(lc);
|
||||
printf(" File transfer [%d%%] %s of type [%s/%s] %s [%s] \n", (int)progress
|
||||
ms_message(" File transfer [%d%%] %s of type [%s/%s] %s [%s] \n", (int)progress
|
||||
,(linphone_chat_message_is_outgoing(message)?"sent":"received")
|
||||
, content->type
|
||||
, content->subtype
|
||||
|
|
@ -157,6 +157,9 @@ void liblinphone_tester_chat_message_state_change(LinphoneChatMessage* msg,Linph
|
|||
case LinphoneChatMessageStateInProgress:
|
||||
counters->number_of_LinphoneMessageInProgress++;
|
||||
break;
|
||||
case LinphoneChatMessageStateFileTransferError:
|
||||
counters->number_of_LinphoneMessageNotDelivered++;
|
||||
break;
|
||||
default:
|
||||
ms_error("Unexpected state [%s] for message [%p]",linphone_chat_message_state_to_string(state),msg);
|
||||
}
|
||||
|
|
@ -377,19 +380,20 @@ static void file_transfer_message(void) {
|
|||
|
||||
linphone_chat_room_send_message2(chat_room,message,liblinphone_tester_chat_message_state_change,pauline->lc);
|
||||
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceivedWithFile,1));
|
||||
if (marie->stat.last_received_info_message ) {
|
||||
linphone_chat_message_start_file_download((const LinphoneChatMessage*)marie->stat.last_received_info_message);
|
||||
if (marie->stat.last_received_chat_message ) {
|
||||
linphone_chat_message_start_file_download(marie->stat.last_received_chat_message, liblinphone_tester_chat_message_state_change);
|
||||
}
|
||||
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneMessageDelivered,1));
|
||||
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageExtBodyReceived,1));
|
||||
|
||||
CU_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageInProgress,1);
|
||||
CU_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageDelivered,1);
|
||||
CU_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageExtBodyReceived,1);
|
||||
|
||||
linphone_core_manager_destroy(marie);
|
||||
linphone_core_manager_destroy(pauline);
|
||||
}
|
||||
|
||||
static void file_transfer_message_io_error(void) {
|
||||
static void file_transfer_message_io_error_upload(void) {
|
||||
int i;
|
||||
char* to;
|
||||
LinphoneChatRoom* chat_room;
|
||||
|
|
@ -439,6 +443,173 @@ static void file_transfer_message_io_error(void) {
|
|||
linphone_core_manager_destroy(pauline);
|
||||
}
|
||||
|
||||
|
||||
#ifdef TEST_IS_BUGGED_NO_CALL_TO_IO_ERROR_CALLBACK
|
||||
static void file_transfer_message_io_error_download(void) {
|
||||
int i;
|
||||
char* to;
|
||||
LinphoneChatRoom* chat_room;
|
||||
LinphoneChatMessage* message;
|
||||
LinphoneContent content;
|
||||
const char* big_file_content="big file"; /* setting dummy file content to something */
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
|
||||
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
|
||||
reset_counters(&marie->stat);
|
||||
reset_counters(&pauline->stat);
|
||||
|
||||
/* setting dummy file content to something */
|
||||
for (i=0;i<sizeof(big_file);i+=strlen(big_file_content))
|
||||
memcpy(big_file+i, big_file_content, strlen(big_file_content));
|
||||
|
||||
big_file[0]=*"S";
|
||||
big_file[sizeof(big_file)-1]=*"E";
|
||||
|
||||
/* Globally configure an http file transfer server. */
|
||||
linphone_core_set_file_transfer_server(pauline->lc,"https://www.linphone.org:444/lft.php");
|
||||
|
||||
/* create a chatroom on pauline's side */
|
||||
to = linphone_address_as_string(marie->identity);
|
||||
chat_room = linphone_core_create_chat_room(pauline->lc,to);
|
||||
|
||||
/* create a file transfer message */
|
||||
memset(&content,0,sizeof(content));
|
||||
content.type="text";
|
||||
content.subtype="plain";
|
||||
content.size=sizeof(big_file); /*total size to be transfered*/
|
||||
content.name = "bigfile.txt";
|
||||
message = linphone_chat_room_create_file_transfer_message(chat_room, &content);
|
||||
|
||||
linphone_chat_room_send_message2(chat_room,message,liblinphone_tester_chat_message_state_change,pauline->lc);
|
||||
|
||||
/* wait for marie to receive pauline's message */
|
||||
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceivedWithFile,1));
|
||||
|
||||
|
||||
if (marie->stat.last_received_chat_message ) { /* get last message and use it to download file */
|
||||
linphone_chat_message_start_file_download(marie->stat.last_received_chat_message, liblinphone_tester_chat_message_state_change);
|
||||
/* wait for file to be 50% downloaded */
|
||||
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.progress_of_LinphoneFileTransfer, 50));
|
||||
/* and simulate network error */
|
||||
sal_set_recv_error(marie->lc->sal, -1);
|
||||
}
|
||||
|
||||
CU_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageInProgress,1);
|
||||
CU_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageDelivered,1);
|
||||
CU_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageNotDelivered,1);
|
||||
CU_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageExtBodyReceived,0);
|
||||
|
||||
sal_set_recv_error(marie->lc->sal, 0);
|
||||
linphone_core_manager_destroy(marie);
|
||||
linphone_core_manager_destroy(pauline);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void file_transfer_message_upload_cancelled(void) {
|
||||
int i;
|
||||
char* to;
|
||||
LinphoneChatRoom* chat_room;
|
||||
LinphoneChatMessage* message;
|
||||
LinphoneContent content;
|
||||
const char* big_file_content="big file"; /* setting dummy file content to something */
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
|
||||
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
|
||||
reset_counters(&marie->stat);
|
||||
reset_counters(&pauline->stat);
|
||||
|
||||
/* setting dummy file content to something */
|
||||
for (i=0;i<sizeof(big_file);i+=strlen(big_file_content))
|
||||
memcpy(big_file+i, big_file_content, strlen(big_file_content));
|
||||
|
||||
big_file[0]=*"S";
|
||||
big_file[sizeof(big_file)-1]=*"E";
|
||||
|
||||
/* Globally configure an http file transfer server. */
|
||||
linphone_core_set_file_transfer_server(pauline->lc,"https://www.linphone.org:444/lft.php");
|
||||
|
||||
/* create a chatroom on pauline's side */
|
||||
to = linphone_address_as_string(marie->identity);
|
||||
chat_room = linphone_core_create_chat_room(pauline->lc,to);
|
||||
|
||||
/* create a file transfer message */
|
||||
memset(&content,0,sizeof(content));
|
||||
content.type="text";
|
||||
content.subtype="plain";
|
||||
content.size=sizeof(big_file); /*total size to be transfered*/
|
||||
content.name = "bigfile.txt";
|
||||
message = linphone_chat_room_create_file_transfer_message(chat_room, &content);
|
||||
|
||||
linphone_chat_room_send_message2(chat_room,message,liblinphone_tester_chat_message_state_change,pauline->lc);
|
||||
|
||||
/*wait for file to be 50% uploaded and cancel the transfer */
|
||||
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.progress_of_LinphoneFileTransfer, 50));
|
||||
linphone_chat_room_cancel_file_transfer(message);
|
||||
|
||||
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneMessageNotDelivered,1));
|
||||
|
||||
CU_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageNotDelivered,1);
|
||||
CU_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageExtBodyReceived,0);
|
||||
|
||||
linphone_core_manager_destroy(marie);
|
||||
linphone_core_manager_destroy(pauline);
|
||||
}
|
||||
|
||||
static void file_transfer_message_download_cancelled(void) {
|
||||
int i;
|
||||
char* to;
|
||||
LinphoneChatRoom* chat_room;
|
||||
LinphoneChatMessage* message;
|
||||
LinphoneContent content;
|
||||
const char* big_file_content="big file"; /* setting dummy file content to something */
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
|
||||
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
|
||||
reset_counters(&marie->stat);
|
||||
reset_counters(&pauline->stat);
|
||||
|
||||
/* setting dummy file content to something */
|
||||
for (i=0;i<sizeof(big_file);i+=strlen(big_file_content))
|
||||
memcpy(big_file+i, big_file_content, strlen(big_file_content));
|
||||
|
||||
big_file[0]=*"S";
|
||||
big_file[sizeof(big_file)-1]=*"E";
|
||||
|
||||
/* Globally configure an http file transfer server. */
|
||||
linphone_core_set_file_transfer_server(pauline->lc,"https://www.linphone.org:444/lft.php");
|
||||
|
||||
/* create a chatroom on pauline's side */
|
||||
to = linphone_address_as_string(marie->identity);
|
||||
chat_room = linphone_core_create_chat_room(pauline->lc,to);
|
||||
|
||||
/* create a file transfer message */
|
||||
memset(&content,0,sizeof(content));
|
||||
content.type="text";
|
||||
content.subtype="plain";
|
||||
content.size=sizeof(big_file); /*total size to be transfered*/
|
||||
content.name = "bigfile.txt";
|
||||
message = linphone_chat_room_create_file_transfer_message(chat_room, &content);
|
||||
|
||||
linphone_chat_room_send_message2(chat_room,message,liblinphone_tester_chat_message_state_change,pauline->lc);
|
||||
|
||||
/* wait for marie to receive pauline's message */
|
||||
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceivedWithFile,1));
|
||||
|
||||
|
||||
if (marie->stat.last_received_chat_message ) { /* get last message and use it to download file */
|
||||
linphone_chat_message_start_file_download(marie->stat.last_received_chat_message, liblinphone_tester_chat_message_state_change);
|
||||
/* wait for file to be 50% downloaded */
|
||||
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.progress_of_LinphoneFileTransfer, 50));
|
||||
/* and cancel the transfer */
|
||||
linphone_chat_room_cancel_file_transfer(marie->stat.last_received_chat_message);
|
||||
}
|
||||
|
||||
CU_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageInProgress,1);
|
||||
CU_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageDelivered,1);
|
||||
CU_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageExtBodyReceived,0);
|
||||
CU_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageNotDelivered,1);
|
||||
|
||||
linphone_core_manager_destroy(marie);
|
||||
linphone_core_manager_destroy(pauline);
|
||||
}
|
||||
|
||||
static void text_message_with_send_error(void) {
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
|
||||
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
|
||||
|
|
@ -671,7 +842,10 @@ test_t message_tests[] = {
|
|||
{ "Text message with send error", text_message_with_send_error },
|
||||
{ "Text message with external body", text_message_with_external_body },
|
||||
{ "File transfer message", file_transfer_message },
|
||||
{ "File transfer message with io error", file_transfer_message_io_error },
|
||||
{ "File transfer message with io error at upload", file_transfer_message_io_error_upload },
|
||||
/* { "File transfer message with io error at download", file_transfer_message_io_error_download },*/
|
||||
{ "File transfer message upload cancelled", file_transfer_message_upload_cancelled },
|
||||
{ "File transfer message download cancelled", file_transfer_message_download_cancelled },
|
||||
{ "Text message denied", text_message_denied },
|
||||
{ "Info message", info_message },
|
||||
{ "Info message with body", info_message_with_body },
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue