29
29
#import " UtilsUrls.h"
30
30
#import " OCSharedDto.h"
31
31
32
+ #define server_version_with_new_shared_schema 8
32
33
#define password_alert_view_tag 600
33
34
34
35
@@ -80,9 +81,24 @@ - (void) showShareActionSheetForFile:(FileDto *)file {
80
81
* @param token -> NSString
81
82
*
82
83
*/
83
- - (void ) presentShareActionSheetForToken : (NSString *)token withPassword : (BOOL ) isPasswordSet {
84
+ - (void ) presentShareActionSheetForToken : (NSString *)sharedLink withPassword : (BOOL ) isPasswordSet {
84
85
85
- NSString *sharedLink = [NSString stringWithFormat: @" %@%@%@ " ,APP_DELEGATE.activeUser.url,k_share_link_middle_part_url,token];
86
+ NSString *url = nil ;
87
+ // From ownCloud server 8.2 the url field is always set for public shares
88
+ if ([sharedLink hasPrefix: @" http://" ] || [sharedLink hasPrefix: @" https://" ])
89
+ {
90
+ url = sharedLink;
91
+ }else {
92
+ // Token
93
+ NSString *firstNumber = [[AppDelegate sharedOCCommunication ].getCurrentServerVersion substringToIndex: 1 ];
94
+
95
+ if (firstNumber.integerValue >= server_version_with_new_shared_schema) {
96
+ // From ownCloud server version 8 on, a different share link scheme is used.
97
+ url = [NSString stringWithFormat: @" %@%@%@ " , APP_DELEGATE.activeUser.url, k_share_link_middle_part_url_after_version_8, sharedLink];
98
+ }else {
99
+ url = [NSString stringWithFormat: @" %@%@%@ " , APP_DELEGATE.activeUser.url, k_share_link_middle_part_url_before_version_8, sharedLink];
100
+ }
101
+ }
86
102
87
103
UIActivityItemProvider *activityProvider = [[UIActivityItemProvider alloc ] initWithPlaceholderItem: [NSURL URLWithString: sharedLink]];
88
104
NSArray *items = @[activityProvider, sharedLink];
@@ -192,7 +208,6 @@ - (void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSIntege
192
208
* @param isFile -> BOOL. Distinct between is fileDto or shareDto
193
209
*/
194
210
- (void ) clickOnShareLinkFromFileDto : (BOOL )isFileDto {
195
- DLog (@" Click on Share Link" );
196
211
197
212
AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication ]delegate];
198
213
@@ -278,7 +293,7 @@ - (void) clickOnShareLinkFromFileDto:(BOOL)isFileDto {
278
293
[[AppDelegate sharedOCCommunication ] setUserAgent: [UtilsUrls getUserAgent ]];
279
294
280
295
// Checking the Shared files and folders
281
- [[AppDelegate sharedOCCommunication ] shareFileOrFolderByServer: app.activeUser.url andFileOrFolderPath: filePath onCommunication: [AppDelegate sharedOCCommunication ] successRequest: ^(NSHTTPURLResponse *response, NSString *token , NSString *redirectedServer) {
296
+ [[AppDelegate sharedOCCommunication ] shareFileOrFolderByServer: app.activeUser.url andFileOrFolderPath: filePath onCommunication: [AppDelegate sharedOCCommunication ] successRequest: ^(NSHTTPURLResponse *response, NSString *shareLink , NSString *redirectedServer) {
282
297
283
298
BOOL isSamlCredentialsError=NO ;
284
299
@@ -300,7 +315,7 @@ - (void) clickOnShareLinkFromFileDto:(BOOL)isFileDto {
300
315
[self endLoading ];
301
316
302
317
// Present
303
- [self presentShareActionSheetForToken: token withPassword: false ];
318
+ [self presentShareActionSheetForToken: shareLink withPassword: false ];
304
319
}
305
320
306
321
} failureRequest: ^(NSHTTPURLResponse *response, NSError *error) {
0 commit comments