marinofaggiana 4 жил өмнө
parent
commit
4820edf0c7

+ 0 - 6
Nextcloud.xcodeproj/project.pbxproj

@@ -183,7 +183,6 @@
 		F77B0E1B1D118A16002130FE /* CCGraphics.m in Sources */ = {isa = PBXBuildFile; fileRef = F76C3B841C6388BC00DC4301 /* CCGraphics.m */; };
 		F77B0E221D118A16002130FE /* CCManageLocation.m in Sources */ = {isa = PBXBuildFile; fileRef = F7BFCCC11B68C21900548E76 /* CCManageLocation.m */; };
 		F77B0E301D118A16002130FE /* CCHud.m in Sources */ = {isa = PBXBuildFile; fileRef = F7514EDB1C7B1336008F3338 /* CCHud.m */; };
-		F77B0E311D118A16002130FE /* CCExifGeo.m in Sources */ = {isa = PBXBuildFile; fileRef = F7A54C351C6267B500E2C8BF /* CCExifGeo.m */; };
 		F77B0E4F1D118A16002130FE /* CCManageAutoUpload.m in Sources */ = {isa = PBXBuildFile; fileRef = F7ACE42F1BAC0268006C0017 /* CCManageAutoUpload.m */; };
 		F77B0E5F1D118A16002130FE /* NCSettings.m in Sources */ = {isa = PBXBuildFile; fileRef = F7ACE4311BAC0268006C0017 /* NCSettings.m */; };
 		F77B0E981D118A16002130FE /* CCManageAccount.m in Sources */ = {isa = PBXBuildFile; fileRef = F7ACE42D1BAC0268006C0017 /* CCManageAccount.m */; };
@@ -586,8 +585,6 @@
 		F79A65C52191D95E00FF6DCC /* NCSelect.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCSelect.swift; sourceTree = "<group>"; };
 		F7A321AB1E9E6AD50069AD1B /* CCAdvanced.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCAdvanced.h; sourceTree = "<group>"; };
 		F7A321AC1E9E6AD50069AD1B /* CCAdvanced.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCAdvanced.m; sourceTree = "<group>"; };
-		F7A54C341C6267B500E2C8BF /* CCExifGeo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCExifGeo.h; sourceTree = "<group>"; };
-		F7A54C351C6267B500E2C8BF /* CCExifGeo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCExifGeo.m; sourceTree = "<group>"; };
 		F7A582D71A24DAB500E903D7 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = AppDelegate.h; sourceTree = "<group>"; };
 		F7A80BC8252624C100C7CD01 /* NCFileViewInFolder.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = NCFileViewInFolder.storyboard; sourceTree = "<group>"; };
 		F7A80BC9252624C100C7CD01 /* NCFileViewInFolder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCFileViewInFolder.swift; sourceTree = "<group>"; };
@@ -1233,8 +1230,6 @@
 		F7BFFA991A24D7BB0044ED85 /* Utility */ = {
 			isa = PBXGroup;
 			children = (
-				F7A54C341C6267B500E2C8BF /* CCExifGeo.h */,
-				F7A54C351C6267B500E2C8BF /* CCExifGeo.m */,
 				F76C3B831C6388BC00DC4301 /* CCGraphics.h */,
 				F76C3B841C6388BC00DC4301 /* CCGraphics.m */,
 				F7514EDA1C7B1336008F3338 /* CCHud.h */,
@@ -2027,7 +2022,6 @@
 				F785EE9D246196DF00B3F945 /* NCNetworkingE2EE.swift in Sources */,
 				F77B0E301D118A16002130FE /* CCHud.m in Sources */,
 				F76673ED22C901F6007ED366 /* FileProviderDomain.swift in Sources */,
-				F77B0E311D118A16002130FE /* CCExifGeo.m in Sources */,
 				F7A321AD1E9E6AD50069AD1B /* CCAdvanced.m in Sources */,
 				F77B0E4F1D118A16002130FE /* CCManageAutoUpload.m in Sources */,
 				F7FCFFE01D707B83000E6E29 /* CCPeekPop.m in Sources */,

+ 0 - 1
iOSClient/Nextcloud-Bridging-Header.h

@@ -9,4 +9,3 @@
 #import "NCEndToEndEncryption.h"
 #import "NYMnemonic.h"
 #import "CCPeekPop.h"
-#import "CCExifGeo.h"

+ 0 - 38
iOSClient/Utility/CCExifGeo.h

@@ -1,38 +0,0 @@
-//
-//  CCExifGeo.h
-//  Nextcloud
-//
-//  Created by Marino Faggiana on 03/02/16.
-//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
-//
-//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
-//
-//  This program is free software: you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation, either version 3 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#import <Foundation/Foundation.h>
-#import <CoreLocation/CoreLocation.h>
-#import <ImageIO/ImageIO.h>
-#import <UIKit/UIKit.h>
-
-@class tableMetadata;
-
-@interface CCExifGeo : NSObject
-
-+ (CCExifGeo *)sharedInstance;
-
-- (void)setExif:(tableMetadata *)metadata;
-//- (void)setGeocoder:(NSString *)ocId exifDate:(NSDate *)exifDate latitude:(NSString*)latitude longitude:(NSString*)longitude;
-
-@end

+ 0 - 174
iOSClient/Utility/CCExifGeo.m

@@ -1,174 +0,0 @@
-//
-//  CCExifGeo.m
-//  Nextcloud
-//
-//  Created by Marino Faggiana on 03/02/16.
-//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
-//
-//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
-//
-//  This program is free software: you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation, either version 3 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-//
-
-#import "CCExifGeo.h"
-#import "CCUtility.h"
-#import "NCBridgeSwift.h"
-
-@implementation CCExifGeo
-
-+ (CCExifGeo *)sharedInstance {
-    
-    static CCExifGeo *sharedInstance;
-    
-    @synchronized(self)
-    {
-        if (!sharedInstance) {
-            
-            sharedInstance = [CCExifGeo new];
-        }
-        return sharedInstance;
-    }
-}
-
-- (void)setExif:(tableMetadata *)metadata
-{
-    NSString *dateTime;
-    NSString *latitudeRef;
-    NSString *longitudeRef;
-    NSString *stringLatitude = @"0";
-    NSString *stringLongitude = @"0";
-    
-    double latitude = 0;
-    double longitude = 0;
-    
-    NSDate *date = [NSDate new];
-    
-    if (![CCUtility fileProviderStorageExists:metadata.ocId fileNameView:metadata.fileNameView])
-        return;
-
-    NSURL *url = [NSURL fileURLWithPath:[CCUtility getDirectoryProviderStorageOcId:metadata.ocId fileNameView:metadata.fileNameView]];
-
-    CGImageSourceRef originalSource =  CGImageSourceCreateWithURL((CFURLRef) url, NULL);
-    if (!originalSource)
-        return;
-    
-    CFDictionaryRef imageProperties = CGImageSourceCopyPropertiesAtIndex(originalSource, 0, NULL);
-    if (!imageProperties)
-        return;
-    
-    CFDictionaryRef tiff = CFDictionaryGetValue(imageProperties, kCGImagePropertyTIFFDictionary);
-    CFDictionaryRef gps = CFDictionaryGetValue(imageProperties, kCGImagePropertyGPSDictionary);
-
-    if (tiff) {
-        
-        dateTime = (NSString *)CFDictionaryGetValue(tiff, kCGImagePropertyTIFFDateTime);
-        
-        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
-        [dateFormatter setDateFormat:@"yyyy:MM:dd HH:mm:ss"];
-    
-        date = [dateFormatter dateFromString:dateTime];
-        if (!date) date = metadata.date;
-    }
-    
-    if (gps) {
-        
-        latitude = [(NSString *)CFDictionaryGetValue(gps, kCGImagePropertyGPSLatitude) doubleValue];
-        longitude = [(NSString *)CFDictionaryGetValue(gps, kCGImagePropertyGPSLongitude) doubleValue];
-        
-        latitudeRef = (NSString *)CFDictionaryGetValue(gps, kCGImagePropertyGPSLatitudeRef);
-        longitudeRef = (NSString *)CFDictionaryGetValue(gps, kCGImagePropertyGPSLongitudeRef);
-        
-        // conversion 4 decimal +N -S
-        // The latitude in degrees. Positive values indicate latitudes north of the equator. Negative values indicate latitudes south of the equator.
-        if ([latitudeRef isEqualToString:@"N"])
-            stringLatitude = [NSString stringWithFormat:@"+%.4f", latitude];
-        else
-            stringLatitude = [NSString stringWithFormat:@"-%.4f", latitude];
-        
-        // conversion 4 decimal +E -W
-        // The longitude in degrees. Measurements are relative to the zero meridian, with positive values extending east of the meridian
-        // and negative values extending west of the meridian.
-        if ([longitudeRef isEqualToString:@"E"])
-            stringLongitude = [NSString stringWithFormat:@"+%.4f", longitude];
-        else
-            stringLongitude = [NSString stringWithFormat:@"-%.4f", longitude];
-        
-        if (latitude == 0 || longitude == 0){
-            
-            stringLatitude = @"0";
-            stringLongitude = @"0";
-        }
-    }
-
-    // Wite data EXIF in DB
-    if (tiff || gps) {
-        [[NCManageDatabase sharedInstance] setLocalFileWithOcId:metadata.ocId exifDate:date exifLatitude:stringLatitude exifLongitude:stringLongitude];
-        if ([stringLatitude doubleValue] != 0 || [stringLongitude doubleValue] != 0) {
-            [self setGeocoder:metadata.ocId exifDate:date latitude:stringLatitude longitude:stringLongitude];
-        }
-    }
-       
-    CFRelease(originalSource);
-    CFRelease(imageProperties);
-}
-
-- (void)setGeocoder:(NSString *)ocId exifDate:(NSDate *)exifDate latitude:(NSString*)latitude longitude:(NSString*)longitude
-{
-    // If exists already geocoder data in TableGPS exit
-    if ([[NCManageDatabase sharedInstance] getLocationFromGeoLatitude:latitude longitude:longitude])
-        return;
-    
-    CLGeocoder *geocoder = [[CLGeocoder alloc] init];
-    CLLocation *location = [[CLLocation alloc] initWithLatitude:[latitude doubleValue] longitude:[longitude doubleValue]];
-    
-    [geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {
-        
-        //DDLogInfo(@"[LOG] Found placemarks: %@, error: %@", placemarks, error);
-        
-        if (error == nil && [placemarks count] > 0) {
-            
-            CLPlacemark *placemark = [placemarks lastObject];
-            
-            NSString *thoroughfare = @"";
-            NSString *postalCode = @"";
-            NSString *locality = @"";
-            NSString *administrativeArea = @"";
-            NSString *country = @"";
-            
-            if (placemark.thoroughfare) thoroughfare = placemark.thoroughfare;
-            if (placemark.postalCode) postalCode = placemark.postalCode;
-            if (placemark.locality) locality = placemark.locality;
-            if (placemark.administrativeArea) administrativeArea = placemark.administrativeArea;
-            if (placemark.country) country = placemark.country;
-            
-            NSString *location = [NSString stringWithFormat:@"%@ %@ %@ %@ %@", thoroughfare, postalCode, locality, administrativeArea, country];
-            location = [location stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
-            
-            // GPS
-            if ([location length] > 0) {
-                
-                [[NCManageDatabase sharedInstance] addGeocoderLocation:location placemarkAdministrativeArea:placemark.administrativeArea placemarkCountry:placemark.country placemarkLocality:placemark.locality placemarkPostalCode:placemark.postalCode placemarkThoroughfare:placemark.thoroughfare latitude:latitude longitude:longitude];
-                
-                NSDictionary *dictionary = [[NSDictionary alloc] initWithObjectsAndKeys:exifDate, ocId, nil];
-                
-                // Notify for CCDetail
-                [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"insertGeocoderLocation" object:nil userInfo:dictionary];
-            }
-        } else {
-            //NSLog(@"[LOG] setGeocoderocId : %@", error.debugDescription);
-        }
-    }];
-}
-
-@end

+ 4 - 0
iOSClient/Utility/CCUtility.h

@@ -265,6 +265,10 @@
 + (BOOL)isPermissionToRead:(NSInteger) permissionValue;
 + (BOOL)isPermissionToReadCreateUpdate:(NSInteger) permissionValue;
 
+// ===== EXIF =====
+
++ (void)setExif:(tableMetadata *)metadata;
+
 // ===== Third parts =====
 
 + (NSString *)stringValueForKey:(id)key conDictionary:(NSDictionary *)dictionary;

+ 129 - 0
iOSClient/Utility/CCUtility.m

@@ -25,6 +25,7 @@
 #import "CCGraphics.h"
 #import "NCBridgeSwift.h"
 #import <OpenSSL/OpenSSL.h>
+#import <CoreLocation/CoreLocation.h>
 
 #define INTRO_MessageType       @"MessageType_"
 
@@ -1679,6 +1680,134 @@
     
 }
 
+#pragma --------------------------------------------------------------------------------------------
+#pragma mark ===== EXIF =====
+#pragma --------------------------------------------------------------------------------------------
+
++ (void)setExif:(tableMetadata *)metadata
+{
+    NSString *dateTime;
+    NSString *latitudeRef;
+    NSString *longitudeRef;
+    NSString *stringLatitude = @"0";
+    NSString *stringLongitude = @"0";
+    
+    double latitude = 0;
+    double longitude = 0;
+    
+    NSDate *date = [NSDate new];
+    
+    // test
+    if (![CCUtility fileProviderStorageExists:metadata.ocId fileNameView:metadata.fileNameView])
+        return;
+    
+    NSURL *url = [NSURL fileURLWithPath:[CCUtility getDirectoryProviderStorageOcId:metadata.ocId fileNameView:metadata.fileNameView]];
+
+    CGImageSourceRef originalSource =  CGImageSourceCreateWithURL((CFURLRef) url, NULL);
+    if (!originalSource)
+        return;
+    
+    CFDictionaryRef imageProperties = CGImageSourceCopyPropertiesAtIndex(originalSource, 0, NULL);
+    if (!imageProperties)
+        return;
+    
+    CFDictionaryRef tiff = CFDictionaryGetValue(imageProperties, kCGImagePropertyTIFFDictionary);
+    CFDictionaryRef gps = CFDictionaryGetValue(imageProperties, kCGImagePropertyGPSDictionary);
+
+    if (tiff) {
+        
+        dateTime = (NSString *)CFDictionaryGetValue(tiff, kCGImagePropertyTIFFDateTime);
+        
+        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
+        [dateFormatter setDateFormat:@"yyyy:MM:dd HH:mm:ss"];
+    
+        date = [dateFormatter dateFromString:dateTime];
+        if (!date) date = metadata.date;
+    }
+    
+    if (gps) {
+        
+        latitude = [(NSString *)CFDictionaryGetValue(gps, kCGImagePropertyGPSLatitude) doubleValue];
+        longitude = [(NSString *)CFDictionaryGetValue(gps, kCGImagePropertyGPSLongitude) doubleValue];
+        
+        latitudeRef = (NSString *)CFDictionaryGetValue(gps, kCGImagePropertyGPSLatitudeRef);
+        longitudeRef = (NSString *)CFDictionaryGetValue(gps, kCGImagePropertyGPSLongitudeRef);
+        
+        // conversion 4 decimal +N -S
+        // The latitude in degrees. Positive values indicate latitudes north of the equator. Negative values indicate latitudes south of the equator.
+        if ([latitudeRef isEqualToString:@"N"])
+            stringLatitude = [NSString stringWithFormat:@"+%.4f", latitude];
+        else
+            stringLatitude = [NSString stringWithFormat:@"-%.4f", latitude];
+        
+        // conversion 4 decimal +E -W
+        // The longitude in degrees. Measurements are relative to the zero meridian, with positive values extending east of the meridian
+        // and negative values extending west of the meridian.
+        if ([longitudeRef isEqualToString:@"E"])
+            stringLongitude = [NSString stringWithFormat:@"+%.4f", longitude];
+        else
+            stringLongitude = [NSString stringWithFormat:@"-%.4f", longitude];
+        
+        if (latitude == 0 || longitude == 0){
+            
+            stringLatitude = @"0";
+            stringLongitude = @"0";
+        }
+    }
+
+    // Wite data EXIF in DB
+    if (tiff || gps) {
+        [[NCManageDatabase sharedInstance] setLocalFileWithOcId:metadata.ocId exifDate:date exifLatitude:stringLatitude exifLongitude:stringLongitude];
+        if ([stringLatitude doubleValue] != 0 || [stringLongitude doubleValue] != 0) {
+            
+            // If exists already geocoder data in TableGPS exit
+            if ([[NCManageDatabase sharedInstance] getLocationFromGeoLatitude:stringLatitude longitude:stringLongitude]) {
+                return;
+            }
+            
+            CLGeocoder *geocoder = [[CLGeocoder alloc] init];
+            CLLocation *location = [[CLLocation alloc] initWithLatitude:latitude longitude:longitude];
+            
+            [geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {
+                        
+                if (error == nil && [placemarks count] > 0) {
+                    
+                    CLPlacemark *placemark = [placemarks lastObject];
+                    
+                    NSString *thoroughfare = @"";
+                    NSString *postalCode = @"";
+                    NSString *locality = @"";
+                    NSString *administrativeArea = @"";
+                    NSString *country = @"";
+                    
+                    if (placemark.thoroughfare) thoroughfare = placemark.thoroughfare;
+                    if (placemark.postalCode) postalCode = placemark.postalCode;
+                    if (placemark.locality) locality = placemark.locality;
+                    if (placemark.administrativeArea) administrativeArea = placemark.administrativeArea;
+                    if (placemark.country) country = placemark.country;
+                    
+                    NSString *location = [NSString stringWithFormat:@"%@ %@ %@ %@ %@", thoroughfare, postalCode, locality, administrativeArea, country];
+                    location = [location stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
+                    
+                    // GPS
+                    if ([location length] > 0) {
+                        
+                        [[NCManageDatabase sharedInstance] addGeocoderLocation:location placemarkAdministrativeArea:placemark.administrativeArea placemarkCountry:placemark.country placemarkLocality:placemark.locality placemarkPostalCode:placemark.postalCode placemarkThoroughfare:placemark.thoroughfare latitude:stringLatitude longitude:stringLongitude];
+                    }
+                }
+            }];
+        }
+    }
+       
+    CFRelease(originalSource);
+    CFRelease(imageProperties);
+}
+
+- (void)setGeocoder:(NSString *)ocId exifDate:(NSDate *)exifDate latitude:(NSString*)latitude longitude:(NSString*)longitude
+{
+    
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Third parts =====
 #pragma --------------------------------------------------------------------------------------------