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
8c9c9621
Commit
8c9c9621
authored
Jun 18, 2013
by
Ghislain MARY
Browse files
Use presence model to notify presence.
Use libxml2 to generate XML content.
parent
220c4713
Changes
14
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
861 additions
and
505 deletions
+861
-505
coreapi/bellesip_sal/sal_impl.c
coreapi/bellesip_sal/sal_impl.c
+2
-0
coreapi/bellesip_sal/sal_impl.h
coreapi/bellesip_sal/sal_impl.h
+1
-1
coreapi/bellesip_sal/sal_op_presence.c
coreapi/bellesip_sal/sal_op_presence.c
+13
-389
coreapi/bellesip_sal/sal_op_publish.c
coreapi/bellesip_sal/sal_op_publish.c
+4
-5
coreapi/callbacks.c
coreapi/callbacks.c
+29
-14
coreapi/friend.c
coreapi/friend.c
+16
-52
coreapi/linphonecall.c
coreapi/linphonecall.c
+6
-2
coreapi/linphonecore.c
coreapi/linphonecore.c
+116
-12
coreapi/linphonefriend.h
coreapi/linphonefriend.h
+19
-2
coreapi/linphonepresence.h
coreapi/linphonepresence.h
+10
-1
coreapi/presence.c
coreapi/presence.c
+634
-17
coreapi/private.h
coreapi/private.h
+4
-4
coreapi/proxy.c
coreapi/proxy.c
+3
-4
include/sal/sal.h
include/sal/sal.h
+4
-2
No files found.
coreapi/bellesip_sal/sal_impl.c
View file @
8c9c9621
...
...
@@ -488,6 +488,8 @@ void sal_set_callbacks(Sal *ctx, const SalCallbacks *cbs){
ctx
->
callbacks
.
subscribe_closed
=
(
SalOnSubscribeClosed
)
unimplemented_stub
;
if
(
ctx
->
callbacks
.
parse_presence_requested
==
NULL
)
ctx
->
callbacks
.
parse_presence_requested
=
(
SalOnParsePresenceRequested
)
unimplemented_stub
;
if
(
ctx
->
callbacks
.
convert_presence_to_xml_requested
==
NULL
)
ctx
->
callbacks
.
convert_presence_to_xml_requested
=
(
SalOnConvertPresenceToXMLRequested
)
unimplemented_stub
;
if
(
ctx
->
callbacks
.
notify_presence
==
NULL
)
ctx
->
callbacks
.
notify_presence
=
(
SalOnNotifyPresence
)
unimplemented_stub
;
if
(
ctx
->
callbacks
.
subscribe_presence_received
==
NULL
)
...
...
coreapi/bellesip_sal/sal_impl.h
View file @
8c9c9621
...
...
@@ -134,7 +134,7 @@ void sal_op_call_process_notify(SalOp *op, const belle_sip_request_event_t *even
SalAuthInfo
*
sal_auth_info_create
(
belle_sip_auth_event_t
*
event
)
;
void
sal_add_pending_auth
(
Sal
*
sal
,
SalOp
*
op
);
void
sal_remove_pending_auth
(
Sal
*
sal
,
SalOp
*
op
);
void
sal_add_presence_info
(
belle_sip_message_t
*
notify
,
SalPresence
Status
online_status
);
void
sal_add_presence_info
(
SalOp
*
op
,
belle_sip_message_t
*
notify
,
SalPresence
Model
*
presence
);
belle_sip_response_t
*
sal_create_response_from_request
(
Sal
*
sal
,
belle_sip_request_t
*
req
,
int
code
);
...
...
coreapi/bellesip_sal/sal_op_presence.c
View file @
8c9c9621
...
...
@@ -18,404 +18,28 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "sal_impl.h"
typedef
enum
{
PIDF
=
0
,
RFCxxxx
=
1
,
MSOLDPRES
=
2
}
presence_type_t
;
/*
* REVISIT: this static variable forces every dialog to use the same presence description type depending
* on what is received on a single dialog...
*/
static
presence_type_t
presence_style
=
PIDF
;
static
void
mk_presence_body
(
const
SalPresenceStatus
online_status
,
const
char
*
contact_info
,
char
*
buf
,
size_t
buflen
,
presence_type_t
ptype
)
{
switch
(
ptype
)
{
case
RFCxxxx
:
{
/* definition from http://msdn.microsoft.com/en-us/library/cc246202%28PROT.10%29.aspx */
int
atom_id
=
1000
;
if
(
online_status
==
SalPresenceOnline
)
{
snprintf
(
buf
,
buflen
,
"<?xml version=
\"
1.0
\"
?>
\n
\
<!DOCTYPE presence PUBLIC
\"
-//IETF//DTD RFCxxxx XPIDF 1.0//EN
\"
\"
xpidf.dtd
\"
>
\n
\
<presence>
\n
\
<presentity uri=
\"
%s;method=SUBSCRIBE
\"
/>
\n
\
<atom id=
\"
%i
\"
>
\n
\
<address uri=
\"
%s
\"
priority=
\"
0.800000
\"
>
\n
\
<status status=
\"
open
\"
/>
\n
\
<msnsubstatus substatus=
\"
online
\"
/>
\n
\
</address>
\n
\
</atom>
\n
\
</presence>"
,
contact_info
,
atom_id
,
contact_info
);
}
else
if
(
online_status
==
SalPresenceBusy
||
online_status
==
SalPresenceDonotdisturb
)
{
snprintf
(
buf
,
buflen
,
"<?xml version=
\"
1.0
\"
?>
\n
\
<!DOCTYPE presence PUBLIC
\"
-//IETF//DTD RFCxxxx XPIDF 1.0//EN
\"
\"
xpidf.dtd
\"
>
\n
\
<presence>
\n
\
<presentity uri=
\"
%s;method=SUBSCRIBE
\"
/>
\n
\
<atom id=
\"
%i
\"
>
\n
\
<address uri=
\"
%s
\"
priority=
\"
0.800000
\"
>
\n
\
<status status=
\"
inuse
\"
/>
\n
\
<msnsubstatus substatus=
\"
busy
\"
/>
\n
\
</address>
\n
\
</atom>
\n
</presence>"
,
contact_info
,
atom_id
,
contact_info
);
}
else
if
(
online_status
==
SalPresenceBerightback
)
{
snprintf
(
buf
,
buflen
,
"<?xml version=
\"
1.0
\"
?>
\n
\
<!DOCTYPE presence PUBLIC
\"
-//IETF//DTD RFCxxxx XPIDF 1.0//EN
\"
\"
xpidf.dtd
\"
>
\n
\
<presence>
\n
\
<presentity uri=
\"
%s;method=SUBSCRIBE
\"
/>
\n
\
<atom id=
\"
%i
\"
>
\n
\
<address uri=
\"
%s
\"
priority=
\"
0.800000
\"
>
\n
\
<status status=
\"
open
\"
/>
\n
\
<msnsubstatus substatus=
\"
berightback
\"
/>
\n
\
</address>
\n
\
</atom>
\n
\
</presence>"
,
contact_info
,
atom_id
,
contact_info
);
}
else
if
(
online_status
==
SalPresenceAway
||
online_status
==
SalPresenceMoved
)
{
snprintf
(
buf
,
buflen
,
"<?xml version=
\"
1.0
\"
?>
\n
\
<!DOCTYPE presence PUBLIC
\"
-//IETF//DTD RFCxxxx XPIDF 1.0//EN
\"
\"
xpidf.dtd
\"
>
\n
\
<presence>
\n
\
<presentity uri=
\"
%s;method=SUBSCRIBE
\"
/>
\n
\
<atom id=
\"
%i
\"
>
\n
\
<address uri=
\"
%s
\"
priority=
\"
0.800000
\"
>
\n
\
<status status=
\"
open
\"
/>
\n
\
<msnsubstatus substatus=
\"
away
\"
/>
\n
\
</address>
\n
\
</atom>
\n
\
</presence>"
,
contact_info
,
atom_id
,
contact_info
);
}
else
if
(
online_status
==
SalPresenceOnthephone
)
{
snprintf
(
buf
,
buflen
,
"<?xml version=
\"
1.0
\"
?>
\n
\
<!DOCTYPE presence PUBLIC
\"
-//IETF//DTD RFCxxxx XPIDF 1.0//EN
\"
\"
xpidf.dtd
\"
>
\n
\
<presence>
\n
\
<presentity uri=
\"
%s;method=SUBSCRIBE
\"
/>
\n
\
<atom id=
\"
%i
\"
>
\n
\
<address uri=
\"
%s
\"
priority=
\"
0.800000
\"
>
\n
\
<status status=
\"
inuse
\"
/>
\n
\
<msnsubstatus substatus=
\"
onthephone
\"
/>
\n
\
</address>
\n
\
</atom>
\n
\
</presence>"
,
contact_info
,
atom_id
,
contact_info
);
}
else
if
(
online_status
==
SalPresenceOuttolunch
)
{
snprintf
(
buf
,
buflen
,
"<?xml version=
\"
1.0
\"
?>
\n
\
<!DOCTYPE presence PUBLIC
\"
-//IETF//DTD RFCxxxx XPIDF 1.0//EN
\"
\"
xpidf.dtd
\"
>
\n
\
<presence>
\n
\
<presentity uri=
\"
%s;method=SUBSCRIBE
\"
/>
\n
\
<atom id=
\"
%i
\"
>
\n
\
<address uri=
\"
%s
\"
priority=
\"
0.800000
\"
>
\n
\
<status status=
\"
open
\"
/>
\n
\
<msnsubstatus substatus=
\"
outtolunch
\"
/>
\n
\
</address>
\n
\
</atom>
\n
\
</presence>"
,
contact_info
,
atom_id
,
contact_info
);
}
else
{
snprintf
(
buf
,
buflen
,
"<?xml version=
\"
1.0
\"
?>
\n
\
<!DOCTYPE presence PUBLIC
\"
-//IETF//DTD RFCxxxx XPIDF 1.0//EN
\"
\"
xpidf.dtd
\"
>
\n
\
<presence>
\n
\
<presentity uri=
\"
%s;method=SUBSCRIBE
\"
/>
\n
\
<atom id=
\"
%i
\"
>
\n
\
<address uri=
\"
%s
\"
priority=
\"
0.800000
\"
>
\n
\
<status status=
\"
closed
\"
/>
\n
\
<msnsubstatus substatus=
\"
away
\"
/>
\n
\
</address>
\n
\
</atom>
\n
\
</presence>"
,
contact_info
,
atom_id
,
contact_info
);
}
break
;
}
case
MSOLDPRES
:
{
/* Couldn't find schema http://schemas.microsoft.com/2002/09/sip/presence
* so messages format has been taken from Communigate that can send notify
* requests with this schema
*/
int
atom_id
=
1000
;
if
(
online_status
==
SalPresenceOnline
)
{
snprintf
(
buf
,
buflen
,
"<?xml version=
\"
1.0
\"
?>
\n
\
<!DOCTYPE presence SYSTEM
\"
http://schemas.microsoft.com/2002/09/sip/presence
\"
>
\n
\
<presence>
\n
\
<presentity uri=
\"
%s;method=SUBSCRIBE
\"
/>
\n
\
<atom id=
\"
%i
\"
>
\n
\
<address uri=
\"
%s
\"
>
\n
\
<status status=
\"
open
\"
/>
\n
\
<msnsubstatus substatus=
\"
online
\"
/>
\n
\
</address>
\n
\
</atom>
\n
\
</presence>"
,
contact_info
,
atom_id
,
contact_info
);
}
else
if
(
online_status
==
SalPresenceBusy
||
online_status
==
SalPresenceDonotdisturb
)
{
snprintf
(
buf
,
buflen
,
"<?xml version=
\"
1.0
\"
?>
\n
\
<!DOCTYPE presence SYSTEM
\"
http://schemas.microsoft.com/2002/09/sip/presence
\"
>
\n
\
<presence>
\n
\
<presentity uri=
\"
%s;method=SUBSCRIBE
\"
/>
\n
\
<atom id=
\"
%i
\"
>
\n
\
<address uri=
\"
%s
\"
>
\n
\
<status status=
\"
inuse
\"
/>
\n
\
<msnsubstatus substatus=
\"
busy
\"
/>
\n
\
</address>
\n
\
</atom>
\n
</presence>"
,
contact_info
,
atom_id
,
contact_info
);
}
else
if
(
online_status
==
SalPresenceBerightback
)
{
snprintf
(
buf
,
buflen
,
"<?xml version=
\"
1.0
\"
?>
\n
\
<!DOCTYPE presence SYSTEM
\"
http://schemas.microsoft.com/2002/09/sip/presence
\"
>
\n
\
<presence>
\n
\
<presentity uri=
\"
%s;method=SUBSCRIBE
\"
/>
\n
\
<atom id=
\"
%i
\"
>
\n
\
<address uri=
\"
%s
\"
>
\n
\
<status status=
\"
inactive
\"
/>
\n
\
<msnsubstatus substatus=
\"
berightback
\"
/>
\n
\
</address>
\n
\
</atom>
\n
\
</presence>"
,
contact_info
,
atom_id
,
contact_info
);
}
else
if
(
online_status
==
SalPresenceAway
||
online_status
==
SalPresenceMoved
)
{
snprintf
(
buf
,
buflen
,
"<?xml version=
\"
1.0
\"
?>
\n
\
<!DOCTYPE presence SYSTEM
\"
http://schemas.microsoft.com/2002/09/sip/presence
\"
>
\n
\
<presence>
\n
\
<presentity uri=
\"
%s;method=SUBSCRIBE
\"
/>
\n
\
<atom id=
\"
%i
\"
>
\n
\
<address uri=
\"
%s
\"
>
\n
\
<status status=
\"
inactive
\"
/>
\n
\
<msnsubstatus substatus=
\"
idle
\"
/>
\n
\
</address>
\n
\
</atom>
\n
\
</presence>"
,
contact_info
,
atom_id
,
contact_info
);
}
else
if
(
online_status
==
SalPresenceOnthephone
)
{
snprintf
(
buf
,
buflen
,
"<?xml version=
\"
1.0
\"
?>
\n
\
<!DOCTYPE presence SYSTEM
\"
http://schemas.microsoft.com/2002/09/sip/presence
\"
>
\n
\
<presence>
\n
\
<presentity uri=
\"
%s;method=SUBSCRIBE
\"
/>
\n
\
<atom id=
\"
%i
\"
>
\n
\
<address uri=
\"
%s
\"
>
\n
\
<status status=
\"
inuse
\"
/>
\n
\
<msnsubstatus substatus=
\"
onthephone
\"
/>
\n
\
</address>
\n
\
</atom>
\n
\
</presence>"
,
contact_info
,
atom_id
,
contact_info
);
}
else
if
(
online_status
==
SalPresenceOuttolunch
)
{
snprintf
(
buf
,
buflen
,
"<?xml version=
\"
1.0
\"
?>
\n
\
<!DOCTYPE presence SYSTEM
\"
http://schemas.microsoft.com/2002/09/sip/presence
\"
>
\n
\
<presence>
\n
\
<presentity uri=
\"
%s;method=SUBSCRIBE
\"
/>
\n
\
<atom id=
\"
%i
\"
>
\n
\
<address uri=
\"
%s
\"
>
\n
\
<status status=
\"
inactive
\"
/>
\n
\
<msnsubstatus substatus=
\"
outtolunch
\"
/>
\n
\
</address>
\n
\
</atom>
\n
\
</presence>"
,
contact_info
,
atom_id
,
contact_info
);
}
else
{
snprintf
(
buf
,
buflen
,
"<?xml version=
\"
1.0
\"
?>
\n
\
<!DOCTYPE presence SYSTEM
\"
http://schemas.microsoft.com/2002/09/sip/presence
\"
>
\n
\
<presence>
\n
\
<presentity uri=
\"
%s;method=SUBSCRIBE
\"
/>
\n
\
<atom id=
\"
%i
\"
>
\n
\
<address uri=
\"
%s
\"
>
\n
\
<status status=
\"
closed
\"
/>
\n
\
<msnsubstatus substatus=
\"
offline
\"
/>
\n
\
</address>
\n
\
</atom>
\n
\
</presence>"
,
contact_info
,
atom_id
,
contact_info
);
}
break
;
}
default:
{
/* use pidf+xml as default format, rfc4479, rfc4480, rfc3863 */
if
(
online_status
==
SalPresenceOnline
)
{
snprintf
(
buf
,
buflen
,
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?>
\n
\
<presence xmlns=
\"
urn:ietf:params:xml:ns:pidf
\"
\
xmlns:dm=
\"
urn:ietf:params:xml:ns:pidf:data-model
\"
\
xmlns:rpid=
\"
urn:ietf:params:xml:ns:pidf:rpid
\"
\
entity=
\"
%s
\"
>
\n
\
<tuple id=
\"
sg89ae
\"
>
\n
\
<status><basic>open</basic></status>
\n
\
<contact priority=
\"
0.8
\"
>%s</contact>
\n
\
</tuple>
\n
\
</presence>"
,
contact_info
,
contact_info
);
}
else
if
(
online_status
==
SalPresenceBusy
||
online_status
==
SalPresenceDonotdisturb
)
{
snprintf
(
buf
,
buflen
,
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?>
\n
\
<presence xmlns=
\"
urn:ietf:params:xml:ns:pidf
\"
\
xmlns:dm=
\"
urn:ietf:params:xml:ns:pidf:data-model
\"
\
xmlns:rpid=
\"
urn:ietf:params:xml:ns:pidf:rpid
\"
\
entity=
\"
%s
\"
>
\n
\
<tuple id=
\"
sg89ae
\"
>
\n
\
<status><basic>open</basic></status>
\n
\
<contact priority=
\"
0.8
\"
>%s</contact>
\n
\
</tuple>
\n
\
<dm:person id=
\"
sg89aep
\"
>
\n
\
<rpid:activities><rpid:busy/></rpid:activities>
\n
\
</dm:person>
\n
\
</presence>"
,
contact_info
,
contact_info
);
}
else
if
(
online_status
==
SalPresenceBerightback
)
{
snprintf
(
buf
,
buflen
,
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?>
\n
\
<presence xmlns=
\"
urn:ietf:params:xml:ns:pidf
\"
\
xmlns:dm=
\"
urn:ietf:params:xml:ns:pidf:data-model
\"
\
xmlns:rpid=
\"
urn:ietf:params:xml:ns:pidf:rpid
\"
\
entity=
\"
%s
\"
>
\n
\
<tuple id=
\"
sg89ae
\"
>
\n
\
<status><basic>open</basic></status>
\n
\
<contact priority=
\"
0.8
\"
>%s</contact>
\n
\
</tuple>
\n
\
<dm:person id=
\"
sg89aep
\"
>
\n
\
<rpid:activities><rpid:in-transit/></rpid:activities>
\n
\
</dm:person>
\n
\
</presence>"
,
contact_info
,
contact_info
);
}
else
if
(
online_status
==
SalPresenceAway
||
online_status
==
SalPresenceMoved
)
{
snprintf
(
buf
,
buflen
,
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?>
\n
\
<presence xmlns=
\"
urn:ietf:params:xml:ns:pidf
\"
\
xmlns:dm=
\"
urn:ietf:params:xml:ns:pidf:data-model
\"
\
xmlns:rpid=
\"
urn:ietf:params:xml:ns:pidf:rpid
\"
\
entity=
\"
%s
\"
>
\n
\
<tuple id=
\"
sg89ae
\"
>
\n
\
<status><basic>open</basic></status>
\n
\
<contact priority=
\"
0.8
\"
>%s</contact>
\n
\
</tuple>
\n
\
<dm:person id=
\"
sg89aep
\"
>
\n
\
<rpid:activities><rpid:away/></rpid:activities>
\n
\
</dm:person>
\n
\
</presence>"
,
contact_info
,
contact_info
);
}
else
if
(
online_status
==
SalPresenceOnVacation
)
{
snprintf
(
buf
,
buflen
,
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?>
\n
\
<presence xmlns=
\"
urn:ietf:params:xml:ns:pidf
\"
\
xmlns:dm=
\"
urn:ietf:params:xml:ns:pidf:data-model
\"
\
xmlns:rpid=
\"
urn:ietf:params:xml:ns:pidf:rpid
\"
\
entity=
\"
%s
\"
>
\n
\
<tuple id=
\"
sg89ae
\"
>
\n
\
<status><basic>open</basic></status>
\n
\
<contact priority=
\"
0.8
\"
>%s</contact>
\n
\
</tuple>
\n
\
<dm:person id=
\"
sg89aep
\"
>
\n
\
<rpid:activities><rpid:vacation/></rpid:activities>
\n
\
</dm:person>
\n
\
</presence>"
,
contact_info
,
contact_info
);
}
else
if
(
online_status
==
SalPresenceOnthephone
)
{
snprintf
(
buf
,
buflen
,
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?>
\n
\
<presence xmlns=
\"
urn:ietf:params:xml:ns:pidf
\"
\
xmlns:dm=
\"
urn:ietf:params:xml:ns:pidf:data-model
\"
\
xmlns:rpid=
\"
urn:ietf:params:xml:ns:pidf:rpid
\"
\
entity=
\"
%s
\"
>
\n
\
<tuple id=
\"
sg89ae
\"
>
\n
\
<status><basic>open</basic></status>
\n
\
<contact priority=
\"
0.8
\"
>%s</contact>
\n
\
</tuple>
\n
\
<dm:person id=
\"
sg89aep
\"
>
\n
\
<rpid:activities><rpid:on-the-phone/></rpid:activities>
\n
\
</dm:person>
\n
\
</presence>"
,
contact_info
,
contact_info
);
}
else
if
(
online_status
==
SalPresenceOuttolunch
)
{
snprintf
(
buf
,
buflen
,
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?>
\n
\
<presence xmlns=
\"
urn:ietf:params:xml:ns:pidf
\"
\
xmlns:dm=
\"
urn:ietf:params:xml:ns:pidf:data-model
\"
\
xmlns:rpid=
\"
urn:ietf:params:xml:ns:pidf:rpid
\"
\
entity=
\"
%s
\"
>
\n
\
<tuple id=
\"
7777
\"
>
\n
\
<status><basic>open</basic></status>
\n
\
<contact priority=
\"
0.8
\"
>%s</contact>
\n
\
</tuple>
\n
\
<dm:person id=
\"
78787878
\"
>
\n
\
<rpid:activities><rpid:lunch/></rpid:activities>
\n
\
<rpid:note>Out to lunch</rpid:note>
\n
\
</dm:person>
\n
\
</presence>"
,
contact_info
,
contact_info
);
}
else
{
snprintf
(
buf
,
buflen
,
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?>
\n
\
<presence xmlns=
\"
urn:ietf:params:xml:ns:pidf
\"
\
xmlns:dm=
\"
urn:ietf:params:xml:ns:pidf:data-model
\"
\
xmlns:rpid=
\"
urn:ietf:params:xml:ns:pidf:rpid
\"
\
entity=
\"
%s
\"
>
\n
\
<tuple id=
\"
sg89ae
\"
>
\n
\
<status><basic>closed</basic></status>
\n
\
<contact priority=
\"
0.8
\"
>%s</contact>
\n
\
</tuple>
\n
\
</presence>
\n
"
,
contact_info
,
contact_info
);
}
break
;
}
}
// switch
}
void
sal_add_presence_info
(
belle_sip_message_t
*
notify
,
SalPresenceStatus
online_status
)
{
char
buf
[
1000
];
void
sal_add_presence_info
(
SalOp
*
op
,
belle_sip_message_t
*
notify
,
SalPresenceModel
*
presence
)
{
char
*
contact_info
;
char
*
content
=
NULL
;
size_t
content_length
;
belle_sip_header_from_t
*
from
=
belle_sip_message_get_header_by_type
(
notify
,
belle_sip_header_from_t
);
contact_info
=
belle_sip_uri_to_string
(
belle_sip_header_address_get_uri
(
BELLE_SIP_HEADER_ADDRESS
(
from
)));
mk_presence_body
(
online_status
,
contact_info
,
buf
,
sizeof
(
buf
),
presence_style
);
op
->
base
.
root
->
callbacks
.
convert_presence_to_xml_requested
(
op
,
presence
,
contact_info
,
&
content
);
if
(
content
==
NULL
)
{
ms_free
(
contact_info
);
return
;
}
belle_sip_message_remove_header
(
BELLE_SIP_MESSAGE
(
notify
),
BELLE_SIP_CONTENT_TYPE
);
belle_sip_message_add_header
(
BELLE_SIP_MESSAGE
(
notify
)
,
BELLE_SIP_HEADER
(
belle_sip_header_content_type_create
(
"application"
,
presence_style
?
"xpidf+xml"
:
"pidf+xml"
)));
,
BELLE_SIP_HEADER
(
belle_sip_header_content_type_create
(
"application"
,
"pidf+xml"
)));
belle_sip_message_remove_header
(
BELLE_SIP_MESSAGE
(
notify
),
BELLE_SIP_CONTENT_LENGTH
);
belle_sip_message_add_header
(
BELLE_SIP_MESSAGE
(
notify
)
,
BELLE_SIP_HEADER
(
belle_sip_header_content_length_create
(
content_length
=
strlen
(
buf
))));
belle_sip_message_set_body
(
BELLE_SIP_MESSAGE
(
notify
),
buf
,
content_length
);
,
BELLE_SIP_HEADER
(
belle_sip_header_content_length_create
(
content_length
=
strlen
(
content
))));
belle_sip_message_set_body
(
BELLE_SIP_MESSAGE
(
notify
),
content
,
content_length
);
ms_free
(
contact_info
);
}
...
...
@@ -627,9 +251,9 @@ static belle_sip_request_t *create_presence_notify(SalOp *op){
return
notify
;
}
int
sal_notify_presence
(
SalOp
*
op
,
SalPresence
Status
status
,
const
char
*
status_messag
e
){
int
sal_notify_presence
(
SalOp
*
op
,
SalPresence
Model
*
presenc
e
){
belle_sip_request_t
*
notify
=
create_presence_notify
(
op
);
sal_add_presence_info
(
BELLE_SIP_MESSAGE
(
notify
),
status
);
/*FIXME, what about expires ??*/
sal_add_presence_info
(
op
,
BELLE_SIP_MESSAGE
(
notify
),
presence
);
/*FIXME, what about expires ??*/
belle_sip_message_add_header
(
BELLE_SIP_MESSAGE
(
notify
)
,
BELLE_SIP_HEADER
(
belle_sip_header_subscription_state_create
(
BELLE_SIP_SUBSCRIPTION_STATE_ACTIVE
,
600
)));
return
sal_op_send_request
(
op
,
notify
);
...
...
@@ -637,7 +261,7 @@ int sal_notify_presence(SalOp *op, SalPresenceStatus status, const char *status_
int
sal_notify_presence_close
(
SalOp
*
op
){
belle_sip_request_t
*
notify
=
create_presence_notify
(
op
);
sal_add_presence_info
(
BELLE_SIP_MESSAGE
(
notify
),
SalPresenceOffline
);
/*FIXME, what about expires ??*/
sal_add_presence_info
(
op
,
BELLE_SIP_MESSAGE
(
notify
),
NULL
);
/*FIXME, what about expires ??*/
belle_sip_message_add_header
(
BELLE_SIP_MESSAGE
(
notify
)
,
BELLE_SIP_HEADER
(
belle_sip_header_subscription_state_create
(
BELLE_SIP_SUBSCRIPTION_STATE_TERMINATED
,
-
1
)));
return
sal_op_send_request
(
op
,
notify
);
...
...
coreapi/bellesip_sal/sal_op_publish.c
View file @
8c9c9621
...
...
@@ -30,7 +30,7 @@ static void publish_refresher_listener ( const belle_sip_refresher_t* refresher
}
/*presence publish */
int
sal_publish_presence
(
SalOp
*
op
,
const
char
*
from
,
const
char
*
to
,
SalPresence
Status
status
){
int
sal_publish_presence
(
SalOp
*
op
,
const
char
*
from
,
const
char
*
to
,
SalPresence
Model
*
presence
){
belle_sip_request_t
*
req
=
NULL
;
if
(
!
op
->
refresher
||
!
belle_sip_refresher_get_transaction
(
op
->
refresher
))
{
if
(
from
)
...
...
@@ -41,14 +41,13 @@ int sal_publish_presence(SalOp *op, const char *from, const char *to, SalPresenc
op
->
type
=
SalOpPublish
;
req
=
sal_op_build_request
(
op
,
"PUBLISH"
);
belle_sip_message_add_header
(
BELLE_SIP_MESSAGE
(
req
),
belle_sip_header_create
(
"Event"
,
"presence"
));
sal_add_presence_info
(
BELLE_SIP_MESSAGE
(
req
),
status
);
sal_add_presence_info
(
op
,
BELLE_SIP_MESSAGE
(
req
),
presence
);
return
sal_op_send_and_create_refresher
(
op
,
req
,
600
,
publish_refresher_listener
);
}
else
{
/*update status*/
/*update
presence
status*/
const
belle_sip_client_transaction_t
*
last_publish_trans
=
belle_sip_refresher_get_transaction
(
op
->
refresher
);
belle_sip_request_t
*
last_publish
=
belle_sip_transaction_get_request
(
BELLE_SIP_TRANSACTION
(
last_publish_trans
));
/*update status*/
sal_add_presence_info
(
BELLE_SIP_MESSAGE
(
last_publish
),
status
);
sal_add_presence_info
(
op
,
BELLE_SIP_MESSAGE
(
last_publish
),
presence
);
return
belle_sip_refresher_refresh
(
op
->
refresher
,
BELLE_SIP_REFRESHER_REUSE_EXPIRES
);
}
}
...
...
coreapi/callbacks.c
View file @
8c9c9621
...
...
@@ -219,21 +219,31 @@ static void call_received(SalOp *h){
bool_t
prevent_colliding_calls
=
lp_config_get_int
(
lc
->
config
,
"sip"
,
"prevent_colliding_calls"
,
TRUE
);
/* first check if we can answer successfully to this invite */
if
(
lc
->
presence_mode
==
LinphoneStatusBusy
||
lc
->
presence_mode
==
LinphoneStatusOffline
||
lc
->
presence_mode
==
LinphoneStatusDoNotDisturb
||
lc
->
presence_mode
==
LinphoneStatusMoved
){
if
(
lc
->
presence_mode
==
LinphoneStatusBusy
)
sal_call_decline
(
h
,
SalReasonBusy
,
NULL
);
else
if
(
lc
->
presence_mode
==
LinphoneStatusOffline
)
sal_call_decline
(
h
,
SalReasonTemporarilyUnavailable
,
NULL
);
else
if
(
lc
->
presence_mode
==
LinphoneStatusDoNotDisturb
)
sal_call_decline
(
h
,
SalReasonTemporarilyUnavailable
,
NULL
);
else
if
(
lc
->
alt_contact
!=
NULL
&&
lc
->
presence_mode
==
LinphoneStatusMoved
)
sal_call_decline
(
h
,
SalReasonRedirect
,
lc
->
alt_contact
);
sal_op_release
(
h
);
return
;
if
(
linphone_presence_model_get_basic_status
(
lc
->
presence_model
)
==
LinphonePresenceBasicStatusClosed
)
{
LinphonePresenceActivity
activity
=
LinphonePresenceActivityOffline
;
if
(
linphone_presence_model_get_activity
(
lc
->
presence_model
,
&
activity
,
NULL
))
{
switch
(
activity
)
{
case
LinphonePresenceActivityBusy
:
sal_call_decline
(
h
,
SalReasonBusy
,
NULL
);
break
;
case
LinphonePresenceActivityAppointment
:
case
LinphonePresenceActivityMeeting
:
case
LinphonePresenceActivityOffline
:
case
LinphonePresenceActivityWorship
:
sal_call_decline
(
h
,
SalReasonTemporarilyUnavailable
,
NULL
);
break
;
case
LinphonePresenceActivityPermanentAbsence
:
if
(
lc
->
alt_contact
!=
NULL
)
sal_call_decline
(
h
,
SalReasonRedirect
,
lc
->
alt_contact
);
break
;
default:
break
;
}
sal_op_release
(
h
);
return
;
}
}
if
(
!
linphone_core_can_we_add_call
(
lc
)){
/*busy*/
sal_call_decline
(
h
,
SalReasonBusy
,
NULL
);
sal_op_release
(
h
);
...
...
@@ -881,6 +891,10 @@ static void parse_presence_requested(SalOp *op, const char *content_type, const
linphone_notify_parse_presence
(
op
,
content_type
,
content_subtype
,
body
,
result
);
}
static
void
convert_presence_to_xml_requested
(
SalOp
*
op
,
SalPresenceModel
*
presence
,
const
char
*
contact
,
char
**
content
)
{
linphone_notify_convert_presence_to_xml
(
op
,
presence
,
contact
,
content
);
}
static
void
notify_presence
(
SalOp
*
op
,
SalSubscribeStatus
ss
,
SalPresenceModel
*
model
,
const
char
*
msg
){
LinphoneCore
*
lc
=
(
LinphoneCore
*
)
sal_get_user_pointer
(
sal_op_get_sal
(
op
));
linphone_notify_recv
(
lc
,
op
,
ss
,
model
);
...
...
@@ -1090,6 +1104,7 @@ SalCallbacks linphone_sal_callbacks={
subscribe_presence_received
,
subscribe_presence_closed
,
parse_presence_requested
,
convert_presence_to_xml_requested
,
notify_presence
,
ping_reply
,
auth_requested
,
...
...
coreapi/friend.c
View file @
8c9c9621
...
...
@@ -226,57 +226,12 @@ int linphone_friend_set_inc_subscribe_policy(LinphoneFriend *fr, LinphoneSubscri
return
0
;
}
SalPresenceStatus
linphone_online_status_to_sal
(
LinphoneOnlineStatus
os
){
switch
(
os
){
case
LinphoneStatusOffline
:
return
SalPresenceOffline
;
break
;
case
LinphoneStatusOnline
:
return
SalPresenceOnline
;
break
;
case
LinphoneStatusBusy
:
return
SalPresenceBusy
;
break
;
case
LinphoneStatusBeRightBack
:
return
SalPresenceBerightback
;
break
;
case
LinphoneStatusAway
:
return
SalPresenceAway
;
break
;
case
LinphoneStatusOnThePhone
:
return
SalPresenceOnthephone
;
break
;
case
LinphoneStatusOutToLunch
:
return
SalPresenceOuttolunch
;
break
;
case
LinphoneStatusDoNotDisturb
:
return
SalPresenceDonotdisturb
;
break
;
case
LinphoneStatusMoved
:
return
SalPresenceMoved
;
break
;
case
LinphoneStatusAltService
:
return
SalPresenceAltService
;
break
;
case
LinphoneStatusPending
: