├── .gitattributes
├── .gitignore
├── APACHE-LICENSE-2.0.txt
├── CHANGES.md
├── Docs
└── Images
│ └── AddMacSDK.png
├── EvernoteSDK.xcodeproj
├── project.pbxproj
└── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ └── IDEWorkspaceChecks.plist
├── EvernoteSDK
├── 3rdParty
│ ├── AFNetworking
│ │ ├── ENAFURLConnectionOperation.h
│ │ └── ENAFURLConnectionOperation.m
│ ├── KSHTMLWriter
│ │ ├── KSForwardingWriter.h
│ │ ├── KSForwardingWriter.m
│ │ ├── KSHTMLWriter.h
│ │ ├── KSHTMLWriter.m
│ │ ├── KSWriter.h
│ │ ├── KSWriter.m
│ │ ├── KSXMLAttributes.h
│ │ ├── KSXMLAttributes.m
│ │ ├── KSXMLWriter.h
│ │ ├── KSXMLWriter.m
│ │ ├── LICENSE.txt
│ │ ├── NSString+XMLAdditions.h
│ │ └── NSString+XMLAdditions.m
│ ├── NSString+URLEncoding
│ │ ├── LICENSE
│ │ ├── NSString+URLEncoding.h
│ │ └── NSString+URLEncoding.m
│ ├── SSKeychain
│ │ ├── LICENSE
│ │ ├── SSKeychain.h
│ │ └── SSKeychain.m
│ ├── Thrift
│ │ ├── LICENSE
│ │ ├── TApplicationException.h
│ │ ├── TApplicationException.m
│ │ ├── TException.h
│ │ ├── TException.m
│ │ ├── TObjective-C.h
│ │ ├── TProcessor.h
│ │ ├── TProcessorFactory.h
│ │ ├── Thrift.h
│ │ ├── protocol
│ │ │ ├── TBinaryProtocol.h
│ │ │ ├── TBinaryProtocol.m
│ │ │ ├── TProtocol.h
│ │ │ ├── TProtocolException.h
│ │ │ ├── TProtocolException.m
│ │ │ ├── TProtocolFactory.h
│ │ │ ├── TProtocolUtil.h
│ │ │ └── TProtocolUtil.m
│ │ └── transport
│ │ │ ├── THTTPClient.h
│ │ │ ├── THTTPClient.m
│ │ │ ├── TMemoryBuffer.h
│ │ │ ├── TMemoryBuffer.m
│ │ │ ├── TTransport.h
│ │ │ ├── TTransportException.h
│ │ │ └── TTransportException.m
│ └── cocoa-oauth
│ │ ├── ENGCOAuth.h
│ │ ├── ENGCOAuth.m
│ │ ├── LICENSE
│ │ ├── NSData+ENBase64.h
│ │ └── NSData+ENBase64.m
├── EDAM
│ ├── EDAM.h
│ ├── EDAMErrors.h
│ ├── EDAMErrors.m
│ ├── EDAMLimits.h
│ ├── EDAMLimits.m
│ ├── EDAMNoteStore.h
│ ├── EDAMNoteStore.m
│ ├── EDAMTypes.h
│ ├── EDAMTypes.m
│ ├── EDAMUserStore.h
│ └── EDAMUserStore.m
├── EDAMNoteStoreClient+Utilities.h
├── EDAMNoteStoreClient+Utilities.m
├── ENConstants.h
├── ENConstants.m
├── EvernoteNoteStore+Extras.h
├── EvernoteNoteStore+Extras.m
├── EvernoteNoteStore.h
├── EvernoteNoteStore.m
├── EvernoteSDK-Mac-Info.plist
├── EvernoteSDK-Mac-Prefix.pch
├── EvernoteSDK-Prefix.pch
├── EvernoteSDK.h
├── EvernoteSDK.m
├── EvernoteSession.h
├── EvernoteSession.m
├── EvernoteUserStore+Extras.h
├── EvernoteUserStore+Extras.m
├── EvernoteUserStore.h
├── EvernoteUserStore.m
├── Utilities
│ ├── ENMLUtility.h
│ ├── ENMLUtility.m
│ ├── NSData+EvernoteSDK.h
│ ├── NSData+EvernoteSDK.m
│ ├── NSDataBase64Additions.h
│ ├── NSDataBase64Additions.m
│ ├── NSDate+EDAMAdditions.h
│ └── NSDate+EDAMAdditions.m
└── internal
│ ├── Bridge
│ ├── ENApplicationBridge.h
│ ├── ENApplicationBridge.m
│ ├── ENApplicationBridge_Private.h
│ ├── ENApplicationRequest.h
│ ├── ENAuthenticationRequest.h
│ ├── ENAuthenticationRequest.m
│ ├── ENLinkNotebookRequest.h
│ ├── ENLinkNotebookRequest.m
│ ├── ENNewNoteRequest.h
│ ├── ENNewNoteRequest.m
│ ├── ENNoteImportRequest.h
│ ├── ENNoteImportRequest.m
│ ├── ENNoteViewRequest.h
│ ├── ENNoteViewRequest.m
│ ├── ENResourceAttachment.h
│ ├── ENResourceAttachment.m
│ ├── ENSearchRequest.h
│ ├── ENSearchRequest.m
│ └── EvernoteBridge.h
│ ├── ENAPI.h
│ ├── ENAPI.m
│ ├── ENCredentialStore.h
│ ├── ENCredentialStore.m
│ ├── ENCredentials.h
│ ├── ENCredentials.m
│ ├── ENOAuthProtocol.h
│ ├── ENOAuthViewController.h
│ ├── ENOAuthViewController.m
│ ├── ENOAuthWindowController.h
│ ├── ENOAuthWindowController.m
│ ├── ENOAuthWindowController.xib
│ └── Resources
│ └── EvernoteSDK.strings
├── FUTURE-IDEAS.md
├── INSTALL-MAC.md
├── LICENSE
├── NOTICE
├── README.md
├── SampleApp-Mac
├── AppDelegate.h
├── AppDelegate.m
├── Base.lproj
│ └── MainMenu.xib
├── SampleApp-Mac-Info.plist
├── SampleApp-Mac-Prefix.pch
├── SampleApp-Mac.entitlements
├── en.lproj
│ ├── Credits.rtf
│ ├── InfoPlist.strings
│ └── MainMenu.xib
└── main.m
├── SampleApp-iOS
├── AppDelegate.h
├── AppDelegate.m
├── Base.lproj
│ ├── iPad.storyboard
│ └── iPhone.storyboard
├── Extras
│ └── UI
│ │ ├── NotebookChooserViewController.h
│ │ └── NotebookChooserViewController.m
├── MoreViewController.h
├── MoreViewController.m
├── NoteBrowserViewController.h
├── NoteBrowserViewController.m
├── Resources
│ ├── Default-568h@2x.png
│ └── Images
│ │ └── evernote_logo_4c-sm.png
├── SampleApp-Info.plist
├── SampleApp-Prefix.pch
├── en.lproj
│ ├── InfoPlist.strings
│ ├── iPad.storyboard
│ └── iPhone.storyboard
├── iPadViewController.h
├── iPadViewController.m
├── iPhoneViewController.h
├── iPhoneViewController.m
└── main.m
├── UnitTests
├── 3rdParty
│ └── OCMock
│ │ ├── LICENSE
│ │ ├── OCMock
│ │ ├── NSNotificationCenter+OCMAdditions.h
│ │ ├── OCMArg.h
│ │ ├── OCMConstraint.h
│ │ ├── OCMock.h
│ │ ├── OCMockObject.h
│ │ └── OCMockRecorder.h
│ │ └── libOCMock.a
├── EvernoteSessionTests.h
├── EvernoteSessionTests.m
├── UnitTests-Info.plist
├── UnitTests-Prefix.pch
└── en.lproj
│ └── InfoPlist.strings
└── src
├── edam
├── EDAMErrors.h
├── EDAMErrors.m
├── EDAMLimits.h
├── EDAMLimits.m
├── EDAMNoteStore.h
├── EDAMNoteStore.m
├── EDAMTypes.h
├── EDAMTypes.m
├── EDAMUserStore.h
└── EDAMUserStore.m
└── thrift
├── TApplicationException.h
├── TApplicationException.m
├── TException.h
├── TException.m
├── TProcessor.h
├── TProcessorFactory.h
├── TSharedProcessorFactory.h
├── TSharedProcessorFactory.m
├── protocol
├── TBinaryProtocol.h
├── TBinaryProtocol.m
├── TProtocol.h
├── TProtocolException.h
├── TProtocolException.m
├── TProtocolFactory.h
├── TProtocolUtil.h
└── TProtocolUtil.m
└── transport
├── THTTPClient.h
├── THTTPClient.m
├── TMemoryBuffer.h
├── TMemoryBuffer.m
├── TTransport.h
├── TTransportException.h
└── TTransportException.m
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.pbxproj binary merge=union
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | xcuserdata
2 | # OS X Finder
3 | .DS_Store
4 |
5 | # Xcode per-user config
6 | *.mode1
7 | *.mode1v3
8 | *.mode2v3
9 | *.perspective
10 | *.perspectivev3
11 | *.pbxuser
12 | # Build products
13 | build/
14 | *.o
15 | *.LinkFileList
16 | *.hmap
17 | # Automatic backup files
18 | *~.nib/
19 | *.swp
20 | *~
21 | *.dat
22 | *.dep
23 | # Cocoapods
24 | Pods
25 | Podfile.lock
--------------------------------------------------------------------------------
/Docs/Images/AddMacSDK.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Evernote/evernote-sdk-mac/012939f50b0d2b646cac09fb5260ee4296287efd/Docs/Images/AddMacSDK.png
--------------------------------------------------------------------------------
/EvernoteSDK.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/EvernoteSDK.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/KSHTMLWriter/KSForwardingWriter.h:
--------------------------------------------------------------------------------
1 | //
2 | // KSForwardingWriter.h
3 | //
4 | // Copyright (c) 2010, Mike Abdullah and Karelia Software
5 | // All rights reserved.
6 | //
7 | // Redistribution and use in source and binary forms, with or without
8 | // modification, are permitted provided that the following conditions are met:
9 | // * Redistributions of source code must retain the above copyright
10 | // notice, this list of conditions and the following disclaimer.
11 | // * Redistributions in binary form must reproduce the above copyright
12 | // notice, this list of conditions and the following disclaimer in the
13 | // documentation and/or other materials provided with the distribution.
14 | //
15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | // DISCLAIMED. IN NO EVENT SHALL MIKE ABDULLAH OR KARELIA SOFTWARE BE LIABLE FOR ANY
19 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 | //
26 | // Abstract base class for any writers that operate by sending strings along to an output writer.
27 | //
28 |
29 |
30 | #import
31 | #import "KSWriter.h"
32 |
33 |
34 | @interface KSForwardingWriter : NSObject
35 | {
36 | @private
37 | id _writer;
38 | }
39 |
40 | #pragma mark Creating a Writer
41 | - (id)initWithOutputWriter:(id )stream; // designated initializer
42 | - (id)init; // calls -initWithOutputWriter with nil. Handy for iteration & deriving info, but not a lot else
43 |
44 |
45 | #pragma mark Primitive
46 |
47 | - (void)writeString:(NSString *)string; // calls -writeString: on our string stream. Override to customize raw writing
48 |
49 |
50 | @end
51 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/KSHTMLWriter/KSForwardingWriter.m:
--------------------------------------------------------------------------------
1 | //
2 | // KSForwardingWriter.m
3 | //
4 | // Copyright (c) 2010, Mike Abdullah and Karelia Software
5 | // All rights reserved.
6 | //
7 | // Redistribution and use in source and binary forms, with or without
8 | // modification, are permitted provided that the following conditions are met:
9 | // * Redistributions of source code must retain the above copyright
10 | // notice, this list of conditions and the following disclaimer.
11 | // * Redistributions in binary form must reproduce the above copyright
12 | // notice, this list of conditions and the following disclaimer in the
13 | // documentation and/or other materials provided with the distribution.
14 | //
15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | // DISCLAIMED. IN NO EVENT SHALL MIKE ABDULLAH OR KARELIA SOFTWARE BE LIABLE FOR ANY
19 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 | //
26 |
27 |
28 | #import "KSForwardingWriter.h"
29 |
30 |
31 | @implementation KSForwardingWriter
32 |
33 | #pragma mark Init & Dealloc
34 |
35 | - (id)initWithOutputWriter:(id )output; // designated initializer
36 | {
37 | self = [super init];
38 | if (self != nil) {
39 | _writer = output;
40 | }
41 | return self;
42 | }
43 |
44 | - (id)init;
45 | {
46 | return [self initWithOutputWriter:nil];
47 | }
48 |
49 | - (void)dealloc
50 | {
51 | [self close];
52 | NSAssert(!_writer, @"-close failed to dispose of output writer");
53 |
54 | }
55 |
56 | #pragma mark Writer Status
57 |
58 | - (void)close;
59 | {
60 | _writer = nil;
61 | }
62 |
63 | #pragma mark Primitive
64 |
65 | - (void)writeString:(NSString *)string;
66 | {
67 | [_writer writeString:string];
68 | }
69 |
70 | @end
71 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/KSHTMLWriter/KSWriter.h:
--------------------------------------------------------------------------------
1 | //
2 | // KSWriter.h
3 | //
4 | // Copyright (c) 2010, Mike Abdullah and Karelia Software
5 | // All rights reserved.
6 | //
7 | // Redistribution and use in source and binary forms, with or without
8 | // modification, are permitted provided that the following conditions are met:
9 | // * Redistributions of source code must retain the above copyright
10 | // notice, this list of conditions and the following disclaimer.
11 | // * Redistributions in binary form must reproduce the above copyright
12 | // notice, this list of conditions and the following disclaimer in the
13 | // documentation and/or other materials provided with the distribution.
14 | //
15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | // DISCLAIMED. IN NO EVENT SHALL MIKE ABDULLAH OR KARELIA SOFTWARE BE LIABLE FOR ANY
19 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 | //
26 |
27 |
28 | #import
29 |
30 |
31 | @protocol KSWriter
32 | - (void)writeString:(NSString *)string;
33 | - (void)close; // most writers will ignore, but others may use it to trigger an action
34 | @end
35 |
36 |
37 | @protocol KSBufferingWriter
38 | - (void)startBuffering; // can be called multiple times, implementor chooses how to handle that
39 | - (void)flush; // writes all buffered content
40 | - (void)writeString:(NSString *)string bypassBuffer:(BOOL)bypassBuffer;
41 | @end
42 |
43 |
44 | @protocol KSMultiBufferingWriter
45 | - (void)startBuffering; // each call is expected to start a new distinct buffer, while maintaining the old
46 | - (void)flushFirstBuffer; // thus you can stagger beginning and ending buffers
47 | - (NSUInteger)numberOfBuffers;
48 | - (void)writeString:(NSString *)string toBufferAtIndex:(NSUInteger)index; // 0 bypasses all buffers
49 | @end
50 |
51 |
52 | @interface NSMutableString (KSWriter)
53 | @end
54 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/KSHTMLWriter/KSWriter.m:
--------------------------------------------------------------------------------
1 | //
2 | // KSWriter.m
3 | //
4 | // Copyright (c) 2010, Mike Abdullah and Karelia Software
5 | // All rights reserved.
6 | //
7 | // Redistribution and use in source and binary forms, with or without
8 | // modification, are permitted provided that the following conditions are met:
9 | // * Redistributions of source code must retain the above copyright
10 | // notice, this list of conditions and the following disclaimer.
11 | // * Redistributions in binary form must reproduce the above copyright
12 | // notice, this list of conditions and the following disclaimer in the
13 | // documentation and/or other materials provided with the distribution.
14 | //
15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | // DISCLAIMED. IN NO EVENT SHALL MIKE ABDULLAH OR KARELIA SOFTWARE BE LIABLE FOR ANY
19 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 | //
26 |
27 |
28 | #import "KSWriter.h"
29 |
30 |
31 | @implementation NSMutableString (KSWriter)
32 |
33 | - (void)writeString:(NSString *)string
34 | {
35 | /* This was some experimental code to see if it would speed up writing:
36 | const UniChar *characters = CFStringGetCharactersPtr((CFStringRef)string);
37 | if (characters)
38 | {
39 | CFStringAppendCharacters((CFMutableStringRef)self,
40 | characters,
41 | CFStringGetLength((CFStringRef)string));
42 | }
43 | else
44 | {
45 | CFStringAppend((CFMutableStringRef)self, (CFStringRef)string);
46 | }*/
47 |
48 | [self appendString:string];
49 | }
50 |
51 | - (void)close; { } // do nothing as it makes no sense to close a mutable string
52 |
53 | @end
54 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/KSHTMLWriter/KSXMLAttributes.h:
--------------------------------------------------------------------------------
1 | //
2 | // KSXMLAttributes.h
3 | // Sandvox
4 | //
5 | // Created by Mike on 19/11/2010.
6 | // Copyright 2010 Karelia Software. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 |
12 | @interface KSXMLAttributes : NSObject
13 | {
14 | @private
15 | NSMutableArray *_attributes;
16 | }
17 |
18 | - (id)initWithXMLAttributes:(KSXMLAttributes *)info;
19 |
20 | @property(nonatomic, copy) NSDictionary *attributesAsDictionary;
21 | - (BOOL)hasAttributes;
22 | - (void)addAttribute:(NSString *)attribute value:(id)value;
23 |
24 | - (void)close; // removes all attributes
25 |
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/KSHTMLWriter/KSXMLAttributes.m:
--------------------------------------------------------------------------------
1 | //
2 | // KSXMLAttributes.m
3 | // Sandvox
4 | //
5 | // Created by Mike on 19/11/2010.
6 | // Copyright 2010 Karelia Software. All rights reserved.
7 | //
8 |
9 | #import "KSXMLAttributes.h"
10 |
11 | #import "KSXMLWriter.h"
12 |
13 |
14 | @implementation KSXMLAttributes
15 |
16 | #pragma mark Lifecycle
17 |
18 | - (id)init;
19 | {
20 | self = [super init];
21 | if (self != nil) {
22 | _attributes = [[NSMutableArray alloc] initWithCapacity:2];
23 | }
24 | return self;
25 | }
26 |
27 | - (id)initWithXMLAttributes:(KSXMLAttributes *)info;
28 | {
29 | self = [super init]; // call super, so _attributes is still nil
30 |
31 | _attributes = [info->_attributes mutableCopy];
32 |
33 | return self;
34 | }
35 |
36 |
37 | - (NSDictionary *)attributesAsDictionary;
38 | {
39 | NSMutableDictionary *result = [NSMutableDictionary dictionary];
40 |
41 | for (NSUInteger i = 0; i < [_attributes count]; i+=2)
42 | {
43 | NSString *attribute = [_attributes objectAtIndex:i];
44 | NSString *value = [_attributes objectAtIndex:i+1];
45 | [result setObject:value forKey:attribute];
46 | }
47 |
48 | return result;
49 | }
50 |
51 | - (void)setAttributesAsDictionary:(NSDictionary *)dictionary;
52 | {
53 | for (NSString *anAttribute in dictionary)
54 | {
55 | [self addAttribute:anAttribute value:[dictionary objectForKey:anAttribute]];
56 | }
57 | }
58 |
59 | - (BOOL)hasAttributes;
60 | {
61 | return [_attributes count];
62 | }
63 |
64 | - (void)addAttribute:(NSString *)attribute value:(id)value;
65 | {
66 | NSParameterAssert(value);
67 | [_attributes addObject:attribute];
68 | [_attributes addObject:value];
69 | }
70 |
71 | - (void)close; // sets name to nil and removes all attributes
72 | {
73 | [_attributes removeAllObjects];
74 | }
75 |
76 | #pragma mark NSCopying
77 |
78 | - (id)copyWithZone:(NSZone *)zone;
79 | {
80 | return [[[KSXMLAttributes class] alloc] initWithXMLAttributes:self];
81 | }
82 |
83 | #pragma mark Description
84 |
85 | - (NSString *)description;
86 | {
87 | NSMutableString *result = [NSMutableString stringWithString:[super description]];
88 |
89 | KSXMLWriter *writer = [[KSXMLWriter alloc] initWithOutputWriter:result];
90 | [writer writeString:@" "];
91 |
92 | [writer startElement:@"" attributes:[self attributesAsDictionary]];
93 | [writer endElement];
94 |
95 |
96 | return result;
97 | }
98 |
99 | @end
100 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/KSHTMLWriter/LICENSE.txt:
--------------------------------------------------------------------------------
1 | KSHTMLWriter Copyright (c) 2010, Mike Abdullah and Karelia Software All
2 | rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are
6 | met: * Redistributions of source code must retain the above copyright
7 | notice, this list of conditions and the following disclaimer. *
8 | Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 |
12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
13 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
14 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
15 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MIKE ABDULLAH OR
16 | KARELIA SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
17 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
18 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
19 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
20 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/KSHTMLWriter/NSString+XMLAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSString+XMLAdditions.h
3 | // Evernote
4 | //
5 | // Created by Steve White on 10/5/07.
6 | // Copyright 2007 Evernote Corporation. All rights reserved.
7 | //
8 |
9 |
10 | #import
11 |
12 | @interface NSString (XMLAdditions)
13 |
14 | /**
15 | * Escape the standard 5 XML entities: &, <, >, ", '
16 | */
17 | - (NSString *) stringByEscapingCriticalXMLEntities;
18 | /**
19 | * Unescape the standard 5 XML entities: &, <, >, ", '
20 | */
21 | - (NSString *) stringByUnescapingCrititcalXMLEntities;
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/KSHTMLWriter/NSString+XMLAdditions.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSString+XMLAdditions.m
3 | // Evernote
4 | //
5 | // Created by Steve White on 10/5/07.
6 | // Copyright 2007 Evernote Corporation. All rights reserved.
7 | //
8 |
9 | #import "NSString+XMLAdditions.h"
10 |
11 | @implementation NSString (XMLAdditions)
12 |
13 | // see .h
14 | - (NSString *) stringByEscapingCriticalXMLEntities
15 | {
16 | NSMutableString * mutable = [NSMutableString stringWithString:self];
17 | [mutable replaceOccurrencesOfString: @"&"
18 | withString: @"&"
19 | options: NSLiteralSearch
20 | range: NSMakeRange(0, mutable.length)];
21 | [mutable replaceOccurrencesOfString: @"<"
22 | withString: @"<"
23 | options: NSLiteralSearch
24 | range: NSMakeRange(0, mutable.length)];
25 | [mutable replaceOccurrencesOfString: @">"
26 | withString: @">"
27 | options: NSLiteralSearch
28 | range: NSMakeRange(0, mutable.length)];
29 | [mutable replaceOccurrencesOfString: @"'"
30 | withString: @"'"
31 | options: NSLiteralSearch
32 | range: NSMakeRange(0, mutable.length)];
33 | [mutable replaceOccurrencesOfString: @"\""
34 | withString: @"""
35 | options: NSLiteralSearch
36 | range: NSMakeRange(0, mutable.length)];
37 | return mutable;
38 | }
39 |
40 | - (NSString *) stringByUnescapingCrititcalXMLEntities
41 | {
42 | NSMutableString *mutable = [NSMutableString stringWithString:self];
43 | [mutable replaceOccurrencesOfString:@"&"
44 | withString:@"&"
45 | options:NSLiteralSearch
46 | range:NSMakeRange(0, mutable.length)];
47 | [mutable replaceOccurrencesOfString:@"<"
48 | withString:@"<"
49 | options:NSLiteralSearch
50 | range:NSMakeRange(0, mutable.length)];
51 | [mutable replaceOccurrencesOfString:@">"
52 | withString:@">"
53 | options:NSLiteralSearch
54 | range:NSMakeRange(0, mutable.length)];
55 | [mutable replaceOccurrencesOfString:@"'"
56 | withString:@"'"
57 | options:NSLiteralSearch
58 | range:NSMakeRange(0, mutable.length)];
59 | [mutable replaceOccurrencesOfString:@"""
60 | withString:@"\""
61 | options:NSLiteralSearch
62 | range:NSMakeRange(0, mutable.length)];
63 | return mutable;
64 | };
65 |
66 | @end
67 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/NSString+URLEncoding/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2007 Kaboomerang LLC. All rights reserved.
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/NSString+URLEncoding/NSString+URLEncoding.h:
--------------------------------------------------------------------------------
1 | /*
2 | * NSString+URLEncoding.h
3 | * evernote-sdk-ios
4 | *
5 | * Copyright 2012 Evernote Corporation
6 | * All rights reserved.
7 | *
8 | * Redistribution and use in source and binary forms, with or without modification,
9 | * are permitted provided that the following conditions are met:
10 | *
11 | * 1. Redistributions of source code must retain the above copyright notice, this
12 | * list of conditions and the following disclaimer.
13 | *
14 | * 2. Redistributions in binary form must reproduce the above copyright notice,
15 | * this list of conditions and the following disclaimer in the documentation
16 | * and/or other materials provided with the distribution.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | #import
31 |
32 |
33 | @interface NSString (URLEncoding)
34 | - (NSString *)stringByUnescapingFromURLQuery;
35 | - (NSDictionary*)queryDictionaryUsingEncoding: (NSStringEncoding)encoding;
36 | - (NSString *) urlEncode;
37 | - (NSString *)URLEncodedString;
38 | - (NSString *)URLDecodedString;
39 | @end
40 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/SSKeychain/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2010-2011 Sam Soffes.
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining
4 | a copy of this software and associated documentation files (the
5 | "Software"), to deal in the Software without restriction, including
6 | without limitation the rights to use, copy, modify, merge, publish,
7 | distribute, sublicense, and/or sell copies of the Software, and to
8 | permit persons to whom the Software is furnished to do so, subject to
9 | the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be
12 | included in all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/Thrift/TApplicationException.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import "TException.h"
21 | #import "TProtocol.h"
22 |
23 | enum {
24 | TApplicationException_UNKNOWN = 0,
25 | TApplicationException_UNKNOWN_METHOD = 1,
26 | TApplicationException_INVALID_MESSAGE_TYPE = 2,
27 | TApplicationException_WRONG_METHOD_NAME = 3,
28 | TApplicationException_BAD_SEQUENCE_ID = 4,
29 | TApplicationException_MISSING_RESULT = 5,
30 | TApplicationException_INTERNAL_ERROR = 6,
31 | TApplicationException_PROTOCOL_ERROR = 7
32 | };
33 |
34 | // FIXME
35 | @interface TApplicationException : TException {
36 | int mType;
37 | }
38 |
39 | + (TApplicationException *) read: (id ) protocol;
40 |
41 | - (void) write: (id ) protocol;
42 |
43 | + (TApplicationException *) exceptionWithType: (int) type
44 | reason: (NSString *) message;
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/Thrift/TApplicationException.m:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import "TApplicationException.h"
21 | #import "TProtocolUtil.h"
22 | #import "TObjective-C.h"
23 |
24 | @implementation TApplicationException
25 |
26 | - (id) initWithType: (int) type
27 | reason: (NSString *) reason
28 | {
29 | mType = type;
30 |
31 | NSString * name;
32 | switch (type) {
33 | case TApplicationException_UNKNOWN_METHOD:
34 | name = @"Unknown method";
35 | break;
36 | case TApplicationException_INVALID_MESSAGE_TYPE:
37 | name = @"Invalid message type";
38 | break;
39 | case TApplicationException_WRONG_METHOD_NAME:
40 | name = @"Wrong method name";
41 | break;
42 | case TApplicationException_BAD_SEQUENCE_ID:
43 | name = @"Bad sequence ID";
44 | break;
45 | case TApplicationException_MISSING_RESULT:
46 | name = @"Missing result";
47 | break;
48 | default:
49 | name = @"Unknown";
50 | break;
51 | }
52 |
53 | self = [super initWithName: name reason: reason userInfo: nil];
54 | return self;
55 | }
56 |
57 |
58 | + (TApplicationException *) read: (id ) protocol
59 | {
60 | NSString * reason = nil;
61 | int type = TApplicationException_UNKNOWN;
62 | int fieldType;
63 | int fieldID;
64 |
65 | [protocol readStructBeginReturningName: NULL];
66 |
67 | while (true) {
68 | [protocol readFieldBeginReturningName: NULL
69 | type: &fieldType
70 | fieldID: &fieldID];
71 | if (fieldType == TType_STOP) {
72 | break;
73 | }
74 | switch (fieldID) {
75 | case 1:
76 | if (fieldType == TType_STRING) {
77 | reason = [protocol readString];
78 | } else {
79 | [TProtocolUtil skipType: fieldType onProtocol: protocol];
80 | }
81 | break;
82 | case 2:
83 | if (fieldType == TType_I32) {
84 | type = [protocol readI32];
85 | } else {
86 | [TProtocolUtil skipType: fieldType onProtocol: protocol];
87 | }
88 | break;
89 | default:
90 | [TProtocolUtil skipType: fieldType onProtocol: protocol];
91 | break;
92 | }
93 | [protocol readFieldEnd];
94 | }
95 | [protocol readStructEnd];
96 |
97 | return [TApplicationException exceptionWithType: type reason: reason];
98 | }
99 |
100 |
101 | - (void) write: (id ) protocol
102 | {
103 | [protocol writeStructBeginWithName: @"TApplicationException"];
104 |
105 | if ([self reason] != nil) {
106 | [protocol writeFieldBeginWithName: @"message"
107 | type: TType_STRING
108 | fieldID: 1];
109 | [protocol writeString: [self reason]];
110 | [protocol writeFieldEnd];
111 | }
112 |
113 | [protocol writeFieldBeginWithName: @"type"
114 | type: TType_I32
115 | fieldID: 2];
116 | [protocol writeI32: mType];
117 | [protocol writeFieldEnd];
118 |
119 | [protocol writeFieldStop];
120 | [protocol writeStructEnd];
121 | }
122 |
123 |
124 | + (TApplicationException *) exceptionWithType: (int) type
125 | reason: (NSString *) reason
126 | {
127 | return [[[TApplicationException alloc] initWithType: type
128 | reason: reason] autorelease_stub];
129 | }
130 |
131 | @end
132 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/Thrift/TException.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import
21 |
22 | @interface TException : NSException {
23 | }
24 |
25 | + (id) exceptionWithName: (NSString *) name;
26 |
27 | + (id) exceptionWithName: (NSString *) name
28 | reason: (NSString *) reason;
29 |
30 | + (id) exceptionWithName: (NSString *) name
31 | reason: (NSString *) reason
32 | error: (NSError *) error;
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/Thrift/TException.m:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import "TException.h"
21 | #import "TObjective-C.h"
22 |
23 | @implementation TException
24 |
25 | + (id) exceptionWithName: (NSString *) name
26 | {
27 | return [self exceptionWithName: name reason: @"unknown" error: nil];
28 | }
29 |
30 |
31 | + (id) exceptionWithName: (NSString *) name
32 | reason: (NSString *) reason
33 | {
34 | return [self exceptionWithName: name reason: reason error: nil];
35 | }
36 |
37 |
38 | + (id) exceptionWithName: (NSString *) name
39 | reason: (NSString *) reason
40 | error: (NSError *) error
41 | {
42 | NSDictionary * userInfo = nil;
43 | if (error != nil) {
44 | userInfo = [NSDictionary dictionaryWithObject: error forKey: @"error"];
45 | }
46 |
47 | return [super exceptionWithName: name
48 | reason: reason
49 | userInfo: userInfo];
50 | }
51 |
52 |
53 | - (NSString *) description
54 | {
55 | NSMutableString * result = [NSMutableString stringWithString: [self name]];
56 | [result appendFormat: @": %@", [self reason]];
57 | if ([self userInfo] != nil) {
58 | [result appendFormat: @"\n userInfo = %@", [self userInfo]];
59 | }
60 |
61 | return result;
62 | }
63 |
64 |
65 | @end
66 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/Thrift/TObjective-C.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | /*
21 | * TObjective-C.h is for supporting coexistence of both the ARC (Automatic
22 | * Reference Counting) mode and the Non-ARC mode of Objective-C
23 | * in the same source code.
24 | *
25 | * 2011/11/14 HIRANO Satoshi (AIST, Japan)
26 | *
27 | * Before:
28 | *
29 | * var = [aObject retain];
30 | * [aObject release];
31 | * [aObject autorelease];
32 | * [super dealloc];
33 | * CFFunction(obj);
34 | *
35 | * ARC and Non-ARC compatible:
36 | *
37 | * #import "TObjective-C.h"
38 | * var = [aObject retain_stub];
39 | * [aObject release_stub];
40 | * [aObject autorelease_stub];
41 | * [super dealloc_stub];
42 | * CFFunction(bridge_stub obj);
43 | *
44 | * Don't use retain_stub for @property(retain).
45 | * Use NSAutoreleasePool like this:
46 | * #if __has_feature(objc_arc)
47 | * @autoreleasepool {
48 | * // code
49 | * }
50 | * #else
51 | * NSAutoReleasePool *pool = [[NSAutoReleasePool alloc] init...
52 | * // code
53 | * [pool release];
54 | * #endif
55 | */
56 |
57 |
58 | #if !defined(retain_stub)
59 | #if __has_feature(objc_arc)
60 | #define retain_stub self
61 | #define autorelease_stub self
62 | #define release_stub self
63 | #define dealloc_stub self
64 | #define bridge_stub __bridge
65 | #else
66 | #define retain_stub retain
67 | #define autorelease_stub autorelease
68 | #define release_stub release
69 | #define dealloc_stub dealloc
70 | #define bridge_stub
71 | #endif
72 | #endif
73 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/Thrift/TProcessor.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import
21 | #import "TProtocol.h"
22 |
23 |
24 | @protocol TProcessor
25 |
26 | - (BOOL) processOnInputProtocol: (id ) inProtocol
27 | outputProtocol: (id ) outProtocol;
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/Thrift/TProcessorFactory.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import
21 | #import "TProcessor.h"
22 |
23 | @protocol TProcessorFactory
24 |
25 | - (id) processorForTransport: (id) transport;
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/Thrift/Thrift.h:
--------------------------------------------------------------------------------
1 | #import "TApplicationException.h"
2 | #import "TBinaryProtocol.h"
3 | #import "TException.h"
4 | #import "THTTPClient.h"
5 | #import "TProcessor.h"
6 | #import "TProtocol.h"
7 | #import "TProtocolException.h"
8 | #import "TProtocolFactory.h"
9 | #import "TProtocolUtil.h"
10 | #import "TTransport.h"
11 | #import "TTransportException.h"
12 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/Thrift/protocol/TBinaryProtocol.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import "TProtocol.h"
21 | #import "TTransport.h"
22 | #import "TProtocolFactory.h"
23 |
24 |
25 | @interface TBinaryProtocol : NSObject {
26 | id mTransport;
27 | BOOL mStrictRead;
28 | BOOL mStrictWrite;
29 | int32_t mMessageSizeLimit;
30 | }
31 |
32 | - (id) initWithTransport: (id ) transport;
33 |
34 | - (id) initWithTransport: (id ) transport
35 | strictRead: (BOOL) strictRead
36 | strictWrite: (BOOL) strictWrite;
37 |
38 | - (int32_t) messageSizeLimit;
39 | - (void) setMessageSizeLimit: (int32_t) sizeLimit;
40 |
41 | @end;
42 |
43 |
44 | @interface TBinaryProtocolFactory : NSObject {
45 | }
46 |
47 | + (TBinaryProtocolFactory *) sharedFactory;
48 |
49 | - (TBinaryProtocol *) newProtocolOnTransport: (id ) transport;
50 |
51 | @end
52 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/Thrift/protocol/TProtocol.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import
21 |
22 | #import "TTransport.h"
23 |
24 |
25 | enum {
26 | TMessageType_CALL = 1,
27 | TMessageType_REPLY = 2,
28 | TMessageType_EXCEPTION = 3,
29 | TMessageType_ONEWAY = 4
30 | };
31 |
32 | enum {
33 | TType_STOP = 0,
34 | TType_VOID = 1,
35 | TType_BOOL = 2,
36 | TType_BYTE = 3,
37 | TType_DOUBLE = 4,
38 | TType_I16 = 6,
39 | TType_I32 = 8,
40 | TType_I64 = 10,
41 | TType_STRING = 11,
42 | TType_STRUCT = 12,
43 | TType_MAP = 13,
44 | TType_SET = 14,
45 | TType_LIST = 15
46 | };
47 |
48 |
49 | @protocol TProtocol
50 |
51 | - (id ) transport;
52 |
53 | - (void) readMessageBeginReturningName: (NSString **) name
54 | type: (int *) type
55 | sequenceID: (int *) sequenceID;
56 | - (void) readMessageEnd;
57 |
58 | - (void) readStructBeginReturningName: (NSString **) name;
59 | - (void) readStructEnd;
60 |
61 | - (void) readFieldBeginReturningName: (NSString **) name
62 | type: (int *) fieldType
63 | fieldID: (int *) fieldID;
64 | - (void) readFieldEnd;
65 |
66 | - (NSString *) readString;
67 |
68 | - (BOOL) readBool;
69 |
70 | - (unsigned char) readByte;
71 |
72 | - (short) readI16;
73 |
74 | - (int32_t) readI32;
75 |
76 | - (int64_t) readI64;
77 |
78 | - (double) readDouble;
79 |
80 | - (NSData *) readBinary;
81 |
82 | - (void) readMapBeginReturningKeyType: (int *) keyType
83 | valueType: (int *) valueType
84 | size: (int *) size;
85 | - (void) readMapEnd;
86 |
87 |
88 | - (void) readSetBeginReturningElementType: (int *) elementType
89 | size: (int *) size;
90 | - (void) readSetEnd;
91 |
92 |
93 | - (void) readListBeginReturningElementType: (int *) elementType
94 | size: (int *) size;
95 | - (void) readListEnd;
96 |
97 |
98 | - (void) writeMessageBeginWithName: (NSString *) name
99 | type: (int) messageType
100 | sequenceID: (int) sequenceID;
101 | - (void) writeMessageEnd;
102 |
103 | - (void) writeStructBeginWithName: (NSString *) name;
104 | - (void) writeStructEnd;
105 |
106 | - (void) writeFieldBeginWithName: (NSString *) name
107 | type: (int) fieldType
108 | fieldID: (int) fieldID;
109 |
110 | - (void) writeI32: (int32_t) value;
111 |
112 | - (void) writeI64: (int64_t) value;
113 |
114 | - (void) writeI16: (short) value;
115 |
116 | - (void) writeByte: (uint8_t) value;
117 |
118 | - (void) writeString: (NSString *) value;
119 |
120 | - (void) writeDouble: (double) value;
121 |
122 | - (void) writeBool: (BOOL) value;
123 |
124 | - (void) writeBinary: (NSData *) data;
125 |
126 | - (void) writeFieldStop;
127 |
128 | - (void) writeFieldEnd;
129 |
130 | - (void) writeMapBeginWithKeyType: (int) keyType
131 | valueType: (int) valueType
132 | size: (int) size;
133 | - (void) writeMapEnd;
134 |
135 |
136 | - (void) writeSetBeginWithElementType: (int) elementType
137 | size: (int) size;
138 | - (void) writeSetEnd;
139 |
140 |
141 | - (void) writeListBeginWithElementType: (int) elementType
142 | size: (int) size;
143 |
144 | - (void) writeListEnd;
145 |
146 |
147 | @end
148 |
149 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/Thrift/protocol/TProtocolException.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import "TException.h"
21 |
22 | @interface TProtocolException : TException {
23 | }
24 |
25 | @end
26 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/Thrift/protocol/TProtocolException.m:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import "TProtocolException.h"
21 |
22 | @implementation TProtocolException
23 | @end
24 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/Thrift/protocol/TProtocolFactory.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import
21 | #import "TProtocol.h"
22 | #import "TTransport.h"
23 |
24 |
25 | @protocol TProtocolFactory
26 |
27 | - (id ) newProtocolOnTransport: (id ) transport;
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/Thrift/protocol/TProtocolUtil.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import "TProtocol.h"
21 | #import "TTransport.h"
22 |
23 | @interface TProtocolUtil : NSObject {
24 |
25 | }
26 |
27 | + (void) skipType: (int) type onProtocol: (id ) protocol;
28 |
29 | @end;
30 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/Thrift/protocol/TProtocolUtil.m:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import "TProtocolUtil.h"
21 |
22 | @implementation TProtocolUtil
23 |
24 | + (void) skipType: (int) type onProtocol: (id ) protocol
25 | {
26 | switch (type) {
27 | case TType_BOOL:
28 | [protocol readBool];
29 | break;
30 | case TType_BYTE:
31 | [protocol readByte];
32 | break;
33 | case TType_I16:
34 | [protocol readI16];
35 | break;
36 | case TType_I32:
37 | [protocol readI32];
38 | break;
39 | case TType_I64:
40 | [protocol readI64];
41 | break;
42 | case TType_DOUBLE:
43 | [protocol readDouble];
44 | break;
45 | case TType_STRING:
46 | [protocol readString];
47 | break;
48 | case TType_STRUCT:
49 | [protocol readStructBeginReturningName: NULL];
50 | while (true) {
51 | int fieldType;
52 | [protocol readFieldBeginReturningName: nil type: &fieldType fieldID: nil];
53 | if (fieldType == TType_STOP) {
54 | break;
55 | }
56 | [TProtocolUtil skipType: fieldType onProtocol: protocol];
57 | [protocol readFieldEnd];
58 | }
59 | [protocol readStructEnd];
60 | break;
61 | case TType_MAP:
62 | {
63 | int keyType;
64 | int valueType;
65 | int size;
66 | [protocol readMapBeginReturningKeyType: &keyType valueType: &valueType size: &size];
67 | int i;
68 | for (i = 0; i < size; i++) {
69 | [TProtocolUtil skipType: keyType onProtocol: protocol];
70 | [TProtocolUtil skipType: valueType onProtocol: protocol];
71 | }
72 | [protocol readMapEnd];
73 | }
74 | break;
75 | case TType_SET:
76 | {
77 | int elemType;
78 | int size;
79 | [protocol readSetBeginReturningElementType: &elemType size: &size];
80 | int i;
81 | for (i = 0; i < size; i++) {
82 | [TProtocolUtil skipType: elemType onProtocol: protocol];
83 | }
84 | [protocol readSetEnd];
85 | }
86 | break;
87 | case TType_LIST:
88 | {
89 | int elemType;
90 | int size;
91 | [protocol readListBeginReturningElementType: &elemType size: &size];
92 | int i;
93 | for (i = 0; i < size; i++) {
94 | [TProtocolUtil skipType: elemType onProtocol: protocol];
95 | }
96 | [protocol readListEnd];
97 | }
98 | break;
99 | default:
100 | return;
101 | }
102 | }
103 |
104 | @end
105 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/Thrift/transport/THTTPClient.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import
21 | #import "TTransport.h"
22 |
23 | typedef void (^ProgressBlock)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite);
24 |
25 | @interface THTTPClient : NSObject {
26 | NSURL * mURL;
27 | NSMutableURLRequest * mRequest;
28 | NSMutableData * mRequestData;
29 | NSData * mResponseData;
30 | int mResponseDataOffset;
31 | NSString * mUserAgent;
32 | int mTimeout;
33 | }
34 |
35 | @property (nonatomic,copy) ProgressBlock uploadBlock;
36 | @property (nonatomic,copy) ProgressBlock downloadBlock;
37 |
38 | - (id) initWithURL: (NSURL *) aURL;
39 |
40 | - (id) initWithURL: (NSURL *) aURL
41 | userAgent: (NSString *) userAgent
42 | timeout: (int) timeout;
43 |
44 | - (void) setURL: (NSURL *) aURL;
45 |
46 | - (void) cancel;
47 |
48 | @end
49 |
50 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/Thrift/transport/TMemoryBuffer.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import
21 | #import "TTransport.h"
22 |
23 | @interface TMemoryBuffer : NSObject {
24 | NSMutableData *mBuffer;
25 | NSUInteger mOffset;
26 | }
27 | - (id)initWithData:(NSData *)data;
28 | - (NSData *)getBuffer;
29 | @end
30 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/Thrift/transport/TMemoryBuffer.m:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import "TMemoryBuffer.h"
21 | #import "TTransportException.h"
22 | #import "TObjective-C.h"
23 |
24 | #define GARBAGE_BUFFER_SIZE 4096 // 4KiB
25 |
26 | @implementation TMemoryBuffer
27 | - (id)init {
28 | if (self = [super init]) {
29 | mBuffer = [[NSMutableData alloc] init];
30 | mOffset = 0;
31 | }
32 | return self;
33 | }
34 |
35 | - (id)initWithData:(NSData *)data {
36 | if (self = [super init]) {
37 | mBuffer = [data mutableCopy];
38 | mOffset = 0;
39 | }
40 | return self;
41 | }
42 |
43 | - (int)readAll:(uint8_t *)buf offset:(int)off length:(int)len {
44 | if ((int)([mBuffer length] - mOffset) < len) {
45 | @throw [TTransportException exceptionWithReason:@"Not enough bytes remain in buffer"];
46 | }
47 | [mBuffer getBytes:buf range:NSMakeRange(mOffset, len)];
48 | mOffset += len;
49 | if (mOffset >= GARBAGE_BUFFER_SIZE) {
50 | [mBuffer replaceBytesInRange:NSMakeRange(0, mOffset) withBytes:NULL length:0];
51 | mOffset = 0;
52 | }
53 | return len;
54 | }
55 |
56 | - (void)write:(const uint8_t *)data offset:(unsigned int)offset length:(unsigned int)length {
57 | [mBuffer appendBytes:data+offset length:length];
58 | }
59 |
60 | - (void)flush {
61 | // noop
62 | }
63 |
64 | - (NSData *)getBuffer {
65 | return [[mBuffer copy] autorelease_stub];
66 | }
67 |
68 | - (void)dealloc {
69 | [mBuffer release_stub];
70 | [super dealloc_stub];
71 | }
72 |
73 | - (void)cancel {
74 | // noop
75 | }
76 |
77 | - (void)setUploadProgressBlock:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block {
78 | // noop
79 | }
80 |
81 | - (void)setDownloadProgressBlock:(void (^)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))block {
82 | // noop
83 | }
84 |
85 | @end
86 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/Thrift/transport/TTransport.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | @protocol TTransport
21 |
22 | /**
23 | * Guarantees that all of len bytes are read
24 | *
25 | * @param buf Buffer to read into
26 | * @param off Index in buffer to start storing bytes at
27 | * @param len Maximum number of bytes to read
28 | * @return The number of bytes actually read, which must be equal to len
29 | * @throws TTransportException if there was an error reading data
30 | */
31 | - (int) readAll: (uint8_t *) buf offset: (int) off length: (int) len;
32 |
33 | - (void) write: (const uint8_t *) data offset: (unsigned int) offset length: (unsigned int) length;
34 |
35 | - (void) flush;
36 |
37 | - (void) cancel;
38 |
39 | - (void)setUploadProgressBlock:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block;
40 |
41 | - (void)setDownloadProgressBlock:(void (^)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))block;
42 |
43 | @end
44 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/Thrift/transport/TTransportException.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import "TException.h"
21 |
22 | @interface TTransportException : TException {
23 | }
24 |
25 | + (id) exceptionWithReason: (NSString *) reason
26 | error: (NSError *) error;
27 |
28 | + (id) exceptionWithReason: (NSString *) reason;
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/Thrift/transport/TTransportException.m:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import "TTransportException.h"
21 | #import "TObjective-C.h"
22 |
23 | @implementation TTransportException
24 |
25 | + (id) exceptionWithReason: (NSString *) reason
26 | error: (NSError *) error
27 | {
28 | NSDictionary * userInfo = nil;
29 | if (error != nil) {
30 | userInfo = [NSDictionary dictionaryWithObject: error forKey: @"error"];
31 | }
32 |
33 | return [super exceptionWithName: @"TTransportException"
34 | reason: reason
35 | userInfo: userInfo];
36 | }
37 |
38 |
39 | + (id) exceptionWithReason: (NSString *) reason
40 | {
41 | return [self exceptionWithReason: reason error: nil];
42 | }
43 |
44 | @end
45 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/cocoa-oauth/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2011 TweetDeck Inc. All rights reserved.
2 |
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions are met:
5 |
6 | 1. Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 |
9 | 2. 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 |
13 | THIS SOFTWARE IS PROVIDED BY TWEETDECK INC. ``AS IS'' AND ANY EXPRESS OR
14 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
15 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
16 | EVENT SHALL TWEETDECK INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
17 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 |
24 | The views and conclusions contained in the software and documentation are
25 | those of the authors and should not be interpreted as representing official
26 | policies, either expressed or implied, of TweetDeck Inc.
27 |
--------------------------------------------------------------------------------
/EvernoteSDK/3rdParty/cocoa-oauth/NSData+ENBase64.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSData+ENBase64.h
3 | // base64
4 | //
5 | // Created by Matt Gallagher on 2009/06/03.
6 | // Copyright 2009 Matt Gallagher. All rights reserved.
7 | //
8 | // This software is provided 'as-is', without any express or implied
9 | // warranty. In no event will the authors be held liable for any damages
10 | // arising from the use of this software. Permission is granted to anyone to
11 | // use this software for any purpose, including commercial applications, and to
12 | // alter it and redistribute it freely, subject to the following restrictions:
13 | //
14 | // 1. The origin of this software must not be misrepresented; you must not
15 | // claim that you wrote the original software. If you use this software
16 | // in a product, an acknowledgment in the product documentation would be
17 | // appreciated but is not required.
18 | // 2. Altered source versions must be plainly marked as such, and must not be
19 | // misrepresented as being the original software.
20 | // 3. This notice may not be removed or altered from any source
21 | // distribution.
22 | //
23 |
24 | #import
25 |
26 | void *NewBase64Decode(
27 | const char *inputBuffer,
28 | size_t length,
29 | size_t *outputLength);
30 |
31 | char *NewBase64Encode(
32 | const void *inputBuffer,
33 | size_t length,
34 | bool separateLines,
35 | size_t *outputLength);
36 |
37 | @interface NSData (ENBase64)
38 |
39 | + (NSData *)dataFromBase64String:(NSString *)aString;
40 | - (NSString *)base64EncodedString;
41 |
42 | @end
43 |
--------------------------------------------------------------------------------
/EvernoteSDK/EDAM/EDAM.h:
--------------------------------------------------------------------------------
1 | #import "EDAMLimits.h"
2 | #import "EDAMNoteStore.h"
3 | #import "EDAMTypes.h"
4 | #import "EDAMUserStore.h"
5 | #import "EDAMErrors.h"
6 |
--------------------------------------------------------------------------------
/EvernoteSDK/EDAMNoteStoreClient+Utilities.h:
--------------------------------------------------------------------------------
1 | /*
2 | * EDAMNoteStoreClient+Utilities.h
3 | * evernote-sdk-ios
4 | *
5 | * Copyright 2012 Evernote Corporation
6 | * All rights reserved.
7 | *
8 | * Redistribution and use in source and binary forms, with or without modification,
9 | * are permitted provided that the following conditions are met:
10 | *
11 | * 1. Redistributions of source code must retain the above copyright notice, this
12 | * list of conditions and the following disclaimer.
13 | *
14 | * 2. Redistributions in binary form must reproduce the above copyright notice,
15 | * this list of conditions and the following disclaimer in the documentation
16 | * and/or other materials provided with the distribution.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | #import "EDAM.h"
31 |
32 | /** Extra functions on top of the thrift generated code.
33 | */
34 | @interface EDAMNoteStoreClient (Utilities)
35 |
36 | /** Cancel an operation on the note store.
37 |
38 | This lets you cancel the first operation in the notestore queue.
39 | */
40 | - (void)cancel;
41 |
42 | /**
43 | Sets a callback to be called when an undetermined number of bytes have been uploaded to the server.
44 |
45 | @param block A block object to be called when an undetermined number of bytes have been uploaded to the server. This block has no return value and takes three arguments: the number of bytes written since the last time the upload progress block was called, the total bytes written, and the total bytes expected to be written during the request, as initially determined by the length of the HTTP body. This block may be called multiple times, and will execute on the main thread.
46 | */
47 | - (void)setUploadProgressBlock:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block;
48 |
49 | /**
50 | Sets a callback to be called when an undetermined number of bytes have been downloaded from the server.
51 |
52 | @param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the main thread.
53 | */
54 | - (void)setDownloadProgressBlock:(void (^)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))block;
55 |
56 | @end
57 |
--------------------------------------------------------------------------------
/EvernoteSDK/EDAMNoteStoreClient+Utilities.m:
--------------------------------------------------------------------------------
1 | /*
2 | * EDAMNoteStoreClient+Utilities.m
3 | * evernote-sdk-ios
4 | *
5 | * Copyright 2012 Evernote Corporation
6 | * All rights reserved.
7 | *
8 | * Redistribution and use in source and binary forms, with or without modification,
9 | * are permitted provided that the following conditions are met:
10 | *
11 | * 1. Redistributions of source code must retain the above copyright notice, this
12 | * list of conditions and the following disclaimer.
13 | *
14 | * 2. Redistributions in binary form must reproduce the above copyright notice,
15 | * this list of conditions and the following disclaimer in the documentation
16 | * and/or other materials provided with the distribution.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | #import "EDAMNoteStoreClient+Utilities.h"
31 |
32 | @implementation EDAMNoteStoreClient (Utilities)
33 |
34 | - (void)cancel {
35 | [[outProtocol transport] cancel];
36 | }
37 |
38 | - (void)setUploadProgressBlock:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block {
39 | [[outProtocol transport] setUploadProgressBlock:block];
40 | }
41 |
42 | - (void)setDownloadProgressBlock:(void (^)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))block {
43 | [[outProtocol transport] setDownloadProgressBlock:block];
44 | }
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/EvernoteSDK/ENConstants.h:
--------------------------------------------------------------------------------
1 | /*
2 | * ENConstants.h
3 | * evernote-sdk-ios
4 | *
5 | * Copyright 2012 Evernote Corporation
6 | * All rights reserved.
7 | *
8 | * Redistribution and use in source and binary forms, with or without modification,
9 | * are permitted provided that the following conditions are met:
10 | *
11 | * 1. Redistributions of source code must retain the above copyright notice, this
12 | * list of conditions and the following disclaimer.
13 | *
14 | * 2. Redistributions in binary form must reproduce the above copyright notice,
15 | * this list of conditions and the following disclaimer in the documentation
16 | * and/or other materials provided with the distribution.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 |
31 | #import
32 |
33 | @interface ENConstants : NSObject
34 |
35 | FOUNDATION_EXPORT NSString * const ENBootstrapProfileNameChina;
36 | FOUNDATION_EXPORT NSString * const ENBootstrapProfileNameInternational;
37 |
38 | FOUNDATION_EXPORT NSString * const BootstrapServerBaseURLStringCN;
39 | FOUNDATION_EXPORT NSString * const BootstrapServerBaseURLStringUS;
40 |
41 | FOUNDATION_EXPORT NSString * const kBootstrapServerBaseURLStringUS;
42 | FOUNDATION_EXPORT NSString * const kBootstrapServerBaseURLStringCN;
43 | FOUNDATION_EXPORT NSString * const BootstrapServerBaseURLStringSandbox;
44 |
45 | FOUNDATION_EXPORT NSString * const BusinessHostNameSuffix;
46 |
47 | FOUNDATION_EXPORT NSString * const ENMLTagCrypt;
48 | FOUNDATION_EXPORT NSString * const ENMLTagTodo;
49 | FOUNDATION_EXPORT NSString * const ENMLTagNote;
50 | FOUNDATION_EXPORT NSString * const ENHTMLClassInkSlice;
51 | FOUNDATION_EXPORT NSString * const ENHTMLClassInkContainer;
52 | FOUNDATION_EXPORT NSString * const ENHTMLClassIgnore;
53 | FOUNDATION_EXPORT NSString * const ENHTMLClassAttachment;
54 |
55 | FOUNDATION_EXPORT NSString * const ENHTMLAttributeMime;
56 |
57 | FOUNDATION_EXPORT NSString * const ENHTMLEncryptionAttributeHint;
58 | FOUNDATION_EXPORT NSString * const ENHTMLEncryptionAttributeCipher;
59 |
60 | FOUNDATION_EXPORT NSString * const ENMIMETypeOctetStream;
61 | FOUNDATION_EXPORT NSString * const ENMLTagMedia;
62 |
63 | @end
64 |
--------------------------------------------------------------------------------
/EvernoteSDK/ENConstants.m:
--------------------------------------------------------------------------------
1 | /*
2 | * ENConstants.m
3 | * evernote-sdk-ios
4 | *
5 | * Copyright 2012 Evernote Corporation
6 | * All rights reserved.
7 | *
8 | * Redistribution and use in source and binary forms, with or without modification,
9 | * are permitted provided that the following conditions are met:
10 | *
11 | * 1. Redistributions of source code must retain the above copyright notice, this
12 | * list of conditions and the following disclaimer.
13 | *
14 | * 2. Redistributions in binary form must reproduce the above copyright notice,
15 | * this list of conditions and the following disclaimer in the documentation
16 | * and/or other materials provided with the distribution.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | #import "ENConstants.h"
31 |
32 | @implementation ENConstants
33 |
34 | NSString * const ENBootstrapProfileNameChina = @"Evernote-China";
35 | NSString * const ENBootstrapProfileNameInternational = @"Evernote";
36 |
37 | NSString * const BootstrapServerBaseURLStringCN = @"app.yinxiang.com";
38 | NSString * const BootstrapServerBaseURLStringUS = @"www.evernote.com";
39 | NSString * const BootstrapServerBaseURLStringSandbox = @"sandbox.evernote.com";
40 |
41 | NSString * const kBootstrapServerBaseURLStringUS = @"en_US";
42 | NSString * const kBootstrapServerBaseURLStringCN = @"zh";
43 |
44 | NSString * const BusinessHostNameSuffix = @"-business";
45 |
46 | NSString * const ENMLTagCrypt = @"en-crypt";
47 | NSString * const ENMLTagTodo = @"en-todo";
48 | NSString * const ENMLTagNote = @"en-note";
49 | NSString * const ENHTMLClassInkSlice = @"en-ink-slice";
50 | NSString * const ENHTMLClassInkContainer = @"en-ink-media";
51 |
52 | NSString * const ENHTMLClassIgnore = @"en-ignore";
53 | NSString * const ENHTMLClassAttachment = @"en-attachment";
54 |
55 | NSString * const ENHTMLAttributeMime = @"x-evernote-mime";
56 |
57 | NSString * const ENHTMLEncryptionAttributeHint = @"title";
58 | NSString * const ENHTMLEncryptionAttributeCipher = @"alt";
59 |
60 | NSString * const ENMIMETypeOctetStream = @"application/octet-stream";
61 | NSString * const ENMLTagMedia = @"en-media";
62 |
63 | @end
64 |
--------------------------------------------------------------------------------
/EvernoteSDK/EvernoteSDK-Mac-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | FMWK
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1
25 | NSHumanReadableCopyright
26 | Copyright © 2013 Evernote Corp. All rights reserved.
27 | NSPrincipalClass
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/EvernoteSDK/EvernoteSDK-Mac-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header for all source files of the 'EvernoteSDK-Mac' target in the 'EvernoteSDK-Mac' project
3 | //
4 |
5 | #ifdef __OBJC__
6 | #import
7 | #endif
8 |
--------------------------------------------------------------------------------
/EvernoteSDK/EvernoteSDK-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header for all source files of the 'evernote-sdk-ios' target in the 'evernote-sdk-ios' project
3 | //
4 |
5 | #ifdef __OBJC__
6 | #import
7 | #endif
8 |
--------------------------------------------------------------------------------
/EvernoteSDK/EvernoteSDK.h:
--------------------------------------------------------------------------------
1 | /*
2 | * EvernoteSDK.h
3 | * evernote-sdk-ios
4 | *
5 | * Copyright 2012 Evernote Corporation
6 | * All rights reserved.
7 | *
8 | * Redistribution and use in source and binary forms, with or without modification,
9 | * are permitted provided that the following conditions are met:
10 | *
11 | * 1. Redistributions of source code must retain the above copyright notice, this
12 | * list of conditions and the following disclaimer.
13 | *
14 | * 2. Redistributions in binary form must reproduce the above copyright notice,
15 | * this list of conditions and the following disclaimer in the documentation
16 | * and/or other materials provided with the distribution.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | #import "EvernoteNoteStore.h"
31 | #import "EvernoteSession.h"
32 | #import "EvernoteUserStore.h"
33 | #import "EvernoteNoteStore+Extras.h"
34 | #import "EvernoteUserStore+Extras.h"
35 | #import "ENConstants.h"
36 |
37 | // For other application-level error codes, see EDAMErrorCode in EDAMErrors.h.
38 | typedef enum {
39 | EvernoteSDKErrorCode_TRANSPORT_ERROR = -3000,
40 | EvernoteSDKErrorCode_NO_VIEWCONTROLLER = -3001,
41 | } EvernoteSDKErrorCode;
42 |
43 | // Evernote SDK NSError error domain.
44 | extern NSString *const EvernoteSDKErrorDomain;
45 |
46 |
--------------------------------------------------------------------------------
/EvernoteSDK/EvernoteSDK.m:
--------------------------------------------------------------------------------
1 | /*
2 | * EvernoteSDK.m
3 | * evernote-sdk-ios
4 | *
5 | * Copyright 2012 Evernote Corporation
6 | * All rights reserved.
7 | *
8 | * Redistribution and use in source and binary forms, with or without modification,
9 | * are permitted provided that the following conditions are met:
10 | *
11 | * 1. Redistributions of source code must retain the above copyright notice, this
12 | * list of conditions and the following disclaimer.
13 | *
14 | * 2. Redistributions in binary form must reproduce the above copyright notice,
15 | * this list of conditions and the following disclaimer in the documentation
16 | * and/or other materials provided with the distribution.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 | #import "EvernoteSDK.h"
30 |
31 | #if !__has_feature(objc_arc)
32 | #error Evernote iOS SDK must be built with ARC.
33 | // You can turn on ARC for only Evertnote SDK files by adding -fobjc-arc to the build phase for each of its files.
34 | #endif
35 |
36 | NSString *const EvernoteSDKErrorDomain = @"com.evernote.sdk";
37 |
--------------------------------------------------------------------------------
/EvernoteSDK/EvernoteUserStore+Extras.h:
--------------------------------------------------------------------------------
1 | /*
2 | * EvernoteUserStore+Extras.h
3 | * evernote-sdk-ios
4 | *
5 | * Copyright 2012 Evernote Corporation
6 | * All rights reserved.
7 | *
8 | * Redistribution and use in source and binary forms, with or without modification,
9 | * are permitted provided that the following conditions are met:
10 | *
11 | * 1. Redistributions of source code must retain the above copyright notice, this
12 | * list of conditions and the following disclaimer.
13 | *
14 | * 2. Redistributions in binary form must reproduce the above copyright notice,
15 | * this list of conditions and the following disclaimer in the documentation
16 | * and/or other materials provided with the distribution.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | #import "EvernoteUserStore.h"
31 |
32 | /** Some utility functions for the Evernote UserStore, which makes it easier to use Business API's.
33 | */
34 | @interface EvernoteUserStore (Extras)
35 |
36 | /** Check if the user is a member of a business premium account.
37 |
38 | @param success Success completion block.
39 | @param failure Failure completion block.
40 | */
41 | - (void)isUserMemberOfBusinessWithSuccess:(void(^)(BOOL isMemberOfBusiness))success
42 | failure:(void(^)(NSError *error))failure;
43 |
44 | @end
45 |
--------------------------------------------------------------------------------
/EvernoteSDK/EvernoteUserStore+Extras.m:
--------------------------------------------------------------------------------
1 | /*
2 | * EvernoteUserStore+Extras.m
3 | * evernote-sdk-ios
4 | *
5 | * Copyright 2012 Evernote Corporation
6 | * All rights reserved.
7 | *
8 | * Redistribution and use in source and binary forms, with or without modification,
9 | * are permitted provided that the following conditions are met:
10 | *
11 | * 1. Redistributions of source code must retain the above copyright notice, this
12 | * list of conditions and the following disclaimer.
13 | *
14 | * 2. Redistributions in binary form must reproduce the above copyright notice,
15 | * this list of conditions and the following disclaimer in the documentation
16 | * and/or other materials provided with the distribution.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | #import "EvernoteUserStore+Extras.h"
31 |
32 | @implementation EvernoteUserStore (Extras)
33 |
34 | - (void)isUserMemberOfBusinessWithSuccess:(void(^)(BOOL isMemberOfBusiness))success
35 | failure:(void(^)(NSError *error))failure {
36 | [self getUserWithSuccess:^(EDAMUser *user) {
37 | if([[user accounting] businessIdIsSet]) {
38 | success(YES);
39 | }
40 | else {
41 | success(NO);
42 | }
43 | } failure:failure];
44 | }
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/EvernoteSDK/Utilities/ENMLUtility.h:
--------------------------------------------------------------------------------
1 | /*
2 | * ENMLUtility.h
3 | * evernote-sdk-ios
4 | *
5 | * Copyright 2012 Evernote Corporation
6 | * All rights reserved.
7 | *
8 | * Redistribution and use in source and binary forms, with or without modification,
9 | * are permitted provided that the following conditions are met:
10 | *
11 | * 1. Redistributions of source code must retain the above copyright notice, this
12 | * list of conditions and the following disclaimer.
13 | *
14 | * 2. Redistributions in binary form must reproduce the above copyright notice,
15 | * this list of conditions and the following disclaimer in the documentation
16 | * and/or other materials provided with the distribution.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | #import
31 | #import "KSHTMLWriter.h"
32 |
33 | /** Utility methods to work with ENML.
34 | */
35 | @interface ENMLUtility : NSObject
36 |
37 | /** Utility function to create an enml media tag.
38 |
39 | @param dataHash The md5 hash of the data
40 | @param mime The mime type of the data
41 | */
42 | + (NSString*) mediaTagWithDataHash:(NSData *)dataHash
43 | mime:(NSString *)mime;
44 |
45 |
46 | /** Utility function to convert ENML to HTML.
47 |
48 | @param enmlContent The enml content of the note
49 | @param block The completion block that will be called on completion
50 | */
51 | - (void) convertENMLToHTML:(NSString*)enmlContent completionBlock:(void(^)(NSString* html, NSError *error))block;
52 |
53 |
54 | /** Utility function to convert ENML to HTML.
55 |
56 | @param enmlContent The enml content of the note
57 | @param resources The resources array
58 | @param block The completion block that will be called on completion
59 | */
60 | - (void) convertENMLToHTML:(NSString*)enmlContent withResources:(NSArray*)resources completionBlock:(void(^)(NSString* html, NSError *error))block;
61 |
62 | @end
63 |
--------------------------------------------------------------------------------
/EvernoteSDK/Utilities/NSData+EvernoteSDK.h:
--------------------------------------------------------------------------------
1 | /*
2 | * NSData+EvernoteSDK.h
3 | * evernote-sdk-ios
4 | *
5 | * Copyright 2012 Evernote Corporation
6 | * All rights reserved.
7 | *
8 | * Redistribution and use in source and binary forms, with or without modification,
9 | * are permitted provided that the following conditions are met:
10 | *
11 | * 1. Redistributions of source code must retain the above copyright notice, this
12 | * list of conditions and the following disclaimer.
13 | *
14 | * 2. Redistributions in binary form must reproduce the above copyright notice,
15 | * this list of conditions and the following disclaimer in the documentation
16 | * and/or other materials provided with the distribution.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | #import
31 |
32 | /** Extra methods on `NSData` to deal with Evernote API data.
33 | */
34 | @interface NSData (EvernoteSDK)
35 |
36 | /** MD5 hash of the receiver
37 |
38 | @returns The MD5 hash
39 | */
40 | - (NSData *) enmd5;
41 |
42 | /** hex representation of data (used in ENML media)
43 |
44 | @returns The hex representation in lower case
45 | */
46 | - (NSString *) enlowercaseHexDigits;
47 |
48 | + (NSData *) endataWithHexDigits: (NSString *) hexDigits;
49 |
50 | @end
51 |
--------------------------------------------------------------------------------
/EvernoteSDK/Utilities/NSData+EvernoteSDK.m:
--------------------------------------------------------------------------------
1 | /*
2 | * NSData+EvernoteSDK.m
3 | * evernote-sdk-ios
4 | *
5 | * Copyright 2012 Evernote Corporation
6 | * All rights reserved.
7 | *
8 | * Redistribution and use in source and binary forms, with or without modification,
9 | * are permitted provided that the following conditions are met:
10 | *
11 | * 1. Redistributions of source code must retain the above copyright notice, this
12 | * list of conditions and the following disclaimer.
13 | *
14 | * 2. Redistributions in binary form must reproduce the above copyright notice,
15 | * this list of conditions and the following disclaimer in the documentation
16 | * and/or other materials provided with the distribution.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | #import "NSData+EvernoteSDK.h"
31 | #import
32 |
33 | @implementation NSData (EvernoteSDK)
34 |
35 | - (NSData *) enmd5
36 | {
37 | unsigned char md5Buffer[CC_MD5_DIGEST_LENGTH];
38 | CC_MD5(self.bytes, (CC_LONG)self.length, md5Buffer);
39 | NSMutableData * md5Data = [NSMutableData dataWithBytes:md5Buffer length: CC_MD5_DIGEST_LENGTH];
40 | return md5Data;
41 | }
42 |
43 | - (NSString *) enlowercaseHexDigits
44 | {
45 | unsigned const char * bytes = [self bytes];
46 |
47 | NSMutableString * hex = [NSMutableString stringWithCapacity: [self length] * 2];
48 |
49 | NSUInteger i;
50 | for (i = 0; i < [self length]; i++) {
51 | [hex appendFormat: @"%.2x", bytes[i]];
52 | }
53 |
54 | return hex;
55 | }
56 |
57 | + (NSData *) endataWithHexDigits: (NSString *) hexDigits
58 | {
59 | if (!hexDigits) {
60 | return nil;
61 | }
62 | if ([hexDigits length] % 2 != 0) {
63 | return nil;
64 | }
65 |
66 | NSMutableData * data = [NSMutableData dataWithLength: [hexDigits length] / 2];
67 |
68 | const char * sourceBytes = [hexDigits cStringUsingEncoding: NSASCIIStringEncoding];
69 | unsigned char * bytes = [data mutableBytes];
70 |
71 | const char * pos = sourceBytes;
72 | for (NSUInteger count = 0; count < [hexDigits length] / 2; count++) {
73 | sscanf(pos, "%2hhx", &bytes[count]);
74 | pos += 2;
75 | }
76 |
77 | return [NSData dataWithData:data];
78 | }
79 |
80 | @end
81 |
--------------------------------------------------------------------------------
/EvernoteSDK/Utilities/NSDataBase64Additions.h:
--------------------------------------------------------------------------------
1 | // Created by khammond on Mon Oct 29 2001.
2 | // Formatted by Timothy Hatcher on Sun Jul 4 2004.
3 | // Copyright (c) 2001 Kyle Hammond. All rights reserved.
4 | // Original development by Dave Winer.
5 |
6 | @interface NSData (NSDataBase64Additions)
7 | + (NSData *) endataWithBase64EncodedString:(NSString *) string;
8 | - (id) initWithBase64EncodedString:(NSString *) string;
9 |
10 | - (NSString *) enbase64Encoding;
11 | - (NSString *) enbase64EncodingWithLineLength:(unsigned int) lineLength;
12 | @end
13 |
--------------------------------------------------------------------------------
/EvernoteSDK/Utilities/NSDate+EDAMAdditions.h:
--------------------------------------------------------------------------------
1 | /*
2 | * NSDate+EDAMAdditions.h
3 | * evernote-sdk-ios
4 | *
5 | * Copyright 2012 Evernote Corporation
6 | * All rights reserved.
7 | *
8 | * Redistribution and use in source and binary forms, with or without modification,
9 | * are permitted provided that the following conditions are met:
10 | *
11 | * 1. Redistributions of source code must retain the above copyright notice, this
12 | * list of conditions and the following disclaimer.
13 | *
14 | * 2. Redistributions in binary form must reproduce the above copyright notice,
15 | * this list of conditions and the following disclaimer in the documentation
16 | * and/or other materials provided with the distribution.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | #import
31 |
32 | /** Extra methods on `NSDate` to deal with Evernote API time stamps.
33 | */
34 | @interface NSDate (NSDateEDAMAdditions)
35 |
36 | /** Convert an edam timestamp to an NSDate
37 |
38 | @param edamTimestamp The timestamp obtained from an Evernote API data structure.
39 | @return The equivalent NSDate
40 | */
41 | + (NSDate *) endateFromEDAMTimestamp: (int64_t) edamTimestamp;
42 |
43 |
44 | /**
45 | * Convert an NSDate to an edam timestamp
46 | */
47 | - (int64_t) enedamTimestamp;
48 |
49 | @end
50 |
--------------------------------------------------------------------------------
/EvernoteSDK/Utilities/NSDate+EDAMAdditions.m:
--------------------------------------------------------------------------------
1 | /*
2 | * NSDate+EDAMAdditions.m
3 | * evernote-sdk-ios
4 | *
5 | * Copyright 2012 Evernote Corporation
6 | * All rights reserved.
7 | *
8 | * Redistribution and use in source and binary forms, with or without modification,
9 | * are permitted provided that the following conditions are met:
10 | *
11 | * 1. Redistributions of source code must retain the above copyright notice, this
12 | * list of conditions and the following disclaimer.
13 | *
14 | * 2. Redistributions in binary form must reproduce the above copyright notice,
15 | * this list of conditions and the following disclaimer in the documentation
16 | * and/or other materials provided with the distribution.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | #import "NSDate+EDAMAdditions.h"
31 |
32 | @implementation NSDate (EDAMAdditions)
33 |
34 | + (NSDate *) endateFromEDAMTimestamp: (int64_t) edamTimestamp
35 | {
36 | return [NSDate dateWithTimeIntervalSince1970: ((double)edamTimestamp)/1000.0];
37 | }
38 |
39 | - (int64_t) enedamTimestamp
40 | {
41 | return trunc([self timeIntervalSince1970]) * 1000;
42 | }
43 |
44 | @end
45 |
--------------------------------------------------------------------------------
/EvernoteSDK/internal/Bridge/ENApplicationBridge.h:
--------------------------------------------------------------------------------
1 | //
2 | // ENApplicationBridge.h
3 | // EvernoteClipper
4 | //
5 | // Created by Evernote Corporation on 5/27/09.
6 | // Copyright 2009 Evernote Corporation. All rights reserved.
7 | //
8 |
9 | #import
10 | #if TARGET_OS_IPHONE
11 | # import
12 | #else
13 | # import
14 | #endif
15 |
16 | #import "ENApplicationRequest.h"
17 | #import "ENLinkNotebookRequest.h"
18 | #import "ENNewNoteRequest.h"
19 | #import "ENNoteViewRequest.h"
20 | #import "ENResourceAttachment.h"
21 | #import "ENSearchRequest.h"
22 | #import "ENAuthenticationRequest.h"
23 |
24 | extern NSString * const kEN_ApplicationBridge_EvernoteNotInstalled;
25 | extern NSString * const kEN_ApplicationBridge_InvalidRequestType;
26 |
27 | @interface ENApplicationBridge : NSObject {
28 |
29 | }
30 |
31 | /*!
32 | @function
33 | @abstract <#(description)#>
34 | @discussion <#(description)#>
35 | @param <#(name) (description)#>
36 | @result <#(description)#>
37 | */
38 | + (ENApplicationBridge *) newApplicationBridge;
39 |
40 | /*!
41 | @function
42 | @abstract <#(description)#>
43 | @discussion <#(description)#>
44 | @result Returns YES if Evernote is installed.
45 | */
46 | - (BOOL) isEvernoteInstalled;
47 |
48 | /*!
49 | @function
50 | @abstract <#(description)#>
51 | @discussion Returns an NSURL where the Evernote application can be downloaded from.
52 | On the iPhone this will be a URL that invokes the App Store.
53 | @result
54 | */
55 | - (NSURL *) evernoteDownloadURL;
56 |
57 | /*!
58 | @function
59 | @abstract <#(description)#>
60 | @discussion <#(description)#>
61 | @param <#(name) (description)#>
62 | */
63 | - (void) performRequest:(id)request;
64 |
65 | /*!
66 | @function
67 | @abstract <#(description)#>
68 | @discussion <#(description)#>
69 | @param <#(name) (description)#>
70 | */
71 | - (void) performRequest:(id)request withCallbackURL:(NSURL *)callbackURL;
72 |
73 | @end
74 |
--------------------------------------------------------------------------------
/EvernoteSDK/internal/Bridge/ENApplicationBridge_Private.h:
--------------------------------------------------------------------------------
1 | //
2 | // ENApplicationBridge_Private.h
3 | // Evernote
4 | //
5 | // Created by Steve White on 5/7/10.
6 | // Copyright 2010 Evernote Corporation. All rights reserved.
7 | //
8 |
9 | #import "ENNewNoteRequest.h"
10 | #import "ENResourceAttachment.h"
11 |
12 | extern const uint32_t kEN_ApplicationBridge_DataVersion;
13 |
14 | extern NSString * const kEN_ApplicationBridge_DataVersionKey;
15 | extern NSString * const kEN_ApplicationBridge_CallBackURLKey;
16 | extern NSString * const kEN_ApplicationBridge_RequestIdentifierKey;
17 | extern NSString * const kEN_ApplicationBridge_RequestDataKey;
18 | extern NSString * const kEN_ApplicationBridge_CallerAppNameKey;
19 | extern NSString * const kEN_ApplicationBridge_CallerAppIdentifierKey;
20 | extern NSString * const kEN_ApplicationBridge_ConsumerKey;
21 |
22 | @interface ENResourceAttachment ()
23 | @property (strong, nonatomic) NSString *filepath;
24 | @end
25 |
26 | @interface ENNewNoteRequest ()
27 | - (uint32_t) totalRequestSize;
28 | @end
29 |
--------------------------------------------------------------------------------
/EvernoteSDK/internal/Bridge/ENApplicationRequest.h:
--------------------------------------------------------------------------------
1 | //
2 | // ENApplicationRequest.h
3 | // EvernoteClipper
4 | //
5 | // Created by Evernote Corporation on 5/27/09.
6 | // Copyright 2009 Evernote Corporation. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 |
12 | @protocol ENApplicationRequest
13 | @required
14 | - (NSString *) requestIdentifier;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/EvernoteSDK/internal/Bridge/ENAuthenticationRequest.h:
--------------------------------------------------------------------------------
1 | //
2 | // ENAuthenticationRequest.h
3 | // Evernote
4 | //
5 | // Created by Mustafa Furniturewala on 12/27/12.
6 | // Copyright (c) 2012 Evernote Corporation. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "ENApplicationRequest.h"
11 |
12 | @interface ENAuthenticationRequest : NSObject
13 |
14 | @property (nonatomic,copy) NSString* consumerKey;
15 | @property (nonatomic,copy) NSString* oauthUserAuthorization;
16 | @property (nonatomic,copy) NSString* profileName;
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/EvernoteSDK/internal/Bridge/ENAuthenticationRequest.m:
--------------------------------------------------------------------------------
1 | //
2 | // ENAuthenticationRequest.m
3 | // Evernote
4 | //
5 | // Created by Mustafa Furniturewala on 12/27/12.
6 | // Copyright (c) 2012 Evernote Corporation. All rights reserved.
7 | //
8 |
9 | #import "ENAuthenticationRequest.h"
10 |
11 | static NSString *ENAuthenticationRequestConsumerKeyKey = @"_consumerKey";
12 | static NSString *ENAuthenticationRequestOauthUserAuthorizationKey = @"_oauthUserAuthorization";
13 | static NSString *ENAuthenticationRequestProfileName = @"_profileName";
14 |
15 | @implementation ENAuthenticationRequest
16 |
17 |
18 | - (id) init {
19 | self = [super init];
20 | if (self != nil) {
21 |
22 | }
23 | return self;
24 | }
25 |
26 | - (id) initWithCoder:(NSCoder *)coder {
27 | self = [self init];
28 | if (self != nil) {
29 | self.consumerKey = [coder decodeObjectForKey:ENAuthenticationRequestConsumerKeyKey];
30 | self.oauthUserAuthorization = [coder decodeObjectForKey:ENAuthenticationRequestOauthUserAuthorizationKey];
31 | self.profileName = [coder decodeObjectForKey:ENAuthenticationRequestProfileName];
32 | }
33 | return self;
34 | }
35 |
36 | - (void) encodeWithCoder:(NSCoder *)coder {
37 | [coder encodeObject:_consumerKey forKey:ENAuthenticationRequestConsumerKeyKey];
38 | [coder encodeObject:_oauthUserAuthorization forKey:ENAuthenticationRequestOauthUserAuthorizationKey];
39 | [coder encodeObject:_profileName forKey:ENAuthenticationRequestProfileName];
40 | }
41 |
42 | - (NSString *) requestIdentifier {
43 | return NSStringFromClass([self class]);
44 | }
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/EvernoteSDK/internal/Bridge/ENLinkNotebookRequest.h:
--------------------------------------------------------------------------------
1 | //
2 | // ENLinkNotebookRequest.h
3 | // Evernote
4 | //
5 | // Created by Steve White on 9/14/11.
6 | // Copyright 2011 Evernote Corporation. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "ENApplicationRequest.h"
11 |
12 | @interface ENLinkNotebookRequest : NSObject {
13 | NSString *_shareKey;
14 | NSString *_shardID;
15 | NSString *_name;
16 | NSString *_ownerName;
17 | }
18 |
19 | @property (strong, nonatomic) NSString *shareKey;
20 | @property (strong, nonatomic) NSString *shardID;
21 | @property (strong, nonatomic) NSString *name;
22 | @property (strong, nonatomic) NSString *ownerName;
23 |
24 | + (ENLinkNotebookRequest *) linkNotebookRequestWithName:(NSString *)name
25 | ownerName:(NSString *)ownerName
26 | shareKey:(NSString *)shareKey
27 | shardID:(NSString *)shardID;
28 |
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/EvernoteSDK/internal/Bridge/ENLinkNotebookRequest.m:
--------------------------------------------------------------------------------
1 | //
2 | // ENLinkNotebookRequest.m
3 | // Evernote
4 | //
5 | // Created by Steve White on 9/14/11.
6 | // Copyright 2011 Evernote Corporation. All rights reserved.
7 | //
8 |
9 | #import "ENLinkNotebookRequest.h"
10 |
11 | static int ENLinkNotebookRequestVersion = 0x00010000;
12 | static NSString *ENLinkNotebookRequestVersionKey = @"!version!";
13 | static NSString *ENLinkNotebookRequestOwnerName = @"_ownerName";
14 | static NSString *ENLinkNotebookRequestShareKey = @"_shareKey";
15 | static NSString *ENLinkNotebookRequestShardID = @"_shardID";
16 | static NSString *ENLinkNotebookRequestName = @"_name";
17 |
18 | @implementation ENLinkNotebookRequest
19 |
20 | @synthesize ownerName = _ownerName;
21 | @synthesize shareKey = _shareKey;
22 | @synthesize shardID = _shardID;
23 | @synthesize name = _name;
24 |
25 | + (ENLinkNotebookRequest *) linkNotebookRequestWithName:(NSString *)name
26 | ownerName:(NSString *)ownerName
27 | shareKey:(NSString *)shareKey
28 | shardID:(NSString *)shardID
29 | {
30 | ENLinkNotebookRequest *request = [[ENLinkNotebookRequest alloc] init];
31 | request.shareKey = shareKey;
32 | request.ownerName = ownerName;
33 | request.name = name;
34 | request.shardID = shardID;
35 | return request;
36 | }
37 |
38 | - (id) initWithCoder:(NSCoder *)coder {
39 | self = [super init];
40 | if (self != nil) {
41 | int encodedVersion = [coder decodeIntForKey:ENLinkNotebookRequestVersionKey];
42 | if (encodedVersion != ENLinkNotebookRequestVersion) {
43 | return nil;
44 | }
45 | self.ownerName = [coder decodeObjectForKey:ENLinkNotebookRequestOwnerName];
46 | self.shareKey = [coder decodeObjectForKey:ENLinkNotebookRequestShareKey];
47 | self.name = [coder decodeObjectForKey:ENLinkNotebookRequestName];
48 | self.shardID = [coder decodeObjectForKey:ENLinkNotebookRequestShardID];
49 | }
50 | return self;
51 | }
52 |
53 | - (void) encodeWithCoder:(NSCoder *)coder {
54 | [coder encodeInt:ENLinkNotebookRequestVersion forKey:ENLinkNotebookRequestVersionKey];
55 | [coder encodeObject:_ownerName forKey:ENLinkNotebookRequestOwnerName];
56 | [coder encodeObject:_shareKey forKey:ENLinkNotebookRequestShareKey];
57 | [coder encodeObject:_name forKey:ENLinkNotebookRequestName];
58 | [coder encodeObject:_shardID forKey:ENLinkNotebookRequestShardID];
59 | }
60 |
61 |
62 | - (NSString *) requestIdentifier {
63 | return NSStringFromClass([self class]);
64 | }
65 |
66 | #pragma mark -
67 | #pragma mark
68 | - (NSString *) description {
69 | NSMutableString *ms = [NSMutableString string];
70 |
71 | [ms appendString:NSStringFromClass([self class])];
72 | [ms appendString:@"("];
73 |
74 | [ms appendString: @"name:"];
75 | [ms appendFormat: @"\"%@\"", _name];
76 | [ms appendString: @",ownerName:"];
77 | [ms appendFormat: @"\"%@\"", _ownerName];
78 | [ms appendString: @",shareKey:"];
79 | [ms appendFormat: @"\"%@\"", _shareKey];
80 | [ms appendString: @",shardID:"];
81 | [ms appendFormat: @"\"%@\"", _shardID];
82 |
83 | [ms appendString: @")"];
84 |
85 | return [NSString stringWithString:ms];
86 | }
87 |
88 | @end
89 |
--------------------------------------------------------------------------------
/EvernoteSDK/internal/Bridge/ENNewNoteRequest.h:
--------------------------------------------------------------------------------
1 | //
2 | // ENNewNoteRequest.h
3 | // EvernoteClipper
4 | //
5 | // Created by Evernote Corporation on 5/27/09.
6 | // Copyright 2009 Evernote Corporation. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "ENApplicationRequest.h"
11 | #import "ENResourceAttachment.h"
12 |
13 | @interface ENNewNoteRequest : NSObject {
14 | NSString *mTitle;
15 | NSString *mContent;
16 | NSString *mContentMimeType;
17 | NSURL *mSourceURL;
18 | NSString *mSourceApplication;
19 | NSArray *mTagNames;
20 | NSArray *mResourceAttachments;
21 |
22 | // These are double because CLLocation might not exist on
23 | // the given platform...
24 | double mLatitude;
25 | double mLongitude;
26 | double mAltitude;
27 | }
28 |
29 | @property (strong, nonatomic) NSString *title;
30 | @property (strong, nonatomic) NSString *content;
31 | @property (strong, nonatomic) NSString *contentMimeType;
32 | @property (strong, nonatomic) NSURL *sourceURL;
33 | @property (strong, nonatomic) NSString *sourceApplication;
34 | @property (strong, nonatomic) NSArray *tagNames;
35 | @property (nonatomic, copy) NSString* notebookGUID;
36 | @property (nonatomic,copy) NSString* consumerKey;
37 |
38 | @property (strong, nonatomic) NSArray *resourceAttachments;
39 |
40 | @property (nonatomic) double latitude;
41 | @property (nonatomic) double longitude;
42 | @property (nonatomic) double altitude;
43 |
44 |
45 | - (void) addResourceAttachment:(ENResourceAttachment *)resourceAttachment;
46 | - (void) removeResourceAttachment:(ENResourceAttachment *)resourceAttachment;
47 |
48 | @end
49 |
--------------------------------------------------------------------------------
/EvernoteSDK/internal/Bridge/ENNoteImportRequest.h:
--------------------------------------------------------------------------------
1 | //
2 | // ENNoteImportRequest.h
3 | // Evernote
4 | //
5 | // Created by Steve White on 7/20/12.
6 | // Copyright (c) 2012 Evernote Corporation. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "ENApplicationRequest.h"
11 |
12 | @interface ENNoteImportRequest : NSObject
13 |
14 | @property (strong, nonatomic) NSString *file;
15 | @property (assign, nonatomic) BOOL createNotebook;
16 |
17 | + (ENNoteImportRequest *) importRequestForFile:(NSString *)file;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/EvernoteSDK/internal/Bridge/ENNoteImportRequest.m:
--------------------------------------------------------------------------------
1 | //
2 | // ENNoteImportRequest.m
3 | // Evernote
4 | //
5 | // Created by Steve White on 7/20/12.
6 | // Copyright (c) 2012 Evernote Corporation. All rights reserved.
7 | //
8 |
9 | #import "ENNoteImportRequest.h"
10 |
11 | @implementation ENNoteImportRequest
12 |
13 | @synthesize file = _file;
14 | @synthesize createNotebook = _createNotebook;
15 |
16 | + (ENNoteImportRequest *) importRequestForFile:(NSString *)file {
17 | ENNoteImportRequest *request = [[ENNoteImportRequest alloc] init];
18 | request.file = file;
19 | return request;
20 | }
21 |
22 | - (id) initWithCoder:(NSCoder *)aDecoder {
23 | self = [super init];
24 | if (self != nil) {
25 | self.file = [aDecoder decodeObjectForKey:@"file"];
26 | self.createNotebook = [aDecoder decodeBoolForKey:@"createNotebook"];
27 | }
28 | return self;
29 | }
30 |
31 | - (void) encodeWithCoder:(NSCoder *)aCoder {
32 | [aCoder encodeObject:self.file forKey:@"file"];
33 | [aCoder encodeBool:self.createNotebook forKey:@"createNotebook"];
34 | }
35 |
36 | - (NSString *) requestIdentifier {
37 | return NSStringFromClass([self class]);
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/EvernoteSDK/internal/Bridge/ENNoteViewRequest.h:
--------------------------------------------------------------------------------
1 | //
2 | // ENNoteViewRequest.h
3 | // EvernoteClipper
4 | //
5 | // Created by Evernote Corporation on 5/27/09.
6 | // Copyright 2009 Evernote Corporation. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "ENApplicationRequest.h"
11 |
12 | extern NSString * const ENNoteViewRequestErrorDomain;
13 |
14 | enum {
15 | ENNoteViewRequestUnsupportedCommand = -4000,
16 | ENNoteViewRequestInvalidFormat = -4001,
17 | };
18 |
19 |
20 | @interface ENNoteViewRequest : NSObject {
21 | NSString *_noteID;
22 | NSString *_shardID;
23 | NSUInteger _userID;
24 | NSString *_linkedNotebookID;
25 | NSString *_searchTerms;
26 | }
27 |
28 | @property (assign, nonatomic) NSUInteger userID;
29 | @property (strong, nonatomic) NSString *noteID;
30 | @property (strong, nonatomic) NSString *shardID;
31 | @property (strong, nonatomic) NSString *linkedNotebookID;
32 | @property (strong, nonatomic) NSString *searchTerms;
33 | @property (nonatomic,copy) NSString* consumerKey;
34 |
35 | + (ENNoteViewRequest *) noteViewRequestWithNoteID:(NSString *)noteID;
36 | + (ENNoteViewRequest *) noteViewRequestWithNoteID:(NSString *)noteID searchTerms:(NSString *)searchTerms;
37 | + (ENNoteViewRequest *) noteViewRequestWithURL:(NSURL *)url
38 | error:(NSError **)outError;
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/EvernoteSDK/internal/Bridge/ENResourceAttachment.h:
--------------------------------------------------------------------------------
1 | //
2 | // ENResourceAttachment.h
3 | // EvernoteClipper
4 | //
5 | // Created by Evernote Corporation on 5/27/09.
6 | // Copyright 2009 Evernote Corporation. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "ENApplicationRequest.h"
11 |
12 | @interface ENResourceAttachment : NSObject {
13 | NSData *mResourceData;
14 | NSString *mMimeType;
15 | NSString *mFilename;
16 | NSString *mFilepath;
17 | }
18 |
19 | @property (strong, nonatomic) NSData *resourceData;
20 | @property (strong, nonatomic) NSString *mimeType;
21 | @property (strong, nonatomic) NSString *filename;
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/EvernoteSDK/internal/Bridge/ENResourceAttachment.m:
--------------------------------------------------------------------------------
1 | //
2 | // ENResourceAttachment.m
3 | // EvernoteClipper
4 | //
5 | // Created by Steve White on 5/27/09.
6 | // Copyright 2009 Evernote Corporation. All rights reserved.
7 | //
8 |
9 | #import "ENResourceAttachment.h"
10 | #import "ENApplicationBridge_Private.h"
11 |
12 | static int kEN_ResourceAttachment_Version = 0x00010000;
13 | static NSString *kEN_ResourceAttachment_VersionKey = @"!version!";
14 |
15 | static NSString *kEN_ResourceAttachment_ResourceData = @"mResourceData";
16 | static NSString *kEN_ResourceAttachment_MimeType = @"mMimeType";
17 | static NSString *kEN_ResourceAttachment_Filename = @"mFilename";
18 |
19 |
20 | @implementation ENResourceAttachment
21 |
22 | @synthesize resourceData = mResourceData;
23 | @synthesize mimeType = mMimeType;
24 | @synthesize filename = mFilename;
25 | @synthesize filepath = mFilepath;
26 |
27 | - (id) initWithCoder:(NSCoder *)coder {
28 | self = [super init];
29 | if (self != nil) {
30 | int encodedVersion = [coder decodeIntForKey:kEN_ResourceAttachment_VersionKey];
31 | if (encodedVersion != kEN_ResourceAttachment_Version) {
32 | return nil;
33 | }
34 |
35 | self.resourceData = [coder decodeObjectForKey:kEN_ResourceAttachment_ResourceData];
36 | self.mimeType = [coder decodeObjectForKey:kEN_ResourceAttachment_MimeType];
37 | self.filename = [coder decodeObjectForKey:kEN_ResourceAttachment_Filename];
38 | }
39 | return self;
40 | }
41 |
42 | - (void) encodeWithCoder:(NSCoder *)coder {
43 | [coder encodeInt:kEN_ResourceAttachment_Version forKey:kEN_ResourceAttachment_VersionKey];
44 | [coder encodeObject:self.resourceData forKey:kEN_ResourceAttachment_ResourceData];
45 | [coder encodeObject:self.mimeType forKey:kEN_ResourceAttachment_MimeType];
46 | [coder encodeObject:self.filename forKey:kEN_ResourceAttachment_Filename];
47 | }
48 |
49 |
50 | - (NSString *) requestIdentifier {
51 | return NSStringFromClass([self class]);
52 | }
53 |
54 | #pragma mark -
55 | #pragma mark
56 | - (NSString *) description {
57 | NSMutableString *ms = [NSMutableString string];
58 |
59 | [ms appendString:NSStringFromClass([self class])];
60 | [ms appendString:@"("];
61 |
62 | [ms appendString: @"resourceData:"];
63 | [ms appendFormat: @"%@", self.resourceData];
64 | [ms appendString: @",mimeType:"];
65 | [ms appendFormat: @"\"%@\"", self.mimeType];
66 | [ms appendString: @",filename:"];
67 | [ms appendFormat: @"\"%@\"", self.filename];
68 |
69 | [ms appendString: @")"];
70 |
71 | return [NSString stringWithString:ms];
72 | }
73 | @end
74 |
--------------------------------------------------------------------------------
/EvernoteSDK/internal/Bridge/ENSearchRequest.h:
--------------------------------------------------------------------------------
1 | //
2 | // ENSearchRequest.h
3 | // EvernoteClipper
4 | //
5 | // Created by Evernote Corporation on 5/27/09.
6 | // Copyright 2009 Evernote Corporation. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "ENApplicationRequest.h"
11 |
12 | @interface ENSearchRequest : NSObject {
13 | NSString *mQueryString;
14 | }
15 |
16 | @property (strong, nonatomic) NSString *queryString;
17 |
18 | + (ENSearchRequest *) searchRequestWithQueryString:(NSString *)queryString;
19 | + (ENSearchRequest *) searchRequestForSourceApplication:(NSString *)sourceApplication;
20 |
21 | @end
22 |
--------------------------------------------------------------------------------
/EvernoteSDK/internal/Bridge/ENSearchRequest.m:
--------------------------------------------------------------------------------
1 | //
2 | // ENSearchRequest.m
3 | // EvernoteClipper
4 | //
5 | // Created by Steve White on 5/27/09.
6 | // Copyright 2009 Evernote Corporation. All rights reserved.
7 | //
8 |
9 | #import "ENSearchRequest.h"
10 |
11 | static int kEN_SearchRequest_Version = 0x00010000;
12 | static NSString *kEN_SearchRequest_VersionKey = @"!version!";
13 | static NSString *kEN_SearchRequest_QueryString = @"mQueryString";
14 |
15 | @implementation ENSearchRequest
16 |
17 | @synthesize queryString = mQueryString;
18 |
19 | + (ENSearchRequest *) searchRequestWithQueryString:(NSString *)queryString {
20 | ENSearchRequest *result = [[ENSearchRequest alloc] init];
21 | result.queryString = queryString;
22 | return result;
23 | }
24 |
25 | + (ENSearchRequest *) searchRequestForSourceApplication:(NSString *)sourceApplication {
26 | NSString *queryString = [NSString stringWithFormat:@"sourceApplication:\"%@\"", sourceApplication];
27 | return [self searchRequestWithQueryString:queryString];
28 | }
29 |
30 |
31 | - (id) initWithCoder:(NSCoder *)coder {
32 | self = [super init];
33 | if (self != nil) {
34 | int encodedVersion = [coder decodeIntForKey:kEN_SearchRequest_VersionKey];
35 | if (encodedVersion != kEN_SearchRequest_Version) {
36 | return nil;
37 | }
38 | self.queryString = [coder decodeObjectForKey:kEN_SearchRequest_QueryString];
39 | }
40 | return self;
41 | }
42 |
43 | - (void) encodeWithCoder:(NSCoder *)coder {
44 | [coder encodeInt:kEN_SearchRequest_Version forKey:kEN_SearchRequest_VersionKey];
45 | [coder encodeObject:self.queryString forKey:kEN_SearchRequest_QueryString];
46 | }
47 |
48 |
49 | - (NSString *) requestIdentifier {
50 | return NSStringFromClass([self class]);
51 | }
52 |
53 | #pragma mark -
54 | #pragma mark
55 | - (NSString *) description {
56 | NSMutableString *ms = [NSMutableString string];
57 |
58 | [ms appendString:NSStringFromClass([self class])];
59 | [ms appendString:@"("];
60 |
61 | [ms appendString: @"queryString:"];
62 | [ms appendFormat: @"\"%@\"", self.queryString];
63 |
64 | [ms appendString: @")"];
65 |
66 | return [NSString stringWithString:ms];
67 | }
68 |
69 |
70 | @end
71 |
--------------------------------------------------------------------------------
/EvernoteSDK/internal/Bridge/EvernoteBridge.h:
--------------------------------------------------------------------------------
1 | //
2 | // EvernoteBridge.h
3 | // EvernoteBridge
4 | //
5 | // Created by Steve White on 5/28/09.
6 | // Copyright 2009 Evernote Corporation. All rights reserved.
7 | //
8 | #import "ENApplicationBridge.h"
9 | #import "ENNewNoteRequest.h"
10 | #import "ENNoteViewRequest.h"
11 | #import "ENResourceAttachment.h"
12 | #import "ENSearchRequest.h"
13 |
--------------------------------------------------------------------------------
/EvernoteSDK/internal/ENAPI.h:
--------------------------------------------------------------------------------
1 | /*
2 | * ENAPI.h
3 | * evernote-sdk-ios
4 | *
5 | * Copyright 2012 Evernote Corporation
6 | * All rights reserved.
7 | *
8 | * Redistribution and use in source and binary forms, with or without modification,
9 | * are permitted provided that the following conditions are met:
10 | *
11 | * 1. Redistributions of source code must retain the above copyright notice, this
12 | * list of conditions and the following disclaimer.
13 | *
14 | * 2. Redistributions in binary form must reproduce the above copyright notice,
15 | * this list of conditions and the following disclaimer in the documentation
16 | * and/or other materials provided with the distribution.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 | #import
30 | #import "EDAM.h"
31 | #import "EvernoteSession.h"
32 |
33 | // Superclass for Evernote API classes (EvernoteNoteStore, EvernoteUserStore, etc.)
34 | @interface ENAPI : NSObject
35 |
36 | @property (nonatomic, strong) EvernoteSession *session;
37 | @property (weak, nonatomic, readonly) EDAMNoteStoreClient *noteStore;
38 | @property (weak, nonatomic, readonly) EDAMUserStoreClient *userStore;
39 | @property (weak, nonatomic, readonly) EDAMNoteStoreClient *businessNoteStore;
40 |
41 | - (id)initWithSession:(EvernoteSession *)session;
42 |
43 | // Make an NSError from a given NSException.
44 | - (NSError *)errorFromNSException:(NSException *)exception;
45 |
46 | // asynchronously invoke the given blocks,
47 | // calling back to success/failure on the main threa.
48 | - (void)invokeAsyncBoolBlock:(BOOL(^)())block
49 | success:(void(^)(BOOL val))success
50 | failure:(void(^)(NSError *error))failure;
51 | - (void)invokeAsyncIdBlock:(id(^)())block
52 | success:(void(^)(id))success
53 | failure:(void(^)(NSError *error))failure;
54 | - (void)invokeAsyncInt32Block:(int32_t(^)())block
55 | success:(void(^)(int32_t val))success
56 | failure:(void(^)(NSError *error))failure;
57 | - (void)invokeAsyncVoidBlock:(void(^)())block
58 | success:(void(^)())success
59 | failure:(void(^)(NSError *error))failure;
60 |
61 | @end
62 |
--------------------------------------------------------------------------------
/EvernoteSDK/internal/ENCredentialStore.h:
--------------------------------------------------------------------------------
1 | /*
2 | * ENCredentialStore.h
3 | * evernote-sdk-ios
4 | *
5 | * Copyright 2012 Evernote Corporation
6 | * All rights reserved.
7 | *
8 | * Redistribution and use in source and binary forms, with or without modification,
9 | * are permitted provided that the following conditions are met:
10 | *
11 | * 1. Redistributions of source code must retain the above copyright notice, this
12 | * list of conditions and the following disclaimer.
13 | *
14 | * 2. Redistributions in binary form must reproduce the above copyright notice,
15 | * this list of conditions and the following disclaimer in the documentation
16 | * and/or other materials provided with the distribution.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
31 | #import
32 | #endif
33 |
34 | #import "ENCredentials.h"
35 | #import "EvernoteSession.h"
36 |
37 | // Permanent store of Evernote credentials.
38 | // Credentials are unique per (host,consumer key) tuple.
39 | @interface ENCredentialStore : NSObject
40 |
41 | // Load the credential store from user defaults.
42 | + (ENCredentialStore *)loadCredentials;
43 |
44 | // Save the credential store to user defaults.
45 | - (void)save;
46 |
47 | // Delete the credential store from user defaults.
48 | // Leaves the keychain intact.
49 | - (void)delete;
50 |
51 | // Add credentials to the store.
52 | // Also saves the authentication token to the keychain.
53 | - (void)addCredentials:(ENCredentials *)credentials;
54 |
55 | // Look up the credentials for the given host.
56 | - (ENCredentials *)credentialsForHost:(NSString *)host;
57 |
58 | // Remove credentials from the store.
59 | // Also deletes the credentials' auth token from the keychain.
60 | - (void)removeCredentials:(ENCredentials *)credentials;
61 |
62 | // Remove all credentials from the store.
63 | // Also deletes the credentials' auth tokens from the keychain.
64 | - (void)clearAllCredentials;
65 |
66 | // Save the current selected boostrap profile.
67 | + (void)saveCurrentProfile:(EvernoteService)code;
68 |
69 | // Save the expiration date for the business authentication token
70 | + (void)saveBusinessTokenExpiration:(NSTimeInterval)expirationTimeStamp;
71 |
72 | // Look up the currently selected bootstrap profile
73 | + (NSInteger)getCurrentProfile;
74 |
75 | // Look up the currently saved business auth token expiration date
76 | + (NSTimeInterval)getBusinessTokenExpiration;
77 |
78 | @end
79 |
--------------------------------------------------------------------------------
/EvernoteSDK/internal/ENCredentials.h:
--------------------------------------------------------------------------------
1 | /*
2 | * ENCredentials.h
3 | * evernote-sdk-ios
4 | *
5 | * Copyright 2012 Evernote Corporation
6 | * All rights reserved.
7 | *
8 | * Redistribution and use in source and binary forms, with or without modification,
9 | * are permitted provided that the following conditions are met:
10 | *
11 | * 1. Redistributions of source code must retain the above copyright notice, this
12 | * list of conditions and the following disclaimer.
13 | *
14 | * 2. Redistributions in binary form must reproduce the above copyright notice,
15 | * this list of conditions and the following disclaimer in the documentation
16 | * and/or other materials provided with the distribution.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | #import
31 |
32 | @interface ENCredentials : NSObject
33 |
34 | @property (nonatomic, copy) NSString *host;
35 | @property (nonatomic, copy) NSString *edamUserId;
36 | @property (nonatomic, copy) NSString *noteStoreUrl;
37 | @property (nonatomic, copy) NSString *webApiUrlPrefix;
38 | @property (nonatomic, copy) NSString *authenticationToken;
39 |
40 | - (id)initWithHost:(NSString *)host
41 | edamUserId:(NSString *)edamUserId
42 | noteStoreUrl:(NSString *)noteStoreUrl
43 | webApiUrlPrefix:(NSString *)webApiUrlPrefix
44 | authenticationToken:(NSString *)authenticationToken;
45 |
46 | - (BOOL)saveToKeychain;
47 | - (void)deleteFromKeychain;
48 |
49 | @end
50 |
--------------------------------------------------------------------------------
/EvernoteSDK/internal/ENCredentials.m:
--------------------------------------------------------------------------------
1 | /*
2 | * ENCredentials.m
3 | * evernote-sdk-ios
4 | *
5 | * Copyright 2012 Evernote Corporation
6 | * All rights reserved.
7 | *
8 | * Redistribution and use in source and binary forms, with or without modification,
9 | * are permitted provided that the following conditions are met:
10 | *
11 | * 1. Redistributions of source code must retain the above copyright notice, this
12 | * list of conditions and the following disclaimer.
13 | *
14 | * 2. Redistributions in binary form must reproduce the above copyright notice,
15 | * this list of conditions and the following disclaimer in the documentation
16 | * and/or other materials provided with the distribution.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | #import "ENCredentials.h"
31 | #import "SSKeychain.h"
32 |
33 | @interface ENCredentials()
34 |
35 | @end
36 |
37 | @implementation ENCredentials
38 |
39 | @synthesize host = _host;
40 | @synthesize edamUserId = _edamUserId;
41 | @synthesize noteStoreUrl = _noteStoreUrl;
42 | @synthesize webApiUrlPrefix = _webApiUrlPrefix;
43 | @synthesize authenticationToken = _authenticationToken;
44 |
45 | - (id)initWithHost:(NSString *)host
46 | edamUserId:(NSString *)edamUserId
47 | noteStoreUrl:(NSString *)noteStoreUrl
48 | webApiUrlPrefix:(NSString *)webApiUrlPrefix
49 | authenticationToken:(NSString *)authenticationToken
50 | {
51 | self = [super init];
52 | if (self) {
53 | self.host = host;
54 | self.edamUserId = edamUserId;
55 | self.noteStoreUrl = noteStoreUrl;
56 | self.webApiUrlPrefix = webApiUrlPrefix;
57 | self.authenticationToken = authenticationToken;
58 | }
59 | return self;
60 | }
61 |
62 | - (BOOL)saveToKeychain
63 | {
64 | // auth token gets saved to the keychain
65 | NSError *error;
66 | BOOL success = [SSKeychain setPassword:_authenticationToken
67 | forService:self.host
68 | account:self.edamUserId
69 | error:&error];
70 | if (!success) {
71 | NSLog(@"Error saving to keychain: %@ %ld", error, (long)error.code);
72 | return NO;
73 | }
74 | return YES;
75 | }
76 |
77 | - (void)deleteFromKeychain
78 | {
79 | [SSKeychain deletePasswordForService:self.host account:self.edamUserId];
80 | }
81 |
82 | - (NSString *)authenticationToken
83 | {
84 | NSError *error;
85 | NSString *token = [SSKeychain passwordForService:self.host account:self.edamUserId error:&error];
86 | if (!token) {
87 | NSLog(@"Error getting password from keychain: %@", error);
88 | }
89 | return token;
90 | }
91 |
92 | #pragma mark - NSCoding
93 |
94 | - (void)encodeWithCoder:(NSCoder *)encoder {
95 | [encoder encodeObject:self.host forKey:@"host"];
96 | [encoder encodeObject:self.edamUserId forKey:@"edamUserId"];
97 | [encoder encodeObject:self.noteStoreUrl forKey:@"noteStoreUrl"];
98 | [encoder encodeObject:self.webApiUrlPrefix forKey:@"webApiUrlPrefix"];
99 | }
100 |
101 | - (id)initWithCoder:(NSCoder *)decoder {
102 | if((self = [super init])) {
103 | self.host = [decoder decodeObjectForKey:@"host"];
104 | self.edamUserId = [decoder decodeObjectForKey:@"edamUserId"];
105 | self.noteStoreUrl = [decoder decodeObjectForKey:@"noteStoreUrl"];
106 | self.webApiUrlPrefix = [decoder decodeObjectForKey:@"webApiUrlPrefix"];
107 | }
108 | return self;
109 | }
110 |
111 | @end
112 |
--------------------------------------------------------------------------------
/EvernoteSDK/internal/ENOAuthProtocol.h:
--------------------------------------------------------------------------------
1 | //
2 | // ENOAuthProtocol.h
3 | // EvernoteSDK
4 | //
5 | // Created by Dirk Holtwick on 02.04.13.
6 | // Copyright (c) 2013 n/a. All rights reserved.
7 | //
8 |
9 | @protocol ENOAuthDelegate
10 | - (void)oauthViewControllerDidCancel:(id)sender;
11 | - (void)oauthViewControllerDidSwitchProfile:(id)sender;
12 | - (void)oauthViewController:(id)sender didFailWithError:(NSError *)error;
13 | - (void)oauthViewController:(id)sender receivedOAuthCallbackURL:(NSURL *)url;
14 | @end
15 |
--------------------------------------------------------------------------------
/EvernoteSDK/internal/ENOAuthViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ENOAuthViewController.h
3 | // evernote-sdk-ios
4 | //
5 | // Created by Matthew McGlincy on 5/26/12.
6 | // Copyright (c) 2012 n/a. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "ENOAuthProtocol.h"
11 | #import
12 |
13 | @class ENOAuthViewController;
14 |
15 | @interface ENOAuthViewController : UIViewController
16 |
17 | @property (nonatomic, weak) id delegate;
18 |
19 | - (id)initWithAuthorizationURL:(NSURL *)authorizationURL
20 | oauthCallbackPrefix:(NSString *)oauthCallbackPrefix
21 | profileName:(NSString *)currentProfileName
22 | allowSwitching:(BOOL)isSwitchingAllowed
23 | delegate:(id)delegate;
24 |
25 | - (void)updateUIForNewProfile:(NSString*)newProfile withAuthorizationURL:(NSURL*)authURL;
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/EvernoteSDK/internal/ENOAuthWindowController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ENOAuthWindowController.h
3 | // EvernoteSDK
4 | //
5 | // Created by Dirk Holtwick on 02.04.13.
6 | // Copyright (c) 2013 n/a. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | #import "ENOAuthProtocol.h"
13 |
14 | @interface ENOAuthWindowController : NSWindowController
15 |
16 | @property (weak) IBOutlet NSProgressIndicator *activityIndicator;
17 | @property (weak) IBOutlet WKWebView *webView;
18 |
19 | @property (nonatomic, weak) id delegate;
20 |
21 | - (id)initWithAuthorizationURL:(NSURL *)authorizationURL
22 | oauthCallbackPrefix:(NSString *)oauthCallbackPrefix
23 | profileName:(NSString *)currentProfileName
24 | allowSwitching:(BOOL)isSwitchingAllowed
25 | delegate:(id)delegate;
26 | - (void)updateUIForNewProfile:(NSString*)newProfile withAuthorizationURL:(NSURL*)authURL;
27 |
28 | - (void)presentSheetForWindow:(NSWindow *)window;
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/EvernoteSDK/internal/Resources/EvernoteSDK.strings:
--------------------------------------------------------------------------------
1 | /*
2 | * Localizable.strings
3 | * evernote-sdk-ios
4 | *
5 | * Copyright 2012 Evernote Corporation
6 | * All rights reserved.
7 | *
8 | * Redistribution and use in source and binary forms, with or without modification,
9 | * are permitted provided that the following conditions are met:
10 | *
11 | * 1. Redistributions of source code must retain the above copyright notice, this
12 | * list of conditions and the following disclaimer.
13 | *
14 | * 2. Redistributions in binary form must reproduce the above copyright notice,
15 | * this list of conditions and the following disclaimer in the documentation
16 | * and/or other materials provided with the distribution.
17 | *
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 | * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 | */
29 |
30 | "Cancel" = "Cancel";
31 |
32 | "Evernote-China" = "印象笔记";
33 |
34 | "Evernote-International" = "Evernote International";
--------------------------------------------------------------------------------
/FUTURE-IDEAS.md:
--------------------------------------------------------------------------------
1 | # Future Ideas
2 |
3 | Some randomly collected ideas for future development of API. If you have further ideas feel free to add them in the *Github Issues* section.
4 |
5 | ### iOS SDK
6 |
7 | ~
8 |
9 | ### Mac SDK
10 |
11 | - Routing OAuth dialog through default browser
12 | - Support for AppleScript communication with Evernote Mac App
13 | - Direct OAuth authentication using installed Evernote Mac App
14 |
--------------------------------------------------------------------------------
/INSTALL-MAC.md:
--------------------------------------------------------------------------------
1 | # Evernote Mac SDK
2 |
3 | How to use the Evernote SDK in your own Mac project.
4 |
5 | ## Step by Step
6 |
7 | 1. Download the Evernote SDK from github
8 | 2. Drag the EvernoteSDK Xcode project into your own project
9 | 3. Add the `EvernoteSDK-mac.framework`
10 | 4. Add `EvernoteSDK-Mac` to the `Target dependencies`
11 | 5. Add a `Copy files` build phase and choose destination `Frameworks` from the pull down menu, then add the `EvernoteSDK-mac.framework` to the list
12 |
13 | 
14 |
15 | ## Coding
16 |
17 | 1. Use Evernote SDK in your source by adding `#import `
18 | 2. Setup shared Evernote session object
19 | 3. Find a sweet spot for authentication
20 | 4. Use Evernote API
21 |
22 |
23 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2007-2012 by Evernote Corporation, All rights reserved.
3 | *
4 | * Use of the source code and binary libraries included in this package
5 | * is permitted under the following terms:
6 | *
7 | * Redistribution and use in source and binary forms, with or without
8 | * modification, are permitted provided that the following conditions
9 | * are met:
10 | *
11 | * 1. Redistributions of source code must retain the above copyright
12 | * notice, this list of conditions and the following disclaimer.
13 | * 2. Redistributions in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in the
15 | * documentation and/or other materials provided with the distribution.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | */
28 |
--------------------------------------------------------------------------------
/NOTICE:
--------------------------------------------------------------------------------
1 | Apache Thrift
2 | Copyright 2006-2010 The Apache Software Foundation.
3 |
4 | This product includes software developed at
5 | The Apache Software Foundation (http://www.apache.org/).
--------------------------------------------------------------------------------
/SampleApp-Mac/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // SampleApp-Mac
4 | //
5 | // Created by Dirk Holtwick on 02.04.13.
6 | // Copyright (c) 2013 n/a. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : NSObject
12 |
13 | @property (assign) IBOutlet NSWindow *window;
14 | @property (strong, nonatomic) NSArray *content;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/SampleApp-Mac/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // SampleApp-Mac
4 | //
5 | // Created by Dirk Holtwick on 02.04.13.
6 | // Copyright (c) 2013 n/a. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 | #import
11 |
12 | @implementation AppDelegate
13 |
14 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
15 | {
16 | // Override point for customization after application launch.
17 |
18 | // Initial development is done on the sandbox service
19 | // Change this to BootstrapServerBaseURLStringUS to use the production Evernote service
20 | // Change this to BootstrapServerBaseURLStringCN to use the Yinxiang Biji production service
21 | // BootstrapServerBaseURLStringSandbox does not support the Yinxiang Biji service
22 | NSString *EVERNOTE_HOST = BootstrapServerBaseURLStringSandbox;
23 |
24 | #warning Add Consumer Key and Consumer Secret, but also modify Info.plist according to documentation!
25 | #warning Remove these warnings once done with it.
26 |
27 | // Fill in the consumer key and secret with the values that you received from Evernote
28 | // To get an API key, visit http://dev.evernote.com/documentation/cloud/
29 | NSString *CONSUMER_KEY = @"your key";
30 | NSString *CONSUMER_SECRET = @"your secret";
31 |
32 | // set up Evernote session singleton
33 | [EvernoteSession setSharedSessionHost:EVERNOTE_HOST
34 | consumerKey:CONSUMER_KEY
35 | consumerSecret:CONSUMER_SECRET];
36 | }
37 |
38 | - (IBAction)doAuthenticate:(id)sender {
39 | EvernoteSession *session = [EvernoteSession sharedSession];
40 | NSLog(@"Session %@", session);
41 | [session authenticateWithWindow:self.window completionHandler:^(NSError *error) {
42 | if (error || !session.isAuthenticated) {
43 | NSRunCriticalAlertPanel(@"Error", @"Could not authenticate", @"OK", nil, nil);
44 | }
45 | else {
46 | NSLog(@"authenticated! noteStoreUrl:%@ webApiUrlPrefix:%@", session.noteStoreUrl, session.webApiUrlPrefix);
47 |
48 | EvernoteNoteStore *noteStore = [EvernoteNoteStore noteStore];
49 | [noteStore listNotebooksWithSuccess:^(NSArray *notebooks) {
50 | self.content = notebooks;
51 | NSLog(@"notebooks: %@", notebooks);
52 | } failure:^(NSError *error2) {
53 | NSLog(@"error %@", error2);
54 | }];
55 | }
56 | }];
57 | }
58 |
59 | @end
60 |
--------------------------------------------------------------------------------
/SampleApp-Mac/SampleApp-Mac-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1
25 | LSMinimumSystemVersion
26 | ${MACOSX_DEPLOYMENT_TARGET}
27 | NSHumanReadableCopyright
28 | Copyright © 2013 n/a. All rights reserved.
29 | NSMainNibFile
30 | MainMenu
31 | NSPrincipalClass
32 | NSApplication
33 |
34 |
35 |
--------------------------------------------------------------------------------
/SampleApp-Mac/SampleApp-Mac-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header for all source files of the 'SampleApp-Mac' target in the 'SampleApp-Mac' project
3 | //
4 |
5 | #ifdef __OBJC__
6 | #import
7 | #endif
8 |
--------------------------------------------------------------------------------
/SampleApp-Mac/SampleApp-Mac.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 | com.apple.security.network.client
8 |
9 | com.apple.security.network.server
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/SampleApp-Mac/en.lproj/Credits.rtf:
--------------------------------------------------------------------------------
1 | {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;}
2 | {\colortbl;\red255\green255\blue255;}
3 | \paperw9840\paperh8400
4 | \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
5 |
6 | \f0\b\fs24 \cf0 Engineering:
7 | \b0 \
8 | Some people\
9 | \
10 |
11 | \b Human Interface Design:
12 | \b0 \
13 | Some other people\
14 | \
15 |
16 | \b Testing:
17 | \b0 \
18 | Hopefully not nobody\
19 | \
20 |
21 | \b Documentation:
22 | \b0 \
23 | Whoever\
24 | \
25 |
26 | \b With special thanks to:
27 | \b0 \
28 | Mom\
29 | }
30 |
--------------------------------------------------------------------------------
/SampleApp-Mac/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/SampleApp-Mac/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // SampleApp-Mac
4 | //
5 | // Created by Dirk Holtwick on 02.04.13.
6 | // Copyright (c) 2013 n/a. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | int main(int argc, char *argv[])
12 | {
13 | return NSApplicationMain(argc, (const char **)argv);
14 | }
15 |
--------------------------------------------------------------------------------
/SampleApp-iOS/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // OAuthTest
4 | //
5 | // Created by Matthew McGlincy on 3/17/12.
6 | //
7 |
8 | #import
9 |
10 | @interface AppDelegate : UIResponder
11 |
12 | @property (strong, nonatomic) UIWindow *window;
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/SampleApp-iOS/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // OAuthTest
4 | //
5 | // Created by Matthew McGlincy on 3/17/12.
6 | //
7 | // A simple sample application that demonstrates authenticating to Evernote
8 | // via OAuth and using the resulting authentication token to make a simple
9 | // Evernote API call.
10 | //
11 | // To get started, fill in your consumer key and secret below.
12 | //
13 |
14 | #import "AppDelegate.h"
15 | #import "EvernoteSDK.h"
16 |
17 | @implementation AppDelegate
18 |
19 | @synthesize window = _window;
20 |
21 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
22 | {
23 | // Override point for customization after application launch.
24 |
25 | // Initial development is done on the sandbox service
26 | // Change this to BootstrapServerBaseURLStringUS to use the production Evernote service
27 | // Change this to BootstrapServerBaseURLStringCN to use the Yinxiang Biji production service
28 | // BootstrapServerBaseURLStringSandbox does not support the Yinxiang Biji service
29 | NSString *EVERNOTE_HOST = BootstrapServerBaseURLStringSandbox;
30 |
31 | #warning Add Consumer Key and Consumer Secret, but also modify Info.plist according to documentation!
32 | #warning Remove these warnings once done with it.
33 |
34 | // Fill in the consumer key and secret with the values that you received from Evernote
35 | // To get an API key, visit http://dev.evernote.com/documentation/cloud/
36 | NSString *CONSUMER_KEY = @"your key";
37 | NSString *CONSUMER_SECRET = @"your secret";
38 |
39 | // set up Evernote session singleton
40 | [EvernoteSession setSharedSessionHost:EVERNOTE_HOST
41 | consumerKey:CONSUMER_KEY
42 | consumerSecret:CONSUMER_SECRET];
43 |
44 | return YES;
45 | }
46 |
47 | - (void)applicationWillResignActive:(UIApplication *)application
48 | {
49 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
50 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
51 | }
52 |
53 | - (void)applicationDidEnterBackground:(UIApplication *)application
54 | {
55 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
56 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
57 | }
58 |
59 | - (void)applicationWillEnterForeground:(UIApplication *)application
60 | {
61 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
62 | }
63 |
64 | - (void)applicationDidBecomeActive:(UIApplication *)application
65 | {
66 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
67 | [[EvernoteSession sharedSession] handleDidBecomeActive];
68 | }
69 |
70 | - (void)applicationWillTerminate:(UIApplication *)application
71 | {
72 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
73 | }
74 |
75 | - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
76 | BOOL canHandle = NO;
77 | if ([[NSString stringWithFormat:@"en-%@", [[EvernoteSession sharedSession] consumerKey]] isEqualToString:[url scheme]] == YES) {
78 | canHandle = [[EvernoteSession sharedSession] canHandleOpenURL:url];
79 | }
80 | return canHandle;
81 | }
82 |
83 | - (BOOL) canHandleSwitchProfileURL:(NSURL *)url {
84 | NSString *requestURL = [url path];
85 | NSArray *components = [requestURL componentsSeparatedByString:@"/"];
86 | if ([components count] < 2) {
87 | NSLog(@"URL:%@ has invalid component count: %i", url, [components count]);
88 | return NO;
89 | }
90 | [[EvernoteSession sharedSession] updateCurrentBootstrapProfileWithName:components[1]];
91 | return YES;
92 | }
93 |
94 | @end
95 |
--------------------------------------------------------------------------------
/SampleApp-iOS/Extras/UI/NotebookChooserViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NotbookChooserViewController.h
3 | // evernote-sdk-ios
4 | //
5 | // Created by Mustafa Furniturewala on 2/11/13.
6 | // Copyright (c) 2013 n/a. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class EDAMNotebook;
12 | @class NotebookChooserViewController;
13 |
14 | @protocol NotebookChooserViewControllerDelegate
15 | -(void)notebookChooserController:(NotebookChooserViewController*)controller didSelectNotebook:(EDAMNotebook*)notebook;
16 | @end
17 |
18 | @interface NotebookChooserViewController : UITableViewController
19 |
20 | @property(nonatomic, assign) id delegate;
21 | @property(nonatomic, strong) EDAMNotebook *selectedNotebook;
22 | @property(nonatomic, strong) NSIndexPath *selectedIndex;
23 |
24 | - (void)setSelectedNotebookWithGUID:(NSString *)notebookGUID;
25 | - (void)setSelectedNotebookWithName:(NSString *)notebookName;
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/SampleApp-iOS/MoreViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // MoreViewController.h
3 | // evernote-sdk-ios
4 | //
5 | // Created by Mustafa Furniturewala on 2/4/13.
6 | // Copyright (c) 2013 n/a. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "EvernoteSDK.h"
11 | #import "NotebookChooserViewController.h"
12 |
13 | @interface MoreViewController : UIViewController
14 |
15 | - (IBAction)saveNewNote:(id)sender;
16 | - (IBAction)viewNote:(id)sender;
17 | - (IBAction)installEvernote:(id)sender;
18 | - (IBAction)invlokeNotebookChooser:(id)sender;
19 | - (IBAction)createBusinessNote:(id)sender;
20 |
21 | @end
22 |
--------------------------------------------------------------------------------
/SampleApp-iOS/NoteBrowserViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NoteBrowserViewController.h
3 | // evernote-sdk-ios
4 | //
5 | // Created by Mustafa Furniturewala on 2/6/13.
6 | // Copyright (c) 2013 n/a. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface NoteBrowserViewController : UIViewController
13 | @property (weak, nonatomic) IBOutlet UIBarButtonItem *btnPrev;
14 |
15 | @property (weak, nonatomic) IBOutlet WKWebView *webView;
16 | - (IBAction)nextNote:(id)sender;
17 | - (IBAction)previousNote:(id)sender;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/SampleApp-iOS/NoteBrowserViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // NoteBrowserViewController.m
3 | // evernote-sdk-ios
4 | //
5 | // Created by Mustafa Furniturewala on 2/6/13.
6 | // Copyright (c) 2013 n/a. All rights reserved.
7 | //
8 |
9 | #import "NoteBrowserViewController.h"
10 | #import "EvernoteSDK.h"
11 | #import "ENMLUtility.h"
12 |
13 | @interface NoteBrowserViewController ()
14 |
15 | @property (nonatomic,assign) NSInteger currentNote;
16 | @property (nonatomic,strong) UIActivityIndicatorView* activityIndicator;
17 | @property (nonatomic,strong) NSArray* noteList;
18 |
19 | @end
20 |
21 | @implementation NoteBrowserViewController
22 |
23 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
24 | {
25 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
26 | if (self) {
27 | // Custom initialization
28 | }
29 | return self;
30 | }
31 |
32 | - (void)viewDidLoad
33 | {
34 | [super viewDidLoad];
35 | // Do any additional setup after loading the view.
36 | [self.btnPrev setEnabled:NO];
37 | self.activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
38 | CGRect viewRect = self.webView.frame;
39 | [self.activityIndicator setFrame:CGRectMake(viewRect.size.width/2, viewRect.size.height/2, 20, 20)];
40 | [self.activityIndicator setHidesWhenStopped:YES];
41 | [self.webView addSubview:self.activityIndicator];
42 | [self loadMoreNotes];
43 | }
44 |
45 | - (void)didReceiveMemoryWarning
46 | {
47 | [self setWebView:nil];
48 | [self setBtnPrev:nil];
49 | [super didReceiveMemoryWarning];
50 | // Dispose of any resources that can be recreated.
51 | }
52 |
53 | - (IBAction)nextNote:(id)sender {
54 | if(self.currentNote%10==0) {
55 | self.currentNote++;
56 | [self loadMoreNotes];
57 | }
58 | else {
59 | self.currentNote++;
60 | [self loadCurrentNote];
61 | }
62 | if(self.currentNote > 0) {
63 | [self.btnPrev setEnabled:YES];
64 | }
65 | }
66 |
67 | - (IBAction)previousNote:(id)sender {
68 | self.currentNote--;
69 | [self loadCurrentNote];
70 | if(self.currentNote==0) {
71 | [self.btnPrev setEnabled:NO];
72 | }
73 | }
74 |
75 | - (void)loadMoreNotes {
76 | [[self activityIndicator] startAnimating];
77 | EDAMNoteFilter* filter = [[EDAMNoteFilter alloc] initWithOrder:0 ascending:NO words:nil notebookGuid:nil tagGuids:nil timeZone:nil inactive:NO emphasized:nil];
78 | EDAMNotesMetadataResultSpec *resultSpec = [[EDAMNotesMetadataResultSpec alloc] initWithIncludeTitle: NO includeContentLength:NO includeCreated:NO includeUpdated:NO includeDeleted:NO includeUpdateSequenceNum:NO includeNotebookGuid:NO includeTagGuids:NO includeAttributes: NO includeLargestResourceMime:NO includeLargestResourceSize:NO];
79 | [[EvernoteNoteStore noteStore] findNotesMetadataWithFilter:filter offset:self.currentNote maxNotes:10 resultSpec:resultSpec success:^(EDAMNotesMetadataList *metadata) {
80 | if(metadata.notes.count > 0) {
81 | self.noteList = metadata.notes;
82 | [self loadCurrentNote];
83 | }
84 | else {
85 | [self.webView loadHTMLString:@"No note found" baseURL:nil];
86 | [[self activityIndicator] stopAnimating];
87 | }
88 | } failure:^(NSError *error) {
89 | NSLog(@"Failed to find notes : %@",error);
90 | [[self activityIndicator] stopAnimating];
91 | }];
92 | }
93 |
94 | - (void) loadCurrentNote {
95 | [[self activityIndicator] startAnimating];
96 | if([self.noteList count] > self.currentNote%10) {
97 | EDAMNoteMetadata* foundNote = self.noteList[self.currentNote%10];
98 | [[EvernoteNoteStore noteStore] getNoteWithGuid:foundNote.guid withContent:YES withResourcesData:YES withResourcesRecognition:NO withResourcesAlternateData:NO success:^(EDAMNote *note) {
99 | ENMLUtility *utltility = [[ENMLUtility alloc] init];
100 | [utltility convertENMLToHTML:note.content withResources:note.resources completionBlock:^(NSString *html, NSError *error) {
101 | if(error == nil) {
102 | [self.webView loadHTMLString:html baseURL:nil];
103 | [[self activityIndicator] stopAnimating];
104 | }
105 | }];
106 | } failure:^(NSError *error) {
107 | NSLog(@"Failed to get note : %@",error);
108 | [[self activityIndicator] stopAnimating];
109 | }];
110 | }
111 | }
112 | @end
113 |
--------------------------------------------------------------------------------
/SampleApp-iOS/Resources/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Evernote/evernote-sdk-mac/012939f50b0d2b646cac09fb5260ee4296287efd/SampleApp-iOS/Resources/Default-568h@2x.png
--------------------------------------------------------------------------------
/SampleApp-iOS/Resources/Images/evernote_logo_4c-sm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Evernote/evernote-sdk-mac/012939f50b0d2b646cac09fb5260ee4296287efd/SampleApp-iOS/Resources/Images/evernote_logo_4c-sm.png
--------------------------------------------------------------------------------
/SampleApp-iOS/SampleApp-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleURLTypes
24 |
25 |
26 | CFBundleURLName
27 |
28 | CFBundleURLSchemes
29 |
30 | en-<your consumer key>
31 |
32 |
33 |
34 | CFBundleVersion
35 | 1.0
36 | LSRequiresIPhoneOS
37 |
38 | UIMainStoryboardFile
39 | iPhone
40 | UIMainStoryboardFile~ipad
41 | iPad
42 | UIRequiredDeviceCapabilities
43 |
44 | armv7
45 |
46 | UISupportedInterfaceOrientations
47 |
48 | UIInterfaceOrientationPortrait
49 | UIInterfaceOrientationLandscapeLeft
50 | UIInterfaceOrientationLandscapeRight
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/SampleApp-iOS/SampleApp-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header for all source files of the 'OAuthTest' target in the 'OAuthTest' project
3 | //
4 |
5 | #import
6 |
7 | #ifndef __IPHONE_5_0
8 | #warning "This project uses features only available in iOS SDK 5.0 and later."
9 | #endif
10 |
11 | #ifdef __OBJC__
12 | #import
13 | #import
14 | #endif
15 |
--------------------------------------------------------------------------------
/SampleApp-iOS/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/SampleApp-iOS/iPadViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // iPadViewController.h
3 | // evernote-sdk-ios
4 | //
5 | // Created by Matthew McGlincy on 6/12/12.
6 | // Copyright (c) 2012 n/a. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface iPadViewController : UIViewController
12 |
13 | - (IBAction)authenticate:(id)sender;
14 | - (IBAction)listNotebooks:(id)sender;
15 | - (IBAction)listSharedNotes:(id)sender;
16 | - (IBAction)listBusinessNotebooks:(id)sender;
17 | - (IBAction)createPhotoNote:(id)sender;
18 | - (IBAction)logout:(id)sender;
19 |
20 | @property (strong, nonatomic) IBOutlet UIButton *authenticateButton;
21 | @property (strong, nonatomic) IBOutlet UIButton *listNotebooksButton;
22 | @property (strong, nonatomic) IBOutlet UIButton *listBusinessButton;
23 | @property (strong, nonatomic) IBOutlet UIButton *photoNoteButton;
24 | @property (strong, nonatomic) IBOutlet UIButton *sharedNotesButton;
25 | @property (strong, nonatomic) IBOutlet UITableView *tableView;
26 | @property (strong, nonatomic) IBOutlet UIButton *logoutButton;
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/SampleApp-iOS/iPhoneViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // iPhoneViewController.h
3 | // OAuthTest
4 | //
5 | // Created by Matthew McGlincy on 3/17/12.
6 | //
7 |
8 | #import
9 | #import
10 | @interface iPhoneViewController : UIViewController
11 | - (IBAction)authenticate:(id)sender;
12 | - (IBAction)listNotes:(id)sender;
13 | - (IBAction)listBusinessNotebooks:(id)sender;
14 | - (IBAction)createBusinessNotebook:(id)sender;
15 | - (IBAction)listSharedNotes:(id)sender;
16 | - (IBAction)createPhotoNote:(id)sender;
17 | - (IBAction)logout:(id)sender;
18 | @property (strong, nonatomic) IBOutlet UILabel *userLabel;
19 | @property (strong, nonatomic) IBOutlet UILabel *businessLabel;
20 | @property (strong, nonatomic) IBOutlet UIButton *listNotebooksButton;
21 | @property (strong, nonatomic) IBOutlet UIButton *createBusinessNotebookButton;
22 | @property (strong, nonatomic) IBOutlet UIButton *listBusinessButton;
23 | @property (strong, nonatomic) IBOutlet UIButton *authenticateButton;
24 | @property (strong, nonatomic) IBOutlet UIButton *createPhotoButton;
25 | @property (strong, nonatomic) IBOutlet UIButton *sharedNotesButton;
26 | @property (strong, nonatomic) IBOutlet UIButton *logoutButton;
27 | @property (weak, nonatomic) IBOutlet UIButton *moreButton;
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/SampleApp-iOS/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // OAuthTest
4 | //
5 | // Created by Matthew McGlincy on 3/17/12.
6 | // Copyright (c) 2012 n/a. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import "AppDelegate.h"
12 |
13 | int main(int argc, char *argv[])
14 | {
15 | @autoreleasepool {
16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/UnitTests/3rdParty/OCMock/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | Copyright (c) 2004-2012 by Mulle Kybernetik. All rights reserved.
3 |
4 | Permission to use, copy, modify and distribute this software and its documentation
5 | is hereby granted, provided that both the copyright notice and this permission
6 | notice appear in all copies of the software, derivative works or modified versions,
7 | and any portions thereof, and that both notices appear in supporting documentation,
8 | and that credit is given to Mulle Kybernetik in all documents and publicity
9 | pertaining to direct or indirect use of this code or its derivatives.
10 |
11 | THIS IS EXPERIMENTAL SOFTWARE AND IT IS KNOWN TO HAVE BUGS, SOME OF WHICH MAY HAVE
12 | SERIOUS CONSEQUENCES. THE COPYRIGHT HOLDER ALLOWS FREE USE OF THIS SOFTWARE IN ITS
13 | "AS IS" CONDITION. THE COPYRIGHT HOLDER DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY
14 | DAMAGES WHATSOEVER RESULTING DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE
15 | OR OF ANY DERIVATIVE WORK.
--------------------------------------------------------------------------------
/UnitTests/3rdParty/OCMock/OCMock/NSNotificationCenter+OCMAdditions.h:
--------------------------------------------------------------------------------
1 | //---------------------------------------------------------------------------------------
2 | // $Id$
3 | // Copyright (c) 2009 by Mulle Kybernetik. See License file for details.
4 | //---------------------------------------------------------------------------------------
5 |
6 | #import
7 |
8 | @class OCMockObserver;
9 |
10 |
11 | @interface NSNotificationCenter(OCMAdditions)
12 |
13 | - (void)addMockObserver:(OCMockObserver *)notificationObserver name:(NSString *)notificationName object:(id)notificationSender;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/UnitTests/3rdParty/OCMock/OCMock/OCMArg.h:
--------------------------------------------------------------------------------
1 | //---------------------------------------------------------------------------------------
2 | // $Id$
3 | // Copyright (c) 2009-2010 by Mulle Kybernetik. See License file for details.
4 | //---------------------------------------------------------------------------------------
5 |
6 | #import
7 |
8 | @interface OCMArg : NSObject
9 |
10 | // constraining arguments
11 |
12 | + (id)any;
13 | + (void *)anyPointer;
14 | + (id)isNil;
15 | + (id)isNotNil;
16 | + (id)isNotEqual:(id)value;
17 | + (id)checkWithSelector:(SEL)selector onObject:(id)anObject;
18 | #if NS_BLOCKS_AVAILABLE
19 | + (id)checkWithBlock:(BOOL (^)(id))block;
20 | #endif
21 |
22 | // manipulating arguments
23 |
24 | + (id *)setTo:(id)value;
25 |
26 | // internal use only
27 |
28 | + (id)resolveSpecialValues:(NSValue *)value;
29 |
30 | @end
31 |
32 | #define OCMOCK_ANY [OCMArg any]
33 | #define OCMOCK_VALUE(variable) [NSValue value:&variable withObjCType:@encode(__typeof__(variable))]
34 |
--------------------------------------------------------------------------------
/UnitTests/3rdParty/OCMock/OCMock/OCMConstraint.h:
--------------------------------------------------------------------------------
1 | //---------------------------------------------------------------------------------------
2 | // $Id$
3 | // Copyright (c) 2007-2010 by Mulle Kybernetik. See License file for details.
4 | //---------------------------------------------------------------------------------------
5 |
6 | #import
7 |
8 |
9 | @interface OCMConstraint : NSObject
10 |
11 | + (id)constraint;
12 | - (BOOL)evaluate:(id)value;
13 |
14 | // if you are looking for any, isNil, etc, they have moved to OCMArg
15 |
16 | // try to use [OCMArg checkWith...] instead of the constraintWith... methods below
17 |
18 | + (id)constraintWithSelector:(SEL)aSelector onObject:(id)anObject;
19 | + (id)constraintWithSelector:(SEL)aSelector onObject:(id)anObject withValue:(id)aValue;
20 |
21 |
22 | @end
23 |
24 | @interface OCMAnyConstraint : OCMConstraint
25 | @end
26 |
27 | @interface OCMIsNilConstraint : OCMConstraint
28 | @end
29 |
30 | @interface OCMIsNotNilConstraint : OCMConstraint
31 | @end
32 |
33 | @interface OCMIsNotEqualConstraint : OCMConstraint
34 | {
35 | @public
36 | id testValue;
37 | }
38 |
39 | @end
40 |
41 | @interface OCMInvocationConstraint : OCMConstraint
42 | {
43 | @public
44 | NSInvocation *invocation;
45 | }
46 |
47 | @end
48 |
49 | #if NS_BLOCKS_AVAILABLE
50 |
51 | @interface OCMBlockConstraint : OCMConstraint
52 | {
53 | BOOL (^block)(id);
54 | }
55 |
56 | - (id)initWithConstraintBlock:(BOOL (^)(id))block;
57 |
58 | @end
59 |
60 | #endif
61 |
62 |
63 | #define CONSTRAINT(aSelector) [OCMConstraint constraintWithSelector:aSelector onObject:self]
64 | #define CONSTRAINTV(aSelector, aValue) [OCMConstraint constraintWithSelector:aSelector onObject:self withValue:(aValue)]
65 |
--------------------------------------------------------------------------------
/UnitTests/3rdParty/OCMock/OCMock/OCMock.h:
--------------------------------------------------------------------------------
1 | //---------------------------------------------------------------------------------------
2 | // $Id$
3 | // Copyright (c) 2004-2008 by Mulle Kybernetik. See License file for details.
4 | //---------------------------------------------------------------------------------------
5 |
6 | #import
7 | #import
8 | #import
9 | #import
10 | #import
11 |
--------------------------------------------------------------------------------
/UnitTests/3rdParty/OCMock/OCMock/OCMockObject.h:
--------------------------------------------------------------------------------
1 | //---------------------------------------------------------------------------------------
2 | // $Id$
3 | // Copyright (c) 2004-2008 by Mulle Kybernetik. See License file for details.
4 | //---------------------------------------------------------------------------------------
5 |
6 | #import
7 |
8 | @interface OCMockObject : NSProxy
9 | {
10 | BOOL isNice;
11 | BOOL expectationOrderMatters;
12 | NSMutableArray *recorders;
13 | NSMutableArray *expectations;
14 | NSMutableArray *rejections;
15 | NSMutableArray *exceptions;
16 | }
17 |
18 | + (id)mockForClass:(Class)aClass;
19 | + (id)mockForProtocol:(Protocol *)aProtocol;
20 | + (id)partialMockForObject:(NSObject *)anObject;
21 |
22 | + (id)niceMockForClass:(Class)aClass;
23 | + (id)niceMockForProtocol:(Protocol *)aProtocol;
24 |
25 | + (id)observerMock;
26 |
27 | - (id)init;
28 |
29 | - (void)setExpectationOrderMatters:(BOOL)flag;
30 |
31 | - (id)stub;
32 | - (id)expect;
33 | - (id)reject;
34 |
35 | - (void)verify;
36 |
37 | // internal use only
38 |
39 | - (id)getNewRecorder;
40 | - (BOOL)handleInvocation:(NSInvocation *)anInvocation;
41 | - (void)handleUnRecordedInvocation:(NSInvocation *)anInvocation;
42 |
43 | @end
44 |
--------------------------------------------------------------------------------
/UnitTests/3rdParty/OCMock/OCMock/OCMockRecorder.h:
--------------------------------------------------------------------------------
1 | //---------------------------------------------------------------------------------------
2 | // $Id$
3 | // Copyright (c) 2004-2010 by Mulle Kybernetik. See License file for details.
4 | //---------------------------------------------------------------------------------------
5 |
6 | #import
7 |
8 | @interface OCMockRecorder : NSProxy
9 | {
10 | id signatureResolver;
11 | NSInvocation *recordedInvocation;
12 | NSMutableArray *invocationHandlers;
13 | }
14 |
15 | - (id)initWithSignatureResolver:(id)anObject;
16 |
17 | - (BOOL)matchesInvocation:(NSInvocation *)anInvocation;
18 | - (void)releaseInvocation;
19 |
20 | - (id)andReturn:(id)anObject;
21 | - (id)andReturnValue:(NSValue *)aValue;
22 | - (id)andThrow:(NSException *)anException;
23 | - (id)andPost:(NSNotification *)aNotification;
24 | - (id)andCall:(SEL)selector onObject:(id)anObject;
25 | #if NS_BLOCKS_AVAILABLE
26 | - (id)andDo:(void (^)(NSInvocation *))block;
27 | #endif
28 | - (id)andForwardToRealObject;
29 |
30 | - (NSArray *)invocationHandlers;
31 |
32 | @end
33 |
--------------------------------------------------------------------------------
/UnitTests/3rdParty/OCMock/libOCMock.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Evernote/evernote-sdk-mac/012939f50b0d2b646cac09fb5260ee4296287efd/UnitTests/3rdParty/OCMock/libOCMock.a
--------------------------------------------------------------------------------
/UnitTests/EvernoteSessionTests.h:
--------------------------------------------------------------------------------
1 | //
2 | // EvernoteSessionTests.h
3 | // evernote-sdk-ios
4 | //
5 | // Created by Matthew McGlincy on 5/1/12.
6 | // Copyright (c) 2012 n/a. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface EvernoteSessionTests : SenTestCase
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/UnitTests/UnitTests-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundlePackageType
14 | BNDL
15 | CFBundleShortVersionString
16 | 1.0
17 | CFBundleSignature
18 | ????
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/UnitTests/UnitTests-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header for all source files of the 'UnitTests' target in the 'UnitTests' project
3 | //
4 |
5 | #ifdef __OBJC__
6 | #import
7 | #import
8 | #endif
9 |
--------------------------------------------------------------------------------
/UnitTests/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/src/edam/EDAMErrors.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Autogenerated by Thrift
3 | *
4 | * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5 | */
6 |
7 | #import
8 |
9 | #import "TProtocol.h"
10 | #import "TApplicationException.h"
11 | #import "TProtocolUtil.h"
12 | #import "TProcessor.h"
13 | #import "TObjective-C.h"
14 |
15 |
16 | enum EDAMErrorCode {
17 | EDAMErrorCode_UNKNOWN = 1,
18 | EDAMErrorCode_BAD_DATA_FORMAT = 2,
19 | EDAMErrorCode_PERMISSION_DENIED = 3,
20 | EDAMErrorCode_INTERNAL_ERROR = 4,
21 | EDAMErrorCode_DATA_REQUIRED = 5,
22 | EDAMErrorCode_LIMIT_REACHED = 6,
23 | EDAMErrorCode_QUOTA_REACHED = 7,
24 | EDAMErrorCode_INVALID_AUTH = 8,
25 | EDAMErrorCode_AUTH_EXPIRED = 9,
26 | EDAMErrorCode_DATA_CONFLICT = 10,
27 | EDAMErrorCode_ENML_VALIDATION = 11,
28 | EDAMErrorCode_SHARD_UNAVAILABLE = 12,
29 | EDAMErrorCode_LEN_TOO_SHORT = 13,
30 | EDAMErrorCode_LEN_TOO_LONG = 14,
31 | EDAMErrorCode_TOO_FEW = 15,
32 | EDAMErrorCode_TOO_MANY = 16,
33 | EDAMErrorCode_UNSUPPORTED_OPERATION = 17,
34 | EDAMErrorCode_TAKEN_DOWN = 18,
35 | EDAMErrorCode_RATE_LIMIT_REACHED = 19
36 | };
37 |
38 | @interface EDAMUserException : NSException {
39 | int __errorCode;
40 | NSString * __parameter;
41 |
42 | BOOL __errorCode_isset;
43 | BOOL __parameter_isset;
44 | }
45 |
46 | #if TARGET_OS_IPHONE || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
47 | @property (nonatomic, getter=errorCode, setter=setErrorCode:) int errorCode;
48 | @property (nonatomic, retain, getter=parameter, setter=setParameter:) NSString * parameter;
49 | #endif
50 |
51 | - (id) init;
52 | - (id) initWithErrorCode: (int) errorCode parameter: (NSString *) parameter;
53 |
54 | - (void) read: (id ) inProtocol;
55 | - (void) write: (id ) outProtocol;
56 |
57 | #if !__has_feature(objc_arc)
58 | - (int) errorCode;
59 | - (void) setErrorCode: (int) errorCode;
60 | #endif
61 | - (BOOL) errorCodeIsSet;
62 |
63 | #if !__has_feature(objc_arc)
64 | - (NSString *) parameter;
65 | - (void) setParameter: (NSString *) parameter;
66 | #endif
67 | - (BOOL) parameterIsSet;
68 |
69 | @end
70 |
71 | @interface EDAMSystemException : NSException {
72 | int __errorCode;
73 | NSString * __message;
74 | int32_t __rateLimitDuration;
75 |
76 | BOOL __errorCode_isset;
77 | BOOL __message_isset;
78 | BOOL __rateLimitDuration_isset;
79 | }
80 |
81 | #if TARGET_OS_IPHONE || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
82 | @property (nonatomic, getter=errorCode, setter=setErrorCode:) int errorCode;
83 | @property (nonatomic, retain, getter=message, setter=setMessage:) NSString * message;
84 | @property (nonatomic, getter=rateLimitDuration, setter=setRateLimitDuration:) int32_t rateLimitDuration;
85 | #endif
86 |
87 | - (id) init;
88 | - (id) initWithErrorCode: (int) errorCode message: (NSString *) message rateLimitDuration: (int32_t) rateLimitDuration;
89 |
90 | - (void) read: (id ) inProtocol;
91 | - (void) write: (id ) outProtocol;
92 |
93 | #if !__has_feature(objc_arc)
94 | - (int) errorCode;
95 | - (void) setErrorCode: (int) errorCode;
96 | #endif
97 | - (BOOL) errorCodeIsSet;
98 |
99 | #if !__has_feature(objc_arc)
100 | - (NSString *) message;
101 | - (void) setMessage: (NSString *) message;
102 | #endif
103 | - (BOOL) messageIsSet;
104 |
105 | #if !__has_feature(objc_arc)
106 | - (int32_t) rateLimitDuration;
107 | - (void) setRateLimitDuration: (int32_t) rateLimitDuration;
108 | #endif
109 | - (BOOL) rateLimitDurationIsSet;
110 |
111 | @end
112 |
113 | @interface EDAMNotFoundException : NSException {
114 | NSString * __identifier;
115 | NSString * __key;
116 |
117 | BOOL __identifier_isset;
118 | BOOL __key_isset;
119 | }
120 |
121 | #if TARGET_OS_IPHONE || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
122 | @property (nonatomic, retain, getter=identifier, setter=setIdentifier:) NSString * identifier;
123 | @property (nonatomic, retain, getter=key, setter=setKey:) NSString * key;
124 | #endif
125 |
126 | - (id) init;
127 | - (id) initWithIdentifier: (NSString *) identifier key: (NSString *) key;
128 |
129 | - (void) read: (id ) inProtocol;
130 | - (void) write: (id ) outProtocol;
131 |
132 | #if !__has_feature(objc_arc)
133 | - (NSString *) identifier;
134 | - (void) setIdentifier: (NSString *) identifier;
135 | #endif
136 | - (BOOL) identifierIsSet;
137 |
138 | #if !__has_feature(objc_arc)
139 | - (NSString *) key;
140 | - (void) setKey: (NSString *) key;
141 | #endif
142 | - (BOOL) keyIsSet;
143 |
144 | @end
145 |
146 | @interface ErrorsConstants : NSObject {
147 | }
148 | @end
149 |
--------------------------------------------------------------------------------
/src/thrift/TApplicationException.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import "TException.h"
21 | #import "TProtocol.h"
22 |
23 | enum {
24 | TApplicationException_UNKNOWN = 0,
25 | TApplicationException_UNKNOWN_METHOD = 1,
26 | TApplicationException_INVALID_MESSAGE_TYPE = 2,
27 | TApplicationException_WRONG_METHOD_NAME = 3,
28 | TApplicationException_BAD_SEQUENCE_ID = 4,
29 | TApplicationException_MISSING_RESULT = 5,
30 | TApplicationException_INTERNAL_ERROR = 6,
31 | TApplicationException_PROTOCOL_ERROR = 7
32 | };
33 |
34 | // FIXME
35 | @interface TApplicationException : TException {
36 | int mType;
37 | }
38 |
39 | + (TApplicationException *) read: (id ) protocol;
40 |
41 | - (void) write: (id ) protocol;
42 |
43 | + (TApplicationException *) exceptionWithType: (int) type
44 | reason: (NSString *) message;
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/src/thrift/TApplicationException.m:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import "TApplicationException.h"
21 | #import "TProtocolUtil.h"
22 |
23 | @implementation TApplicationException
24 |
25 | - (id) initWithType: (int) type
26 | reason: (NSString *) reason
27 | {
28 | mType = type;
29 |
30 | NSString * name;
31 | switch (type) {
32 | case TApplicationException_UNKNOWN_METHOD:
33 | name = @"Unknown method";
34 | break;
35 | case TApplicationException_INVALID_MESSAGE_TYPE:
36 | name = @"Invalid message type";
37 | break;
38 | case TApplicationException_WRONG_METHOD_NAME:
39 | name = @"Wrong method name";
40 | break;
41 | case TApplicationException_BAD_SEQUENCE_ID:
42 | name = @"Bad sequence ID";
43 | break;
44 | case TApplicationException_MISSING_RESULT:
45 | name = @"Missing result";
46 | break;
47 | default:
48 | name = @"Unknown";
49 | break;
50 | }
51 |
52 | self = [super initWithName: name reason: reason userInfo: nil];
53 | return self;
54 | }
55 |
56 |
57 | + (TApplicationException *) read: (id ) protocol
58 | {
59 | NSString * reason = nil;
60 | int type = TApplicationException_UNKNOWN;
61 | int fieldType;
62 | int fieldID;
63 |
64 | [protocol readStructBeginReturningName: NULL];
65 |
66 | while (true) {
67 | [protocol readFieldBeginReturningName: NULL
68 | type: &fieldType
69 | fieldID: &fieldID];
70 | if (fieldType == TType_STOP) {
71 | break;
72 | }
73 | switch (fieldID) {
74 | case 1:
75 | if (fieldType == TType_STRING) {
76 | reason = [protocol readString];
77 | } else {
78 | [TProtocolUtil skipType: fieldType onProtocol: protocol];
79 | }
80 | break;
81 | case 2:
82 | if (fieldType == TType_I32) {
83 | type = [protocol readI32];
84 | } else {
85 | [TProtocolUtil skipType: fieldType onProtocol: protocol];
86 | }
87 | break;
88 | default:
89 | [TProtocolUtil skipType: fieldType onProtocol: protocol];
90 | break;
91 | }
92 | [protocol readFieldEnd];
93 | }
94 | [protocol readStructEnd];
95 |
96 | return [TApplicationException exceptionWithType: type reason: reason];
97 | }
98 |
99 |
100 | - (void) write: (id ) protocol
101 | {
102 | [protocol writeStructBeginWithName: @"TApplicationException"];
103 |
104 | if ([self reason] != nil) {
105 | [protocol writeFieldBeginWithName: @"message"
106 | type: TType_STRING
107 | fieldID: 1];
108 | [protocol writeString: [self reason]];
109 | [protocol writeFieldEnd];
110 | }
111 |
112 | [protocol writeFieldBeginWithName: @"type"
113 | type: TType_I32
114 | fieldID: 2];
115 | [protocol writeI32: mType];
116 | [protocol writeFieldEnd];
117 |
118 | [protocol writeFieldStop];
119 | [protocol writeStructEnd];
120 | }
121 |
122 |
123 | + (TApplicationException *) exceptionWithType: (int) type
124 | reason: (NSString *) reason
125 | {
126 | return [[[TApplicationException alloc] initWithType: type
127 | reason: reason] autorelease];
128 | }
129 |
130 | @end
131 |
--------------------------------------------------------------------------------
/src/thrift/TException.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import
21 |
22 | @interface TException : NSException {
23 | }
24 |
25 | + (id) exceptionWithName: (NSString *) name;
26 |
27 | + (id) exceptionWithName: (NSString *) name
28 | reason: (NSString *) reason;
29 |
30 | + (id) exceptionWithName: (NSString *) name
31 | reason: (NSString *) reason
32 | error: (NSError *) error;
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/src/thrift/TException.m:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import "TException.h"
21 |
22 | @implementation TException
23 |
24 | + (id) exceptionWithName: (NSString *) name
25 | {
26 | return [self exceptionWithName: name reason: @"unknown" error: nil];
27 | }
28 |
29 |
30 | + (id) exceptionWithName: (NSString *) name
31 | reason: (NSString *) reason
32 | {
33 | return [self exceptionWithName: name reason: reason error: nil];
34 | }
35 |
36 |
37 | + (id) exceptionWithName: (NSString *) name
38 | reason: (NSString *) reason
39 | error: (NSError *) error
40 | {
41 | NSDictionary * userInfo = nil;
42 | if (error != nil) {
43 | userInfo = [NSDictionary dictionaryWithObject: error forKey: @"error"];
44 | }
45 |
46 | return [super exceptionWithName: name
47 | reason: reason
48 | userInfo: userInfo];
49 | }
50 |
51 |
52 | - (NSString *) description
53 | {
54 | NSMutableString * result = [NSMutableString stringWithString: [self name]];
55 | [result appendFormat: @": %@", [self reason]];
56 | if ([self userInfo] != nil) {
57 | [result appendFormat: @"\n userInfo = %@", [self userInfo]];
58 | }
59 |
60 | return result;
61 | }
62 |
63 |
64 | @end
65 |
--------------------------------------------------------------------------------
/src/thrift/TProcessor.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import
21 | #import "TProtocol.h"
22 |
23 |
24 | @protocol TProcessor
25 |
26 | - (BOOL) processOnInputProtocol: (id ) inProtocol
27 | outputProtocol: (id ) outProtocol;
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/src/thrift/TProcessorFactory.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import
21 | #import "TProcessor.h"
22 |
23 | @protocol TProcessorFactory
24 |
25 | - (id) processorForTransport: (id) transport;
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/src/thrift/TSharedProcessorFactory.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import
21 | #import "TProcessorFactory.h"
22 |
23 | @interface TSharedProcessorFactory : NSObject {
24 | id mSharedProcessor;
25 | }
26 | - (id) initWithSharedProcessor: (id) sharedProcessor;
27 | @end
28 |
--------------------------------------------------------------------------------
/src/thrift/TSharedProcessorFactory.m:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 |
21 | #import "TSharedProcessorFactory.h"
22 |
23 |
24 | @implementation TSharedProcessorFactory
25 |
26 |
27 | - (id) initWithSharedProcessor: (id) sharedProcessor
28 | {
29 | self = [super init];
30 | if (!self) {
31 | return nil;
32 | }
33 |
34 | mSharedProcessor = [sharedProcessor retain];
35 | return self;
36 | }
37 |
38 |
39 | - (void) dealloc
40 | {
41 | [mSharedProcessor release];
42 | [super dealloc];
43 | }
44 |
45 |
46 | - (id) processorForTransport: (id) transport
47 | {
48 | return [[mSharedProcessor retain] autorelease];
49 | }
50 |
51 | @end
52 |
--------------------------------------------------------------------------------
/src/thrift/protocol/TBinaryProtocol.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import "TProtocol.h"
21 | #import "TTransport.h"
22 | #import "TProtocolFactory.h"
23 |
24 |
25 | @interface TBinaryProtocol : NSObject {
26 | id mTransport;
27 | BOOL mStrictRead;
28 | BOOL mStrictWrite;
29 | int32_t mMessageSizeLimit;
30 | }
31 |
32 | - (id) initWithTransport: (id ) transport;
33 |
34 | - (id) initWithTransport: (id ) transport
35 | strictRead: (BOOL) strictRead
36 | strictWrite: (BOOL) strictWrite;
37 |
38 | - (int32_t) messageSizeLimit;
39 | - (void) setMessageSizeLimit: (int32_t) sizeLimit;
40 |
41 | @end;
42 |
43 |
44 | @interface TBinaryProtocolFactory : NSObject {
45 | }
46 |
47 | + (TBinaryProtocolFactory *) sharedFactory;
48 |
49 | - (TBinaryProtocol *) newProtocolOnTransport: (id ) transport;
50 |
51 | @end
52 |
--------------------------------------------------------------------------------
/src/thrift/protocol/TProtocol.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import
21 |
22 | #import "TTransport.h"
23 |
24 |
25 | enum {
26 | TMessageType_CALL = 1,
27 | TMessageType_REPLY = 2,
28 | TMessageType_EXCEPTION = 3,
29 | TMessageType_ONEWAY = 4
30 | };
31 |
32 | enum {
33 | TType_STOP = 0,
34 | TType_VOID = 1,
35 | TType_BOOL = 2,
36 | TType_BYTE = 3,
37 | TType_DOUBLE = 4,
38 | TType_I16 = 6,
39 | TType_I32 = 8,
40 | TType_I64 = 10,
41 | TType_STRING = 11,
42 | TType_STRUCT = 12,
43 | TType_MAP = 13,
44 | TType_SET = 14,
45 | TType_LIST = 15
46 | };
47 |
48 |
49 | @protocol TProtocol
50 |
51 | - (id ) transport;
52 |
53 | - (void) readMessageBeginReturningName: (NSString **) name
54 | type: (int *) type
55 | sequenceID: (int *) sequenceID;
56 | - (void) readMessageEnd;
57 |
58 | - (void) readStructBeginReturningName: (NSString **) name;
59 | - (void) readStructEnd;
60 |
61 | - (void) readFieldBeginReturningName: (NSString **) name
62 | type: (int *) fieldType
63 | fieldID: (int *) fieldID;
64 | - (void) readFieldEnd;
65 |
66 | - (NSString *) readString;
67 |
68 | - (BOOL) readBool;
69 |
70 | - (unsigned char) readByte;
71 |
72 | - (short) readI16;
73 |
74 | - (int32_t) readI32;
75 |
76 | - (int64_t) readI64;
77 |
78 | - (double) readDouble;
79 |
80 | - (NSData *) readBinary;
81 |
82 | - (void) readMapBeginReturningKeyType: (int *) keyType
83 | valueType: (int *) valueType
84 | size: (int *) size;
85 | - (void) readMapEnd;
86 |
87 |
88 | - (void) readSetBeginReturningElementType: (int *) elementType
89 | size: (int *) size;
90 | - (void) readSetEnd;
91 |
92 |
93 | - (void) readListBeginReturningElementType: (int *) elementType
94 | size: (int *) size;
95 | - (void) readListEnd;
96 |
97 |
98 | - (void) writeMessageBeginWithName: (NSString *) name
99 | type: (int) messageType
100 | sequenceID: (int) sequenceID;
101 | - (void) writeMessageEnd;
102 |
103 | - (void) writeStructBeginWithName: (NSString *) name;
104 | - (void) writeStructEnd;
105 |
106 | - (void) writeFieldBeginWithName: (NSString *) name
107 | type: (int) fieldType
108 | fieldID: (int) fieldID;
109 |
110 | - (void) writeI32: (int32_t) value;
111 |
112 | - (void) writeI64: (int64_t) value;
113 |
114 | - (void) writeI16: (short) value;
115 |
116 | - (void) writeByte: (uint8_t) value;
117 |
118 | - (void) writeString: (NSString *) value;
119 |
120 | - (void) writeDouble: (double) value;
121 |
122 | - (void) writeBool: (BOOL) value;
123 |
124 | - (void) writeBinary: (NSData *) data;
125 |
126 | - (void) writeFieldStop;
127 |
128 | - (void) writeFieldEnd;
129 |
130 | - (void) writeMapBeginWithKeyType: (int) keyType
131 | valueType: (int) valueType
132 | size: (int) size;
133 | - (void) writeMapEnd;
134 |
135 |
136 | - (void) writeSetBeginWithElementType: (int) elementType
137 | size: (int) size;
138 | - (void) writeSetEnd;
139 |
140 |
141 | - (void) writeListBeginWithElementType: (int) elementType
142 | size: (int) size;
143 |
144 | - (void) writeListEnd;
145 |
146 |
147 | @end
148 |
149 |
--------------------------------------------------------------------------------
/src/thrift/protocol/TProtocolException.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import "TException.h"
21 |
22 | @interface TProtocolException : TException {
23 | }
24 |
25 | @end
26 |
--------------------------------------------------------------------------------
/src/thrift/protocol/TProtocolException.m:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import "TProtocolException.h"
21 |
22 | @implementation TProtocolException
23 | @end
24 |
--------------------------------------------------------------------------------
/src/thrift/protocol/TProtocolFactory.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import
21 | #import "TProtocol.h"
22 | #import "TTransport.h"
23 |
24 |
25 | @protocol TProtocolFactory
26 |
27 | - (id ) newProtocolOnTransport: (id ) transport;
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/src/thrift/protocol/TProtocolUtil.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import "TProtocol.h"
21 | #import "TTransport.h"
22 |
23 | @interface TProtocolUtil : NSObject {
24 |
25 | }
26 |
27 | + (void) skipType: (int) type onProtocol: (id ) protocol;
28 |
29 | @end;
30 |
--------------------------------------------------------------------------------
/src/thrift/protocol/TProtocolUtil.m:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import "TProtocolUtil.h"
21 |
22 | @implementation TProtocolUtil
23 |
24 | + (void) skipType: (int) type onProtocol: (id ) protocol
25 | {
26 | switch (type) {
27 | case TType_BOOL:
28 | [protocol readBool];
29 | break;
30 | case TType_BYTE:
31 | [protocol readByte];
32 | break;
33 | case TType_I16:
34 | [protocol readI16];
35 | break;
36 | case TType_I32:
37 | [protocol readI32];
38 | break;
39 | case TType_I64:
40 | [protocol readI64];
41 | break;
42 | case TType_DOUBLE:
43 | [protocol readDouble];
44 | break;
45 | case TType_STRING:
46 | [protocol readString];
47 | break;
48 | case TType_STRUCT:
49 | [protocol readStructBeginReturningName: NULL];
50 | while (true) {
51 | int fieldType;
52 | [protocol readFieldBeginReturningName: nil type: &fieldType fieldID: nil];
53 | if (fieldType == TType_STOP) {
54 | break;
55 | }
56 | [TProtocolUtil skipType: fieldType onProtocol: protocol];
57 | [protocol readFieldEnd];
58 | }
59 | [protocol readStructEnd];
60 | break;
61 | case TType_MAP:
62 | {
63 | int keyType;
64 | int valueType;
65 | int size;
66 | [protocol readMapBeginReturningKeyType: &keyType valueType: &valueType size: &size];
67 | int i;
68 | for (i = 0; i < size; i++) {
69 | [TProtocolUtil skipType: keyType onProtocol: protocol];
70 | [TProtocolUtil skipType: valueType onProtocol: protocol];
71 | }
72 | [protocol readMapEnd];
73 | }
74 | break;
75 | case TType_SET:
76 | {
77 | int elemType;
78 | int size;
79 | [protocol readSetBeginReturningElementType: &elemType size: &size];
80 | int i;
81 | for (i = 0; i < size; i++) {
82 | [TProtocolUtil skipType: elemType onProtocol: protocol];
83 | }
84 | [protocol readSetEnd];
85 | }
86 | break;
87 | case TType_LIST:
88 | {
89 | int elemType;
90 | int size;
91 | [protocol readListBeginReturningElementType: &elemType size: &size];
92 | int i;
93 | for (i = 0; i < size; i++) {
94 | [TProtocolUtil skipType: elemType onProtocol: protocol];
95 | }
96 | [protocol readListEnd];
97 | }
98 | break;
99 | default:
100 | return;
101 | }
102 | }
103 |
104 | @end
105 |
--------------------------------------------------------------------------------
/src/thrift/transport/THTTPClient.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import
21 | #import "TTransport.h"
22 |
23 | @interface THTTPClient : NSObject {
24 | NSURL * mURL;
25 | NSMutableURLRequest * mRequest;
26 | NSMutableData * mRequestData;
27 | NSData * mResponseData;
28 | int mResponseDataOffset;
29 | NSString * mUserAgent;
30 | int mTimeout;
31 | }
32 |
33 | - (id) initWithURL: (NSURL *) aURL;
34 |
35 | - (id) initWithURL: (NSURL *) aURL
36 | userAgent: (NSString *) userAgent
37 | timeout: (int) timeout;
38 |
39 | - (void) setURL: (NSURL *) aURL;
40 |
41 | @end
42 |
43 |
--------------------------------------------------------------------------------
/src/thrift/transport/TMemoryBuffer.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import
21 | #import "TTransport.h"
22 |
23 | @interface TMemoryBuffer : NSObject {
24 | NSMutableData *mBuffer;
25 | NSUInteger mOffset;
26 | }
27 | - (id)initWithData:(NSData *)data;
28 | - (NSData *)getBuffer;
29 | @end
30 |
--------------------------------------------------------------------------------
/src/thrift/transport/TMemoryBuffer.m:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import "TMemoryBuffer.h"
21 | #import "TTransportException.h"
22 |
23 | #define GARBAGE_BUFFER_SIZE 4096 // 4KiB
24 |
25 | @implementation TMemoryBuffer
26 | - (id)init {
27 | if (self = [super init]) {
28 | mBuffer = [[NSMutableData alloc] init];
29 | mOffset = 0;
30 | }
31 | return self;
32 | }
33 |
34 | - (id)initWithData:(NSData *)data {
35 | if (self = [super init]) {
36 | mBuffer = [data mutableCopy];
37 | mOffset = 0;
38 | }
39 | return self;
40 | }
41 |
42 | - (int)readAll:(uint8_t *)buf offset:(int)off length:(int)len {
43 | if ([mBuffer length] - mOffset < len) {
44 | @throw [TTransportException exceptionWithReason:@"Not enough bytes remain in buffer"];
45 | }
46 | [mBuffer getBytes:buf range:NSMakeRange(mOffset, len)];
47 | mOffset += len;
48 | if (mOffset >= GARBAGE_BUFFER_SIZE) {
49 | [mBuffer replaceBytesInRange:NSMakeRange(0, mOffset) withBytes:NULL length:0];
50 | mOffset = 0;
51 | }
52 | return len;
53 | }
54 |
55 | - (void)write:(const uint8_t *)data offset:(unsigned int)offset length:(unsigned int)length {
56 | [mBuffer appendBytes:data+offset length:length];
57 | }
58 |
59 | - (void)flush {
60 | // noop
61 | }
62 |
63 | - (NSData *)getBuffer {
64 | return [[mBuffer copy] autorelease];
65 | }
66 |
67 | - (void)dealloc {
68 | [mBuffer release];
69 | [super dealloc];
70 | }
71 | @end
72 |
--------------------------------------------------------------------------------
/src/thrift/transport/TTransport.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | @protocol TTransport
21 |
22 | /**
23 | * Guarantees that all of len bytes are read
24 | *
25 | * @param buf Buffer to read into
26 | * @param off Index in buffer to start storing bytes at
27 | * @param len Maximum number of bytes to read
28 | * @return The number of bytes actually read, which must be equal to len
29 | * @throws TTransportException if there was an error reading data
30 | */
31 | - (int) readAll: (uint8_t *) buf offset: (int) off length: (int) len;
32 |
33 | - (void) write: (const uint8_t *) data offset: (unsigned int) offset length: (unsigned int) length;
34 |
35 | - (void) flush;
36 | @end
37 |
--------------------------------------------------------------------------------
/src/thrift/transport/TTransportException.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import "TException.h"
21 |
22 | @interface TTransportException : TException {
23 | }
24 |
25 | + (id) exceptionWithReason: (NSString *) reason
26 | error: (NSError *) error;
27 |
28 | + (id) exceptionWithReason: (NSString *) reason;
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/src/thrift/transport/TTransportException.m:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | #import "TTransportException.h"
21 |
22 | @implementation TTransportException
23 |
24 | + (id) exceptionWithReason: (NSString *) reason
25 | error: (NSError *) error
26 | {
27 | NSDictionary * userInfo = nil;
28 | if (error != nil) {
29 | userInfo = [NSDictionary dictionaryWithObject: error forKey: @"error"];
30 | }
31 |
32 | return [super exceptionWithName: @"TTransportException"
33 | reason: reason
34 | userInfo: userInfo];
35 | }
36 |
37 |
38 | + (id) exceptionWithReason: (NSString *) reason
39 | {
40 | return [self exceptionWithReason: reason error: nil];
41 | }
42 |
43 | @end
44 |
--------------------------------------------------------------------------------