PageRenderTime 29ms CodeModel.GetById 2ms app.highlight 24ms RepoModel.GetById 1ms app.codeStats 0ms

/core/externals/update-engine/externals/gdata-objectivec-client/Source/Clients/Contacts/GDataEntryContact.m

http://macfuse.googlecode.com/
Objective C | 150 lines | 94 code | 37 blank | 19 comment | 2 complexity | 9cd4f9a8f388496bb8d62d3f67ab80d3 MD5 | raw file
  1/* Copyright (c) 2008 Google Inc.
  2 *
  3 * Licensed under the Apache License, Version 2.0 (the "License");
  4 * you may not use this file except in compliance with the License.
  5 * You may obtain a copy of the License at
  6 *
  7 *     http://www.apache.org/licenses/LICENSE-2.0
  8 *
  9 * Unless required by applicable law or agreed to in writing, software
 10 * distributed under the License is distributed on an "AS IS" BASIS,
 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12 * See the License for the specific language governing permissions and
 13 * limitations under the License.
 14 */
 15
 16//
 17//  GDataEntryContact.m
 18//
 19
 20#if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_CONTACTS_SERVICE
 21
 22#import "GDataEntryContact.h"
 23#import "GDataContactConstants.h"
 24
 25// phonetic name
 26@interface GDataContactYomiName : GDataValueElementConstruct <GDataExtension>
 27@end
 28 
 29@implementation GDataContactYomiName
 30+ (NSString *)extensionElementURI       { return kGDataNamespaceContact; }
 31+ (NSString *)extensionElementPrefix    { return kGDataNamespaceContactPrefix; }
 32+ (NSString *)extensionElementLocalName { return @"yomiName"; }
 33@end
 34
 35@implementation GDataEntryContact
 36
 37+ (GDataEntryContact *)contactEntryWithName:(GDataName *)name {
 38
 39  GDataEntryContact *obj = [self object];
 40  [obj setNamespaces:[GDataContactConstants contactNamespaces]];
 41  [obj setName:name];
 42  return obj;
 43}
 44
 45+ (GDataEntryContact *)contactEntryWithFullNameString:(NSString *)str {
 46  GDataName *name = [GDataName nameWithFullNameString:str];
 47  GDataEntryContact *obj = [self contactEntryWithName:name];
 48  return obj;
 49}
 50
 51+ (GDataEntryContact *)contactEntryWithTitle:(NSString *)title {
 52
 53  GDataEntryContact *obj = [self object];
 54
 55  [obj setNamespaces:[GDataContactConstants contactNamespaces]];
 56
 57  [obj setTitleWithString:title];
 58  return obj;
 59}
 60
 61#pragma mark -
 62
 63+ (NSString *)standardEntryKind {
 64  return kGDataCategoryContact;
 65}
 66
 67+ (void)load {
 68  [self registerEntryClass];
 69}
 70
 71- (void)addExtensionDeclarations {
 72  
 73  [super addExtensionDeclarations];
 74
 75  // ContactEntry extensions
 76
 77  Class entryClass = [self class];
 78  [self addExtensionDeclarationForParentClass:entryClass
 79                                 childClasses:
 80   [GDataGroupMembershipInfo class],
 81   nil];
 82}
 83
 84#if !GDATA_SIMPLE_DESCRIPTIONS
 85- (NSMutableArray *)itemsForDescription {
 86
 87  static struct GDataDescriptionRecord descRecs[] = {
 88    { @"group",           @"groupMembershipInfos", kGDataDescArrayDescs   },
 89    { @"version>=3:yomi", @"yomi",                 kGDataDescValueLabeled },
 90    { nil, nil, (GDataDescRecTypes)0 }
 91  };
 92  
 93  NSMutableArray *items = [super itemsForDescription];
 94  [self addDescriptionRecords:descRecs toItems:items];
 95  return items;
 96}
 97#endif
 98
 99+ (NSString *)defaultServiceVersion {
100  return kGDataContactDefaultServiceVersion;
101}
102
103#pragma mark -
104
105- (NSString *)yomi {
106  GDATA_DEBUG_ASSERT_MIN_SERVICE_VERSION(kGDataContactServiceV3);
107
108  GDataContactYomiName *obj = [self objectForExtensionClass:[GDataContactYomiName class]];
109  return [obj stringValue];
110}
111
112- (void)setYomi:(NSString *)str {
113  GDATA_DEBUG_ASSERT_MIN_SERVICE_VERSION(kGDataContactServiceV3);
114
115  GDataContactYomiName *obj = nil;
116  if ([str length] > 0) {
117    obj = [GDataContactYomiName valueWithString:str];
118  }
119  [self setObject:obj forExtensionClass:[GDataContactYomiName class]]; 
120}
121
122
123- (NSArray *)groupMembershipInfos {
124  return [self objectsForExtensionClass:[GDataGroupMembershipInfo class]];
125}
126
127- (void)setGroupMembershipInfos:(NSArray *)arr {
128  [self setObjects:arr forExtensionClass:[GDataGroupMembershipInfo class]];
129}
130
131- (void)addGroupMembershipInfo:(GDataGroupMembershipInfo *)obj {
132  [self addObject:obj forExtensionClass:[GDataGroupMembershipInfo class]];
133}
134
135- (void)removeGroupMembershipInfo:(GDataGroupMembershipInfo *)obj {
136  [self removeObject:obj forExtensionClass:[GDataGroupMembershipInfo class]];
137}
138#pragma mark -
139
140- (GDataGroupMembershipInfo *)groupMembershipInfoWithHref:(NSString *)href {
141  GDataGroupMembershipInfo *groupInfo;
142  
143  groupInfo = [GDataUtilities firstObjectFromArray:[self groupMembershipInfos]
144                                         withValue:href
145                                        forKeyPath:@"href"];
146  return groupInfo;
147}
148@end
149
150#endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_CONTACTS_SERVICE