root/trunk/VoxAtomApi.m @ 40

Revision 40, 3.1 kB (checked in by ngerakines, 3 years ago)

* Added growl notification on service connect
* Changed the language used in login and prefs
* On enter from password field a login is performed
* Made several adjustments throughout the app

Line 
1//
2//  VoxAtomApi.m
3//  Fence
4//
5//  Created by Nicholas Gerakines on 6/11/06.
6//  Copyright 2006 __MyCompanyName__. All rights reserved.
7//
8
9#import "VoxAtomApi.h"
10#import "AtomExtensions.h"
11#import "NSDataAdditions.h"
12
13@implementation VoxAtomApi
14
15// [self setfile:@"/path/to/file"];
16// [self newpost:@"gallery"];
17- (void) newpost:(NSString *) to args:(NSMutableDictionary *) args {
18        /* NSLog(@"-(void) newpost:(NSString *)to - called\n"); */
19        NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
20        NSString *reqtype;
21        if ([to isEqualToString:@"weblogdiscovery"] || [to isEqualToString:@"3"]) {
22                /* NSLog(@"set as gallery post type\n"); */
23                reqtype = @"GET";
24                [self setApiurl:@"http://www.vox.com/atom/"];
25                [self weblog_discover];
26        }
27        if ([to isEqualToString:@"collection"] || [to isEqualToString:@"1"]) {
28// NSLog(@"set as weblog post type\n");
29                reqtype = @"POST";
30                [self setApiurl:[NSString stringWithFormat:@"http://www.vox.com/atom/svc=post/collection_id=%@", [args objectForKey:@"destinationid"]]];
31                [self weblog_upload: dataarg];
32        }
33        if ([to isEqualToString:@"quickpost"] || [to isEqualToString:@"2"]) {
34// NSLog(@"set as quickpost post type\n");
35                reqtype = @"POST";
36                [self setApiurl:[NSString stringWithFormat:@"http://www.vox.com/atom/collection_id=%@", [args objectForKey:@"destinationid"]]];
37                [self weblog_newpost:@"Quick Post" content:dataarg];
38        }
39        // http://www.vox.com/atom/svc=post/collection_id=
40        /* NSLog(@"Making request with request type %@\n", reqtype); */
41        [self makerequest:reqtype];
42}
43
44- (NSString *) weblog_discover {
45        /* NSLog(@"- (NSString *) weblog_newitem - called"); */
46        /* NSLog(@"Creating atom feed based on upload file %@\n", uploadfile); */
47        /* atomdata = [NSString stringWithFormat:@"<entry xmlns=\"http://purl.org/atom/ns#\"><title>%@</title><summary></summary><content mode=\"xml\"><div xmlns=\"http://www.w3.org/1999/xhtml\">%@</div></content></entry>", title, content]; */
48        atomdata = @"";
49        /* NSLog(@"Atom feed:\n%@\n", atomdata); */
50        return @"";
51}
52
53- (NSString *) weblog_upload: (NSString *) file {
54// NSLog(@"- (NSString *) weblog_upload - called");
55        NSData *data = [NSData dataWithContentsOfFile:file];
56        NSString *encodedFile = [data base64Encoding];
57        // TODO: enable standalone mode - <standalone xmlns=\"http://sixapart.com/atom/typepad#\">1</standalone>
58        atomdata = [NSString stringWithFormat:@"<entry xmlns=\"http://purl.org/atom/ns#\" xmlns:photo=\"http://sixapart.com/atom/photo#\"><title>%@</title><summary></summary><photo:filename>%@</photo:filename><content mode=\"base64\" type=\"image/%@\">%@</content><standalone xmlns=\"http://sixapart.com/atom/typepad#\">1</standalone></entry>",[file lastPathComponent],[file lastPathComponent], [file pathExtension], encodedFile];
59        return atomdata;
60}
61
62- (NSString *) weblog_newpost: (NSString *) title content: (NSString *) content {
63// NSLog(@"- (NSString *) weblog_newpost - called");
64        atomdata = [NSString stringWithFormat:@"<entry xmlns=\"http://purl.org/atom/ns#\"><title>%@</title><summary></summary><content mode=\"xml\"><div xmlns=\"http://www.w3.org/1999/xhtml\">%@</div></content></entry>", title, content];
65        return atomdata;
66}
67
68@end
Note: See TracBrowser for help on using the browser.