Enhanced iCalendar protocol support
This commit is contained in:
parent
c121c58480
commit
b485b5bd72
@ -16,7 +16,30 @@ as
|
|||||||
m_protocol_version constant varchar2(3) := '2.0';
|
m_protocol_version constant varchar2(3) := '2.0';
|
||||||
m_date_format constant varchar2(30) := 'YYYYMMDD"T"HH24MISS';
|
m_date_format constant varchar2(30) := 'YYYYMMDD"T"HH24MISS';
|
||||||
m_line_delimiter constant varchar2(2) := chr(13) || chr(10);
|
m_line_delimiter constant varchar2(2) := chr(13) || chr(10);
|
||||||
|
|
||||||
|
m_prodid varchar2(2000);
|
||||||
|
|
||||||
|
|
||||||
|
procedure set_prodid (p_prodid in varchar2)
|
||||||
|
as
|
||||||
|
begin
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Purpose: set prodid (company/product name)
|
||||||
|
|
||||||
|
Remarks:
|
||||||
|
|
||||||
|
Who Date Description
|
||||||
|
------ ---------- --------------------------------
|
||||||
|
MBR 07.03.2018 Created
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
m_prodid := substr(p_prodid, 1, 2000);
|
||||||
|
|
||||||
|
end set_prodid;
|
||||||
|
|
||||||
|
|
||||||
function fmt_date (p_date in date) return varchar2
|
function fmt_date (p_date in date) return varchar2
|
||||||
as
|
as
|
||||||
@ -85,6 +108,8 @@ begin
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
-- TODO: "Actual line feeds in data items are encoded as a backslash followed by the letter N (the bytes 5C 6E or 5C 4E in UTF-8). "
|
-- TODO: "Actual line feeds in data items are encoded as a backslash followed by the letter N (the bytes 5C 6E or 5C 4E in UTF-8). "
|
||||||
|
|
||||||
|
-- TODO: Encode text according to https://tools.ietf.org/html/rfc5545#section-3.3.11
|
||||||
|
|
||||||
l_returnvalue := p_text;
|
l_returnvalue := p_text;
|
||||||
|
|
||||||
@ -93,8 +118,7 @@ begin
|
|||||||
end fmt_text;
|
end fmt_text;
|
||||||
|
|
||||||
|
|
||||||
function add_core_object (p_ical_body in varchar2,
|
function add_core_object (p_ical_body in varchar2) return varchar2
|
||||||
p_prod_id in varchar2 := null) return varchar2
|
|
||||||
as
|
as
|
||||||
l_returnvalue string_util_pkg.t_max_pl_varchar2;
|
l_returnvalue string_util_pkg.t_max_pl_varchar2;
|
||||||
begin
|
begin
|
||||||
@ -113,7 +137,7 @@ begin
|
|||||||
|
|
||||||
l_returnvalue := 'BEGIN:VCALENDAR' || m_line_delimiter ||
|
l_returnvalue := 'BEGIN:VCALENDAR' || m_line_delimiter ||
|
||||||
'VERSION:' || m_protocol_version || m_line_delimiter ||
|
'VERSION:' || m_protocol_version || m_line_delimiter ||
|
||||||
'PRODID:' || nvl(p_prod_id, '-//My Company//NONSGML My Product//EN') || m_line_delimiter ||
|
'PRODID:' || nvl(m_prodid, '-//My Company//NONSGML My Product//EN') || m_line_delimiter ||
|
||||||
p_ical_body || m_line_delimiter ||
|
p_ical_body || m_line_delimiter ||
|
||||||
'END:VCALENDAR';
|
'END:VCALENDAR';
|
||||||
|
|
||||||
@ -122,14 +146,14 @@ begin
|
|||||||
end add_core_object;
|
end add_core_object;
|
||||||
|
|
||||||
|
|
||||||
function get_event (p_event in t_event) return varchar2
|
function get_event_str (p_event in t_event) return varchar2
|
||||||
as
|
as
|
||||||
l_returnvalue string_util_pkg.t_max_pl_varchar2;
|
l_returnvalue string_util_pkg.t_max_pl_varchar2;
|
||||||
begin
|
begin
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
Purpose: get event
|
Purpose: get event string
|
||||||
|
|
||||||
Remarks:
|
Remarks:
|
||||||
|
|
||||||
@ -147,20 +171,46 @@ begin
|
|||||||
'DTSTART:' || fmt_date(p_event.start_date) || m_line_delimiter ||
|
'DTSTART:' || fmt_date(p_event.start_date) || m_line_delimiter ||
|
||||||
'DTEND:' || fmt_date(nvl(p_event.end_date, p_event.start_date)) || m_line_delimiter ||
|
'DTEND:' || fmt_date(nvl(p_event.end_date, p_event.start_date)) || m_line_delimiter ||
|
||||||
'DTSTAMP:' || fmt_date(sysdate) || m_line_delimiter ||
|
'DTSTAMP:' || fmt_date(sysdate) || m_line_delimiter ||
|
||||||
'UID:' || nvl(p_event.uid, rawtohex(sys_guid()) || '@domain.example') || m_line_delimiter ||
|
'UID:' || nvl(p_event.uid, rawtohex(sys_guid()) || chr(64) || 'domain.example') || m_line_delimiter ||
|
||||||
'STATUS:NEEDS-ACTION' || m_line_delimiter ||
|
'STATUS:' || nvl(p_event.status, 'CONFIRMED') || m_line_delimiter ||
|
||||||
'END:VEVENT';
|
'END:VEVENT';
|
||||||
|
|
||||||
l_returnvalue := add_core_object (l_returnvalue);
|
l_returnvalue := add_core_object (l_returnvalue);
|
||||||
|
|
||||||
return l_returnvalue;
|
return l_returnvalue;
|
||||||
|
|
||||||
end get_event;
|
end get_event_str;
|
||||||
|
|
||||||
|
procedure download_event_str (p_event_str in varchar2,
|
||||||
|
p_filename in varchar2 := null)
|
||||||
|
as
|
||||||
|
l_event_str string_util_pkg.t_max_pl_varchar2;
|
||||||
|
begin
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Purpose: download event string
|
||||||
|
|
||||||
|
Remarks:
|
||||||
|
|
||||||
|
Who Date Description
|
||||||
|
------ ---------- --------------------------------
|
||||||
|
MBR 07.03.2018 Created
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
owa_util.mime_header('text/calendar', false);
|
||||||
|
htp.p('Content-length: ' || length(p_event_str));
|
||||||
|
htp.p('Content-Disposition: attachment; filename="' || nvl(p_filename, 'event.ics') || '"');
|
||||||
|
owa_util.http_header_close;
|
||||||
|
|
||||||
|
htp.prn (p_event_str);
|
||||||
|
|
||||||
|
end download_event_str;
|
||||||
|
|
||||||
|
|
||||||
procedure download_event (p_event in t_event)
|
procedure download_event (p_event in t_event)
|
||||||
as
|
as
|
||||||
l_event_str string_util_pkg.t_max_pl_varchar2;
|
|
||||||
begin
|
begin
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -172,17 +222,11 @@ begin
|
|||||||
Who Date Description
|
Who Date Description
|
||||||
------ ---------- --------------------------------
|
------ ---------- --------------------------------
|
||||||
MBR 26.10.2012 Created
|
MBR 26.10.2012 Created
|
||||||
|
MBR 07.03.2018 Refactored
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
l_event_str := get_event (p_event);
|
download_event_str (p_event_str => get_event_str (p_event), p_filename => file_util_pkg.get_filename_str(p_event.summary, 'ics'));
|
||||||
|
|
||||||
owa_util.mime_header('text/calendar', false);
|
|
||||||
htp.p('Content-length: ' || length(l_event_str));
|
|
||||||
htp.p('Content-Disposition: attachment; filename="' || file_util_pkg.get_filename_str(p_event.summary, 'ics') || '"');
|
|
||||||
owa_util.http_header_close;
|
|
||||||
|
|
||||||
htp.prn (l_event_str);
|
|
||||||
|
|
||||||
end download_event;
|
end download_event;
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ as
|
|||||||
Purpose: Package handles the iCalendar protocol (RFC 5545)
|
Purpose: Package handles the iCalendar protocol (RFC 5545)
|
||||||
|
|
||||||
Remarks: see http://en.wikipedia.org/wiki/ICalendar and http://tools.ietf.org/html/rfc5545
|
Remarks: see http://en.wikipedia.org/wiki/ICalendar and http://tools.ietf.org/html/rfc5545
|
||||||
|
|
||||||
Who Date Description
|
Who Date Description
|
||||||
------ ---------- --------------------------------
|
------ ---------- --------------------------------
|
||||||
MBR 26.10.2012 Created
|
MBR 26.10.2012 Created
|
||||||
@ -21,13 +21,20 @@ as
|
|||||||
location varchar2(2000),
|
location varchar2(2000),
|
||||||
organizer_name varchar2(2000),
|
organizer_name varchar2(2000),
|
||||||
organizer_email varchar2(2000),
|
organizer_email varchar2(2000),
|
||||||
|
status varchar2(2000),
|
||||||
uid varchar2(2000)
|
uid varchar2(2000)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- set prodid (company/product name)
|
||||||
|
procedure set_prodid (p_prodid in varchar2);
|
||||||
|
|
||||||
-- get event
|
-- get event string
|
||||||
function get_event (p_event in t_event) return varchar2;
|
function get_event_str (p_event in t_event) return varchar2;
|
||||||
|
|
||||||
|
-- download event string
|
||||||
|
procedure download_event_str (p_event_str in varchar2,
|
||||||
|
p_filename in varchar2 := null);
|
||||||
|
|
||||||
-- download event
|
-- download event
|
||||||
procedure download_event (p_event in t_event);
|
procedure download_event (p_event in t_event);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user