Sip subscribe presence

Version 14 (Adrian Georgescu, 02/22/2009 03:06 pm)

1 8 Adrian Georgescu
== sip_subscribe_presence ==
2 10 Adrian Georgescu
[[TOC(SipTesting*, sip_*, depth=2)]]
3 1 Adrian Georgescu
4 14 Adrian Georgescu
To use this script you must to have a valid [wiki:SipConfiguration configuration file] with appropriate Presence settings. To test this script you can subscribe to sip:alice@ag-projects.com.
5 13 Adrian Georgescu
6 1 Adrian Georgescu
7 8 Adrian Georgescu
=== Description ===
8 1 Adrian Georgescu
9 11 Adrian Georgescu
[[Image(http://www.openxcap.org/chrome/site/SIMPLE-Server.png, nolink)]]
10 4 Adrian Georgescu
11 3 Adrian Georgescu
Source code: [source:scripts/sip_subscribe_presence.py scripts/sip_subscribe_presence.py]
12 3 Adrian Georgescu
13 1 Adrian Georgescu
{{{
14 1 Adrian Georgescu
adigeo@ag-imac3:~$sip_subscribe_presence -h
15 5 Adrian Georgescu
Usage: sip_subscribe_presence [options] [target-user@target-domain.com]
16 1 Adrian Georgescu
17 5 Adrian Georgescu
This script will SUBSCRIBE to the presence event published by the specified
18 5 Adrian Georgescu
SIP target. If a SIP target is not specified, it will subscribe to its own
19 5 Adrian Georgescu
address. It will then interprete PIDF bodies contained in NOTIFYs and display
20 5 Adrian Georgescu
their meaning. The program will un-SUBSCRIBE and quit when CTRL+D is pressed.
21 1 Adrian Georgescu
22 1 Adrian Georgescu
Options:
23 1 Adrian Georgescu
  -h, --help            show this help message and exit
24 1 Adrian Georgescu
  -a NAME, --account-name=NAME
25 1 Adrian Georgescu
                        The account name from which to read account settings.
26 1 Adrian Georgescu
                        Corresponds to section Account_NAME in the
27 1 Adrian Georgescu
                        configuration file. If not supplied, the section
28 1 Adrian Georgescu
                        Account will be read.
29 1 Adrian Georgescu
  --sip-address=SIP_ADDRESS
30 1 Adrian Georgescu
                        SIP address of the user in the form user@domain
31 1 Adrian Georgescu
  -p PASSWORD, --password=PASSWORD
32 1 Adrian Georgescu
                        Password to use to authenticate the local account.
33 1 Adrian Georgescu
                        This overrides the setting from the config file.
34 1 Adrian Georgescu
  -n DISPLAY_NAME, --display-name=DISPLAY_NAME
35 1 Adrian Georgescu
                        Display name to use for the local account. This
36 1 Adrian Georgescu
                        overrides the setting from the config file.
37 1 Adrian Georgescu
  -e EXPIRES, --expires=EXPIRES
38 1 Adrian Georgescu
                        "Expires" value to set in SUBSCRIBE. Default is 300
39 1 Adrian Georgescu
                        seconds.
40 1 Adrian Georgescu
  -o IP[:PORT], --outbound-proxy=IP[:PORT]
41 1 Adrian Georgescu
                        Outbound SIP proxy to use. By default a lookup of the
42 1 Adrian Georgescu
                        domain is performed based on SRV and A records. This
43 1 Adrian Georgescu
                        overrides the setting from the config file.
44 1 Adrian Georgescu
  -c CONTENT_TYPE, --content-type=CONTENT_TYPE
45 1 Adrian Georgescu
                        "Content-Type" the UA expects to receving in a NOTIFY
46 1 Adrian Georgescu
                        for this subscription. For the known events this does
47 1 Adrian Georgescu
                        not need to be specified, but may be overridden".
48 1 Adrian Georgescu
  -s, --trace-sip       Dump the raw contents of incoming and outgoing SIP
49 1 Adrian Georgescu
                        messages (disabled by default).
50 1 Adrian Georgescu
  -l, --log-pjsip       Print PJSIP logging output (disabled by default).
51 1 Adrian Georgescu
}}}
52 2 Adrian Georgescu
53 8 Adrian Georgescu
=== Example ===
54 2 Adrian Georgescu
55 2 Adrian Georgescu
{{{
56 2 Adrian Georgescu
adigeo@ag-imac3:~$sip_subscribe_presence -a umts ag@ag-projects.com
57 2 Adrian Georgescu
Accounts available: 'alice', 'ew', 'mrg', 'pbx', 'tf', 'umts', 'unet', default
58 2 Adrian Georgescu
Using account 'umts': adi@umts.ro
59 2 Adrian Georgescu
Resolved DNS SRV record "_sip._udp.umts.ro" --> proxy.sipthor.net:5060
60 2 Adrian Georgescu
Resolved DNS A record "proxy.sipthor.net" --> 81.23.228.150, 81.23.228.129, 85.17.186.7
61 2 Adrian Georgescu
Subscribing to "<sip:ag@ag-projects.com>" for the presence event, at 85.17.186.7:5060
62 2 Adrian Georgescu
Received NOTIFY:
63 2 Adrian Georgescu
----------------
64 2 Adrian Georgescu
Presence for 31208005169@ag-projects.com:
65 2 Adrian Georgescu
  Person id yipgulqr
66 2 Adrian Georgescu
    Timestamp: 2008-10-26 10:37:32
67 2 Adrian Georgescu
    Activities
68 2 Adrian Georgescu
      Note(en): I am working
69 2 Adrian Georgescu
    Mood: sad, contended, mean
70 2 Adrian Georgescu
    Time offset from UTC: 60 minutes 
71 2 Adrian Georgescu
  ---
72 2 Adrian Georgescu
  Service id apgjjwtz
73 2 Adrian Georgescu
    Timestamp: 2008-10-26 10:37:42
74 2 Adrian Georgescu
    Status: open
75 2 Adrian Georgescu
----------------
76 2 Adrian Georgescu
Received NOTIFY:
77 2 Adrian Georgescu
----------------
78 2 Adrian Georgescu
Presence for 31208005169@ag-projects.com:
79 2 Adrian Georgescu
  Person id ksgxtgwo
80 2 Adrian Georgescu
    Timestamp: 2008-10-26 10:41:04
81 2 Adrian Georgescu
    Mood: impressed, flirtatious, thirsty
82 2 Adrian Georgescu
    Time offset from UTC: 60 minutes 
83 2 Adrian Georgescu
  Person id yipgulqr
84 2 Adrian Georgescu
    Timestamp: 2008-10-26 10:37:32
85 2 Adrian Georgescu
    Activities
86 2 Adrian Georgescu
      Note(en): I am working
87 2 Adrian Georgescu
    Mood: sad, contended, mean
88 2 Adrian Georgescu
    Time offset from UTC: 60 minutes 
89 2 Adrian Georgescu
  ---
90 2 Adrian Georgescu
  Service id apgjjwtz
91 2 Adrian Georgescu
    Timestamp: 2008-10-26 10:37:42
92 2 Adrian Georgescu
    Status: open
93 2 Adrian Georgescu
  Service id hxpzsnfp
94 2 Adrian Georgescu
    Timestamp: 2008-10-26 10:41:00
95 2 Adrian Georgescu
    Status: open
96 2 Adrian Georgescu
----------------
97 2 Adrian Georgescu
Received NOTIFY:
98 2 Adrian Georgescu
----------------
99 2 Adrian Georgescu
Presence for 31208005169@ag-projects.com:
100 2 Adrian Georgescu
  Person id ksgxtgwo
101 2 Adrian Georgescu
    Timestamp: 2008-10-26 10:41:04
102 2 Adrian Georgescu
    Mood: impressed, flirtatious, thirsty
103 2 Adrian Georgescu
    Time offset from UTC: 60 minutes 
104 2 Adrian Georgescu
  Person id yipgulqr
105 2 Adrian Georgescu
    Timestamp: 2008-10-26 10:37:32
106 2 Adrian Georgescu
    Activities
107 2 Adrian Georgescu
      Note(en): I am working
108 2 Adrian Georgescu
    Mood: sad, contended, mean
109 2 Adrian Georgescu
    Time offset from UTC: 60 minutes 
110 2 Adrian Georgescu
  ---
111 2 Adrian Georgescu
  Service id apgjjwtz
112 2 Adrian Georgescu
    Timestamp: 2008-10-26 10:37:42
113 2 Adrian Georgescu
    Status: open
114 2 Adrian Georgescu
  Service id hxpzsnfp
115 2 Adrian Georgescu
    Timestamp: 2008-10-26 10:41:07
116 2 Adrian Georgescu
    Status: closed
117 2 Adrian Georgescu
----------------
118 2 Adrian Georgescu
119 2 Adrian Georgescu
}}}