PageRenderTime 67ms CodeModel.GetById 49ms app.highlight 16ms RepoModel.GetById 1ms app.codeStats 0ms

/core/externals/update-engine/externals/gdata-objectivec-client/Source/Elements/GDataIM.m

http://macfuse.googlecode.com/
Objective C | 112 lines | 65 code | 24 blank | 23 comment | 1 complexity | 0cab7c5a6878da3685e136bda1ac4aa7 MD5 | raw file
  1/* Copyright (c) 2007 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//  GDataIM.m
 18//
 19
 20#if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_CONTACTS_SERVICE
 21
 22#define GDATAIM_DEFINE_GLOBALS 1
 23#import "GDataIM.h"
 24
 25static NSString* const kRelAttr = @"rel";
 26static NSString* const kLabelAttr = @"label";
 27static NSString* const kAddressAttr = @"address";
 28static NSString* const kProtocolAttr = @"protocol";
 29static NSString* const kPrimaryAttr = @"primary";
 30
 31@implementation GDataIM
 32// IM element, as in
 33//   <gd:im protocol="http://schemas.google.com/g/2005#MSN"
 34//      address="foo@bar.example.com" label="Alternate"
 35//      rel="http://schemas.google.com/g/2005#other" >
 36//
 37// http://code.google.com/apis/gdata/common-elements.html#gdIm
 38
 39+ (NSString *)extensionElementURI       { return kGDataNamespaceGData; }
 40+ (NSString *)extensionElementPrefix    { return kGDataNamespaceGDataPrefix; }
 41+ (NSString *)extensionElementLocalName { return @"im"; }
 42
 43+ (GDataIM *)IMWithProtocol:(NSString *)protocol
 44                        rel:(NSString *)rel
 45                      label:(NSString *)label
 46                    address:(NSString *)address {
 47
 48  GDataIM *obj = [self object];
 49  [obj setProtocol:protocol];
 50  [obj setRel:rel];
 51  [obj setLabel:label];
 52  [obj setAddress:address];
 53  return obj;
 54}
 55
 56- (void)addParseDeclarations {
 57  NSArray *attrs = [NSArray arrayWithObjects:
 58                    kAddressAttr, kProtocolAttr, kLabelAttr, kRelAttr,
 59                    kPrimaryAttr, nil];
 60
 61  [self addLocalAttributeDeclarations:attrs];
 62}
 63
 64- (NSArray *)attributesIgnoredForEquality {
 65
 66  return [NSArray arrayWithObject:kPrimaryAttr];
 67}
 68
 69#pragma mark -
 70
 71- (NSString *)label {
 72  return [self stringValueForAttribute:kLabelAttr];
 73}
 74
 75- (void)setLabel:(NSString *)str {
 76  [self setStringValue:str forAttribute:kLabelAttr];
 77}
 78
 79- (NSString *)rel {
 80  return [self stringValueForAttribute:kRelAttr];
 81}
 82
 83- (void)setRel:(NSString *)str {
 84  [self setStringValue:str forAttribute:kRelAttr];
 85}
 86
 87- (NSString *)address {
 88  return [self stringValueForAttribute:kAddressAttr];
 89}
 90
 91- (void)setAddress:(NSString *)str {
 92  [self setStringValue:str forAttribute:kAddressAttr];
 93}
 94
 95- (NSString *)protocol {
 96  return [self stringValueForAttribute:kProtocolAttr];
 97}
 98
 99- (void)setProtocol:(NSString *)str {
100  [self setStringValue:str forAttribute:kProtocolAttr];
101}
102
103- (BOOL)isPrimary {
104  return [self boolValueForAttribute:kPrimaryAttr defaultValue:NO];
105}
106
107- (void)setIsPrimary:(BOOL)flag {
108  [self setBoolValue:flag defaultValue:NO forAttribute:kPrimaryAttr];
109}
110@end
111
112#endif // !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_CONTACTS_SERVICE