/Source/externals/GData/Source/Elements/GDataIM.m

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