• R/O
  • SSH
  • HTTPS

iphotouploader: Commit


Commit MetaInfo

Revision18 (tree)
Zeit2008-05-17 00:34:00
Autoritok

Log Message

add flickr service

Ändern Zusammenfassung

Diff

--- trunk/test/PUTest.m (revision 17)
+++ trunk/test/PUTest.m (revision 18)
@@ -9,6 +9,7 @@
99 #import "PUTest.h"
1010 #import "PhotoZou.h"
1111 #import "Fotolife.h"
12+#import "Flickr.h"
1213 #import "PUMultiRequest.h"
1314
1415 @implementation PUTest
@@ -17,6 +18,8 @@
1718 {
1819 m_albumDic = [[NSMutableDictionary alloc] init];
1920 // [NSApp runModalForWindow:o_window];
21+
22+ [FlickrRequest setToken:@"72157604967069675-cb2309b1cf279031"];
2023 }
2124
2225 -(void) login
@@ -34,6 +37,11 @@
3437
3538 -(IBAction) nop:(id)sender
3639 {
40+ Flickr_Auth_GetFrob* req = [[Flickr_Auth_GetFrob alloc] init];
41+// Flickr_Auth_GetToken* req = [[Flickr_Auth_GetToken alloc] initWithFrob:@"72157604967577065-87c2f3eeb9d84691-877008"];
42+ [req setDelegate:self];
43+ [req start];
44+ return;
3745 #if 0
3846 [self login];
3947 PhotoZou_Nop* nop = [[PhotoZou_Nop alloc] init];
@@ -50,11 +58,18 @@
5058 {
5159 [self login];
5260
53- int albumId = [[[m_albumDic objectForKey:[_albumMenu objectAtIndex:_albumIndex]] valueForKey:@"album_id"] intValue];
61+// int albumId = [[[m_albumDic objectForKey:[_albumMenu objectAtIndex:_albumIndex]] valueForKey:@"album_id"] intValue];
5462 NSOpenPanel* op = [NSOpenPanel openPanel];
5563 // [op setAllowsMultipleSelection:YES];
5664 if ([op runModalForTypes:[NSArray arrayWithObjects:@"jpeg", @"jpg", nil]] == NSOKButton) {
5765 #if 1
66+ Flickr_Upload* req = [[Flickr_Upload alloc] init];
67+ [req setValue:[NSURL fileURLWithPath:[[op filenames] objectAtIndex:0]] forKey:@"fileUrl"];
68+ [req setValue:@"image/jpeg" forKey:@"contentType"];
69+ [req setDelegate:self];
70+ [req start];
71+#else
72+#if 1
5873 Fotolife_AtomPost* req = [[Fotolife_AtomPost alloc] init];
5974 [req setValue:[NSURL fileURLWithPath:[[op filenames] objectAtIndex:0]] forKey:@"fileUrl"];
6075 [req setValue:@"image/jpeg" forKey:@"contentType"];
@@ -80,6 +95,7 @@
8095 [mreq setDelegate:self];
8196 [mreq start:reqs];
8297 #endif
98+#endif
8399 }
84100 }
85101
@@ -109,8 +125,9 @@
109125 #if 0
110126 NSData* data = [request responseData];
111127 NSXMLDocument* xml = [[NSXMLDocument alloc] initWithData:data options:0 error:nil];
112- NSLog(@"%@", [xml description]);
113- NSLog(@"%@", [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]);
128+ if (xml) {
129+ NSLog(@"%@", [xml description]);
130+ NSLog(@"%@", [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]);
114131 [xml release];
115132 #endif
116133 }
--- trunk/Info.plist (revision 17)
+++ trunk/Info.plist (revision 18)
@@ -19,7 +19,7 @@
1919 <key>CFBundleSignature</key>
2020 <string>????</string>
2121 <key>CFBundleVersion</key>
22- <string>0.0.2</string>
22+ <string>0.0.3</string>
2323 <key>NSPrincipalClass</key>
2424 <string>iPhotoUploader</string>
2525 <key>NSMainNibFile</key>
--- trunk/src/main/iPhotoUploader.m (revision 17)
+++ trunk/src/main/iPhotoUploader.m (revision 18)
@@ -156,6 +156,7 @@
156156 static const char* service_names[] = {
157157 "PhotoZouService",
158158 "FotolifeService",
159+ "FlickrService",
159160 nil
160161 };
161162 int i;
@@ -242,7 +243,7 @@
242243 {
243244 [m_resArr removeAllObjects];
244245
245- if (IS_NULL_STR([(NSObject*)m_curService valueForKey:@"username"]) || IS_NULL_STR([(NSObject*)m_curService valueForKey:@"password"])) {
246+ if (![m_curService checkAuth]) {
246247 NSRunAlertPanel(LOCALIZED(@"Please enter username and password"), @"", @"OK", @"", @"");
247248 return;
248249 }
--- trunk/src/photozou/PhotoZou_PhotoAdd.h (revision 17)
+++ trunk/src/photozou/PhotoZou_PhotoAdd.h (revision 18)
@@ -36,7 +36,7 @@
3636 int _albumId;
3737 NSString* _name;
3838 NSArray* _tags;
39- NSString* _comment;
39+ NSString* _comment;
4040 }
4141
4242 @end
--- trunk/src/photozou/PhotoZouService.m (revision 17)
+++ trunk/src/photozou/PhotoZouService.m (revision 18)
@@ -144,8 +144,15 @@
144144
145145 -(void) request:(PURequest*)request didCompletedWithResult:(int)code
146146 {
147- NSLog(@"didCompletedWithResult %d", code);
147+// NSLog(@"didCompletedWithResult %d", code);
148148 if ([request isKindOfClass:[PhotoZou_PhotoAlbum class]]) {
149+ NSError* err = [request lastError];
150+ if (err) {
151+ NSRunAlertPanel([NSString stringWithFormat:LOCALIZED(@"Error Occurred : %d"), [err code]], [err localizedDescription], LOCALIZED(@"OK"), @"", @"");
152+ [request release];
153+ return;
154+ }
155+
149156 NSArray* albums = [request responseData];
150157 NSEnumerator* enume = [albums objectEnumerator];
151158 PZAlbum* album;
--- trunk/src/photozou/PhotoZouRequest.m (revision 17)
+++ trunk/src/photozou/PhotoZouRequest.m (revision 18)
@@ -59,14 +59,19 @@
5959 -(NSError*) lastError
6060 {
6161 NSXMLDocument* xml = [self responseData];
62- NSXMLElement* root = [xml rootElement];
63- if (xml && [[root attributeValueForXPath:@"/rsp" andName:@"stat" error:nil] isEqualTo:@"fail"]) {
64- id code = [root attributeValueForXPath:@"/rsp/err" andName:@"code" error:nil];
65- id msg = [root attributeValueForXPath:@"/rsp/err" andName:@"msg" error:nil];
66- if (code) {
67- NSDictionary* userInfo = (msg) ? [NSDictionary dictionaryWithObjectsAndKeys:msg, NSLocalizedDescriptionKey, nil] : nil;
68- NSError* err = [NSError errorWithDomain:PURequestErrorDomain code:[code intValue] userInfo:userInfo];
69- return err;
62+ if (!(xml && [xml isKindOfClass:[NSXMLDocument class]])) {
63+ xml = [super responseData];
64+ }
65+ if (xml && [xml isKindOfClass:[NSXMLDocument class]]) {
66+ NSXMLElement* root = [xml rootElement];
67+ if ([[root attributeValueForXPath:@"/rsp" andName:@"stat" error:nil] isEqualTo:@"fail"]) {
68+ id code = [root attributeValueForXPath:@"/rsp/err" andName:@"code" error:nil];
69+ id msg = [root attributeValueForXPath:@"/rsp/err" andName:@"msg" error:nil];
70+ if (code) {
71+ NSDictionary* userInfo = (msg) ? [NSDictionary dictionaryWithObjectsAndKeys:msg, NSLocalizedDescriptionKey, nil] : nil;
72+ NSError* err = [NSError errorWithDomain:PURequestErrorDomain code:[code intValue] userInfo:userInfo];
73+ return err;
74+ }
7075 }
7176 }
7277 return nil;
--- trunk/src/common/PUService.m (revision 17)
+++ trunk/src/common/PUService.m (revision 18)
@@ -147,4 +147,9 @@
147147 return;
148148 }
149149
150+-(BOOL) checkAuth
151+{
152+ return (!(IS_NULL_STR([self valueForKey:@"username"]) || IS_NULL_STR([self valueForKey:@"password"])));
153+}
154+
150155 @end
--- trunk/src/common/PUMultiRequest.m (revision 17)
+++ trunk/src/common/PUMultiRequest.m (revision 18)
@@ -27,6 +27,7 @@
2727
2828 #import "PUMultiRequest.h"
2929 #import "PURequest.h"
30+#import "PUMacros.h"
3031
3132 @interface PUMultiRequest (Private)
3233
@@ -40,6 +41,7 @@
4041 {
4142 if (self = [super init]) {
4243 m_reqs = [[NSMutableArray alloc] init];
44+ m_errOccurred = NO;
4345 }
4446 return self;
4547 }
@@ -80,6 +82,12 @@
8082
8183 -(void) request:(PURequest*)request didCompletedWithResult:(int)code
8284 {
85+ NSError* err = [request lastError];
86+ if (err) {
87+ m_errOccurred = YES;
88+ NSRunAlertPanel([NSString stringWithFormat:LOCALIZED(@"Error Occurred : %d"), [err code]], [err localizedDescription], LOCALIZED(@"OK"), @"", @"");
89+ }
90+
8391 if (m_delegate && [m_delegate respondsToSelector:@selector(multiRequest:didCompletedOne:withProgress:)]) {
8492 [m_delegate multiRequest:self didCompletedOne:request withProgress:((m_total - [m_reqs count]) / (double)m_total)];
8593 }
@@ -112,7 +120,7 @@
112120 [m_reqs removeObjectAtIndex:0];
113121 } else {
114122 if (m_delegate && [m_delegate respondsToSelector:@selector(multiRequestDidCompleted:result:)]) {
115- [m_delegate multiRequestDidCompleted:self result:kPUMultiRequest_Success];
123+ [m_delegate multiRequestDidCompleted:self result:(m_errOccurred) ? kPUMultiRequest_Fail : kPUMultiRequest_Success];
116124 }
117125 }
118126 }
--- trunk/src/common/PUService.h (revision 17)
+++ trunk/src/common/PUService.h (revision 18)
@@ -81,14 +81,24 @@
8181 */
8282 -(void) login;
8383
84+/**
85+ * @brief 認証確認
86+ * @note パスワードなどの入力確認
87+ */
88+-(BOOL) checkAuth;
89+
8490 @end
8591
92+/**
93+ * @brief 写真共有サービス親クラス
94+ * @note keychain 経由のアカウント管理はこのクラスで行う
95+ */
8696 @interface PUService : NSObject <PUService>
8797 {
8898 BOOL m_activated;
8999
90- NSString* m_usernameKey;
91- NSURL* m_keychainURL;
100+ NSString* m_usernameKey; //!< アカウント名の保存キー (サブクラスで初期化)
101+ NSURL* m_keychainURL; //!< keychain登録用URL (サブクラスで初期化)
92102
93103 IBOutlet id o_view;
94104
--- trunk/src/common/PUMultiRequest.h (revision 17)
+++ trunk/src/common/PUMultiRequest.h (revision 18)
@@ -43,6 +43,7 @@
4343 int m_total;
4444 PURequest* m_curReq;
4545 id m_delegate;
46+ BOOL m_errOccurred;
4647 }
4748
4849 /**
--- trunk/src/flickr/Flickr_Auth_CheckToken.h (nonexistent)
+++ trunk/src/flickr/Flickr_Auth_CheckToken.h (revision 18)
@@ -0,0 +1,16 @@
1+//
2+// Flickr_Auth_CheckToken.h
3+// iPhotoUploader
4+//
5+// Created by 伊藤 啓 on 08/05/09.
6+// Copyright 2008 __MyCompanyName__. All rights reserved.
7+//
8+
9+#import <Cocoa/Cocoa.h>
10+#import "FlickrRequest.h"
11+
12+@interface Flickr_Auth_CheckToken : FlickrRequest {
13+
14+}
15+
16+@end
--- trunk/src/flickr/Flickr_Auth_GetToken.h (nonexistent)
+++ trunk/src/flickr/Flickr_Auth_GetToken.h (revision 18)
@@ -0,0 +1,38 @@
1+// Copyright (c) 2008 itok ( http://itok.jp/ , http://110k.net/ )
2+// All rights reserved.
3+//
4+// Redistribution and use in source and binary forms, with or without modification,
5+// are permitted provided that the following conditions are met:
6+//
7+// - Redistributions of source code must retain the above copyright notice,
8+// this list of conditions and the following disclaimer.
9+// - Redistributions in binary form must reproduce the above copyright notice,
10+// this list of conditions and the following disclaimer in the documentation
11+// and/or other materials provided with the distribution.
12+// - Neither the name of itok nor the names of its contributors may be used to endorse
13+// or promote products derived from this software without specific prior written permission.
14+//
15+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
16+// AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
17+// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
18+// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19+// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
20+// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26+// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
28+#import <Cocoa/Cocoa.h>
29+#import "FlickrRequest.h"
30+
31+
32+@interface Flickr_Auth_GetToken : FlickrRequest {
33+
34+}
35+
36+-(id) initWithFrob:(NSString*)frob;
37+
38+@end
--- trunk/src/flickr/FlickrService.h (nonexistent)
+++ trunk/src/flickr/FlickrService.h (revision 18)
@@ -0,0 +1,40 @@
1+// Copyright (c) 2008 itok ( http://itok.jp/ , http://110k.net/ )
2+// All rights reserved.
3+//
4+// Redistribution and use in source and binary forms, with or without modification,
5+// are permitted provided that the following conditions are met:
6+//
7+// - Redistributions of source code must retain the above copyright notice,
8+// this list of conditions and the following disclaimer.
9+// - Redistributions in binary form must reproduce the above copyright notice,
10+// this list of conditions and the following disclaimer in the documentation
11+// and/or other materials provided with the distribution.
12+// - Neither the name of itok nor the names of its contributors may be used to endorse
13+// or promote products derived from this software without specific prior written permission.
14+//
15+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
16+// AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
17+// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
18+// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19+// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
20+// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26+// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
28+
29+#import <Cocoa/Cocoa.h>
30+#import "PUService.h"
31+
32+@interface FlickrService : PUService {
33+ NSString* _frob;
34+ NSString* _token;
35+ NSString* _authBtnTitle;
36+}
37+
38+-(IBAction) authorization:(id)sender;
39+
40+@end
--- trunk/src/flickr/Flickr_People_GetUploadStatus.m (nonexistent)
+++ trunk/src/flickr/Flickr_People_GetUploadStatus.m (revision 18)
@@ -0,0 +1,28 @@
1+//
2+// Flickr_People_GetUploadStatus.m
3+// iPhotoUploader
4+//
5+// Created by 伊藤 啓 on 08/05/09.
6+// Copyright 2008 __MyCompanyName__. All rights reserved.
7+//
8+
9+#import "Flickr_People_GetUploadStatus.h"
10+#import "FlickrSignature.h"
11+
12+#define PEOPLE_GETUPLOADSTATUS_ARG \
13+ [NSDictionary dictionaryWithObjectsAndKeys: \
14+ @"flickr.people.getUploadStatus", @"method", \
15+ [FlickrRequest token], @"auth_token", \
16+ [FlickrSignature apiKey], @"api_key", \
17+ nil]
18+
19+@implementation Flickr_People_GetUploadStatus
20+
21+-(id) init
22+{
23+ if (self = [super initWithBasePath:@"http://api.flickr.com/services/rest/" withArgs:PEOPLE_GETUPLOADSTATUS_ARG needSignature:YES method:@"GET"]) {
24+ }
25+ return self;
26+}
27+
28+@end
--- trunk/src/flickr/FlickrSignature.h (nonexistent)
+++ trunk/src/flickr/FlickrSignature.h (revision 18)
@@ -0,0 +1,42 @@
1+// Copyright (c) 2008 itok ( http://itok.jp/ , http://110k.net/ )
2+// All rights reserved.
3+//
4+// Redistribution and use in source and binary forms, with or without modification,
5+// are permitted provided that the following conditions are met:
6+//
7+// - Redistributions of source code must retain the above copyright notice,
8+// this list of conditions and the following disclaimer.
9+// - Redistributions in binary form must reproduce the above copyright notice,
10+// this list of conditions and the following disclaimer in the documentation
11+// and/or other materials provided with the distribution.
12+// - Neither the name of itok nor the names of its contributors may be used to endorse
13+// or promote products derived from this software without specific prior written permission.
14+//
15+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
16+// AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
17+// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
18+// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19+// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
20+// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26+// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
28+#import <Cocoa/Cocoa.h>
29+
30+
31+@interface FlickrSignature : NSObject
32+
33++(NSString*) apiKey;
34+
35+/**
36+ * @brief api_sig を計算する
37+ * @param args GET/POSTに渡すパラメータセット
38+ * @note SECRET + key1 + obj1 + key2 + obj2 の順番で連結し md5 ハッシュを計算
39+ */
40++(NSString*) generateApiSignature:(NSDictionary*)args;
41+
42+@end
--- trunk/src/flickr/Flickr_Auth_CheckToken.m (nonexistent)
+++ trunk/src/flickr/Flickr_Auth_CheckToken.m (revision 18)
@@ -0,0 +1,29 @@
1+//
2+// Flickr_Auth_CheckToken.m
3+// iPhotoUploader
4+//
5+// Created by 伊藤 啓 on 08/05/09.
6+// Copyright 2008 __MyCompanyName__. All rights reserved.
7+//
8+
9+#import "Flickr_Auth_CheckToken.h"
10+#import "FlickrSignature.h"
11+
12+#define AUTH_CHECKTOKEN_ARG \
13+ [NSDictionary dictionaryWithObjectsAndKeys: \
14+ @"flickr.auth.checkToken", @"method", \
15+ [FlickrSignature apiKey], @"api_key", \
16+ [FlickrRequest token], @"auth_token", \
17+ nil]
18+
19+
20+@implementation Flickr_Auth_CheckToken
21+
22+-(id) initWithFrob:(NSString*)frob
23+{
24+ if (self = [super initWithBasePath:@"http://api.flickr.com/services/rest/" withArgs:AUTH_CHECKTOKEN_ARG needSignature:YES method:@"GET"]) {
25+ }
26+ return self;
27+}
28+
29+@end
--- trunk/src/flickr/Flickr_Auth_GetToken.m (nonexistent)
+++ trunk/src/flickr/Flickr_Auth_GetToken.m (revision 18)
@@ -0,0 +1,48 @@
1+// Copyright (c) 2008 itok ( http://itok.jp/ , http://110k.net/ )
2+// All rights reserved.
3+//
4+// Redistribution and use in source and binary forms, with or without modification,
5+// are permitted provided that the following conditions are met:
6+//
7+// - Redistributions of source code must retain the above copyright notice,
8+// this list of conditions and the following disclaimer.
9+// - Redistributions in binary form must reproduce the above copyright notice,
10+// this list of conditions and the following disclaimer in the documentation
11+// and/or other materials provided with the distribution.
12+// - Neither the name of itok nor the names of its contributors may be used to endorse
13+// or promote products derived from this software without specific prior written permission.
14+//
15+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
16+// AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
17+// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
18+// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19+// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
20+// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26+// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
28+
29+#import "Flickr_Auth_GetToken.h"
30+#import "FlickrSignature.h"
31+
32+#define AUTH_GETTOKEN_ARG \
33+ [NSDictionary dictionaryWithObjectsAndKeys: \
34+ @"flickr.auth.getToken", @"method", \
35+ [FlickrSignature apiKey], @"api_key", \
36+ frob, @"frob", \
37+ nil]
38+
39+@implementation Flickr_Auth_GetToken
40+
41+-(id) initWithFrob:(NSString*)frob
42+{
43+ if (self = [super initWithBasePath:@"http://api.flickr.com/services/rest/" withArgs:AUTH_GETTOKEN_ARG needSignature:YES method:@"GET"]) {
44+ }
45+ return self;
46+}
47+
48+@end
--- trunk/src/flickr/FlickrService.m (nonexistent)
+++ trunk/src/flickr/FlickrService.m (revision 18)
@@ -0,0 +1,221 @@
1+// Copyright (c) 2008 itok ( http://itok.jp/ , http://110k.net/ )
2+// All rights reserved.
3+//
4+// Redistribution and use in source and binary forms, with or without modification,
5+// are permitted provided that the following conditions are met:
6+//
7+// - Redistributions of source code must retain the above copyright notice,
8+// this list of conditions and the following disclaimer.
9+// - Redistributions in binary form must reproduce the above copyright notice,
10+// this list of conditions and the following disclaimer in the documentation
11+// and/or other materials provided with the distribution.
12+// - Neither the name of itok nor the names of its contributors may be used to endorse
13+// or promote products derived from this software without specific prior written permission.
14+//
15+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
16+// AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
17+// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
18+// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19+// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
20+// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26+// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
28+
29+#import "FlickrService.h"
30+#import "Flickr.h"
31+#import "PUMacros.h"
32+#import "NSXMLElement-ex.h"
33+
34+#define AUTH_WEB_ARG \
35+ [NSDictionary dictionaryWithObjectsAndKeys: \
36+ [FlickrSignature apiKey], @"api_key", \
37+ _frob, @"frob", \
38+ @"write", @"perms", \
39+ nil]
40+
41+@implementation FlickrService
42+
43+-(id) init
44+{
45+ if (self = [super init]) {
46+ [NSBundle loadNibNamed:@"Flickr" owner:self];
47+ m_activated = NO;
48+ }
49+ return self;
50+}
51+
52+-(void) dealloc
53+{
54+ [super dealloc];
55+}
56+
57+-(IBAction) authorization:(id)sender
58+{
59+ int ret;
60+ if ([_authBtnTitle isEqualTo:LOCALIZED(@"Login...")]) {
61+ if (!IS_NULL_STR(_frob)) {
62+ // frob 取得済み
63+ ret = NSRunAlertPanel(LOCALIZED(@"iPhotoUpload requires your authorization before it can upload your photos to Flickr"), LOCALIZED(@"Authorizing is a simple process which takes place in your web browser. When you're finished, return to this window to complete authorization"), LOCALIZED(@"Authorize..."), LOCALIZED(@"Cancel"), @"");
64+ if (ret == NSAlertDefaultReturn) {
65+ // 認証用URLを生成
66+ NSString* path = [FlickrRequest createPath:@"http://www.flickr.com/services/auth/" withArgs:AUTH_WEB_ARG needSignature:YES];
67+ NSURL* url = [NSURL URLWithString:path];
68+ // ブラウザで開く
69+ [[NSWorkspace sharedWorkspace] openURL:url];
70+
71+ ret = NSRunAlertPanel(LOCALIZED(@"Return to this window after you have finished the authorization process on Flickr.com"), LOCALIZED(@"Once you're done, click the 'Complete Authorization' button below and you can begin using iPhotoUploader"), LOCALIZED(@"Complete Authorization"), LOCALIZED(@"Cancel"), @"");
72+ if (ret == NSAlertDefaultReturn) {
73+ // token 取得
74+ Flickr_Auth_GetToken* req = [[Flickr_Auth_GetToken alloc] initWithFrob:_frob];
75+ [req setDelegate:self];
76+ [req start];
77+ }
78+ }
79+ }
80+ } else {
81+ ret = NSRunAlertPanel(LOCALIZED(@"Do you logout really?"), LOCALIZED(@"It is necessary to remove permission of iPhotoUploader on Flickr.com. You need to login again if you want to upload to Flickr"), LOCALIZED(@"Open Filckr.com"), LOCALIZED(@"Cancel"), @"");
82+ if (ret == NSAlertDefaultReturn) {
83+ [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://flickr.com/services/auth/list.gne?from=extend"]];
84+ ret = NSRunAlertPanel(LOCALIZED(@"Return to this window after you have finished the remove process on Flickr.com"), LOCALIZED(@"Once you're done, click the 'Complete Remove' button below"), LOCALIZED(@"Complete Remove"), LOCALIZED(@"Cancel"), @"");
85+ if (ret == NSAlertDefaultReturn) {
86+ NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
87+ [defaults setObject:nil forKey:@"Flickr_Token"];
88+ [defaults synchronize];
89+ [FlickrRequest setToken:nil];
90+ [self setValue:LOCALIZED(@"Login...") forKey:@"authBtnTitle"];
91+ }
92+ }
93+ }
94+}
95+
96+-(void) request:(PURequest*)request didCompletedWithResult:(int)code
97+{
98+ if ([request isKindOfClass:[FlickrRequest class]]) {
99+ NSXMLDocument* xml = [request responseData];
100+ NSError* err = [request lastError];
101+ if (err) {
102+ NSRunAlertPanel([NSString stringWithFormat:LOCALIZED(@"Error Occurred : %d"), [err code]], [err localizedDescription], LOCALIZED(@"OK"), @"", @"");
103+ [request release];
104+ return;
105+ }
106+// NSLog(@"%@", [xml description]);
107+ if ([request isKindOfClass:[Flickr_Auth_GetFrob class]]) {
108+ // frob 取得
109+ if (xml && [xml isKindOfClass:[NSXMLDocument class]]) {
110+ [self setValue:[[xml rootElement] objectValueForXPath:@"/rsp/frob" error:nil] forKey:@"frob"];
111+ }
112+ } else if ([request isKindOfClass:[Flickr_Auth_GetToken class]]) {
113+ // token 取得
114+ if (xml && [xml isKindOfClass:[NSXMLDocument class]]) {
115+ [self setValue:[[xml rootElement] objectValueForXPath:@"/rsp/auth/token" error:nil] forKey:@"token"];
116+ NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
117+ [defaults setObject:_token forKey:@"Flickr_Token"];
118+ [defaults synchronize];
119+ [FlickrRequest setToken:_token];
120+ [self setValue:LOCALIZED(@"Logout...") forKey:@"authBtnTitle"];
121+ }
122+ }
123+ }
124+
125+ [request release];
126+}
127+
128+#pragma mark ___ PUService protocol ___
129+
130+-(NSString*) title
131+{
132+ return LOCALIZED(@"Flickr");
133+}
134+
135+-(NSArray*) requestsWithMgr:(ExportMgr*)mgr andURLs:(NSDictionary*)urlDic
136+{
137+ NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
138+ int i;
139+ Flickr_Upload* req;
140+ NSMutableArray* reqs = [NSMutableArray array];
141+ NSString* origPath;
142+ NSURL* url;
143+ for (i = 0; i < [mgr imageCount]; i++) {
144+ req = [[Flickr_Upload alloc] init];
145+ origPath = [mgr imagePathAtIndex:i];
146+ if (urlDic && (url = [urlDic objectForKey:origPath])) {
147+ } else {
148+ url = [NSURL fileURLWithPath:origPath];
149+ }
150+ [req setValue:url forKey:@"fileUrl"];
151+ [req setValue:@"image/jpeg" forKey:@"contentType"];
152+ if ([defaults boolForKey:@"Flickr_UseTitle"]) {
153+ [req setValue:[mgr imageTitleAtIndex:i] forKey:@"name"];
154+ }
155+ if ([defaults boolForKey:@"Flickr_UseComment"]) {
156+ [req setValue:[mgr imageCommentsAtIndex:i] forKey:@"comment"];
157+ }
158+ if ([defaults boolForKey:@"Flickr_UseKeyword"]) {
159+ [req setValue:[mgr imageKeywordsAtIndex:i] forKey:@"tags"];
160+ }
161+ [reqs addObject:req];
162+ }
163+ return reqs;
164+}
165+
166+-(NSDictionary*) convertAttributes
167+{
168+ return nil;
169+}
170+
171+-(NSURL*) URLForLastUpload:(NSArray*)responses
172+{
173+ NSString* path = nil;
174+ if (responses && [responses count] > 0) {
175+ NSEnumerator* enume = [responses objectEnumerator];
176+ id photo;
177+ NSMutableString* ids = [NSMutableString string];
178+ while (photo = [enume nextObject]) {
179+ if ([photo isKindOfClass:[FLPhoto class]]) {
180+ if ([ids length] > 0) {
181+ [ids appendString:@","];
182+ }
183+ [ids appendFormat:@"%@", [photo valueForKey:@"photoid"]];
184+ }
185+ }
186+ if ([ids length] > 0) {
187+ path = [NSString stringWithFormat:@"http://www.flickr.com/tools/uploader_edit.gne?ids=%@", ids];
188+ }
189+ } else {
190+ }
191+ if (path) {
192+ return [NSURL URLWithString:path];
193+ }
194+ return nil;
195+}
196+
197+-(void) login
198+{
199+ NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
200+ id token = [defaults objectForKey:@"Flickr_Token"];
201+ if (token) {
202+ // token取得済み
203+ [self setValue:token forKey:@"token"];
204+ [FlickrRequest setToken:_token];
205+ [self setValue:LOCALIZED(@"Logout...") forKey:@"authBtnTitle"];
206+ } else {
207+ // token未取得
208+ // frob を取得しておく
209+ Flickr_Auth_GetFrob* req = [[Flickr_Auth_GetFrob alloc] init];
210+ [req setDelegate:self];
211+ [req start];
212+ [self setValue:LOCALIZED(@"Login...") forKey:@"authBtnTitle"];
213+ }
214+}
215+
216+-(BOOL) checkAuth
217+{
218+ return (!IS_NULL_STR(_token));
219+}
220+
221+@end
--- trunk/src/flickr/Flickr_Auth_GetFrob.h (nonexistent)
+++ trunk/src/flickr/Flickr_Auth_GetFrob.h (revision 18)
@@ -0,0 +1,36 @@
1+// Copyright (c) 2008 itok ( http://itok.jp/ , http://110k.net/ )
2+// All rights reserved.
3+//
4+// Redistribution and use in source and binary forms, with or without modification,
5+// are permitted provided that the following conditions are met:
6+//
7+// - Redistributions of source code must retain the above copyright notice,
8+// this list of conditions and the following disclaimer.
9+// - Redistributions in binary form must reproduce the above copyright notice,
10+// this list of conditions and the following disclaimer in the documentation
11+// and/or other materials provided with the distribution.
12+// - Neither the name of itok nor the names of its contributors may be used to endorse
13+// or promote products derived from this software without specific prior written permission.
14+//
15+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
16+// AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
17+// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
18+// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19+// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
20+// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26+// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
28+
29+#import <Cocoa/Cocoa.h>
30+#import "FlickrRequest.h"
31+
32+@interface Flickr_Auth_GetFrob : FlickrRequest {
33+
34+}
35+
36+@end
--- trunk/src/flickr/Flickr_Auth_GetFrob.m (nonexistent)
+++ trunk/src/flickr/Flickr_Auth_GetFrob.m (revision 18)
@@ -0,0 +1,47 @@
1+// Copyright (c) 2008 itok ( http://itok.jp/ , http://110k.net/ )
2+// All rights reserved.
3+//
4+// Redistribution and use in source and binary forms, with or without modification,
5+// are permitted provided that the following conditions are met:
6+//
7+// - Redistributions of source code must retain the above copyright notice,
8+// this list of conditions and the following disclaimer.
9+// - Redistributions in binary form must reproduce the above copyright notice,
10+// this list of conditions and the following disclaimer in the documentation
11+// and/or other materials provided with the distribution.
12+// - Neither the name of itok nor the names of its contributors may be used to endorse
13+// or promote products derived from this software without specific prior written permission.
14+//
15+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
16+// AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
17+// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
18+// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19+// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
20+// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26+// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
28+
29+#import "Flickr_Auth_GetFrob.h"
30+#import "FlickrSignature.h"
31+
32+#define AUTH_GETFROB_ARG \
33+ [NSDictionary dictionaryWithObjectsAndKeys: \
34+ @"flickr.auth.getFrob", @"method", \
35+ [FlickrSignature apiKey], @"api_key", \
36+ nil]
37+
38+@implementation Flickr_Auth_GetFrob
39+
40+-(id) init
41+{
42+ if (self = [super initWithBasePath:@"http://api.flickr.com/services/rest/" withArgs:AUTH_GETFROB_ARG needSignature:YES method:@"GET"]) {
43+ }
44+ return self;
45+}
46+
47+@end
--- trunk/src/flickr/Flickr.h (nonexistent)
+++ trunk/src/flickr/Flickr.h (revision 18)
@@ -0,0 +1,41 @@
1+// Copyright (c) 2008 itok ( http://itok.jp/ , http://110k.net/ )
2+// All rights reserved.
3+//
4+// Redistribution and use in source and binary forms, with or without modification,
5+// are permitted provided that the following conditions are met:
6+//
7+// - Redistributions of source code must retain the above copyright notice,
8+// this list of conditions and the following disclaimer.
9+// - Redistributions in binary form must reproduce the above copyright notice,
10+// this list of conditions and the following disclaimer in the documentation
11+// and/or other materials provided with the distribution.
12+// - Neither the name of itok nor the names of its contributors may be used to endorse
13+// or promote products derived from this software without specific prior written permission.
14+//
15+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
16+// AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
17+// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
18+// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19+// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
20+// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26+// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
28+// Flickr API http://flickr.com/services/api/
29+
30+#include <Cocoa/Cocoa.h>
31+
32+#import "FlickrRequest.h"
33+#import "Flickr_Auth_GetFrob.h"
34+#import "Flickr_Auth_GetToken.h"
35+#import "Flickr_Upload.h"
36+
37+#import "FlickrSignature.h"
38+
39+#import "FlickrService.h"
40+
41+#import "FLPhoto.h"
--- trunk/src/flickr/FLPhoto.h (nonexistent)
+++ trunk/src/flickr/FLPhoto.h (revision 18)
@@ -0,0 +1,17 @@
1+//
2+// FLPhoto.h
3+// iPhotoUploader
4+//
5+// Created by 伊藤 啓 on 08/05/11.
6+// Copyright 2008 __MyCompanyName__. All rights reserved.
7+//
8+
9+#import <Cocoa/Cocoa.h>
10+
11+
12+@interface FLPhoto : NSObject
13+{
14+ int _photoid;
15+}
16+
17+@end
--- trunk/src/flickr/Flickr_Upload.h (nonexistent)
+++ trunk/src/flickr/Flickr_Upload.h (revision 18)
@@ -0,0 +1,41 @@
1+// Copyright (c) 2008 itok ( http://itok.jp/ , http://110k.net/ )
2+// All rights reserved.
3+//
4+// Redistribution and use in source and binary forms, with or without modification,
5+// are permitted provided that the following conditions are met:
6+//
7+// - Redistributions of source code must retain the above copyright notice,
8+// this list of conditions and the following disclaimer.
9+// - Redistributions in binary form must reproduce the above copyright notice,
10+// this list of conditions and the following disclaimer in the documentation
11+// and/or other materials provided with the distribution.
12+// - Neither the name of itok nor the names of its contributors may be used to endorse
13+// or promote products derived from this software without specific prior written permission.
14+//
15+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
16+// AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
17+// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
18+// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19+// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
20+// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26+// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
28+
29+#import <Cocoa/Cocoa.h>
30+#import "FlickrRequest.h"
31+
32+@interface Flickr_Upload : FlickrRequest
33+{
34+ NSURL* _fileUrl;
35+ NSString* _contentType;
36+ NSString* _name;
37+ NSArray* _tags;
38+ NSString* _comment;
39+}
40+
41+@end
--- trunk/src/flickr/FLPhoto.m (nonexistent)
+++ trunk/src/flickr/FLPhoto.m (revision 18)
@@ -0,0 +1,14 @@
1+//
2+// FLPhoto.m
3+// iPhotoUploader
4+//
5+// Created by 伊藤 啓 on 08/05/11.
6+// Copyright 2008 __MyCompanyName__. All rights reserved.
7+//
8+
9+#import "FLPhoto.h"
10+
11+
12+@implementation FLPhoto
13+
14+@end
--- trunk/src/flickr/FlickrRequest.h (nonexistent)
+++ trunk/src/flickr/FlickrRequest.h (revision 18)
@@ -0,0 +1,43 @@
1+// Copyright (c) 2008 itok ( http://itok.jp/ , http://110k.net/ )
2+// All rights reserved.
3+//
4+// Redistribution and use in source and binary forms, with or without modification,
5+// are permitted provided that the following conditions are met:
6+//
7+// - Redistributions of source code must retain the above copyright notice,
8+// this list of conditions and the following disclaimer.
9+// - Redistributions in binary form must reproduce the above copyright notice,
10+// this list of conditions and the following disclaimer in the documentation
11+// and/or other materials provided with the distribution.
12+// - Neither the name of itok nor the names of its contributors may be used to endorse
13+// or promote products derived from this software without specific prior written permission.
14+//
15+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
16+// AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
17+// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
18+// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19+// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
20+// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26+// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
28+
29+#import <Cocoa/Cocoa.h>
30+#import "PURequest.h"
31+
32+
33+@interface FlickrRequest : PURequest
34+{
35+}
36+
37+-(id) initWithBasePath:(NSString*)path withArgs:(NSDictionary*)args needSignature:(BOOL)need method:(NSString*)method;
38+
39++(NSString*) createPath:(NSString*)path withArgs:(NSDictionary*)args needSignature:(BOOL)need;
40++(void) setToken:(NSString*)token;
41++(NSString*) token;
42+
43+@end
--- trunk/src/flickr/Flickr_Upload.m (nonexistent)
+++ trunk/src/flickr/Flickr_Upload.m (revision 18)
@@ -0,0 +1,89 @@
1+// Copyright (c) 2008 itok ( http://itok.jp/ , http://110k.net/ )
2+// All rights reserved.
3+//
4+// Redistribution and use in source and binary forms, with or without modification,
5+// are permitted provided that the following conditions are met:
6+//
7+// - Redistributions of source code must retain the above copyright notice,
8+// this list of conditions and the following disclaimer.
9+// - Redistributions in binary form must reproduce the above copyright notice,
10+// this list of conditions and the following disclaimer in the documentation
11+// and/or other materials provided with the distribution.
12+// - Neither the name of itok nor the names of its contributors may be used to endorse
13+// or promote products derived from this software without specific prior written permission.
14+//
15+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
16+// AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
17+// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
18+// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19+// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
20+// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26+// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
28+
29+#import "Flickr_Upload.h"
30+#import "FlickrSignature.h"
31+#import "FLPhoto.h"
32+#import "NSXMLElement-ex.h"
33+
34+@implementation Flickr_Upload
35+
36+-(id) init
37+{
38+ if (self = [super initWithBasePath:@"http://api.flickr.com/services/upload/" withArgs:nil needSignature:NO method:@"POST"]) {
39+ }
40+ return self;
41+}
42+
43+-(void) start
44+{
45+ if (!(_fileUrl && [_fileUrl isFileURL] && _contentType)) {
46+ return;
47+ }
48+
49+ [m_postData setObject:[FlickrSignature apiKey] forKey:@"api_key"];
50+ [m_postData setObject:[FlickrRequest token] forKey:@"auth_token"];
51+
52+ if (_name && [_name length] > 0) {
53+ [m_postData setObject:_name forKey:@"title"];
54+ }
55+ if (_tags && [_tags count] > 0) {
56+ [m_postData setObject:[_tags componentsJoinedByString:@" "] forKey:@"tags"];
57+ }
58+ if (_comment && [_comment length] > 0) {
59+ [m_postData setObject:_comment forKey:@"description"];
60+ }
61+
62+ // photo以外のすべてのパラメータについてのsignatureを算出する
63+ [m_postData setObject:[FlickrSignature generateApiSignature:m_postData] forKey:@"api_sig"];
64+
65+ [m_postData setObject:[NSDictionary dictionaryWithObjectsAndKeys:
66+ _fileUrl, KEY_URL,
67+ _contentType, KEY_TYPE,
68+ nil]
69+ forKey:@"photo"];
70+
71+ [super start];
72+}
73+
74+-(id) responseData
75+{
76+ NSXMLDocument* xml = [super responseData];
77+ if (xml && [xml isKindOfClass:[NSXMLDocument class]]) {
78+// NSLog(@"%@", [xml description]);
79+ id photoId = [[xml rootElement] objectValueForXPath:@"/rsp/photoid" error:nil];
80+ if (photoId) {
81+ FLPhoto* photo = [[FLPhoto alloc] init];
82+ [photo setValue:photoId forKey:@"photoid"];
83+ return [photo autorelease];
84+ }
85+ }
86+ return nil;
87+}
88+
89+@end
--- trunk/src/flickr/Flickr_People_GetUploadStatus.h (nonexistent)
+++ trunk/src/flickr/Flickr_People_GetUploadStatus.h (revision 18)
@@ -0,0 +1,16 @@
1+//
2+// Flickr_People_GetUploadStatus.h
3+// iPhotoUploader
4+//
5+// Created by 伊藤 啓 on 08/05/09.
6+// Copyright 2008 __MyCompanyName__. All rights reserved.
7+//
8+
9+#import <Cocoa/Cocoa.h>
10+#import "FlickrRequest.h"
11+
12+@interface Flickr_People_GetUploadStatus : FlickrRequest
13+{
14+}
15+
16+@end
--- trunk/src/flickr/FlickrRequest.m (nonexistent)
+++ trunk/src/flickr/FlickrRequest.m (revision 18)
@@ -0,0 +1,146 @@
1+// Copyright (c) 2008 itok ( http://itok.jp/ , http://110k.net/ )
2+// All rights reserved.
3+//
4+// Redistribution and use in source and binary forms, with or without modification,
5+// are permitted provided that the following conditions are met:
6+//
7+// - Redistributions of source code must retain the above copyright notice,
8+// this list of conditions and the following disclaimer.
9+// - Redistributions in binary form must reproduce the above copyright notice,
10+// this list of conditions and the following disclaimer in the documentation
11+// and/or other materials provided with the distribution.
12+// - Neither the name of itok nor the names of its contributors may be used to endorse
13+// or promote products derived from this software without specific prior written permission.
14+//
15+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
16+// AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
17+// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
18+// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19+// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
20+// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26+// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
28+
29+#import "FlickrRequest.h"
30+#import "FlickrSignature.h"
31+#import "NSXMLElement-ex.h"
32+
33+static NSString* s_token = nil;
34+
35+@implementation FlickrRequest
36+
37++(NSString*) createPath:(NSString*)path withArgs:(NSDictionary*)args needSignature:(BOOL)need
38+{
39+ // GET 用 URL を生成
40+ BOOL isFirst = YES;
41+ NSMutableString* str = [NSMutableString stringWithString:path];
42+ if (args && [args count] > 0) {
43+ [str appendString:@"?"];
44+
45+ NSEnumerator* enume = [args keyEnumerator];
46+ id key;
47+ while (key = [enume nextObject]) {
48+ id value = [args objectForKey:key];
49+ if (isFirst) {
50+ isFirst = NO;
51+ } else {
52+ [str appendString:@"&"];
53+ }
54+ [str appendFormat:@"%@=%@", key, value];
55+ }
56+ }
57+
58+ if (need) {
59+ // api_sig が必要
60+ if (!args || [args count] == 0) {
61+ [str appendString:@"?"];
62+ }
63+ if (!isFirst) {
64+ [str appendString:@"&"];
65+ }
66+ [str appendFormat:@"api_sig=%@", [FlickrSignature generateApiSignature:args]];
67+ }
68+ // NSLog(@"%@", str);
69+ return str;
70+}
71+
72+-(id) initWithBasePath:(NSString*)path withArgs:(NSDictionary*)args needSignature:(BOOL)need method:(NSString*)method
73+{
74+ NSString* str = [FlickrRequest createPath:path withArgs:args needSignature:need];
75+ if (self = [super initWithURL:[NSURL URLWithString:str] withMethod:method]) {
76+ }
77+ return self;
78+}
79+
80+-(void) start
81+{
82+ [super start];
83+}
84+
85+-(id) responseData
86+{
87+ NSData* data = [super responseData];
88+ if (data && [data isKindOfClass:[NSData class]]) {
89+ NSError* err;
90+ NSXMLDocument* xml = [[[NSXMLDocument alloc] initWithData:data options:0 error:&err] autorelease];
91+ if (!xml) {
92+ NSLog(@"%@", [err description]);
93+ }
94+ return xml;
95+ }
96+ return nil;
97+}
98+
99+-(NSError*) lastError
100+{
101+ NSXMLDocument* xml = [self responseData];
102+ if (!(xml && [xml isKindOfClass:[NSXMLDocument class]])) {
103+ xml = [super responseData];
104+ }
105+ if (xml && [xml isKindOfClass:[NSXMLDocument class]]) {
106+ NSXMLElement* root = [xml rootElement];
107+ if ([[root attributeValueForXPath:@"/rsp" andName:@"stat" error:nil] isEqualTo:@"fail"]) {
108+ id code = [root attributeValueForXPath:@"/rsp/err" andName:@"code" error:nil];
109+ id msg = [root attributeValueForXPath:@"/rsp/err" andName:@"msg" error:nil];
110+ if (code) {
111+ NSDictionary* userInfo = (msg) ? [NSDictionary dictionaryWithObjectsAndKeys:msg, NSLocalizedDescriptionKey, nil] : nil;
112+ NSError* err = [NSError errorWithDomain:PURequestErrorDomain code:[code intValue] userInfo:userInfo];
113+ return err;
114+ }
115+ }
116+ }
117+ return nil;
118+}
119+
120++(void) setToken:(NSString*)token
121+{
122+ if (s_token) {
123+ [s_token release];
124+ }
125+ s_token = [token copy];
126+}
127+
128++(NSString*) token
129+{
130+ return s_token;
131+}
132+
133+-(void) setValue:(id)value forUndefinedKey:(id)key
134+{
135+}
136+
137+-(void) setNilValue:(id)value forKey:(id)key
138+{
139+}
140+
141+-(id) valueForUndefinedKey:(id)key
142+{
143+ return nil;
144+}
145+
146+@end
--- trunk/installer.pmdoc/01iphotouploader-contents.xml (revision 17)
+++ trunk/installer.pmdoc/01iphotouploader-contents.xml (revision 18)
@@ -1 +1 @@
1-<pkg-contents spec="1.12"><f n="iPhotoUploader.iPhotoExporter" o="itok" g="admin" p="16877" pt="/Volumes/Data/Work/cocoa/iphotouploader/trunk/build/Release/iPhotoUploader.iPhotoExporter" m="true" t="file"><f n="Contents" o="itok" g="admin" p="16877"><f n="Info.plist" o="itok" g="admin" p="33188"/><f n="MacOS" o="itok" g="admin" p="16877"><f n="iPhotoUploader" o="itok" g="admin" p="33261"/></f><f n="Resources" o="itok" g="admin" p="16877"><f n="Japanese.lproj" o="itok" g="admin" p="16877"><f n="Fotolife.nib" o="itok" g="admin" p="16877"><f n="designable.nib" o="itok" g="admin" p="33188"/><f n="keyedobjects.nib" o="itok" g="admin" p="33188"/></f><f n="iPhotoUploader.nib" o="itok" g="admin" p="16877"><f n="designable.nib" o="itok" g="admin" p="33188"/><f n="keyedobjects.nib" o="itok" g="admin" p="33188"/></f><f n="Localizable.strings" o="itok" g="admin" p="33188"/><f n="PhotoZou.nib" o="itok" g="admin" p="16877"><f n="designable.nib" o="itok" g="admin" p="33188"/><f n="keyedobjects.nib" o="itok" g="admin" p="33188"/></f></f><f n="LICENCE" o="itok" g="admin" p="33188"/></f></f></f></pkg-contents>
\ No newline at end of file
1+<pkg-contents spec="1.12"><f n="iPhotoUploader.iPhotoExporter" o="itok" g="admin" p="16877" pt="/Volumes/Data/Work/cocoa/iphotouploader/trunk/build/Release/iPhotoUploader.iPhotoExporter" m="true" t="file"><f n="Contents" o="itok" g="admin" p="16877"><f n="Info.plist" o="itok" g="admin" p="33188"/><f n="MacOS" o="itok" g="admin" p="16877"><f n="iPhotoUploader" o="itok" g="admin" p="33261"/></f><f n="Resources" o="itok" g="admin" p="16877"><f n="Japanese.lproj" o="itok" g="admin" p="16877"><f n="Flickr.nib" o="itok" g="admin" p="16877"><f n="designable.nib" o="itok" g="admin" p="33188"/><f n="keyedobjects.nib" o="itok" g="admin" p="33188"/></f><f n="Fotolife.nib" o="itok" g="admin" p="16877"><f n="designable.nib" o="itok" g="admin" p="33188"/><f n="keyedobjects.nib" o="itok" g="admin" p="33188"/></f><f n="iPhotoUploader.nib" o="itok" g="admin" p="16877"><f n="designable.nib" o="itok" g="admin" p="33188"/><f n="keyedobjects.nib" o="itok" g="admin" p="33188"/></f><f n="Localizable.strings" o="itok" g="admin" p="33188"/><f n="PhotoZou.nib" o="itok" g="admin" p="16877"><f n="designable.nib" o="itok" g="admin" p="33188"/><f n="keyedobjects.nib" o="itok" g="admin" p="33188"/></f></f><f n="LICENCE" o="itok" g="admin" p="33188"/></f></f></f></pkg-contents>
\ No newline at end of file
--- trunk/installer.pmdoc/01iphotouploader.xml (revision 17)
+++ trunk/installer.pmdoc/01iphotouploader.xml (revision 18)
@@ -1 +1 @@
1-<pkgref spec="1.12" uuid="6073DE94-FD24-453D-A03E-87AA6F57A902"><config><identifier>jp.itok.iphotouploader.pkg</identifier><version>1</version><description></description><post-install type="none"/><requireAuthorization/><installFrom relative="true" includeRoot="true">build/Release/iPhotoUploader.iPhotoExporter</installFrom><installTo mod="true">/Applications/iPhoto.app/Contents/PlugIns/</installTo><flags><followSymbolicLinks/></flags><packageStore type="internal"></packageStore><mod>parent</mod><mod>installFrom.isRelativeType</mod><mod>installTo.path</mod><mod>version</mod><mod>installTo</mod></config><contents><file-list>01iphotouploader-contents.xml</file-list><component id="jp.itok.iPhotoUploader" path="/Volumes/Data/Work/cocoa/iphotouploader/trunk/build/Release/iPhotoUploader.iPhotoExporter" version="0.0.1"/><filter>/CVS$</filter><filter>/\.svn$</filter><filter>/\.cvsignore$</filter><filter>/\.cvspass$</filter><filter>/\.DS_Store$</filter></contents></pkgref>
\ No newline at end of file
1+<pkgref spec="1.12" uuid="6073DE94-FD24-453D-A03E-87AA6F57A902"><config><identifier>jp.itok.iphotouploader.pkg</identifier><version>1</version><description></description><post-install type="none"/><requireAuthorization/><installFrom relative="true" includeRoot="true">build/Release/iPhotoUploader.iPhotoExporter</installFrom><installTo mod="true">/Applications/iPhoto.app/Contents/PlugIns/</installTo><flags><followSymbolicLinks/></flags><packageStore type="internal"></packageStore><mod>parent</mod><mod>installFrom.isRelativeType</mod><mod>installTo.path</mod><mod>version</mod><mod>installTo</mod></config><contents><file-list>01iphotouploader-contents.xml</file-list><component id="jp.itok.iPhotoUploader" path="/Volumes/Data/Work/cocoa/iphotouploader/trunk/build/Release/iPhotoUploader.iPhotoExporter" version="0.0.2"/><filter>/CVS$</filter><filter>/\.svn$</filter><filter>/\.cvsignore$</filter><filter>/\.cvspass$</filter><filter>/\.DS_Store$</filter></contents></pkgref>
\ No newline at end of file
Show on old repository browser