Skip to content

Commit

Permalink
Runs again, after changes!
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya Vaidyam committed Feb 3, 2016
1 parent 8438ecd commit e9dd7aa
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 30 deletions.
4 changes: 2 additions & 2 deletions Hangouts/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public final class Client {
// The first time this is called, we need to retrieve the user's email address.
if self.email == nil {
self.getSelfInfo {
self.email = $0!.self_entity!.properties.emails[0] as? String
self.email = $0!.self_entity!.properties!.email[0] as? String
}
}

Expand Down Expand Up @@ -236,7 +236,7 @@ public final class Client {
for conv_state in conv_states {
let participants = conv_state.conversation!.participant_data
required_user_ids = required_user_ids.union(Set(participants.map {
UserID(chatID: $0.id.chat_id as! String, gaiaID: $0.id.gaia_id as! String)
UserID(chatID: $0.id!.chat_id as! String, gaiaID: $0.id!.gaia_id as! String)
}))
}

Expand Down
4 changes: 2 additions & 2 deletions Hangouts/Conversation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ public class Conversation {
get {
return conversation.participant_data.map {
self.user_list[UserID(
chatID: $0.id.chat_id as! String,
gaiaID: $0.id.gaia_id as! String
chatID: $0.id!.chat_id as! String,
gaiaID: $0.id!.gaia_id as! String
)]
}
}
Expand Down
8 changes: 4 additions & 4 deletions Hangouts/ConversationList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,13 @@ public class ConversationList {

// Receive ClientSetTypingNotification and update the conversation
public func handle_set_typing_notification(set_typing_notification: SET_TYPING_NOTIFICATION) {
let conv_id = set_typing_notification.conversation_id.id
let conv_id = set_typing_notification.conversation_id!.id
if let conv = conv_dict[conv_id as! String] {
let res = parseTypingStatusMessage(set_typing_notification)
delegate?.conversationList(self, didChangeTypingStatusTo: res.status)
let user = user_list[UserID(
chatID: set_typing_notification.user_id.chat_id as! String,
gaiaID: set_typing_notification.user_id.gaia_id as! String
chatID: set_typing_notification.sender_id!.chat_id as! String,
gaiaID: set_typing_notification.sender_id!.gaia_id as! String
)]
conv.handleTypingStatus(res.status, forUser: user)
} else {
Expand Down Expand Up @@ -203,7 +203,7 @@ public class ConversationList {
handle_watermark_notification(watermark_notification)
}
if let event_notification = update.event_notification {
on_client_event(event_notification.event)
on_client_event(event_notification.event!)
}
}
}
6 changes: 3 additions & 3 deletions Hangouts/Event.swift
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ public typealias WatermarkNotification = (convID: String, userID: UserID, readTi
// message is sent the typing status will not change to stopped.
internal func parseTypingStatusMessage(p: SET_TYPING_NOTIFICATION) -> TypingStatusMessage {
return TypingStatusMessage(
convID: p.conversation_id.id as! String,
userID: UserID(chatID: p.user_id.chat_id as! String, gaiaID: p.user_id.gaia_id as! String),
convID: p.conversation_id!.id as! String,
userID: UserID(chatID: p.sender_id!.chat_id as! String, gaiaID: p.sender_id!.gaia_id as! String),
timestamp: from_timestamp(p.timestamp)!,
status: p.status
status: p.type!
)
}

Expand Down
19 changes: 10 additions & 9 deletions Hangouts/Messages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ public typealias GetSelfInfoResponse = GET_SELF_INFO_RESPONSE

@objc(RESPONSE_HEADER)
public class RESPONSE_HEADER : Message {
public var status: ResponseStatus?
public var status: NSNumber? // ResponseStatus?
public var field1: AnyObject?
public var field2: AnyObject?
public var request_trace_id: NSString = ""
Expand Down Expand Up @@ -1068,10 +1068,10 @@ public class UserConversationState: Message {
public class ConversationParticipantData: Message {
public var id: ParticipantId?
public var fallback_name: NSString?
public var invitation_status: InvitationStatus?
public var invitation_status: NSNumber? // InvitationStatus?
public var field4: AnyObject?
public var participant_type: ParticipantType?
public var new_invitation_status: InvitationStatus?
public var participant_type: NSNumber? // ParticipantType?
public var new_invitation_status: NSNumber? // InvitationStatus?
}
public typealias CONVERSATION_PARTICIPANT_DATA = ConversationParticipantData

Expand Down Expand Up @@ -1153,6 +1153,7 @@ public class RequestHeader: Message {

@objc(Entity)
public class Entity: Message {
public var field1: AnyObject?
public var field2: AnyObject?
public var field3: AnyObject?
public var field4: AnyObject?
Expand All @@ -1164,16 +1165,16 @@ public class Entity: Message {
public var properties: EntityProperties?
public var field11: AnyObject?
public var field12: AnyObject?
public var entity_type: ParticipantType?
public var entity_type: AnyObject? // ParticipantType?
public var field14: AnyObject?
public var field15: AnyObject?
public var had_past_hangout_state: PastHangoutState?
public var had_past_hangout_state: AnyObject? // PastHangoutState?
}
public typealias ENTITY = Entity

@objc(EntityProperties)
public class EntityProperties: Message {
public var type: ProfileType?
public var type: NSNumber? // ProfileType?
public var display_name: NSString?
public var first_name: NSString?
public var photo_url: NSString?
Expand All @@ -1183,8 +1184,8 @@ public class EntityProperties: Message {
public var field8: AnyObject?
public var field9: AnyObject?
public var in_users_domain: NSNumber?
public var gender: Gender?
public var photo_url_status: PhotoUrlStatus?
public var gender: NSNumber? // Gender?
public var photo_url_status: NSNumber? // PhotoUrlStatus?
public var field13: AnyObject?
public var field14: AnyObject?
public var canonical_email: NSString?
Expand Down
46 changes: 44 additions & 2 deletions Hangouts/PBLite.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ public class PBLiteSerialization {
}

/* TODO: Use Swift reflection to unwrap [AnyObject]. */
/* TODO: Add all Message classes here. */
//return Mirror(reflecting: arr).types[0] as! Message.Type
public class func getArrayMessageType(arr: Any) -> Message.Type? {
//let mirror = Mirror(reflecting: arr)
//return mirror.types[0] as! Message.Type
if arr is [CONVERSATION_ID] { return CONVERSATION_ID.self }
if arr is [CONVERSATION_STATE] { return CONVERSATION_STATE.self }
if arr is [PARTICIPANT_ID] { return PARTICIPANT_ID.self }
Expand All @@ -110,7 +110,48 @@ public class PBLiteSerialization {

/* TODO: Use Swift reflection to unwrap [AnyObject]. */
public class func getArrayEnumType(arr: Any) -> Enum.Type? {
if arr is [ActiveClientState] { return ConversationView.self }
if arr is [FocusType] { return FocusType.self }
if arr is [FocusDevice] { return FocusDevice.self }
if arr is [TypingType] { return TypingType.self }
if arr is [ClientPresenceStateType] { return ClientPresenceStateType.self }
if arr is [NotificationLevel] { return NotificationLevel.self }
if arr is [SegmentType] { return SegmentType.self }
if arr is [ItemType] { return ItemType.self }
if arr is [MediaType] { return MediaType.self }
if arr is [MembershipChangeType] { return MembershipChangeType.self }
if arr is [HangoutEventType] { return HangoutEventType.self }
if arr is [OffTheRecordToggle] { return OffTheRecordToggle.self }
if arr is [OffTheRecordStatus] { return OffTheRecordStatus.self }
if arr is [SourceType] { return SourceType.self }
if arr is [EventType] { return EventType.self }
if arr is [ConversationType] { return ConversationType.self }
if arr is [ConversationStatus] { return ConversationStatus.self }
if arr is [ConversationView] { return ConversationView.self }
if arr is [DeliveryMediumType] { return DeliveryMediumType.self }
if arr is [ParticipantType] { return ParticipantType.self }
if arr is [InvitationStatus] { return InvitationStatus.self }
if arr is [ForceHistory] { return ForceHistory.self }
if arr is [NetworkType] { return NetworkType.self }
if arr is [BlockState] { return BlockState.self }
if arr is [ReplyToInviteType] { return ReplyToInviteType.self }
if arr is [ClientID] { return ClientID.self }
if arr is [ClientBuildType] { return ClientBuildType.self }
if arr is [ResponseStatus] { return ResponseStatus.self }
if arr is [PastHangoutState] { return PastHangoutState.self }
if arr is [PhotoURLStatus] { return PhotoURLStatus.self }
if arr is [Gender] { return Gender.self }
if arr is [ProfileType] { return ProfileType.self }
if arr is [ConfigurationBitType] { return ConfigurationBitType.self }
if arr is [RichPresenceType] { return RichPresenceType.self }
if arr is [FieldMask] { return FieldMask.self }
if arr is [DeleteType] { return DeleteType.self }
if arr is [SyncFilter] { return SyncFilter.self }
if arr is [SoundState] { return SoundState.self }
if arr is [CallerIDSettingsMask] { return CallerIDSettingsMask.self }
if arr is [PhoneVerificationStatus] { return PhoneVerificationStatus.self }
if arr is [PhoneDiscoverabilityStatus] { return PhoneDiscoverabilityStatus.self }
if arr is [PhoneValidationResult] { return PhoneValidationResult.self }
return nil
}

Expand Down Expand Up @@ -159,6 +200,7 @@ public class PBLiteSerialization {

// Unwrapping an optional enum
} else if let type = _unwrapOptionalType(property) as? Enum.Type {
print("TEST \(propertyName): \(type)")
let val: (AnyObject?) = type.init(value: (arr[i] as! NSNumber))
instance.setValue(val, forKey: propertyName)

Expand Down
16 changes: 8 additions & 8 deletions Hangouts/User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,24 @@ public struct User: Hashable, Equatable {
// Initialize a User from an Entity.
// If selfUser is nil, assume this is the self user.
public init(entity: ENTITY, selfUser: UserID?) {
let userID = UserID(chatID: entity.id.chat_id as! String,
gaiaID: entity.id.gaia_id as! String)
let userID = UserID(chatID: entity.id!.chat_id as! String,
gaiaID: entity.id!.gaia_id as! String)
let isSelf = (selfUser != nil ? (selfUser == userID) : true)

self.init(userID: userID,
fullName: entity.properties.display_name as String?,
firstName: entity.properties.first_name as String?,
photoURL: entity.properties.photo_url as String?,
emails: entity.properties.emails.map { $0 as! String },
fullName: entity.properties!.display_name as String?,
firstName: entity.properties!.first_name as String?,
photoURL: entity.properties!.photo_url as String?,
emails: entity.properties!.email.map { $0 as! String },
isSelf: isSelf
)
}

// Initialize from ClientConversationParticipantData.
// If selfUser is nil, assume this is the self user.
public init(data: CONVERSATION_PARTICIPANT_DATA, selfUser: UserID?) {
let userID = UserID(chatID: data.id.chat_id as! String,
gaiaID: data.id.gaia_id as! String)
let userID = UserID(chatID: data.id!.chat_id as! String,
gaiaID: data.id!.gaia_id as! String)
let isSelf = (selfUser != nil ? (selfUser == userID) : true)

self.init(userID: userID,
Expand Down

0 comments on commit e9dd7aa

Please sign in to comment.