Skip to content

Commit

Permalink
Merge pull request #8150 from hansemannn/TIMOB-18927-FIXED
Browse files Browse the repository at this point in the history
[TIMOB-18927] iOS: Expose Ti.Calendar.Attendee
  • Loading branch information
AngelkPetkov committed Jul 23, 2016
2 parents 2e41752 + 9db5b42 commit c379c34
Show file tree
Hide file tree
Showing 10 changed files with 420 additions and 59 deletions.
46 changes: 46 additions & 0 deletions apidoc/Titanium/Calendar/Attendee.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
name: Titanium.Calendar.Attendee
summary: An object that represents a single attendee of an event.
description: |
The API supports retrieving information about the attendee of an event.
extends: Titanium.Proxy
platforms: [iphone, ipad]
since: "6.0.0"
createable: false

properties:
- name: isOrganizer
summary: Indicates whether this attendee is the event organizer.
type: Boolean
platforms: [iphone, ipad]

- name: name
summary: The attendee name.
type: String
platforms: [iphone, ipad]

- name: email
summary: The attendee email.
description: |
Due to privacy concerns in iOS, this value will be empty if the attendee
is the device owner.
type: String
platforms: [iphone, ipad]

- name: role
summary: The role of the attendee.
type: Number
constants: Titanium.Calendar.ATTENDEE_ROLE_*
platforms: [iphone, ipad]

- name: type
summary: The type of the attendee.
type: Number
constants: Titanium.Calendar.ATTENDEE_TYPE_*
platforms: [iphone, ipad]

- name: status
summary: The status of the attendee.
type: Number
constants: Titanium.Calendar.ATTENDEE_STATUS_*
platforms: [iphone, ipad]
119 changes: 119 additions & 0 deletions apidoc/Titanium/Calendar/Calendar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,125 @@ properties:
permission: read-only
platforms: [android]

- name: ATTENDEE_STATUS_UNKNOWN
summary: Attendee status is unknown.
type: Number
permission: read-only
platforms: [iphone, ipad]
since: "6.0.0"

- name: ATTENDEE_STATUS_PENDING
summary: Attendee status is pending.
type: Number
permission: read-only
platforms: [iphone, ipad]
since: "6.0.0"

- name: ATTENDEE_STATUS_ACCEPTED
summary: Attendee status is accepted.
type: Number
permission: read-only
platforms: [iphone, ipad]
since: "6.0.0"

- name: ATTENDEE_STATUS_DECLINED
summary: Attendee status is declined.
type: Number
permission: read-only
platforms: [iphone, ipad]
since: "6.0.0"

- name: ATTENDEE_STATUS_TENTATIVE
summary: Attendee status is tentative.
type: Number
permission: read-only
platforms: [iphone, ipad]
since: "6.0.0"

- name: ATTENDEE_STATUS_DELEGATED
summary: Attendee status is delegated.
type: Number
permission: read-only
platforms: [iphone, ipad]
since: "6.0.0"

- name: ATTENDEE_STATUS_IN_PROCESS
summary: Attendee status is in process.
type: Number
permission: read-only
platforms: [iphone, ipad]
since: "6.0.0"

- name: ATTENDEE_ROLE_UNKNOWN
summary: Attendee role is unknown.
type: Number
permission: read-only
platforms: [iphone, ipad]
since: "6.0.0"

- name: ATTENDEE_ROLE_OPTIONAL
summary: Attendee role is optional.
type: Number
permission: read-only
platforms: [iphone, ipad]
since: "6.0.0"

- name: ATTENDEE_ROLE_REQUIRED
summary: Attendee role is required.
type: Number
permission: read-only
platforms: [iphone, ipad]
since: "6.0.0"

- name: ATTENDEE_ROLE_CHAIR
summary: Attendee role is chair.
type: Number
permission: read-only
platforms: [iphone, ipad]
since: "6.0.0"

- name: ATTENDEE_ROLE_NON_PARTICIPANT
summary: Attendee is not a participant.
type: Number
permission: read-only
platforms: [iphone, ipad]
since: "6.0.0"

- name: ATTENDEE_TYPE_UNKNOWN
summary: Attendee type is unknown.
type: Number
permission: read-only
platforms: [iphone, ipad]
since: "6.0.0"

- name: ATTENDEE_TYPE_PERSON
summary: Attendee type is person.
type: Number
permission: read-only
platforms: [iphone, ipad]
since: "6.0.0"

- name: ATTENDEE_TYPE_ROOM
summary: Attendee type is room.
type: Number
permission: read-only
platforms: [iphone, ipad]
since: "6.0.0"

- name: ATTENDEE_TYPE_RESOURCE
summary: Attendee type is resource.
type: Number
permission: read-only
platforms: [iphone, ipad]
since: "6.0.0"

- name: ATTENDEE_TYPE_GROUP
summary: Attendee type is group.
type: Number
permission: read-only
platforms: [iphone, ipad]
since: "6.0.0"

- name: eventsAuthorization
summary: Returns an authorization constant indicating if the application has access to the events in the EventKit.
description: |
Expand Down
7 changes: 7 additions & 0 deletions apidoc/Titanium/Calendar/Event.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,10 @@ properties:
constants: Titanium.Calendar.VISIBILITY_*
permission: read-only
platforms: [android]

- name: attendees
summary: The list of event attendees. This list will be empty if the event has no attendees.
type: Array<Titanium.Calendar.Attendee>
platforms: [iphone, ipad]
permission: read-only
since: "6.0.0"
22 changes: 22 additions & 0 deletions iphone/Classes/CalendarModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,28 @@
@property (nonatomic, readonly)NSNumber* AUTHORIZATION_DENIED;
@property (nonatomic, readonly)NSNumber* AUTHORIZATION_AUTHORIZED;

@property (nonatomic, readonly)NSNumber* ATTENDEE_STATUS_UNKNOWN;
@property (nonatomic, readonly)NSNumber* ATTENDEE_STATUS_PENDING;
@property (nonatomic, readonly)NSNumber* ATTENDEE_STATUS_ACCEPTED;
@property (nonatomic, readonly)NSNumber* ATTENDEE_STATUS_DECLINED;
@property (nonatomic, readonly)NSNumber* ATTENDEE_STATUS_TENTATIVE;
@property (nonatomic, readonly)NSNumber* ATTENDEE_STATUS_DELEGATED;
@property (nonatomic, readonly)NSNumber* ATTENDEE_STATUS_COMPLETED;
@property (nonatomic, readonly)NSNumber* ATTENDEE_STATUS_IN_PROCESS;

@property (nonatomic, readonly)NSNumber* ATTENDEE_ROLE_UNKNOWN;
@property (nonatomic, readonly)NSNumber* ATTENDEE_ROLE_REQUIRED;
@property (nonatomic, readonly)NSNumber* ATTENDEE_ROLE_OPTIONAL;
@property (nonatomic, readonly)NSNumber* ATTENDEE_ROLE_CHAIR;
@property (nonatomic, readonly)NSNumber* ATTENDEE_ROLE_NON_PARTICIPANT;

@property (nonatomic, readonly)NSNumber* ATTENDEE_TYPE_UNKNOWN;
@property (nonatomic, readonly)NSNumber* ATTENDEE_TYPE_PERSON;
@property (nonatomic, readonly)NSNumber* ATTENDEE_TYPE_ROOM;
@property (nonatomic, readonly)NSNumber* ATTENDEE_TYPE_RESOURCE;
@property (nonatomic, readonly)NSNumber* ATTENDEE_TYPE_GROUP;


@end

#endif
21 changes: 21 additions & 0 deletions iphone/Classes/CalendarModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,27 @@ -(NSNumber*) calendarAuthorization
MAKE_SYSTEM_PROP(AUTHORIZATION_DENIED, EKAuthorizationStatusDenied);
MAKE_SYSTEM_PROP(AUTHORIZATION_AUTHORIZED, EKAuthorizationStatusAuthorized);

MAKE_SYSTEM_PROP(ATTENDEE_STATUS_UNKNOWN, EKParticipantStatusUnknown);
MAKE_SYSTEM_PROP(ATTENDEE_STATUS_PENDING, EKParticipantStatusPending);
MAKE_SYSTEM_PROP(ATTENDEE_STATUS_ACCEPTED, EKParticipantStatusAccepted);
MAKE_SYSTEM_PROP(ATTENDEE_STATUS_DECLINED, EKParticipantStatusDeclined);
MAKE_SYSTEM_PROP(ATTENDEE_STATUS_TENTATIVE, EKParticipantStatusTentative);
MAKE_SYSTEM_PROP(ATTENDEE_STATUS_DELEGATED, EKParticipantStatusDelegated);
MAKE_SYSTEM_PROP(ATTENDEE_STATUS_COMPLETED, EKParticipantStatusCompleted);
MAKE_SYSTEM_PROP(ATTENDEE_STATUS_IN_PROCESS, EKParticipantStatusInProcess);

MAKE_SYSTEM_PROP(ATTENDEE_ROLE_UNKNOWN, EKParticipantRoleUnknown);
MAKE_SYSTEM_PROP(ATTENDEE_ROLE_REQUIRED, EKParticipantRoleRequired);
MAKE_SYSTEM_PROP(ATTENDEE_ROLE_OPTIONAL, EKParticipantRoleOptional);
MAKE_SYSTEM_PROP(ATTENDEE_ROLE_CHAIR, EKParticipantRoleChair);
MAKE_SYSTEM_PROP(ATTENDEE_ROLE_NON_PARTICIPANT, EKParticipantRoleNonParticipant);

MAKE_SYSTEM_PROP(ATTENDEE_TYPE_UNKNOWN, EKParticipantTypeUnknown);
MAKE_SYSTEM_PROP(ATTENDEE_TYPE_PERSON, EKParticipantTypePerson);
MAKE_SYSTEM_PROP(ATTENDEE_TYPE_ROOM, EKParticipantTypeRoom);
MAKE_SYSTEM_PROP(ATTENDEE_TYPE_RESOURCE, EKParticipantTypeResource);
MAKE_SYSTEM_PROP(ATTENDEE_TYPE_GROUP, EKParticipantTypeGroup);

@end

#endif
20 changes: 20 additions & 0 deletions iphone/Classes/TiCalendarAttendee.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2016 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/

#ifdef USE_TI_CALENDAR
#import "TiProxy.h"
#import "CalendarModule.h"

@interface TiCalendarAttendee : TiProxy {
EKParticipant* participant;
}

-(id)_initWithPageContext:(id<TiEvaluator>)context participant:(EKParticipant*)participant_;

@end

#endif
76 changes: 76 additions & 0 deletions iphone/Classes/TiCalendarAttendee.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2016 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
#ifdef USE_TI_CALENDAR
#import "TiCalendarAttendee.h"

@implementation TiCalendarAttendee

#pragma mark - Internals

- (id)_initWithPageContext:(id<TiEvaluator>)context participant:(EKParticipant*)participant_
{
if (self = [super _initWithPageContext:context]) {
participant = [participant_ retain];
}
return self;
}

- (void)dealloc
{
RELEASE_TO_NIL(participant);
[super dealloc];
}

- (EKParticipant*)participant
{
return participant;
}

- (NSString*)apiName
{
return @"Ti.Calendar.Attendee";
}

#pragma mark - Public API's

- (NSString*)name
{
return [[self participant] name];
}

- (NSString*)email
{
if ([[self participant] isCurrentUser]) {
return @"";
}

return [[[self participant] URL] resourceSpecifier];
}

- (NSNumber*)role
{
return NUMUINT([[self participant] participantRole]);
}

- (NSNumber*)type
{
return NUMUINT([[self participant] participantType]);
}

- (NSNumber*)status
{
return NUMUINT([[self participant] participantStatus]);
}

- (NSNumber*)isOrganizer
{
return NUMBOOL([[self participant] isCurrentUser]);
}

@end

#endif
16 changes: 14 additions & 2 deletions iphone/Classes/TiCalendarEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#import "TiCalendarEvent.h"
#import "TiCalendarAlert.h"
#import "TiCalendarRecurrenceRule.h"
#import "TiCalendarAttendee.h"

@implementation TiCalendarEvent

Expand Down Expand Up @@ -42,7 +43,6 @@ -(NSString*)apiName
return @"Ti.Calendar.Event";
}


+(NSArray*) convertEvents:(NSArray*)events_ withContext:(id<TiEvaluator>)context_ calendar:(EKCalendar*)calendar_ module:(CalendarModule*)module_
{
NSMutableArray* events = [NSMutableArray arrayWithCapacity:[events_ count]];
Expand Down Expand Up @@ -529,6 +529,18 @@ -(NSNumber*) refresh:(id)unused
return NUMBOOL(result);
}

-(NSArray*) attendees
{
NSArray* participants = [[self event] attendees];
NSMutableArray* result = [NSMutableArray arrayWithCapacity:[participants count]];

for (EKParticipant* participant in participants) {
[result addObject:[[[TiCalendarAttendee alloc] _initWithPageContext:[self executionContext] participant:participant] autorelease]];
}

return result;
}

@end

#endif
#endif

0 comments on commit c379c34

Please sign in to comment.