mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-31 02:17:41 +00:00 
			
		
		
		
	Constants and comments after crossed review
This commit is contained in:
		
							parent
							
								
									825ef70cef
								
							
						
					
					
						commit
						f42a9f8c61
					
				| @ -63,6 +63,8 @@ public class GetRemoteStatusOperation extends RemoteOperation { | |||||||
| 
 | 
 | ||||||
|     private static final String NODE_INSTALLED = "installed"; |     private static final String NODE_INSTALLED = "installed"; | ||||||
|     private static final String NODE_VERSION = "version"; |     private static final String NODE_VERSION = "version"; | ||||||
|  |     private static final String HTTPS_PREFIX = "https://"; | ||||||
|  |     private static final String HTTP_PREFIX = "http://"; | ||||||
| 
 | 
 | ||||||
|     private RemoteOperationResult mLatestResult; |     private RemoteOperationResult mLatestResult; | ||||||
|     private Context mContext; |     private Context mContext; | ||||||
| @ -93,8 +95,8 @@ public class GetRemoteStatusOperation extends RemoteOperation { | |||||||
|                 && !mLatestResult.isSuccess()) { |                 && !mLatestResult.isSuccess()) { | ||||||
| 
 | 
 | ||||||
|                 isRedirectToNonSecureConnection |= ( |                 isRedirectToNonSecureConnection |= ( | ||||||
|                     baseUrlSt.startsWith("https://") && |                     baseUrlSt.startsWith(HTTPS_PREFIX) && | ||||||
|                         redirectedLocation.startsWith("http://") |                         redirectedLocation.startsWith(HTTP_PREFIX) | ||||||
|                 ); |                 ); | ||||||
|                 get.releaseConnection(); |                 get.releaseConnection(); | ||||||
|                 get = new GetMethod(redirectedLocation); |                 get = new GetMethod(redirectedLocation); | ||||||
| @ -125,7 +127,7 @@ public class GetRemoteStatusOperation extends RemoteOperation { | |||||||
|                         ); |                         ); | ||||||
|                     } else { |                     } else { | ||||||
|                         mLatestResult = new RemoteOperationResult( |                         mLatestResult = new RemoteOperationResult( | ||||||
|                             baseUrlSt.startsWith("https://") ? |                             baseUrlSt.startsWith(HTTPS_PREFIX) ? | ||||||
|                                 RemoteOperationResult.ResultCode.OK_SSL : |                                 RemoteOperationResult.ResultCode.OK_SSL : | ||||||
|                                 RemoteOperationResult.ResultCode.OK_NO_SSL |                                 RemoteOperationResult.ResultCode.OK_NO_SSL | ||||||
|                         ); |                         ); | ||||||
| @ -180,15 +182,15 @@ public class GetRemoteStatusOperation extends RemoteOperation { | |||||||
|             return new RemoteOperationResult(RemoteOperationResult.ResultCode.NO_NETWORK_CONNECTION); |             return new RemoteOperationResult(RemoteOperationResult.ResultCode.NO_NETWORK_CONNECTION); | ||||||
|         } |         } | ||||||
|         String baseUriStr = client.getBaseUri().toString(); |         String baseUriStr = client.getBaseUri().toString(); | ||||||
|         if (baseUriStr.startsWith("http://") || baseUriStr.startsWith("https://")) { |         if (baseUriStr.startsWith(HTTP_PREFIX) || baseUriStr.startsWith(HTTPS_PREFIX)) { | ||||||
|             tryConnection(client); |             tryConnection(client); | ||||||
| 
 | 
 | ||||||
|         } else { |         } else { | ||||||
|             client.setBaseUri(Uri.parse("https://" + baseUriStr)); |             client.setBaseUri(Uri.parse(HTTPS_PREFIX + baseUriStr)); | ||||||
|             boolean httpsSuccess = tryConnection(client); |             boolean httpsSuccess = tryConnection(client); | ||||||
|             if (!httpsSuccess && !mLatestResult.isSslRecoverableException()) { |             if (!httpsSuccess && !mLatestResult.isSslRecoverableException()) { | ||||||
|                 Log_OC.d(TAG, "establishing secure connection failed, trying non secure connection"); |                 Log_OC.d(TAG, "establishing secure connection failed, trying non secure connection"); | ||||||
|                 client.setBaseUri(Uri.parse("http://" + baseUriStr)); |                 client.setBaseUri(Uri.parse(HTTP_PREFIX + baseUriStr)); | ||||||
|                 tryConnection(client); |                 tryConnection(client); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -48,6 +48,8 @@ public class OwnCloudVersion implements Comparable<OwnCloudVersion> { | |||||||
|     private static final int MINIMUM_VERSION_WITH_SESSION_MONITORING_WORKING_IN_PREEMPTIVE_MODE = 0x09010301; |     private static final int MINIMUM_VERSION_WITH_SESSION_MONITORING_WORKING_IN_PREEMPTIVE_MODE = 0x09010301; | ||||||
|     // 9.1.3.1, final 9.1.3: https://github.com/owncloud/core/commit/f9a867b70c217463289a741d4d26079eb2a80dfd |     // 9.1.3.1, final 9.1.3: https://github.com/owncloud/core/commit/f9a867b70c217463289a741d4d26079eb2a80dfd | ||||||
| 
 | 
 | ||||||
|  |     private static final String INVALID_ZERO_VERSION = "0.0.0"; | ||||||
|  | 
 | ||||||
|     private static final int MAX_DOTS = 3; |     private static final int MAX_DOTS = 3; | ||||||
| 
 | 
 | ||||||
|     // format is in version |     // format is in version | ||||||
| @ -80,8 +82,11 @@ public class OwnCloudVersion implements Comparable<OwnCloudVersion> { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public String toString() { |     public String toString() { | ||||||
|  |         // gets the first digit of version, shifting hexadecimal version to right 'til max position | ||||||
|         String versionToString = String.valueOf((mVersion >> (8 * MAX_DOTS)) % 256); |         String versionToString = String.valueOf((mVersion >> (8 * MAX_DOTS)) % 256); | ||||||
|         for (int i = MAX_DOTS - 1; i >= 0; i--) { |         for (int i = MAX_DOTS - 1; i >= 0; i--) { | ||||||
|  |             // gets another digit of version, shifting hexadecimal version to right 8*i bits and... | ||||||
|  |             // ...discarding left part with mod 256 | ||||||
|             versionToString = versionToString + "." + String.valueOf((mVersion >> (8 * i)) % 256); |             versionToString = versionToString + "." + String.valueOf((mVersion >> (8 * i)) % 256); | ||||||
|         } |         } | ||||||
|         if (!mIsValid) { |         if (!mIsValid) { | ||||||
| @ -94,7 +99,7 @@ public class OwnCloudVersion implements Comparable<OwnCloudVersion> { | |||||||
|         if (mIsValid) { |         if (mIsValid) { | ||||||
|             return toString(); |             return toString(); | ||||||
|         } else { |         } else { | ||||||
|             return "0.0.0"; |             return INVALID_ZERO_VERSION; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user