PageRenderTime 52ms CodeModel.GetById 12ms app.highlight 35ms RepoModel.GetById 1ms app.codeStats 0ms

/core/externals/update-engine/externals/gdata-objectivec-client/Source/Media/GDataMediaGroup.m

http://macfuse.googlecode.com/
Objective C | 259 lines | 163 code | 60 blank | 36 comment | 2 complexity | 1e4faebb480f846595047bd6a5ef4f17 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//  GDataMediaGroup.m
 18//
 19
 20#if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_PHOTOS_SERVICE \
 21  || GDATA_INCLUDE_YOUTUBE_SERVICE
 22
 23#define GDATAMEDIAGROUP_DEFINE_GLOBALS 1
 24#import "GDataMediaGroup.h"
 25
 26#import "GDataMediaContent.h"
 27#import "GDataMediaCredit.h"
 28#import "GDataMediaPlayer.h"
 29#import "GDataMediaThumbnail.h"
 30#import "GDataMediaKeywords.h"
 31#import "GDataMediaCategory.h"
 32#import "GDataMediaRating.h"
 33#import "GDataMediaRestriction.h"
 34
 35// we'll define MediaDescription and MediaTitle here, since they're
 36// just derived classes of GDataTextConstruct
 37
 38@implementation GDataMediaDescription
 39+ (NSString *)extensionElementURI       { return kGDataNamespaceMedia; }
 40+ (NSString *)extensionElementPrefix    { return kGDataNamespaceMediaPrefix; }
 41+ (NSString *)extensionElementLocalName { return @"description"; }
 42@end
 43
 44@implementation GDataMediaTitle
 45+ (NSString *)extensionElementURI       { return kGDataNamespaceMedia; }
 46+ (NSString *)extensionElementPrefix    { return kGDataNamespaceMediaPrefix; }
 47+ (NSString *)extensionElementLocalName { return @"title"; }
 48@end
 49
 50
 51@implementation GDataMediaGroup
 52// for media:group, like 
 53// <media:group> <media:contents  ... /> </media:group>
 54
 55+ (NSString *)extensionElementURI       { return kGDataNamespaceMedia; }
 56+ (NSString *)extensionElementPrefix    { return kGDataNamespaceMediaPrefix; }
 57+ (NSString *)extensionElementLocalName { return @"group"; }
 58
 59#pragma mark -
 60
 61+ (id)mediaGroup {
 62  GDataMediaGroup *obj = [self object];
 63  return obj;
 64}
 65
 66- (void)addExtensionDeclarations {
 67  
 68  [super addExtensionDeclarations];
 69  
 70  [self addExtensionDeclarationForParentClass:[self class]
 71                                 childClasses:
 72   [GDataMediaContent class],
 73   [GDataMediaCategory class],
 74   [GDataMediaCredit class],
 75   [GDataMediaDescription class],
 76   [GDataMediaPlayer class],
 77   [GDataMediaRating class],
 78   [GDataMediaRestriction class],
 79   [GDataMediaThumbnail class],
 80   [GDataMediaKeywords class],
 81   [GDataMediaTitle class],
 82   nil];  
 83  
 84  // still unsupported:
 85  // MediaCopyright, MediaHash, MediaText
 86}
 87
 88#if !GDATA_SIMPLE_DESCRIPTIONS
 89- (NSMutableArray *)itemsForDescription {
 90
 91  static struct GDataDescriptionRecord descRecs[] = {
 92    { @"categories",  @"mediaCategories",  kGDataDescArrayDescs   },
 93    { @"contents",    @"mediaContents",    kGDataDescArrayDescs   },
 94    { @"credits",     @"mediaCredits",     kGDataDescArrayDescs   },
 95    { @"thumbnails",  @"mediaThumbnails",  kGDataDescArrayDescs   },
 96    { @"keywords",    @"mediaKeywords",    kGDataDescValueLabeled },
 97    { @"description", @"mediaDescription", kGDataDescValueLabeled },
 98    { @"players",     @"mediaPlayers",     kGDataDescArrayDescs   },
 99    { @"ratings",     @"mediaRatings",     kGDataDescArrayDescs   },
100    { @"title",       @"mediaTitle",       kGDataDescValueLabeled },
101    { nil, nil, (GDataDescRecTypes)0 }
102  };
103
104  NSMutableArray *items = [super itemsForDescription];
105  [self addDescriptionRecords:descRecs toItems:items];
106  return items;
107}
108#endif
109
110#pragma mark -
111
112// there are many more possible extensions; see MediaGroup.java
113//
114// Initially, we're just supporting the ones needed for Google Photos
115
116// MediaCategories
117
118- (NSArray *)mediaCategories {
119  NSArray *array = [self objectsForExtensionClass:[GDataMediaCategory class]];
120  return array;
121}
122
123- (void)setMediaCategories:(NSArray *)array {
124  [self setObjects:array forExtensionClass:[GDataMediaCategory class]]; 
125}
126
127- (void)addMediaCategory:(GDataMediaCategory *)attribute {
128  [self addObject:attribute forExtensionClass:[GDataMediaCategory class]]; 
129}
130
131// MediaContents
132
133- (NSArray *)mediaContents {
134  NSArray *array = [self objectsForExtensionClass:[GDataMediaContent class]];
135  return array;
136}
137
138- (void)setMediaContents:(NSArray *)array {
139  [self setObjects:array forExtensionClass:[GDataMediaContent class]]; 
140}
141
142- (void)addMediaContent:(GDataMediaContent *)attribute {
143  [self addObject:attribute forExtensionClass:[GDataMediaContent class]]; 
144}
145
146// MediaCredits
147
148- (NSArray *)mediaCredits {
149  NSArray *array = [self objectsForExtensionClass:[GDataMediaCredit class]];
150  return array;
151}
152
153- (void)setMediaCredits:(NSArray *)array {
154  [self setObjects:array forExtensionClass:[GDataMediaCredit class]]; 
155}
156
157- (void)addMediaCredit:(GDataMediaCredit *)attribute {
158  [self addObject:attribute forExtensionClass:[GDataMediaCredit class]]; 
159}
160
161// MediaPlayers
162
163- (NSArray *)mediaPlayers {
164  NSArray *array = [self objectsForExtensionClass:[GDataMediaPlayer class]];
165  return array;
166}
167
168- (void)setMediaPlayers:(NSArray *)array {
169  [self setObjects:array forExtensionClass:[GDataMediaPlayer class]]; 
170}
171
172- (void)addMediaPlayer:(GDataMediaPlayer *)attribute {
173  [self addObject:attribute forExtensionClass:[GDataMediaPlayer class]]; 
174}
175
176// MediaRatings
177
178- (NSArray *)mediaRatings {
179  NSArray *array = [self objectsForExtensionClass:[GDataMediaRating class]];
180  return array;
181}
182
183- (void)setMediaRatings:(NSArray *)array {
184  [self setObjects:array forExtensionClass:[GDataMediaRating class]]; 
185}
186
187- (void)addMediaRating:(GDataMediaRating *)attribute {
188  [self addObject:attribute forExtensionClass:[GDataMediaRating class]]; 
189}
190
191// MediaRatings
192
193- (NSArray *)mediaRestrictions {
194  NSArray *array = [self objectsForExtensionClass:[GDataMediaRestriction class]];
195  return array;
196}
197
198- (void)setMediaRestrictions:(NSArray *)array {
199  [self setObjects:array forExtensionClass:[GDataMediaRestriction class]]; 
200}
201
202- (void)addMediaRestriction:(GDataMediaRestriction *)attribute {
203  [self addObject:attribute forExtensionClass:[GDataMediaRestriction class]]; 
204}
205
206// MediaThumbnails
207
208- (NSArray *)mediaThumbnails {
209  NSArray *array = [self objectsForExtensionClass:[GDataMediaThumbnail class]];
210  return array;
211}
212
213- (void)setMediaThumbnails:(NSArray *)array {
214  [self setObjects:array forExtensionClass:[GDataMediaThumbnail class]]; 
215}
216
217- (void)addMediaThumbnail:(GDataMediaThumbnail *)attribute {
218  [self addObject:attribute forExtensionClass:[GDataMediaThumbnail class]]; 
219}
220
221// MediaKeywords
222
223- (GDataMediaKeywords *)mediaKeywords {
224  GDataMediaKeywords *obj = 
225      [self objectForExtensionClass:[GDataMediaKeywords class]];
226  return obj;
227}
228
229- (void)setMediaKeywords:(GDataMediaKeywords *)obj {
230  [self setObject:obj forExtensionClass:[GDataMediaKeywords class]]; 
231}
232
233// MediaDescription
234
235- (GDataMediaDescription *)mediaDescription {
236  GDataMediaDescription *obj = 
237      [self objectForExtensionClass:[GDataMediaDescription class]];
238  return obj;
239}
240
241- (void)setMediaDescription:(GDataMediaDescription *)obj {
242  [self setObject:obj forExtensionClass:[GDataMediaDescription class]]; 
243}
244
245// MediaTitle
246
247- (GDataMediaTitle *)mediaTitle {
248  GDataMediaTitle *obj =
249    [self objectForExtensionClass:[GDataMediaTitle class]];
250  return obj;
251}
252
253- (void)setMediaTitle:(GDataMediaTitle *)obj {
254  [self setObject:obj forExtensionClass:[GDataMediaTitle class]]; 
255}
256
257@end
258
259#endif // #if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_*_SERVICE