├── .gitignore ├── ESSVideoShare.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── matthias.xcuserdatad │ │ └── WorkspaceSettings.xcsettings └── xcuserdata │ └── matthias.xcuserdatad │ └── xcschemes │ ├── ESSVideoShare.xcscheme │ └── xcschememanagement.plist ├── ESSVideoShare ├── Base64Transcoder.c ├── Base64Transcoder.h ├── ESSFacebook.h ├── ESSFacebook.m ├── ESSFacebookWindow.xib ├── ESSFacebookWindowController.h ├── ESSFacebookWindowController.m ├── ESSFacebookiOSLoginView_iPad.xib ├── ESSFacebookiOSLoginView_iPhone.xib ├── ESSFacebookiOSViewController.h ├── ESSFacebookiOSViewController.m ├── ESSFlickr.h ├── ESSFlickr.m ├── ESSFlickrWindow.xib ├── ESSFlickrWindowController.h ├── ESSFlickrWindowController.m ├── ESSFlickriOSViewController.h ├── ESSFlickriOSViewController.m ├── ESSFlickriOSView_iPad.xib ├── ESSFlickriOSView_iPhone.xib ├── ESSVideoShare-Info.plist ├── ESSVideoShare-Prefix.pch ├── ESSVideoShare.h ├── ESSVimeo.h ├── ESSVimeo.m ├── ESSVimeoWindowController.h ├── ESSVimeoWindowController.m ├── ESSVimeoiOSViewController.h ├── ESSVimeoiOSViewController.m ├── ESSVimeoiOSView_iPad.xib ├── ESSVimeoiOSView_iPhone.xib ├── ESSYouTube.h ├── ESSYouTube.m ├── ESSYouTubeWindow.xib ├── ESSYouTubeWindowController.h ├── ESSYouTubeWindowController.m ├── ESSYouTubeiOSViewController.h ├── ESSYouTubeiOSViewController.m ├── ESSYouTubeiOSView_iPad.xib ├── ESSYouTubeiOSView_iPhone.xib ├── Flickr_Progress.tiff ├── Localizable.strings ├── NSMutableURLRequest+Parameters.h ├── NSMutableURLRequest+Parameters.m ├── NSString+URLEncoding.h ├── NSString+URLEncoding.m ├── NSURL+Base.h ├── NSURL+Base.m ├── OAAsynchronousDataFetcher.h ├── OAAsynchronousDataFetcher.m ├── OAConsumer.h ├── OAConsumer.m ├── OADataFetcher.h ├── OADataFetcher.m ├── OAHMAC_SHA1SignatureProvider.h ├── OAHMAC_SHA1SignatureProvider.m ├── OAMutableURLRequest.h ├── OAMutableURLRequest.m ├── OAPlaintextSignatureProvider.h ├── OAPlaintextSignatureProvider.m ├── OARequestParameter.h ├── OARequestParameter.m ├── OAServiceTicket.h ├── OAServiceTicket.m ├── OASignatureProviding.h ├── OATestServer.rb ├── OAToken.h ├── OAToken.m ├── OAToken_KeychainExtensions.h ├── OAToken_KeychainExtensions.m ├── OAuthConsumer.h ├── OAuthConsumer_Prefix.pch ├── Vimeo.png ├── en.lproj │ └── InfoPlist.strings ├── essvimeoWindow.xib ├── fb.png └── publish-youtube.tif └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | ESSVideoShare.xcodeproj/project.xcworkspace/xcuserdata/matthias.xcuserdatad/UserInterfaceState.xcuserstate 3 | -------------------------------------------------------------------------------- /ESSVideoShare.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ESSVideoShare.xcodeproj/project.xcworkspace/xcuserdata/matthias.xcuserdatad/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEWorkspaceUserSettings_HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges 6 | 7 | IDEWorkspaceUserSettings_SnapshotAutomaticallyBeforeSignificantChanges 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ESSVideoShare.xcodeproj/xcuserdata/matthias.xcuserdatad/xcschemes/ESSVideoShare.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 42 | 43 | 44 | 45 | 51 | 52 | 54 | 55 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /ESSVideoShare.xcodeproj/xcuserdata/matthias.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ESSVideoShare.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 393EC2191482702000F7074A 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /ESSVideoShare/Base64Transcoder.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Base64Transcoder.c 3 | * Base64Test 4 | * 5 | * Created by Jonathan Wight on Tue Mar 18 2003. 6 | * Copyright (c) 2003 Toxic Software. All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | * 26 | */ 27 | 28 | #include "Base64Transcoder.h" 29 | 30 | #include 31 | #include 32 | 33 | const u_int8_t kBase64EncodeTable[64] = { 34 | /* 0 */ 'A', /* 1 */ 'B', /* 2 */ 'C', /* 3 */ 'D', 35 | /* 4 */ 'E', /* 5 */ 'F', /* 6 */ 'G', /* 7 */ 'H', 36 | /* 8 */ 'I', /* 9 */ 'J', /* 10 */ 'K', /* 11 */ 'L', 37 | /* 12 */ 'M', /* 13 */ 'N', /* 14 */ 'O', /* 15 */ 'P', 38 | /* 16 */ 'Q', /* 17 */ 'R', /* 18 */ 'S', /* 19 */ 'T', 39 | /* 20 */ 'U', /* 21 */ 'V', /* 22 */ 'W', /* 23 */ 'X', 40 | /* 24 */ 'Y', /* 25 */ 'Z', /* 26 */ 'a', /* 27 */ 'b', 41 | /* 28 */ 'c', /* 29 */ 'd', /* 30 */ 'e', /* 31 */ 'f', 42 | /* 32 */ 'g', /* 33 */ 'h', /* 34 */ 'i', /* 35 */ 'j', 43 | /* 36 */ 'k', /* 37 */ 'l', /* 38 */ 'm', /* 39 */ 'n', 44 | /* 40 */ 'o', /* 41 */ 'p', /* 42 */ 'q', /* 43 */ 'r', 45 | /* 44 */ 's', /* 45 */ 't', /* 46 */ 'u', /* 47 */ 'v', 46 | /* 48 */ 'w', /* 49 */ 'x', /* 50 */ 'y', /* 51 */ 'z', 47 | /* 52 */ '0', /* 53 */ '1', /* 54 */ '2', /* 55 */ '3', 48 | /* 56 */ '4', /* 57 */ '5', /* 58 */ '6', /* 59 */ '7', 49 | /* 60 */ '8', /* 61 */ '9', /* 62 */ '+', /* 63 */ '/' 50 | }; 51 | 52 | /* 53 | -1 = Base64 end of data marker. 54 | -2 = White space (tabs, cr, lf, space) 55 | -3 = Noise (all non whitespace, non-base64 characters) 56 | -4 = Dangerous noise 57 | -5 = Illegal noise (null byte) 58 | */ 59 | 60 | const int8_t kBase64DecodeTable[128] = { 61 | /* 0x00 */ -5, /* 0x01 */ -3, /* 0x02 */ -3, /* 0x03 */ -3, 62 | /* 0x04 */ -3, /* 0x05 */ -3, /* 0x06 */ -3, /* 0x07 */ -3, 63 | /* 0x08 */ -3, /* 0x09 */ -2, /* 0x0a */ -2, /* 0x0b */ -2, 64 | /* 0x0c */ -2, /* 0x0d */ -2, /* 0x0e */ -3, /* 0x0f */ -3, 65 | /* 0x10 */ -3, /* 0x11 */ -3, /* 0x12 */ -3, /* 0x13 */ -3, 66 | /* 0x14 */ -3, /* 0x15 */ -3, /* 0x16 */ -3, /* 0x17 */ -3, 67 | /* 0x18 */ -3, /* 0x19 */ -3, /* 0x1a */ -3, /* 0x1b */ -3, 68 | /* 0x1c */ -3, /* 0x1d */ -3, /* 0x1e */ -3, /* 0x1f */ -3, 69 | /* ' ' */ -2, /* '!' */ -3, /* '"' */ -3, /* '#' */ -3, 70 | /* '$' */ -3, /* '%' */ -3, /* '&' */ -3, /* ''' */ -3, 71 | /* '(' */ -3, /* ')' */ -3, /* '*' */ -3, /* '+' */ 62, 72 | /* ',' */ -3, /* '-' */ -3, /* '.' */ -3, /* '/' */ 63, 73 | /* '0' */ 52, /* '1' */ 53, /* '2' */ 54, /* '3' */ 55, 74 | /* '4' */ 56, /* '5' */ 57, /* '6' */ 58, /* '7' */ 59, 75 | /* '8' */ 60, /* '9' */ 61, /* ':' */ -3, /* ';' */ -3, 76 | /* '<' */ -3, /* '=' */ -1, /* '>' */ -3, /* '?' */ -3, 77 | /* '@' */ -3, /* 'A' */ 0, /* 'B' */ 1, /* 'C' */ 2, 78 | /* 'D' */ 3, /* 'E' */ 4, /* 'F' */ 5, /* 'G' */ 6, 79 | /* 'H' */ 7, /* 'I' */ 8, /* 'J' */ 9, /* 'K' */ 10, 80 | /* 'L' */ 11, /* 'M' */ 12, /* 'N' */ 13, /* 'O' */ 14, 81 | /* 'P' */ 15, /* 'Q' */ 16, /* 'R' */ 17, /* 'S' */ 18, 82 | /* 'T' */ 19, /* 'U' */ 20, /* 'V' */ 21, /* 'W' */ 22, 83 | /* 'X' */ 23, /* 'Y' */ 24, /* 'Z' */ 25, /* '[' */ -3, 84 | /* '\' */ -3, /* ']' */ -3, /* '^' */ -3, /* '_' */ -3, 85 | /* '`' */ -3, /* 'a' */ 26, /* 'b' */ 27, /* 'c' */ 28, 86 | /* 'd' */ 29, /* 'e' */ 30, /* 'f' */ 31, /* 'g' */ 32, 87 | /* 'h' */ 33, /* 'i' */ 34, /* 'j' */ 35, /* 'k' */ 36, 88 | /* 'l' */ 37, /* 'm' */ 38, /* 'n' */ 39, /* 'o' */ 40, 89 | /* 'p' */ 41, /* 'q' */ 42, /* 'r' */ 43, /* 's' */ 44, 90 | /* 't' */ 45, /* 'u' */ 46, /* 'v' */ 47, /* 'w' */ 48, 91 | /* 'x' */ 49, /* 'y' */ 50, /* 'z' */ 51, /* '{' */ -3, 92 | /* '|' */ -3, /* '}' */ -3, /* '~' */ -3, /* 0x7f */ -3 93 | }; 94 | 95 | const u_int8_t kBits_00000011 = 0x03; 96 | const u_int8_t kBits_00001111 = 0x0F; 97 | const u_int8_t kBits_00110000 = 0x30; 98 | const u_int8_t kBits_00111100 = 0x3C; 99 | const u_int8_t kBits_00111111 = 0x3F; 100 | const u_int8_t kBits_11000000 = 0xC0; 101 | const u_int8_t kBits_11110000 = 0xF0; 102 | const u_int8_t kBits_11111100 = 0xFC; 103 | 104 | size_t EstimateBas64EncodedDataSize(size_t inDataSize) 105 | { 106 | size_t theEncodedDataSize = (int)ceil(inDataSize / 3.0) * 4; 107 | theEncodedDataSize = theEncodedDataSize / 72 * 74 + theEncodedDataSize % 72; 108 | return(theEncodedDataSize); 109 | } 110 | 111 | size_t EstimateBas64DecodedDataSize(size_t inDataSize) 112 | { 113 | size_t theDecodedDataSize = (int)ceil(inDataSize / 4.0) * 3; 114 | //theDecodedDataSize = theDecodedDataSize / 72 * 74 + theDecodedDataSize % 72; 115 | return(theDecodedDataSize); 116 | } 117 | 118 | bool Base64EncodeData(const void *inInputData, size_t inInputDataSize, char *outOutputData, size_t *ioOutputDataSize) 119 | { 120 | size_t theEncodedDataSize = EstimateBas64EncodedDataSize(inInputDataSize); 121 | if (*ioOutputDataSize < theEncodedDataSize) 122 | return(false); 123 | *ioOutputDataSize = theEncodedDataSize; 124 | const u_int8_t *theInPtr = (const u_int8_t *)inInputData; 125 | u_int32_t theInIndex = 0, theOutIndex = 0; 126 | for (; theInIndex < (inInputDataSize / 3) * 3; theInIndex += 3) 127 | { 128 | outOutputData[theOutIndex++] = kBase64EncodeTable[(theInPtr[theInIndex] & kBits_11111100) >> 2]; 129 | outOutputData[theOutIndex++] = kBase64EncodeTable[(theInPtr[theInIndex] & kBits_00000011) << 4 | (theInPtr[theInIndex + 1] & kBits_11110000) >> 4]; 130 | outOutputData[theOutIndex++] = kBase64EncodeTable[(theInPtr[theInIndex + 1] & kBits_00001111) << 2 | (theInPtr[theInIndex + 2] & kBits_11000000) >> 6]; 131 | outOutputData[theOutIndex++] = kBase64EncodeTable[(theInPtr[theInIndex + 2] & kBits_00111111) >> 0]; 132 | if (theOutIndex % 74 == 72) 133 | { 134 | outOutputData[theOutIndex++] = '\r'; 135 | outOutputData[theOutIndex++] = '\n'; 136 | } 137 | } 138 | const size_t theRemainingBytes = inInputDataSize - theInIndex; 139 | if (theRemainingBytes == 1) 140 | { 141 | outOutputData[theOutIndex++] = kBase64EncodeTable[(theInPtr[theInIndex] & kBits_11111100) >> 2]; 142 | outOutputData[theOutIndex++] = kBase64EncodeTable[(theInPtr[theInIndex] & kBits_00000011) << 4 | (0 & kBits_11110000) >> 4]; 143 | outOutputData[theOutIndex++] = '='; 144 | outOutputData[theOutIndex++] = '='; 145 | if (theOutIndex % 74 == 72) 146 | { 147 | outOutputData[theOutIndex++] = '\r'; 148 | outOutputData[theOutIndex++] = '\n'; 149 | } 150 | } 151 | else if (theRemainingBytes == 2) 152 | { 153 | outOutputData[theOutIndex++] = kBase64EncodeTable[(theInPtr[theInIndex] & kBits_11111100) >> 2]; 154 | outOutputData[theOutIndex++] = kBase64EncodeTable[(theInPtr[theInIndex] & kBits_00000011) << 4 | (theInPtr[theInIndex + 1] & kBits_11110000) >> 4]; 155 | outOutputData[theOutIndex++] = kBase64EncodeTable[(theInPtr[theInIndex + 1] & kBits_00001111) << 2 | (0 & kBits_11000000) >> 6]; 156 | outOutputData[theOutIndex++] = '='; 157 | if (theOutIndex % 74 == 72) 158 | { 159 | outOutputData[theOutIndex++] = '\r'; 160 | outOutputData[theOutIndex++] = '\n'; 161 | } 162 | } 163 | return(true); 164 | } 165 | 166 | bool Base64DecodeData(const void *inInputData, size_t inInputDataSize, void *ioOutputData, size_t *ioOutputDataSize) 167 | { 168 | memset(ioOutputData, '.', *ioOutputDataSize); 169 | 170 | size_t theDecodedDataSize = EstimateBas64DecodedDataSize(inInputDataSize); 171 | if (*ioOutputDataSize < theDecodedDataSize) 172 | return(false); 173 | *ioOutputDataSize = 0; 174 | const u_int8_t *theInPtr = (const u_int8_t *)inInputData; 175 | u_int8_t *theOutPtr = (u_int8_t *)ioOutputData; 176 | size_t theInIndex = 0, theOutIndex = 0; 177 | u_int8_t theOutputOctet; 178 | size_t theSequence = 0; 179 | for (; theInIndex < inInputDataSize; ) 180 | { 181 | int8_t theSextet = 0; 182 | 183 | int8_t theCurrentInputOctet = theInPtr[theInIndex]; 184 | theSextet = kBase64DecodeTable[theCurrentInputOctet]; 185 | if (theSextet == -1) 186 | break; 187 | while (theSextet == -2) 188 | { 189 | theCurrentInputOctet = theInPtr[++theInIndex]; 190 | theSextet = kBase64DecodeTable[theCurrentInputOctet]; 191 | } 192 | while (theSextet == -3) 193 | { 194 | theCurrentInputOctet = theInPtr[++theInIndex]; 195 | theSextet = kBase64DecodeTable[theCurrentInputOctet]; 196 | } 197 | if (theSequence == 0) 198 | { 199 | theOutputOctet = (theSextet >= 0 ? theSextet : 0) << 2 & kBits_11111100; 200 | } 201 | else if (theSequence == 1) 202 | { 203 | theOutputOctet |= (theSextet >- 0 ? theSextet : 0) >> 4 & kBits_00000011; 204 | theOutPtr[theOutIndex++] = theOutputOctet; 205 | } 206 | else if (theSequence == 2) 207 | { 208 | theOutputOctet = (theSextet >= 0 ? theSextet : 0) << 4 & kBits_11110000; 209 | } 210 | else if (theSequence == 3) 211 | { 212 | theOutputOctet |= (theSextet >= 0 ? theSextet : 0) >> 2 & kBits_00001111; 213 | theOutPtr[theOutIndex++] = theOutputOctet; 214 | } 215 | else if (theSequence == 4) 216 | { 217 | theOutputOctet = (theSextet >= 0 ? theSextet : 0) << 6 & kBits_11000000; 218 | } 219 | else if (theSequence == 5) 220 | { 221 | theOutputOctet |= (theSextet >= 0 ? theSextet : 0) >> 0 & kBits_00111111; 222 | theOutPtr[theOutIndex++] = theOutputOctet; 223 | } 224 | theSequence = (theSequence + 1) % 6; 225 | if (theSequence != 2 && theSequence != 4) 226 | theInIndex++; 227 | } 228 | *ioOutputDataSize = theOutIndex; 229 | return(true); 230 | } 231 | -------------------------------------------------------------------------------- /ESSVideoShare/Base64Transcoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Base64Transcoder.h 3 | * Base64Test 4 | * 5 | * Created by Jonathan Wight on Tue Mar 18 2003. 6 | * Copyright (c) 2003 Toxic Software. All rights reserved. 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | * 26 | */ 27 | 28 | #include 29 | #include 30 | 31 | extern size_t EstimateBas64EncodedDataSize(size_t inDataSize); 32 | extern size_t EstimateBas64DecodedDataSize(size_t inDataSize); 33 | 34 | extern bool Base64EncodeData(const void *inInputData, size_t inInputDataSize, char *outOutputData, size_t *ioOutputDataSize); 35 | extern bool Base64DecodeData(const void *inInputData, size_t inInputDataSize, void *ioOutputData, size_t *ioOutputDataSize); 36 | 37 | -------------------------------------------------------------------------------- /ESSVideoShare/ESSFacebook.h: -------------------------------------------------------------------------------- 1 | // 2 | // ESSFacebook.h 3 | // FacebookMac 4 | // 5 | // Created by Matthias Gansrigler on 29.10.11. 6 | // Copyright (c) 2011 Eternal Storms Software. All rights reserved. 7 | // 8 | 9 | #import 10 | #if (!TARGET_OS_IPHONE && !TARGET_OS_EMBEDDED && !TARGET_IPHONE_SIMULATOR) 11 | #import "ESSFacebookWindowController.h" 12 | #else 13 | #import "ESSFacebookiOSViewController.h" 14 | #endif 15 | 16 | #define ESSLocalizedString(key, comment) NSLocalizedStringFromTableInBundle((key),nil,[NSBundle bundleForClass:[self class]],(comment)) 17 | 18 | @class ESSFacebook; 19 | 20 | @protocol ESSFacebookDelegate 21 | 22 | @required 23 | #if (!TARGET_OS_IPHONE && !TARGET_OS_EMBEDDED && !TARGET_IPHONE_SIMULATOR) 24 | - (NSWindow *)ESSFacebookNeedsWindowToAttachTo:(ESSFacebook *)facebook; 25 | #else 26 | - (UIViewController *)ESSFacebookNeedsCurrentViewControllerToAttachTo:(ESSFacebook *)facebook; 27 | #endif 28 | 29 | @optional 30 | - (void)ESSFacebookDidUploadVideoWithFacebookURL:(NSURL *)url; 31 | - (void)ESSFacebookDidFinish:(ESSFacebook *)fb; //sent so user of this class can release their fb object 32 | 33 | @end 34 | 35 | #if (!TARGET_OS_IPHONE && !TARGET_OS_EMBEDDED && !TARGET_IPHONE_SIMULATOR) 36 | @interface ESSFacebook : NSObject 37 | #else 38 | @interface ESSFacebook : NSObject 39 | #endif 40 | 41 | @property (assign) id delegate; 42 | @property (retain) NSURLConnection *_uploader; 43 | @property (retain) NSString *appID; 44 | @property (retain) NSString *appSecret; 45 | @property (retain) NSString *_uploadedObjectID; 46 | #if (!TARGET_OS_IPHONE && !TARGET_OS_EMBEDDED && !TARGET_IPHONE_SIMULATOR) 47 | @property (retain) ESSFacebookWindowController *_fbWinCtr; 48 | #else 49 | @property (retain) ESSFacebookiOSViewController *_fbViewCtr; 50 | #endif 51 | @property (retain) NSMutableData *_receivedData; 52 | 53 | @property (retain) NSString *_accessToken; 54 | @property (retain) NSString *_username; 55 | 56 | - (id)initWithDelegate:(id)del 57 | appID:(NSString *)anID 58 | appSecret:(NSString *)secret; 59 | 60 | - (void)uploadVideoAtURL:(NSURL *)videoURL; 61 | 62 | //private 63 | - (void)_authorize; //checks if we have a token in defaults. if so, use that. if not, open up authorize webview 64 | - (void)_deauthorize; 65 | - (void)_uploadVideoAtURL:(NSURL *)videoURL 66 | title:(NSString *)title 67 | description:(NSString *)description 68 | isPrivate:(BOOL)isPrivate; 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /ESSVideoShare/ESSFacebookWindowController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ESSFacebookLoginWindowController.h 3 | // FacebookMac 4 | // 5 | // Created by Matthias Gansrigler on 29.10.11. 6 | // Copyright (c) 2011 Eternal Storms Software. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @class ESSFacebookWindowController; 13 | 14 | @protocol ESSFacebookWindowControllerDelegate 15 | 16 | @required 17 | - (void)facebookLogin:(ESSFacebookWindowController *)login returnedAccessToken:(NSString *)token expirationDate:(NSDate *)expDate; 18 | 19 | @end 20 | 21 | @interface ESSFacebookWindowController : NSWindowController 22 | 23 | @property (retain) IBOutlet WebView *webView; 24 | @property (assign) IBOutlet NSButton *uploadButton; 25 | @property (retain) IBOutlet NSView *uploadView; 26 | @property (assign) IBOutlet NSTextField *usernameField; 27 | @property (assign) IBOutlet NSTextField *titleField; 28 | @property (assign) IBOutlet NSTextField *descriptionField; 29 | @property (assign) IBOutlet NSButton *makePrivateButton; 30 | @property (assign) IBOutlet NSProgressIndicator *uploadProgressBar; 31 | @property (assign) IBOutlet NSTextField *uploadProgressField; 32 | @property (assign) IBOutlet NSView *uploadProgressView; 33 | @property (assign) IBOutlet NSView *uploadResultView; 34 | @property (assign) IBOutlet NSImageView *resultImageView; 35 | @property (assign) IBOutlet NSTextField *resultTextField; 36 | @property (assign) IBOutlet NSButton *cancelButton; 37 | @property (assign) IBOutlet NSButton *viewOnFBButton; 38 | 39 | @property (assign) id delegate; 40 | @property (assign) BOOL reactToCancel; 41 | @property (retain) NSString *appID; 42 | @property (retain) NSMutableArray *temporaryCookies; 43 | @property (retain) NSURL *videoURL; 44 | 45 | - (id)initWithDelegate:(id)del appID:(NSString *)appIDString videoURL:(NSURL *)url; 46 | 47 | - (void)openAuthorizationURLWithAppID:(NSString *)anID; 48 | 49 | - (void)switchToUploadViewWithAnimation:(BOOL)shouldAnimate; 50 | - (void)switchToLoginViewWithAnimation:(BOOL)shouldAnimate; 51 | 52 | - (IBAction)cancel:(id)sender; 53 | - (IBAction)changeAccount:(id)sender; 54 | - (IBAction)startUpload:(id)sender; 55 | - (IBAction)viewOnFacebook:(id)sender; 56 | 57 | - (void)temporarilyDeleteFacebookCookies; 58 | - (void)restoreTemporarilyDeletedFacebookCookies; 59 | 60 | - (void)uploadStarted; 61 | - (void)uploadUpdatedWithBytes:(NSInteger)bytesUploaded ofTotalBytes:(NSInteger)totalBytes; 62 | - (void)uploadFinishedWithFacebookVideoURL:(NSURL *)url; 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /ESSVideoShare/ESSFacebookWindowController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ESSFacebookLoginWindowController.m 3 | // FacebookMac 4 | // 5 | // Created by Matthias Gansrigler on 29.10.11. 6 | // Copyright (c) 2011 Eternal Storms Software. All rights reserved. 7 | // 8 | 9 | #import "ESSFacebookWindowController.h" 10 | #import "ESSFacebook.h" 11 | 12 | @implementation ESSFacebookWindowController 13 | @synthesize uploadButton; 14 | @synthesize uploadView; 15 | @synthesize usernameField; 16 | @synthesize titleField; 17 | @synthesize descriptionField; 18 | @synthesize makePrivateButton; 19 | @synthesize uploadProgressBar; 20 | @synthesize uploadProgressField; 21 | @synthesize uploadProgressView; 22 | @synthesize uploadResultView; 23 | @synthesize resultImageView; 24 | @synthesize resultTextField; 25 | @synthesize cancelButton; 26 | @synthesize viewOnFBButton; 27 | @synthesize webView,delegate,reactToCancel,appID; 28 | @synthesize temporaryCookies,videoURL; 29 | 30 | - (id)initWithDelegate:(id)del appID:(NSString *)appIDString videoURL:(NSURL *)url 31 | { 32 | if (self = [super initWithWindowNibName:@"ESSFacebookWindow"]) 33 | { 34 | self.delegate = del; 35 | self.appID = appIDString; 36 | self.videoURL = url; 37 | 38 | return self; 39 | } 40 | 41 | return nil; 42 | } 43 | 44 | - (void)windowDidLoad 45 | { 46 | [super windowDidLoad]; 47 | 48 | // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. 49 | } 50 | 51 | - (void)awakeFromNib 52 | { 53 | self.window.delegate = self; 54 | } 55 | 56 | - (void)windowWillClose:(NSNotification *)notification 57 | { 58 | double delayInSeconds = 0.65; 59 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); 60 | dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ 61 | [NSApp endSheet:self.window]; 62 | }); 63 | } 64 | 65 | - (void)switchToUploadViewWithAnimation:(BOOL)shouldAnimate 66 | { 67 | [self.webView removeFromSuperview]; 68 | self.uploadButton.alphaValue = 0.0; 69 | [self.uploadButton setHidden:NO]; 70 | [self.uploadButton setEnabled:YES]; 71 | 72 | if (!shouldAnimate) 73 | { 74 | self.cancelButton.alphaValue = 1.0; 75 | self.uploadButton.alphaValue = 1.0; 76 | [self.window setFrame:NSMakeRect(self.window.frame.origin.x, self.window.frame.origin.y, self.window.frame.size.width, self.uploadView.frame.size.height+67+48+22/*titlebarheight*/) display:YES]; 77 | self.uploadView.frame = NSMakeRect(0, 48, self.window.frame.size.width, self.uploadView.frame.size.height); 78 | [self.window.contentView addSubview:self.uploadView]; 79 | } else 80 | { 81 | [self.cancelButton.animator setAlphaValue:1.0]; 82 | [self.uploadButton.animator setAlphaValue:1.0]; 83 | self.uploadView.frame = NSMakeRect(0, 48, self.window.frame.size.width, self.uploadView.frame.size.height); 84 | self.uploadView.alphaValue = 0.0; 85 | [self.window.contentView addSubview:self.uploadView]; 86 | [self.window setFrame:NSMakeRect(self.window.frame.origin.x, self.window.frame.origin.y, self.window.frame.size.width, self.uploadView.frame.size.height+67+48/*+22*//*titlebarheight*/) display:YES animate:YES]; 87 | [self.uploadView.animator setAlphaValue:1.0]; 88 | } 89 | 90 | [self restoreTemporarilyDeletedFacebookCookies]; 91 | } 92 | 93 | - (void)switchToLoginViewWithAnimation:(BOOL)shouldAnimate 94 | { 95 | [self.uploadView removeFromSuperview]; 96 | 97 | [self temporarilyDeleteFacebookCookies]; 98 | 99 | if (!shouldAnimate) 100 | { 101 | self.cancelButton.alphaValue = 0.0; 102 | [self.uploadButton setHidden:YES]; 103 | [self.uploadButton setEnabled:NO]; 104 | 105 | [self.window setContentSize:NSMakeSize(self.window.frame.size.width, self.webView.frame.size.height+67+48)]; 106 | self.webView.frame = NSMakeRect(0, 48, self.window.frame.size.width, self.webView.frame.size.height); 107 | [self.window.contentView addSubview:self.webView]; 108 | } else 109 | { 110 | [self.cancelButton.animator setAlphaValue:0.0]; 111 | [self.uploadButton.animator setAlphaValue:0.0]; 112 | [self.uploadButton setEnabled:NO]; 113 | double delayInSeconds = 0.6; 114 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC); 115 | dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ 116 | [self.uploadButton setHidden:YES]; 117 | }); 118 | 119 | self.webView.frame = NSMakeRect(0, 48, self.window.frame.size.width, self.webView.frame.size.height); 120 | self.webView.alphaValue = 0.0; 121 | [self.window setFrame:NSMakeRect(self.window.frame.origin.x, self.window.frame.origin.y, self.window.frame.size.width, self.webView.frame.size.height+67+48/*+22*//*titlebarheight*/) display:YES animate:YES]; 122 | [self.webView.animator setAlphaValue:1.0]; 123 | [self.window.contentView performSelector:@selector(addSubview:) withObject:self.webView afterDelay:0.55]; 124 | } 125 | 126 | [self openAuthorizationURLWithAppID:self.appID]; 127 | } 128 | 129 | - (void)openAuthorizationURLWithAppID:(NSString *)anID 130 | { 131 | self.reactToCancel = NO; 132 | if (anID == nil) 133 | { 134 | if ([self.delegate respondsToSelector:@selector(facebookLogin:returnedAccessToken:expirationDate:)]) 135 | [self.delegate facebookLogin:self returnedAccessToken:nil expirationDate:nil]; 136 | return; 137 | } 138 | self.appID = anID; 139 | 140 | NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://www.facebook.com/dialog/oauth?client_id=%@&response_type=token&scope=publish_stream&display=popup&redirect_uri=https://www.facebook.com/connect/login_success.html",self.appID]]; 141 | 142 | NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60.0]; 143 | [[self.webView mainFrame] loadRequest:req]; 144 | } 145 | 146 | - (IBAction)cancel:(id)sender 147 | { 148 | if ([self.delegate respondsToSelector:@selector(facebookLogin:returnedAccessToken:expirationDate:)]) 149 | [self.delegate facebookLogin:self returnedAccessToken:nil expirationDate:nil]; 150 | } 151 | 152 | - (NSRect)webViewFrame:(WebView *)sender 153 | { 154 | return self.webView.frame; 155 | } 156 | 157 | - (void)webView:(WebView *)webView setFrame:(NSRect)frame 158 | { 159 | [self.webView setFrame:self.webView.frame]; 160 | } 161 | 162 | - (IBAction)changeAccount:(id)sender 163 | { 164 | [self.cancelButton.animator setAlphaValue:0.0]; 165 | [sender setEnabled:NO]; 166 | [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"essfacebookauth"]; 167 | 168 | if ([self.delegate respondsToSelector:@selector(_deauthorize)]) 169 | [(ESSFacebook *)self.delegate _deauthorize]; 170 | 171 | [self switchToLoginViewWithAnimation:YES]; 172 | [sender setEnabled:YES]; 173 | } 174 | 175 | - (IBAction)startUpload:(id)sender 176 | { 177 | if (self.titleField.stringValue.length == 0) 178 | { 179 | [self.window makeFirstResponder:self.titleField]; 180 | NSBeep(); 181 | return; 182 | } 183 | 184 | //switch to upload view 185 | [self uploadStarted]; 186 | 187 | [(ESSFacebook *)self.delegate _uploadVideoAtURL:self.videoURL 188 | title:self.titleField.stringValue 189 | description:self.descriptionField.stringValue 190 | isPrivate:(self.makePrivateButton.state == NSOnState)]; 191 | } 192 | 193 | - (IBAction)viewOnFacebook:(id)sender 194 | { 195 | NSURL *url = [NSURL URLWithString:((NSButton *)sender).alternateTitle]; 196 | [[NSWorkspace sharedWorkspace] openURL:url]; 197 | } 198 | 199 | - (void)uploadStarted 200 | { 201 | [self.window makeFirstResponder:nil]; 202 | [self.uploadProgressBar setIndeterminate:YES]; 203 | [self.uploadProgressBar startAnimation:nil]; 204 | [self.uploadProgressView setAlphaValue:0.0]; 205 | self.uploadProgressView.frame = self.uploadView.frame; 206 | [self.window.contentView addSubview:self.uploadProgressView]; 207 | [self.uploadView.animator setAlphaValue:0.0]; 208 | [self.uploadProgressView.animator setAlphaValue:1.0]; 209 | 210 | [self.uploadButton setEnabled:NO]; 211 | [self.uploadButton.animator setAlphaValue:0.0]; 212 | 213 | double delayInSeconds = 0.6; 214 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC); 215 | dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ 216 | [self.uploadView removeFromSuperview]; 217 | self.uploadButton.title = ESSLocalizedString(@"ESSFacebookButtonDone",nil); 218 | self.uploadButton.action = @selector(cancel:); 219 | }); 220 | } 221 | 222 | - (void)uploadUpdatedWithBytes:(NSInteger)bytesUploaded ofTotalBytes:(NSInteger)totalBytes 223 | { 224 | [self.uploadProgressBar setMinValue:0.0]; 225 | [self.uploadProgressBar setMaxValue:totalBytes]; 226 | [self.uploadProgressBar setDoubleValue:bytesUploaded]; 227 | [self.uploadProgressBar setIndeterminate:NO]; 228 | 229 | double percentDone = bytesUploaded*100/totalBytes; 230 | percentDone = round(percentDone); 231 | 232 | self.uploadProgressField.stringValue = [NSString stringWithFormat:ESSLocalizedString(@"ESSFacebookUploadPercentageDone",nil),(NSUInteger)percentDone]; 233 | } 234 | 235 | - (void)uploadFinishedWithFacebookVideoURL:(NSURL *)url 236 | { 237 | //set view up 238 | NSImage *statusImage = nil; 239 | NSString *statusString = nil; 240 | self.viewOnFBButton.alternateTitle = [url absoluteString]; 241 | [self.cancelButton.animator setAlphaValue:0.0]; 242 | double delayInSeconds = 0.55; 243 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC); 244 | dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ 245 | [self.cancelButton setHidden:YES]; 246 | }); 247 | if (url != nil) //set green check image for uploadResultImageView and set according text 248 | { 249 | [self.uploadButton setEnabled:YES]; 250 | [self.uploadButton.animator setAlphaValue:1.0]; 251 | 252 | statusString = ESSLocalizedString(@"ESSFacebookUploadSucceeded",nil); 253 | NSString *imgPath = @"/System/Library/CoreServices/Installer.app/Contents/PlugIns/Summary.bundle/Contents/Resources/Success.png"; 254 | statusImage = [[[NSImage alloc] initWithContentsOfFile:imgPath] autorelease]; 255 | [self.viewOnFBButton setHidden:NO]; 256 | } else //there's been an error, set red fail image and according text 257 | { 258 | statusString = ESSLocalizedString(@"ESSFacebookUploadFailed",nil); 259 | 260 | NSString *imgPath = @"/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"; 261 | statusImage = [[[NSImage alloc] initWithContentsOfFile:imgPath] autorelease]; 262 | [self.viewOnFBButton setHidden:YES]; 263 | } 264 | self.resultTextField.stringValue = statusString; 265 | self.resultImageView.image = statusImage; 266 | 267 | //switch to result view 268 | self.uploadResultView.frame = self.uploadProgressView.frame; 269 | self.uploadResultView.alphaValue = 0.0; 270 | [self.window.contentView addSubview:self.uploadResultView]; 271 | [self.uploadProgressView.animator setAlphaValue:0.0]; 272 | [self.uploadResultView.animator setAlphaValue:1.0]; 273 | } 274 | 275 | - (void)webView:(WebView *)sender 276 | resource:(id)identifier 277 | didReceiveResponse:(NSURLResponse *)response 278 | fromDataSource:(WebDataSource *)dataSource 279 | { 280 | NSString *urlStr = [response.URL absoluteString]; 281 | 282 | if ([urlStr rangeOfString:@"#access_token="].location != NSNotFound && [urlStr rangeOfString:@"&expires_in="].location != NSNotFound) 283 | { 284 | //got auth 285 | NSRange authRange = [urlStr rangeOfString:@"#access_token="]; 286 | NSString *authToken = [urlStr substringFromIndex:authRange.location + authRange.length]; 287 | authToken = [authToken substringToIndex:[authToken rangeOfString:@"&expires_in="].location]; 288 | NSRange expRange = [urlStr rangeOfString:@"&expires_in="]; 289 | NSString *expSecs = [urlStr substringFromIndex:expRange.location + expRange.length]; 290 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:[expSecs integerValue]]; 291 | 292 | if ([self.delegate respondsToSelector:@selector(facebookLogin:returnedAccessToken:expirationDate:)]) 293 | [self.delegate facebookLogin:self returnedAccessToken:authToken expirationDate:date]; 294 | } else if ([urlStr rangeOfString:@"error_reason="].location != NSNotFound || [urlStr rangeOfString:@"error_description="].location != NSNotFound) 295 | [self cancel:nil]; 296 | } 297 | 298 | - (void)temporarilyDeleteFacebookCookies 299 | { 300 | if (self.temporaryCookies != nil) 301 | { 302 | for (NSHTTPCookie *ck in self.temporaryCookies) 303 | [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:ck]; 304 | } 305 | 306 | self.temporaryCookies = [NSMutableArray array]; 307 | for (NSHTTPCookie *ck in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]) 308 | { 309 | if ([[ck domain] rangeOfString:@"facebook.com"].location != NSNotFound) 310 | [self.temporaryCookies addObject:ck]; 311 | } 312 | 313 | for (NSHTTPCookie *ck in self.temporaryCookies) 314 | [[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:ck]; 315 | } 316 | 317 | - (void)restoreTemporarilyDeletedFacebookCookies 318 | { 319 | if (self.temporaryCookies != nil) 320 | { 321 | for (NSHTTPCookie *ck in self.temporaryCookies) 322 | [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:ck]; 323 | } 324 | } 325 | 326 | - (void)dealloc 327 | { 328 | self.delegate = nil; 329 | self.appID = nil; 330 | self.webView = nil; 331 | self.uploadView = nil; 332 | self.temporaryCookies = nil; 333 | self.videoURL = nil; 334 | 335 | [super dealloc]; 336 | } 337 | 338 | @end 339 | -------------------------------------------------------------------------------- /ESSVideoShare/ESSFacebookiOSViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ESSFacebookiOSViewController.h 3 | // ESSVideoShare 4 | // 5 | // Created by Matthias Gansrigler on 24.03.12. 6 | // Copyright (c) 2012 Eternal Storms Software. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class ESSFacebookiOSViewController; 12 | 13 | @protocol ESSFacebookiOSViewControllerDelegate 14 | 15 | @required 16 | - (void)facebookLogin:(ESSFacebookiOSViewController *)login returnedAccessToken:(NSString *)token expirationDate:(NSDate *)expDate; 17 | 18 | @end 19 | 20 | @interface ESSFacebookiOSViewController : UIViewController 21 | 22 | @property (assign) id delegate; 23 | 24 | @property (retain) UITableViewCell *titleTVCell; 25 | @property (retain) UITableViewCell *descriptionTVCell; 26 | @property (retain) UITableViewCell *privacyTVCell; 27 | 28 | @property (retain) NSString *appID; 29 | @property (retain) NSURL *videoURL; 30 | 31 | @property (retain) NSString *username; 32 | @property (retain) NSString *videoTitle; 33 | 34 | @property (retain) NSMutableArray *temporaryCookies; 35 | 36 | @property (retain) UINavigationController *navContr; 37 | 38 | @property (retain) IBOutlet UITableViewController *infoTableViewController; 39 | 40 | @property (retain) IBOutlet UIViewController *uploadingViewController; 41 | @property (assign) IBOutlet UIProgressView *uploadProgressBarView; 42 | @property (assign) IBOutlet UILabel *percentDoneField; 43 | 44 | @property (retain) IBOutlet UIViewController *doneViewController; 45 | @property (assign) IBOutlet UIImageView *doneImageView; 46 | @property (assign) IBOutlet UILabel *doneTextField; 47 | @property (assign) IBOutlet UIButton *viewButton; 48 | 49 | - (id)initWithDelegate:(id)del appID:(NSString *)someID videoURL:(NSURL *)url; 50 | 51 | - (void)openAuthorizationURLWithAppID:(NSString *)anID; 52 | 53 | - (void)cancel:(id)sender; 54 | - (void)changeAccount:(id)sender; 55 | - (void)startUpload:(id)sender; 56 | - (IBAction)viewOnFacebook:(id)sender; 57 | 58 | - (void)switchToLoginViewWithAnimation:(BOOL)animate; //shows uiwebview 59 | - (void)switchToUploadViewWithAnimation:(BOOL)animate; //shows infoTableView 60 | 61 | - (void)updateUsername:(NSString *)name; 62 | - (void)updateVideoTitle:(NSString *)title; 63 | 64 | - (void)temporarilyDeleteFacebookCookies; 65 | - (void)restoreTemporarilyDeletedFacebookCookies; 66 | 67 | - (void)uploadStarted; 68 | - (void)uploadUpdatedWithBytes:(NSInteger)bytesUploaded ofTotalBytes:(NSInteger)totalBytes; 69 | - (void)uploadFinishedWithFacebookVideoURL:(NSURL *)url; 70 | 71 | - (UITableViewCell *)customTVCellForIndexPath:(NSIndexPath *)indexPath; 72 | 73 | @end 74 | -------------------------------------------------------------------------------- /ESSVideoShare/ESSFlickr.h: -------------------------------------------------------------------------------- 1 | // 2 | // ESSFlickr.h 3 | // Zlidez 4 | // 5 | // Created by Matthias Gansrigler on 07.11.11. 6 | // Copyright (c) 2011 Eternal Storms Software. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "OAuthConsumer.h" 11 | #import 12 | #import 13 | #if (!TARGET_OS_IPHONE && !TARGET_OS_EMBEDDED && !TARGET_IPHONE_SIMULATOR) 14 | #import "ESSFlickrWindowController.h" 15 | #else 16 | #import "ESSFlickriOSViewController.h" 17 | #endif 18 | 19 | #define ESSLocalizedString(key, comment) NSLocalizedStringFromTableInBundle((key),nil,[NSBundle bundleForClass:[self class]],(comment)) 20 | 21 | @class ESSFlickr; 22 | 23 | @protocol ESSFlickrDelegate 24 | 25 | @required 26 | #if (!TARGET_OS_IPHONE && !TARGET_OS_EMBEDDED && !TARGET_IPHONE_SIMULATOR) 27 | - (NSWindow *)ESSFlickrNeedsWindowToAttachTo:(ESSFlickr *)flickr; 28 | #else 29 | - (UIViewController *)ESSFlickrNeedsViewController:(ESSFlickr *)flickr; 30 | #endif 31 | - (void)ESSFlickrDidUploadVideoWithFlickrURL:(NSURL *)url; 32 | - (void)ESSFlickrDidFinish:(ESSFlickr *)flickr; 33 | 34 | @end 35 | 36 | #if (!TARGET_OS_IPHONE && !TARGET_OS_EMBEDDED && !TARGET_IPHONE_SIMULATOR) 37 | @interface ESSFlickr : NSObject 38 | #else 39 | @interface ESSFlickr : NSObject 40 | #endif 41 | 42 | @property (assign) id delegate; 43 | @property (retain) OAConsumer *_oaconsumer; 44 | @property (retain) OAPlaintextSignatureProvider *_sigProv; 45 | @property (retain) OAToken *_authToken; 46 | @property (retain) OAToken *_requestToken; 47 | #if (!TARGET_OS_IPHONE && !TARGET_OS_EMBEDDED && !TARGET_IPHONE_SIMULATOR) 48 | @property (retain) ESSFlickrWindowController *_flWinCtr; 49 | #else 50 | @property (retain) ESSFlickriOSViewController *_viewCtr; 51 | #endif 52 | @property (retain) NSURLConnection *_uploader; 53 | @property (retain) NSMutableData *_resultData; 54 | 55 | - (id)initWithDelegate:(id)del 56 | applicationKey:(NSString *)key 57 | applicationSecret:(NSString *)secret; 58 | 59 | - (void)uploadVideoAtURL:(NSURL *)url; 60 | 61 | #if (TARGET_OS_IPHONE || TARGET_OS_EMBEDDED || TARGET_IPHONE_SIMULATOR) 62 | - (void)handleOpenURL:(NSURL *)url; 63 | #endif 64 | 65 | //private 66 | - (void)_authorize; 67 | 68 | - (void)_deauthorize; 69 | 70 | - (BOOL)_canUploadVideosKeyInvalidCheck:(BOOL *)keyInvalid errorConnecting:(BOOL *)errorConnecting; 71 | 72 | - (NSString *)_unescapedString:(NSString *)aString; 73 | 74 | - (void)_uploadVideoAtURL:(NSURL *)url 75 | title:(NSString *)title 76 | description:(NSString *)description 77 | tags:(NSString *)tags 78 | makePrivate:(BOOL)makePrivate; 79 | 80 | - (void)_checkPhotoID:(NSString *)photoID; 81 | 82 | @end -------------------------------------------------------------------------------- /ESSVideoShare/ESSFlickrWindowController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ESSFlickrWindowController.h 3 | // Zlidez 4 | // 5 | // Created by Matthias Gansrigler on 07.11.11. 6 | // Copyright (c) 2011 Eternal Storms Software. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class ESSFlickrWindowController; 12 | 13 | @protocol ESSFlickrWindowControllerDelegate 14 | 15 | @required 16 | - (void)flickrWindowDidCancel:(ESSFlickrWindowController *)flickrWinCtr; 17 | 18 | @end 19 | 20 | @interface ESSFlickrWindowController : NSWindowController 21 | 22 | @property (retain) NSURL *videoURL; 23 | @property (assign) id delegate; 24 | 25 | @property (retain) IBOutlet NSView *loginView; 26 | @property (assign) IBOutlet NSButton *authorizeButton; 27 | @property (assign) IBOutlet NSProgressIndicator *loginProgInd; 28 | @property (assign) IBOutlet NSTextField *loginStatusField; 29 | 30 | @property (retain) IBOutlet NSView *uploadView; 31 | @property (assign) IBOutlet NSTextField *usernameField; 32 | @property (assign) IBOutlet NSTextField *descriptionField; 33 | @property (assign) IBOutlet NSTokenField *tagsField; 34 | @property (assign) IBOutlet NSButton *privateButton; 35 | @property (assign) IBOutlet NSTextField *titleField; 36 | 37 | @property (assign) IBOutlet NSView *uploadProgressView; 38 | @property (assign) IBOutlet NSProgressIndicator *uploadProgressBar; 39 | @property (assign) IBOutlet NSTextField *uploadStatusField; 40 | @property (assign) IBOutlet NSButton *uploadProgressCancelButton; 41 | 42 | @property (assign) IBOutlet NSView *doneView; 43 | @property (assign) IBOutlet NSImageView *doneImageView; 44 | @property (assign) IBOutlet NSTextField *doneStatusField; 45 | @property (assign) IBOutlet NSButton *viewOnFlickrButton; 46 | 47 | - (id)initWithDelegate:(id)del videoURL:(NSURL *)url; 48 | 49 | - (void)switchToAuthorizeViewWithAnimation:(BOOL)shouldAnimate; 50 | - (void)switchToUploadViewWithAnimation:(BOOL)shouldAnimate; 51 | 52 | - (IBAction)authorize:(id)sender; 53 | - (IBAction)cancel:(id)sender; 54 | 55 | - (IBAction)changeAccount:(id)sender; 56 | - (IBAction)startUpload:(id)sender; 57 | 58 | - (IBAction)viewOnFlickr:(id)sender; 59 | - (IBAction)done:(id)sender; 60 | 61 | - (void)uploadUpdatedWithBytes:(NSUInteger)bytesLoaded ofTotal:(NSUInteger)totalBytes; 62 | - (void)uploadFinishedWithFlickrURL:(NSURL *)url success:(BOOL)success; 63 | @end 64 | -------------------------------------------------------------------------------- /ESSVideoShare/ESSFlickrWindowController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ESSFlickrWindowController.m 3 | // Zlidez 4 | // 5 | // Created by Matthias Gansrigler on 07.11.11. 6 | // Copyright (c) 2011 Eternal Storms Software. All rights reserved. 7 | // 8 | 9 | #import "ESSFlickrWindowController.h" 10 | #import "ESSFlickr.h" 11 | 12 | @implementation ESSFlickrWindowController 13 | @synthesize loginView; 14 | @synthesize authorizeButton; 15 | @synthesize loginProgInd; 16 | @synthesize loginStatusField; 17 | @synthesize uploadView; 18 | @synthesize usernameField; 19 | @synthesize descriptionField; 20 | @synthesize tagsField; 21 | @synthesize privateButton; 22 | @synthesize titleField; 23 | @synthesize uploadProgressView; 24 | @synthesize uploadProgressBar; 25 | @synthesize uploadStatusField; 26 | @synthesize uploadProgressCancelButton; 27 | @synthesize doneView; 28 | @synthesize doneImageView; 29 | @synthesize doneStatusField; 30 | @synthesize viewOnFlickrButton,videoURL,delegate; 31 | 32 | - (id)initWithDelegate:(id)del videoURL:(NSURL *)url 33 | { 34 | if (self = [super initWithWindowNibName:@"ESSFlickrWindow"]) 35 | { 36 | self.delegate = del; 37 | self.videoURL = url; 38 | 39 | return self; 40 | } 41 | 42 | return nil; 43 | } 44 | 45 | - (void)switchToAuthorizeViewWithAnimation:(BOOL)shouldAnimate 46 | { 47 | [self.uploadView removeFromSuperview]; 48 | [self.loginView setFrameOrigin:NSZeroPoint]; 49 | 50 | [self.loginProgInd stopAnimation:self]; 51 | [self.loginProgInd setHidden:YES]; 52 | [self.loginStatusField setHidden:YES]; 53 | [self.authorizeButton setHidden:NO]; 54 | [self.authorizeButton setEnabled:YES]; 55 | [self.authorizeButton setAlphaValue:1.0]; 56 | 57 | if (!shouldAnimate) 58 | { 59 | [self.window setContentSize:NSMakeSize(self.loginView.frame.size.width, self.loginView.frame.size.height+38)]; 60 | [self.window.contentView addSubview:self.loginView]; 61 | } else 62 | { 63 | [self.window setFrame:NSMakeRect(self.window.frame.origin.x, self.window.frame.origin.y, self.loginView.frame.size.width, self.loginView.frame.size.height+38) display:YES animate:YES]; 64 | [self.loginView setAlphaValue:0.0]; 65 | [self.window.contentView addSubview:self.loginView]; 66 | [self.loginView.animator setAlphaValue:1.0]; 67 | } 68 | } 69 | 70 | - (void)switchToUploadViewWithAnimation:(BOOL)shouldAnimate 71 | { 72 | [self.loginView removeFromSuperview]; 73 | [self.uploadView setFrameOrigin:NSZeroPoint]; 74 | 75 | if (self.titleField.stringValue.length == 0) 76 | self.titleField.stringValue = ESSLocalizedString(@"ESSFlickrDefaultTitle", nil); 77 | 78 | if (!shouldAnimate) 79 | { 80 | [self.window setContentSize:NSMakeSize(self.uploadView.frame.size.width, self.uploadView.frame.size.height+38)]; 81 | [self.window.contentView addSubview:self.uploadView]; 82 | } else 83 | { 84 | [self.window setFrame:NSMakeRect(self.window.frame.origin.x, self.window.frame.origin.y, self.uploadView.frame.size.width, self.uploadView.frame.size.height+38) display:YES animate:YES]; 85 | [self.uploadView setAlphaValue:0.0]; 86 | [self.window.contentView addSubview:self.uploadView]; 87 | [self.uploadView.animator setAlphaValue:1.0]; 88 | } 89 | } 90 | 91 | - (IBAction)authorize:(id)sender 92 | { 93 | [(ESSFlickr *)self.delegate _authorize]; 94 | 95 | //show authstatusfield,authstatusprogind, hide auth button 96 | [sender setEnabled:NO]; 97 | [((NSButton *)sender).animator setAlphaValue:0.0]; 98 | 99 | [self.loginProgInd setAlphaValue:0.0]; 100 | [self.loginStatusField setAlphaValue:0.0]; 101 | [self.loginProgInd startAnimation:self]; 102 | [self.loginProgInd setHidden:NO]; 103 | [self.loginStatusField setHidden:NO]; 104 | [self.loginProgInd.animator setAlphaValue:1.0]; 105 | [self.loginStatusField.animator setAlphaValue:1.0]; 106 | } 107 | 108 | - (IBAction)cancel:(id)sender 109 | { 110 | [sender setEnabled:NO]; 111 | [self.window orderOut:nil]; 112 | //if (self.window.parentWindow != nil) 113 | [NSApp endSheet:self.window]; 114 | 115 | double delayInSeconds = 0.55; 116 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC); 117 | dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ 118 | [self.delegate flickrWindowDidCancel:self]; 119 | }); 120 | } 121 | 122 | - (IBAction)changeAccount:(id)sender 123 | { 124 | [(ESSFlickr *)self.delegate _deauthorize]; 125 | [self switchToAuthorizeViewWithAnimation:YES]; 126 | } 127 | 128 | - (IBAction)startUpload:(id)sender 129 | { 130 | //switch to upload view 131 | [self.uploadView removeFromSuperview]; 132 | [self.uploadProgressBar setIndeterminate:YES]; 133 | [self.uploadProgressBar startAnimation:nil]; 134 | self.uploadStatusField.stringValue = ESSLocalizedString(@"ESSFlickrInitializingUpload",nil); 135 | 136 | [self.uploadProgressView setFrameOrigin:NSZeroPoint]; 137 | [self.window setFrame:NSMakeRect(self.window.frame.origin.x, self.window.frame.origin.y, self.uploadProgressView.frame.size.width, self.uploadProgressView.frame.size.height+38) display:YES animate:YES]; 138 | self.uploadProgressView.alphaValue = 0.0; 139 | [self.window.contentView addSubview:self.uploadProgressView]; 140 | [self.uploadProgressView.animator setAlphaValue:1.0]; 141 | 142 | //start upload 143 | NSString *title = self.titleField.stringValue; 144 | if (title == nil) 145 | title = @""; 146 | NSString *descr = self.descriptionField.stringValue; 147 | if (descr == nil) 148 | descr = @""; 149 | NSString *tags = self.tagsField.stringValue; 150 | if (tags == nil) 151 | tags = @""; 152 | 153 | [((ESSFlickr *)self.delegate) _uploadVideoAtURL:self.videoURL 154 | title:title 155 | description:descr 156 | tags:tags 157 | makePrivate:(self.privateButton.state == NSOnState)]; 158 | 159 | } 160 | 161 | - (void)uploadUpdatedWithBytes:(NSUInteger)bytesLoaded ofTotal:(NSUInteger)totalBytes 162 | { 163 | [self.uploadProgressBar setIndeterminate:NO]; 164 | [self.uploadProgressBar startAnimation:nil]; 165 | self.uploadProgressBar.minValue = 0; 166 | self.uploadProgressBar.maxValue = totalBytes; 167 | self.uploadProgressBar.doubleValue = bytesLoaded; 168 | 169 | double percentDone = bytesLoaded*100/totalBytes; 170 | percentDone = round(percentDone); 171 | 172 | self.uploadStatusField.stringValue = [NSString stringWithFormat:ESSLocalizedString(@"ESSFlickrUploadPercentageDone",nil),(NSUInteger)percentDone]; //@"%ld%% uploaded 173 | 174 | if (bytesLoaded == totalBytes) 175 | { 176 | [self.uploadProgressBar setIndeterminate:YES]; 177 | [self.uploadProgressBar startAnimation:nil]; 178 | [self.uploadProgressCancelButton setEnabled:NO]; 179 | self.uploadStatusField.stringValue = ESSLocalizedString(@"ESSFlickrWaitingForFlickrToProcessVideo",nil); 180 | } 181 | } 182 | 183 | - (void)uploadFinishedWithFlickrURL:(NSURL *)url success:(BOOL)success 184 | { 185 | if (url != nil) 186 | { 187 | [self.viewOnFlickrButton setHidden:NO]; 188 | self.viewOnFlickrButton.alternateTitle = [url absoluteString]; 189 | } else 190 | [self.viewOnFlickrButton setHidden:YES]; 191 | 192 | NSString *statusString = nil; 193 | NSImage *image = nil; 194 | if (success) 195 | { 196 | //show success image and status text 197 | statusString = ESSLocalizedString(@"ESSFlickrUploadSucceeded", nil); 198 | NSString *imgPath = @"/System/Library/CoreServices/Installer.app/Contents/PlugIns/Summary.bundle/Contents/Resources/Success.png"; 199 | image = [[[NSImage alloc] initWithContentsOfFile:imgPath] autorelease]; 200 | } else 201 | { 202 | //show fail image and status text 203 | statusString = ESSLocalizedString(@"ESSFlickrUploadFailed", nil); 204 | NSString *imgPath = @"/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"; 205 | image = [[[NSImage alloc] initWithContentsOfFile:imgPath] autorelease]; 206 | } 207 | 208 | self.doneImageView.image = image; 209 | self.doneStatusField.stringValue = statusString; 210 | 211 | [self.uploadProgressView removeFromSuperview]; 212 | [self.doneView setFrameOrigin:NSZeroPoint]; 213 | [self.window setFrame:NSMakeRect(self.window.frame.origin.x, self.window.frame.origin.y, self.doneView.frame.size.width, self.doneView.frame.size.height+38) display:YES animate:YES]; 214 | self.doneView.alphaValue = 0.0; 215 | [self.window.contentView addSubview:self.doneView]; 216 | [self.doneView.animator setAlphaValue:1.0]; 217 | } 218 | 219 | - (IBAction)viewOnFlickr:(id)sender 220 | { 221 | [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:self.viewOnFlickrButton.alternateTitle]]; 222 | } 223 | 224 | - (IBAction)done:(id)sender 225 | { 226 | [self cancel:sender]; 227 | } 228 | 229 | - (void)dealloc 230 | { 231 | self.delegate = nil; 232 | self.videoURL = nil; 233 | self.loginView = nil; 234 | self.uploadView = nil; 235 | 236 | [super dealloc]; 237 | } 238 | @end 239 | -------------------------------------------------------------------------------- /ESSVideoShare/ESSFlickriOSViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ESSFlickriOSViewController.h 3 | // essvideoshareiostest 4 | // 5 | // Created by Matthias Gansrigler on 31.03.12. 6 | // Copyright (c) 2012 Eternal Storms Software. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class ESSFlickriOSViewController; 12 | 13 | @protocol ESSFlickriOSViewControllerDelegate 14 | 15 | @required 16 | - (void)flickrDidCancel:(ESSFlickriOSViewController *)flickrCtr; 17 | 18 | @end 19 | 20 | @interface ESSFlickriOSViewController : UIViewController 21 | 22 | @property (assign) id delegate; 23 | @property (retain) NSURL *videoURL; 24 | 25 | @property (retain) UINavigationController *navCtr; 26 | 27 | @property (retain) NSString *username; 28 | 29 | @property (retain) IBOutlet UIViewController *videoInfoViewController; 30 | 31 | @property (retain) IBOutlet UIViewController *uploadingViewController; 32 | @property (assign) IBOutlet UILabel *uploadingLabel; 33 | @property (assign) IBOutlet UIProgressView *uploadingProgressView; 34 | 35 | @property (retain) IBOutlet UIViewController *doneViewController; 36 | @property (retain) IBOutlet UIImageView *doneImageView; 37 | @property (retain) IBOutlet UILabel *doneLabel; 38 | @property (retain) IBOutlet UIButton *doneButton; 39 | 40 | @property (retain) UITableViewCell *titleTVCell; 41 | @property (retain) UITableViewCell *descriptionTVCell; 42 | @property (retain) UITableViewCell *tagsTVCell; 43 | @property (retain) UITableViewCell *privacyTVCell; 44 | 45 | - (id)initWithDelegate:(id)del videoURL:(NSURL *)url; 46 | 47 | - (void)updateUsername:(NSString *)name; 48 | 49 | - (void)switchToLoginViewWithAnimation:(BOOL)animate; 50 | - (void)switchToUploadViewWithAnimation:(BOOL)animate; 51 | 52 | - (void)login:(id)sender; 53 | - (void)cancel:(id)sender; 54 | - (void)startUpload:(id)sender; 55 | 56 | - (void)uploadUpdatedWithUploadedBytes:(NSInteger)uploadedBytes ofTotalBytes:(NSInteger)totalBytes; 57 | - (void)uploadFinishedWithURL:(NSURL *)url; 58 | 59 | - (IBAction)showOnFlickr:(id)sender; 60 | 61 | - (UITableViewCell *)customTVCellForIndexPath:(NSIndexPath *)indexPath; 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /ESSVideoShare/ESSFlickriOSViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ESSFlickriOSViewController.m 3 | // essvideoshareiostest 4 | // 5 | // Created by Matthias Gansrigler on 31.03.12. 6 | // Copyright (c) 2012 Eternal Storms Software. All rights reserved. 7 | // 8 | 9 | #import "ESSFlickriOSViewController.h" 10 | #import "ESSFlickr.h" 11 | 12 | @interface ESSFlickriOSViewController () 13 | 14 | @end 15 | 16 | @implementation ESSFlickriOSViewController 17 | 18 | @synthesize delegate,videoURL,navCtr,username,videoInfoViewController,uploadingViewController,uploadingLabel,uploadingProgressView,doneViewController,doneImageView,doneLabel,doneButton, 19 | titleTVCell,descriptionTVCell,tagsTVCell,privacyTVCell; 20 | 21 | - (id)initWithDelegate:(id)del videoURL:(NSURL *)url 22 | { 23 | NSString *nibName = @"ESSFlickriOSView_iPhone"; 24 | if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) 25 | { 26 | nibName = @"ESSFlickriOSView_iPad"; 27 | self.modalPresentationStyle = UIModalPresentationFormSheet; 28 | self.videoInfoViewController.modalPresentationStyle = UIModalPresentationFormSheet; 29 | self.uploadingViewController.modalPresentationStyle = UIModalPresentationFormSheet; 30 | self.doneViewController.modalPresentationStyle = UIModalPresentationFormSheet; 31 | } 32 | 33 | if (self = [super initWithNibName:nibName bundle:nil]) 34 | { 35 | self.delegate = del; 36 | self.videoURL = url; 37 | 38 | return self; 39 | } 40 | 41 | return nil; 42 | } 43 | 44 | - (void)viewDidLoad 45 | { 46 | [super viewDidLoad]; 47 | // Do any additional setup after loading the view. 48 | } 49 | 50 | - (void)viewDidUnload 51 | { 52 | [super viewDidUnload]; 53 | // Release any retained subviews of the main view. 54 | } 55 | 56 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 57 | { 58 | return (interfaceOrientation == UIInterfaceOrientationPortrait); 59 | } 60 | 61 | - (IBAction)showOnFlickr:(id)sender 62 | { 63 | NSURL *url = [NSURL URLWithString:[(UIButton *)sender titleForState:UIControlStateDisabled]]; 64 | 65 | [[UIApplication sharedApplication] openURL:url]; 66 | } 67 | 68 | - (void)updateUsername:(NSString *)name 69 | { 70 | self.username = name; 71 | 72 | //update videoinfotableview with username 73 | [(UITableView *)self.videoInfoViewController.view reloadData]; 74 | } 75 | 76 | //table view delegate/data source methods 77 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 78 | { 79 | if (section == 0) //user name 80 | return 1; 81 | else if (section == 1) //video info - title and description 82 | return 3; 83 | else if (section == 2) //privacy 84 | return 1; 85 | 86 | return 0; 87 | } 88 | 89 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 90 | { 91 | return 3; 92 | } 93 | 94 | - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section 95 | { 96 | if (section == 0) //flickr name 97 | return ESSLocalizedString(@"ESSFlickriOSAccountInfoFooter", nil); 98 | else if (section == 1) //video info 99 | return ESSLocalizedString(@"ESSFlickriOSVideoInfoTagFooter",nil); 100 | else if (section == 2) //privacy 101 | return ESSLocalizedString(@"ESSFlickriOSPrivacyInfoFooter",nil); 102 | 103 | return nil; 104 | } 105 | 106 | - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section 107 | { 108 | if (section == 0) 109 | return ESSLocalizedString(@"ESSFlickriOSAccountInfoHeader", nil); 110 | else if (section == 1) 111 | return ESSLocalizedString(@"ESSFlickriOSVideoInfoHeader", nil); 112 | else if (section == 2) 113 | return ESSLocalizedString(@"ESSFlickriOSPrivacyHeader", nil); 114 | 115 | return nil; 116 | } 117 | 118 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 119 | { 120 | if ([indexPath indexAtPosition:0] == 0) 121 | { 122 | //user name cell 123 | UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"userNameCell"]; 124 | cell.textLabel.text = ESSLocalizedString(@"ESSFlickriOSUsernameTVCellTitle",nil); 125 | cell.detailTextLabel.text = self.username; 126 | return [cell autorelease]; 127 | } else if ([indexPath indexAtPosition:0] == 1) 128 | { 129 | //video info 130 | if ([indexPath indexAtPosition:1] == 0) 131 | { 132 | if (self.titleTVCell == nil) 133 | self.titleTVCell = [self customTVCellForIndexPath:indexPath]; 134 | 135 | return self.titleTVCell; 136 | } else if ([indexPath indexAtPosition:1] == 1) 137 | { 138 | if (self.descriptionTVCell == nil) 139 | self.descriptionTVCell = [self customTVCellForIndexPath:indexPath]; 140 | 141 | return self.descriptionTVCell; 142 | } else 143 | { 144 | if (self.tagsTVCell == nil) 145 | self.tagsTVCell = [self customTVCellForIndexPath:indexPath]; 146 | 147 | return self.tagsTVCell; 148 | } 149 | } else if ([indexPath indexAtPosition:0] == 2) 150 | { 151 | //privacy 152 | if (self.privacyTVCell == nil) 153 | { 154 | self.privacyTVCell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"privacyCell"] autorelease]; 155 | self.privacyTVCell.accessoryType = UITableViewCellAccessoryNone; 156 | self.privacyTVCell.selectionStyle = UITableViewCellSelectionStyleNone; 157 | self.privacyTVCell.textLabel.text = ESSLocalizedString(@"ESSFlickriOSPrivateVideoTVCellTitle",nil); 158 | 159 | UISwitch *aSwitch = nil; 160 | if ([[UIDevice currentDevice] userInterfaceIdiom] != UIUserInterfaceIdiomPad) 161 | aSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(222,10,186,20)]; 162 | else //iPad 163 | aSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(420,10,186,20)]; 164 | aSwitch.on = YES; 165 | 166 | [self.privacyTVCell addSubview:aSwitch]; 167 | [aSwitch release]; 168 | } 169 | 170 | return self.privacyTVCell; 171 | } 172 | 173 | return nil; 174 | } 175 | 176 | - (UITableViewCell *)customTVCellForIndexPath:(NSIndexPath *)indexPath 177 | { 178 | UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"videoInfoCell"]; 179 | cell.accessoryType = UITableViewCellAccessoryNone; 180 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 181 | 182 | UITextField *editableTextField = nil; 183 | if ([[UIDevice currentDevice] userInterfaceIdiom] != UIUserInterfaceIdiomPad) 184 | editableTextField = [[UITextField alloc] initWithFrame:CGRectMake(120,11,186,22)]; 185 | else 186 | editableTextField = [[UITextField alloc] initWithFrame:CGRectMake(145,11,360,22)]; 187 | editableTextField.adjustsFontSizeToFitWidth = YES; 188 | editableTextField.textColor = [UIColor colorWithRed:0.22 green:0.33 blue:0.53 alpha:1]; 189 | editableTextField.backgroundColor = cell.backgroundColor; 190 | editableTextField.autocorrectionType = UITextAutocorrectionTypeDefault; 191 | editableTextField.autocapitalizationType = UITextAutocapitalizationTypeSentences; 192 | editableTextField.textAlignment = UITextAlignmentLeft; 193 | editableTextField.tag = 0; 194 | editableTextField.clearButtonMode = UITextFieldViewModeWhileEditing; 195 | editableTextField.enabled = YES; 196 | editableTextField.keyboardType = UIKeyboardTypeDefault; 197 | editableTextField.delegate = self; 198 | [cell addSubview:editableTextField]; 199 | if ([indexPath indexAtPosition:1] == 0) 200 | { 201 | //title 202 | editableTextField.returnKeyType = UIReturnKeyDone; 203 | cell.textLabel.text = ESSLocalizedString(@"ESSFlickriOSTitleTVCellTitle",nil); 204 | editableTextField.placeholder = ESSLocalizedString(@"ESSFlickriOSRequiredCellTitle", nil); 205 | } else if ([indexPath indexAtPosition:1] == 1) 206 | { 207 | //description 208 | editableTextField.returnKeyType = UIReturnKeyDone; 209 | cell.textLabel.text = ESSLocalizedString(@"ESSFlickriOSDescriptionTVCellTitle",nil); 210 | editableTextField.placeholder = ESSLocalizedString(@"ESSFlickriOSOptionalCellTitle", nil); 211 | } else 212 | { 213 | editableTextField.returnKeyType = UIReturnKeyDone; 214 | cell.textLabel.text = ESSLocalizedString(@"ESSFlickriOSTagsTVCellTitle",nil); 215 | editableTextField.placeholder = ESSLocalizedString(@"ESSFlickriOSOptionalCellTitle", nil); 216 | } 217 | [editableTextField release]; 218 | return [cell autorelease]; 219 | } 220 | 221 | - (BOOL)textFieldShouldReturn:(UITextField *)textField 222 | { 223 | [textField resignFirstResponder]; 224 | return YES; 225 | } 226 | 227 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 228 | { 229 | [tableView deselectRowAtIndexPath:indexPath animated:YES]; 230 | if ([indexPath indexAtPosition:0] == 0) 231 | { 232 | if ([self.delegate respondsToSelector:@selector(_deauthorize)]) 233 | [(ESSFlickr *)self.delegate _deauthorize]; 234 | 235 | [self switchToLoginViewWithAnimation:YES]; 236 | } 237 | } 238 | 239 | - (void)switchToLoginViewWithAnimation:(BOOL)animate 240 | { 241 | [self.navCtr popToViewController:self animated:animate]; 242 | 243 | UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithTitle:ESSLocalizedString(@"ESSFlickriOSCancel", nil) 244 | style:UIBarButtonItemStyleBordered 245 | target:self 246 | action:@selector(cancel:)]; 247 | self.navigationItem.leftBarButtonItem = btn; 248 | [btn release]; 249 | btn = [[UIBarButtonItem alloc] initWithTitle:ESSLocalizedString(@"ESSFlickriOSLogin", nil) 250 | style:UIBarButtonItemStyleDone 251 | target:self 252 | action:@selector(login:)]; 253 | self.navigationItem.rightBarButtonItem = btn; 254 | [btn release]; 255 | self.navigationItem.title = @"Flickr"; 256 | } 257 | 258 | - (void)cancel:(id)sender 259 | { 260 | if ([self.delegate respondsToSelector:@selector(flickrDidCancel:)]) 261 | [self.delegate flickrDidCancel:self]; 262 | } 263 | 264 | - (void)login:(id)sender 265 | { 266 | self.navigationItem.leftBarButtonItem.enabled = NO; 267 | self.navigationItem.rightBarButtonItem.enabled = NO; 268 | 269 | [(ESSFlickr *)self.delegate _authorize]; 270 | } 271 | - (void)switchToUploadViewWithAnimation:(BOOL)animate 272 | { 273 | [self.navCtr pushViewController:self.videoInfoViewController animated:animate]; 274 | UIViewController *crCtr = self.videoInfoViewController; 275 | 276 | UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithTitle:ESSLocalizedString(@"ESSFlickriOSCancel", nil) 277 | style:UIBarButtonItemStyleBordered 278 | target:self 279 | action:@selector(cancel:)]; 280 | crCtr.navigationItem.leftBarButtonItem = btn; 281 | [btn release]; 282 | btn = [[UIBarButtonItem alloc] initWithTitle:ESSLocalizedString(@"ESSFlickriOSUpload", nil) 283 | style:UIBarButtonItemStyleDone 284 | target:self 285 | action:@selector(startUpload:)]; 286 | crCtr.navigationItem.rightBarButtonItem = btn; 287 | [btn release]; 288 | crCtr.title = @"Flickr"; 289 | } 290 | 291 | - (void)startUpload:(id)sender 292 | { 293 | UITableViewCell *cell = self.titleTVCell; 294 | UITextField *videoTitleField = nil; 295 | for (UIView *view in cell.subviews) 296 | { 297 | if ([view isKindOfClass:[UITextField class]]) 298 | { 299 | videoTitleField = (UITextField *)view; 300 | break; 301 | } 302 | } 303 | [videoTitleField resignFirstResponder]; 304 | NSString *title = videoTitleField.text; 305 | 306 | if (title.length == 0) 307 | { 308 | [videoTitleField becomeFirstResponder]; 309 | return; 310 | } 311 | 312 | cell = self.descriptionTVCell; 313 | UITextField *videoDescField = nil; 314 | for (UIView *view in cell.subviews) 315 | { 316 | if ([view isKindOfClass:[UITextField class]]) 317 | { 318 | videoDescField = (UITextField *)view; 319 | break; 320 | } 321 | } 322 | [videoDescField resignFirstResponder]; 323 | NSString *description = videoDescField.text; 324 | 325 | /*if (description.length == 0) 326 | { 327 | [videoDescField becomeFirstResponder]; 328 | return; 329 | }*/ 330 | 331 | cell = self.tagsTVCell; 332 | UITextField *videoTags = nil; 333 | for (UIView *view in cell.subviews) 334 | { 335 | if ([view isKindOfClass:[UITextField class]]) 336 | { 337 | videoTags = (UITextField *)view; 338 | break; 339 | } 340 | } 341 | [videoTags resignFirstResponder]; 342 | NSString *tags = videoTags.text; 343 | 344 | /*if (tags.length == 0) 345 | { 346 | [videoTags becomeFirstResponder]; 347 | return; 348 | }*/ 349 | 350 | cell = [((UITableView *)self.videoInfoViewController.view) cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:2]]; 351 | UISwitch *aSwitch = nil; 352 | for (UIView *view in cell.subviews) 353 | { 354 | if ([view isKindOfClass:[UISwitch class]]) 355 | { 356 | aSwitch = (UISwitch *)view; 357 | break; 358 | } 359 | } 360 | 361 | BOOL isPrivate = aSwitch.on; 362 | 363 | [self uploadStarted]; 364 | 365 | [(ESSFlickr *)self.delegate _uploadVideoAtURL:self.videoURL 366 | title:title 367 | description:description 368 | tags:tags 369 | makePrivate:isPrivate]; 370 | } 371 | 372 | - (void)uploadStarted 373 | { 374 | self.uploadingProgressView.progress = 0.0; 375 | [self.navCtr pushViewController:self.uploadingViewController animated:YES]; 376 | UIViewController *crCtr = self.uploadingViewController; 377 | 378 | UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithTitle:ESSLocalizedString(@"ESSFlickriOSCancel", nil) 379 | style:UIBarButtonItemStyleBordered 380 | target:self 381 | action:@selector(cancel:)]; 382 | crCtr.navigationItem.leftBarButtonItem = btn; 383 | [btn release]; 384 | crCtr.navigationItem.rightBarButtonItem = nil; 385 | } 386 | 387 | - (void)uploadUpdatedWithUploadedBytes:(NSInteger)uploadedBytes ofTotalBytes:(NSInteger)totalBytes 388 | { 389 | [self.uploadingProgressView setProgress:(CGFloat)((CGFloat)uploadedBytes/(CGFloat)totalBytes) animated:YES]; 390 | double percentDone = uploadedBytes*100/totalBytes; 391 | percentDone = round(percentDone); 392 | 393 | self.uploadingLabel.text = [NSString stringWithFormat:ESSLocalizedString(@"ESSFlickrUploadPercentageDone", nil),(NSUInteger)percentDone]; 394 | 395 | if (uploadedBytes == totalBytes) 396 | self.uploadingLabel.text = ESSLocalizedString(@"ESSFlickrWaitingForFlickrToVerifyVideo", nil); 397 | } 398 | 399 | - (void)uploadFinishedWithURL:(NSURL *)url 400 | { 401 | if (url == nil) 402 | { 403 | //upload failed 404 | self.doneLabel.text = ESSLocalizedString(@"ESSFlickrUploadFailed", nil); 405 | [self.doneButton setTitle:nil forState:UIControlStateDisabled]; 406 | } else 407 | { 408 | self.doneLabel.text = ESSLocalizedString(@"ESSFlickrUploadSucceeded", nil); 409 | [self.doneButton setTitle:url.absoluteString forState:UIControlStateDisabled]; 410 | } 411 | 412 | [self.navCtr pushViewController:self.doneViewController animated:YES]; 413 | UIViewController *crCtr = self.doneViewController; 414 | 415 | UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithTitle:ESSLocalizedString(@"ESSFlickriOSCancel", nil) 416 | style:UIBarButtonItemStyleBordered 417 | target:self 418 | action:@selector(cancel:)]; 419 | crCtr.navigationItem.leftBarButtonItem = btn; 420 | [btn release]; 421 | btn = [[UIBarButtonItem alloc] initWithTitle:ESSLocalizedString(@"ESSFlickriOSDone", nil) 422 | style:UIBarButtonItemStyleDone 423 | target:self 424 | action:@selector(cancel:)]; 425 | crCtr.navigationItem.rightBarButtonItem = btn; 426 | [btn release]; 427 | } 428 | 429 | - (void)dealloc 430 | { 431 | self.delegate = nil; 432 | self.videoURL = nil; 433 | self.navCtr = nil; 434 | self.username = nil; 435 | self.videoInfoViewController = nil; 436 | self.uploadingViewController = nil; 437 | self.doneViewController = nil; 438 | self.titleTVCell = nil; 439 | self.descriptionTVCell = nil; 440 | self.tagsTVCell = nil; 441 | self.privacyTVCell = nil; 442 | 443 | [super dealloc]; 444 | } 445 | 446 | @end 447 | -------------------------------------------------------------------------------- /ESSVideoShare/ESSVideoShare-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | at.EternalStorms.${PRODUCT_NAME:rfc1034identifier} 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 © 2012 Eternal Storms Software. All rights reserved. 27 | NSPrincipalClass 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /ESSVideoShare/ESSVideoShare-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'ESSVideoShare' target in the 'ESSVideoShare' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /ESSVideoShare/ESSVideoShare.h: -------------------------------------------------------------------------------- 1 | // 2 | // ESSVideoShare.h 3 | // ESSVideoShare 4 | // 5 | // Created by Matthias Gansrigler on 27.11.11. 6 | // Copyright (c) 2011 Eternal Storms Software. All rights reserved. 7 | // 8 | 9 | /* 10 | 11 | License Agreement for Source Code provided by Matthias Gansrigler 12 | 13 | This software is supplied to you by Matthias Gansrigler in consideration of your agreement to the following terms, 14 | and your use, installation, modification or redistribution of this software constitutes acceptance of these terms. 15 | If you do not agree with these terms, please do not use, install, modify or redistribute this software. 16 | 17 | In consideration of your agreement to abide by the following terms, and subject to these terms, Matthias Gansrigler grants you a personal, 18 | non-exclusive license, to use, reproduce, modify and redistribute the software, with or without modifications, in source and/or binary forms; 19 | provided that if you redistribute the software in its entirety and without modifications, you must retain this notice and the following text and 20 | disclaimers in all such redistributions of the software, and that in all cases attribution of Matthias Gansrigler as the original author of the source code 21 | shall be included in all such resulting software products or distributions. Neither the name, trademarks, service marks or logos of Matthias Gansrigler may be used 22 | to endorse or promote products derived from the software without specific prior written permission from Matthias Gansrigler. 23 | Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Matthias Gansrigler herein, 24 | including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the software may be incorporated. 25 | 26 | The software is provided by Matthias Gansrigler on an "AS IS" basis. 27 | MATTHIAS GANSRIGLER MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, 28 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 29 | 30 | IN NO EVENT SHALL MATTHIAS GANSRIGLER BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES 31 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 | ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, 33 | TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF Matthias Gansrigler HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | 35 | 36 | ------------------------ 37 | 38 | 39 | This code uses the OAuthConsumer framework http://code.google.com/p/oauthconsumer/ which is under the MIT License http://www.opensource.org/licenses/mit-license.php 40 | 41 | 42 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 43 | 44 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 45 | 46 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 47 | 48 | */ 49 | 50 | #import 51 | #import "ESSFacebook.h" 52 | #import "ESSYouTube.h" 53 | #import "ESSVimeo.h" 54 | #import "ESSFlickr.h" 55 | 56 | /*@interface ESSVideoShare : NSObject 57 | 58 | @end 59 | */ -------------------------------------------------------------------------------- /ESSVideoShare/ESSVimeo.h: -------------------------------------------------------------------------------- 1 | // 2 | // ESSVimeo.h 3 | // Zlidez 4 | // 5 | // Created by Matthias Gansrigler on 28.10.11. 6 | // Copyright (c) 2011 Eternal Storms Software. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "OAuthConsumer.h" 11 | #if (!TARGET_OS_IPHONE && !TARGET_OS_EMBEDDED && !TARGET_IPHONE_SIMULATOR) 12 | #import "ESSVimeoWindowController.h" 13 | #else 14 | #import "ESSVimeoiOSViewController.h" 15 | #endif 16 | 17 | #define ESSLocalizedString(key, comment) NSLocalizedStringFromTableInBundle((key),nil,[NSBundle bundleForClass:[self class]],(comment)) 18 | 19 | @class ESSVimeo; 20 | 21 | #define VIMEO_API_CALL_URL @"http://vimeo.com/api/rest/v2/" 22 | 23 | #define VIMEO_OAUTH_REQUEST_TOKEN_URL @"https://vimeo.com/oauth/request_token" 24 | #define VIMEO_OAUTH_AUTH_URL @"https://vimeo.com/oauth/authorize" 25 | #define VIMEO_OAUTH_ACCESS_TOKEN_URL @"https://vimeo.com/oauth/access_token" 26 | 27 | @protocol ESSVimeoDelegate 28 | 29 | @required 30 | #if (!TARGET_OS_IPHONE && !TARGET_OS_EMBEDDED && !TARGET_IPHONE_SIMULATOR) 31 | - (NSWindow *)ESSVimeoNeedsWindowToAttachWindowTo:(ESSVimeo *)uploader; 32 | #else 33 | - (UIViewController *)ESSVimeoNeedsViewControllerToAttachTo:(ESSVimeo *)uploader; 34 | #endif 35 | - (void)ESSVimeoDidUploadVideoWithVimeoURL:(NSURL *)url; 36 | - (void)ESSVimeoFinished:(ESSVimeo *)uploader; 37 | 38 | @end 39 | 40 | #if (!TARGET_OS_IPHONE && !TARGET_OS_EMBEDDED && !TARGET_IPHONE_SIMULATOR) 41 | @interface ESSVimeo : NSObject 42 | #else 43 | @interface ESSVimeo : NSObject 44 | #endif 45 | 46 | @property (assign) id delegate; 47 | #if (!TARGET_OS_IPHONE && !TARGET_OS_EMBEDDED && !TARGET_IPHONE_SIMULATOR) 48 | @property (retain) ESSVimeoWindowController *_winCtr; 49 | #else 50 | @property (retain) ESSVimeoiOSViewController *_viewCtr; 51 | #endif 52 | @property (assign) BOOL plusOnly; 53 | @property (retain) OAToken *_requestToken; 54 | @property (retain) OAToken *_authToken; 55 | @property (retain) OAConsumer *_oaconsumer; 56 | @property (retain) OAHMAC_SHA1SignatureProvider *_sigProv; 57 | @property (assign) NSUInteger _byteSizeOfVideo; 58 | @property (retain) NSURLConnection *_uploader; 59 | @property (retain) NSString *_uploadTicketID; 60 | @property (retain) NSString *_description; 61 | @property (retain) NSString *_title; 62 | @property (assign) BOOL _isPrivate; 63 | @property (retain) NSString *_tags; 64 | 65 | - (id)initWithAPIKey:(NSString *)key 66 | secret:(NSString *)secret 67 | canUploadToPlusOnly:(BOOL)canUploadToPlusOnly //if the key you have has plus-upload-access only, pass canUploadToPlusOnly -> YES 68 | delegate:(id)del; 69 | 70 | - (void)uploadVideoAtURL:(NSURL *)url; 71 | 72 | //private 73 | 74 | - (void)_uploadVideoAtURL:(NSURL *)url 75 | title:(NSString *)vidTitle 76 | description:(NSString *)descr 77 | tags:(NSString *)vidTags 78 | makePrivate:(BOOL)makePrivate; 79 | 80 | #pragma mark - 81 | #pragma mark Authorization 82 | 83 | - (void)_startAuthorization; //√ callback addition in format oauthcallback? 84 | 85 | - (void)_deauthorize; 86 | 87 | #if (TARGET_OS_IPHONE || TARGET_OS_EMBEDDED || TARGET_IPHONE_SIMULATOR) 88 | - (void)handleiOSURL:(NSURL *)url; 89 | #endif 90 | 91 | #pragma mark - 92 | #pragma mark Upload 93 | 94 | - (void)_getQuotaJustConfirmingLogin:(BOOL)confirming; 95 | 96 | #pragma mark - 97 | #pragma mark Private Methods 98 | 99 | - (NSString *)_executeMethod:(NSString *)method 100 | withParameters:(NSDictionary *)parameters; 101 | 102 | @end 103 | -------------------------------------------------------------------------------- /ESSVideoShare/ESSVimeoWindowController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ESSVimeoWindowController.h 3 | // Zlidez 4 | // 5 | // Created by Matthias Gansrigler on 21.11.11. 6 | // Copyright (c) 2011 Eternal Storms Software. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class ESSVimeoWindowController; 12 | 13 | @protocol ESSVimeoWindowDelegate 14 | 15 | @required 16 | - (void)vimeoWindowIsFinished:(ESSVimeoWindowController *)ctr; 17 | 18 | @end 19 | 20 | @interface ESSVimeoWindowController : NSWindowController 21 | 22 | @property (assign) id delegate; 23 | @property (retain) NSURL *videoURL; 24 | 25 | - (id)initWithVideoURL:(NSURL *)url delegate:(id)del; 26 | 27 | @property (retain) IBOutlet NSView *loginView; 28 | @property (assign) IBOutlet NSTextField *loginStatusField; 29 | @property (assign) IBOutlet NSProgressIndicator *loginStatusProgressIndicator; 30 | @property (assign) IBOutlet NSButton *authorizeButton; 31 | - (IBAction)authorize:(id)sender; 32 | - (IBAction)cancelAuthorization:(id)sender; 33 | 34 | @property (retain) IBOutlet NSView *uploadView; 35 | @property (assign) IBOutlet NSTextField *usernameField; 36 | @property (assign) IBOutlet NSTextField *titleField; 37 | @property (assign) IBOutlet NSTextField *descriptionField; 38 | @property (assign) IBOutlet NSTokenField *tagsField; 39 | @property (assign) IBOutlet NSButton *makePrivateButton; 40 | - (IBAction)cancelBeforeUpload:(id)sender; 41 | - (IBAction)startUpload:(id)sender; 42 | - (IBAction)changeAccount:(id)sender; 43 | 44 | @property (assign) IBOutlet NSView *noUploadSpaceView; 45 | @property (assign) IBOutlet NSImageView *noSpaceImageView; 46 | @property (assign) IBOutlet NSTextField *noSpaceStatusField; 47 | - (IBAction)cancelNoSpace:(id)sender; 48 | 49 | @property (retain) IBOutlet NSView *licenseView; 50 | - (IBAction)cancelLicense:(id)sender; 51 | - (IBAction)backToUploadView:(id)sender; 52 | - (IBAction)uploadNow:(id)sender; 53 | 54 | @property (assign) IBOutlet NSView *uploadProgressView; 55 | @property (assign) IBOutlet NSProgressIndicator *uploadProgressBar; 56 | @property (assign) IBOutlet NSTextField *uploadStatusField; 57 | @property (assign) IBOutlet NSButton *cancelUploadButton; 58 | - (IBAction)cancelDuringUpload:(id)sender; 59 | 60 | @property (assign) IBOutlet NSView *doneView; 61 | @property (assign) IBOutlet NSImageView *doneImageView; 62 | @property (assign) IBOutlet NSTextField *doneField; 63 | @property (assign) IBOutlet NSButton *viewOnVimeoButton; 64 | - (IBAction)viewOnVimeo:(id)sender; 65 | - (IBAction)done:(id)sender; 66 | 67 | - (void)switchToLoginViewWithAnimation:(BOOL)shouldAnimate; 68 | - (void)switchToUploadViewWithAnimation:(BOOL)shouldAnimate; 69 | 70 | - (void)showNoSpaceLeftWarning; 71 | - (void)showNoPlusAccountWarning; 72 | 73 | - (void)uploadUpdatedWithBytes:(NSUInteger)uploaded ofTotal:(NSUInteger)total; 74 | - (void)uploadFinishedWithURL:(NSURL *)vimeoURL; 75 | 76 | @end 77 | -------------------------------------------------------------------------------- /ESSVideoShare/ESSVimeoWindowController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ESSVimeoWindowController.m 3 | // Zlidez 4 | // 5 | // Created by Matthias Gansrigler on 21.11.11. 6 | // Copyright (c) 2011 Eternal Storms Software. All rights reserved. 7 | // 8 | 9 | #import "ESSVimeoWindowController.h" 10 | #import "ESSVimeo.h" 11 | 12 | @implementation ESSVimeoWindowController 13 | @synthesize doneView; 14 | @synthesize doneImageView; 15 | @synthesize doneField; 16 | @synthesize viewOnVimeoButton; 17 | @synthesize uploadProgressView; 18 | @synthesize uploadProgressBar; 19 | @synthesize uploadStatusField; 20 | @synthesize cancelUploadButton; 21 | @synthesize licenseView; 22 | @synthesize noUploadSpaceView; 23 | @synthesize noSpaceImageView; 24 | @synthesize noSpaceStatusField; 25 | @synthesize uploadView; 26 | @synthesize usernameField; 27 | @synthesize titleField; 28 | @synthesize descriptionField; 29 | @synthesize tagsField; 30 | @synthesize makePrivateButton; 31 | @synthesize loginView; 32 | @synthesize loginStatusField; 33 | @synthesize loginStatusProgressIndicator; 34 | @synthesize authorizeButton,delegate,videoURL; 35 | 36 | - (id)initWithVideoURL:(NSURL *)url 37 | delegate:(id)del 38 | { 39 | if (self = [super initWithWindowNibName:@"essvimeoWindow"]) 40 | { 41 | self.delegate = del; 42 | self.videoURL = url; 43 | 44 | return self; 45 | } 46 | 47 | return nil; 48 | } 49 | 50 | - (void)windowDidLoad 51 | { 52 | [super windowDidLoad]; 53 | 54 | // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. 55 | } 56 | 57 | - (void)awakeFromNib 58 | { 59 | [self.loginStatusProgressIndicator setHidden:NO]; 60 | } 61 | 62 | - (void)switchToLoginViewWithAnimation:(BOOL)shouldAnimate 63 | { 64 | [self.delegate _deauthorize]; 65 | 66 | [self.loginStatusField setHidden:YES]; 67 | [self.loginStatusProgressIndicator setHidden:YES]; 68 | [self.authorizeButton setEnabled:YES]; 69 | [self.authorizeButton setHidden:NO]; 70 | 71 | [self.uploadView removeFromSuperview]; 72 | [self.loginView setFrameOrigin:NSZeroPoint]; 73 | 74 | if (!shouldAnimate) 75 | { 76 | [self.window setContentSize:NSMakeSize(NSWidth(self.loginView.frame),38+NSHeight(self.loginView.frame))]; 77 | [self.loginView.animator setAlphaValue:1.0]; 78 | [self.window.contentView addSubview:self.loginView]; 79 | } else //shouldanimate 80 | { 81 | [self.window setFrame:NSMakeRect(0, 0, NSWidth(self.loginView.frame), 38+NSHeight(self.loginView.frame)) display:YES animate:YES]; 82 | [self.loginView setAlphaValue:0.0]; 83 | [self.window.contentView addSubview:self.loginView]; 84 | [self.loginView.animator setAlphaValue:1.0]; 85 | } 86 | } 87 | 88 | - (void)switchToUploadViewWithAnimation:(BOOL)shouldAnimate 89 | { 90 | [self.loginStatusField setHidden:YES]; 91 | [self.loginStatusProgressIndicator setHidden:YES]; 92 | [self.authorizeButton setEnabled:YES]; 93 | [self.authorizeButton setHidden:NO]; 94 | 95 | [self.loginView removeFromSuperview]; 96 | [self.uploadView setFrameOrigin:NSZeroPoint]; 97 | 98 | if (!shouldAnimate) 99 | { 100 | [self.window setContentSize:NSMakeSize(NSWidth(self.uploadView.frame),38+NSHeight(self.uploadView.frame))]; 101 | [self.uploadView.animator setAlphaValue:1.0]; 102 | [self.window.contentView addSubview:self.uploadView]; 103 | } else //shouldanimate 104 | { 105 | [self.window setFrame:NSMakeRect(0, 0, NSWidth(self.uploadView.frame), 38+NSHeight(self.uploadView.frame)) display:YES animate:YES]; 106 | self.uploadView.alphaValue = 1.0; 107 | [self.window.contentView addSubview:self.uploadView]; 108 | } 109 | } 110 | 111 | - (IBAction)authorize:(id)sender 112 | { 113 | [self.authorizeButton setHidden:YES]; 114 | [self.authorizeButton setEnabled:NO]; 115 | [self.loginStatusField setHidden:NO]; 116 | [self.loginStatusProgressIndicator startAnimation:nil]; 117 | [self.loginStatusProgressIndicator setHidden:NO]; 118 | 119 | [self.delegate _startAuthorization]; 120 | } 121 | 122 | - (IBAction)cancelAuthorization:(id)sender 123 | { 124 | [self done:sender]; 125 | } 126 | 127 | - (IBAction)cancelBeforeUpload:(id)sender 128 | { 129 | [self done:sender]; 130 | } 131 | 132 | - (IBAction)startUpload:(id)sender 133 | { 134 | [self.uploadView removeFromSuperview]; 135 | [self.licenseView setFrameOrigin:NSZeroPoint]; 136 | [self.window setFrame:NSMakeRect(0, 0, NSWidth(self.licenseView.frame), 38+NSHeight(self.licenseView.frame)) display:YES animate:YES]; 137 | self.licenseView.alphaValue = 0.0; 138 | [self.window.contentView addSubview:self.licenseView]; 139 | [self.licenseView.animator setAlphaValue:1.0]; 140 | } 141 | 142 | - (IBAction)changeAccount:(id)sender 143 | { 144 | [self.delegate _deauthorize]; 145 | 146 | [self switchToLoginViewWithAnimation:YES]; 147 | } 148 | 149 | - (IBAction)cancelNoSpace:(id)sender 150 | { 151 | [self done:sender]; 152 | } 153 | 154 | - (IBAction)cancelLicense:(id)sender 155 | { 156 | [self done:sender]; 157 | } 158 | 159 | - (IBAction)backToUploadView:(id)sender 160 | { 161 | [self.licenseView removeFromSuperview]; 162 | [self.uploadView setFrameOrigin:NSZeroPoint]; 163 | [self.window setFrame:NSMakeRect(0, 0, NSWidth(self.uploadView.frame), 38+NSHeight(self.uploadView.frame)) display:YES animate:YES]; 164 | self.uploadView.alphaValue = 0.0; 165 | [self.window.contentView addSubview:self.uploadView]; 166 | [self.uploadView.animator setAlphaValue:1.0]; 167 | } 168 | 169 | - (IBAction)uploadNow:(id)sender 170 | { 171 | [self.uploadProgressBar setIndeterminate:YES]; 172 | [self.uploadProgressBar startAnimation:nil]; 173 | 174 | self.uploadStatusField.stringValue = ESSLocalizedString(@"ESSVimeoInitializingUpload", nil); 175 | 176 | [self.licenseView removeFromSuperview]; 177 | [self.uploadProgressView setFrameOrigin:NSZeroPoint]; 178 | [self.window setFrame:NSMakeRect(0, 0, NSWidth(self.uploadProgressView.frame), 38+NSHeight(self.uploadProgressView.frame)) display:YES animate:YES]; 179 | self.uploadProgressView.alphaValue = 0.0; 180 | [self.window.contentView addSubview:self.uploadProgressView]; 181 | [self.uploadProgressView.animator setAlphaValue:1.0]; 182 | 183 | [self.delegate _uploadVideoAtURL:self.videoURL 184 | title:self.titleField.stringValue 185 | description:self.descriptionField.stringValue 186 | tags:self.tagsField.stringValue 187 | makePrivate:(self.makePrivateButton.state == NSOnState)]; 188 | } 189 | 190 | - (IBAction)cancelDuringUpload:(id)sender 191 | { 192 | [self done:sender]; 193 | } 194 | 195 | - (IBAction)viewOnVimeo:(id)sender 196 | { 197 | [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[sender alternateTitle]]]; 198 | } 199 | 200 | - (IBAction)done:(id)sender 201 | { 202 | [sender setEnabled:NO]; 203 | 204 | [self.window orderOut:nil]; 205 | //if (self.window.parentWindow != nil) 206 | [NSApp endSheet:self.window]; 207 | 208 | if ([self.delegate respondsToSelector:@selector(vimeoWindowIsFinished:)]) 209 | { 210 | double delayInSeconds = 0.6; 211 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC); 212 | dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ 213 | [self.delegate vimeoWindowIsFinished:self]; 214 | }); 215 | } 216 | } 217 | 218 | - (void)showNoSpaceLeftWarning 219 | { 220 | [self.loginView removeFromSuperview]; 221 | [self.noUploadSpaceView setFrameOrigin:NSZeroPoint]; 222 | [self.window setFrame:NSMakeRect(0, 0, NSWidth(self.noUploadSpaceView.frame), 38+NSHeight(self.noUploadSpaceView.frame)) display:YES animate:YES]; 223 | self.noUploadSpaceView.alphaValue = 0.0; 224 | [self.window.contentView addSubview:self.noUploadSpaceView]; 225 | [self.noUploadSpaceView.animator setAlphaValue:1.0]; 226 | NSString *imgPath = @"/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"; 227 | NSImage *img = [[[NSImage alloc] initWithContentsOfFile:imgPath] autorelease]; 228 | self.noSpaceImageView.image = img; 229 | self.noSpaceStatusField.stringValue = ESSLocalizedString(@"ESSVimeoNoSpaceLeft", nil); 230 | } 231 | 232 | - (void)showNoPlusAccountWarning 233 | { 234 | [self.loginView removeFromSuperview]; 235 | [self.noUploadSpaceView setFrameOrigin:NSZeroPoint]; 236 | [self.window setFrame:NSMakeRect(0, 0, NSWidth(self.noUploadSpaceView.frame), 38+NSHeight(self.noUploadSpaceView.frame)) display:YES animate:YES]; 237 | self.noUploadSpaceView.alphaValue = 0.0; 238 | [self.window.contentView addSubview:self.noUploadSpaceView]; 239 | [self.noUploadSpaceView.animator setAlphaValue:1.0]; 240 | NSString *imgPath = @"/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"; 241 | NSImage *img = [[[NSImage alloc] initWithContentsOfFile:imgPath] autorelease]; 242 | self.noSpaceImageView.image = img; 243 | self.noSpaceStatusField.stringValue = ESSLocalizedString(@"ESSVimeoNoPlusAccount", nil); 244 | } 245 | 246 | - (void)uploadUpdatedWithBytes:(NSUInteger)uploaded ofTotal:(NSUInteger)total 247 | { 248 | [self.uploadProgressBar setIndeterminate:NO]; 249 | [self.uploadProgressBar startAnimation:nil]; 250 | self.uploadProgressBar.minValue = 0; 251 | self.uploadProgressBar.maxValue = total; 252 | self.uploadProgressBar.doubleValue = uploaded; 253 | 254 | double percentDone = uploaded*100/total; 255 | percentDone = round(percentDone); 256 | 257 | self.uploadStatusField.stringValue = [NSString stringWithFormat:ESSLocalizedString(@"ESSVimeoUploadPercentageDone",nil),(NSUInteger)percentDone]; 258 | 259 | if (uploaded == total) 260 | { 261 | [self.uploadProgressBar setIndeterminate:YES]; 262 | [self.uploadProgressBar startAnimation:nil]; 263 | [self.cancelUploadButton setEnabled:NO]; 264 | self.uploadStatusField.stringValue = ESSLocalizedString(@"ESSVimeoWaitingForVimeoToVerifyVideo",nil); 265 | } 266 | } 267 | 268 | - (void)uploadFinishedWithURL:(NSURL *)vimeoURL 269 | { 270 | if (vimeoURL == nil) 271 | { 272 | [self.viewOnVimeoButton setEnabled:NO]; 273 | [self.viewOnVimeoButton setHidden:YES]; 274 | self.doneField.stringValue = ESSLocalizedString(@"ESSVimeoUploadFailed",nil); 275 | NSString *imgPath = @"/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"; 276 | NSImage *img = [[[NSImage alloc] initWithContentsOfFile:imgPath] autorelease]; 277 | self.doneImageView.image = img; 278 | } else 279 | { 280 | [self.viewOnVimeoButton setEnabled:YES]; 281 | [self.viewOnVimeoButton setHidden:NO]; 282 | self.doneField.stringValue = ESSLocalizedString(@"ESSVimeoUploadSucceeded",nil); 283 | NSString *imgPath = @"/System/Library/CoreServices/Installer.app/Contents/PlugIns/Summary.bundle/Contents/Resources/Success.png"; 284 | NSImage *img = [[[NSImage alloc] initWithContentsOfFile:imgPath] autorelease]; 285 | self.doneImageView.image = img; 286 | } 287 | 288 | [self.viewOnVimeoButton setAlternateTitle:[vimeoURL absoluteString]]; 289 | 290 | [self.uploadProgressView removeFromSuperview]; 291 | [self.doneView setFrameOrigin:NSZeroPoint]; 292 | [self.window setFrame:NSMakeRect(0, 0, NSWidth(self.doneView.frame), 38+NSHeight(self.doneView.frame)) display:YES animate:YES]; 293 | self.doneView.alphaValue = 0.0; 294 | [self.window.contentView addSubview:self.doneView]; 295 | [self.doneView.animator setAlphaValue:1.0]; 296 | } 297 | 298 | - (void)dealloc 299 | { 300 | self.loginView = nil; 301 | self.uploadView = nil; 302 | self.delegate = nil; 303 | self.videoURL = nil; 304 | self.licenseView = nil; 305 | 306 | [super dealloc]; 307 | } 308 | 309 | @end 310 | -------------------------------------------------------------------------------- /ESSVideoShare/ESSVimeoiOSViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ESSVimeoiOSViewController.h 3 | // essvideoshareiostest 4 | // 5 | // Created by Matthias Gansrigler on 29.03.12. 6 | // Copyright (c) 2012 Eternal Storms Software. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class ESSVimeoiOSViewController; 12 | 13 | @protocol ESSVimeoiOSViewControllerDelegate 14 | 15 | @required 16 | - (void)vimeoIsFinished:(ESSVimeoiOSViewController *)ctr; 17 | 18 | @end 19 | 20 | @interface ESSVimeoiOSViewController : UIViewController 21 | 22 | @property (assign) id delegate; 23 | @property (retain) NSURL *videoURL; 24 | @property (retain) NSString *username; 25 | 26 | @property (retain) UINavigationController *navCtr; 27 | 28 | @property (retain) IBOutlet UIViewController *videoInfoViewController; 29 | 30 | @property (retain) IBOutlet UIViewController *warningViewController; 31 | @property (assign) IBOutlet UIImageView *warningImageView; 32 | @property (assign) IBOutlet UILabel *warningLabel; 33 | 34 | @property (retain) IBOutlet UIViewController *termsViewController; 35 | 36 | @property (retain) IBOutlet UIViewController *uploadingViewController; 37 | @property (assign) IBOutlet UILabel *uploadingLabel; 38 | @property (assign) IBOutlet UIProgressView *uploadingProgressView; 39 | 40 | @property (retain) IBOutlet UIViewController *doneViewController; 41 | @property (retain) IBOutlet UIImageView *doneImageView; 42 | @property (retain) IBOutlet UILabel *doneLabel; 43 | @property (retain) IBOutlet UIButton *doneButton; 44 | 45 | @property (retain) UITableViewCell *titleTVCell; 46 | @property (retain) UITableViewCell *descriptionTVCell; 47 | @property (retain) UITableViewCell *tagsTVCell; 48 | @property (retain) UITableViewCell *privacyTVCell; 49 | 50 | - (id)initWithVideoURL:(NSURL *)url delegate:(id)del; 51 | 52 | - (void)switchToLoginViewWithAnimation:(BOOL)animate; 53 | - (void)switchToUploadViewWithAnimation:(BOOL)animate; 54 | 55 | - (void)showNoPlusAccountWarning; 56 | - (void)showNoSpaceLeftWarning; 57 | 58 | - (void)cancel:(id)sender; 59 | - (void)login:(id)sender; 60 | - (void)showTerms:(id)sender; 61 | - (void)startUpload:(id)sender; 62 | - (void)uploadStarted; 63 | 64 | - (void)updateUsername:(NSString *)name; 65 | 66 | - (void)resetLoginView; //activates the authorize button at the top right and the cancel button at the top left 67 | 68 | - (void)uploadUpdatedWithUploadedBytes:(NSInteger)uploadedBytes ofTotalBytes:(NSInteger)totalBytes; 69 | - (void)uploadFinishedWithURL:(NSURL *)url; 70 | 71 | - (IBAction)showOnVimeo:(id)sender; 72 | 73 | - (UITableViewCell *)customTVCellForIndexPath:(NSIndexPath *)indexPath; 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /ESSVideoShare/ESSVimeoiOSViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ESSVimeoiOSViewController.m 3 | // essvideoshareiostest 4 | // 5 | // Created by Matthias Gansrigler on 29.03.12. 6 | // Copyright (c) 2012 Eternal Storms Software. All rights reserved. 7 | // 8 | 9 | #import "ESSVimeoiOSViewController.h" 10 | #import "ESSVimeo.h" 11 | 12 | @interface ESSVimeoiOSViewController () 13 | 14 | @end 15 | 16 | @implementation ESSVimeoiOSViewController 17 | 18 | @synthesize delegate,videoURL,navCtr,username,videoInfoViewController,warningViewController,warningImageView,warningLabel,termsViewController,uploadingViewController,uploadingLabel,uploadingProgressView,doneViewController,doneImageView,doneLabel,doneButton,titleTVCell,descriptionTVCell,tagsTVCell,privacyTVCell; 19 | 20 | - (id)initWithVideoURL:(NSURL *)url delegate:(id)del 21 | { 22 | NSString *nibName = @"ESSVimeoiOSView_iPhone"; 23 | if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) 24 | { 25 | nibName = @"ESSVimeoiOSView_iPad"; 26 | self.modalPresentationStyle = UIModalPresentationFormSheet; 27 | self.videoInfoViewController.modalPresentationStyle = UIModalPresentationFormSheet; 28 | self.warningViewController.modalPresentationStyle = UIModalPresentationFormSheet; 29 | self.termsViewController.modalPresentationStyle = UIModalPresentationFormSheet; 30 | self.uploadingViewController.modalPresentationStyle = UIModalPresentationFormSheet; 31 | self.doneViewController.modalPresentationStyle = UIModalPresentationFormSheet; 32 | } 33 | 34 | if (self = [super initWithNibName:nibName bundle:nil]) 35 | { 36 | self.delegate = del; 37 | self.videoURL = url; 38 | 39 | return self; 40 | } 41 | 42 | return nil; 43 | } 44 | 45 | - (void)viewDidLoad 46 | { 47 | [super viewDidLoad]; 48 | // Do any additional setup after loading the view from its nib. 49 | } 50 | 51 | - (void)viewDidUnload 52 | { 53 | [super viewDidUnload]; 54 | // Release any retained subviews of the main view. 55 | // e.g. self.myOutlet = nil; 56 | } 57 | 58 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 59 | { 60 | return interfaceOrientation == UIInterfaceOrientationPortrait; 61 | } 62 | 63 | - (void)switchToLoginViewWithAnimation:(BOOL)animate 64 | { 65 | [self.navCtr popToViewController:self animated:animate]; 66 | 67 | UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithTitle:ESSLocalizedString(@"ESSVimeoiOSCancel", nil) 68 | style:UIBarButtonItemStyleBordered 69 | target:self 70 | action:@selector(cancel:)]; 71 | self.navigationItem.leftBarButtonItem = btn; 72 | [btn release]; 73 | btn = [[UIBarButtonItem alloc] initWithTitle:ESSLocalizedString(@"ESSVimeoiOSLogin", nil) 74 | style:UIBarButtonItemStyleDone 75 | target:self 76 | action:@selector(login:)]; 77 | self.navigationItem.rightBarButtonItem = btn; 78 | [btn release]; 79 | self.navigationItem.title = @"Vimeo"; 80 | } 81 | 82 | - (void)cancel:(id)sender 83 | { 84 | if ([self.delegate respondsToSelector:@selector(vimeoIsFinished:)]) 85 | [self.delegate vimeoIsFinished:self]; 86 | } 87 | 88 | - (void)login:(id)sender 89 | { 90 | self.navigationItem.leftBarButtonItem.enabled = NO; 91 | self.navigationItem.rightBarButtonItem.enabled = NO; 92 | 93 | [(ESSVimeo *)self.delegate _startAuthorization]; 94 | } 95 | 96 | - (void)resetLoginView 97 | { 98 | double delayInSeconds = 0.5; 99 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC); 100 | dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ 101 | UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithTitle:ESSLocalizedString(@"ESSVimeoiOSCancel", nil) 102 | style:UIBarButtonItemStyleBordered 103 | target:self 104 | action:@selector(cancel:)]; 105 | self.navigationItem.leftBarButtonItem = btn; 106 | [btn release]; 107 | btn = [[UIBarButtonItem alloc] initWithTitle:ESSLocalizedString(@"ESSVimeoiOSLogin", nil) 108 | style:UIBarButtonItemStyleDone 109 | target:self 110 | action:@selector(login:)]; 111 | self.navigationItem.rightBarButtonItem = btn; 112 | [btn release]; 113 | }); 114 | } 115 | 116 | - (void)switchToUploadViewWithAnimation:(BOOL)animate 117 | { 118 | [self.navCtr pushViewController:self.videoInfoViewController animated:animate]; 119 | UIViewController *crCtr = self.videoInfoViewController; 120 | 121 | UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithTitle:ESSLocalizedString(@"ESSVimeoiOSCancel", nil) 122 | style:UIBarButtonItemStyleBordered 123 | target:self 124 | action:@selector(cancel:)]; 125 | crCtr.navigationItem.leftBarButtonItem = btn; 126 | [btn release]; 127 | btn = [[UIBarButtonItem alloc] initWithTitle:ESSLocalizedString(@"ESSVimeoiOSUpload", nil) 128 | style:UIBarButtonItemStyleDone 129 | target:self 130 | action:@selector(showTerms:)]; 131 | crCtr.navigationItem.rightBarButtonItem = btn; 132 | [btn release]; 133 | crCtr.title = @"Vimeo"; 134 | } 135 | 136 | - (void)showTerms:(id)sender 137 | { 138 | //only if title is set. 139 | UITableViewCell *cell = self.titleTVCell; 140 | UITextField *videoTitleField = nil; 141 | for (UIView *view in cell.subviews) 142 | { 143 | if ([view isKindOfClass:[UITextField class]]) 144 | { 145 | videoTitleField = (UITextField *)view; 146 | break; 147 | } 148 | } 149 | [videoTitleField resignFirstResponder]; 150 | NSString *title = videoTitleField.text; 151 | 152 | if (title.length == 0) 153 | { 154 | [videoTitleField becomeFirstResponder]; 155 | return; 156 | } 157 | 158 | [self.navCtr pushViewController:self.termsViewController animated:YES]; 159 | 160 | UIViewController *crCtr = self.termsViewController; 161 | 162 | UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithTitle:ESSLocalizedString(@"ESSVimeoiOSCancel", nil) 163 | style:UIBarButtonItemStyleBordered 164 | target:self 165 | action:@selector(cancel:)]; 166 | crCtr.navigationItem.leftBarButtonItem = btn; 167 | [btn release]; 168 | btn = [[UIBarButtonItem alloc] initWithTitle:ESSLocalizedString(@"ESSVimeoiOSUpload", nil) 169 | style:UIBarButtonItemStyleDone 170 | target:self 171 | action:@selector(startUpload:)]; 172 | crCtr.navigationItem.rightBarButtonItem = btn; 173 | [btn release]; 174 | crCtr.title = @"Vimeo"; 175 | } 176 | 177 | - (void)showNoSpaceLeftWarning 178 | { 179 | self.warningLabel.text = ESSLocalizedString(@"ESSVimeoiOSNoSpaceWarning", nil); 180 | [self.navCtr pushViewController:self.warningViewController animated:YES]; 181 | 182 | UIViewController *crCtr = self.videoInfoViewController; 183 | 184 | crCtr.title = @"Vimeo"; 185 | } 186 | 187 | - (void)showNoPlusAccountWarning 188 | { 189 | self.warningLabel.text = ESSLocalizedString(@"ESSVimeoiOSNoPlusAccountWarning", nil); 190 | [self.navCtr pushViewController:self.warningViewController animated:YES]; 191 | 192 | UIViewController *crCtr = self.videoInfoViewController; 193 | 194 | crCtr.title = @"Vimeo"; 195 | } 196 | 197 | - (void)startUpload:(id)sender 198 | { 199 | UITableViewCell *cell = self.titleTVCell; 200 | UITextField *videoTitleField = nil; 201 | for (UIView *view in cell.subviews) 202 | { 203 | if ([view isKindOfClass:[UITextField class]]) 204 | { 205 | videoTitleField = (UITextField *)view; 206 | break; 207 | } 208 | } 209 | [videoTitleField resignFirstResponder]; 210 | NSString *title = videoTitleField.text; 211 | 212 | if (title.length == 0) 213 | { 214 | [videoTitleField becomeFirstResponder]; 215 | return; 216 | } 217 | 218 | cell = self.descriptionTVCell; 219 | UITextField *videoDescField = nil; 220 | for (UIView *view in cell.subviews) 221 | { 222 | if ([view isKindOfClass:[UITextField class]]) 223 | { 224 | videoDescField = (UITextField *)view; 225 | break; 226 | } 227 | } 228 | [videoDescField resignFirstResponder]; 229 | NSString *description = videoDescField.text; 230 | 231 | cell = self.tagsTVCell; 232 | UITextField *videoTags = nil; 233 | for (UIView *view in cell.subviews) 234 | { 235 | if ([view isKindOfClass:[UITextField class]]) 236 | { 237 | videoTags = (UITextField *)view; 238 | break; 239 | } 240 | } 241 | [videoTags resignFirstResponder]; 242 | NSString *tags = videoTags.text; 243 | 244 | cell = [((UITableView *)self.videoInfoViewController.view) cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:2]]; 245 | UISwitch *aSwitch = nil; 246 | for (UIView *view in cell.subviews) 247 | { 248 | if ([view isKindOfClass:[UISwitch class]]) 249 | { 250 | aSwitch = (UISwitch *)view; 251 | break; 252 | } 253 | } 254 | 255 | BOOL isPrivate = aSwitch.on; 256 | 257 | [self uploadStarted]; 258 | 259 | [(ESSVimeo *)self.delegate _uploadVideoAtURL:self.videoURL 260 | title:title 261 | description:description 262 | tags:tags 263 | makePrivate:isPrivate]; 264 | } 265 | 266 | - (void)uploadStarted 267 | { 268 | self.uploadingProgressView.progress = 0.0; 269 | [self.navCtr pushViewController:self.uploadingViewController animated:YES]; 270 | UIViewController *crCtr = self.uploadingViewController; 271 | 272 | UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithTitle:ESSLocalizedString(@"ESSVimeoiOSCancel", nil) 273 | style:UIBarButtonItemStyleBordered 274 | target:self 275 | action:@selector(cancel:)]; 276 | crCtr.navigationItem.leftBarButtonItem = btn; 277 | [btn release]; 278 | crCtr.navigationItem.rightBarButtonItem = nil; 279 | } 280 | 281 | - (void)updateUsername:(NSString *)name 282 | { 283 | self.username = name; 284 | 285 | //update videoinfotableview with username 286 | [(UITableView *)self.videoInfoViewController.view reloadData]; 287 | } 288 | 289 | - (void)uploadUpdatedWithUploadedBytes:(NSInteger)uploadedBytes ofTotalBytes:(NSInteger)totalBytes 290 | { 291 | [self.uploadingProgressView setProgress:(CGFloat)((CGFloat)uploadedBytes/(CGFloat)totalBytes) animated:YES]; 292 | double percentDone = uploadedBytes*100/totalBytes; 293 | percentDone = round(percentDone); 294 | 295 | self.uploadingLabel.text = [NSString stringWithFormat:ESSLocalizedString(@"ESSVimeoUploadPercentageDone", nil),(NSUInteger)percentDone]; 296 | 297 | if (uploadedBytes == totalBytes) 298 | self.uploadingLabel.text = ESSLocalizedString(@"ESSVimeoWaitingForVimeoToVerifyVideo", nil); 299 | } 300 | 301 | - (void)uploadFinishedWithURL:(NSURL *)url 302 | { 303 | if (url == nil) 304 | { 305 | //upload failed 306 | self.doneLabel.text = ESSLocalizedString(@"ESSVimeoUploadFailed", nil); 307 | [self.doneButton setTitle:nil forState:UIControlStateDisabled]; 308 | } else 309 | { 310 | self.doneLabel.text = ESSLocalizedString(@"ESSVimeoUploadSucceeded", nil); 311 | [self.doneButton setTitle:url.absoluteString forState:UIControlStateDisabled]; 312 | } 313 | 314 | [self.navCtr pushViewController:self.doneViewController animated:YES]; 315 | UIViewController *crCtr = self.doneViewController; 316 | 317 | UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithTitle:ESSLocalizedString(@"ESSVimeoiOSCancel", nil) 318 | style:UIBarButtonItemStyleBordered 319 | target:self 320 | action:@selector(cancel:)]; 321 | crCtr.navigationItem.leftBarButtonItem = btn; 322 | [btn release]; 323 | btn = [[UIBarButtonItem alloc] initWithTitle:ESSLocalizedString(@"ESSVimeoiOSDone", nil) 324 | style:UIBarButtonItemStyleDone 325 | target:self 326 | action:@selector(cancel:)]; 327 | crCtr.navigationItem.rightBarButtonItem = btn; 328 | [btn release]; 329 | } 330 | 331 | - (IBAction)showOnVimeo:(id)sender 332 | { 333 | NSURL *url = [NSURL URLWithString:[(UIButton *)sender titleForState:UIControlStateDisabled]]; 334 | 335 | [[UIApplication sharedApplication] openURL:url]; 336 | } 337 | 338 | //table view delegate/data source methods 339 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 340 | { 341 | if (section == 0) //user name 342 | return 1; 343 | else if (section == 1) //video info - title and description 344 | return 3; 345 | else if (section == 2) //privacy 346 | return 1; 347 | 348 | return 0; 349 | } 350 | 351 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 352 | { 353 | return 3; 354 | } 355 | 356 | - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section 357 | { 358 | if (section == 0) //facebook name 359 | return ESSLocalizedString(@"ESSVimeoiOSAccountInfoFooter", nil); 360 | else if (section == 1) //video info 361 | return ESSLocalizedString(@"ESSVimeoiOSVideoInfoTagFooter",nil); 362 | else if (section == 2) //privacy 363 | return ESSLocalizedString(@"ESSVimeoiOSPrivacyInfoFooter",nil); 364 | 365 | return nil; 366 | } 367 | 368 | - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section 369 | { 370 | if (section == 0) 371 | return ESSLocalizedString(@"ESSVimeoiOSAccountInfoHeader", nil); 372 | else if (section == 1) 373 | return ESSLocalizedString(@"ESSVimeoiOSVideoInfoHeader", nil); 374 | else if (section == 2) 375 | return ESSLocalizedString(@"ESSVimeoiOSPrivacyHeader", nil); 376 | 377 | return nil; 378 | } 379 | 380 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 381 | { 382 | if ([indexPath indexAtPosition:0] == 0) 383 | { 384 | //user name cell 385 | UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"userNameCell"]; 386 | cell.textLabel.text = ESSLocalizedString(@"ESSVimeoiOSUsernameTVCellTitle",nil); 387 | cell.detailTextLabel.text = self.username; 388 | return [cell autorelease]; 389 | } else if ([indexPath indexAtPosition:0] == 1) 390 | { 391 | //video info 392 | if ([indexPath indexAtPosition:1] == 0) 393 | { 394 | if (self.titleTVCell == nil) 395 | self.titleTVCell = [self customTVCellForIndexPath:indexPath]; 396 | 397 | return self.titleTVCell; 398 | } else if ([indexPath indexAtPosition:1] == 1) 399 | { 400 | if (self.descriptionTVCell == nil) 401 | self.descriptionTVCell = [self customTVCellForIndexPath:indexPath]; 402 | 403 | return self.descriptionTVCell; 404 | } else 405 | { 406 | if (self.tagsTVCell == nil) 407 | self.tagsTVCell = [self customTVCellForIndexPath:indexPath]; 408 | 409 | return self.tagsTVCell; 410 | } 411 | } else if ([indexPath indexAtPosition:0] == 2) 412 | { 413 | //privacy 414 | if (self.privacyTVCell == nil) 415 | { 416 | self.privacyTVCell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"privacyCell"] autorelease]; 417 | self.privacyTVCell.accessoryType = UITableViewCellAccessoryNone; 418 | self.privacyTVCell.selectionStyle = UITableViewCellSelectionStyleNone; 419 | self.privacyTVCell.textLabel.text = ESSLocalizedString(@"ESSVimeoiOSPrivateVideoTVCellTitle",nil); 420 | 421 | UISwitch *aSwitch = nil; 422 | if ([[UIDevice currentDevice] userInterfaceIdiom] != UIUserInterfaceIdiomPad) 423 | aSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(222,10,186,20)]; 424 | else //iPad 425 | aSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(420,10,186,20)]; 426 | aSwitch.on = YES; 427 | 428 | [self.privacyTVCell addSubview:aSwitch]; 429 | [aSwitch release]; 430 | } 431 | 432 | return self.privacyTVCell; 433 | } 434 | 435 | return nil; 436 | } 437 | 438 | - (UITableViewCell *)customTVCellForIndexPath:(NSIndexPath *)indexPath 439 | { 440 | UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"videoInfoCell"]; 441 | cell.accessoryType = UITableViewCellAccessoryNone; 442 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 443 | 444 | UITextField *editableTextField = nil; 445 | if ([[UIDevice currentDevice] userInterfaceIdiom] != UIUserInterfaceIdiomPad) 446 | editableTextField = [[UITextField alloc] initWithFrame:CGRectMake(120,11,186,22)]; 447 | else 448 | editableTextField = [[UITextField alloc] initWithFrame:CGRectMake(145,11,360,22)]; 449 | editableTextField.adjustsFontSizeToFitWidth = YES; 450 | editableTextField.textColor = [UIColor colorWithRed:0.22 green:0.33 blue:0.53 alpha:1]; 451 | editableTextField.backgroundColor = cell.backgroundColor; 452 | editableTextField.autocorrectionType = UITextAutocorrectionTypeDefault; 453 | editableTextField.autocapitalizationType = UITextAutocapitalizationTypeSentences; 454 | editableTextField.textAlignment = UITextAlignmentLeft; 455 | editableTextField.tag = 0; 456 | editableTextField.clearButtonMode = UITextFieldViewModeWhileEditing; 457 | editableTextField.enabled = YES; 458 | editableTextField.keyboardType = UIKeyboardTypeDefault; 459 | editableTextField.delegate = self; 460 | [cell addSubview:editableTextField]; 461 | if ([indexPath indexAtPosition:1] == 0) 462 | { 463 | //title 464 | editableTextField.returnKeyType = UIReturnKeyDone; 465 | cell.textLabel.text = ESSLocalizedString(@"ESSVimeoiOSTitleTVCellTitle",nil); 466 | editableTextField.placeholder = ESSLocalizedString(@"ESSVimeoiOSRequiredCellTitle", nil); 467 | } else if ([indexPath indexAtPosition:1] == 1) 468 | { 469 | //description 470 | editableTextField.returnKeyType = UIReturnKeyDone; 471 | cell.textLabel.text = ESSLocalizedString(@"ESSVimeoiOSDescriptionTVCellTitle",nil); 472 | editableTextField.placeholder = ESSLocalizedString(@"ESSVimeoiOSOptionalCellTitle", nil); 473 | } else 474 | { 475 | editableTextField.returnKeyType = UIReturnKeyDone; 476 | cell.textLabel.text = ESSLocalizedString(@"ESSVimeoiOSTagsTVCellTitle",nil); 477 | editableTextField.placeholder = ESSLocalizedString(@"ESSVimeoiOSOptionalCellTitle", nil); 478 | } 479 | [editableTextField release]; 480 | return [cell autorelease]; 481 | } 482 | 483 | - (BOOL)textFieldShouldReturn:(UITextField *)textField 484 | { 485 | [textField resignFirstResponder]; 486 | return YES; 487 | } 488 | 489 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 490 | { 491 | [tableView deselectRowAtIndexPath:indexPath animated:YES]; 492 | if ([indexPath indexAtPosition:0] == 0) 493 | { 494 | if ([self.delegate respondsToSelector:@selector(_deauthorize)]) 495 | [(ESSVimeo *)self.delegate _deauthorize]; 496 | 497 | [self switchToLoginViewWithAnimation:YES]; 498 | } 499 | } 500 | 501 | - (void)dealloc 502 | { 503 | self.delegate = nil; 504 | self.videoURL = nil; 505 | self.navCtr = nil; 506 | self.username = nil; 507 | self.videoInfoViewController = nil; 508 | self.warningViewController = nil; 509 | self.termsViewController = nil; 510 | self.uploadingViewController = nil; 511 | self.doneViewController = nil; 512 | 513 | [super dealloc]; 514 | } 515 | 516 | @end 517 | -------------------------------------------------------------------------------- /ESSVideoShare/ESSYouTube.h: -------------------------------------------------------------------------------- 1 | // 2 | // ESSYouTube.h 3 | // Zlidez 4 | // 5 | // Created by Matthias Gansrigler on 04.11.11. 6 | // Copyright (c) 2011 Eternal Storms Software. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #if (!TARGET_OS_IPHONE && !TARGET_OS_EMBEDDED && !TARGET_IPHONE_SIMULATOR) 12 | #import "ESSYouTubeWindowController.h" 13 | #else 14 | #import "ESSYouTubeiOSViewController.h" 15 | #endif 16 | 17 | #define ESSLocalizedString(key, comment) NSLocalizedStringFromTableInBundle((key),nil,[NSBundle bundleForClass:[self class]],(comment)) 18 | 19 | @class ESSYouTube; 20 | 21 | @protocol ESSYouTubeDelegate 22 | 23 | @required 24 | #if (!TARGET_OS_IPHONE && !TARGET_OS_EMBEDDED && !TARGET_IPHONE_SIMULATOR) 25 | - (NSWindow *)ESSYouTubeNeedsWindowToAttachTo:(ESSYouTube *)youtube; 26 | #else 27 | - (UIViewController *)ESSYouTubeNeedsCurrentViewControllerToAttachTo:(ESSYouTube *)youtube; 28 | #endif 29 | - (void)ESSYouTubeDidUploadVideoWithYouTubeURL:(NSURL *)url; 30 | - (void)ESSYouTubeDidFinish:(ESSYouTube *)youtube; 31 | 32 | @end 33 | 34 | #if (!TARGET_OS_IPHONE && !TARGET_OS_EMBEDDED && !TARGET_IPHONE_SIMULATOR) 35 | @interface ESSYouTube : NSObject 36 | #else 37 | @interface ESSYouTube : NSObject 38 | #endif 39 | 40 | @property (assign) id delegate; 41 | @property (retain) NSString *developerKey; 42 | @property (retain) NSString *_authToken; 43 | #if (!TARGET_OS_IPHONE && !TARGET_OS_EMBEDDED && !TARGET_IPHONE_SIMULATOR) 44 | @property (retain) ESSYouTubeWindowController *_ytWinCtr; 45 | #else 46 | @property (retain) ESSYouTubeiOSViewController *_ytViewCtr; 47 | #endif 48 | @property (retain) NSURLConnection *_uploader; 49 | @property (retain) NSMutableData *_receivedData; 50 | 51 | - (id)initWithDelegate:(id)del 52 | developerKey:(NSString *)key; 53 | 54 | - (void)uploadVideoAtURL:(NSURL *)url; 55 | 56 | //private 57 | - (void)_authorize; //checks if we have a token saved. if so, skip ahead to upload view of windowcontroller. if not, present user with login in windowcontroller. 58 | 59 | - (void)_authorizeWithUsername:(NSString *)username 60 | password:(NSString *)password; //does the actual authorization 61 | 62 | - (void)_deauthorize; //removes authorization token from userdefaults 63 | 64 | - (NSString *)_nameForLoggedInUserErrorConnecting:(BOOL *)errorConnecting; 65 | 66 | - (void)_uploadVideoAtURL:(NSURL *)url 67 | withTitle:(NSString *)title 68 | description:(NSString *)description 69 | makePrivate:(BOOL)makePrivate 70 | keywords:(NSString *)keywords 71 | category:(NSString *)category; 72 | 73 | - (BOOL)_videoUploadWithID:(NSString *)videoID 74 | isFinishedWithError:(BOOL *)uploadFailed; 75 | 76 | - (NSDictionary *)_categoriesDictionary; 77 | - (void)_checkProcessingOnYouTubeWithVideoID:(NSString *)vidID; 78 | 79 | @end 80 | -------------------------------------------------------------------------------- /ESSVideoShare/ESSYouTubeWindowController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ESSYouTubeWindowController.h 3 | // Zlidez 4 | // 5 | // Created by Matthias Gansrigler on 04.11.11. 6 | // Copyright (c) 2011 Eternal Storms Software. All rights reserved. 7 | // 8 | 9 | #import 10 | @class ESSYouTubeWindowController; 11 | 12 | @protocol ESSYouTubeWindowControllerDelegate 13 | 14 | @required 15 | - (void)youtubeWindowControllerDidDismiss:(ESSYouTubeWindowController *)ytWCtr; 16 | 17 | @end 18 | 19 | @interface ESSYouTubeWindowController : NSWindowController 20 | 21 | @property (assign) id delegate; 22 | @property (retain) NSURL *videoURL; 23 | 24 | @property (retain) IBOutlet NSView *loginView; 25 | @property (assign) IBOutlet NSTextField *usernameField; 26 | @property (assign) IBOutlet NSSecureTextField *passwordField; 27 | @property (assign) IBOutlet NSButton *signInButton; 28 | @property (assign) IBOutlet NSTextField *signingInStatusField; 29 | @property (assign) IBOutlet NSProgressIndicator *signingInProgWheel; 30 | @property (assign) IBOutlet NSButton *loginCancelButton; 31 | 32 | @property (retain) IBOutlet NSView *uploadView; 33 | @property (assign) IBOutlet NSTextField *uploadUsernameField; 34 | @property (assign) IBOutlet NSPopUpButton *categoryPopUpButton; 35 | @property (assign) IBOutlet NSTextField *titleField; 36 | @property (assign) IBOutlet NSTextField *descriptionField; 37 | @property (assign) IBOutlet NSTokenField *tagsTokenField; 38 | @property (assign) IBOutlet NSButton *makePrivateButton; 39 | @property (assign) IBOutlet NSButton *uploadNextButton; 40 | 41 | @property (retain) IBOutlet NSView *licenseView; 42 | @property (assign) IBOutlet NSTextView *licenseTextView; 43 | 44 | @property (retain) IBOutlet NSView *uploadProgressView; 45 | @property (assign) IBOutlet NSProgressIndicator *uploadProgressBar; 46 | @property (assign) IBOutlet NSTextField *uploadStatusField; 47 | @property (assign) IBOutlet NSButton *duringUploadCancelButton; 48 | 49 | @property (retain) IBOutlet NSView *doneView; 50 | @property (assign) IBOutlet NSImageView *doneImageView; 51 | @property (assign) IBOutlet NSTextField *doneStatusField; 52 | @property (assign) IBOutlet NSButton *viewOnYouTubeButton; 53 | 54 | - (id)initWithDelegate:(id)del videoURL:(NSURL *)url; 55 | 56 | - (void)switchToLoginWithAnimation:(BOOL)shouldAnimate; //show username and password prompt 57 | - (void)switchToUploadWithAnimation:(BOOL)shouldAnimate; //show title,description etc. prompt 58 | 59 | - (void)uploadStarted; //show progress prompt 60 | - (void)uploadUpdatedWithUploadedBytes:(NSInteger)uploadedBytes ofTotalBytes:(NSInteger)totalBytes; 61 | - (void)uploadFinishedWithYouTubeVideoURL:(NSURL *)url; //loop while checking for processing of file. if processing on yt is done, switch to done-View with either success or failure notice 62 | 63 | - (IBAction)cancelLoginOrBeforeUpload:(id)sender; 64 | - (IBAction)cancelDuringUpload:(id)sender; 65 | - (IBAction)back:(id)sender; //if license, show upload, if upload show login 66 | - (IBAction)next:(id)sender; //if login show upload, if upload show license, if license start upload 67 | - (IBAction)startUpload:(id)sender; 68 | - (IBAction)viewOnYouTube:(id)sender; 69 | 70 | - (void)setupCategoriesPopUpButtonWithCategoriesDictionary:(NSDictionary *)catDict; 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /ESSVideoShare/ESSYouTubeWindowController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ESSYouTubeWindowController.m 3 | // Zlidez 4 | // 5 | // Created by Matthias Gansrigler on 04.11.11. 6 | // Copyright (c) 2011 Eternal Storms Software. All rights reserved. 7 | // 8 | 9 | #import "ESSYouTubeWindowController.h" 10 | #import "ESSYouTube.h" 11 | 12 | @implementation ESSYouTubeWindowController 13 | @synthesize loginView; 14 | @synthesize usernameField; 15 | @synthesize passwordField; 16 | @synthesize signInButton; 17 | @synthesize signingInStatusField; 18 | @synthesize signingInProgWheel; 19 | @synthesize loginCancelButton; 20 | @synthesize uploadView; 21 | @synthesize uploadUsernameField; 22 | @synthesize categoryPopUpButton; 23 | @synthesize titleField; 24 | @synthesize descriptionField; 25 | @synthesize tagsTokenField; 26 | @synthesize makePrivateButton; 27 | @synthesize uploadNextButton; 28 | @synthesize licenseView; 29 | @synthesize licenseTextView; 30 | @synthesize uploadProgressView; 31 | @synthesize uploadProgressBar; 32 | @synthesize uploadStatusField; 33 | @synthesize duringUploadCancelButton; 34 | @synthesize doneView; 35 | @synthesize doneImageView; 36 | @synthesize doneStatusField; 37 | @synthesize viewOnYouTubeButton; 38 | 39 | @synthesize delegate,videoURL; 40 | 41 | - (id)initWithDelegate:(id)del videoURL:(NSURL *)url 42 | { 43 | if (self = [super initWithWindowNibName:@"ESSYouTubeWindow"]) 44 | { 45 | self.delegate = del; 46 | self.videoURL = url; 47 | 48 | return self; 49 | } 50 | 51 | return nil; 52 | } 53 | 54 | - (void)windowDidLoad 55 | { 56 | [super windowDidLoad]; 57 | // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. 58 | } 59 | 60 | - (void)setupCategoriesPopUpButtonWithCategoriesDictionary:(NSDictionary *)catDict 61 | { 62 | NSMenu *men = self.categoryPopUpButton.menu; 63 | [men removeAllItems]; 64 | NSArray *arr = [[catDict allKeys] sortedArrayUsingSelector:@selector(compare:)]; 65 | for (NSString *key in arr) 66 | { 67 | NSMenuItem *it = [[NSMenuItem alloc] initWithTitle:key action:nil keyEquivalent:@""]; 68 | [it setRepresentedObject:[catDict objectForKey:key]]; 69 | [men addItem:it]; 70 | [it release]; 71 | } 72 | [self.uploadNextButton setEnabled:YES]; 73 | } 74 | 75 | - (void)switchToLoginWithAnimation:(BOOL)shouldAnimate //show username and password prompt 76 | { 77 | [self.uploadView removeFromSuperview]; 78 | 79 | self.usernameField.stringValue = @""; 80 | self.passwordField.stringValue = @""; 81 | [self.loginView setFrameOrigin:NSZeroPoint]; 82 | [self.loginCancelButton setHidden:NO]; 83 | [self.signingInProgWheel stopAnimation:nil]; 84 | [self.signingInProgWheel setHidden:YES]; 85 | [self.signingInStatusField setHidden:YES]; 86 | 87 | if (!shouldAnimate) 88 | { 89 | [self.window setContentSize:NSMakeSize(self.loginView.frame.size.width,self.loginView.frame.size.height+40)]; 90 | 91 | [self.window.contentView addSubview:self.loginView]; 92 | } else 93 | { 94 | self.loginView.alphaValue = 0.0; 95 | 96 | [self.window.contentView addSubview:self.loginView]; 97 | 98 | [self.loginView.animator setAlphaValue:1.0]; 99 | 100 | [self.window setFrame:NSMakeRect(self.window.frame.origin.x,self.window.frame.origin.y,self.loginView.frame.size.width,self.loginView.frame.size.height+40) 101 | display:YES 102 | animate:YES]; 103 | } 104 | } 105 | 106 | - (void)switchToUploadWithAnimation:(BOOL)shouldAnimate //show title,description etc. prompt 107 | { 108 | [self.loginView removeFromSuperview]; 109 | 110 | if (self.titleField.stringValue.length == 0) 111 | self.titleField.stringValue = ESSLocalizedString(@"ESSYouTubeDefaultTitle", nil); 112 | [self.signingInProgWheel setHidden:YES]; 113 | [self.uploadView setFrameOrigin:NSZeroPoint]; 114 | 115 | if (!shouldAnimate) 116 | { 117 | [self.window setContentSize:NSMakeSize(self.uploadView.frame.size.width, self.uploadView.frame.size.height+40)]; 118 | 119 | [self.window.contentView addSubview:self.uploadView]; 120 | } else 121 | { 122 | self.uploadView.alphaValue = 0.0; 123 | [self.window.contentView addSubview:self.uploadView]; 124 | 125 | [self.uploadView.animator setAlphaValue:1.0]; 126 | 127 | [self.window setFrame:NSMakeRect(self.window.frame.origin.x,self.window.frame.origin.y,self.uploadView.frame.size.width,self.uploadView.frame.size.height+40) 128 | display:YES 129 | animate:YES]; 130 | } 131 | } 132 | 133 | - (void)uploadStarted //show progress prompt 134 | { 135 | self.uploadStatusField.stringValue = ESSLocalizedString(@"ESSYouTubeInizializingUpload",nil); 136 | [self.licenseView removeFromSuperview]; 137 | [self.uploadProgressBar startAnimation:nil]; 138 | [self.uploadProgressBar setIndeterminate:YES]; 139 | 140 | [self.uploadProgressView setFrameOrigin:NSZeroPoint]; 141 | self.uploadProgressView.alphaValue = 0.0; 142 | [self.window.contentView addSubview:self.uploadProgressView]; 143 | 144 | [self.uploadProgressView.animator setAlphaValue:1.0]; 145 | 146 | [self.window setFrame:NSMakeRect(self.window.frame.origin.x,self.window.frame.origin.y,self.uploadProgressView.frame.size.width,self.uploadProgressView.frame.size.height+40) 147 | display:YES 148 | animate:YES]; 149 | } 150 | 151 | - (void)uploadUpdatedWithUploadedBytes:(NSInteger)uploadedBytes ofTotalBytes:(NSInteger)totalBytes 152 | { 153 | [self.uploadProgressBar setIndeterminate:NO]; 154 | self.uploadProgressBar.minValue = 0; 155 | self.uploadProgressBar.maxValue = totalBytes; 156 | self.uploadProgressBar.doubleValue = uploadedBytes; 157 | 158 | double percentDone = uploadedBytes*100/totalBytes; 159 | percentDone = round(percentDone); 160 | 161 | self.uploadStatusField.stringValue = [NSString stringWithFormat:ESSLocalizedString(@"ESSYouTubeUploadPercentageDone",nil),(NSUInteger)percentDone]; //@"%ld%% uploaded 162 | 163 | if (uploadedBytes == totalBytes) 164 | { 165 | [self.uploadProgressBar setIndeterminate:YES]; 166 | [self.uploadProgressBar startAnimation:nil]; 167 | [self.duringUploadCancelButton setEnabled:NO]; 168 | self.uploadStatusField.stringValue = ESSLocalizedString(@"ESSYouTubeWaitingForYouTubeToProcessVideo",nil); 169 | } 170 | } 171 | 172 | - (void)uploadFinishedWithYouTubeVideoURL:(NSURL *)url 173 | { 174 | if (url == nil) 175 | [self.viewOnYouTubeButton setHidden:YES]; 176 | else 177 | [self.viewOnYouTubeButton setHidden:NO]; 178 | self.viewOnYouTubeButton.alternateTitle = [url absoluteString]; 179 | 180 | //switch to done view 181 | [self.uploadProgressView removeFromSuperview]; 182 | 183 | [self.doneView setFrameOrigin:NSZeroPoint]; 184 | self.doneView.alphaValue = 0.0; 185 | [self.window.contentView addSubview:self.doneView]; 186 | 187 | [self.doneView.animator setAlphaValue:1.0]; 188 | 189 | [self.window setFrame:NSMakeRect(self.window.frame.origin.x,self.window.frame.origin.y,self.doneView.frame.size.width,self.doneView.frame.size.height+40) 190 | display:YES 191 | animate:YES]; 192 | } 193 | 194 | - (IBAction)cancelLoginOrBeforeUpload:(id)sender 195 | { 196 | [sender setEnabled:NO]; 197 | [self.window orderOut:nil]; 198 | //if (self.window.parentWindow != nil) 199 | [NSApp endSheet:self.window]; 200 | 201 | if ([self.delegate respondsToSelector:@selector(youtubeWindowControllerDidDismiss:)]) 202 | { 203 | double delayInSeconds = 0.6; 204 | dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC); 205 | dispatch_after(popTime, dispatch_get_main_queue(), ^(void) 206 | { 207 | [self.delegate youtubeWindowControllerDidDismiss:self]; 208 | }); 209 | } 210 | } 211 | 212 | - (IBAction)cancelDuringUpload:(id)sender 213 | { 214 | [self cancelLoginOrBeforeUpload:sender]; 215 | } 216 | 217 | - (IBAction)back:(id)sender //if license, show upload, if upload show login 218 | { 219 | if ([sender superview] == self.uploadView) //change... button pressed 220 | { 221 | [(ESSYouTube *)self.delegate _deauthorize]; 222 | [self switchToLoginWithAnimation:YES]; 223 | } else if ([sender superview] == self.licenseView) 224 | { 225 | [self.licenseView removeFromSuperview]; 226 | 227 | [self.uploadView setFrameOrigin:NSZeroPoint]; 228 | self.uploadView.alphaValue = 0.0; 229 | [self.window.contentView addSubview:self.uploadView]; 230 | 231 | [self.uploadView.animator setAlphaValue:1.0]; 232 | 233 | [self.window setFrame:NSMakeRect(self.window.frame.origin.x,self.window.frame.origin.y,self.uploadView.frame.size.width,self.uploadView.frame.size.height+40) 234 | display:YES 235 | animate:YES]; 236 | } 237 | } 238 | 239 | - (IBAction)next:(id)sender //if login show upload, if upload show license, if license start upload 240 | { 241 | if ([sender superview] == self.loginView) //perform login 242 | { 243 | if (self.usernameField.stringValue.length == 0 || self.passwordField.stringValue.length == 0) 244 | { 245 | NSBeep(); 246 | return; 247 | } 248 | 249 | [self.loginCancelButton setHidden:YES]; 250 | [self.signingInProgWheel startAnimation:nil]; 251 | [self.signingInProgWheel setHidden:NO]; 252 | [self.signingInStatusField setHidden:NO]; 253 | [(NSButton *)sender setEnabled:NO]; 254 | [(ESSYouTube *)self.delegate _authorizeWithUsername:self.usernameField.stringValue 255 | password:self.passwordField.stringValue]; 256 | } else if ([sender superview] == self.uploadView) //switch to license view 257 | { 258 | if (self.titleField.stringValue.length == 0 || self.descriptionField.stringValue.length == 0 || self.tagsTokenField.stringValue.length == 0) 259 | { 260 | NSBeep(); 261 | return; 262 | } 263 | 264 | [self.uploadView removeFromSuperview]; 265 | 266 | [self.licenseView setFrameOrigin:NSZeroPoint]; 267 | self.licenseView.alphaValue = 0.0; 268 | [self.window.contentView addSubview:self.licenseView]; 269 | 270 | [self.licenseView.animator setAlphaValue:1.0]; 271 | 272 | [self.window setFrame:NSMakeRect(self.window.frame.origin.x,self.window.frame.origin.y,self.licenseView.frame.size.width,self.licenseView.frame.size.height+40) 273 | display:YES 274 | animate:YES]; 275 | } 276 | } 277 | 278 | - (IBAction)startUpload:(id)sender 279 | { 280 | if (self.titleField.stringValue.length == 0 || self.descriptionField.stringValue.length == 0 || self.tagsTokenField.stringValue.length == 0) 281 | { 282 | NSBeep(); 283 | return; 284 | } 285 | 286 | [self uploadStarted]; 287 | 288 | [(ESSYouTube *)self.delegate _uploadVideoAtURL:self.videoURL 289 | withTitle:self.titleField.stringValue 290 | description:self.descriptionField.stringValue 291 | makePrivate:(self.makePrivateButton.state == NSOnState) 292 | keywords:self.tagsTokenField.stringValue 293 | category:self.categoryPopUpButton.selectedItem.representedObject]; 294 | } 295 | 296 | - (IBAction)viewOnYouTube:(id)sender 297 | { 298 | [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:((NSButton *)sender).alternateTitle]]; 299 | } 300 | 301 | - (void)dealloc 302 | { 303 | self.delegate = nil; 304 | self.videoURL = nil; 305 | self.loginView = nil; 306 | self.uploadView = nil; 307 | self.licenseView = nil; 308 | self.uploadProgressView = nil; 309 | self.doneView = nil; 310 | 311 | [super dealloc]; 312 | } 313 | @end 314 | -------------------------------------------------------------------------------- /ESSVideoShare/ESSYouTubeiOSViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ESSYouTubeiOSViewController.h 3 | // essvideoshareiostest 4 | // 5 | // Created by Matthias Gansrigler on 27.03.12. 6 | // Copyright (c) 2012 Eternal Storms Software. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class ESSYouTubeiOSViewController; 12 | 13 | @protocol ESSYouTubeiOSViewControllerDelegate 14 | 15 | @required 16 | - (void)youtubeiOSViewControllerDidDismiss:(ESSYouTubeiOSViewController *)ytVCtr; 17 | 18 | @end 19 | 20 | @interface ESSYouTubeiOSViewController : UIViewController 21 | 22 | @property (assign) id delegate; 23 | @property (retain) NSURL *videoURL; 24 | @property (retain) NSString *username; 25 | @property (retain) NSDictionary *categoriesDict; 26 | 27 | @property (retain) UITableViewCell *titleTVCell; 28 | @property (retain) UITableViewCell *categoryTVCell; 29 | @property (retain) UITableViewCell *descriptionTVCell; 30 | @property (retain) UITableViewCell *tagsTVCell; 31 | @property (retain) UITableViewCell *privacyTVCell; 32 | 33 | @property (retain) UIPickerView *picker; 34 | 35 | @property (retain) UINavigationController *navContr; 36 | 37 | @property (retain) IBOutlet UITableViewController *videoInfoViewController; 38 | 39 | @property (retain) IBOutlet UIViewController *termsViewController; 40 | 41 | @property (retain) IBOutlet UIViewController *uploadingViewController; 42 | @property (assign) IBOutlet UIProgressView *uploadProgressView; 43 | @property (assign) IBOutlet UILabel *uploadLabel; 44 | 45 | @property (retain) IBOutlet UIViewController *doneViewController; 46 | @property (assign) IBOutlet UIImageView *doneImageView; 47 | @property (assign) IBOutlet UILabel *doneLabel; 48 | @property (assign) IBOutlet UIButton *viewButton; 49 | 50 | - (id)initWithDelegate:(id)del videoURL:(NSURL *)url; 51 | 52 | - (void)cancel; 53 | - (void)login:(id)sender; 54 | - (void)beginUploadProcess; 55 | - (void)startUpload; 56 | - (void)uploadStarted; 57 | 58 | - (void)updateUsername:(NSString *)name; 59 | - (void)updateCategories:(NSDictionary *)dict; 60 | 61 | - (void)resetLoginInfo; //used when login fails, enable login button 62 | 63 | - (IBAction)showOnYouTube:(id)sender; 64 | 65 | - (void)switchToLoginViewWithAnimation:(BOOL)animate; 66 | - (void)switchToInfoViewWithAnimation:(BOOL)animate; 67 | 68 | - (UITableViewCell *)customTVCellForIndexPath:(NSIndexPath *)indexPath; 69 | 70 | - (void)uploadUpdatedWithUploadedBytes:(NSInteger)uploadedBytes ofTotalBytes:(NSInteger)totalBytes; 71 | - (void)uploadFinishedWithYouTubeVideoURL:(NSURL *)url; 72 | 73 | @end 74 | -------------------------------------------------------------------------------- /ESSVideoShare/Flickr_Progress.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternalstorms/ESSVideoShare-for-OS-X-Lion/6f3adb2d32d837ca8e612b93db012a91bd3658c5/ESSVideoShare/Flickr_Progress.tiff -------------------------------------------------------------------------------- /ESSVideoShare/Localizable.strings: -------------------------------------------------------------------------------- 1 | /* 2 | Localizable.strings 3 | Zlidez 4 | 5 | Created by Matthias Gansrigler on 13.10.11. 6 | Copyright (c) 2011 Eternal Storms Software. All rights reserved. 7 | */ 8 | 9 | /* 10 | FACEBOOK 11 | */ 12 | 13 | "ESSFacebookUploadPercentageDone" = "%ld%% uploaded"; 14 | "ESSFacebookDefaultTitle" = "Movie"; 15 | "ESSFacebookUnknownUsername" = "Unknown Username"; 16 | "ESSFacebookButtonDone" = "Done"; 17 | "ESSFacebookUploadSucceeded" = "Publishing to Facebook was successful."; 18 | "ESSFacebookUploadFailed" = "Publishing to Facebook has failed."; 19 | 20 | "ESSFacebookNoInternetConnection" = "Can't connect to Facebook"; 21 | "ESSFacebookNoInternetConnectionMsg" = "There was an error connecting to Facebook.\nPlease check your internet connection and try again."; 22 | 23 | //iOS 24 | "Cancel" = "Cancel"; 25 | "Login to Facebook" = "Facebook"; 26 | "Upload" = "Upload"; 27 | "Video Info" = "Facebook"; 28 | "Press to log in to a different Facebook account" = "Tap to log in to a different Facebook account"; 29 | "Private videos can only be viewed from your account" = "Private videos can only be viewed from your account"; 30 | "Title" = "Title"; 31 | "required" = "required"; 32 | "Description" = "Description"; 33 | "Private Video" = "Private Video"; 34 | "Facebook User Info" = "Account Info"; 35 | "VideoInfo" = "Video Info"; 36 | "Privacy" = "Privacy"; 37 | "Facebook Username" = "Username"; 38 | "PublishingToFacebook" = "Facebook"; 39 | "FacebookErrorUpload" = "The video could not be published to Facebook."; 40 | "FacebookSuccessfulUpload" = "The video was successfully published to Facebook."; 41 | "UploadDone" = "Facebook"; 42 | "Done" = "Done"; 43 | 44 | /* 45 | YOUTUBE 46 | */ 47 | "ESSYouTubeCategoryURLString" = "http://gdata.youtube.com/schemas/2007/categories.cat?hl=en-US"; //http://code.google.com/apis/youtube/2.0/reference.html#YouTube_Category_List 48 | "ESSYouTubeUploadPercentageDone" = "%ld%% uploaded"; 49 | "ESSYouTubeWaitingForYouTubeToProcessVideo" = "Waiting for YouTube to process the upload..."; 50 | "ESSYouTubeUploadFailed" = "Publishing to YouTube has failed. The file probably couldn't be converted."; 51 | "ESSYouTubeUploadSucceeded" = "Publishing to YouTube was successful."; 52 | "ESSYouTubeDefaultTitle" = "Movie"; 53 | "ESSYouTubeInitializingUpload" = "Initializing Upload..."; 54 | 55 | "ESSYouTubeNoInternetConnection" = "Can't connect to YouTube"; 56 | "ESSYouTubeNoInternetConnectionMsg" = "There was an error connecting to YouTube.\nPlease check your internet connection and try again."; 57 | 58 | "ESSYouTubeiOSLoginTableViewFooter" = ""; 59 | "ESSYouTubeiOSAccountInfoTableViewFooter" = "Tap to log in to a different YouTube account"; 60 | "ESSYouTubeiOSVideoInfoTableViewFooter" = "Separate multiple tags with commas. Each tag must contain at least two characters"; 61 | "ESSYouTubeiOSPrivacyTableViewFooter" = "Private movies can only be viewed from your account and other YouTube accounts that you authorize"; 62 | "ESSYouTubeiOSLoginTableViewHeader" = "Login to your YouTube account"; 63 | "ESSYouTubeiOSAccountInfoTableViewHeader" = "Account Info"; 64 | "ESSYouTubeiOSVideoInfoTableViewHeader" = "Video Info"; 65 | "ESSYouTubeiOSPrivacyTableViewHeader" = "Privacy"; 66 | "ESSYouTubeiOSUsernameCellTitle" = "Username"; 67 | "ESSYouTubeiOSPasswordCellTitle" = "Password"; 68 | "ESSYouTubeiOSLoginButtonTitle" = "Login"; 69 | "ESSYouTubeiOSCancelButtonTitle" = "Cancel"; 70 | "ESSYouTubeiOSUploadButtonTitle" = "Upload"; 71 | "ESSYouTubeiOSDoneButtonTitle" = "Done"; 72 | "ESSYouTubeiOSTitleCellTitle" = "Title"; 73 | "ESSYouTubeiOSDescriptionCellTitle" = "Description"; 74 | "ESSYouTubeiOSTagsCellTitle" = "Tags"; 75 | "ESSYouTubeiOSCategoryCellTitle" = "Category"; 76 | "ESSYouTubeiOSPrivateCellTitle" = "Private Video"; 77 | "ESSYouTubeiOSSelectCategoryButton" = "Select Category"; 78 | "optional" = "optional"; 79 | "required" = "required"; 80 | 81 | /* 82 | FLICKR 83 | */ 84 | 85 | "ESSFlickrMovieTooLongTitle" = "Your movie couldn't be published to Flickr because it is longer than 90 seconds."; 86 | "ESSFlickrOKButton" = "OK"; 87 | "ESSFlickrMovieTooLongMessage" = "You can save the movie to your hard disk, open it with QuickTime Player X, trim it there and then try uploading it again."; 88 | "ESSFlickrInitializingUpload" = "Initializing Upload..."; 89 | "ESSFlickrUploadPercentageDone" = "%ld%% uploaded"; 90 | "ESSFlickrWaitingForFlickrToProcessVideo" = "Waiting for Flickr to process the upload..."; 91 | "ESSFlickrUploadFailed" = "Publishing to Flickr has failed. The file probably couldn't be converted."; 92 | "ESSFlickrUploadSucceeded" = "Publishing to Flickr was successful."; 93 | "ESSFlickrDefaultTitle" = "Movie"; 94 | "ESSFlickrUnknownUsername" = "Unknown Username"; 95 | 96 | "ESSFlickrNoInternetConnection" = "Can't connect to flickr"; 97 | "ESSFlickrNoInternetConnectionMsg" = "There was an error connecting to flickr.\nPlease check your internet connection and try again."; 98 | 99 | "ESSFlickriOSAccountInfoFooter" = "Tap to log in to a different flickr account"; 100 | "ESSFlickriOSVideoInfoTagFooter" = "Multiple tags can be separated with commas"; 101 | "ESSFlickriOSPrivacyInfoFooter" = "Private movies can only be viewed from your account and other Flickr accounts that you authorize"; 102 | "ESSFlickriOSAccountInfoHeader" = "Account Info"; 103 | "ESSFlickriOSVideoInfoHeader" = "Video Info"; 104 | "ESSFlickriOSPrivacyHeader" = "Privacy"; 105 | "ESSFlickriOSUsernameTVCellTitle" = "Username"; 106 | "ESSFlickriOSPrivateVideoTVCellTitle" = "Private"; 107 | "ESSFlickriOSTitleTVCellTitle" = "Title"; 108 | "ESSFlickriOSRequiredCellTitle" = "required"; 109 | "ESSFlickriOSDescriptionTVCellTitle" = "Description"; 110 | "ESSFlickriOSOptionalCellTitle" = "optional"; 111 | "ESSFlickriOSTagsTVCellTitle" = "Tags"; 112 | "ESSFlickriOSCancel" = "Cancel"; 113 | "ESSFlickriOSLogin" = "Authorize"; 114 | "ESSFlickriOSUpload" = "Upload"; 115 | "ESSFlickrWaitingForFlickrToVerifyVideo" = "Verifying Upload..."; 116 | "ESSFlickriOSDone" = "Done"; 117 | 118 | /* 119 | VIMEO 120 | */ 121 | 122 | "ESSVimeoInitializingUpload" = "Initializing Upload..."; 123 | "ESSVimeoNoSpaceLeft" = "There is no space left in the account you have logged in to for the movie to be uploaded."; 124 | "ESSVimeoNoPlusAccount" = "This application can only upload to Vimeo PLUS accounts."; 125 | "ESSVimeoUploadPercentageDone" = "%ld%% uploaded"; 126 | "ESSVimeoWaitingForVimeoToVerifyVideo" = "Verifying Upload..."; 127 | "ESSVimeoUploadFailed" = "Your movie could not be published to Vimeo."; 128 | "ESSVimeoUploadSucceeded" = "Your movie was successfully published to Vimeo."; 129 | "ESSVimeoUnknownUsername" = "Unknown Username"; 130 | "ESSVimeoDefaultTitle" = "Movie"; 131 | 132 | "ESSVimeoNoInternetConnection" = "Can't connect to Vimeo"; 133 | "ESSVimeoNoInternetConnectionMsg" = "There was an error connecting to Vimeo.\nPlease check your internet connection and try again."; 134 | 135 | "ESSVimeoUploadPercentageDone" = "%ld%% uploaded"; 136 | "ESSVimeoWaitingForVimeoToVerifyVideo" = "Verifying Upload..."; 137 | "ESSVimeoiOSCancel" = "Cancel"; 138 | "ESSVimeoiOSLogin" = "Authorize"; 139 | "ESSVimeoiOSUpload" = "Upload"; 140 | "ESSVimeoiOSDone" = "Done"; 141 | "ESSVimeoiOSNoSpaceWarning" = "There is no space left for this video in your Vimeo account."; 142 | "ESSVimeoiOSNoPlusAccountWarning" = "This app can only upload to Vimeo PLUS accounts."; 143 | "ESSVimeoiOSTitleTVCellTitle" = "Title"; 144 | "ESSVimeoiOSDescriptionTVCellTitle" = "Description"; 145 | "ESSVimeoiOSTagsTVCellTitle" = "Tags"; 146 | "ESSVimeoiOSRequiredCellTitle" = "required"; 147 | "ESSVimeoiOSOptionalCellTitle" = "optional"; 148 | "ESSVimeoiOSAccountInfoFooter" = "Tap to log in to a different Vimeo account"; 149 | "ESSVimeoiOSVideoInfoTagFooter" = "Multiple tags can be separated with commas"; 150 | "ESSVimeoiOSAccountVideoInfoTagFooter" = "Multiple tags can be separated with commas"; 151 | "ESSVimeoiOSPrivacyInfoFooter" = "Private movies can only be viewed from your account and other Vimeo accounts that you authorize"; 152 | "ESSVimeoiOSAccountInfoHeader" = "Account Info"; 153 | "ESSVimeoiOSVideoInfoHeader" = "Video Info"; 154 | "ESSVimeoiOSPrivacyHeader" = "Privacy"; 155 | "ESSVimeoiOSUsernameTVCellTitle" = "Username"; 156 | "ESSVimeoiOSPrivateVideoTVCellTitle" = "Private"; -------------------------------------------------------------------------------- /ESSVideoShare/NSMutableURLRequest+Parameters.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSMutableURLRequest+Parameters.h 3 | // 4 | // Created by Jon Crosby on 10/19/07. 5 | // Copyright 2007 Kaboomerang LLC. All rights reserved. 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | #import 26 | #import "OARequestParameter.h" 27 | #import "NSURL+Base.h" 28 | 29 | 30 | @interface NSMutableURLRequest (OAParameterAdditions) 31 | 32 | - (NSArray *)parameters; 33 | - (void)setParameters:(NSArray *)parameters; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /ESSVideoShare/NSMutableURLRequest+Parameters.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSMutableURLRequest+Parameters.m 3 | // 4 | // Created by Jon Crosby on 10/19/07. 5 | // Copyright 2007 Kaboomerang LLC. All rights reserved. 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | 26 | #import "NSMutableURLRequest+Parameters.h" 27 | 28 | 29 | @implementation NSMutableURLRequest (OAParameterAdditions) 30 | 31 | - (NSArray *)parameters 32 | { 33 | NSString *encodedParameters; 34 | BOOL shouldfree = NO; 35 | 36 | if ([[self HTTPMethod] isEqualToString:@"GET"] || [[self HTTPMethod] isEqualToString:@"DELETE"]) 37 | encodedParameters = [[[self URL] query] retain]; 38 | else 39 | { 40 | // POST, PUT 41 | shouldfree = YES; 42 | encodedParameters = [[NSString alloc] initWithData:[self HTTPBody] encoding:NSASCIIStringEncoding]; 43 | } 44 | 45 | if ((encodedParameters == nil) || ([encodedParameters isEqualToString:@""])) 46 | { 47 | [encodedParameters release]; 48 | return nil; 49 | } 50 | 51 | NSArray *encodedParameterPairs = [encodedParameters componentsSeparatedByString:@"&"]; 52 | NSMutableArray *requestParameters = [[NSMutableArray alloc] initWithCapacity:16]; 53 | 54 | for (NSString *encodedPair in encodedParameterPairs) 55 | { 56 | NSArray *encodedPairElements = [encodedPair componentsSeparatedByString:@"="]; 57 | OARequestParameter *parameter = [OARequestParameter requestParameterWithName:[[encodedPairElements objectAtIndex:0] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] 58 | value:[[encodedPairElements objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; 59 | [requestParameters addObject:parameter]; 60 | } 61 | 62 | // Cleanup 63 | if (shouldfree) 64 | [encodedParameters release]; 65 | 66 | return [requestParameters autorelease]; 67 | } 68 | 69 | - (void)setParameters:(NSArray *)parameters 70 | { 71 | NSMutableString *encodedParameterPairs = [NSMutableString stringWithCapacity:256]; 72 | 73 | int position = 1; 74 | for (OARequestParameter *requestParameter in parameters) 75 | { 76 | [encodedParameterPairs appendString:[requestParameter URLEncodedNameValuePair]]; 77 | if (position < [parameters count]) 78 | [encodedParameterPairs appendString:@"&"]; 79 | 80 | position++; 81 | } 82 | 83 | if ([[self HTTPMethod] isEqualToString:@"GET"] || [[self HTTPMethod] isEqualToString:@"DELETE"]) 84 | [self setURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?%@", [[self URL] URLStringWithoutQuery], encodedParameterPairs]]]; 85 | else 86 | { 87 | // POST, PUT 88 | NSData *postData = [encodedParameterPairs dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; 89 | [self setHTTPBody:postData]; 90 | [self setValue:[NSString stringWithFormat:@"%ld", [postData length]] forHTTPHeaderField:@"Content-Length"]; 91 | [self setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; 92 | } 93 | } 94 | 95 | @end 96 | -------------------------------------------------------------------------------- /ESSVideoShare/NSString+URLEncoding.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+URLEncoding.h 3 | // 4 | // Created by Jon Crosby on 10/19/07. 5 | // Copyright 2007 Kaboomerang LLC. All rights reserved. 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | 26 | #import 27 | 28 | 29 | @interface NSString (OAURLEncodingAdditions) 30 | 31 | - (NSString *)URLEncodedString; 32 | - (NSString *)URLDecodedString; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /ESSVideoShare/NSString+URLEncoding.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+URLEncoding.m 3 | // 4 | // Created by Jon Crosby on 10/19/07. 5 | // Copyright 2007 Kaboomerang LLC. All rights reserved. 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | 26 | #import "NSString+URLEncoding.h" 27 | 28 | 29 | @implementation NSString (OAURLEncodingAdditions) 30 | 31 | - (NSString *)URLEncodedString 32 | { 33 | NSString *result = (NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, 34 | (CFStringRef)self, 35 | NULL, 36 | CFSTR("!*'();:@&=+$,/?%#[]"), 37 | kCFStringEncodingUTF8); 38 | [result autorelease]; 39 | return result; 40 | } 41 | 42 | - (NSString*)URLDecodedString 43 | { 44 | NSString *result = (NSString *)CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault, 45 | (CFStringRef)self, 46 | CFSTR(""), 47 | kCFStringEncodingUTF8); 48 | [result autorelease]; 49 | return result; 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /ESSVideoShare/NSURL+Base.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSURL+Base.h 3 | // OAuthConsumer 4 | // 5 | // Created by Jon Crosby on 10/19/07. 6 | // Copyright 2007 Kaboomerang LLC. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | 27 | #import 28 | 29 | 30 | @interface NSURL (OABaseAdditions) 31 | 32 | - (NSString *)URLStringWithoutQuery; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /ESSVideoShare/NSURL+Base.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSURL+Base.m 3 | // OAuthConsumer 4 | // 5 | // Created by Jon Crosby on 10/19/07. 6 | // Copyright 2007 Kaboomerang LLC. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | 27 | #import "NSURL+Base.h" 28 | 29 | 30 | @implementation NSURL (OABaseAdditions) 31 | 32 | - (NSString *)URLStringWithoutQuery 33 | { 34 | NSArray *parts = [[self absoluteString] componentsSeparatedByString:@"?"]; 35 | return [parts objectAtIndex:0]; 36 | } 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /ESSVideoShare/OAAsynchronousDataFetcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // OAAsynchronousDataFetcher.h 3 | // OAuthConsumer 4 | // 5 | // Created by Zsombor Szabó on 12/3/08. 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | #import 26 | 27 | #import "OAMutableURLRequest.h" 28 | 29 | @interface OAAsynchronousDataFetcher : NSObject { 30 | OAMutableURLRequest *request; 31 | NSURLResponse *response; 32 | NSURLConnection *connection; 33 | NSMutableData *responseData; 34 | id delegate; 35 | SEL didFinishSelector; 36 | SEL didFailSelector; 37 | } 38 | 39 | + (id)asynchronousFetcherWithRequest:(OAMutableURLRequest *)aRequest delegate:(id)aDelegate didFinishSelector:(SEL)finishSelector didFailSelector:(SEL)failSelector; 40 | - (id)initWithRequest:(OAMutableURLRequest *)aRequest delegate:(id)aDelegate didFinishSelector:(SEL)finishSelector didFailSelector:(SEL)failSelector; 41 | 42 | - (void)start; 43 | - (void)cancel; 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /ESSVideoShare/OAAsynchronousDataFetcher.m: -------------------------------------------------------------------------------- 1 | // 2 | // OAAsynchronousDataFetcher.m 3 | // OAuthConsumer 4 | // 5 | // Created by Zsombor Szabó on 12/3/08. 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | #import "OAAsynchronousDataFetcher.h" 26 | 27 | #import "OAServiceTicket.h" 28 | 29 | @implementation OAAsynchronousDataFetcher 30 | 31 | + (id)asynchronousFetcherWithRequest:(OAMutableURLRequest *)aRequest delegate:(id)aDelegate didFinishSelector:(SEL)finishSelector didFailSelector:(SEL)failSelector 32 | { 33 | return [[[OAAsynchronousDataFetcher alloc] initWithRequest:aRequest delegate:aDelegate didFinishSelector:finishSelector didFailSelector:failSelector] autorelease]; 34 | } 35 | 36 | - (id)initWithRequest:(OAMutableURLRequest *)aRequest delegate:(id)aDelegate didFinishSelector:(SEL)finishSelector didFailSelector:(SEL)failSelector 37 | { 38 | if (self = [super init]) 39 | { 40 | request = [aRequest retain]; 41 | delegate = aDelegate; 42 | didFinishSelector = finishSelector; 43 | didFailSelector = failSelector; 44 | } 45 | return self; 46 | } 47 | 48 | - (void)start 49 | { 50 | [request prepare]; 51 | 52 | if (connection) 53 | [connection release]; 54 | 55 | connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; 56 | 57 | if (connection) 58 | { 59 | if (responseData) 60 | [responseData release]; 61 | responseData = [[NSMutableData data] retain]; 62 | } 63 | else 64 | { 65 | OAServiceTicket *ticket= [[OAServiceTicket alloc] initWithRequest:request 66 | response:nil 67 | didSucceed:NO]; 68 | [delegate performSelector:didFailSelector 69 | withObject:ticket 70 | withObject:nil]; 71 | [ticket release]; 72 | } 73 | } 74 | 75 | - (void)cancel 76 | { 77 | if (connection) 78 | { 79 | [connection cancel]; 80 | [connection release]; 81 | connection = nil; 82 | } 83 | } 84 | 85 | - (void)dealloc 86 | { 87 | if (request) [request release]; 88 | if (connection) [connection release]; 89 | if (response) [response release]; 90 | if (responseData) [responseData release]; 91 | [super dealloc]; 92 | } 93 | 94 | #pragma mark - 95 | #pragma mark NSURLConnection methods 96 | 97 | - (void)connection:(NSURLConnection *)aConnection didReceiveResponse:(NSURLResponse *)aResponse 98 | { 99 | if (response) 100 | [response release]; 101 | response = [aResponse retain]; 102 | [responseData setLength:0]; 103 | } 104 | 105 | - (void)connection:(NSURLConnection *)aConnection didReceiveData:(NSData *)data 106 | { 107 | [responseData appendData:data]; 108 | } 109 | 110 | - (void)connection:(NSURLConnection *)aConnection didFailWithError:(NSError *)error 111 | { 112 | OAServiceTicket *ticket= [[OAServiceTicket alloc] initWithRequest:request 113 | response:response 114 | didSucceed:NO]; 115 | [delegate performSelector:didFailSelector 116 | withObject:ticket 117 | withObject:error]; 118 | 119 | [ticket release]; 120 | } 121 | 122 | - (void)connectionDidFinishLoading:(NSURLConnection *)aConnection 123 | { 124 | OAServiceTicket *ticket = [[OAServiceTicket alloc] initWithRequest:request 125 | response:response 126 | didSucceed:[(NSHTTPURLResponse *)response statusCode] < 400]; 127 | [delegate performSelector:didFinishSelector 128 | withObject:ticket 129 | withObject:responseData]; 130 | 131 | [ticket release]; 132 | } 133 | 134 | @end 135 | -------------------------------------------------------------------------------- /ESSVideoShare/OAConsumer.h: -------------------------------------------------------------------------------- 1 | // 2 | // OAConsumer.h 3 | // OAuthConsumer 4 | // 5 | // Created by Jon Crosby on 10/19/07. 6 | // Copyright 2007 Kaboomerang LLC. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | 27 | #import 28 | 29 | 30 | @interface OAConsumer : NSObject { 31 | @protected 32 | NSString *key; 33 | NSString *secret; 34 | } 35 | @property(retain) NSString *key; 36 | @property(retain) NSString *secret; 37 | 38 | - (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /ESSVideoShare/OAConsumer.m: -------------------------------------------------------------------------------- 1 | // 2 | // OAConsumer.m 3 | // OAuthConsumer 4 | // 5 | // Created by Jon Crosby on 10/19/07. 6 | // Copyright 2007 Kaboomerang LLC. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | #import "OAConsumer.h" 27 | 28 | 29 | @implementation OAConsumer 30 | @synthesize key, secret; 31 | 32 | #pragma mark init 33 | 34 | - (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret 35 | { 36 | if (self = [super init]) 37 | { 38 | self.key = aKey; 39 | self.secret = aSecret; 40 | } 41 | return self; 42 | } 43 | 44 | - (void)dealloc 45 | { 46 | [key release]; 47 | [secret release]; 48 | [super dealloc]; 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /ESSVideoShare/OADataFetcher.h: -------------------------------------------------------------------------------- 1 | // 2 | // OADataFetcher.h 3 | // OAuthConsumer 4 | // 5 | // Created by Jon Crosby on 11/5/07. 6 | // Copyright 2007 Kaboomerang LLC. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | #import 27 | #import "OAMutableURLRequest.h" 28 | #import "OAServiceTicket.h" 29 | 30 | 31 | @interface OADataFetcher : NSObject { 32 | @private 33 | OAMutableURLRequest *request; 34 | NSURLResponse *response; 35 | NSURLConnection *connection; 36 | NSError *error; 37 | NSData *responseData; 38 | id delegate; 39 | SEL didFinishSelector; 40 | SEL didFailSelector; 41 | } 42 | 43 | - (void)fetchDataWithRequest:(OAMutableURLRequest *)aRequest delegate:(id)aDelegate didFinishSelector:(SEL)finishSelector didFailSelector:(SEL)failSelector; 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /ESSVideoShare/OADataFetcher.m: -------------------------------------------------------------------------------- 1 | // 2 | // OADataFetcher.m 3 | // OAuthConsumer 4 | // 5 | // Created by Jon Crosby on 11/5/07. 6 | // Copyright 2007 Kaboomerang LLC. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | 27 | #import "OADataFetcher.h" 28 | 29 | 30 | @implementation OADataFetcher 31 | 32 | - (void)fetchDataWithRequest:(OAMutableURLRequest *)aRequest 33 | delegate:(id)aDelegate 34 | didFinishSelector:(SEL)finishSelector 35 | didFailSelector:(SEL)failSelector 36 | { 37 | request = aRequest; 38 | delegate = aDelegate; 39 | didFinishSelector = finishSelector; 40 | didFailSelector = failSelector; 41 | 42 | [request prepare]; 43 | 44 | responseData = [NSURLConnection sendSynchronousRequest:request 45 | returningResponse:&response 46 | error:&error]; 47 | 48 | if (response == nil || responseData == nil || error != nil) { 49 | OAServiceTicket *ticket= [[OAServiceTicket alloc] initWithRequest:request 50 | response:response 51 | didSucceed:NO]; 52 | [delegate performSelector:didFailSelector 53 | withObject:[ticket autorelease] 54 | withObject:error]; 55 | } else { 56 | OAServiceTicket *ticket = [[OAServiceTicket alloc] initWithRequest:request 57 | response:response 58 | didSucceed:[(NSHTTPURLResponse *)response statusCode] < 400]; 59 | [delegate performSelector:didFinishSelector 60 | withObject:[ticket autorelease] 61 | withObject:responseData]; 62 | } 63 | } 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /ESSVideoShare/OAHMAC_SHA1SignatureProvider.h: -------------------------------------------------------------------------------- 1 | // 2 | // OAHMAC_SHA1SignatureProvider.h 3 | // OAuthConsumer 4 | // 5 | // Created by Jon Crosby on 10/19/07. 6 | // Copyright 2007 Kaboomerang LLC. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | 27 | #import 28 | #import "OASignatureProviding.h" 29 | 30 | 31 | @interface OAHMAC_SHA1SignatureProvider : NSObject 32 | @end 33 | -------------------------------------------------------------------------------- /ESSVideoShare/OAHMAC_SHA1SignatureProvider.m: -------------------------------------------------------------------------------- 1 | // 2 | // OAHMAC_SHA1SignatureProvider.m 3 | // OAuthConsumer 4 | // 5 | // Created by Jon Crosby on 10/19/07. 6 | // Copyright 2007 Kaboomerang LLC. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | 27 | #import "OAHMAC_SHA1SignatureProvider.h" 28 | #import 29 | 30 | #include "Base64Transcoder.h" 31 | 32 | @implementation OAHMAC_SHA1SignatureProvider 33 | 34 | - (NSString *)name 35 | { 36 | return @"HMAC-SHA1"; 37 | } 38 | 39 | - (NSString *)signClearText:(NSString *)text withSecret:(NSString *)secret 40 | { 41 | NSData *secretData = [secret dataUsingEncoding:NSUTF8StringEncoding]; 42 | NSData *clearTextData = [text dataUsingEncoding:NSUTF8StringEncoding]; 43 | unsigned char result[20]; 44 | CCHmac(kCCHmacAlgSHA1, [secretData bytes], [secretData length], [clearTextData bytes], [clearTextData length], result); 45 | 46 | //Base64 Encoding 47 | 48 | char base64Result[32]; 49 | size_t theResultLength = 32; 50 | Base64EncodeData(result, 20, base64Result, &theResultLength); 51 | NSData *theData = [NSData dataWithBytes:base64Result length:theResultLength]; 52 | 53 | NSString *base64EncodedResult = [[NSString alloc] initWithData:theData encoding:NSUTF8StringEncoding]; 54 | 55 | return [base64EncodedResult autorelease]; 56 | } 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /ESSVideoShare/OAMutableURLRequest.h: -------------------------------------------------------------------------------- 1 | // 2 | // OAMutableURLRequest.h 3 | // OAuthConsumer 4 | // 5 | // Created by Jon Crosby on 10/19/07. 6 | // Copyright 2007 Kaboomerang LLC. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | 27 | #import 28 | #import "OAConsumer.h" 29 | #import "OAToken.h" 30 | #import "OAHMAC_SHA1SignatureProvider.h" 31 | #import "OASignatureProviding.h" 32 | #import "NSMutableURLRequest+Parameters.h" 33 | #import "NSURL+Base.h" 34 | 35 | 36 | @interface OAMutableURLRequest : NSMutableURLRequest { 37 | @protected 38 | OAConsumer *consumer; 39 | OAToken *token; 40 | NSString *realm; 41 | NSString *signature; 42 | id signatureProvider; 43 | NSString *nonce; 44 | NSString *timestamp; 45 | NSMutableDictionary *extraOAuthParameters; 46 | } 47 | @property(readonly) NSString *signature; 48 | @property(readonly) NSString *nonce; 49 | 50 | - (id)initWithURL:(NSURL *)aUrl 51 | consumer:(OAConsumer *)aConsumer 52 | token:(OAToken *)aToken 53 | realm:(NSString *)aRealm 54 | signatureProvider:(id)aProvider; 55 | 56 | - (id)initWithURL:(NSURL *)aUrl 57 | consumer:(OAConsumer *)aConsumer 58 | token:(OAToken *)aToken 59 | realm:(NSString *)aRealm 60 | signatureProvider:(id)aProvider 61 | nonce:(NSString *)aNonce 62 | timestamp:(NSString *)aTimestamp; 63 | 64 | - (void)prepare; 65 | 66 | - (void)setOAuthParameterName:(NSString*)parameterName withValue:(NSString*)parameterValue; 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /ESSVideoShare/OAMutableURLRequest.m: -------------------------------------------------------------------------------- 1 | // 2 | // OAMutableURLRequest.m 3 | // OAuthConsumer 4 | // 5 | // Created by Jon Crosby on 10/19/07. 6 | // Copyright 2007 Kaboomerang LLC. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | 27 | #import "OAMutableURLRequest.h" 28 | 29 | 30 | @interface OAMutableURLRequest (Private) 31 | - (void)_generateTimestamp; 32 | - (void)_generateNonce; 33 | - (NSString *)_signatureBaseString; 34 | @end 35 | 36 | @implementation OAMutableURLRequest 37 | @synthesize signature, nonce; 38 | 39 | #pragma mark init 40 | 41 | - (id)initWithURL:(NSURL *)aUrl 42 | consumer:(OAConsumer *)aConsumer 43 | token:(OAToken *)aToken 44 | realm:(NSString *)aRealm 45 | signatureProvider:(id)aProvider 46 | { 47 | if (self = [super initWithURL:aUrl 48 | cachePolicy:NSURLRequestReloadIgnoringCacheData 49 | timeoutInterval:10.0]) 50 | { 51 | consumer = [aConsumer retain]; 52 | 53 | // empty token for Unauthorized Request Token transaction 54 | if (aToken == nil) 55 | token = [[OAToken alloc] init]; 56 | else 57 | token = [aToken retain]; 58 | 59 | if (aRealm == nil) 60 | realm = [[NSString alloc] initWithString:@""]; 61 | else 62 | realm = [aRealm retain]; 63 | 64 | // default to HMAC-SHA1 65 | if (aProvider == nil) 66 | signatureProvider = [[OAHMAC_SHA1SignatureProvider alloc] init]; 67 | else 68 | signatureProvider = [aProvider retain]; 69 | 70 | [self _generateTimestamp]; 71 | [self _generateNonce]; 72 | } 73 | return self; 74 | } 75 | 76 | // Setting a timestamp and nonce to known 77 | // values can be helpful for testing 78 | - (id)initWithURL:(NSURL *)aUrl 79 | consumer:(OAConsumer *)aConsumer 80 | token:(OAToken *)aToken 81 | realm:(NSString *)aRealm 82 | signatureProvider:(id)aProvider 83 | nonce:(NSString *)aNonce 84 | timestamp:(NSString *)aTimestamp 85 | { 86 | if (self = [super initWithURL:aUrl 87 | cachePolicy:NSURLRequestReloadIgnoringCacheData 88 | timeoutInterval:10.0]) 89 | { 90 | consumer = [aConsumer retain]; 91 | 92 | // empty token for Unauthorized Request Token transaction 93 | if (aToken == nil) 94 | token = [[OAToken alloc] init]; 95 | else 96 | token = [aToken retain]; 97 | 98 | if (aRealm == nil) 99 | realm = [[NSString alloc] initWithString:@""]; 100 | else 101 | realm = [aRealm retain]; 102 | 103 | // default to HMAC-SHA1 104 | if (aProvider == nil) 105 | signatureProvider = [[OAHMAC_SHA1SignatureProvider alloc] init]; 106 | else 107 | signatureProvider = [aProvider retain]; 108 | 109 | timestamp = [aTimestamp retain]; 110 | nonce = [aNonce retain]; 111 | } 112 | return self; 113 | } 114 | 115 | - (void)dealloc 116 | { 117 | [consumer release]; 118 | [token release]; 119 | [realm release]; 120 | [signatureProvider release]; 121 | [timestamp release]; 122 | [nonce release]; 123 | [extraOAuthParameters release]; 124 | [super dealloc]; 125 | } 126 | 127 | #pragma mark - 128 | #pragma mark Public 129 | 130 | - (void)setOAuthParameterName:(NSString*)parameterName withValue:(NSString*)parameterValue 131 | { 132 | assert(parameterName && parameterValue); 133 | 134 | if (extraOAuthParameters == nil) { 135 | extraOAuthParameters = [NSMutableDictionary new]; 136 | } 137 | 138 | [extraOAuthParameters setObject:parameterValue forKey:parameterName]; 139 | } 140 | 141 | - (void)prepare 142 | { 143 | // sign 144 | // Secrets must be urlencoded before concatenated with '&' 145 | // TODO: if later RSA-SHA1 support is added then a little code redesign is needed 146 | signature = [signatureProvider signClearText:[self _signatureBaseString] 147 | withSecret:[NSString stringWithFormat:@"%@&%@", 148 | [consumer.secret URLEncodedString], 149 | [token.secret URLEncodedString]]]; 150 | 151 | // set OAuth headers 152 | NSString *oauthToken; 153 | if ([token.key isEqualToString:@""]) 154 | oauthToken = @""; // not used on Request Token transactions 155 | else 156 | oauthToken = [NSString stringWithFormat:@"oauth_token=\"%@\", ", [token.key URLEncodedString]]; 157 | 158 | NSMutableString *extraParameters = [NSMutableString string]; 159 | 160 | // Adding the optional parameters in sorted order isn't required by the OAuth spec, but it makes it possible to hard-code expected values in the unit tests. 161 | for(NSString *parameterName in [[extraOAuthParameters allKeys] sortedArrayUsingSelector:@selector(compare:)]) 162 | { 163 | [extraParameters appendFormat:@", %@=\"%@\"", 164 | [parameterName URLEncodedString], 165 | [[extraOAuthParameters objectForKey:parameterName] URLEncodedString]]; 166 | } 167 | 168 | NSString *oauthHeader = [NSString stringWithFormat:@"OAuth realm=\"%@\", oauth_consumer_key=\"%@\", %@oauth_signature_method=\"%@\", oauth_signature=\"%@\", oauth_timestamp=\"%@\", oauth_nonce=\"%@\", oauth_version=\"1.0\"%@", 169 | [realm URLEncodedString], 170 | [consumer.key URLEncodedString], 171 | oauthToken, 172 | [[signatureProvider name] URLEncodedString], 173 | [signature URLEncodedString], 174 | timestamp, 175 | nonce, 176 | extraParameters]; 177 | 178 | [self setValue:oauthHeader forHTTPHeaderField:@"Authorization"]; 179 | } 180 | 181 | #pragma mark - 182 | #pragma mark Private 183 | 184 | - (void)_generateTimestamp 185 | { 186 | timestamp = [[NSString stringWithFormat:@"%ld", time(NULL)] retain]; 187 | } 188 | 189 | - (void)_generateNonce 190 | { 191 | CFUUIDRef theUUID = CFUUIDCreate(NULL); 192 | CFStringRef string = CFUUIDCreateString(NULL, theUUID); 193 | NSMakeCollectable(theUUID); 194 | nonce = (NSString *)string; 195 | } 196 | 197 | - (NSString *)_signatureBaseString 198 | { 199 | // OAuth Spec, Section 9.1.1 "Normalize Request Parameters" 200 | // build a sorted array of both request parameters and OAuth header parameters 201 | NSMutableArray *parameterPairs = [NSMutableArray arrayWithCapacity:(6 + [[self parameters] count])]; // 6 being the number of OAuth params in the Signature Base String 202 | 203 | [parameterPairs addObject:[[OARequestParameter requestParameterWithName:@"oauth_consumer_key" value:consumer.key] URLEncodedNameValuePair]]; 204 | [parameterPairs addObject:[[OARequestParameter requestParameterWithName:@"oauth_signature_method" value:[signatureProvider name]] URLEncodedNameValuePair]]; 205 | [parameterPairs addObject:[[OARequestParameter requestParameterWithName:@"oauth_timestamp" value:timestamp] URLEncodedNameValuePair]]; 206 | [parameterPairs addObject:[[OARequestParameter requestParameterWithName:@"oauth_nonce" value:nonce] URLEncodedNameValuePair]]; 207 | [parameterPairs addObject:[[OARequestParameter requestParameterWithName:@"oauth_version" value:@"1.0"] URLEncodedNameValuePair]]; 208 | 209 | if (![token.key isEqualToString:@""]) { 210 | [parameterPairs addObject:[[OARequestParameter requestParameterWithName:@"oauth_token" value:token.key] URLEncodedNameValuePair]]; 211 | } 212 | 213 | for (OARequestParameter *param in [self parameters]) { 214 | [parameterPairs addObject:[param URLEncodedNameValuePair]]; 215 | } 216 | 217 | NSArray *sortedPairs = [parameterPairs sortedArrayUsingSelector:@selector(compare:)]; 218 | NSString *normalizedRequestParameters = [sortedPairs componentsJoinedByString:@"&"]; 219 | 220 | // OAuth Spec, Section 9.1.2 "Concatenate Request Elements" 221 | NSString *ret = [NSString stringWithFormat:@"%@&%@&%@", 222 | [self HTTPMethod], 223 | [[[self URL] URLStringWithoutQuery] URLEncodedString], 224 | [normalizedRequestParameters URLEncodedString]]; 225 | 226 | return ret; 227 | } 228 | 229 | @end 230 | -------------------------------------------------------------------------------- /ESSVideoShare/OAPlaintextSignatureProvider.h: -------------------------------------------------------------------------------- 1 | // 2 | // OAPlaintextSignatureProvider.h 3 | // OAuthConsumer 4 | // 5 | // Created by Jon Crosby on 10/19/07. 6 | // Copyright 2007 Kaboomerang LLC. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | 27 | #import 28 | #import "OASignatureProviding.h" 29 | 30 | @interface OAPlaintextSignatureProvider : NSObject 31 | @end 32 | -------------------------------------------------------------------------------- /ESSVideoShare/OAPlaintextSignatureProvider.m: -------------------------------------------------------------------------------- 1 | // 2 | // OAPlaintextSignatureProvider.m 3 | // OAuthConsumer 4 | // 5 | // Created by Jon Crosby on 10/19/07. 6 | // Copyright 2007 Kaboomerang LLC. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | 27 | #import "OAPlaintextSignatureProvider.h" 28 | #import "NSString+URLEncoding.h" 29 | 30 | 31 | @implementation OAPlaintextSignatureProvider 32 | 33 | - (NSString *)name 34 | { 35 | return @"PLAINTEXT"; 36 | } 37 | 38 | - (NSString *)signClearText:(NSString *)text withSecret:(NSString *)secret 39 | { 40 | return secret; 41 | } 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /ESSVideoShare/OARequestParameter.h: -------------------------------------------------------------------------------- 1 | // 2 | // OARequestParameter.h 3 | // OAuthConsumer 4 | // 5 | // Created by Jon Crosby on 10/19/07. 6 | // Copyright 2007 Kaboomerang LLC. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | 27 | #import 28 | #import "NSString+URLEncoding.h" 29 | 30 | 31 | @interface OARequestParameter : NSObject { 32 | @protected 33 | NSString *name; 34 | NSString *value; 35 | } 36 | @property(retain) NSString *name; 37 | @property(retain) NSString *value; 38 | 39 | + (id)requestParameterWithName:(NSString *)aName value:(NSString *)aValue; 40 | - (id)initWithName:(NSString *)aName value:(NSString *)aValue; 41 | - (NSString *)URLEncodedName; 42 | - (NSString *)URLEncodedValue; 43 | - (NSString *)URLEncodedNameValuePair; 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /ESSVideoShare/OARequestParameter.m: -------------------------------------------------------------------------------- 1 | // 2 | // OARequestParameter.m 3 | // OAuthConsumer 4 | // 5 | // Created by Jon Crosby on 10/19/07. 6 | // Copyright 2007 Kaboomerang LLC. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | 27 | #import "OARequestParameter.h" 28 | 29 | 30 | @implementation OARequestParameter 31 | @synthesize name, value; 32 | 33 | + (id)requestParameterWithName:(NSString *)aName value:(NSString *)aValue 34 | { 35 | return [[[OARequestParameter alloc] initWithName:aName value:aValue] autorelease]; 36 | } 37 | 38 | - (id)initWithName:(NSString *)aName value:(NSString *)aValue 39 | { 40 | if (self = [super init]) 41 | { 42 | self.name = aName; 43 | self.value = aValue; 44 | } 45 | return self; 46 | } 47 | 48 | - (void)dealloc 49 | { 50 | [name release]; 51 | [value release]; 52 | [super dealloc]; 53 | } 54 | 55 | - (NSString *)URLEncodedName 56 | { 57 | return [self.name URLEncodedString]; 58 | } 59 | 60 | - (NSString *)URLEncodedValue 61 | { 62 | return [self.value URLEncodedString]; 63 | } 64 | 65 | - (NSString *)URLEncodedNameValuePair 66 | { 67 | return [NSString stringWithFormat:@"%@=%@", [self URLEncodedName], [self URLEncodedValue]]; 68 | } 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /ESSVideoShare/OAServiceTicket.h: -------------------------------------------------------------------------------- 1 | // 2 | // OAServiceTicket.h 3 | // OAuthConsumer 4 | // 5 | // Created by Jon Crosby on 11/5/07. 6 | // Copyright 2007 Kaboomerang LLC. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | 27 | #import 28 | #import "OAMutableURLRequest.h" 29 | 30 | 31 | @interface OAServiceTicket : NSObject { 32 | @private 33 | OAMutableURLRequest *request; 34 | NSURLResponse *response; 35 | BOOL didSucceed; 36 | } 37 | @property(retain) OAMutableURLRequest *request; 38 | @property(retain) NSURLResponse *response; 39 | @property(assign) BOOL didSucceed; 40 | 41 | - (id)initWithRequest:(OAMutableURLRequest *)aRequest response:(NSURLResponse *)aResponse didSucceed:(BOOL)success; 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /ESSVideoShare/OAServiceTicket.m: -------------------------------------------------------------------------------- 1 | // 2 | // OAServiceTicket.m 3 | // OAuthConsumer 4 | // 5 | // Created by Jon Crosby on 11/5/07. 6 | // Copyright 2007 Kaboomerang LLC. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | 27 | #import "OAServiceTicket.h" 28 | 29 | 30 | @implementation OAServiceTicket 31 | @synthesize request, response, didSucceed; 32 | 33 | - (id)initWithRequest:(OAMutableURLRequest *)aRequest response:(NSURLResponse *)aResponse didSucceed:(BOOL)success 34 | { 35 | if (self = [super init]) 36 | { 37 | self.request = aRequest; 38 | self.response = aResponse; 39 | self.didSucceed = success; 40 | } 41 | return self; 42 | } 43 | 44 | - (void)dealloc 45 | { 46 | [request release]; 47 | [response release]; 48 | [super dealloc]; 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /ESSVideoShare/OASignatureProviding.h: -------------------------------------------------------------------------------- 1 | // 2 | // OASignatureProviding.h 3 | // 4 | // Created by Jon Crosby on 10/19/07. 5 | // Copyright 2007 Kaboomerang LLC. All rights reserved. 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | 26 | #import 27 | 28 | 29 | @protocol OASignatureProviding 30 | 31 | - (NSString *)name; 32 | - (NSString *)signClearText:(NSString *)text withSecret:(NSString *)secret; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /ESSVideoShare/OATestServer.rb: -------------------------------------------------------------------------------- 1 | # 2 | # OATestServer.rb 3 | # OAuthConsumer 4 | # 5 | # Created by Jon Crosby on 10/19/07. 6 | # Copyright 2007 Kaboomerang LLC. All rights reserved. 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # Note: Before running this, install Sinatra: http://sinatra.rubyforge.org/ 27 | 28 | require 'rubygems' 29 | require 'sinatra' 30 | 31 | get '/' do 32 | "Testing..." 33 | end 34 | 35 | post '/request_token' do 36 | "oauth_token=nnch734d00sl2jdk&oauth_token_secret=pfkkdhi9sl3r4s00" 37 | end -------------------------------------------------------------------------------- /ESSVideoShare/OAToken.h: -------------------------------------------------------------------------------- 1 | // 2 | // OAToken.h 3 | // OAuthConsumer 4 | // 5 | // Created by Jon Crosby on 10/19/07. 6 | // Copyright 2007 Kaboomerang LLC. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | #import 27 | 28 | @interface OAToken : NSObject { 29 | @protected 30 | NSString *key; 31 | NSString *secret; 32 | } 33 | @property(retain) NSString *key; 34 | @property(retain) NSString *secret; 35 | 36 | - (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret; 37 | - (id)initWithUserDefaultsUsingServiceProviderName:(NSString *)provider prefix:(NSString *)prefix; 38 | - (id)initWithHTTPResponseBody:(NSString *)body; 39 | - (int)storeInUserDefaultsWithServiceProviderName:(NSString *)provider prefix:(NSString *)prefix; 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /ESSVideoShare/OAToken.m: -------------------------------------------------------------------------------- 1 | // 2 | // OAToken.m 3 | // OAuthConsumer 4 | // 5 | // Created by Jon Crosby on 10/19/07. 6 | // Copyright 2007 Kaboomerang LLC. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | 27 | #import "OAToken.h" 28 | 29 | 30 | @implementation OAToken 31 | 32 | @synthesize key, secret; 33 | 34 | #pragma mark init 35 | 36 | - (id)init 37 | { 38 | if (self = [super init]) 39 | { 40 | self.key = @""; 41 | self.secret = @""; 42 | } 43 | return self; 44 | } 45 | 46 | - (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret 47 | { 48 | if (self = [super init]) 49 | { 50 | self.key = aKey; 51 | self.secret = aSecret; 52 | } 53 | return self; 54 | } 55 | 56 | - (id)initWithHTTPResponseBody:(NSString *)body 57 | { 58 | if (self = [super init]) 59 | { 60 | NSArray *pairs = [body componentsSeparatedByString:@"&"]; 61 | 62 | for (NSString *pair in pairs) { 63 | NSArray *elements = [pair componentsSeparatedByString:@"="]; 64 | if ([[elements objectAtIndex:0] isEqualToString:@"oauth_token"]) { 65 | self.key = [[elements objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 66 | } else if ([[elements objectAtIndex:0] isEqualToString:@"oauth_token_secret"]) { 67 | self.secret = [[elements objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 68 | } 69 | } 70 | } 71 | return self; 72 | } 73 | 74 | - (id)initWithUserDefaultsUsingServiceProviderName:(NSString *)provider prefix:(NSString *)prefix 75 | { 76 | if (self = [super init]) 77 | { 78 | NSString *theKey = [[NSUserDefaults standardUserDefaults] stringForKey:[NSString stringWithFormat:@"OAUTH_%@_%@_KEY", prefix, provider]]; 79 | NSString *theSecret = [[NSUserDefaults standardUserDefaults] stringForKey:[NSString stringWithFormat:@"OAUTH_%@_%@_SECRET", prefix, provider]]; 80 | if (theKey == NULL || theSecret == NULL) 81 | return(nil); 82 | self.key = theKey; 83 | self.secret = theSecret; 84 | } 85 | return self; 86 | } 87 | 88 | - (void)dealloc 89 | { 90 | [key release]; 91 | [secret release]; 92 | [super dealloc]; 93 | } 94 | 95 | #pragma mark - 96 | 97 | - (int)storeInUserDefaultsWithServiceProviderName:(NSString *)provider prefix:(NSString *)prefix 98 | { 99 | [[NSUserDefaults standardUserDefaults] setObject:self.key forKey:[NSString stringWithFormat:@"OAUTH_%@_%@_KEY", prefix, provider]]; 100 | [[NSUserDefaults standardUserDefaults] setObject:self.secret forKey:[NSString stringWithFormat:@"OAUTH_%@_%@_SECRET", prefix, provider]]; 101 | [[NSUserDefaults standardUserDefaults] synchronize]; 102 | return(0); 103 | } 104 | 105 | @end 106 | -------------------------------------------------------------------------------- /ESSVideoShare/OAToken_KeychainExtensions.h: -------------------------------------------------------------------------------- 1 | // 2 | // OAToken_KeychainExtensions.h 3 | // TouchTheFireEagle 4 | // 5 | // Created by Jonathan Wight on 04/04/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "OAToken.h" 10 | 11 | #if (!TARGET_OS_IPHONE && !TARGET_OS_EMBEDDED && !TARGET_IPHONE_SIMULATOR) 12 | #import 13 | #endif 14 | 15 | @interface OAToken (OAToken_KeychainExtensions) 16 | 17 | #if (!TARGET_OS_IPHONE && !TARGET_OS_EMBEDDED && !TARGET_IPHONE_SIMULATOR) 18 | - (id)initWithKeychainUsingAppName:(NSString *)name serviceProviderName:(NSString *)provider; 19 | - (int)storeInDefaultKeychainWithAppName:(NSString *)name serviceProviderName:(NSString *)provider; 20 | - (int)storeInKeychain:(SecKeychainRef)keychain appName:(NSString *)name serviceProviderName:(NSString *)provider; 21 | #endif 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /ESSVideoShare/OAToken_KeychainExtensions.m: -------------------------------------------------------------------------------- 1 | // 2 | // OAToken_KeychainExtensions.m 3 | // TouchTheFireEagle 4 | // 5 | // Created by Jonathan Wight on 04/04/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "OAToken_KeychainExtensions.h" 10 | 11 | @implementation OAToken (OAToken_KeychainExtensions) 12 | 13 | #if (!TARGET_OS_IPHONE && !TARGET_OS_EMBEDDED && !TARGET_IPHONE_SIMULATOR) 14 | - (id)initWithKeychainUsingAppName:(NSString *)name serviceProviderName:(NSString *)provider 15 | { 16 | [super init]; 17 | SecKeychainItemRef item; 18 | NSString *serviceName = [NSString stringWithFormat:@"%@::OAuth::%@", name, provider]; 19 | OSStatus status = SecKeychainFindGenericPassword(NULL, 20 | (UInt32)strlen([serviceName UTF8String]), 21 | [serviceName UTF8String], 22 | 0, 23 | NULL, 24 | NULL, 25 | NULL, 26 | &item); 27 | if (status != noErr) { 28 | return nil; 29 | } 30 | 31 | // from Advanced Mac OS X Programming, ch. 16 32 | UInt32 length; 33 | char *password; 34 | SecKeychainAttribute attributes[8]; 35 | SecKeychainAttributeList list; 36 | 37 | attributes[0].tag = kSecAccountItemAttr; 38 | attributes[1].tag = kSecDescriptionItemAttr; 39 | attributes[2].tag = kSecLabelItemAttr; 40 | attributes[3].tag = kSecModDateItemAttr; 41 | 42 | list.count = 4; 43 | list.attr = attributes; 44 | 45 | status = SecKeychainItemCopyContent(item, NULL, &list, &length, (void **)&password); 46 | 47 | if (status == noErr) { 48 | self.key = [NSString stringWithCString:list.attr[0].data encoding:NSUTF8StringEncoding]; 49 | if (password != NULL) { 50 | char passwordBuffer[1024]; 51 | 52 | if (length > 1023) { 53 | length = 1023; 54 | } 55 | strncpy(passwordBuffer, password, length); 56 | 57 | passwordBuffer[length] = '\0'; 58 | self.secret = [NSString stringWithCString:passwordBuffer encoding:NSUTF8StringEncoding]; 59 | } 60 | 61 | SecKeychainItemFreeContent(&list, password); 62 | 63 | } else { 64 | // TODO find out why this always works in i386 and always fails on ppc 65 | NSLog(@"Error from SecKeychainItemCopyContent: %d", status); 66 | return nil; 67 | } 68 | 69 | NSMakeCollectable(item); 70 | 71 | return self; 72 | } 73 | 74 | 75 | - (int)storeInDefaultKeychainWithAppName:(NSString *)name serviceProviderName:(NSString *)provider 76 | { 77 | return [self storeInKeychain:NULL appName:name serviceProviderName:provider]; 78 | } 79 | 80 | - (int)storeInKeychain:(SecKeychainRef)keychain appName:(NSString *)name serviceProviderName:(NSString *)provider 81 | { 82 | OSStatus status = SecKeychainAddGenericPassword(keychain, 83 | (UInt32)([name length] + [provider length] + 9), 84 | [[NSString stringWithFormat:@"%@::OAuth::%@", name, provider] UTF8String], 85 | (UInt32)[self.key length], 86 | [self.key UTF8String], 87 | (UInt32)[self.secret length], 88 | [self.secret UTF8String], 89 | NULL 90 | ); 91 | return status; 92 | } 93 | #endif 94 | 95 | @end 96 | -------------------------------------------------------------------------------- /ESSVideoShare/OAuthConsumer.h: -------------------------------------------------------------------------------- 1 | // 2 | // OAuthConsumer.h 3 | // OAuthConsumer 4 | // 5 | // Created by Jon Crosby on 10/19/07. 6 | // Copyright 2007 Kaboomerang LLC. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | #import 27 | #import "OAToken.h" 28 | #import "OAConsumer.h" 29 | #import "OAMutableURLRequest.h" 30 | #import "NSString+URLEncoding.h" 31 | #import "NSMutableURLRequest+Parameters.h" 32 | #import "NSURL+Base.h" 33 | #import "OASignatureProviding.h" 34 | #import "OAHMAC_SHA1SignatureProvider.h" 35 | #import "OAPlaintextSignatureProvider.h" 36 | #import "OARequestParameter.h" 37 | #import "OAServiceTicket.h" 38 | #import "OADataFetcher.h" 39 | #import "OAAsynchronousDataFetcher.h" -------------------------------------------------------------------------------- /ESSVideoShare/OAuthConsumer_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'OAuthConsumer' target in the 'OAuthConsumer' project. 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /ESSVideoShare/Vimeo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternalstorms/ESSVideoShare-for-OS-X-Lion/6f3adb2d32d837ca8e612b93db012a91bd3658c5/ESSVideoShare/Vimeo.png -------------------------------------------------------------------------------- /ESSVideoShare/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /ESSVideoShare/fb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternalstorms/ESSVideoShare-for-OS-X-Lion/6f3adb2d32d837ca8e612b93db012a91bd3658c5/ESSVideoShare/fb.png -------------------------------------------------------------------------------- /ESSVideoShare/publish-youtube.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternalstorms/ESSVideoShare-for-OS-X-Lion/6f3adb2d32d837ca8e612b93db012a91bd3658c5/ESSVideoShare/publish-youtube.tif -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ESSVideoShare.framework for OS X Lion and iOS ReadMe 2 | 3 | ## What is ESSVideoShare.framework? 4 | 5 | ESSVideoShare.framework makes it very easy and quick to add uploading functionality for videos to these services: 6 | [YouTube](http://www.youtube.com), [Vimeo](http://www.vimeo.com), [Facebook](http://www.facebook.com) and [Flickr](http://www.flickr.com). 7 | 8 | It was inspired by QuickTime Player X's sharing functionality. 9 | 10 | ## First, the License Agreement 11 | 12 | 1) You can use the code in your own products. 13 | 2) You can modify the code as you wish, and use the modified code in your products. 14 | 3) You can redistribute the original, unmodified code, but you have to include the full license text below. 15 | 4) You can redistribute the modified code as you wish (without the full license text below). 16 | 5) In all cases, you must include a credit mentioning Matthias Gansrigler as the original author of the source. 17 | 6) I’m not liable for anything you do with the code, no matter what. So be sensible. 18 | 7) You can’t use my name or other marks to promote your products based on the code. 19 | 8) This framework uses the OAuthConsumer framework code which you can separately download from http://code.google.com/p/oauthconsumer/ which is made available under the MIT License. 20 | 9) If you agree to all of that, go ahead and download the source. Otherwise, don’t. 21 | 22 | # How To use ESSVideoShare 23 | 24 | Please be aware that the sample projects might not have the newest ESSVideoShare framework imported.) 25 | 26 | [OS X Lion (Wiki)](https://github.com/eternalstorms/ESSVideoShare-for-OS-X-Lion/wiki/How-To-for-OS-X-Lion) ([Sample Project for OS X Lion, ~250 KB](http://eternalstorms.at/opensource/ESSVideoShare/esvideosharetestMac.zip)) 27 | 28 | [iOS (Wiki)](https://github.com/eternalstorms/ESSVideoShare-for-OS-X-Lion/wiki/How-To-for-iOS) ([Sample Project for iOS, ~3 MB](http://eternalstorms.at/opensource/ESSVideoShare/essvideoshareios.zip)) 29 | 30 | # ESSVideoShare in Action 31 | 32 | ## ESSYouTube 33 | 34 | ![Login](http://www.eternalstorms.at/opensource/ESSVideoShare/youtube/1.png "Login") 35 | ![Meta Data](http://www.eternalstorms.at/opensource/ESSVideoShare/youtube/2.png "Movie meta data") 36 | ![Terms of Use](http://www.eternalstorms.at/opensource/ESSVideoShare/youtube/3.png "Terms of Use") 37 | ![Upload Progress](http://www.eternalstorms.at/opensource/ESSVideoShare/youtube/4.png "Upload progress") 38 | ![Waiting For Processing](http://www.eternalstorms.at/opensource/ESSVideoShare/youtube/5.png "Waiting for Processing") 39 | ![Done](http://www.eternalstorms.at/opensource/ESSVideoShare/youtube/6.png "Done") 40 | 41 | ## ESSVimeo 42 | 43 | ![Login](http://www.eternalstorms.at/opensource/ESSVideoShare/vimeo/1.png "Login") 44 | ![Meta Data](http://www.eternalstorms.at/opensource/ESSVideoShare/vimeo/2.png "Movie meta data") 45 | ![Terms of Use](http://www.eternalstorms.at/opensource/ESSVideoShare/vimeo/3.png "Terms of Use") 46 | ![Upload Progress](http://www.eternalstorms.at/opensource/ESSVideoShare/vimeo/4.png "Upload progress") 47 | ![Done](http://www.eternalstorms.at/opensource/ESSVideoShare/vimeo/5.png "Done") 48 | 49 | ## ESSFacebook 50 | 51 | ![Login](http://www.eternalstorms.at/opensource/ESSVideoShare/facebook/0.png "Login") 52 | ![Confirm Login](http://www.eternalstorms.at/opensource/ESSVideoShare/facebook/2.png "Confirm Login") 53 | ![Movie Metadata](http://www.eternalstorms.at/opensource/ESSVideoShare/facebook/3.png "Movie metadata") 54 | ![Upload Progress](http://www.eternalstorms.at/opensource/ESSVideoShare/facebook/4.png "Upload progress") 55 | ![Done](http://www.eternalstorms.at/opensource/ESSVideoShare/facebook/5.png "Done") 56 | 57 | ## ESSFlickr 58 | 59 | ![Login](http://www.eternalstorms.at/opensource/ESSVideoShare/flickr/1.png "Login") 60 | ![Movie metadata](http://www.eternalstorms.at/opensource/ESSVideoShare/flickr/2.png "Movie metadata") 61 | ![Upload Progress](http://www.eternalstorms.at/opensource/ESSVideoShare/flickr/3.png "Movie metadata") 62 | ![Waiting for Processing](http://www.eternalstorms.at/opensource/ESSVideoShare/flickr/4.png "Waiting for Processing") 63 | ![Done](http://www.eternalstorms.at/opensource/ESSVideoShare/flickr/5.png "Done") 64 | 65 | ## Requirements 66 | This code works on OS X Lion and later. 67 | Developed with Xcode 4.2.1 68 | 69 | ## External Frameworks / Source Code used 70 | 71 | OAuthConsumer framework (http://code.google.com/p/oauthconsumer/ , made available under the MIT License) 72 | 73 | ## Support 74 | The framework and code is provided as-is, but if you need help or have suggestions, you can contact me anytime at [opensource@eternalstorms.at](mailto:opensource@eternalstorms.at) or [@eternalstorms on twitter](http://twitter.com/eternalstorms) 75 | 76 | For other Open Source projects of mine, please visit http://www.eternalstorms.at/opensource 77 | 78 | # I want to hear from you 79 | If you use ESSVideoShare in one of your projects, please [let me know](mailto:opensource@eternalstorms.at)! I'd love to hear about your apps and mention them here on this project page :) !! --------------------------------------------------------------------------------