Sip publish presence

Version 13 (Adrian Georgescu, 03/12/2009 08:07 pm)

1 9 Adrian Georgescu
== sip_publish_presence ==
2 1 Adrian Georgescu
3 11 Adrian Georgescu
[[TOC(SipTesting*, sip_*, depth=2)]]
4 13 Adrian Georgescu
To use this script you must to have a valid [wiki:SipSettingsAPI configuration].
5 13 Adrian Georgescu
6 1 Adrian Georgescu
7 9 Adrian Georgescu
=== Description ===
8 1 Adrian Georgescu
9 11 Adrian Georgescu
[[Image(http://www.openxcap.org/chrome/site/SIMPLE-Server.png, nolink)]]
10 3 Adrian Georgescu
11 7 Adrian Georgescu
This script implements SIP PUBLISH method, for publishing event state.  PUBLISH is similar to REGISTER in that it allows a user to create, modify, and remove state in another entity which manages this state on behalf of the user.  Addressing a PUBLISH request is identical to addressing a SUBSCRIBE request.  The Request-URI of a PUBLISH request is populated with the address of the resource for which the user wishes to publish event state.  The user may in turn have multiple User Agents or endpoints that publish event state. Each endpoint may publish its own unique state, out of which the event state compositor generates the composite event state of the resource.  In addition to a particular resource, all published event state is associated with a specific event package.  Through a subscription to that event package, the user is able to discover the composite event state of all of the active publications.
12 3 Adrian Georgescu
13 2 Adrian Georgescu
Source code: [source:scripts/sip_publish_presence.py scripts/sip_publish_presence.py]
14 2 Adrian Georgescu
15 1 Adrian Georgescu
{{{
16 1 Adrian Georgescu
adigeo@ag-imac3:~$sip_publish_presence -h
17 1 Adrian Georgescu
Usage: sip_publish_presence [options]
18 1 Adrian Georgescu
19 1 Adrian Georgescu
This script will publish rich presence state of the specified SIP account to a
20 1 Adrian Georgescu
SIP Presence Agent, the presence information can be changed using a menu-
21 1 Adrian Georgescu
driven interface.
22 1 Adrian Georgescu
23 1 Adrian Georgescu
Options:
24 1 Adrian Georgescu
  -h, --help            show this help message and exit
25 1 Adrian Georgescu
  -a NAME, --account-name=NAME
26 1 Adrian Georgescu
                        The account name from which to read account settings.
27 1 Adrian Georgescu
                        Corresponds to section Account_NAME in the
28 1 Adrian Georgescu
                        configuration file. If not supplied, the section
29 1 Adrian Georgescu
                        Account will be read.
30 1 Adrian Georgescu
  --sip-address=SIP_ADDRESS
31 1 Adrian Georgescu
                        SIP address of the user in the form user@domain
32 1 Adrian Georgescu
  -e EXPIRES, --expires=EXPIRES
33 1 Adrian Georgescu
                        "Expires" value to set in PUBLISH. Default is 300
34 1 Adrian Georgescu
                        seconds.
35 1 Adrian Georgescu
  -o IP[:PORT], --outbound-proxy=IP[:PORT]
36 1 Adrian Georgescu
                        Outbound SIP proxy to use. By default a lookup of the
37 1 Adrian Georgescu
                        domain is performed based on SRV and A records. This
38 1 Adrian Georgescu
                        overrides the setting from the config file.
39 1 Adrian Georgescu
  -s, --trace-sip       Dump the raw contents of incoming and outgoing SIP
40 1 Adrian Georgescu
                        messages (disabled by default).
41 1 Adrian Georgescu
  -l, --log-pjsip       Print PJSIP logging output (disabled by default).
42 1 Adrian Georgescu
}}}
43 1 Adrian Georgescu
44 9 Adrian Georgescu
=== Example ===
45 1 Adrian Georgescu
46 1 Adrian Georgescu
{{{
47 1 Adrian Georgescu
adigeo@ag-imac3:~$sip_publish_presence 
48 1 Adrian Georgescu
Accounts available: 'alice', 'ew', 'mrg', 'pbx', 'tf', 'umts', 'unet', default
49 1 Adrian Georgescu
Using default account: 31208005169@ag-projects.com
50 1 Adrian Georgescu
Resolved DNS SRV record "_sip._udp.ag-projects.com" --> proxy.sipthor.net:5060
51 1 Adrian Georgescu
Resolved DNS A record "proxy.sipthor.net" --> 85.17.186.7, 81.23.228.150, 81.23.228.129
52 1 Adrian Georgescu
53 1 Adrian Georgescu
Commands:
54 1 Adrian Georgescu
  a: set activities information
55 1 Adrian Georgescu
  b: toggle basic status
56 1 Adrian Georgescu
  m: set mood information
57 1 Adrian Georgescu
  n: set note
58 1 Adrian Georgescu
  q: quit program
59 1 Adrian Georgescu
  s: show PIDF
60 1 Adrian Georgescu
61 1 Adrian Georgescu
<?xml version='1.0' encoding='UTF-8'?>
62 1 Adrian Georgescu
<presence xmlns:rpid="urn:ietf:params:xml:ns:pidf:rpid" xmlns:dm="urn:ietf:params:xml:ns:pidf:data-model" xmlns="urn:ietf:params:xml:ns:pidf" entity="31208005169@ag-projects.com">
63 1 Adrian Georgescu
  <tuple id="apgjjwtz">
64 1 Adrian Georgescu
    <status>
65 1 Adrian Georgescu
      <basic>open</basic>
66 1 Adrian Georgescu
    </status>
67 1 Adrian Georgescu
    <timestamp>2008-10-26T10:37:16+01:00</timestamp>
68 1 Adrian Georgescu
  </tuple>
69 1 Adrian Georgescu
  <dm:person id="yipgulqr">
70 1 Adrian Georgescu
    <rpid:time-offset>60</rpid:time-offset>
71 1 Adrian Georgescu
    <dm:timestamp>2008-10-26T10:37:16+01:00</dm:timestamp>
72 1 Adrian Georgescu
  </dm:person>
73 1 Adrian Georgescu
</presence>
74 1 Adrian Georgescu
75 1 Adrian Georgescu
Commands:
76 1 Adrian Georgescu
  a: set activities information
77 1 Adrian Georgescu
  b: toggle basic status
78 1 Adrian Georgescu
  m: set mood information
79 1 Adrian Georgescu
  n: set note
80 1 Adrian Georgescu
  q: quit program
81 1 Adrian Georgescu
  s: show PIDF
82 1 Adrian Georgescu
83 1 Adrian Georgescu
Commands:
84 1 Adrian Georgescu
  a: set activity
85 1 Adrian Georgescu
  c: clear all activity data
86 1 Adrian Georgescu
  d: delete activity
87 1 Adrian Georgescu
  n: set activity note
88 1 Adrian Georgescu
  q: quit program
89 1 Adrian Georgescu
  s: show current activity
90 1 Adrian Georgescu
  r: set random activity
91 1 Adrian Georgescu
  x: exit to upper level menu
92 1 Adrian Georgescu
93 1 Adrian Georgescu
Set note> I am working
94 1 Adrian Georgescu
95 1 Adrian Georgescu
Note set
96 1 Adrian Georgescu
97 1 Adrian Georgescu
Commands:
98 1 Adrian Georgescu
  a: set activities information
99 1 Adrian Georgescu
  b: toggle basic status
100 1 Adrian Georgescu
  m: set mood information
101 1 Adrian Georgescu
  n: set note
102 1 Adrian Georgescu
  q: quit program
103 1 Adrian Georgescu
  s: show PIDF
104 1 Adrian Georgescu
105 1 Adrian Georgescu
106 1 Adrian Georgescu
Commands:
107 1 Adrian Georgescu
  a: add a mood
108 1 Adrian Georgescu
  c: clear all mood data
109 1 Adrian Georgescu
  d: delete a mood
110 1 Adrian Georgescu
  n: set mood note
111 1 Adrian Georgescu
  q: quit program
112 1 Adrian Georgescu
  s: show current moods
113 1 Adrian Georgescu
  r: set random mood
114 1 Adrian Georgescu
  x: exit to upper level menu
115 1 Adrian Georgescu
116 1 Adrian Georgescu
You are now contended, sad, mean
117 1 Adrian Georgescu
118 1 Adrian Georgescu
Commands:
119 1 Adrian Georgescu
  a: set activities information
120 1 Adrian Georgescu
  b: toggle basic status
121 1 Adrian Georgescu
  m: set mood information
122 1 Adrian Georgescu
  n: set note
123 1 Adrian Georgescu
  q: quit program
124 1 Adrian Georgescu
  s: show PIDF
125 1 Adrian Georgescu
126 1 Adrian Georgescu
<?xml version='1.0' encoding='UTF-8'?>
127 1 Adrian Georgescu
<presence xmlns:rpid="urn:ietf:params:xml:ns:pidf:rpid" xmlns:dm="urn:ietf:params:xml:ns:pidf:data-model" xmlns="urn:ietf:params:xml:ns:pidf" entity="31208005169@ag-projects.com">
128 1 Adrian Georgescu
  <tuple id="apgjjwtz">
129 1 Adrian Georgescu
    <status>
130 1 Adrian Georgescu
      <basic>open</basic>
131 1 Adrian Georgescu
    </status>
132 1 Adrian Georgescu
    <timestamp>2008-10-26T10:37:16+01:00</timestamp>
133 1 Adrian Georgescu
  </tuple>
134 1 Adrian Georgescu
  <dm:person id="yipgulqr">
135 1 Adrian Georgescu
    <rpid:mood>
136 1 Adrian Georgescu
      <rpid:mean/>
137 1 Adrian Georgescu
      <rpid:contended/>
138 1 Adrian Georgescu
      <rpid:sad/>
139 1 Adrian Georgescu
    </rpid:mood>
140 1 Adrian Georgescu
    <rpid:activities>
141 1 Adrian Georgescu
      <rpid:note xml:lang="en">I am working</rpid:note>
142 1 Adrian Georgescu
    </rpid:activities>
143 1 Adrian Georgescu
    <rpid:time-offset>60</rpid:time-offset>
144 1 Adrian Georgescu
    <dm:timestamp>2008-10-26T10:37:32+01:00</dm:timestamp>
145 1 Adrian Georgescu
  </dm:person>
146 1 Adrian Georgescu
</presence>
147 1 Adrian Georgescu
148 1 Adrian Georgescu
Commands:
149 1 Adrian Georgescu
  a: set activities information
150 1 Adrian Georgescu
  b: toggle basic status
151 1 Adrian Georgescu
  m: set mood information
152 1 Adrian Georgescu
  n: set note
153 1 Adrian Georgescu
  q: quit program
154 1 Adrian Georgescu
  s: show PIDF
155 1 Adrian Georgescu
156 1 Adrian Georgescu
Your basic status is now 'closed'
157 1 Adrian Georgescu
158 1 Adrian Georgescu
Commands:
159 1 Adrian Georgescu
  a: set activities information
160 1 Adrian Georgescu
  b: toggle basic status
161 1 Adrian Georgescu
  m: set mood information
162 1 Adrian Georgescu
  n: set note
163 1 Adrian Georgescu
  q: quit program
164 1 Adrian Georgescu
  s: show PIDF
165 1 Adrian Georgescu
166 1 Adrian Georgescu
Your basic status is now 'open'
167 1 Adrian Georgescu
168 1 Adrian Georgescu
Commands:
169 1 Adrian Georgescu
  a: set activities information
170 1 Adrian Georgescu
  b: toggle basic status
171 1 Adrian Georgescu
  m: set mood information
172 1 Adrian Georgescu
  n: set note
173 1 Adrian Georgescu
  q: quit program
174 1 Adrian Georgescu
  s: show PIDF
175 1 Adrian Georgescu
176 1 Adrian Georgescu
<?xml version='1.0' encoding='UTF-8'?>
177 1 Adrian Georgescu
<presence xmlns:rpid="urn:ietf:params:xml:ns:pidf:rpid" xmlns:dm="urn:ietf:params:xml:ns:pidf:data-model" xmlns="urn:ietf:params:xml:ns:pidf" entity="31208005169@ag-projects.com">
178 1 Adrian Georgescu
  <tuple id="apgjjwtz">
179 1 Adrian Georgescu
    <status>
180 1 Adrian Georgescu
      <basic>open</basic>
181 1 Adrian Georgescu
    </status>
182 1 Adrian Georgescu
    <timestamp>2008-10-26T10:37:42+01:00</timestamp>
183 1 Adrian Georgescu
  </tuple>
184 1 Adrian Georgescu
  <dm:person id="yipgulqr">
185 1 Adrian Georgescu
    <rpid:mood>
186 1 Adrian Georgescu
      <rpid:mean/>
187 1 Adrian Georgescu
      <rpid:contended/>
188 1 Adrian Georgescu
      <rpid:sad/>
189 1 Adrian Georgescu
    </rpid:mood>
190 1 Adrian Georgescu
    <rpid:activities>
191 1 Adrian Georgescu
      <rpid:note xml:lang="en">I am working</rpid:note>
192 1 Adrian Georgescu
    </rpid:activities>
193 1 Adrian Georgescu
    <rpid:time-offset>60</rpid:time-offset>
194 1 Adrian Georgescu
    <dm:timestamp>2008-10-26T10:37:32+01:00</dm:timestamp>
195 1 Adrian Georgescu
  </dm:person>
196 1 Adrian Georgescu
</presence>
197 1 Adrian Georgescu
198 1 Adrian Georgescu
Commands:
199 1 Adrian Georgescu
  a: set activities information
200 1 Adrian Georgescu
  b: toggle basic status
201 1 Adrian Georgescu
  m: set mood information
202 1 Adrian Georgescu
  n: set note
203 1 Adrian Georgescu
  q: quit program
204 1 Adrian Georgescu
  s: show PIDF
205 1 Adrian Georgescu
}}}