/core/externals/update-engine/externals/gdata-objectivec-client/Source/BaseClasses/GDataEntryBase.h

http://macfuse.googlecode.com/ · C++ Header · 222 lines · 124 code · 51 blank · 47 comment · 0 complexity · dd20dfa9368824491aaf0dd8d84a281b 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. // GDataEntryBase.h
  17. //
  18. // This is the base class for all standard GData feed entries.
  19. //
  20. #import "GDataDateTime.h"
  21. #import "GDataTextConstruct.h"
  22. #import "GDataEntryContent.h"
  23. #import "GDataPerson.h"
  24. #import "GDataCategory.h"
  25. #import "GDataDeleted.h"
  26. #import "GDataBatchOperation.h"
  27. #import "GDataBatchID.h"
  28. #import "GDataBatchStatus.h"
  29. #import "GDataBatchInterrupted.h"
  30. #import "GDataAtomPubControl.h"
  31. #import "GDataLink.h"
  32. #undef _EXTERN
  33. #undef _INITIALIZE_AS
  34. #ifdef GDATAENTRYBASE_DEFINE_GLOBALS
  35. #define _EXTERN
  36. #define _INITIALIZE_AS(x) =x
  37. #else
  38. #define _EXTERN GDATA_EXTERN
  39. #define _INITIALIZE_AS(x)
  40. #endif
  41. _EXTERN NSString* const kGDataCategoryScheme _INITIALIZE_AS(@"http://schemas.google.com/g/2005#kind");
  42. @interface GDataEntryBase : GDataObject <NSCopying> {
  43. // either uploadData_ or uploadFileHandle_ may be set, but not both
  44. NSData *uploadData_;
  45. NSFileHandle *uploadFileHandle_;
  46. NSURL *uploadLocationURL_; // requires uploadFileHandle be set
  47. NSString *uploadMIMEType_;
  48. NSString *uploadSlug_; // for http slug (filename) header when uploading
  49. BOOL shouldUploadDataOnly_;
  50. }
  51. + (NSDictionary *)baseGDataNamespaces;
  52. + (id)entry;
  53. // basic entry fields
  54. - (NSString *)identifier;
  55. - (void)setIdentifier:(NSString *)theIdString;
  56. - (GDataDateTime *)publishedDate;
  57. - (void)setPublishedDate:(GDataDateTime *)thePublishedDate;
  58. - (GDataDateTime *)updatedDate;
  59. - (void)setUpdatedDate:(GDataDateTime *)theUpdatedDate;
  60. - (GDataDateTime *)editedDate;
  61. - (void)setEditedDate:(GDataDateTime *)theEditedDate;
  62. - (NSString *)ETag;
  63. - (void)setETag:(NSString *)str;
  64. - (NSString *)fieldSelection;
  65. - (void)setFieldSelection:(NSString *)str;
  66. - (NSString *)kind;
  67. - (void)setKind:(NSString *)str;
  68. - (NSString *)resourceID;
  69. - (void)setResourceID:(NSString *)str;
  70. - (GDataTextConstruct *)title;
  71. - (void)setTitle:(GDataTextConstruct *)theTitle;
  72. - (void)setTitleWithString:(NSString *)str;
  73. - (GDataTextConstruct *)summary;
  74. - (void)setSummary:(GDataTextConstruct *)theSummary;
  75. - (void)setSummaryWithString:(NSString *)str;
  76. - (GDataEntryContent *)content;
  77. - (void)setContent:(GDataEntryContent *)theContent;
  78. - (void)setContentWithString:(NSString *)str;
  79. - (GDataTextConstruct *)rightsString;
  80. - (void)setRightsString:(GDataTextConstruct *)theRightsString;
  81. - (void)setRightsStringWithString:(NSString *)str;
  82. - (NSArray *)links;
  83. - (void)setLinks:(NSArray *)links;
  84. - (void)addLink:(GDataLink *)link;
  85. - (NSArray *)authors;
  86. - (void)setAuthors:(NSArray *)authors;
  87. - (void)addAuthor:(GDataPerson *)authorElement;
  88. - (NSArray *)contributors;
  89. - (void)setContributors:(NSArray *)array;
  90. - (void)addContributor:(GDataPerson *)obj;
  91. - (NSArray *)categories;
  92. - (void)setCategories:(NSArray *)categories;
  93. - (void)addCategory:(GDataCategory *)category;
  94. - (void)removeCategory:(GDataCategory *)category;
  95. // File upload
  96. //
  97. // Either uploadData or uploadFileHandle should be set, but not both
  98. - (NSData *)uploadData;
  99. - (void)setUploadData:(NSData *)data;
  100. - (NSFileHandle *)uploadFileHandle;
  101. - (void)setUploadFileHandle:(NSFileHandle *)fileHandle;
  102. // The location URL is used to restart upload of a file handle
  103. - (NSURL *)uploadLocationURL;
  104. - (void)setUploadLocationURL:(NSURL *)url;
  105. - (NSString *)uploadMIMEType;
  106. - (void)setUploadMIMEType:(NSString *)str;
  107. // support for uploading media data without the XML from the GDataObject
  108. - (BOOL)shouldUploadDataOnly;
  109. - (void)setShouldUploadDataOnly:(BOOL)flag;
  110. // http slug (filename) header when uploading
  111. - (NSString *)uploadSlug;
  112. - (void)setUploadSlug:(NSString *)str;
  113. // extension for entries which may include deleted elements
  114. - (BOOL)isDeleted;
  115. - (void)setIsDeleted:(BOOL)isDeleted;
  116. // extensions for Atom publishing control
  117. - (GDataAtomPubControl *)atomPubControl;
  118. - (void)setAtomPubControl:(GDataAtomPubControl *)obj;
  119. // batch support
  120. + (NSDictionary *)batchNamespaces;
  121. - (GDataBatchOperation *)batchOperation;
  122. - (void)setBatchOperation:(GDataBatchOperation *)obj;
  123. // the batch ID is an arbitrary string defined by clients, and present in the
  124. // batch response feed to let the client match each entry's response to
  125. // the entry
  126. - (GDataBatchID *)batchID;
  127. - (void)setBatchID:(GDataBatchID *)obj;
  128. - (void)setBatchIDWithString:(NSString *)str;
  129. - (GDataBatchStatus *)batchStatus;
  130. - (void)setBatchStatus:(GDataBatchStatus *)obj;
  131. - (GDataBatchInterrupted *)batchInterrupted;
  132. - (void)setBatchInterrupted:(GDataBatchInterrupted *)obj;
  133. // convenience accessors
  134. - (NSArray *)categoriesWithScheme:(NSString *)scheme;
  135. // most entries have a category element with scheme kGDataCategoryScheme
  136. // that indicates the kind of entry
  137. - (GDataCategory *)kindCategory;
  138. - (NSArray *)linksWithRelAttributeValue:(NSString *)relValue;
  139. - (GDataLink *)linkWithRelAttributeValue:(NSString *)relValue;
  140. - (GDataLink *)linkWithRelAttributeValue:(NSString *)rel
  141. type:(NSString *)type;
  142. - (GDataLink *)feedLink;
  143. - (GDataLink *)editLink;
  144. - (GDataLink *)editMediaLink;
  145. - (GDataLink *)alternateLink;
  146. - (GDataLink *)relatedLink;
  147. - (GDataLink *)postLink;
  148. - (GDataLink *)selfLink;
  149. - (GDataLink *)HTMLLink;
  150. - (GDataLink *)uploadEditLink;
  151. - (BOOL)canEdit;
  152. ///////////////////////////////////////////////////////////////////////////////
  153. //
  154. // Protected methods
  155. //
  156. // All remaining methods are intended for use only by subclasses
  157. // of GDataEntryBase.
  158. //
  159. // subclasses call registerEntryClass to register their standardEntryKind
  160. + (void)registerEntryClass;
  161. + (Class)entryClassForCategoryWithScheme:(NSString *)scheme
  162. term:(NSString *)term;
  163. + (Class)entryClassForKindAttributeValue:(NSString *)kind;
  164. // temporary bridge method
  165. + (void)registerEntryClass:(Class)theClass
  166. forCategoryWithScheme:(NSString *)scheme
  167. term:(NSString *)term;
  168. // subclasses override standardEntryKind to provide the term string for the
  169. // kind attribute of their kind category element, if any
  170. + (NSString *)standardEntryKind;
  171. @end