static void text_received(Sal *sal, const SalMessage *msg){
LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal);
if (is_duplicate_msg(lc,msg->message_id)==FALSE){
- linphone_core_message_received(lc,msg->from,msg->text,msg->url);
+ linphone_core_message_received(lc,msg);
}
}
}
-void linphone_core_message_received(LinphoneCore *lc, const char *from, const char *raw_msg,const char* external_url){
+void linphone_core_message_received(LinphoneCore *lc, const SalMessage *sal_msg){
MSList *elem;
LinphoneChatRoom *cr=NULL;
LinphoneAddress *addr;
char *cleanfrom;
LinphoneChatMessage* msg;
- addr=linphone_address_new(from);
+ addr=linphone_address_new(sal_msg->from);
linphone_address_clean(addr);
for(elem=lc->chatrooms;elem!=NULL;elem=ms_list_next(elem)){
cr=(LinphoneChatRoom*)elem->data;
/* create a new chat room */
cr=linphone_core_create_chat_room(lc,cleanfrom);
}
- msg = linphone_chat_room_create_message(cr, raw_msg);
+ msg = linphone_chat_room_create_message(cr, sal_msg->text);
linphone_chat_message_set_from(msg, cr->peer_url);
- if (external_url) {
- linphone_chat_message_set_external_body_url(msg, external_url);
+ msg->time=sal_msg->time;
+
+ if (sal_msg->url) {
+ linphone_chat_message_set_external_body_url(msg, sal_msg->url);
}
linphone_address_destroy(addr);
linphone_chat_room_message_received(cr,lc,msg);
LinphoneAddress* linphone_chat_message_get_from(const LinphoneChatMessage* message) {
return message->from;
}
+
+time_t linphone_chat_message_get_time(const LinphoneChatMessage* message) {
+ return message->time;
+}
+
const char * linphone_chat_message_get_text(const LinphoneChatMessage* message) {
return message->message;
}
* Get text part of this message
* @return text or NULL if no text.
*/
-const char * linphone_chat_message_get_text(const LinphoneChatMessage* message);
+const char * linphone_chat_message_get_text(const LinphoneChatMessage* message);
+
+/**
+ * Get the time the message was sent
+ * @return time_t or NULL if no time
+ */
+time_t linphone_chat_message_get_time(const LinphoneChatMessage* message);
+
/**
* user pointer get function
*/
void* message_userdata;
char* external_body_url;
LinphoneAddress* from;
+ time_t time;
};
typedef struct StunCandidate{
int linphone_proxy_config_normalize_number(LinphoneProxyConfig *cfg, const char *username, char *result, size_t result_len);
-void linphone_core_message_received(LinphoneCore *lc, const char *from, const char *raw_msg,const char* external_url);
+void linphone_core_message_received(LinphoneCore *lc, const SalMessage *msg);
void linphone_core_play_tone(LinphoneCore *lc);
const char *text;
const char *url;
const char *message_id;
+ time_t time;
}SalMessage;
#define SAL_MEDIA_DESCRIPTION_MAX_MESSAGE_ATTRIBUTES 5
}
}
-
static SalOp * sal_find_call(Sal *sal, int cid){
const MSList *elem;
SalOp *op;
return FALSE;
}
+static const char *days[]={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};\r
+static const char *months[]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
+
static void text_received(Sal *sal, eXosip_event_t *ev){
osip_body_t *body=NULL;
char *from=NULL,*msg=NULL;
int external_body_size=0;
SalMessage salmsg;
char message_id[256]={0};
+ osip_header_t *date=NULL;
+ struct tm ret={};
+ char tmp1[80]={0};
+ char tmp2[80]={0};
+ int i,j;
+
+ osip_message_get_date(ev->request,0,&date);
+ if(date==NULL){
+ ms_error("Could not get the date of message");
+ return;
+ }
+ sscanf(date->hvalue,"%3c,%d%s%d%d:%d:%d",tmp1,&ret.tm_mday,tmp2,
+ &ret.tm_year,&ret.tm_hour,&ret.tm_min,&ret.tm_sec);
+ ret.tm_year-=1900;
+ for(i=0;i<7;i++) {
+ if(strcmp(tmp1,days[i])==0) ret.tm_wday=i;
+ }
+ for(j=0;j<12;j++) {
+ if(strcmp(tmp2,months[j])==0) ret.tm_mon=j;
+ }
content_type= osip_message_get_content_type(ev->request);
if (!content_type) {
salmsg.text=msg;
salmsg.url=external_body_size>0 ? unquoted_external_body_url : NULL;
salmsg.message_id=message_id;
+ salmsg.time=mktime(&ret);
sal->callbacks.text_received(sal,&salmsg);
osip_free(from);
}
int sal_message_send(SalOp *op, const char *from, const char *to, const char* content_type, const char *msg){
osip_message_t *sip=NULL;
+ time_t t;
+ time(&t);
+ char buf[26];
if(op->cid == -1)
{
eXosip_message_build_request(&sip,"MESSAGE",sal_op_get_to(op),
sal_op_get_from(op),sal_op_get_route(op));
if (sip!=NULL){
+ osip_message_set_date(sip,ctime_r(&t,buf));
osip_message_set_content_type(sip,content_type);
if (msg) osip_message_set_body(sip,msg,strlen(msg));
sal_add_other(op->base.root,op,sip);
}
-void linphone_gtk_push_text(GtkWidget *w, const LinphoneAddress *from, const char *message, gboolean me,LinphoneChatRoom *cr){
+void linphone_gtk_push_text(GtkWidget *w, const LinphoneAddress *from,
+ const char *message, gboolean me,LinphoneChatRoom *cr, time_t t){
GtkTextView *text=GTK_TEXT_VIEW(linphone_gtk_get_widget(w,"textview"));
GtkTextBuffer *buffer=gtk_text_view_get_buffer(text);
GtkTextIter iter,begin,end;
}
g_object_set_data(G_OBJECT(linphone_gtk_get_main_window()),"history",hash);
+
+ gtk_text_buffer_get_end_iter(buffer,&iter);
+ list=g_list_append(list,GINT_TO_POINTER(gtk_text_iter_get_line(&iter)));
if(me){
- gtk_text_buffer_get_end_iter(buffer,&iter);
- list=g_list_append(list,GINT_TO_POINTER(gtk_text_iter_get_line(&iter)));
gtk_text_buffer_insert_with_tags_by_name(buffer,&iter,"Message in progress.. ",-1,
"italic","right","small","font_grey",NULL);
- gtk_text_buffer_get_end_iter(buffer,&iter);
- gtk_text_buffer_insert(buffer,&iter,"\n",-1);
- g_object_set_data(G_OBJECT(w),"list",list);
+ } else {
+ gtk_text_buffer_insert_with_tags_by_name(buffer,&iter,ctime(&t),-1,
+ "italic","right","small","font_grey",NULL);
}
+ gtk_text_buffer_get_end_iter(buffer,&iter);
+ gtk_text_buffer_insert(buffer,&iter,"\n",-1);
+ g_object_set_data(G_OBJECT(w),"list",list);
GtkTextMark *mark=gtk_text_buffer_create_mark(buffer,NULL,&iter,FALSE);
gtk_text_view_scroll_mark_onscreen(text,mark);
break;
default : result="Message in progress.. ";
}
-
- /*GDateTime *dt=g_date_time_new_now_local();
- char *time=g_date_time_format(dt,"%k:%M");
- gchar result2[80];
- sprintf(result2,"%s %s",result,time);*/
gtk_text_buffer_insert_with_tags_by_name(b,&iter,result,-1,
"italic","right","small","font_grey",NULL);
entered=gtk_entry_get_text(GTK_ENTRY(entry));
if (strlen(entered)>0) {
LinphoneChatMessage *msg;
+ msg=linphone_chat_room_create_message(cr,entered);
linphone_gtk_push_text(w,
linphone_gtk_get_used_identity(),
- entered,TRUE,cr);
- msg=linphone_chat_room_create_message(cr,entered);
+ entered,TRUE,cr,linphone_chat_message_get_time(msg));
linphone_chat_room_send_message2(cr,msg,on_chat_state_changed,NULL);
gtk_entry_set_text(GTK_ENTRY(entry),"");
}
}
-void linphone_gtk_text_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message){
+void linphone_gtk_text_received(LinphoneCore *lc, LinphoneChatRoom *room,
+ LinphoneChatMessage *msg){
GtkWidget *main_window=linphone_gtk_get_main_window();
GtkWidget *friendlist=linphone_gtk_get_widget(main_window,"contact_list");
GtkWidget *w;
- /*GDateTime *dt=g_date_time_new_now_local();
- char *time=g_date_time_format(dt,"%k:%M");*/
+
w=(GtkWidget*)g_object_get_data(G_OBJECT(friendlist),"chatview");
if(w!=NULL){
- linphone_gtk_load_chatroom(room,from,w);
+ linphone_gtk_load_chatroom(room,linphone_chat_message_get_from(msg),w);
} else {
- w=linphone_gtk_init_chatroom(room,from);
+ w=linphone_gtk_init_chatroom(room,linphone_chat_message_get_from(msg));
g_object_set_data(G_OBJECT(friendlist),"chatview",(gpointer)w);
- g_object_set_data(G_OBJECT(friendlist),"from",(gpointer)from);
+ g_object_set_data(G_OBJECT(friendlist),"from",(gpointer)linphone_chat_message_get_from(msg));
}
- const char *display=linphone_address_get_display_name(from);
+ const char *display=linphone_address_get_display_name(linphone_chat_message_get_from(msg));
if (display==NULL || display[0]=='\0') {
- display=linphone_address_get_username(from);
+ display=linphone_address_get_username(linphone_chat_message_get_from(msg));
}
#ifdef HAVE_GTK_OSXs
#else
if(!gtk_window_is_active(GTK_WINDOW(main_window))){
if(!GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w),"is_notified"))){
- /*gchar result2[80];
- sprintf(result2,"%s \n %s sent at %s",message,display,time);*/
- linphone_gtk_notify(NULL,message);
+ linphone_gtk_notify(NULL,linphone_chat_message_get_text(msg));
g_object_set_data(G_OBJECT(w),"is_notified",GINT_TO_POINTER(TRUE));
} else {
g_object_set_data(G_OBJECT(w),"is_notified",GINT_TO_POINTER(FALSE));
}
}
#endif
- linphone_gtk_push_text(w,from,message,FALSE,room);
+ linphone_gtk_push_text(w,linphone_chat_message_get_from(msg),
+ linphone_chat_message_get_text(msg),FALSE,room,linphone_chat_message_get_time(msg));
linphone_gtk_update_chat_picture();
//gtk_window_present(GTK_WINDOW(w));
/*gtk_window_set_urgency_hint(GTK_WINDOW(w),TRUE);*/
void linphone_gtk_fill_webcams(GtkWidget *pb);
void linphone_gtk_load_identities(void);
LinphoneChatRoom * linphone_gtk_create_chatroom(const LinphoneAddress *with);
-void linphone_gtk_text_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message);
+void linphone_gtk_text_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *msg);
void linphone_gtk_call_log_update(GtkWidget *w);
void linphone_gtk_create_log_window(void);
void linphone_gtk_log_show(void);
vtable.display_warning=linphone_gtk_display_warning;
vtable.display_url=linphone_gtk_display_url;
vtable.call_log_updated=linphone_gtk_call_log_updated;
- vtable.text_received=linphone_gtk_text_received;
+ //vtable.text_received=linphone_gtk_text_received;
+ vtable.message_received=linphone_gtk_text_received;
vtable.refer_received=linphone_gtk_refer_received;
vtable.buddy_info_updated=linphone_gtk_buddy_info_updated;
vtable.call_encryption_changed=linphone_gtk_call_encryption_changed;
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
+ <property name="padding">2</property>
<property name="position">0</property>
</packing>
</child>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
+ <property name="padding">6</property>
<property name="position">2</property>
</packing>
</child>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="padding">12</property>
+ <property name="padding">6</property>
<property name="position">0</property>
</packing>
</child>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
+ <property name="padding">6</property>
<property name="position">1</property>
</packing>
</child>