-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathQSMeetingResolver.m
More file actions
60 lines (50 loc) · 1.6 KB
/
QSMeetingResolver.m
File metadata and controls
60 lines (50 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//
// QSZoom.m
// zoom.us Plugin
//
// Created by Rob McBroom on 2019/3/8.
// Copyright © 2019 Quicksilver. All rights reserved.
//
#import "QSMeetingResolver.h"
#pragma mark Helpers
QSObject *objectFromEvent(EKEvent *event, NSDictionary *eventData) {
NSString *url = eventData[@"url"];
NSString *serviceName = eventData[@"service"];
NSString *title = [event title];
QSObject *meeting = [QSObject URLObjectWithURL:url title:title];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterNoStyle];
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
NSString *start = [dateFormatter stringFromDate:[event startDate]];
NSString *end = [dateFormatter stringFromDate:[event endDate]];
[meeting setObject:[NSString stringWithFormat:@"%@ (%@, %@ – %@)", title, serviceName, start, end] forMeta:@"meetingDescription"];
// Set icon based on meeting service
NSImage *icon = iconForMeetingURL(url);
if (icon) {
[meeting setIcon:icon];
[meeting setIconLoaded:YES];
}
return meeting;
}
NSDictionary *meetingDataFromEvent(EKEvent *event) {
NSMutableArray *searchFields = [NSMutableArray arrayWithCapacity:3];
if ([event URL]) {
[searchFields addObject:[[event URL] absoluteString]];
}
if ([event location]) {
[searchFields addObject:[event location]];
}
if ([event notes]) {
[searchFields addObject:[event notes]];
}
for (NSString *field in searchFields) {
NSDictionary *info = meetingDataFromString(field);
if (info) {
NSString *urlString = info[@"url"];
if (urlString.length > 0) {
return info;
}
}
}
return nil;
}