Skip to content

Commit

Permalink
add GEO PUSH message
Browse files Browse the repository at this point in the history
  • Loading branch information
Zengwen Yuan committed Oct 12, 2019
1 parent 272c3aa commit 6e41342
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion rcs_client_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,11 @@ def compose_rcs_msg(self, content_type, content):
+ "Content-Type: application/vnd.gsma.rcs-ft-http+xml; charset=utf-8\r\n" \
+ "\r\n" \
+ content
elif content_type == "geoloc_push":
rcs_msg = "Content-Length: {length}\r\n".format(length = len(content)) \
+ "Content-Type: application/vnd.gsma.rcspushlocation+xml; charset=utf-8\r\n" \
+ "\r\n" \
+ content
else:
rcs_msg = "Content-Length: {length}\r\n".format(length = 12) \
+ "Content-Type: text/plain; charset=utf-8\r\n" \
Expand Down Expand Up @@ -573,6 +578,34 @@ def compose_rcs_ft_body(self, data_url, filename, file_type, file_size, has_thum
# log.debug("Composed RCS FT HTTP message is:\n\n{}\n".format(rcs_ft_xml))
return rcs_ft_xml

def compose_rcs_geolocation_push_body(self):
rcs_geo_xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" \
+ "<rcsenvelope entity=\"tel:{username}\" ".format(username = self.username) \
+ "xmlns=\"urn:gsma:params:xml:ns:rcs:rcs:geolocation\" " \
+ "xmlns:rpid=\"urn:ietf:params:xml:ns:pidf:rpid\" " \
+ "xmlns:gml=\"http://www.opengis.net/gml\" " \
+ "xmlns:gp=\"urn:ietf:params:xml:ns:pidf:geopriv10\" " \
+ "xmlns:gs=\"http://www.opengis.net/pidflo/1.0\" " \
+ "xmlns:dm=\"urn:ietf:params:xml:ns:pidf:data-model\">" \
+ "<rcspushlocation id=\"IgIQx0WCBA\" label=\"https://www.google.com/maps/place/Samueli+School+Samueli+School,+520+Portola+Plaza,+Los+Angeles,+CA+90095,+USA/\"> " \
+ "<gp:geopriv>" \
+ "<gp:location-info>" \
+ "<gs:Circle srsName=\"urn:ogc:def:crs:EPSG::4326\">" \
+ "<gml:pos>34.069820017616955 -118.44278275966646</gml:pos>" \
+ "<gs:radius uom=\"urn:ogc:def:uom:EPSG::9001\">0.0</gs:radius>" \
+ "</gs:Circle>" \
+ "</gp:location-info>" \
+ "<gp:usage-rules>" \
+ "<gp:retention-expiry>2019-09-14T17:29:35</gp:retention-expiry>" \
+ "</gp:usage-rules>" \
+ "</gp:geopriv>" \
+ "<timestamp>2019-09-14T12:29:35</timestamp>" \
+ "</rcspushlocation>" \
+ "</rcsenvelope>"

# log.debug("Composed RCS GEO PUSH message is:\n\n{}\n".format(rcs_geo_xml))
return rcs_geo_xml

def compose_imdn_msg(self, content = "Ok", content_type = "text"):
imdn_msg_id = secrets.token_urlsafe(24)[:24]
rcs_msg = self.compose_rcs_msg(content_type, content)
Expand Down Expand Up @@ -973,8 +1006,10 @@ def main(args):

# google_fi_rcs_ft_http_msg = rcs_messages.compose_rcs_ft_body("https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png", "googlelogo_color_272x92dp.png", "image/png", 5969)
google_fi_rcs_ft_http_msg = rcs_messages.compose_rcs_ft_body("https://i.pinimg.com/originals/5f/72/8d/5f728ddcadd9249142996433bbdebcab.jpg", "5f728ddcadd9249142996433bbdebcab.jpg", "image/jpeg", 194137)
google_fi_rcs_geo_push_msg = rcs_messages.compose_rcs_geolocation_push_body()
# google_fi_invite_1_req = rcs_messages.invite(1, conversation_call_id, Utils.get_ip_address_from_socket(wrappedSocket), "Greetings from your hacker!")
google_fi_invite_1_req = rcs_messages.invite(1, conversation_call_id, Utils.get_ip_address_from_socket(wrappedSocket), google_fi_rcs_ft_http_msg, "ft_http")
# google_fi_invite_1_req = rcs_messages.invite(1, conversation_call_id, Utils.get_ip_address_from_socket(wrappedSocket), google_fi_rcs_ft_http_msg, "ft_http")
google_fi_invite_1_req = rcs_messages.invite(1, conversation_call_id, Utils.get_ip_address_from_socket(wrappedSocket), google_fi_rcs_geo_push_msg, "geoloc_push")
log.info("Sending:\n\n{}\n".format(google_fi_invite_1_req))

if not args.sim_mode:
Expand Down

0 comments on commit 6e41342

Please sign in to comment.