My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes  
Changes to /trunk/Examples/BloggerSample/BloggerSampleWindowController.m
r650 vs. r729 Compare: vs.  Format:
Revision r729
Go to: 
Project members, sign in to write a code review
/trunk/Examples/BloggerSample/BloggerSampleWindowController.m   r650 /trunk/Examples/BloggerSample/BloggerSampleWindowController.m   r729
1 /* Copyright (c) 2009 Google Inc. 1 /* Copyright (c) 2009 Google Inc.
2 * 2 *
3 * Licensed under the Apache License, Version 2.0 (the "License"); 3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with 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 5 * You may obtain a copy of the License at
6 * 6 *
7 * http://www.apache.org/licenses/LICENSE-2.0 7 * http://www.apache.org/licenses/LICENSE-2.0
8 * 8 *
9 * Unless required by applicable law or agreed to in writing, software 9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS, 10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and 12 * See the License for the specific language governing permissions and
13 * limitations under the License. 13 * limitations under the License.
14 */ 14 */
15 15
16 // 16 //
17 // BloggerSampleWindowController.m 17 // BloggerSampleWindowController.m
18 // 18 //
19 19
20 //
21 // IMPORTANT:
22 //
23 // The XML-based API for Blogger has been replaced with a more efficient
24 // and easier-to-use JSON API. The JSON API is documented at
25 //
26 // https://developers.google.com/blogger/
27 //
28 // See the new Objective-C client library and sample code at
29 // http://code.google.com/p/google-api-objectivec-client/
30 //
31 // This sample application and library support for the XML-based Blogger
32 // API will eventually be removed.
33 //
34
20 #import "BloggerSampleWindowController.h" 35 #import "BloggerSampleWindowController.h"
21 36
22 @interface BloggerSampleWindowController (PrivateMethods) 37 @interface BloggerSampleWindowController (PrivateMethods)
23 - (void)updateUI; 38 - (void)updateUI;
24 39
25 - (void)fetchAllBlogs; 40 - (void)fetchAllBlogs;
26 - (void)fetchPostsForSelectedBlog; 41 - (void)fetchPostsForSelectedBlog;
27 - (void)addEntry; 42 - (void)addEntry;
28 - (void)updateSelectedPost; 43 - (void)updateSelectedPost;
29 - (void)deleteSelectedPost; 44 - (void)deleteSelectedPost;
30 45
31 - (GDataServiceGoogleBlogger *)bloggerService; 46 - (GDataServiceGoogleBlogger *)bloggerService;
32 - (GDataEntryBlog *)selectedBlog; 47 - (GDataEntryBlog *)selectedBlog;
33 - (GDataEntryBlogPost *)selectedPost; 48 - (GDataEntryBlogPost *)selectedPost;
34 - (GDataEntryBlogComment *)selectedComment; 49 - (GDataEntryBlogComment *)selectedComment;
35 50
36 - (GDataFeedBase *)blogFeed; 51 - (GDataFeedBase *)blogFeed;
37 - (void)setBlogFeed:(GDataFeedBase *)feed; 52 - (void)setBlogFeed:(GDataFeedBase *)feed;
38 - (NSError *)blogFetchError; 53 - (NSError *)blogFetchError;
39 - (void)setBlogFetchError:(NSError *)error; 54 - (void)setBlogFetchError:(NSError *)error;
40 - (GDataServiceTicket *)blogFeedTicket; 55 - (GDataServiceTicket *)blogFeedTicket;
41 - (void)setBlogFeedTicket:(GDataServiceTicket *)ticket; 56 - (void)setBlogFeedTicket:(GDataServiceTicket *)ticket;
42 57
43 - (GDataFeedBase *)postFeed; 58 - (GDataFeedBase *)postFeed;
44 - (void)setPostFeed:(GDataFeedBase *)feed; 59 - (void)setPostFeed:(GDataFeedBase *)feed;
45 - (NSError *)postFetchError; 60 - (NSError *)postFetchError;
46 - (void)setPostFetchError:(NSError *)error; 61 - (void)setPostFetchError:(NSError *)error;
47 - (GDataServiceTicket *)postFeedTicket; 62 - (GDataServiceTicket *)postFeedTicket;
48 - (void)setPostFeedTicket:(GDataServiceTicket *)ticket; 63 - (void)setPostFeedTicket:(GDataServiceTicket *)ticket;
49 64
50 - (GDataServiceTicket *)editPostTicket; 65 - (GDataServiceTicket *)editPostTicket;
51 - (void)setEditPostTicket:(GDataServiceTicket *)ticket; 66 - (void)setEditPostTicket:(GDataServiceTicket *)ticket;
52 67
53 - (GDataFeedBase *)commentFeed; 68 - (GDataFeedBase *)commentFeed;
54 - (void)setCommentFeed:(GDataFeedBase *)feed; 69 - (void)setCommentFeed:(GDataFeedBase *)feed;
55 - (NSError *)commentFetchError; 70 - (NSError *)commentFetchError;
56 - (void)setCommentFetchError:(NSError *)error; 71 - (void)setCommentFetchError:(NSError *)error;
57 - (GDataServiceTicket *)commentFeedTicket; 72 - (GDataServiceTicket *)commentFeedTicket;
58 - (void)setCommentFeedTicket:(GDataServiceTicket *)ticket; 73 - (void)setCommentFeedTicket:(GDataServiceTicket *)ticket;
59 74
60 @end 75 @end
61 76
62 @implementation BloggerSampleWindowController 77 @implementation BloggerSampleWindowController
63 78
64 + (BloggerSampleWindowController *)sharedBloggerSampleWindowController { 79 + (BloggerSampleWindowController *)sharedBloggerSampleWindowController {
65 80
66 static BloggerSampleWindowController* gController = nil; 81 static BloggerSampleWindowController* gController = nil;
67 82
68 if (!gController) { 83 if (!gController) {
69 gController = [[BloggerSampleWindowController alloc] init]; 84 gController = [[BloggerSampleWindowController alloc] init];
70 } 85 }
71 return gController; 86 return gController;
72 } 87 }
73 88
74 89
75 - (id)init { 90 - (id)init {
76 return [self initWithWindowNibName:@"BloggerSampleWindow"]; 91 return [self initWithWindowNibName:@"BloggerSampleWindow"];
77 } 92 }
78 93
79 - (void)awakeFromNib { 94 - (void)awakeFromNib {
80 // Set the result text fields to have a distinctive color and mono-spaced font 95 // Set the result text fields to have a distinctive color and mono-spaced font
81 [mBlogsResultTextField setTextColor:[NSColor darkGrayColor]]; 96 [mBlogsResultTextField setTextColor:[NSColor darkGrayColor]];
82 [mPostsResultTextField setTextColor:[NSColor darkGrayColor]]; 97 [mPostsResultTextField setTextColor:[NSColor darkGrayColor]];
83 [mCommentsResultTextField setTextColor:[NSColor darkGrayColor]]; 98 [mCommentsResultTextField setTextColor:[NSColor darkGrayColor]];
84 99
85 NSFont *resultTextFont = [NSFont fontWithName:@"Monaco" size:9]; 100 NSFont *resultTextFont = [NSFont fontWithName:@"Monaco" size:9];
86 [mBlogsResultTextField setFont:resultTextFont]; 101 [mBlogsResultTextField setFont:resultTextFont];
87 [mPostsResultTextField setFont:resultTextFont]; 102 [mPostsResultTextField setFont:resultTextFont];
88 [mCommentsResultTextField setFont:resultTextFont]; 103 [mCommentsResultTextField setFont:resultTextFont];
89 104
90 [self updateUI]; 105 [self updateUI];
91 } 106 }
92 107
93 - (void)dealloc { 108 - (void)dealloc {
94 [mBlogFeed release]; 109 [mBlogFeed release];
95 [mBlogFeedTicket release]; 110 [mBlogFeedTicket release];
96 [mBlogFetchError release]; 111 [mBlogFetchError release];
97 112
98 [mPostFeed release]; 113 [mPostFeed release];
99 [mPostFeedTicket release]; 114 [mPostFeedTicket release];
100 [mPostFetchError release]; 115 [mPostFetchError release];
101 116
102 [mEditPostTicket release]; 117 [mEditPostTicket release];
103 118
104 [mCommentFeed release]; 119 [mCommentFeed release];
105 [mCommentFeedTicket release]; 120 [mCommentFeedTicket release];
106 [mCommentFetchError release]; 121 [mCommentFetchError release];
107 122
108 [super dealloc]; 123 [super dealloc];
109 } 124 }
110 125
111 #pragma mark - 126 #pragma mark -
112 127
113 - (void)updateUI { 128 - (void)updateUI {
114 129
115 // blogs list display 130 // blogs list display
116 [mBlogsTable reloadData]; 131 [mBlogsTable reloadData];
117 132
118 if (mBlogFeedTicket != nil) { 133 if (mBlogFeedTicket != nil) {
119 [mBlogsProgressIndicator startAnimation:self]; 134 [mBlogsProgressIndicator startAnimation:self];
120 } else { 135 } else {
121 [mBlogsProgressIndicator stopAnimation:self]; 136 [mBlogsProgressIndicator stopAnimation:self];
122 } 137 }
123 138
124 // blogs fetch result or selected item 139 // blogs fetch result or selected item
125 NSString *blogsResultStr = @""; 140 NSString *blogsResultStr = @"";
126 if (mBlogFetchError) { 141 if (mBlogFetchError) {
127 blogsResultStr = [mBlogFetchError description]; 142 blogsResultStr = [mBlogFetchError description];
128 } else { 143 } else {
129 GDataEntryBlog *blog = [self selectedBlog]; 144 GDataEntryBlog *blog = [self selectedBlog];
130 if (blog) { 145 if (blog) {
131 blogsResultStr = [blog description]; 146 blogsResultStr = [blog description];
132 } 147 }
133 } 148 }
134 [mBlogsResultTextField setString:blogsResultStr]; 149 [mBlogsResultTextField setString:blogsResultStr];
135 150
136 // post list display 151 // post list display
137 [mPostsTable reloadData]; 152 [mPostsTable reloadData];
138 153
139 if (mPostFeedTicket != nil) { 154 if (mPostFeedTicket != nil) {
140 [mPostsProgressIndicator startAnimation:self]; 155 [mPostsProgressIndicator startAnimation:self];
141 } else { 156 } else {
142 [mPostsProgressIndicator stopAnimation:self]; 157 [mPostsProgressIndicator stopAnimation:self];
143 } 158 }
144 159
145 // post fetch result or selected item 160 // post fetch result or selected item
146 NSString *postResultStr = @""; 161 NSString *postResultStr = @"";
147 if (mPostFetchError) { 162 if (mPostFetchError) {
148 postResultStr = [mPostFetchError description]; 163 postResultStr = [mPostFetchError description];
149 } else { 164 } else {
150 if ([self selectedPost] != nil) { 165 if ([self selectedPost] != nil) {
151 postResultStr = [[self selectedPost] description]; 166 postResultStr = [[self selectedPost] description];
152 } 167 }
153 } 168 }
154 [mPostsResultTextField setString:postResultStr]; 169 [mPostsResultTextField setString:postResultStr];
155 170
156 // enable/disable edit buttons 171 // enable/disable edit buttons
157 BOOL isBlogSelected = ([self selectedBlog] != nil); 172 BOOL isBlogSelected = ([self selectedBlog] != nil);
158 [mAddPostButton setEnabled:isBlogSelected]; 173 [mAddPostButton setEnabled:isBlogSelected];
159 174
160 BOOL isPostSelected = ([self selectedPost] != nil); 175 BOOL isPostSelected = ([self selectedPost] != nil);
161 [mDeletePostButton setEnabled:isPostSelected]; 176 [mDeletePostButton setEnabled:isPostSelected];
162 [mPostDraftCheckBox setEnabled:isPostSelected]; 177 [mPostDraftCheckBox setEnabled:isPostSelected];
163 178
164 BOOL canUpdatePost = NO; 179 BOOL canUpdatePost = NO;
165 180
166 if (isPostSelected) { 181 if (isPostSelected) {
167 // the post can be updated if either the text or the draft checkbox state 182 // the post can be updated if either the text or the draft checkbox state
168 // has changed 183 // has changed
169 NSString *postStr = [[[self selectedPost] content] stringValue]; 184 NSString *postStr = [[[self selectedPost] content] stringValue];
170 NSString *editedStr = [mPostEditField stringValue]; 185 NSString *editedStr = [mPostEditField stringValue];
171 186
172 BOOL isPostDraft = [[[self selectedPost] atomPubControl] isDraft]; 187 BOOL isPostDraft = [[[self selectedPost] atomPubControl] isDraft];
173 BOOL isEditedDraft = ([mPostDraftCheckBox state] == NSOnState); 188 BOOL isEditedDraft = ([mPostDraftCheckBox state] == NSOnState);
174 189
175 canUpdatePost = ![postStr isEqual:editedStr] 190 canUpdatePost = ![postStr isEqual:editedStr]
176 || (isPostDraft != isEditedDraft); 191 || (isPostDraft != isEditedDraft);
177 } 192 }
178 [mUpdatePostButton setEnabled:canUpdatePost]; 193 [mUpdatePostButton setEnabled:canUpdatePost];
179 194
180 if (mEditPostTicket != nil) { 195 if (mEditPostTicket != nil) {
181 [mEditProgressIndicator startAnimation:self]; 196 [mEditProgressIndicator startAnimation:self];
182 } else { 197 } else {
183 [mEditProgressIndicator stopAnimation:self]; 198 [mEditProgressIndicator stopAnimation:self];
184 } 199 }
185 200
186 // comment list display 201 // comment list display
187 [mCommentsTable reloadData]; 202 [mCommentsTable reloadData];
188 203
189 if (mCommentFeedTicket != nil) { 204 if (mCommentFeedTicket != nil) {
190 [mCommentsProgressIndicator startAnimation:self]; 205 [mCommentsProgressIndicator startAnimation:self];
191 } else { 206 } else {
192 [mCommentsProgressIndicator stopAnimation:self]; 207 [mCommentsProgressIndicator stopAnimation:self];
193 } 208 }
194 209
195 // comment fetch result or selected item 210 // comment fetch result or selected item
196 NSString *commentResultStr = @""; 211 NSString *commentResultStr = @"";
197 if (mCommentFetchError) { 212 if (mCommentFetchError) {
198 commentResultStr = [mCommentFetchError description]; 213 commentResultStr = [mCommentFetchError description];
199 } else { 214 } else {
200 if ([self selectedComment] != nil) { 215 if ([self selectedComment] != nil) {
201 commentResultStr = [[self selectedComment] description]; 216 commentResultStr = [[self selectedComment] description];
202 } 217 }
203 } 218 }
204 [mCommentsResultTextField setString:commentResultStr]; 219 [mCommentsResultTextField setString:commentResultStr];
205 } 220 }
206 221
207 - (void)reloadEntryEditField { 222 - (void)reloadEntryEditField {
208 GDataEntryBlogPost *entry = [self selectedPost]; 223 GDataEntryBlogPost *entry = [self selectedPost];
209 if (entry) { 224 if (entry) {
210 [mPostEditField setStringValue:[[entry content] stringValue]]; 225 [mPostEditField setStringValue:[[entry content] stringValue]];
211 226
212 BOOL isDraft = [[entry atomPubControl] isDraft]; 227 BOOL isDraft = [[entry atomPubControl] isDraft];
213 [mPostDraftCheckBox setState:(isDraft ? NSOnState : NSOffState)]; 228 [mPostDraftCheckBox setState:(isDraft ? NSOnState : NSOffState)];
214 } 229 }
215 } 230 }
216 231
217 #pragma mark IBActions 232 #pragma mark IBActions
218 - (IBAction)getBlogsClicked:(id)sender { 233 - (IBAction)getBlogsClicked:(id)sender {
219 234
220 NSCharacterSet *whitespace = [NSCharacterSet whitespaceAndNewlineCharacterSet]; 235 NSCharacterSet *whitespace = [NSCharacterSet whitespaceAndNewlineCharacterSet];
221 236
222 NSString *username = [mUsernameField stringValue]; 237 NSString *username = [mUsernameField stringValue];
223 username = [username stringByTrimmingCharactersInSet:whitespace]; 238 username = [username stringByTrimmingCharactersInSet:whitespace];
224 239
225 if ([username rangeOfString:@"@"].location == NSNotFound) { 240 if ([username rangeOfString:@"@"].location == NSNotFound) {
226 // if no domain was supplied, add @gmail.com 241 // if no domain was supplied, add @gmail.com
227 username = [username stringByAppendingString:@"@gmail.com"]; 242 username = [username stringByAppendingString:@"@gmail.com"];
228 } 243 }
229 244
230 [mUsernameField setStringValue:username]; 245 [mUsernameField setStringValue:username];
231 246
232 [self fetchAllBlogs]; 247 [self fetchAllBlogs];
233 } 248 }
234 249
235 - (IBAction)addPostClicked:(id)sender { 250 - (IBAction)addPostClicked:(id)sender {
236 [self addEntry]; 251 [self addEntry];
237 } 252 }
238 253
239 - (IBAction)updatePostClicked:(id)sender { 254 - (IBAction)updatePostClicked:(id)sender {
240 [self updateSelectedPost]; 255 [self updateSelectedPost];
241 } 256 }
242 257
243 - (IBAction)deletePostClicked:(id)sender { 258 - (IBAction)deletePostClicked:(id)sender {
244 [self deleteSelectedPost]; 259 [self deleteSelectedPost];
245 } 260 }
246 261
247 - (IBAction)draftCheckboxClicked:(id)sender { 262 - (IBAction)draftCheckboxClicked:(id)sender {
248 [self updateUI]; 263 [self updateUI];
249 } 264 }
250 265
251 - (IBAction)loggingCheckboxClicked:(id)sender { 266 - (IBAction)loggingCheckboxClicked:(id)sender {
252 [GTMHTTPFetcher setLoggingEnabled:[sender state]]; 267 [GTMHTTPFetcher setLoggingEnabled:[sender state]];
253 } 268 }
254 269
255 #pragma mark - 270 #pragma mark -
256 271
257 // get a google service object with the current username/password 272 // get a google service object with the current username/password
258 // 273 //
259 // A "service" object handles networking tasks. Service objects 274 // A "service" object handles networking tasks. Service objects
260 // contain user authentication information as well as networking 275 // contain user authentication information as well as networking
261 // state information (such as cookies and the "last modified" date for 276 // state information (such as cookies and the "last modified" date for
262 // fetched data.) 277 // fetched data.)
263 278
264 - (GDataServiceGoogleBlogger *)bloggerService { 279 - (GDataServiceGoogleBlogger *)bloggerService {
265 280
266 static GDataServiceGoogleBlogger* service = nil; 281 static GDataServiceGoogleBlogger* service = nil;
267 282
268 if (!service) { 283 if (!service) {
269 service = [[GDataServiceGoogleBlogger alloc] init]; 284 service = [[GDataServiceGoogleBlogger alloc] init];
270 285
271 [service setShouldCacheResponseData:YES]; 286 [service setShouldCacheResponseData:YES];
272 [service setServiceShouldFollowNextLinks:YES]; 287 [service setServiceShouldFollowNextLinks:YES];
273 } 288 }
274 289
275 // update the name/password each time the service is requested 290 // update the name/password each time the service is requested
276 NSString *username = [mUsernameField stringValue]; 291 NSString *username = [mUsernameField stringValue];
277 NSString *password = [mPasswordField stringValue]; 292 NSString *password = [mPasswordField stringValue];
278 293
279 [service setUserCredentialsWithUsername:username 294 [service setUserCredentialsWithUsername:username
280 password:password]; 295 password:password];
281 296
282 return service; 297 return service;
283 } 298 }
284 299
285 // get the blog selected in the top list, or nil if none 300 // get the blog selected in the top list, or nil if none
286 - (GDataEntryBlog *)selectedBlog { 301 - (GDataEntryBlog *)selectedBlog {
287 302
288 NSArray *blogs = [mBlogFeed entries]; 303 NSArray *blogs = [mBlogFeed entries];
289 int rowIndex = [mBlogsTable selectedRow]; 304 int rowIndex = [mBlogsTable selectedRow];
290 if ([blogs count] > 0 && rowIndex > -1) { 305 if ([blogs count] > 0 && rowIndex > -1) {
291 306
292 GDataEntryBlog *blog = [blogs objectAtIndex:rowIndex]; 307 GDataEntryBlog *blog = [blogs objectAtIndex:rowIndex];
293 return blog; 308 return blog;
294 } 309 }
295 return nil; 310 return nil;
296 } 311 }
297 312
298 // get the entry selected in the bottom list, or nil if none 313 // get the entry selected in the bottom list, or nil if none
299 - (GDataEntryBlogPost *)selectedPost { 314 - (GDataEntryBlogPost *)selectedPost {
300 315
301 NSArray *entries = [mPostFeed entries]; 316 NSArray *entries = [mPostFeed entries];
302 int rowIndex = [mPostsTable selectedRow]; 317 int rowIndex = [mPostsTable selectedRow];
303 if ([entries count] > 0 && rowIndex > -1) { 318 if ([entries count] > 0 && rowIndex > -1) {
304 319
305 GDataEntryBlogPost *entry = [entries objectAtIndex:rowIndex]; 320 GDataEntryBlogPost *entry = [entries objectAtIndex:rowIndex];
306 return entry; 321 return entry;
307 } 322 }
308 return nil; 323 return nil;
309 } 324 }
310 325
311 // get the entry selected in the bottom list, or nil if none 326 // get the entry selected in the bottom list, or nil if none
312 - (GDataEntryBlogComment *)selectedComment { 327 - (GDataEntryBlogComment *)selectedComment {
313 328
314 NSArray *entries = [mCommentFeed entries]; 329 NSArray *entries = [mCommentFeed entries];
315 int rowIndex = [mCommentsTable selectedRow]; 330 int rowIndex = [mCommentsTable selectedRow];
316 if ([entries count] > 0 && rowIndex > -1) { 331 if ([entries count] > 0 && rowIndex > -1) {
317 332
318 GDataEntryBlogComment *entry = [entries objectAtIndex:rowIndex]; 333 GDataEntryBlogComment *entry = [entries objectAtIndex:rowIndex];
319 return entry; 334 return entry;
320 } 335 }
321 return nil; 336 return nil;
322 } 337 }
323 338
324 #pragma mark Fetch all blogs 339 #pragma mark Fetch all blogs
325 340
326 // begin retrieving the list of the user's blogs 341 // begin retrieving the list of the user's blogs
327 - (void)fetchAllBlogs { 342 - (void)fetchAllBlogs {
328 343
329 [self setBlogFeed:nil]; 344 [self setBlogFeed:nil];
330 [self setBlogFetchError:nil]; 345 [self setBlogFetchError:nil];
331 346
332 [self setPostFeed:nil]; 347 [self setPostFeed:nil];
333 [self setPostFetchError:nil]; 348 [self setPostFetchError:nil];
334 349
335 [self setCommentFeed:nil]; 350 [self setCommentFeed:nil];
336 [self setCommentFetchError:nil]; 351 [self setCommentFetchError:nil];
337 352
338 NSURL* feedURL = [GDataServiceGoogleBlogger blogFeedURLForUserID:kGDataServiceDefaultUser]; 353 NSURL* feedURL = [GDataServiceGoogleBlogger blogFeedURLForUserID:kGDataServiceDefaultUser];
339 354
340 GDataServiceGoogleBlogger *service = [self bloggerService]; 355 GDataServiceGoogleBlogger *service = [self bloggerService];
341 GDataServiceTicket *ticket; 356 GDataServiceTicket *ticket;
342 357
343 ticket = [service fetchFeedWithURL:feedURL 358 ticket = [service fetchFeedWithURL:feedURL
344 feedClass:[GDataFeedBlog class] 359 feedClass:[GDataFeedBlog class]
345 delegate:self 360 delegate:self
346 didFinishSelector:@selector(blogListTicket:finishedWithFeed:error:)]; 361 didFinishSelector:@selector(blogListTicket:finishedWithFeed:error:)];
347 [self setBlogFeedTicket:ticket]; 362 [self setBlogFeedTicket:ticket];
348 363
349 [self updateUI]; 364 [self updateUI];
350 } 365 }
351 366
352 // blog feed fetch callback 367 // blog feed fetch callback
353 - (void)blogListTicket:(GDataServiceTicket *)ticket 368 - (void)blogListTicket:(GDataServiceTicket *)ticket
354 finishedWithFeed:(GDataFeedBase *)feed 369 finishedWithFeed:(GDataFeedBase *)feed
355 error:(NSError *)error { 370 error:(NSError *)error {
356 371
357 [self setBlogFeed:feed]; 372 [self setBlogFeed:feed];
358 [self setBlogFetchError:error]; 373 [self setBlogFetchError:error];
359 [self setBlogFeedTicket:nil]; 374 [self setBlogFeedTicket:nil];
360 375
361 [self updateUI]; 376 [self updateUI];
362 } 377 }
363 378
364 #pragma mark Fetch a blog's posts 379 #pragma mark Fetch a blog's posts
365 380
366 // for the blog selected in the top list, begin retrieving the list of 381 // for the blog selected in the top list, begin retrieving the list of
367 // entries 382 // entries
368 - (void)fetchPostsForSelectedBlog { 383 - (void)fetchPostsForSelectedBlog {
369 384
370 GDataEntryBlog *blog = [self selectedBlog]; 385 GDataEntryBlog *blog = [self selectedBlog];
371 if (blog != nil) { 386 if (blog != nil) {
372 387
373 [self setPostFeed:nil]; 388 [self setPostFeed:nil];
374 [self setPostFetchError:nil]; 389 [self setPostFetchError:nil];
375 390
376 [self setCommentFeed:nil]; 391 [self setCommentFeed:nil];
377 [self setCommentFetchError:nil]; 392 [self setCommentFetchError:nil];
378 393
379 NSURL *feedURL = [[blog feedLink] URL]; 394 NSURL *feedURL = [[blog feedLink] URL];
380 395
381 GDataServiceGoogleBlogger *service = [self bloggerService]; 396 GDataServiceGoogleBlogger *service = [self bloggerService];
382 GDataServiceTicket *ticket; 397 GDataServiceTicket *ticket;
383 ticket = [service fetchFeedWithURL:feedURL 398 ticket = [service fetchFeedWithURL:feedURL
384 feedClass:[GDataFeedBlogPost class] 399 feedClass:[GDataFeedBlogPost class]
385 delegate:self 400 delegate:self
386 didFinishSelector:@selector(blogPostTicket:finishedWithFeed:error:)]; 401 didFinishSelector:@selector(blogPostTicket:finishedWithFeed:error:)];
387 [self setPostFeedTicket:ticket]; 402 [self setPostFeedTicket:ticket];
388 [self updateUI]; 403 [self updateUI];
389 } 404 }
390 } 405 }
391 406
392 // post feed fetch callback 407 // post feed fetch callback
393 - (void)blogPostTicket:(GDataServiceTicket *)ticket 408 - (void)blogPostTicket:(GDataServiceTicket *)ticket
394 finishedWithFeed:(GDataFeedBase *)feed 409 finishedWithFeed:(GDataFeedBase *)feed
395 error:(NSError *)error { 410 error:(NSError *)error {
396 411
397 [self setPostFeed:feed]; 412 [self setPostFeed:feed];
398 [self setPostFetchError:error]; 413 [self setPostFetchError:error];
399 [self setPostFeedTicket:nil]; 414 [self setPostFeedTicket:nil];
400 415
401 [self updateUI]; 416 [self updateUI];
402 } 417 }
403 418
404 #pragma mark Fetch a blog post's comments 419 #pragma mark Fetch a blog post's comments
405 420
406 // for the post selected in the middle list, begin retrieving the feed of 421 // for the post selected in the middle list, begin retrieving the feed of
407 // comments 422 // comments
408 - (void)fetchCommentsForSelectedPost { 423 - (void)fetchCommentsForSelectedPost {
409 424
410 GDataEntryBlogPost *post = [self selectedPost]; 425 GDataEntryBlogPost *post = [self selectedPost];
411 if (post != nil) { 426 if (post != nil) {
412 427
413 [self setCommentFeed:nil]; 428 [self setCommentFeed:nil];
414 [self setCommentFetchError:nil]; 429 [self setCommentFetchError:nil];
415 430
416 NSURL *feedURL = [[post repliesAtomLink] URL]; 431 NSURL *feedURL = [[post repliesAtomLink] URL];
417 if (feedURL != nil) { 432 if (feedURL != nil) {
418 GDataServiceGoogleBlogger *service = [self bloggerService]; 433 GDataServiceGoogleBlogger *service = [self bloggerService];
419 GDataServiceTicket *ticket; 434 GDataServiceTicket *ticket;
420 ticket = [service fetchFeedWithURL:feedURL 435 ticket = [service fetchFeedWithURL:feedURL
421 feedClass:[GDataFeedBlogComment class] 436 feedClass:[GDataFeedBlogComment class]
422 delegate:self 437 delegate:self
423 didFinishSelector:@selector(blogCommentTicket:finishedWithFeed:error:)]; 438 didFinishSelector:@selector(blogCommentTicket:finishedWithFeed:error:)];
424 [self setCommentFeedTicket:ticket]; 439 [self setCommentFeedTicket:ticket];
425 } 440 }
426 } 441 }
427 [self updateUI]; 442 [self updateUI];
428 } 443 }
429 444
430 // fetched comment feed callback 445 // fetched comment feed callback
431 - (void)blogCommentTicket:(GDataServiceTicket *)ticket 446 - (void)blogCommentTicket:(GDataServiceTicket *)ticket
432 finishedWithFeed:(GDataFeedBase *)feed 447 finishedWithFeed:(GDataFeedBase *)feed
433 error:(NSError *)error { 448 error:(NSError *)error {
434 449
435 [self setCommentFeed:feed]; 450 [self setCommentFeed:feed];
436 [self setCommentFetchError:error]; 451 [self setCommentFetchError:error];
437 [self setCommentFeedTicket:nil]; 452 [self setCommentFeedTicket:nil];
438 453
439 [self updateUI]; 454 [self updateUI];
440 } 455 }
441 456
442 #pragma mark Add an entry 457 #pragma mark Add an entry
443 458
444 - (void)addEntry { 459 - (void)addEntry {
445 GDataEntryBlogPost *newEntry = [GDataEntryBlogPost postEntry]; 460 GDataEntryBlogPost *newEntry = [GDataEntryBlogPost postEntry];
446 461
447 NSString *title = [NSString stringWithFormat:@"Post Created %@", 462 NSString *title = [NSString stringWithFormat:@"Post Created %@",
448 [NSDate date]]; 463 [NSDate date]];
449 NSString *content = [mPostEditField stringValue]; 464 NSString *content = [mPostEditField stringValue];
450 BOOL isDraft = [mPostDraftCheckBox state]; 465 BOOL isDraft = [mPostDraftCheckBox state];
451 466
452 [newEntry setTitleWithString:title]; 467 [newEntry setTitleWithString:title];
453 [newEntry setContentWithString:content]; 468 [newEntry setContentWithString:content];
454 [newEntry addAuthor:[GDataPerson personWithName:@"Blogger Sample App" 469 [newEntry addAuthor:[GDataPerson personWithName:@"Blogger Sample App"
455 email:nil]]; 470 email:nil]];
456 GDataAtomPubControl *atomPub; 471 GDataAtomPubControl *atomPub;
457 atomPub = [GDataAtomPubControl atomPubControlWithIsDraft:isDraft]; 472 atomPub = [GDataAtomPubControl atomPubControlWithIsDraft:isDraft];
458 [newEntry setAtomPubControl:atomPub]; 473 [newEntry setAtomPubControl:atomPub];
459 474
460 NSURL *postURL = [[[self selectedBlog] postLink] URL]; 475 NSURL *postURL = [[[self selectedBlog] postLink] URL];
461 if (postURL != nil) { 476 if (postURL != nil) {
462 GDataServiceGoogleBlogger *service = [self bloggerService]; 477 GDataServiceGoogleBlogger *service = [self bloggerService];
463 [service setServiceUserData:newEntry]; 478 [service setServiceUserData:newEntry];
464 479
465 GDataServiceTicket *ticket; 480 GDataServiceTicket *ticket;
466 ticket = [service fetchEntryByInsertingEntry:newEntry 481 ticket = [service fetchEntryByInsertingEntry:newEntry
467 forFeedURL:postURL 482 forFeedURL:postURL
468 delegate:self 483 delegate:self
469 didFinishSelector:@selector(addEntryTicket:finishedWithEntry:error:)]; 484 didFinishSelector:@selector(addEntryTicket:finishedWithEntry:error:)];
470 [self setEditPostTicket:ticket]; 485 [self setEditPostTicket:ticket];
471 [self updateUI]; 486 [self updateUI];
472 } 487 }
473 } 488 }
474 489
475 // add entry callback 490 // add entry callback
476 - (void)addEntryTicket:(GDataServiceTicket *)ticket 491 - (void)addEntryTicket:(GDataServiceTicket *)ticket
477 finishedWithEntry:(GDataEntryBlogPost *)addedEntry 492 finishedWithEntry:(GDataEntryBlogPost *)addedEntry
478 error:(NSError *)error { 493 error:(NSError *)error {
479 494
480 if (error == nil) { 495 if (error == nil) {
481 NSBeginAlertSheet(@"Add", nil, nil, nil, 496 NSBeginAlertSheet(@"Add", nil, nil, nil,
482 [self window], nil, nil, 497 [self window], nil, nil,
483 nil, nil, @"Added entry: %@", [[addedEntry title] stringValue]); 498 nil, nil, @"Added entry: %@", [[addedEntry title] stringValue]);
484 499
485 NSMutableArray *entries = [NSMutableArray arrayWithArray:[mPostFeed entries]]; 500 NSMutableArray *entries = [NSMutableArray arrayWithArray:[mPostFeed entries]];
486 [entries insertObject:addedEntry atIndex:0]; 501 [entries insertObject:addedEntry atIndex:0];
487 [mPostFeed setEntries:entries]; 502 [mPostFeed setEntries:entries];
488 } else { 503 } else {
489 // failed to add entry 504 // failed to add entry
490 GDataEntryBlogPost *addedEntry = [ticket postedObject]; 505 GDataEntryBlogPost *addedEntry = [ticket postedObject];
491 NSBeginAlertSheet(@"Add", nil, nil, nil, 506 NSBeginAlertSheet(@"Add", nil, nil, nil,
492 [self window], nil, nil, 507 [self window], nil, nil,
493 nil, nil, @"Failed to add entry: %@\nError: %@", 508 nil, nil, @"Failed to add entry: %@\nError: %@",
494 [[addedEntry title] stringValue], error); 509 [[addedEntry title] stringValue], error);
495 } 510 }
496 511
497 [self setEditPostTicket:nil]; 512 [self setEditPostTicket:nil];
498 [self updateUI]; 513 [self updateUI];
499 } 514 }
500 515
501 516
502 #pragma mark Update an entry 517 #pragma mark Update an entry
503 518
504 519
505 - (void)updateSelectedPost { 520 - (void)updateSelectedPost {
506 GDataEntryBlogPost *editedEntry = [[[self selectedPost] copy] autorelease]; 521 GDataEntryBlogPost *editedEntry = [[[self selectedPost] copy] autorelease];
507 if (editedEntry) { 522 if (editedEntry) {
508 523
509 // save the edited text into the entry 524 // save the edited text into the entry
510 [[editedEntry content] setStringValue:[mPostEditField stringValue]]; 525 [[editedEntry content] setStringValue:[mPostEditField stringValue]];
511 526
512 BOOL isDraft = ([mPostDraftCheckBox state] == NSOnState); 527 BOOL isDraft = ([mPostDraftCheckBox state] == NSOnState);
513 528
514 GDataAtomPubControl *atomPub = [editedEntry atomPubControl]; 529 GDataAtomPubControl *atomPub = [editedEntry atomPubControl];
515 if (atomPub == nil) { 530 if (atomPub == nil) {
516 atomPub = [GDataAtomPubControl atomPubControl]; 531 atomPub = [GDataAtomPubControl atomPubControl];
517 [editedEntry setAtomPubControl:atomPub]; 532 [editedEntry setAtomPubControl:atomPub];
518 } 533 }
519 [atomPub setIsDraft:isDraft]; 534 [atomPub setIsDraft:isDraft];
520 535
521 // send the edited entry to the server 536 // send the edited entry to the server
522 GDataServiceGoogleBlogger *service = [self bloggerService]; 537 GDataServiceGoogleBlogger *service = [self bloggerService];
523 538
524 // remember the old entry; we'll replace the edited one with it later 539 // remember the old entry; we'll replace the edited one with it later
525 [service setServiceUserData:[self selectedPost]]; 540 [service setServiceUserData:[self selectedPost]];
526 541
527 GDataServiceTicket *ticket; 542 GDataServiceTicket *ticket;
528 ticket = [service fetchEntryByUpdatingEntry:editedEntry 543 ticket = [service fetchEntryByUpdatingEntry:editedEntry
529 delegate:self 544 delegate:self
530 didFinishSelector:@selector(updateTicket:finishedWithEntry:error:)]; 545 didFinishSelector:@selector(updateTicket:finishedWithEntry:error:)];
531 [self setEditPostTicket:ticket]; 546 [self setEditPostTicket:ticket];
532 [self updateUI]; 547 [self updateUI];
533 } 548 }
534 } 549 }
535 550
536 // update entry callback 551 // update entry callback
537 - (void)updateTicket:(GDataServiceTicket *)ticket 552 - (void)updateTicket:(GDataServiceTicket *)ticket
538 finishedWithEntry:(GDataEntryBlogPost *)editedEntry 553 finishedWithEntry:(GDataEntryBlogPost *)editedEntry
539 error:(NSError *)error { 554 error:(NSError *)error {
540 if (error == nil) { 555 if (error == nil) {
541 NSBeginAlertSheet(@"Update", nil, nil, nil, 556 NSBeginAlertSheet(@"Update", nil, nil, nil,
542 [self window], nil, nil, 557 [self window], nil, nil,
543 nil, nil, @"Updated entry: %@", 558 nil, nil, @"Updated entry: %@",
544 [[editedEntry title] stringValue]); 559 [[editedEntry title] stringValue]);
545 560
546 GDataEntryBlogPost *oldEntry = [ticket userData]; 561 GDataEntryBlogPost *oldEntry = [ticket userData];
547 NSMutableArray *entries = [NSMutableArray arrayWithArray:[mPostFeed entries]]; 562 NSMutableArray *entries = [NSMutableArray arrayWithArray:[mPostFeed entries]];
548 unsigned int indexOfOldEntry = [entries indexOfObject:oldEntry]; 563 unsigned int indexOfOldEntry = [entries indexOfObject:oldEntry];
549 if (indexOfOldEntry != NSNotFound) { 564 if (indexOfOldEntry != NSNotFound) {
550 [entries replaceObjectAtIndex:indexOfOldEntry withObject:editedEntry]; 565 [entries replaceObjectAtIndex:indexOfOldEntry withObject:editedEntry];
551 [mPostFeed setEntries:entries]; 566 [mPostFeed setEntries:entries];
552 } 567 }
553 } else { 568 } else {
554 // update failed 569 // update failed
555 GDataEntryBlogPost *editedEntry = [ticket userData]; 570 GDataEntryBlogPost *editedEntry = [ticket userData];
556 NSBeginAlertSheet(@"Update", nil, nil, nil, 571 NSBeginAlertSheet(@"Update", nil, nil, nil,
557 [self window], nil, nil, 572 [self window], nil, nil,
558 nil, nil, @"Failed to update entry: %@\nError: %@", 573 nil, nil, @"Failed to update entry: %@\nError: %@",
559 [[editedEntry title] stringValue], error); 574 [[editedEntry title] stringValue], error);
560 } 575 }
561 576
562 [self setEditPostTicket:nil]; 577 [self setEditPostTicket:nil];
563 [self updateUI]; 578 [self updateUI];
564 } 579 }
565 580
566 #pragma mark Delete an entry 581 #pragma mark Delete an entry
567 582
568 - (void)deleteSelectedPost { 583 - (void)deleteSelectedPost {
569 GDataEntryBlogPost *entry = [self selectedPost]; 584 GDataEntryBlogPost *entry = [self selectedPost];
570 if (entry) { 585 if (entry) {
571 GDataServiceGoogleBlogger *service = [self bloggerService]; 586 GDataServiceGoogleBlogger *service = [self bloggerService];
572 [service setServiceUserData:entry]; // remember which entry we're deleting 587 [service setServiceUserData:entry]; // remember which entry we're deleting
573 588
574 GDataServiceTicket *ticket; 589 GDataServiceTicket *ticket;
575 ticket = [service deleteEntry:entry 590 ticket = [service deleteEntry:entry
576 delegate:self 591 delegate:self
577 didFinishSelector:@selector(deleteTicket:finishedWithNil:error:)]; 592 didFinishSelector:@selector(deleteTicket:finishedWithNil:error:)];
578 593
579 [ticket setUserData:entry]; 594 [ticket setUserData:entry];
580 [self setEditPostTicket:ticket]; 595 [self setEditPostTicket:ticket];
581 [self updateUI]; 596 [self updateUI];
582 } 597 }
583 } 598 }
584 599
585 - (void)deleteTicket:(GDataServiceTicket *)ticket 600 - (void)deleteTicket:(GDataServiceTicket *)ticket
586 finishedWithNil:(id)object 601 finishedWithNil:(id)object
587 error:(NSError *)error { 602 error:(NSError *)error {
588 GDataEntryBlogPost *entry = [ticket userData]; 603 GDataEntryBlogPost *entry = [ticket userData];
589 604
590 if (error == nil) { 605 if (error == nil) {
591 606
592 NSBeginAlertSheet(@"Delete", nil, nil, nil, 607 NSBeginAlertSheet(@"Delete", nil, nil, nil,
593 [self window], nil, nil, 608 [self window], nil, nil,
594 nil, nil, @"Deleted entry: %@", 609 nil, nil, @"Deleted entry: %@",
595 [[entry title] stringValue]); 610 [[entry title] stringValue]);
596 611
597 // remove the deleted entry from the list 612 // remove the deleted entry from the list
598 NSMutableArray *entries = [NSMutableArray arrayWithArray:[mPostFeed entries]]; 613 NSMutableArray *entries = [NSMutableArray arrayWithArray:[mPostFeed entries]];
599 614
600 if ([entries containsObject:entry]) { 615 if ([entries containsObject:entry]) {
601 [entries removeObject:entry]; 616 [entries removeObject:entry];
602 [mPostFeed setEntries:entries]; 617 [mPostFeed setEntries:entries];
603 } 618 }
604 619
605 [self reloadEntryEditField]; 620 [self reloadEntryEditField];
606 621
607 } else { 622 } else {
608 // delete failed 623 // delete failed
609 NSBeginAlertSheet(@"Delete", nil, nil, nil, 624 NSBeginAlertSheet(@"Delete", nil, nil, nil,
610 [self window], nil, nil, 625 [self window], nil, nil,
611 nil, nil, @"Failed to delete entry: %@\nError: %@", 626 nil, nil, @"Failed to delete entry: %@\nError: %@",
612 [[entry title] stringValue], error); 627 [[entry title] stringValue], error);
613 } 628 }
614 629
615 [self setEditPostTicket:nil]; 630 [self setEditPostTicket:nil];
616 [self updateUI]; 631 [self updateUI];
617 } 632 }
618 633
619 #pragma mark Text field delegate methods 634 #pragma mark Text field delegate methods
620 635
621 - (void)controlTextDidChange:(NSNotification *)note { 636 - (void)controlTextDidChange:(NSNotification *)note {
622 if ([note object] == mPostEditField) { 637 if ([note object] == mPostEditField) {
623 638
624 [self updateUI]; // enabled/disable the Update button 639 [self updateUI]; // enabled/disable the Update button
625 } 640 }
626 } 641 }
627 642
628 #pragma mark TableView delegate methods 643 #pragma mark TableView delegate methods
629 // 644 //
630 // table view delegate methods 645 // table view delegate methods
631 // 646 //
632 647
633 - (void)tableViewSelectionDidChange:(NSNotification *)notification { 648 - (void)tableViewSelectionDidChange:(NSNotification *)notification {
634 649
635 id object = [notification object]; 650 id object = [notification object];
636 if (object == mBlogsTable) { 651 if (object == mBlogsTable) {
637 // the user clicked on a blog, so fetch its entries 652 // the user clicked on a blog, so fetch its entries
638 [self fetchPostsForSelectedBlog]; 653 [self fetchPostsForSelectedBlog];
639 } else if (object == mPostsTable) { 654 } else if (object == mPostsTable) {
640 // the user clicked on an blog post; display it below the posts table 655 // the user clicked on an blog post; display it below the posts table
641 [self reloadEntryEditField]; 656 [self reloadEntryEditField];
642 657
643 // fetch the comment list for the selected post 658 // fetch the comment list for the selected post
644 [self fetchCommentsForSelectedPost]; 659 [self fetchCommentsForSelectedPost];
645 } else { 660 } else {
646 // the user clicked on a comment; redisplay the results field 661 // the user clicked on a comment; redisplay the results field
647 [self updateUI]; 662 [self updateUI];
648 } 663 }
649 } 664 }
650 665
651 // table view data source methods 666 // table view data source methods
652 - (GDataFeedBase *)feedForTableView:(NSTableView *)tableView { 667 - (GDataFeedBase *)feedForTableView:(NSTableView *)tableView {
653 GDataFeedBase *feed; 668 GDataFeedBase *feed;
654 if (tableView == mBlogsTable) { 669 if (tableView == mBlogsTable) {
655 feed = mBlogFeed; 670 feed = mBlogFeed;
656 } else if (tableView == mPostsTable) { 671 } else if (tableView == mPostsTable) {
657 feed = mPostFeed; 672 feed = mPostFeed;
658 } else { 673 } else {
659 feed = mCommentFeed; 674 feed = mCommentFeed;
660 } 675 }
661 return feed; 676 return feed;
662 } 677 }
663 678
664 - (int)numberOfRowsInTableView:(NSTableView *)tableView { 679 - (int)numberOfRowsInTableView:(NSTableView *)tableView {
665 return [[[self feedForTableView:tableView] entries] count]; 680 return [[[self feedForTableView:tableView] entries] count];
666 } 681 }
667 682
668 - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row { 683 - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row {
669 GDataFeedBase *feed = [self feedForTableView:tableView]; 684 GDataFeedBase *feed = [self feedForTableView:tableView];
670 GDataEntryBase *entry = [feed entryAtIndex:row]; 685 GDataEntryBase *entry = [feed entryAtIndex:row];
671 return [[entry title] stringValue]; 686 return [[entry title] stringValue];
672 } 687 }
673 688
674 #pragma mark Setters and Getters 689 #pragma mark Setters and Getters
675 690
676 - (GDataFeedBase *)blogFeed { 691 - (GDataFeedBase *)blogFeed {
677 return mBlogFeed; 692 return mBlogFeed;
678 } 693 }
679 694
680 - (void)setBlogFeed:(GDataFeedBase *)feed { 695 - (void)setBlogFeed:(GDataFeedBase *)feed {
681 [mBlogFeed autorelease]; 696 [mBlogFeed autorelease];
682 mBlogFeed = [feed retain]; 697 mBlogFeed = [feed retain];
683 } 698 }
684 699
685 - (NSError *)blogFetchError { 700 - (NSError *)blogFetchError {
686 return mBlogFetchError; 701 return mBlogFetchError;
687 } 702 }
688 703
689 - (void)setBlogFetchError:(NSError *)error { 704 - (void)setBlogFetchError:(NSError *)error {
690 [mBlogFetchError release]; 705 [mBlogFetchError release];
691 mBlogFetchError = [error retain]; 706 mBlogFetchError = [error retain];
692 } 707 }
693 708
694 - (GDataServiceTicket *)blogFeedTicket { 709 - (GDataServiceTicket *)blogFeedTicket {
695 return mBlogFeedTicket; 710 return mBlogFeedTicket;
696 } 711 }
697 712
698 - (void)setBlogFeedTicket:(GDataServiceTicket *)ticket { 713 - (void)setBlogFeedTicket:(GDataServiceTicket *)ticket {
699 [mBlogFeedTicket autorelease]; 714 [mBlogFeedTicket autorelease];
700 mBlogFeedTicket = [ticket retain]; 715 mBlogFeedTicket = [ticket retain];
701 } 716 }
702 717
703 - (GDataFeedBase *)postFeed { 718 - (GDataFeedBase *)postFeed {
704 return mPostFeed; 719 return mPostFeed;
705 } 720 }
706 721
707 - (void)setPostFeed:(GDataFeedBase *)feed { 722 - (void)setPostFeed:(GDataFeedBase *)feed {
708 [mPostFeed autorelease]; 723 [mPostFeed autorelease];
709 mPostFeed = [feed retain]; 724 mPostFeed = [feed retain];
710 } 725 }
711 726
712 - (NSError *)postFetchError { 727 - (NSError *)postFetchError {
713 return mPostFetchError; 728 return mPostFetchError;
714 } 729 }
715 730
716 - (void)setPostFetchError:(NSError *)error { 731 - (void)setPostFetchError:(NSError *)error {
717 [mPostFetchError release]; 732 [mPostFetchError release];
718 mPostFetchError = [error retain]; 733 mPostFetchError = [error retain];
719 } 734 }
720 735
721 - (GDataServiceTicket *)postFeedTicket { 736 - (GDataServiceTicket *)postFeedTicket {
722 return mPostFeedTicket; 737 return mPostFeedTicket;
723 } 738 }
724 739
725 - (void)setPostFeedTicket:(GDataServiceTicket *)ticket { 740 - (void)setPostFeedTicket:(GDataServiceTicket *)ticket {
726 [mPostFeedTicket autorelease]; 741 [mPostFeedTicket autorelease];
727 mPostFeedTicket = [ticket retain]; 742 mPostFeedTicket = [ticket retain];
728 } 743 }
729 744
730 - (GDataFeedBase *)commentFeed { 745 - (GDataFeedBase *)commentFeed {
731 return mCommentFeed; 746 return mCommentFeed;
732 } 747 }
733 748
734 - (void)setCommentFeed:(GDataFeedBase *)feed { 749 - (void)setCommentFeed:(GDataFeedBase *)feed {
735 [mCommentFeed autorelease]; 750 [mCommentFeed autorelease];
736 mCommentFeed = [feed retain]; 751 mCommentFeed = [feed retain];
737 } 752 }
738 753
739 - (NSError *)commentFetchError { 754 - (NSError *)commentFetchError {
740 return mCommentFetchError; 755 return mCommentFetchError;
741 } 756 }
742 757
743 - (void)setCommentFetchError:(NSError *)error { 758 - (void)setCommentFetchError:(NSError *)error {
744 [mCommentFetchError release]; 759 [mCommentFetchError release];
745 mCommentFetchError = [error retain]; 760 mCommentFetchError = [error retain];
746 } 761 }
747 762
748 - (GDataServiceTicket *)commentFeedTicket { 763 - (GDataServiceTicket *)commentFeedTicket {
749 return mCommentFeedTicket; 764 return mCommentFeedTicket;
750 } 765 }
751 766
752 - (void)setCommentFeedTicket:(GDataServiceTicket *)ticket { 767 - (void)setCommentFeedTicket:(GDataServiceTicket *)ticket {
753 [mCommentFeedTicket autorelease]; 768 [mCommentFeedTicket autorelease];
754 mCommentFeedTicket = [ticket retain]; 769 mCommentFeedTicket = [ticket retain];
755 } 770 }
756 771
757 - (GDataServiceTicket *)editPostTicket { 772 - (GDataServiceTicket *)editPostTicket {
758 return mEditPostTicket; 773 return mEditPostTicket;
759 } 774 }
760 775
761 - (void)setEditPostTicket:(GDataServiceTicket *)ticket { 776 - (void)setEditPostTicket:(GDataServiceTicket *)ticket {
762 [mEditPostTicket autorelease]; 777 [mEditPostTicket autorelease];
763 mEditPostTicket = [ticket retain]; 778 mEditPostTicket = [ticket retain];
764 } 779 }
765 780
766 @end 781 @end
Powered by Google Project Hosting