@josuelmm/capacitor-background-geolocation 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/JosuelmmCapacitorBackgroundGeolocation.podspec +34 -0
- package/LICENSE +17 -0
- package/NOTICE.md +32 -0
- package/Package.swift +45 -0
- package/README.md +402 -0
- package/android/build.gradle +79 -0
- package/android/proguard-rules.pro +1 -0
- package/android/src/main/AndroidManifest.xml +83 -0
- package/android/src/main/java/com/evgenii/jsevaluator/HandlerWrapper.java +18 -0
- package/android/src/main/java/com/evgenii/jsevaluator/JavaScriptInterface.java +22 -0
- package/android/src/main/java/com/evgenii/jsevaluator/JsEvaluator.java +133 -0
- package/android/src/main/java/com/evgenii/jsevaluator/JsFunctionCallFormatter.java +37 -0
- package/android/src/main/java/com/evgenii/jsevaluator/WebViewWrapper.java +71 -0
- package/android/src/main/java/com/evgenii/jsevaluator/interfaces/CallJavaResultInterface.java +8 -0
- package/android/src/main/java/com/evgenii/jsevaluator/interfaces/HandlerWrapperInterface.java +5 -0
- package/android/src/main/java/com/evgenii/jsevaluator/interfaces/JsCallback.java +10 -0
- package/android/src/main/java/com/evgenii/jsevaluator/interfaces/JsEvaluatorInterface.java +18 -0
- package/android/src/main/java/com/evgenii/jsevaluator/interfaces/WebViewWrapperInterface.java +14 -0
- package/android/src/main/java/com/josuelmm/capacitor/backgroundgeolocation/BackgroundGeolocationPlugin.java +898 -0
- package/android/src/main/java/com/josuelmm/capacitor/backgroundgeolocation/ConfigMapper.java +303 -0
- package/android/src/main/java/com/josuelmm/capacitor/backgroundgeolocation/HeadlessTaskRegistry.java +34 -0
- package/android/src/main/java/com/josuelmm/capacitor/backgroundgeolocation/JsEvaluatorTaskRunner.java +63 -0
- package/android/src/main/java/com/marianhello/bgloc/BackgroundGeolocationFacade.java +699 -0
- package/android/src/main/java/com/marianhello/bgloc/BootCompletedReceiver.java +103 -0
- package/android/src/main/java/com/marianhello/bgloc/Config.java +1155 -0
- package/android/src/main/java/com/marianhello/bgloc/ConnectivityListener.java +5 -0
- package/android/src/main/java/com/marianhello/bgloc/HttpPostService.java +362 -0
- package/android/src/main/java/com/marianhello/bgloc/LocationManager.java +138 -0
- package/android/src/main/java/com/marianhello/bgloc/PluginDelegate.java +45 -0
- package/android/src/main/java/com/marianhello/bgloc/PluginException.java +38 -0
- package/android/src/main/java/com/marianhello/bgloc/PostLocationTask.java +238 -0
- package/android/src/main/java/com/marianhello/bgloc/ResourceResolver.java +55 -0
- package/android/src/main/java/com/marianhello/bgloc/data/AbstractLocationTemplate.java +69 -0
- package/android/src/main/java/com/marianhello/bgloc/data/ArrayListLocationTemplate.java +88 -0
- package/android/src/main/java/com/marianhello/bgloc/data/BackgroundActivity.java +108 -0
- package/android/src/main/java/com/marianhello/bgloc/data/BackgroundLocation.java +1088 -0
- package/android/src/main/java/com/marianhello/bgloc/data/ConfigJsonMapper.java +211 -0
- package/android/src/main/java/com/marianhello/bgloc/data/ConfigurationDAO.java +13 -0
- package/android/src/main/java/com/marianhello/bgloc/data/DAOFactory.java +17 -0
- package/android/src/main/java/com/marianhello/bgloc/data/HashMapLocationTemplate.java +82 -0
- package/android/src/main/java/com/marianhello/bgloc/data/LocationDAO.java +27 -0
- package/android/src/main/java/com/marianhello/bgloc/data/LocationTemplate.java +12 -0
- package/android/src/main/java/com/marianhello/bgloc/data/LocationTemplateFactory.java +71 -0
- package/android/src/main/java/com/marianhello/bgloc/data/LocationTransform.java +19 -0
- package/android/src/main/java/com/marianhello/bgloc/data/SessionLocationDAO.java +18 -0
- package/android/src/main/java/com/marianhello/bgloc/data/provider/ContentProviderLocationDAO.java +406 -0
- package/android/src/main/java/com/marianhello/bgloc/data/provider/LocationContentProvider.java +321 -0
- package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteConfigurationContract.java +94 -0
- package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteConfigurationDAO.java +227 -0
- package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteLocationContract.java +122 -0
- package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteLocationDAO.java +550 -0
- package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteOpenHelper.java +189 -0
- package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteSessionContract.java +74 -0
- package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteSessionLocationDAO.java +169 -0
- package/android/src/main/java/com/marianhello/bgloc/driving/DrivingEventsDetector.java +265 -0
- package/android/src/main/java/com/marianhello/bgloc/headless/AbstractTaskRunner.java +15 -0
- package/android/src/main/java/com/marianhello/bgloc/headless/ActivityTask.java +48 -0
- package/android/src/main/java/com/marianhello/bgloc/headless/JsCallback.java +10 -0
- package/android/src/main/java/com/marianhello/bgloc/headless/LocationTask.java +60 -0
- package/android/src/main/java/com/marianhello/bgloc/headless/StationaryTask.java +25 -0
- package/android/src/main/java/com/marianhello/bgloc/headless/Task.java +8 -0
- package/android/src/main/java/com/marianhello/bgloc/headless/TaskRunner.java +5 -0
- package/android/src/main/java/com/marianhello/bgloc/headless/TaskRunnerFactory.java +8 -0
- package/android/src/main/java/com/marianhello/bgloc/http/UrlTemplateResolver.java +115 -0
- package/android/src/main/java/com/marianhello/bgloc/oem/BatteryOemHelper.java +214 -0
- package/android/src/main/java/com/marianhello/bgloc/provider/AbstractLocationProvider.java +218 -0
- package/android/src/main/java/com/marianhello/bgloc/provider/ActivityRecognitionLocationProvider.java +385 -0
- package/android/src/main/java/com/marianhello/bgloc/provider/DistanceFilterLocationProvider.java +685 -0
- package/android/src/main/java/com/marianhello/bgloc/provider/LocationProvider.java +32 -0
- package/android/src/main/java/com/marianhello/bgloc/provider/LocationProviderFactory.java +47 -0
- package/android/src/main/java/com/marianhello/bgloc/provider/ProviderDelegate.java +12 -0
- package/android/src/main/java/com/marianhello/bgloc/provider/RawLocationProvider.java +175 -0
- package/android/src/main/java/com/marianhello/bgloc/sensor/SensorFusionDetector.java +199 -0
- package/android/src/main/java/com/marianhello/bgloc/service/LocationService.java +16 -0
- package/android/src/main/java/com/marianhello/bgloc/service/LocationServiceImpl.java +1531 -0
- package/android/src/main/java/com/marianhello/bgloc/service/LocationServiceInfo.java +6 -0
- package/android/src/main/java/com/marianhello/bgloc/service/LocationServiceInfoImpl.java +41 -0
- package/android/src/main/java/com/marianhello/bgloc/service/LocationServiceIntentBuilder.java +203 -0
- package/android/src/main/java/com/marianhello/bgloc/service/LocationServiceProxy.java +156 -0
- package/android/src/main/java/com/marianhello/bgloc/sync/AccountHelper.java +39 -0
- package/android/src/main/java/com/marianhello/bgloc/sync/Authenticator.java +68 -0
- package/android/src/main/java/com/marianhello/bgloc/sync/AuthenticatorService.java +28 -0
- package/android/src/main/java/com/marianhello/bgloc/sync/BatchManager.java +311 -0
- package/android/src/main/java/com/marianhello/bgloc/sync/NotificationHelper.java +148 -0
- package/android/src/main/java/com/marianhello/bgloc/sync/SyncAdapter.java +301 -0
- package/android/src/main/java/com/marianhello/bgloc/sync/SyncService.java +68 -0
- package/android/src/main/java/com/marianhello/logging/DBLogReader.java +208 -0
- package/android/src/main/java/com/marianhello/logging/LogEntry.java +99 -0
- package/android/src/main/java/com/marianhello/logging/LoggerManager.java +70 -0
- package/android/src/main/java/com/marianhello/logging/UncaughtExceptionLogger.java +36 -0
- package/android/src/main/java/com/marianhello/utils/CloneHelper.java +22 -0
- package/android/src/main/java/com/marianhello/utils/Convert.java +56 -0
- package/android/src/main/java/com/marianhello/utils/TextUtils.java +72 -0
- package/android/src/main/java/com/marianhello/utils/ToneGenerator.java +68 -0
- package/android/src/main/java/org/apache/commons/io/Charsets.java +153 -0
- package/android/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java +344 -0
- package/android/src/main/java/org/chromium/content/browser/ThreadUtils.java +134 -0
- package/android/src/main/java/ru/andremoniy/sqlbuilder/SqlExpression.java +398 -0
- package/android/src/main/java/ru/andremoniy/sqlbuilder/SqlSelectStatement.java +671 -0
- package/android/src/main/java/ru/andremoniy/sqlbuilder/SqlStatement.java +29 -0
- package/android/src/main/java/ru/andremoniy/utils/TextUtils.java +61 -0
- package/android/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/android/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/android/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/android/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/android/src/main/res/values/strings.xml +15 -0
- package/android/src/main/res/xml/authenticator.xml +7 -0
- package/android/src/main/res/xml/syncadapter.xml +9 -0
- package/dist/esm/definitions.d.ts +1052 -0
- package/dist/esm/definitions.js +142 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/index.js +23 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +92 -0
- package/dist/esm/web.js +242 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +415 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +418 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/BackgroundGeolocationPlugin/BackgroundGeolocationPlugin-Bridging-Header.h +18 -0
- package/ios/Sources/BackgroundGeolocationPlugin/BackgroundGeolocationPlugin.m +52 -0
- package/ios/Sources/BackgroundGeolocationPlugin/BackgroundGeolocationPlugin.swift +750 -0
- package/ios/Tests/BackgroundGeolocationPluginTests/BackgroundGeolocationPluginTests.swift +12 -0
- package/ios/common/BackgroundGeolocation/CocoaLumberjack.h +1945 -0
- package/ios/common/BackgroundGeolocation/CocoaLumberjack.m +5255 -0
- package/ios/common/BackgroundGeolocation/FMDB.h +2357 -0
- package/ios/common/BackgroundGeolocation/FMDB.m +2672 -0
- package/ios/common/BackgroundGeolocation/FMDBLogger.h +42 -0
- package/ios/common/BackgroundGeolocation/FMDBLogger.m +264 -0
- package/ios/common/BackgroundGeolocation/INTULocationManager/INTUHeadingRequest.h +41 -0
- package/ios/common/BackgroundGeolocation/INTULocationManager/INTUHeadingRequest.m +68 -0
- package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationManager+Internal.h +33 -0
- package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationManager.h +178 -0
- package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationManager.m +1025 -0
- package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationRequest.h +103 -0
- package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationRequest.m +238 -0
- package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationRequestDefines.h +163 -0
- package/ios/common/BackgroundGeolocation/INTULocationManager/INTURequestIDGenerator.h +39 -0
- package/ios/common/BackgroundGeolocation/INTULocationManager/INTURequestIDGenerator.m +37 -0
- package/ios/common/BackgroundGeolocation/MAURAbstractLocationProvider.h +51 -0
- package/ios/common/BackgroundGeolocation/MAURAbstractLocationProvider.m +53 -0
- package/ios/common/BackgroundGeolocation/MAURActivity.h +23 -0
- package/ios/common/BackgroundGeolocation/MAURActivity.m +52 -0
- package/ios/common/BackgroundGeolocation/MAURActivityLocationProvider.h +18 -0
- package/ios/common/BackgroundGeolocation/MAURActivityLocationProvider.m +340 -0
- package/ios/common/BackgroundGeolocation/MAURBackgroundGeolocationFacade.h +88 -0
- package/ios/common/BackgroundGeolocation/MAURBackgroundGeolocationFacade.m +1193 -0
- package/ios/common/BackgroundGeolocation/MAURBackgroundSync.h +46 -0
- package/ios/common/BackgroundGeolocation/MAURBackgroundSync.m +283 -0
- package/ios/common/BackgroundGeolocation/MAURBackgroundTaskManager.h +25 -0
- package/ios/common/BackgroundGeolocation/MAURBackgroundTaskManager.m +105 -0
- package/ios/common/BackgroundGeolocation/MAURConfig.h +99 -0
- package/ios/common/BackgroundGeolocation/MAURConfig.m +636 -0
- package/ios/common/BackgroundGeolocation/MAURConfigurationContract.h +53 -0
- package/ios/common/BackgroundGeolocation/MAURConfigurationContract.m +54 -0
- package/ios/common/BackgroundGeolocation/MAURDistanceFilterLocationProvider.h +20 -0
- package/ios/common/BackgroundGeolocation/MAURDistanceFilterLocationProvider.m +550 -0
- package/ios/common/BackgroundGeolocation/MAURGeolocationOpenHelper.h +17 -0
- package/ios/common/BackgroundGeolocation/MAURGeolocationOpenHelper.m +124 -0
- package/ios/common/BackgroundGeolocation/MAURLocation.h +73 -0
- package/ios/common/BackgroundGeolocation/MAURLocation.m +392 -0
- package/ios/common/BackgroundGeolocation/MAURLocationContract.h +38 -0
- package/ios/common/BackgroundGeolocation/MAURLocationContract.m +39 -0
- package/ios/common/BackgroundGeolocation/MAURLocationManager.h +53 -0
- package/ios/common/BackgroundGeolocation/MAURLocationManager.m +305 -0
- package/ios/common/BackgroundGeolocation/MAURLogReader.h +26 -0
- package/ios/common/BackgroundGeolocation/MAURLogReader.m +122 -0
- package/ios/common/BackgroundGeolocation/MAURLogging.h +19 -0
- package/ios/common/BackgroundGeolocation/MAURPostLocationTask.h +53 -0
- package/ios/common/BackgroundGeolocation/MAURPostLocationTask.m +367 -0
- package/ios/common/BackgroundGeolocation/MAURProviderDelegate.h +52 -0
- package/ios/common/BackgroundGeolocation/MAURRawLocationProvider.h +18 -0
- package/ios/common/BackgroundGeolocation/MAURRawLocationProvider.m +138 -0
- package/ios/common/BackgroundGeolocation/MAURSQLiteConfigurationDAO.h +26 -0
- package/ios/common/BackgroundGeolocation/MAURSQLiteConfigurationDAO.m +335 -0
- package/ios/common/BackgroundGeolocation/MAURSQLiteHelper.h +57 -0
- package/ios/common/BackgroundGeolocation/MAURSQLiteHelper.m +93 -0
- package/ios/common/BackgroundGeolocation/MAURSQLiteLocationDAO.h +52 -0
- package/ios/common/BackgroundGeolocation/MAURSQLiteLocationDAO.m +520 -0
- package/ios/common/BackgroundGeolocation/MAURSQLiteOpenHelper.h +32 -0
- package/ios/common/BackgroundGeolocation/MAURSQLiteOpenHelper.m +276 -0
- package/ios/common/BackgroundGeolocation/MAURSensorFusionDetector.h +41 -0
- package/ios/common/BackgroundGeolocation/MAURSensorFusionDetector.m +137 -0
- package/ios/common/BackgroundGeolocation/MAURSessionLocationContract.h +29 -0
- package/ios/common/BackgroundGeolocation/MAURSessionLocationContract.m +31 -0
- package/ios/common/BackgroundGeolocation/MAURSessionLocationDAO.h +25 -0
- package/ios/common/BackgroundGeolocation/MAURSessionLocationDAO.m +153 -0
- package/ios/common/BackgroundGeolocation/MAURUncaughtExceptionLogger.h +20 -0
- package/ios/common/BackgroundGeolocation/MAURUncaughtExceptionLogger.m +62 -0
- package/ios/common/BackgroundGeolocation/MAURUrlTemplateResolver.h +31 -0
- package/ios/common/BackgroundGeolocation/MAURUrlTemplateResolver.m +107 -0
- package/ios/common/BackgroundGeolocation/Reachability.h +102 -0
- package/ios/common/BackgroundGeolocation/Reachability.m +475 -0
- package/ios/common/BackgroundGeolocation/SQLQueryBuilder/README.md +170 -0
- package/ios/common/BackgroundGeolocation/SQLQueryBuilder/ext/NSString+ZIMString.h +55 -0
- package/ios/common/BackgroundGeolocation/SQLQueryBuilder/ext/NSString+ZIMString.m +47 -0
- package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlDataManipulationCommand.h +27 -0
- package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlExpression.h +250 -0
- package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlExpression.m +259 -0
- package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlSelectStatement.h +360 -0
- package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlSelectStatement.m +427 -0
- package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlStatement.h +37 -0
- package/ios/common/BackgroundGeolocation/module.modulemap +16 -0
- package/package.json +82 -0
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (c) 2011, Tony Million.
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
16
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
17
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
18
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
19
|
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
20
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
21
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
22
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
23
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
24
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
25
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
#import "Reachability.h"
|
|
29
|
+
|
|
30
|
+
#import <sys/socket.h>
|
|
31
|
+
#import <netinet/in.h>
|
|
32
|
+
#import <netinet6/in6.h>
|
|
33
|
+
#import <arpa/inet.h>
|
|
34
|
+
#import <ifaddrs.h>
|
|
35
|
+
#import <netdb.h>
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
NSString *const kReachabilityChangedNotification = @"kReachabilityChangedNotification";
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@interface Reachability ()
|
|
42
|
+
|
|
43
|
+
@property (nonatomic, assign) SCNetworkReachabilityRef reachabilityRef;
|
|
44
|
+
@property (nonatomic, strong) dispatch_queue_t reachabilitySerialQueue;
|
|
45
|
+
@property (nonatomic, strong) id reachabilityObject;
|
|
46
|
+
|
|
47
|
+
-(void)reachabilityChanged:(SCNetworkReachabilityFlags)flags;
|
|
48
|
+
-(BOOL)isReachableWithFlags:(SCNetworkReachabilityFlags)flags;
|
|
49
|
+
|
|
50
|
+
@end
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
static NSString *reachabilityFlags(SCNetworkReachabilityFlags flags)
|
|
54
|
+
{
|
|
55
|
+
return [NSString stringWithFormat:@"%c%c %c%c%c%c%c%c%c",
|
|
56
|
+
#if TARGET_OS_IPHONE
|
|
57
|
+
(flags & kSCNetworkReachabilityFlagsIsWWAN) ? 'W' : '-',
|
|
58
|
+
#else
|
|
59
|
+
'X',
|
|
60
|
+
#endif
|
|
61
|
+
(flags & kSCNetworkReachabilityFlagsReachable) ? 'R' : '-',
|
|
62
|
+
(flags & kSCNetworkReachabilityFlagsConnectionRequired) ? 'c' : '-',
|
|
63
|
+
(flags & kSCNetworkReachabilityFlagsTransientConnection) ? 't' : '-',
|
|
64
|
+
(flags & kSCNetworkReachabilityFlagsInterventionRequired) ? 'i' : '-',
|
|
65
|
+
(flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) ? 'C' : '-',
|
|
66
|
+
(flags & kSCNetworkReachabilityFlagsConnectionOnDemand) ? 'D' : '-',
|
|
67
|
+
(flags & kSCNetworkReachabilityFlagsIsLocalAddress) ? 'l' : '-',
|
|
68
|
+
(flags & kSCNetworkReachabilityFlagsIsDirect) ? 'd' : '-'];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Start listening for reachability notifications on the current run loop
|
|
72
|
+
static void TMReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* info)
|
|
73
|
+
{
|
|
74
|
+
#pragma unused (target)
|
|
75
|
+
|
|
76
|
+
Reachability *reachability = ((__bridge Reachability*)info);
|
|
77
|
+
|
|
78
|
+
// We probably don't need an autoreleasepool here, as GCD docs state each queue has its own autorelease pool,
|
|
79
|
+
// but what the heck eh?
|
|
80
|
+
@autoreleasepool
|
|
81
|
+
{
|
|
82
|
+
[reachability reachabilityChanged:flags];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@implementation Reachability
|
|
88
|
+
|
|
89
|
+
#pragma mark - Class Constructor Methods
|
|
90
|
+
|
|
91
|
+
+(instancetype)reachabilityWithHostName:(NSString*)hostname
|
|
92
|
+
{
|
|
93
|
+
return [Reachability reachabilityWithHostname:hostname];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
+(instancetype)reachabilityWithHostname:(NSString*)hostname
|
|
97
|
+
{
|
|
98
|
+
SCNetworkReachabilityRef ref = SCNetworkReachabilityCreateWithName(NULL, [hostname UTF8String]);
|
|
99
|
+
if (ref)
|
|
100
|
+
{
|
|
101
|
+
id reachability = [[self alloc] initWithReachabilityRef:ref];
|
|
102
|
+
|
|
103
|
+
return reachability;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return nil;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
+(instancetype)reachabilityWithAddress:(void *)hostAddress
|
|
110
|
+
{
|
|
111
|
+
SCNetworkReachabilityRef ref = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr*)hostAddress);
|
|
112
|
+
if (ref)
|
|
113
|
+
{
|
|
114
|
+
id reachability = [[self alloc] initWithReachabilityRef:ref];
|
|
115
|
+
|
|
116
|
+
return reachability;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return nil;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
+(instancetype)reachabilityForInternetConnection
|
|
123
|
+
{
|
|
124
|
+
struct sockaddr_in zeroAddress;
|
|
125
|
+
bzero(&zeroAddress, sizeof(zeroAddress));
|
|
126
|
+
zeroAddress.sin_len = sizeof(zeroAddress);
|
|
127
|
+
zeroAddress.sin_family = AF_INET;
|
|
128
|
+
|
|
129
|
+
return [self reachabilityWithAddress:&zeroAddress];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
+(instancetype)reachabilityForLocalWiFi
|
|
133
|
+
{
|
|
134
|
+
struct sockaddr_in localWifiAddress;
|
|
135
|
+
bzero(&localWifiAddress, sizeof(localWifiAddress));
|
|
136
|
+
localWifiAddress.sin_len = sizeof(localWifiAddress);
|
|
137
|
+
localWifiAddress.sin_family = AF_INET;
|
|
138
|
+
// IN_LINKLOCALNETNUM is defined in <netinet/in.h> as 169.254.0.0
|
|
139
|
+
localWifiAddress.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM);
|
|
140
|
+
|
|
141
|
+
return [self reachabilityWithAddress:&localWifiAddress];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
// Initialization methods
|
|
146
|
+
|
|
147
|
+
-(instancetype)initWithReachabilityRef:(SCNetworkReachabilityRef)ref
|
|
148
|
+
{
|
|
149
|
+
self = [super init];
|
|
150
|
+
if (self != nil)
|
|
151
|
+
{
|
|
152
|
+
self.reachableOnWWAN = YES;
|
|
153
|
+
self.reachabilityRef = ref;
|
|
154
|
+
|
|
155
|
+
// We need to create a serial queue.
|
|
156
|
+
// We allocate this once for the lifetime of the notifier.
|
|
157
|
+
|
|
158
|
+
self.reachabilitySerialQueue = dispatch_queue_create("com.tonymillion.reachability", NULL);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return self;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
-(void)dealloc
|
|
165
|
+
{
|
|
166
|
+
[self stopNotifier];
|
|
167
|
+
|
|
168
|
+
if(self.reachabilityRef)
|
|
169
|
+
{
|
|
170
|
+
CFRelease(self.reachabilityRef);
|
|
171
|
+
self.reachabilityRef = nil;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
self.reachableBlock = nil;
|
|
175
|
+
self.unreachableBlock = nil;
|
|
176
|
+
self.reachabilityBlock = nil;
|
|
177
|
+
self.reachabilitySerialQueue = nil;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
#pragma mark - Notifier Methods
|
|
181
|
+
|
|
182
|
+
// Notifier
|
|
183
|
+
// NOTE: This uses GCD to trigger the blocks - they *WILL NOT* be called on THE MAIN THREAD
|
|
184
|
+
// - In other words DO NOT DO ANY UI UPDATES IN THE BLOCKS.
|
|
185
|
+
// INSTEAD USE dispatch_async(dispatch_get_main_queue(), ^{UISTUFF}) (or dispatch_sync if you want)
|
|
186
|
+
|
|
187
|
+
-(BOOL)startNotifier
|
|
188
|
+
{
|
|
189
|
+
// allow start notifier to be called multiple times
|
|
190
|
+
if(self.reachabilityObject && (self.reachabilityObject == self))
|
|
191
|
+
{
|
|
192
|
+
return YES;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
SCNetworkReachabilityContext context = { 0, NULL, NULL, NULL, NULL };
|
|
197
|
+
context.info = (__bridge void *)self;
|
|
198
|
+
|
|
199
|
+
if(SCNetworkReachabilitySetCallback(self.reachabilityRef, TMReachabilityCallback, &context))
|
|
200
|
+
{
|
|
201
|
+
// Set it as our reachability queue, which will retain the queue
|
|
202
|
+
if(SCNetworkReachabilitySetDispatchQueue(self.reachabilityRef, self.reachabilitySerialQueue))
|
|
203
|
+
{
|
|
204
|
+
// this should do a retain on ourself, so as long as we're in notifier mode we shouldn't disappear out from under ourselves
|
|
205
|
+
// woah
|
|
206
|
+
self.reachabilityObject = self;
|
|
207
|
+
return YES;
|
|
208
|
+
}
|
|
209
|
+
else
|
|
210
|
+
{
|
|
211
|
+
#ifdef DEBUG
|
|
212
|
+
NSLog(@"SCNetworkReachabilitySetDispatchQueue() failed: %s", SCErrorString(SCError()));
|
|
213
|
+
#endif
|
|
214
|
+
|
|
215
|
+
// UH OH - FAILURE - stop any callbacks!
|
|
216
|
+
SCNetworkReachabilitySetCallback(self.reachabilityRef, NULL, NULL);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
else
|
|
220
|
+
{
|
|
221
|
+
#ifdef DEBUG
|
|
222
|
+
NSLog(@"SCNetworkReachabilitySetCallback() failed: %s", SCErrorString(SCError()));
|
|
223
|
+
#endif
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// if we get here we fail at the internet
|
|
227
|
+
self.reachabilityObject = nil;
|
|
228
|
+
return NO;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
-(void)stopNotifier
|
|
232
|
+
{
|
|
233
|
+
// First stop, any callbacks!
|
|
234
|
+
SCNetworkReachabilitySetCallback(self.reachabilityRef, NULL, NULL);
|
|
235
|
+
|
|
236
|
+
// Unregister target from the GCD serial dispatch queue.
|
|
237
|
+
SCNetworkReachabilitySetDispatchQueue(self.reachabilityRef, NULL);
|
|
238
|
+
|
|
239
|
+
self.reachabilityObject = nil;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
#pragma mark - reachability tests
|
|
243
|
+
|
|
244
|
+
// This is for the case where you flick the airplane mode;
|
|
245
|
+
// you end up getting something like this:
|
|
246
|
+
//Reachability: WR ct-----
|
|
247
|
+
//Reachability: -- -------
|
|
248
|
+
//Reachability: WR ct-----
|
|
249
|
+
//Reachability: -- -------
|
|
250
|
+
// We treat this as 4 UNREACHABLE triggers - really apple should do better than this
|
|
251
|
+
|
|
252
|
+
#define testcase (kSCNetworkReachabilityFlagsConnectionRequired | kSCNetworkReachabilityFlagsTransientConnection)
|
|
253
|
+
|
|
254
|
+
-(BOOL)isReachableWithFlags:(SCNetworkReachabilityFlags)flags
|
|
255
|
+
{
|
|
256
|
+
BOOL connectionUP = YES;
|
|
257
|
+
|
|
258
|
+
if(!(flags & kSCNetworkReachabilityFlagsReachable))
|
|
259
|
+
connectionUP = NO;
|
|
260
|
+
|
|
261
|
+
if( (flags & testcase) == testcase )
|
|
262
|
+
connectionUP = NO;
|
|
263
|
+
|
|
264
|
+
#if TARGET_OS_IPHONE
|
|
265
|
+
if(flags & kSCNetworkReachabilityFlagsIsWWAN)
|
|
266
|
+
{
|
|
267
|
+
// We're on 3G.
|
|
268
|
+
if(!self.reachableOnWWAN)
|
|
269
|
+
{
|
|
270
|
+
// We don't want to connect when on 3G.
|
|
271
|
+
connectionUP = NO;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
#endif
|
|
275
|
+
|
|
276
|
+
return connectionUP;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
-(BOOL)isReachable
|
|
280
|
+
{
|
|
281
|
+
SCNetworkReachabilityFlags flags;
|
|
282
|
+
|
|
283
|
+
if(!SCNetworkReachabilityGetFlags(self.reachabilityRef, &flags))
|
|
284
|
+
return NO;
|
|
285
|
+
|
|
286
|
+
return [self isReachableWithFlags:flags];
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
-(BOOL)isReachableViaWWAN
|
|
290
|
+
{
|
|
291
|
+
#if TARGET_OS_IPHONE
|
|
292
|
+
|
|
293
|
+
SCNetworkReachabilityFlags flags = 0;
|
|
294
|
+
|
|
295
|
+
if(SCNetworkReachabilityGetFlags(self.reachabilityRef, &flags))
|
|
296
|
+
{
|
|
297
|
+
// Check we're REACHABLE
|
|
298
|
+
if(flags & kSCNetworkReachabilityFlagsReachable)
|
|
299
|
+
{
|
|
300
|
+
// Now, check we're on WWAN
|
|
301
|
+
if(flags & kSCNetworkReachabilityFlagsIsWWAN)
|
|
302
|
+
{
|
|
303
|
+
return YES;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
#endif
|
|
308
|
+
|
|
309
|
+
return NO;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
-(BOOL)isReachableViaWiFi
|
|
313
|
+
{
|
|
314
|
+
SCNetworkReachabilityFlags flags = 0;
|
|
315
|
+
|
|
316
|
+
if(SCNetworkReachabilityGetFlags(self.reachabilityRef, &flags))
|
|
317
|
+
{
|
|
318
|
+
// Check we're reachable
|
|
319
|
+
if((flags & kSCNetworkReachabilityFlagsReachable))
|
|
320
|
+
{
|
|
321
|
+
#if TARGET_OS_IPHONE
|
|
322
|
+
// Check we're NOT on WWAN
|
|
323
|
+
if((flags & kSCNetworkReachabilityFlagsIsWWAN))
|
|
324
|
+
{
|
|
325
|
+
return NO;
|
|
326
|
+
}
|
|
327
|
+
#endif
|
|
328
|
+
return YES;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
return NO;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
// WWAN may be available, but not active until a connection has been established.
|
|
337
|
+
// WiFi may require a connection for VPN on Demand.
|
|
338
|
+
-(BOOL)isConnectionRequired
|
|
339
|
+
{
|
|
340
|
+
return [self connectionRequired];
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
-(BOOL)connectionRequired
|
|
344
|
+
{
|
|
345
|
+
SCNetworkReachabilityFlags flags;
|
|
346
|
+
|
|
347
|
+
if(SCNetworkReachabilityGetFlags(self.reachabilityRef, &flags))
|
|
348
|
+
{
|
|
349
|
+
return (flags & kSCNetworkReachabilityFlagsConnectionRequired);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
return NO;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// Dynamic, on demand connection?
|
|
356
|
+
-(BOOL)isConnectionOnDemand
|
|
357
|
+
{
|
|
358
|
+
SCNetworkReachabilityFlags flags;
|
|
359
|
+
|
|
360
|
+
if (SCNetworkReachabilityGetFlags(self.reachabilityRef, &flags))
|
|
361
|
+
{
|
|
362
|
+
return ((flags & kSCNetworkReachabilityFlagsConnectionRequired) &&
|
|
363
|
+
(flags & (kSCNetworkReachabilityFlagsConnectionOnTraffic | kSCNetworkReachabilityFlagsConnectionOnDemand)));
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
return NO;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// Is user intervention required?
|
|
370
|
+
-(BOOL)isInterventionRequired
|
|
371
|
+
{
|
|
372
|
+
SCNetworkReachabilityFlags flags;
|
|
373
|
+
|
|
374
|
+
if (SCNetworkReachabilityGetFlags(self.reachabilityRef, &flags))
|
|
375
|
+
{
|
|
376
|
+
return ((flags & kSCNetworkReachabilityFlagsConnectionRequired) &&
|
|
377
|
+
(flags & kSCNetworkReachabilityFlagsInterventionRequired));
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
return NO;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
#pragma mark - reachability status stuff
|
|
385
|
+
|
|
386
|
+
-(NetworkStatus)currentReachabilityStatus
|
|
387
|
+
{
|
|
388
|
+
if([self isReachable])
|
|
389
|
+
{
|
|
390
|
+
if([self isReachableViaWiFi])
|
|
391
|
+
return ReachableViaWiFi;
|
|
392
|
+
|
|
393
|
+
#if TARGET_OS_IPHONE
|
|
394
|
+
return ReachableViaWWAN;
|
|
395
|
+
#endif
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
return NotReachable;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
-(SCNetworkReachabilityFlags)reachabilityFlags
|
|
402
|
+
{
|
|
403
|
+
SCNetworkReachabilityFlags flags = 0;
|
|
404
|
+
|
|
405
|
+
if(SCNetworkReachabilityGetFlags(self.reachabilityRef, &flags))
|
|
406
|
+
{
|
|
407
|
+
return flags;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
return 0;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
-(NSString*)currentReachabilityString
|
|
414
|
+
{
|
|
415
|
+
NetworkStatus temp = [self currentReachabilityStatus];
|
|
416
|
+
|
|
417
|
+
if(temp == ReachableViaWWAN)
|
|
418
|
+
{
|
|
419
|
+
// Updated for the fact that we have CDMA phones now!
|
|
420
|
+
return NSLocalizedString(@"Cellular", @"");
|
|
421
|
+
}
|
|
422
|
+
if (temp == ReachableViaWiFi)
|
|
423
|
+
{
|
|
424
|
+
return NSLocalizedString(@"WiFi", @"");
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
return NSLocalizedString(@"No Connection", @"");
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
-(NSString*)currentReachabilityFlags
|
|
431
|
+
{
|
|
432
|
+
return reachabilityFlags([self reachabilityFlags]);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
#pragma mark - Callback function calls this method
|
|
436
|
+
|
|
437
|
+
-(void)reachabilityChanged:(SCNetworkReachabilityFlags)flags
|
|
438
|
+
{
|
|
439
|
+
if([self isReachableWithFlags:flags])
|
|
440
|
+
{
|
|
441
|
+
if(self.reachableBlock)
|
|
442
|
+
{
|
|
443
|
+
self.reachableBlock(self);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
else
|
|
447
|
+
{
|
|
448
|
+
if(self.unreachableBlock)
|
|
449
|
+
{
|
|
450
|
+
self.unreachableBlock(self);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
if(self.reachabilityBlock)
|
|
455
|
+
{
|
|
456
|
+
self.reachabilityBlock(self, flags);
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// this makes sure the change notification happens on the MAIN THREAD
|
|
460
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
461
|
+
[[NSNotificationCenter defaultCenter] postNotificationName:kReachabilityChangedNotification
|
|
462
|
+
object:self];
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
#pragma mark - Debug Description
|
|
467
|
+
|
|
468
|
+
- (NSString *) description
|
|
469
|
+
{
|
|
470
|
+
NSString *description = [NSString stringWithFormat:@"<%@: %#x (%@)>",
|
|
471
|
+
NSStringFromClass([self class]), (unsigned int) self, [self currentReachabilityFlags]];
|
|
472
|
+
return description;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
@end
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# Objective-C SQL Query Builder
|
|
2
|
+
|
|
3
|
+
This Objective-C SQLite project is a lightweight library that offers more than just a set of [SQLite](http://www.sqlite.org/)
|
|
4
|
+
wrapper classes. It is divided up into five parts. The first part consists of a set of Objective-C classes that handle
|
|
5
|
+
communications with an SQLite database. Inside the "src" folder, these Objective-C classes are further subdivided into five
|
|
6
|
+
folders. The "db" folder (formerly, the "dao" folder) contains an SQLite wrapper class that easily manages the database
|
|
7
|
+
connection. The "ext" folder contains some class extensions. The "sql" folder contains a collection of SQL builder classes
|
|
8
|
+
that can be used to construct well-formed SQL statements for SQLite via a plethora of convenience methods similar to those
|
|
9
|
+
found in LINQ. Likewise, the "orm" folder has an assortment of classes that can control and manipulate data within an SQLite
|
|
10
|
+
database via the Active Record design pattern. And, the "util" folder contains a set of various helper classes. The
|
|
11
|
+
second part consists of an easy-to-read API, which both documents and diagrams each Objective-C class and XML/DTD file.
|
|
12
|
+
The third part consists of a BASH script that can be used to generate the necessary ORM models using the SQLite's database
|
|
13
|
+
schema. The fourth part consists of the database configuration files for the SQLite database connection. The final part
|
|
14
|
+
has the schema for handling XML to DDL.
|
|
15
|
+
|
|
16
|
+
All classes are designed to be used in iPhone/iOS applications. The classes in the "ARC" branches are compliant with iOS 5's
|
|
17
|
+
[automatic reference counting](http://clang.llvm.org/docs/AutomaticReferenceCounting.html). For projects still using Retains,
|
|
18
|
+
Releases, and Autoreleases (i.e. Pre-ARC) use the classes in the "RRA" branches.
|
|
19
|
+
|
|
20
|
+
## Supported Platforms
|
|
21
|
+
|
|
22
|
+
- Mac OS X 10.7+
|
|
23
|
+
- iOS 4.0+
|
|
24
|
+
|
|
25
|
+
## Motivation
|
|
26
|
+
|
|
27
|
+
The goal of this project is to make these classes the "de facto" standard for communicating with SQLite databases on
|
|
28
|
+
iPhone/iOS devices.
|
|
29
|
+
|
|
30
|
+
With the abundance of third-party libraries for Objective-C, it was apparent that a successful SQLite library needs to
|
|
31
|
+
be simple to learn and intuitive. It must also be cleanly written with clear naming conventions and must be well-documented
|
|
32
|
+
for too many SQLite libraries are hard to understand and are not user-friendly. For these reasons, this SQLite library was
|
|
33
|
+
written.
|
|
34
|
+
|
|
35
|
+
## Features
|
|
36
|
+
|
|
37
|
+
The following is a short-list of some of the features:
|
|
38
|
+
|
|
39
|
+
* [Automatic reference counting](http://longweekendmobile.com/2011/09/07/objc-automatic-reference-counting-in-xcode-explained/);
|
|
40
|
+
* Cleanly wraps-up the sqlite3 C based functions.
|
|
41
|
+
* Automatically places the SQLite database in the "Document" directory.
|
|
42
|
+
* Allows for read-only databases.
|
|
43
|
+
* Provides multi-threading support for asynchronous SQLite database calls;
|
|
44
|
+
* Utilizes a PLIST file for configuring SQLite database connections;
|
|
45
|
+
* Allows database privileges to be restricted.
|
|
46
|
+
* Has an easy to use SQLite database connection pool.
|
|
47
|
+
* Capable of executing an SQL statement with one line of code.
|
|
48
|
+
* Able to execute more than one SQL statement at a time.
|
|
49
|
+
* Has a huge collection of SQL builder classes with methods that mimic their SQL statement equivalents.
|
|
50
|
+
* Converts XML to DDL/SQL statements.
|
|
51
|
+
* Helps ensure that SQL statements are well-formed.
|
|
52
|
+
* Supports all major Objective-C datatypes, including NSNull, NSNumber, NSDecimalNumber, NSString, NSData, and NSDate.
|
|
53
|
+
* Sanitizes data using best practices.
|
|
54
|
+
* Handles most complex queries and works with raw SQL statements.
|
|
55
|
+
* Has a powerful SQLite tokenizer.
|
|
56
|
+
* Contains a message digest to hash strings using md2, md4, md5, sha1, sha224, sha256, sha384, and sha512.
|
|
57
|
+
* Has a data access layer (DAL) that offers Object Relational Mapping (ORM).
|
|
58
|
+
* Data access objects (DAO) handle composite primary keys.
|
|
59
|
+
* Via a Bash script, models (i.e. Active Records) can be auto-generated for each table in the SQLite database.
|
|
60
|
+
* Handles foreign keys via true lazy loading.
|
|
61
|
+
* Requires only those Objective-C classes that are absolutely needed.
|
|
62
|
+
* Classes are easily extendible.
|
|
63
|
+
* Has clear API documentation generated via [Doxygen](http://www.stack.nl/~dimitri/doxygen/).
|
|
64
|
+
|
|
65
|
+
## Getting Started
|
|
66
|
+
|
|
67
|
+
Using these classes in an Xcode project is easy to do. Here is how:
|
|
68
|
+
|
|
69
|
+
1. Download the source code via Github as a tarball (i.e. .tar.gz).
|
|
70
|
+
2. Navigate to the tarball in Finder.
|
|
71
|
+
3. Unarchive the tarball by double-clicking it in a Finder window.
|
|
72
|
+
4. Open an Xcode project.
|
|
73
|
+
5. Right-click on the "Classes" folder and click on the "Add >> Existing Files..." option.
|
|
74
|
+
6. Highlight the files, then click the "Add" button.
|
|
75
|
+
7. Check "Copy items into destination group's folder (if needed)".
|
|
76
|
+
8. Select "Default" for the "Reference Type".
|
|
77
|
+
9. Choose "Recursively create groups for any added folders".
|
|
78
|
+
10. Click "Add".
|
|
79
|
+
|
|
80
|
+
### Required Files
|
|
81
|
+
|
|
82
|
+
A lot of work has gone into making the classes in this repository as independent as possible; however, a few
|
|
83
|
+
dependencies just can't be avoided. To make life easier, the following SDK import files have been created to
|
|
84
|
+
make the implementation process as painless as possible:
|
|
85
|
+
|
|
86
|
+
* ZIMDaoSdk.h
|
|
87
|
+
* ZIMSqlSdk.h
|
|
88
|
+
* ZIMOrmSdk.h
|
|
89
|
+
|
|
90
|
+
Based on which SDK is needed, only those classes listed (i.e. imported) in the SDK import file are needed to be
|
|
91
|
+
added to the respective Xcode project.
|
|
92
|
+
|
|
93
|
+
### Required Frameworks
|
|
94
|
+
|
|
95
|
+
To use these Objective-C classes in an Xcode project, add the following framework:
|
|
96
|
+
|
|
97
|
+
* libsqlite3.dylib
|
|
98
|
+
|
|
99
|
+
### Documentation
|
|
100
|
+
|
|
101
|
+
All classes are heavily documented using [HeaderDoc](http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/HeaderDoc/intro/intro.html#//apple_ref/doc/uid/TP40001215-CH345-SW1).
|
|
102
|
+
You can get familiar with each class by simply looking at the API or by opening its respective ".h" file. Similarly,
|
|
103
|
+
all XML/DTD files are documented using [DTDDoc](http://dtddoc.sourceforge.net). You can also find more information on
|
|
104
|
+
this repository's Wiki.
|
|
105
|
+
|
|
106
|
+
### Tutorials / Examples
|
|
107
|
+
|
|
108
|
+
Checkout this SQLite repository's Wiki for a handful of examples. There, you will find examples on how to make
|
|
109
|
+
an SQLite database connection and how to build [DCL, DDL, DML, and TCL commands](http://download.oracle.com/docs/cd/B12037_01/server.101/b10759/statements_1001.htm)
|
|
110
|
+
(including Create, Read, Update, and Delete (CRUD) statements). The Wiki also has tutorials on how to use Object
|
|
111
|
+
Relational Mapping (ORM) and how to generate the necessary models (i.e. active records).
|
|
112
|
+
|
|
113
|
+
### Further Assistance
|
|
114
|
+
|
|
115
|
+
If you need further assistance in implementing these classes, you can always send an email to oss@ziminji.com with
|
|
116
|
+
any questions that you may have about this repository. Any frequently asked questions (FAQ) will be posted on this
|
|
117
|
+
repository's Wiki.
|
|
118
|
+
|
|
119
|
+
You can also seek assistance via the blogs. A great Web site for community assistance is [Stack Overflow](http://stackoverflow.com).
|
|
120
|
+
|
|
121
|
+
## Reporting Bugs & Making Recommendations
|
|
122
|
+
|
|
123
|
+
Help debug the code in repository by reporting any bugs. The more detailed the report the better. If you have a bug-fix
|
|
124
|
+
or a unit-test, please create an issue under the "Issues" tab of this repository and someone will follow-up with it as
|
|
125
|
+
soon as possible.
|
|
126
|
+
|
|
127
|
+
Likewise, if you would like to make a recommendation on how to improve the code in this repository, take the time to send
|
|
128
|
+
a message so that it can be considered for an upcoming release. Or, if you would like to contribute to the development of
|
|
129
|
+
this Objective-C SQLite repository, go ahead and create a fork.
|
|
130
|
+
|
|
131
|
+
You can also email any bug-fixes, unit-tests, or recommendations to oss@ziminji.com.
|
|
132
|
+
|
|
133
|
+
### Known Issues
|
|
134
|
+
|
|
135
|
+
Usually, code is not posted to this SQLite repository unless it works; however, there are times when some code may get
|
|
136
|
+
posted even though it still contains some bugs. When this occurs, every attempt will be made to list these known bugs
|
|
137
|
+
in this README (if they are not already listed under the "Issues" tab).
|
|
138
|
+
|
|
139
|
+
At the current time, there are no known bugs. However, the "XML to DDL" schema processing is still being developed.
|
|
140
|
+
|
|
141
|
+
### Updates
|
|
142
|
+
|
|
143
|
+
This Objective-C SQLite project is updated frequently with bug-fixes and new features. Be sure to add this repository
|
|
144
|
+
to your watch list so that you can be notified when such updates are made. You can also request email notifications
|
|
145
|
+
regarding updates by emailing oss@ziminji.com.
|
|
146
|
+
|
|
147
|
+
## Future Development
|
|
148
|
+
|
|
149
|
+
This project is under heavy development. There are development plans to add:
|
|
150
|
+
|
|
151
|
+
* Improved functionality to parse "XML to DDL" schema and raw SQLite statements into their SQL builder class equivalents;
|
|
152
|
+
* More utilities (e.g. classes to handle validation, filtering, imports, exports, pagination, partitioning, and migration);
|
|
153
|
+
* A database encryption layer for password protecting an SQLite database;
|
|
154
|
+
* Unit-tests; and,
|
|
155
|
+
* Additional tutorials and examples.
|
|
156
|
+
|
|
157
|
+
Help expand this list with your feedback.
|
|
158
|
+
|
|
159
|
+
## License (Apache v2.0)
|
|
160
|
+
|
|
161
|
+
>Copyright 2011-2015 Ziminji
|
|
162
|
+
>
|
|
163
|
+
>Licensed under the Apache License, Version 2.0 (the "License"); you may not use these files except in compliance with the
|
|
164
|
+
>License. You may obtain a copy of the License at:
|
|
165
|
+
>
|
|
166
|
+
>[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
|
167
|
+
>
|
|
168
|
+
>Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
|
|
169
|
+
>"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
|
|
170
|
+
>language governing permissions and limitations under the License.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2011-2015 Ziminji
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at:
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
#import <Foundation/Foundation.h>
|
|
18
|
+
|
|
19
|
+
/*!
|
|
20
|
+
@category NSString (ZIMString)
|
|
21
|
+
@discussion This category extends the functionality of the NSString class.
|
|
22
|
+
@updated 2011-07-16
|
|
23
|
+
*/
|
|
24
|
+
@interface NSString (ZIMString)
|
|
25
|
+
/*!
|
|
26
|
+
@method matchesRegex:options:
|
|
27
|
+
@discussion This method determines whether the pattern is matched.
|
|
28
|
+
@param pattern The regular expression to be used.
|
|
29
|
+
@param options The options to be used.
|
|
30
|
+
@return A boolean value denoting whether the pattern was matched.
|
|
31
|
+
@updated 2012-03-20
|
|
32
|
+
@see http://developer.apple.com/library/ios/#documentation/Foundation/Reference/NSRegularExpression_Class/Reference/Reference.html
|
|
33
|
+
@see http://quickies.seriot.ch/index.php?id=279
|
|
34
|
+
*/
|
|
35
|
+
- (BOOL) matchesRegex: (NSString *)pattern options: (NSRegularExpressionOptions)options;
|
|
36
|
+
/*!
|
|
37
|
+
@method capitalizeFirstCharacterInString:
|
|
38
|
+
@discussion This method will capitalize the first letter in the specified string.
|
|
39
|
+
@param string The string to be modified.
|
|
40
|
+
@return The modified string.
|
|
41
|
+
@updated 2011-06-29
|
|
42
|
+
@see http://stackoverflow.com/questions/883897/easy-way-to-set-a-single-character-of-an-nsstring-to-uppercase
|
|
43
|
+
*/
|
|
44
|
+
+ (NSString *) capitalizeFirstCharacterInString: (NSString *)string;
|
|
45
|
+
/*!
|
|
46
|
+
@method firstTokenInString:scanUpToCharactersFromSet:
|
|
47
|
+
@discussion This method returns the first token found in the specified string.
|
|
48
|
+
@param string The string to be parsed.
|
|
49
|
+
@param stopSet The set of characters up to which to scan.
|
|
50
|
+
@return The first token found.
|
|
51
|
+
@updated 2011-06-29
|
|
52
|
+
*/
|
|
53
|
+
+ (NSString *) firstTokenInString: (NSString *)string scanUpToCharactersFromSet: (NSCharacterSet *)stopSet;
|
|
54
|
+
|
|
55
|
+
@end
|