int linphone_proxy_config_send_publish(LinphoneProxyConfig *proxy, LinphoneOnlineStatus presence_mode) { osip_message_t *pub; int i; const char *from=NULL; char buf[5000]; if (proxy->publish==FALSE) return 0; if (proxy!=NULL) { from=linphone_proxy_config_get_identity(proxy); } if (from==NULL) from=linphone_core_get_primary_contact(proxy->lc); if (presence_mode==LINPHONE_STATUS_ONLINE) { snprintf(buf, 5000, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\ <presence xmlns=\"urn:ietf:params:xml:ns:pidf\"\n\ entity=\"%s\">\n\ <tuple id=\"sg89ae\">\n\ <status>\n\ <basic>open</basic>\n\ </status>\n\ <contact priority=\"0.8\">%s</contact>\n\ <note>online</note>\n\ </tuple>\n\ </presence>", from, from); }
const char* linphone_gtk_get_used_identity(){ LinphoneCore *lc=linphone_gtk_get_core(); LinphoneProxyConfig *cfg; linphone_core_get_default_proxy(lc,&cfg); if (cfg) return linphone_proxy_config_get_identity(cfg); else return linphone_core_get_primary_contact(lc); }
static void print_prompt(LinphoneCore *opm){ #ifdef IDENTITY_AS_PROMPT snprintf(prompt, PROMPT_MAX_LEN, "%s> ", linphone_core_get_primary_contact(opm)); #else snprintf(prompt, PROMPT_MAX_LEN, "linphonec> "); #endif }
int linphone_proxy_config_done(LinphoneProxyConfig *obj) { const char *id_str; if (!linphone_proxy_config_check(obj->lc,obj)) return -1; if (obj->reg_identity!=NULL) id_str=obj->reg_identity; else id_str=linphone_core_get_primary_contact(obj->lc); obj->frozen=FALSE; if (obj->reg_sendregister){ char *ct=NULL; osip_message_t *msg=NULL; obj->rid=eXosip_register_build_initial_register(id_str,obj->reg_proxy,NULL,obj->expires,&msg); eXosip_register_send_register(obj->rid,msg); if (ct!=NULL) osip_free(ct); } return 0; }
static void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage* msg){ SalOp *op=NULL; LinphoneCall *call; char* content_type; const char *identity=NULL; time_t t=time(NULL); if (lp_config_get_int(cr->lc->config,"sip","chat_use_call_dialogs",0)){ if((call = linphone_core_get_call_by_remote_address(cr->lc,cr->peer))!=NULL){ if (call->state==LinphoneCallConnected || call->state==LinphoneCallStreamsRunning || call->state==LinphoneCallPaused || call->state==LinphoneCallPausing || call->state==LinphoneCallPausedByRemote){ ms_message("send SIP message through the existing call."); op = call->op; call->pending_message=msg; identity=linphone_core_find_best_identity(cr->lc,linphone_call_get_remote_address(call)); } } } msg->time=t; if (op==NULL){ LinphoneProxyConfig *proxy=linphone_core_lookup_known_proxy(cr->lc,cr->peer_url); if (proxy){ identity=linphone_proxy_config_get_identity(proxy); }else identity=linphone_core_get_primary_contact(cr->lc); /*sending out of calls*/ op = sal_op_new(cr->lc->sal); linphone_configure_op(cr->lc,op,cr->peer_url,msg->custom_headers,lp_config_get_int(cr->lc->config,"sip","chat_msg_with_contact",0)); sal_op_set_user_pointer(op, msg); /*if out of call, directly store msg*/ } if (msg->external_body_url) { 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 { sal_text_send(op, identity, cr->peer,msg->message); } msg->dir=LinphoneChatMessageOutgoing; msg->from=linphone_address_new(identity); msg->storage_id=linphone_chat_message_store(msg); }
int main(int argc, char *argv[]){ LinphoneCoreVTable vtable={0}; const char* dest_friend=NULL; int i; const char* big_file_content="big file"; LinphoneChatRoom* chat_room; LinphoneContent* content; LinphoneChatMessage* chat_message; LinphoneChatMessageCbs *cbs; /*seting 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"; signal(SIGINT,stop); //#define DEBUG #ifdef DEBUG linphone_core_enable_logs(NULL); /*enable liblinphone logs.*/ #endif vtable.message_received=message_received; /* Instantiate a LinphoneCore object given the LinphoneCoreVTable */ lc=linphone_core_new(&vtable,NULL,NULL,NULL); dest_friend = linphone_core_get_primary_contact(lc); printf("Send message to me : %s\n", dest_friend); /** * 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/lft.php"); /*Next step is to create a chat room*/ chat_room = linphone_core_get_chat_room_from_uri(lc,dest_friend); content = linphone_core_create_content(lc); linphone_content_set_type(content,"text"); linphone_content_set_subtype(content,"plain"); linphone_content_set_size(content,sizeof(big_file)); /*total size to be transfered*/ linphone_content_set_name(content,"bigfile.txt"); /*now create a chat message with custom content*/ chat_message = linphone_chat_room_create_file_transfer_message(chat_room,content); if (chat_message == NULL) { printf("returned message is null\n"); } /** * Fill the application callbacks. The file_transfer_received callback is used in order to get notifications * about incoming file reception, file_transfer_send to feed file to be transfered and * file_transfer_progress_indication to print progress. */ cbs = linphone_chat_message_get_callbacks(chat_message); linphone_chat_message_cbs_set_file_transfer_recv(cbs, file_transfer_received); linphone_chat_message_cbs_set_file_transfer_send(cbs, file_transfer_send); linphone_chat_message_cbs_set_file_transfer_progress_indication(cbs, file_transfer_progress_indication); /*initiating file transfer*/ linphone_chat_room_send_chat_message(chat_room, chat_message); /* main loop for receiving incoming messages and doing background linphone core work: */ while(running){ linphone_core_iterate(lc); ms_usleep(50000); } printf("Shutting down...\n"); linphone_content_unref(content); linphone_core_destroy(lc); printf("Exited\n"); return 0; }