Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
liblinphone
Commits
1f089fd8
Commit
1f089fd8
authored
Jan 30, 2013
by
Margaux Clerc
Browse files
Add time in LinphoneChatMessage and SalMessage
parent
199133a7
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
83 additions
and
37 deletions
+83
-37
coreapi/callbacks.c
coreapi/callbacks.c
+1
-1
coreapi/chat.c
coreapi/chat.c
+12
-5
coreapi/linphonecore.h
coreapi/linphonecore.h
+8
-1
coreapi/private.h
coreapi/private.h
+2
-1
coreapi/sal.h
coreapi/sal.h
+1
-0
coreapi/sal_eXosip2.c
coreapi/sal_eXosip2.c
+24
-1
coreapi/sal_eXosip2_presence.c
coreapi/sal_eXosip2_presence.c
+4
-0
gtk/chat.c
gtk/chat.c
+24
-25
gtk/linphone.h
gtk/linphone.h
+1
-1
gtk/main.c
gtk/main.c
+2
-1
gtk/main.ui
gtk/main.ui
+4
-1
No files found.
coreapi/callbacks.c
View file @
1f089fd8
...
...
@@ -845,7 +845,7 @@ static bool_t is_duplicate_msg(LinphoneCore *lc, const char *msg_id){
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
);
}
}
...
...
coreapi/chat.c
View file @
1f089fd8
...
...
@@ -103,13 +103,13 @@ void linphone_chat_room_message_received(LinphoneChatRoom *cr, LinphoneCore *lc,
}
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
;
...
...
@@ -123,10 +123,12 @@ void linphone_core_message_received(LinphoneCore *lc, const char *from, const ch
/* 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
);
...
...
@@ -221,6 +223,11 @@ void linphone_chat_message_set_from(LinphoneChatMessage* message, const Linphone
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
;
}
...
...
coreapi/linphonecore.h
View file @
1f089fd8
...
...
@@ -735,7 +735,14 @@ void linphone_chat_message_set_external_body_url(LinphoneChatMessage* message,co
* 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
*/
...
...
coreapi/private.h
View file @
1f089fd8
...
...
@@ -103,6 +103,7 @@ struct _LinphoneChatMessage {
void
*
message_userdata
;
char
*
external_body_url
;
LinphoneAddress
*
from
;
time_t
time
;
};
typedef
struct
StunCandidate
{
...
...
@@ -279,7 +280,7 @@ void linphone_proxy_config_write_to_config_file(struct _LpConfig* config,Linphon
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
);
...
...
coreapi/sal.h
View file @
1f089fd8
...
...
@@ -195,6 +195,7 @@ typedef struct SalMessage{
const
char
*
text
;
const
char
*
url
;
const
char
*
message_id
;
time_t
time
;
}
SalMessage
;
#define SAL_MEDIA_DESCRIPTION_MAX_MESSAGE_ATTRIBUTES 5
...
...
coreapi/sal_eXosip2.c
View file @
1f089fd8
...
...
@@ -52,7 +52,6 @@ void sal_get_default_local_ip(Sal *sal, int address_family,char *ip, size_t iple
}
}
static
SalOp
*
sal_find_call
(
Sal
*
sal
,
int
cid
){
const
MSList
*
elem
;
SalOp
*
op
;
...
...
@@ -1766,6 +1765,9 @@ static bool_t comes_from_local_if(osip_message_t *msg){
return
FALSE
;
}
static
const
char
*
days
[]
=
{
"Sun"
,
"Mon"
,
"Tue"
,
"Wed"
,
"Thu"
,
"Fri"
,
"Sat"
};
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
;
...
...
@@ -1775,6 +1777,26 @@ static void text_received(Sal *sal, eXosip_event_t *ev){
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
)
{
...
...
@@ -1815,6 +1837,7 @@ static void text_received(Sal *sal, eXosip_event_t *ev){
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
);
}
...
...
coreapi/sal_eXosip2_presence.c
View file @
1f089fd8
...
...
@@ -83,6 +83,9 @@ void sal_remove_in_subscribe(Sal *sal, SalOp *op){
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
)
{
...
...
@@ -97,6 +100,7 @@ int sal_message_send(SalOp *op, const char *from, const char *to, const char* co
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
);
...
...
gtk/chat.c
View file @
1f089fd8
...
...
@@ -90,7 +90,8 @@ void udpate_tab_chat_header(GtkWidget *chat_view,const LinphoneAddress *uri,Linp
}
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
;
...
...
@@ -129,15 +130,19 @@ void linphone_gtk_push_text(GtkWidget *w, const LinphoneAddress *from, const cha
}
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
);
...
...
@@ -193,11 +198,6 @@ void update_chat_state_message(LinphoneChatMessageState state){
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
);
...
...
@@ -221,10 +221,10 @@ void linphone_gtk_send_text(){
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
),
""
);
}
...
...
@@ -338,25 +338,25 @@ void linphone_gtk_chat_close(GtkWidget *button){
}
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
...
...
@@ -365,16 +365,15 @@ void linphone_gtk_text_received(LinphoneCore *lc, LinphoneChatRoom *room, const
#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);*/
...
...
gtk/linphone.h
View file @
1f089fd8
...
...
@@ -74,7 +74,7 @@ void linphone_gtk_fill_soundcards(GtkWidget *pb);
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
Linphone
Address
*
from
,
const
char
*
message
);
void
linphone_gtk_text_received
(
LinphoneCore
*
lc
,
LinphoneChatRoom
*
room
,
Linphone
ChatMessage
*
msg
);
void
linphone_gtk_call_log_update
(
GtkWidget
*
w
);
void
linphone_gtk_create_log_window
(
void
);
void
linphone_gtk_log_show
(
void
);
...
...
gtk/main.c
View file @
1f089fd8
...
...
@@ -230,7 +230,8 @@ static void linphone_gtk_init_liblinphone(const char *config_file,
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
;
...
...
gtk/main.ui
View file @
1f089fd8
...
...
@@ -959,6 +959,7 @@
<packing>
<property
name=
"expand"
>
True
</property>
<property
name=
"fill"
>
True
</property>
<property
name=
"padding"
>
2
</property>
<property
name=
"position"
>
0
</property>
</packing>
</child>
...
...
@@ -987,6 +988,7 @@
<packing>
<property
name=
"expand"
>
False
</property>
<property
name=
"fill"
>
True
</property>
<property
name=
"padding"
>
6
</property>
<property
name=
"position"
>
2
</property>
</packing>
</child>
...
...
@@ -1116,7 +1118,7 @@
<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>
...
...
@@ -1384,6 +1386,7 @@
<packing>
<property
name=
"expand"
>
True
</property>
<property
name=
"fill"
>
True
</property>
<property
name=
"padding"
>
6
</property>
<property
name=
"position"
>
1
</property>
</packing>
</child>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment