mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-25 23:28:09 +00:00
File transfer move server to https:linphone.org
This commit is contained in:
parent
e98ad8e4a6
commit
94ce7ad1bf
2 changed files with 23 additions and 41 deletions
|
|
@ -64,13 +64,7 @@ static void file_transfer_progress_indication(LinphoneCore *lc, LinphoneChatMess
|
|||
* function invoked when a file transfer is received.
|
||||
* */
|
||||
static void file_transfer_received(LinphoneCore *lc, LinphoneChatMessage *message, const LinphoneContent* content, const char* buff, size_t size){
|
||||
const LinphoneAddress* from_address = linphone_chat_message_get_from(message);
|
||||
char *from = linphone_address_as_string(from_address);
|
||||
int file=-1;
|
||||
printf(" File transfer receive [%i] bytes of type [%s/%s] from [%s] \n" , (int)size
|
||||
, content->type
|
||||
, content->subtype
|
||||
, from);
|
||||
if (!linphone_chat_message_get_user_data(message)) {
|
||||
/*first chunk, creating file*/
|
||||
file = open("receive_file.dump",O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR);
|
||||
|
|
@ -78,20 +72,18 @@ static void file_transfer_received(LinphoneCore *lc, LinphoneChatMessage *messag
|
|||
} else {
|
||||
/*next chunk*/
|
||||
file = (int)((long)(linphone_chat_message_get_user_data(message))&0x00000000FFFFFFFF);
|
||||
|
||||
if (size==0) {
|
||||
|
||||
printf("File transfert completed\n");
|
||||
linphone_chat_room_destroy(linphone_chat_message_get_chat_room(message));
|
||||
linphone_chat_message_destroy(message);
|
||||
close(file);
|
||||
running=FALSE;
|
||||
} else { /* store content on a file*/
|
||||
write(file,buff,size);
|
||||
}
|
||||
}
|
||||
|
||||
if (size==0) {
|
||||
printf("File transfert completed\n");
|
||||
linphone_chat_room_destroy(linphone_chat_message_get_chat_room(message));
|
||||
linphone_chat_message_destroy(message);
|
||||
close(file);
|
||||
running=FALSE;
|
||||
} else { /* store content on a file*/
|
||||
write(file,buff,size);
|
||||
}
|
||||
|
||||
|
||||
free(from);
|
||||
}
|
||||
|
||||
char big_file [128000];
|
||||
|
|
@ -99,10 +91,7 @@ char big_file [128000];
|
|||
* function called when the file transfer is initiated. file content should be feed into object LinphoneContent
|
||||
* */
|
||||
static void file_transfer_send(LinphoneCore *lc, LinphoneChatMessage *message, const LinphoneContent* content, char* buff, size_t* size){
|
||||
//const LinphoneAddress* to_address = linphone_chat_message_get_to(message);
|
||||
//char *to = linphone_address_as_string(to_address);
|
||||
int offset=-1;
|
||||
/*content->size can be feed*/
|
||||
|
||||
if (!linphone_chat_message_get_user_data(message)) {
|
||||
/*first chunk*/
|
||||
|
|
@ -119,15 +108,9 @@ static void file_transfer_send(LinphoneCore *lc, LinphoneChatMessage *message,
|
|||
}
|
||||
memcpy(buff,big_file+offset,*size);
|
||||
|
||||
printf(" File transfer sending [%i] bytes of type [%s/%s] from [%s] \n" , (int)*size
|
||||
, content->type
|
||||
, content->subtype
|
||||
, "pipo");
|
||||
/*store offset for next chunk*/
|
||||
linphone_chat_message_set_user_data(message,(void*)(offset+*size));
|
||||
|
||||
//free(to);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -193,8 +176,8 @@ int main(int argc, char *argv[]){
|
|||
/**
|
||||
* Globally configure an http file transfer server.
|
||||
*/
|
||||
linphone_core_set_file_transfer_server(lc,"http://npasc.al/lft.php");
|
||||
//linphone_core_set_file_transfer_server(lc,"https://www.linphone.org:444/upload.php");
|
||||
//linphone_core_set_file_transfer_server(lc,"http://npasc.al/lft.php");
|
||||
linphone_core_set_file_transfer_server(lc,"https://www.linphone.org:444/lft.php");
|
||||
|
||||
|
||||
/*Next step is to create a chat room*/
|
||||
|
|
|
|||
|
|
@ -63,16 +63,16 @@ void file_transfer_received(LinphoneCore *lc, LinphoneChatMessage *message, cons
|
|||
} else {
|
||||
/*next chunk*/
|
||||
file = (int)((long)(linphone_chat_message_get_user_data(message))&0x00000000FFFFFFFF);
|
||||
}
|
||||
|
||||
if (size==0) {
|
||||
linphone_chat_room_destroy(linphone_chat_message_get_chat_room(message));
|
||||
linphone_chat_message_destroy(message);
|
||||
stats* counters = get_stats(lc);
|
||||
counters->number_of_LinphoneMessageExtBodyReceived++;
|
||||
close(file);
|
||||
} else { /* store content on a file*/
|
||||
write(file,buff,size);
|
||||
if (size==0) { /* tranfer complerte */
|
||||
linphone_chat_room_destroy(linphone_chat_message_get_chat_room(message));
|
||||
linphone_chat_message_destroy(message);
|
||||
stats* counters = get_stats(lc);
|
||||
counters->number_of_LinphoneMessageExtBodyReceived++;
|
||||
close(file);
|
||||
} else { /* store content on a file*/
|
||||
write(file,buff,size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -319,7 +319,6 @@ static void text_message_with_external_body(void) {
|
|||
static void file_transfer_message(void) {
|
||||
int i;
|
||||
/* setting dummy file content to something */
|
||||
|
||||
const char* big_file_content="big file";
|
||||
for (i=0;i<sizeof(big_file);i+=strlen(big_file_content))
|
||||
memcpy(big_file+i, big_file_content, strlen(big_file_content));
|
||||
|
|
@ -331,7 +330,7 @@ static void file_transfer_message(void) {
|
|||
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
|
||||
|
||||
/* Globally configure an http file transfer server. */
|
||||
linphone_core_set_file_transfer_server(pauline->lc,"http://npasc.al/lft.php");
|
||||
linphone_core_set_file_transfer_server(pauline->lc,"https://www.linphone.org:444/lft.php");
|
||||
|
||||
/* create a chatroom on pauline's side */
|
||||
char* to = linphone_address_as_string(marie->identity);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue