From 3ef4eb8415a0c8af4a961bceac27e410ea3390ac Mon Sep 17 00:00:00 2001 From: Tobias Hagemann Date: Tue, 23 Jun 2015 23:10:59 +0200 Subject: [PATCH] Distinction between internal and public constants - Moved LiveConstants to public scope - Added LiveInternalConstants to internal scope - Removed overrideLoginServer:apiServer: from LiveAuthHelper because it was unused - Updated LIVE_SDK_VERSION to 5.6.2 --- src/LiveSDK.xcodeproj/project.pbxproj | 18 +++- .../Library/Internal/Helpers/LiveApiHelper.m | 1 + .../Library/Internal/Helpers/LiveAuthHelper.h | 3 - .../Library/Internal/Helpers/LiveAuthHelper.m | 14 +-- .../Library/Internal/LiveAuthRefreshRequest.m | 1 + .../Library/Internal/LiveAuthStorage.m | 2 +- .../Library/Internal/LiveConnectClientCore.h | 2 +- src/LiveSDK/Library/Internal/LiveConstants.h | 100 ++++++------------ src/LiveSDK/Library/Internal/LiveConstants.m | 59 +++++++++++ .../Library/Internal/LiveInternalConstants.h | 65 ++++++++++++ .../Library/Internal/LiveInternalConstants.m | 65 ++++++++++++ .../Internal/LiveUploadOperationCore.m | 1 + 12 files changed, 244 insertions(+), 87 deletions(-) create mode 100644 src/LiveSDK/Library/Internal/LiveConstants.m create mode 100644 src/LiveSDK/Library/Internal/LiveInternalConstants.h create mode 100644 src/LiveSDK/Library/Internal/LiveInternalConstants.m diff --git a/src/LiveSDK.xcodeproj/project.pbxproj b/src/LiveSDK.xcodeproj/project.pbxproj index 24c1677..d91ad96 100755 --- a/src/LiveSDK.xcodeproj/project.pbxproj +++ b/src/LiveSDK.xcodeproj/project.pbxproj @@ -97,6 +97,11 @@ 52C47514149B38D1007E646F /* LiveOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 529DB6D7146C7550000973C1 /* LiveOperation.m */; }; 52C47515149B38D1007E646F /* LiveOperationProgress.m in Sources */ = {isa = PBXBuildFile; fileRef = 52B4944C1487625C001EA573 /* LiveOperationProgress.m */; }; 52C47518149B390F007E646F /* LiveAuthDialog.m in Sources */ = {isa = PBXBuildFile; fileRef = 5210CF951494445E00C525F3 /* LiveAuthDialog.m */; }; + 7455C6631B39FF5A008350C6 /* LiveInternalConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = 7455C6611B39FF5A008350C6 /* LiveInternalConstants.h */; }; + 7455C6641B39FF5A008350C6 /* LiveInternalConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 7455C6621B39FF5A008350C6 /* LiveInternalConstants.m */; }; + 7455C6651B39FF63008350C6 /* LiveInternalConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 7455C6621B39FF5A008350C6 /* LiveInternalConstants.m */; }; + 7455C6671B39FF71008350C6 /* LiveConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 7455C6661B39FF71008350C6 /* LiveConstants.m */; }; + 7455C6681B39FF71008350C6 /* LiveConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 7455C6661B39FF71008350C6 /* LiveConstants.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -189,6 +194,9 @@ 52F76E8F147A308500DA0A46 /* LiveApiHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LiveApiHelper.h; path = LiveSDK/Library/Internal/Helpers/LiveApiHelper.h; sourceTree = SOURCE_ROOT; }; 52F76E90147A308500DA0A46 /* LiveApiHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LiveApiHelper.m; path = LiveSDK/Library/Internal/Helpers/LiveApiHelper.m; sourceTree = SOURCE_ROOT; }; 52F76E94147A3FA500DA0A46 /* LiveAuthDialog_iPad.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = LiveAuthDialog_iPad.xib; path = Library/Internal/LiveAuthDialog_iPad.xib; sourceTree = ""; }; + 7455C6611B39FF5A008350C6 /* LiveInternalConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LiveInternalConstants.h; path = Library/Internal/LiveInternalConstants.h; sourceTree = ""; }; + 7455C6621B39FF5A008350C6 /* LiveInternalConstants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LiveInternalConstants.m; path = Library/Internal/LiveInternalConstants.m; sourceTree = ""; }; + 7455C6661B39FF71008350C6 /* LiveConstants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LiveConstants.m; path = Library/Internal/LiveConstants.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -362,6 +370,8 @@ 529DB6D1146C7550000973C1 /* LiveConnectSession.h */, 529DB6D2146C7550000973C1 /* LiveConnectSession.m */, 528518A61473BE78009E8BD6 /* LiveConnectSessionStatus.h */, + 529DB6E7146C7645000973C1 /* LiveConstants.h */, + 7455C6661B39FF71008350C6 /* LiveConstants.m */, 529DB6D3146C7550000973C1 /* LiveDownloadOperation.h */, 529DB6D4146C7550000973C1 /* LiveDownloadOperation.m */, 529DB6D5146C7550000973C1 /* LiveDownloadOperationDelegate.h */, @@ -392,7 +402,8 @@ 529DB712146F5809000973C1 /* LiveAuthRequest.m */, 529DB6EE146C7AEE000973C1 /* LiveConnectClientCore.h */, 529DB6EF146C7AEE000973C1 /* LiveConnectClientCore.m */, - 529DB6E7146C7645000973C1 /* LiveConstants.h */, + 7455C6611B39FF5A008350C6 /* LiveInternalConstants.h */, + 7455C6621B39FF5A008350C6 /* LiveInternalConstants.m */, 52B494511488BDF4001EA573 /* LiveDownloadOperationCore.h */, 52B494521488BDF5001EA573 /* LiveDownloadOperationCore.m */, 52B4946B148B0FDF001EA573 /* LiveDownloadOperationInternal.h */, @@ -435,6 +446,7 @@ 5207541314987F440058A61E /* LiveAuthStorage.h in Headers */, 52851846147282C2009E8BD6 /* LiveConnectClientCore.h in Headers */, 52851848147282C2009E8BD6 /* LiveConstants.h in Headers */, + 7455C6631B39FF5A008350C6 /* LiveInternalConstants.h in Headers */, 52A497E9149F178D0034BE79 /* LiveConnectionHelper.h in Headers */, 52A497EA149F178D0034BE79 /* LiveConnectionCreatorDelegate.h in Headers */, 5207541414987F440058A61E /* LiveDownloadOperationCore.h in Headers */, @@ -567,7 +579,9 @@ 52851850147282E8009E8BD6 /* LiveAuthRequest.m in Sources */, 52851851147282E8009E8BD6 /* LiveConnectClientCore.m in Sources */, 52851852147282E8009E8BD6 /* LiveOperationCore.m in Sources */, + 7455C6641B39FF5A008350C6 /* LiveInternalConstants.m in Sources */, 52851854147282E8009E8BD6 /* JsonParser.m in Sources */, + 7455C6681B39FF71008350C6 /* LiveConstants.m in Sources */, 52851855147282E8009E8BD6 /* JsonWriter.m in Sources */, 52851856147282E8009E8BD6 /* LiveAuthHelper.m in Sources */, 52851857147282E8009E8BD6 /* StringHelper.m in Sources */, @@ -590,6 +604,7 @@ 52C4750E149B38D1007E646F /* LiveDownloadOperationCore.m in Sources */, 52C4750F149B38D1007E646F /* LiveOperationCore.m in Sources */, 52C47510149B38D1007E646F /* LiveUploadOperationCore.m in Sources */, + 7455C6671B39FF71008350C6 /* LiveConstants.m in Sources */, 52C47511149B38D1007E646F /* LiveConnectionHelper.m in Sources */, 52C47512149B38D1007E646F /* LiveConnectClient.m in Sources */, 52C47513149B38D1007E646F /* LiveDownloadOperation.m in Sources */, @@ -611,6 +626,7 @@ 52559D951506EC7100F0DF04 /* LiveConnectClientListener.m in Sources */, 52559D961506EC7100F0DF04 /* MockFactory.m in Sources */, 52559D971506EC7100F0DF04 /* MockResponse.m in Sources */, + 7455C6651B39FF63008350C6 /* LiveInternalConstants.m in Sources */, 52559D981506EC7100F0DF04 /* MockUrlConnection.m in Sources */, 52559D991506EC7100F0DF04 /* StringHelperTests.m in Sources */, 52559D9A1506EC7100F0DF04 /* UrlHelperTests.m in Sources */, diff --git a/src/LiveSDK/Library/Internal/Helpers/LiveApiHelper.m b/src/LiveSDK/Library/Internal/Helpers/LiveApiHelper.m index d2aaa8d..29f6930 100644 --- a/src/LiveSDK/Library/Internal/Helpers/LiveApiHelper.m +++ b/src/LiveSDK/Library/Internal/Helpers/LiveApiHelper.m @@ -27,6 +27,7 @@ #import "LiveAuthHelper.h" #import "LiveApiHelper.h" #import "LiveConstants.h" +#import "LiveInternalConstants.h" #import "JsonParser.h" #import "JsonWriter.h" #import "UrlHelper.h" diff --git a/src/LiveSDK/Library/Internal/Helpers/LiveAuthHelper.h b/src/LiveSDK/Library/Internal/Helpers/LiveAuthHelper.h index 7af94e6..55d10cd 100644 --- a/src/LiveSDK/Library/Internal/Helpers/LiveAuthHelper.h +++ b/src/LiveSDK/Library/Internal/Helpers/LiveAuthHelper.h @@ -74,7 +74,4 @@ + (BOOL) shouldRefreshToken:(LiveConnectSession *)session refreshToken:(NSString *)refreshToken; -+ (void) overrideLoginServer:(NSString *)loginServer - apiServer:(NSString *)apiServer; - @end diff --git a/src/LiveSDK/Library/Internal/Helpers/LiveAuthHelper.m b/src/LiveSDK/Library/Internal/Helpers/LiveAuthHelper.m index 12d9d7d..1116a07 100644 --- a/src/LiveSDK/Library/Internal/Helpers/LiveAuthHelper.m +++ b/src/LiveSDK/Library/Internal/Helpers/LiveAuthHelper.m @@ -25,15 +25,13 @@ #import #import "LiveAuthHelper.h" -#import "LiveConstants.h" #import "LiveConnectSession.h" +#import "LiveConstants.h" +#import "LiveInternalConstants.h" #import "JsonParser.h" #import "StringHelper.h" #import "UrlHelper.h" -NSString * LIVE_ENDPOINT_API_HOST = @"apis.live.net"; -NSString * LIVE_ENDPOINT_LOGIN_HOST = @"login.live.com"; - @implementation LiveAuthHelper + (NSBundle *) getSDKBundle @@ -265,12 +263,4 @@ + (BOOL) shouldRefreshToken:(LiveConnectSession *)session } } -+ (void) overrideLoginServer:(NSString *)loginServer - apiServer:(NSString *)apiServer - -{ - LIVE_ENDPOINT_LOGIN_HOST = loginServer; - LIVE_ENDPOINT_API_HOST = apiServer; -} - @end diff --git a/src/LiveSDK/Library/Internal/LiveAuthRefreshRequest.m b/src/LiveSDK/Library/Internal/LiveAuthRefreshRequest.m index c3b9f66..e6d742a 100644 --- a/src/LiveSDK/Library/Internal/LiveAuthRefreshRequest.m +++ b/src/LiveSDK/Library/Internal/LiveAuthRefreshRequest.m @@ -27,6 +27,7 @@ #import "LiveAuthHelper.h" #import "LiveAuthRefreshRequest.h" #import "LiveConnectionHelper.h" +#import "LiveConstants.h" #import "StringHelper.h" @implementation LiveAuthRefreshRequest diff --git a/src/LiveSDK/Library/Internal/LiveAuthStorage.m b/src/LiveSDK/Library/Internal/LiveAuthStorage.m index fe13d30..4773e39 100644 --- a/src/LiveSDK/Library/Internal/LiveAuthStorage.m +++ b/src/LiveSDK/Library/Internal/LiveAuthStorage.m @@ -25,7 +25,7 @@ #import "LiveAuthStorage.h" -#import "LiveConstants.h" +#import "LiveInternalConstants.h" @interface LiveAuthStorage() diff --git a/src/LiveSDK/Library/Internal/LiveConnectClientCore.h b/src/LiveSDK/Library/Internal/LiveConnectClientCore.h index 44c3fd2..657ed7c 100644 --- a/src/LiveSDK/Library/Internal/LiveConnectClientCore.h +++ b/src/LiveSDK/Library/Internal/LiveConnectClientCore.h @@ -30,9 +30,9 @@ #import "LiveAuthRefreshRequest.h" #import "LiveAuthStorage.h" #import "LiveConnectSession.h" -#import "LiveConstants.h" #import "LiveDownloadOperationCore.h" #import "LiveDownloadOperationDelegate.h" +#import "LiveInternalConstants.h" #import "LiveOperationCore.h" #import "LiveOperationDelegate.h" #import "LiveUploadOperationDelegate.h" diff --git a/src/LiveSDK/Library/Internal/LiveConstants.h b/src/LiveSDK/Library/Internal/LiveConstants.h index 6035d17..ee4da09 100644 --- a/src/LiveSDK/Library/Internal/LiveConstants.h +++ b/src/LiveSDK/Library/Internal/LiveConstants.h @@ -26,72 +26,34 @@ #import -extern NSString * LIVE_ENDPOINT_API_HOST; -extern NSString * LIVE_ENDPOINT_LOGIN_HOST; - -static const NSTimeInterval HTTP_REQUEST_TIMEOUT_INTERVAL = 30; - -static const NSTimeInterval LIVE_AUTH_EXPIRE_VALUE_ADJUSTMENT = 3; -static const NSTimeInterval LIVE_AUTH_REFRESH_TIME_BEFORE_EXPIRE = 30; - -static NSString * const LIVE_API_HEADER_AUTHORIZATION = @"Authorization"; -static NSString * const LIVE_API_HEADER_CONTENTTYPE = @"Content-Type"; -static NSString * const LIVE_API_HEADER_METHOD = @"method"; -static NSString * const LIVE_API_HEADER_CONTENTTYPE_JSON = @"application/json;charset=UTF-8"; -static NSString * const LIVE_API_HEADER_X_HTTP_LIVE_LIBRARY = @"X-HTTP-Live-Library"; -static NSString * const LIVE_API_PARAM_OVERWRITE = @"overwrite"; -static NSString * const LIVE_API_PARAM_SUPPRESS_REDIRECTS = @"suppress_redirects"; -static NSString * const LIVE_API_PARAM_SUPPRESS_RESPONSE_CODES = @"suppress_response_codes"; - -static NSString * const LIVE_AUTH_ACCESS_TOKEN = @"access_token"; -static NSString * const LIVE_AUTH_AUTHENTICATION_TOKEN = @"authentication_token"; -static NSString * const LIVE_AUTH_CODE = @"code"; -static NSString * const LIVE_AUTH_CLIENTID = @"client_id"; -static NSString * const LIVE_AUTH_DISPLAY = @"display"; -static NSString * const LIVE_AUTH_DISPLAY_IOS_PHONE = @"ios_phone"; -static NSString * const LIVE_AUTH_DISPLAY_IOS_TABLET = @"ios_tablet"; -static NSString * const LIVE_AUTH_GRANT_TYPE = @"grant_type"; -static NSString * const LIVE_AUTH_GRANT_TYPE_AUTHCODE = @"authorization_code"; -static NSString * const LIVE_AUTH_LOCALE = @"locale"; -static NSString * const LIVE_AUTH_REDIRECT_URI = @"redirect_uri"; -static NSString * const LIVE_AUTH_REFRESH_TOKEN = @"refresh_token"; -static NSString * const LIVE_AUTH_RESPONSE_TYPE = @"response_type"; -static NSString * const LIVE_AUTH_SCOPE = @"scope"; -static NSString * const LIVE_AUTH_THEME = @"theme"; -static NSString * const LIVE_AUTH_THEME_IOS = @"ios"; -static NSString * const LIVE_AUTH_TOKEN = @"token"; - -static NSString * const LIVE_AUTH_POST_CONTENT_TYPE = @"application/x-www-form-urlencoded;charset=UTF-8"; -static NSString * const LIVE_AUTH_EXPIRES_IN = @"expires_in"; - -static const NSInteger LIVE_ERROR_CODE_LOGIN_FAILED = 1; -static const NSInteger LIVE_ERROR_CODE_LOGIN_CANCELED = 2; -static const NSInteger LIVE_ERROR_CODE_RETRIEVE_TOKEN_FAILED = 3; -static const NSInteger LIVE_ERROR_CODE_API_CANCELED = 4; -static const NSInteger LIVE_ERROR_CODE_API_FAILED = 5; - -static NSString * const LIVE_ERROR_CODE_S_ACCESS_DENIED = @"access_denied"; -static NSString * const LIVE_ERROR_CODE_S_INVALID_GRANT = @"invalid_grant"; -static NSString * const LIVE_ERROR_CODE_S_REQUEST_CANCELED = @"request_canceled"; -static NSString * const LIVE_ERROR_CODE_S_REQUEST_FAILED = @"request_failed"; -static NSString * const LIVE_ERROR_CODE_S_RESPONSE_PARSING_FAILED = @"response_parse_failure"; - -static NSString * const LIVE_ERROR_DESC_API_CANCELED = @"The request was canceled."; -static NSString * const LIVE_ERROR_DESC_AUTH_CANCELED = @"The user has canceled the authorization request."; -static NSString * const LIVE_ERROR_DESC_AUTH_FAILED = @"The authorization request failed to complete."; -static NSString * const LIVE_ERROR_DESC_MISSING_PARAMETER = @"The parameter '%@' must be specified when calling '%@'."; -static NSString * const LIVE_ERROR_DESC_MUST_INIT = @"The LiveConnectClient instance must be initialized before being used."; -static NSString * const LIVE_ERROR_DESC_PENDING_LOGIN_EXIST = @"There is already a pending login request."; -static NSString * const LIVE_ERROR_DESC_REQUIRE_RELATIVE_PATH = @"The 'path' parameter must be a relative path when calling '%@'."; -static NSString * const LIVE_ERROR_DESC_UPLOAD_FAIL_QUERY = @"Failed to query upload location."; - -static NSString * const LIVE_ERROR_DOMAIN = @"LiveServicesErrorDomain"; -static NSString * const LIVE_ERROR_KEY_ERROR = @"error"; -static NSString * const LIVE_ERROR_KEY_DESCRIPTION = @"error_description"; -static NSString * const LIVE_ERROR_KEY_CODE = @"code"; -static NSString * const LIVE_ERROR_KEY_MESSAGE = @"message"; -static NSString * const LIVE_ERROR_KEY_INNER_ERROR = @"internal_error"; - -static NSString * const LIVE_EXCEPTION = @"LiveException"; - -static NSString * const LIVE_SDK_VERSION = @"5.0"; +extern NSInteger const LIVE_ERROR_CODE_LOGIN_FAILED; +extern NSInteger const LIVE_ERROR_CODE_LOGIN_CANCELED; +extern NSInteger const LIVE_ERROR_CODE_RETRIEVE_TOKEN_FAILED; +extern NSInteger const LIVE_ERROR_CODE_API_CANCELED; +extern NSInteger const LIVE_ERROR_CODE_API_FAILED; + +extern NSString * const LIVE_ERROR_CODE_S_ACCESS_DENIED; +extern NSString * const LIVE_ERROR_CODE_S_INVALID_GRANT; +extern NSString * const LIVE_ERROR_CODE_S_REQUEST_CANCELED; +extern NSString * const LIVE_ERROR_CODE_S_REQUEST_FAILED; +extern NSString * const LIVE_ERROR_CODE_S_RESPONSE_PARSING_FAILED; + +extern NSString * const LIVE_ERROR_DESC_API_CANCELED; +extern NSString * const LIVE_ERROR_DESC_AUTH_CANCELED; +extern NSString * const LIVE_ERROR_DESC_AUTH_FAILED; +extern NSString * const LIVE_ERROR_DESC_MISSING_PARAMETER; +extern NSString * const LIVE_ERROR_DESC_MUST_INIT; +extern NSString * const LIVE_ERROR_DESC_PENDING_LOGIN_EXIST; +extern NSString * const LIVE_ERROR_DESC_REQUIRE_RELATIVE_PATH; +extern NSString * const LIVE_ERROR_DESC_UPLOAD_FAIL_QUERY; + +extern NSString * const LIVE_ERROR_DOMAIN; +extern NSString * const LIVE_ERROR_KEY_ERROR; +extern NSString * const LIVE_ERROR_KEY_DESCRIPTION; +extern NSString * const LIVE_ERROR_KEY_CODE; +extern NSString * const LIVE_ERROR_KEY_MESSAGE; +extern NSString * const LIVE_ERROR_KEY_INNER_ERROR; + +extern NSString * const LIVE_EXCEPTION; + +extern NSString * const LIVE_SDK_VERSION; diff --git a/src/LiveSDK/Library/Internal/LiveConstants.m b/src/LiveSDK/Library/Internal/LiveConstants.m new file mode 100644 index 0000000..e59bfd9 --- /dev/null +++ b/src/LiveSDK/Library/Internal/LiveConstants.m @@ -0,0 +1,59 @@ +// +// LiveConstants.m +// Live SDK for iOS +// +// Copyright 2015 Microsoft Corporation +// +// 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: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// 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. +// + + +#import + +NSInteger const LIVE_ERROR_CODE_LOGIN_FAILED = 1; +NSInteger const LIVE_ERROR_CODE_LOGIN_CANCELED = 2; +NSInteger const LIVE_ERROR_CODE_RETRIEVE_TOKEN_FAILED = 3; +NSInteger const LIVE_ERROR_CODE_API_CANCELED = 4; +NSInteger const LIVE_ERROR_CODE_API_FAILED = 5; + +NSString * const LIVE_ERROR_CODE_S_ACCESS_DENIED = @"access_denied"; +NSString * const LIVE_ERROR_CODE_S_INVALID_GRANT = @"invalid_grant"; +NSString * const LIVE_ERROR_CODE_S_REQUEST_CANCELED = @"request_canceled"; +NSString * const LIVE_ERROR_CODE_S_REQUEST_FAILED = @"request_failed"; +NSString * const LIVE_ERROR_CODE_S_RESPONSE_PARSING_FAILED = @"response_parse_failure"; + +NSString * const LIVE_ERROR_DESC_API_CANCELED = @"The request was canceled."; +NSString * const LIVE_ERROR_DESC_AUTH_CANCELED = @"The user has canceled the authorization request."; +NSString * const LIVE_ERROR_DESC_AUTH_FAILED = @"The authorization request failed to complete."; +NSString * const LIVE_ERROR_DESC_MISSING_PARAMETER = @"The parameter '%@' must be specified when calling '%@'."; +NSString * const LIVE_ERROR_DESC_MUST_INIT = @"The LiveConnectClient instance must be initialized before being used."; +NSString * const LIVE_ERROR_DESC_PENDING_LOGIN_EXIST = @"There is already a pending login request."; +NSString * const LIVE_ERROR_DESC_REQUIRE_RELATIVE_PATH = @"The 'path' parameter must be a relative path when calling '%@'."; +NSString * const LIVE_ERROR_DESC_UPLOAD_FAIL_QUERY = @"Failed to query upload location."; + +NSString * const LIVE_ERROR_DOMAIN = @"LiveServicesErrorDomain"; +NSString * const LIVE_ERROR_KEY_ERROR = @"error"; +NSString * const LIVE_ERROR_KEY_DESCRIPTION = @"error_description"; +NSString * const LIVE_ERROR_KEY_CODE = @"code"; +NSString * const LIVE_ERROR_KEY_MESSAGE = @"message"; +NSString * const LIVE_ERROR_KEY_INNER_ERROR = @"internal_error"; + +NSString * const LIVE_EXCEPTION = @"LiveException"; + +NSString * const LIVE_SDK_VERSION = @"5.6.2"; diff --git a/src/LiveSDK/Library/Internal/LiveInternalConstants.h b/src/LiveSDK/Library/Internal/LiveInternalConstants.h new file mode 100644 index 0000000..d7311a5 --- /dev/null +++ b/src/LiveSDK/Library/Internal/LiveInternalConstants.h @@ -0,0 +1,65 @@ +// +// LiveInternalConstants.h +// Live SDK for iOS +// +// Copyright 2015 Microsoft Corporation +// +// 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: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// 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. +// + + +#import + +extern NSString * const LIVE_ENDPOINT_API_HOST; +extern NSString * const LIVE_ENDPOINT_LOGIN_HOST; + +extern NSTimeInterval const HTTP_REQUEST_TIMEOUT_INTERVAL; + +extern NSTimeInterval const LIVE_AUTH_EXPIRE_VALUE_ADJUSTMENT; +extern NSTimeInterval const LIVE_AUTH_REFRESH_TIME_BEFORE_EXPIRE; + +extern NSString * const LIVE_API_HEADER_AUTHORIZATION; +extern NSString * const LIVE_API_HEADER_CONTENTTYPE; +extern NSString * const LIVE_API_HEADER_METHOD; +extern NSString * const LIVE_API_HEADER_CONTENTTYPE_JSON; +extern NSString * const LIVE_API_HEADER_X_HTTP_LIVE_LIBRARY; +extern NSString * const LIVE_API_PARAM_OVERWRITE; +extern NSString * const LIVE_API_PARAM_SUPPRESS_REDIRECTS; +extern NSString * const LIVE_API_PARAM_SUPPRESS_RESPONSE_CODES; + +extern NSString * const LIVE_AUTH_ACCESS_TOKEN; +extern NSString * const LIVE_AUTH_AUTHENTICATION_TOKEN; +extern NSString * const LIVE_AUTH_CODE; +extern NSString * const LIVE_AUTH_CLIENTID; +extern NSString * const LIVE_AUTH_DISPLAY; +extern NSString * const LIVE_AUTH_DISPLAY_IOS_PHONE; +extern NSString * const LIVE_AUTH_DISPLAY_IOS_TABLET; +extern NSString * const LIVE_AUTH_GRANT_TYPE; +extern NSString * const LIVE_AUTH_GRANT_TYPE_AUTHCODE; +extern NSString * const LIVE_AUTH_LOCALE; +extern NSString * const LIVE_AUTH_REDIRECT_URI; +extern NSString * const LIVE_AUTH_REFRESH_TOKEN; +extern NSString * const LIVE_AUTH_RESPONSE_TYPE; +extern NSString * const LIVE_AUTH_SCOPE; +extern NSString * const LIVE_AUTH_THEME; +extern NSString * const LIVE_AUTH_THEME_IOS; +extern NSString * const LIVE_AUTH_TOKEN; + +extern NSString * const LIVE_AUTH_POST_CONTENT_TYPE; +extern NSString * const LIVE_AUTH_EXPIRES_IN; diff --git a/src/LiveSDK/Library/Internal/LiveInternalConstants.m b/src/LiveSDK/Library/Internal/LiveInternalConstants.m new file mode 100644 index 0000000..a66fb8a --- /dev/null +++ b/src/LiveSDK/Library/Internal/LiveInternalConstants.m @@ -0,0 +1,65 @@ +// +// LiveInternalConstants.m +// Live SDK for iOS +// +// Copyright 2015 Microsoft Corporation +// +// 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: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// 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. +// + + +#import + +NSString * const LIVE_ENDPOINT_API_HOST = @"apis.live.net"; +NSString * const LIVE_ENDPOINT_LOGIN_HOST = @"login.live.com"; + +NSTimeInterval const HTTP_REQUEST_TIMEOUT_INTERVAL = 30; + +NSTimeInterval const LIVE_AUTH_EXPIRE_VALUE_ADJUSTMENT = 3; +NSTimeInterval const LIVE_AUTH_REFRESH_TIME_BEFORE_EXPIRE = 30; + +NSString * const LIVE_API_HEADER_AUTHORIZATION = @"Authorization"; +NSString * const LIVE_API_HEADER_CONTENTTYPE = @"Content-Type"; +NSString * const LIVE_API_HEADER_METHOD = @"method"; +NSString * const LIVE_API_HEADER_CONTENTTYPE_JSON = @"application/json;charset=UTF-8"; +NSString * const LIVE_API_HEADER_X_HTTP_LIVE_LIBRARY = @"X-HTTP-Live-Library"; +NSString * const LIVE_API_PARAM_OVERWRITE = @"overwrite"; +NSString * const LIVE_API_PARAM_SUPPRESS_REDIRECTS = @"suppress_redirects"; +NSString * const LIVE_API_PARAM_SUPPRESS_RESPONSE_CODES = @"suppress_response_codes"; + +NSString * const LIVE_AUTH_ACCESS_TOKEN = @"access_token"; +NSString * const LIVE_AUTH_AUTHENTICATION_TOKEN = @"authentication_token"; +NSString * const LIVE_AUTH_CODE = @"code"; +NSString * const LIVE_AUTH_CLIENTID = @"client_id"; +NSString * const LIVE_AUTH_DISPLAY = @"display"; +NSString * const LIVE_AUTH_DISPLAY_IOS_PHONE = @"ios_phone"; +NSString * const LIVE_AUTH_DISPLAY_IOS_TABLET = @"ios_tablet"; +NSString * const LIVE_AUTH_GRANT_TYPE = @"grant_type"; +NSString * const LIVE_AUTH_GRANT_TYPE_AUTHCODE = @"authorization_code"; +NSString * const LIVE_AUTH_LOCALE = @"locale"; +NSString * const LIVE_AUTH_REDIRECT_URI = @"redirect_uri"; +NSString * const LIVE_AUTH_REFRESH_TOKEN = @"refresh_token"; +NSString * const LIVE_AUTH_RESPONSE_TYPE = @"response_type"; +NSString * const LIVE_AUTH_SCOPE = @"scope"; +NSString * const LIVE_AUTH_THEME = @"theme"; +NSString * const LIVE_AUTH_THEME_IOS = @"ios"; +NSString * const LIVE_AUTH_TOKEN = @"token"; + +NSString * const LIVE_AUTH_POST_CONTENT_TYPE = @"application/x-www-form-urlencoded;charset=UTF-8"; +NSString * const LIVE_AUTH_EXPIRES_IN = @"expires_in"; diff --git a/src/LiveSDK/Library/Internal/LiveUploadOperationCore.m b/src/LiveSDK/Library/Internal/LiveUploadOperationCore.m index 68d2859..4cd9cec 100644 --- a/src/LiveSDK/Library/Internal/LiveUploadOperationCore.m +++ b/src/LiveSDK/Library/Internal/LiveUploadOperationCore.m @@ -26,6 +26,7 @@ #import "LiveApiHelper.h" #import "LiveConnectClientCore.h" +#import "LiveConstants.h" #import "LiveOperation.h" #import "LiveUploadOperationCore.h" #import "StringHelper.h"