Skip to content

Commit

Permalink
support X-MICROSOFT-SKYPETEAMSMEETINGURL property
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-virkus committed Oct 9, 2021
1 parent 435b66e commit aa14a30
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 7 deletions.
30 changes: 26 additions & 4 deletions lib/src/components.dart
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ abstract class VComponent {
} else if (!containsStandardCompliantLineBreaks &&
!current.contains(':')) {
// this can happen when the description or similiar fields also contain \n linebreaks
buffer..write('\n')..write(current.trimLeft());
buffer
..write('\n')
..write(current.trimLeft());
if (i == input.length - 1) {
output.add(buffer.toString());
}
Expand Down Expand Up @@ -311,14 +313,20 @@ abstract class VComponent {
}

void render(StringBuffer buffer) {
buffer..write('BEGIN:')..write(name)..write('\r\n');
buffer
..write('BEGIN:')
..write(name)
..write('\r\n');
for (final property in properties) {
buffer.write(property.toString());
}
for (final component in children) {
component.render(buffer);
}
buffer..write('END:')..write(name)..write('\r\n');
buffer
..write('END:')
..write(name)
..write('\r\n');
}

@override
Expand Down Expand Up @@ -881,7 +889,9 @@ class VCalendar extends VComponent {
}
domain ??= 'enough.de';
}
buffer..write('@')..write(domain);
buffer
..write('@')
..write(domain);
return buffer.toString();
}
}
Expand Down Expand Up @@ -1299,6 +1309,18 @@ class VEvent extends _EventTodoJournalComponent {
set isAllDayEvent(bool? value) => setOrRemoveProperty(
BooleanProperty.propertyNameAllDayEvent,
BooleanProperty.create(BooleanProperty.propertyNameAllDayEvent, value));

/// Retrieves the teams meeting URL for this event when the `X-MICROSOFT-SKYPETEAMSMEETINGURL` property is set.
String? get microsoftTeamsMeetingUrl => getProperty<TextProperty>(
TextProperty.propertyNameXMicrosoftSkypeTeamsMeetingUrl)
?.text;

/// Sets the teams meeting URL for this event using the proprietary `X-MICROSOFT-SKYPETEAMSMEETINGURL` property.
set microsoftTeamsMeetingUrl(String? value) => setOrRemoveProperty(
TextProperty.propertyNameResources,
TextProperty.create(
TextProperty.propertyNameXMicrosoftSkypeTeamsMeetingUrl, value));

// @override
// void checkValidity() {
// super.checkValidity();
Expand Down
13 changes: 11 additions & 2 deletions lib/src/properties.dart
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ class Property {
case TextProperty.propertyNameXWrTimezone:
case TextProperty.propertyNameXTimezoneLocation:
case TextProperty.propertyNameXCalendarName:
case TextProperty.propertyNameXMicrosoftSkypeTeamsMeetingUrl:
return TextProperty(definition);
case DateTimeProperty.propertyNameCompleted:
case DateTimeProperty.propertyNameDue:
Expand Down Expand Up @@ -333,7 +334,9 @@ class Property {
..write(parameter.textValue);
}
}
buffer..write(':')..write(textValue);
buffer
..write(':')
..write(textValue);
}

@override
Expand All @@ -345,7 +348,9 @@ class Property {
final definition = buffer.toString();
final wrappedBuffer = StringBuffer();
var startIndex = 72;
wrappedBuffer..write(definition.substring(0, startIndex))..write('\r\n');
wrappedBuffer
..write(definition.substring(0, startIndex))
..write('\r\n');
while (startIndex < definition.length - 73) {
wrappedBuffer
..write(' ')
Expand Down Expand Up @@ -849,6 +854,10 @@ class TextProperty extends Property {
/// `X-WR-CALNAME` calendar name property
static const String propertyNameXCalendarName = 'X-WR-CALNAME';

/// `X-MICROSOFT-SKYPETEAMSMEETINGURL` meeting URL property
static const String propertyNameXMicrosoftSkypeTeamsMeetingUrl =
'X-MICROSOFT-SKYPETEAMSMEETINGURL';

/// Retrieve the language
String? get language => this[ParameterType.language]?.textValue;

Expand Down
6 changes: 5 additions & 1 deletion test/components_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ UID:[email protected]
DTSTAMP:19970610T172345Z
DTSTART:19970714T170000Z
DTEND:19970715T040000Z
X-MICROSOFT-SKYPETEAMSMEETINGURL:https://teams.microsoft.com/l/meetup-join/2SDKJKJKSD%40thread.v2/0?context=%7b
%22Tid%22%3a%22bc74e59c-5fa3-4157-9c37-6232986d11a62%22%2c%22Oid%22%3a%22d41e3f0d-b888-4978-bd06-17f697e563aa%22%7d
SUMMARY:Bastille Day Party
END:VEVENT
END:VCALENDAR''';
Expand All @@ -260,6 +262,8 @@ END:VCALENDAR''';
expect(event.timeStamp, DateTime.utc(1997, 06, 10, 17, 23, 45));
expect(event.start, DateTime.utc(1997, 07, 14, 17, 00, 00));
expect(event.end, DateTime.utc(1997, 07, 15, 04, 00, 00));
expect(event.microsoftTeamsMeetingUrl,
'https://teams.microsoft.com/l/meetup-join/2SDKJKJKSD%40thread.v2/0?context=%7b%22Tid%22%3a%22bc74e59c-5fa3-4157-9c37-6232986d11a62%22%2c%22Oid%22%3a%22d41e3f0d-b888-4978-bd06-17f697e563aa%22%7d');
});

test('Calendar with full day event', () {
Expand Down Expand Up @@ -904,7 +908,7 @@ END:VCALENDAR\r
expect(event.classification, Classification.public);
expect(event.start, DateTime(2021, 07, 22, 14, 00, 00));
expect(event.end, DateTime(2021, 07, 22, 16, 00, 00));
print(event.description);
//print(event.description);
expect(event.description,
'Hey, here\'s the event description, with\nsome commas.');
expect(event.location, 'When in Rome...');
Expand Down

0 comments on commit aa14a30

Please sign in to comment.