Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

- Added new Unique Device Identifier, because [UIDevice currentDevice…

…].uniqueIdentifier is deprecated

- Fixed Singleton Macro defines
- Added NSString Category for SHA crypto methods
- Updated Project Settings
  • Loading branch information...
commit 557eff3a66730c5dfd8c7e45de67d7c39c0f1756 1 parent 9d3bda7
Carl Jahn authored April 03, 2012
21  CrashManager.xcodeproj/project.pbxproj
@@ -3,10 +3,12 @@
3 3
 	archiveVersion = 1;
4 4
 	classes = {
5 5
 	};
6  
-	objectVersion = 45;
  6
+	objectVersion = 46;
7 7
 	objects = {
8 8
 
9 9
 /* Begin PBXBuildFile section */
  10
+		15B5B521152AF3170042EA2E /* MacAdress.m in Sources */ = {isa = PBXBuildFile; fileRef = 15B5B520152AF3170042EA2E /* MacAdress.m */; };
  11
+		15B5B527152AF4E80042EA2E /* NSString+SHA.m in Sources */ = {isa = PBXBuildFile; fileRef = 15B5B526152AF4E80042EA2E /* NSString+SHA.m */; };
10 12
 		1D3623260D0F684500981E51 /* CrashManagerDemoAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3623250D0F684500981E51 /* CrashManagerDemoAppDelegate.m */; };
11 13
 		1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; };
12 14
 		1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
@@ -23,6 +25,10 @@
23 25
 /* End PBXBuildFile section */
24 26
 
25 27
 /* Begin PBXFileReference section */
  28
+		15B5B51F152AF3170042EA2E /* MacAdress.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacAdress.h; sourceTree = "<group>"; };
  29
+		15B5B520152AF3170042EA2E /* MacAdress.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MacAdress.m; sourceTree = "<group>"; };
  30
+		15B5B525152AF4E80042EA2E /* NSString+SHA.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+SHA.h"; sourceTree = "<group>"; };
  31
+		15B5B526152AF4E80042EA2E /* NSString+SHA.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+SHA.m"; sourceTree = "<group>"; };
26 32
 		1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
27 33
 		1D3623240D0F684500981E51 /* CrashManagerDemoAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CrashManagerDemoAppDelegate.h; sourceTree = "<group>"; };
28 34
 		1D3623250D0F684500981E51 /* CrashManagerDemoAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CrashManagerDemoAppDelegate.m; sourceTree = "<group>"; };
@@ -151,6 +157,10 @@
151 157
 			isa = PBXGroup;
152 158
 			children = (
153 159
 				39EF1F111299EC6B00261349 /* SynthesizeSingleton.h */,
  160
+				15B5B51F152AF3170042EA2E /* MacAdress.h */,
  161
+				15B5B520152AF3170042EA2E /* MacAdress.m */,
  162
+				15B5B525152AF4E80042EA2E /* NSString+SHA.h */,
  163
+				15B5B526152AF4E80042EA2E /* NSString+SHA.m */,
154 164
 			);
155 165
 			path = Support;
156 166
 			sourceTree = "<group>";
@@ -191,8 +201,11 @@
191 201
 /* Begin PBXProject section */
192 202
 		29B97313FDCFA39411CA2CEA /* Project object */ = {
193 203
 			isa = PBXProject;
  204
+			attributes = {
  205
+				LastUpgradeCheck = 0430;
  206
+			};
194 207
 			buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "CrashManager" */;
195  
-			compatibilityVersion = "Xcode 3.1";
  208
+			compatibilityVersion = "Xcode 3.2";
196 209
 			developmentRegion = English;
197 210
 			hasScannedForEncodings = 1;
198 211
 			knownRegions = (
@@ -234,6 +247,8 @@
234 247
 				39EF1F181299EC6B00261349 /* StackTracer.m in Sources */,
235 248
 				39EF1F191299EC6B00261349 /* Mailer.m in Sources */,
236 249
 				39EF1F1A1299EC6B00261349 /* ModalViewPresenter.m in Sources */,
  250
+				15B5B521152AF3170042EA2E /* MacAdress.m in Sources */,
  251
+				15B5B527152AF4E80042EA2E /* NSString+SHA.m in Sources */,
237 252
 			);
238 253
 			runOnlyForDeploymentPostprocessing = 0;
239 254
 		};
@@ -275,7 +290,6 @@
275 290
 				GCC_C_LANGUAGE_STANDARD = c99;
276 291
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
277 292
 				GCC_WARN_UNUSED_VARIABLE = YES;
278  
-				PREBINDING = NO;
279 293
 				SDKROOT = iphoneos;
280 294
 			};
281 295
 			name = Debug;
@@ -289,7 +303,6 @@
289 303
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
290 304
 				GCC_WARN_UNUSED_VARIABLE = YES;
291 305
 				OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
292  
-				PREBINDING = NO;
293 306
 				SDKROOT = iphoneos;
294 307
 			};
295 308
 			name = Release;
7  libs/CrashManager/CrashManager.m
@@ -28,7 +28,8 @@
28 28
 #include <unistd.h>
29 29
 #import "StackTracer.h"
30 30
 #import <UIKit/UIKit.h>
31  
-
  31
+#import "MacAdress.h"
  32
+#import "NSString+SHA.h"
32 33
 
33 34
 /** Maximum number of stack frames to capture. */
34 35
 #define kStackFramesToCapture 40
@@ -256,8 +257,8 @@ - (void) storeErrorReport:(NSException*) exception stackTrace:(NSArray*) stackTr
256 257
 	NSString* data = [NSString stringWithFormat:@"App: %@\nVersion: %@\nID: %@\n%@: %@\n%@",
257 258
 					  [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"],
258 259
 					  [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"],
259  
-					  [UIDevice currentDevice].uniqueIdentifier,
260  
-					  [exception name],
  260
+					  [[MacAdress macAdress] sha1],
  261
+            [exception name],
261 262
 					  [exception reason],
262 263
 					  [[StackTracer sharedInstance] printableTrace:stackTrace]];
263 264
 	[data writeToFile:errorReportPath atomically:YES encoding:NSUTF8StringEncoding error:nil];
16  libs/CrashManager/Support/MacAdress.h
... ...
@@ -0,0 +1,16 @@
  1
+//
  2
+//  MacAdress.h
  3
+//  VRM News
  4
+//
  5
+//  Created by Carl Jahn on 21.11.11.
  6
+//  Copyright (c) 2011 NIDAG. All rights reserved.
  7
+//
  8
+
  9
+#import <Foundation/Foundation.h>
  10
+
  11
+@interface MacAdress : NSObject
  12
+
  13
++ (NSString *)macAdress;
  14
+
  15
+
  16
+@end
84  libs/CrashManager/Support/MacAdress.m
... ...
@@ -0,0 +1,84 @@
  1
+//
  2
+//  MacAdress.m
  3
+//  VRM News
  4
+//
  5
+//  Created by Carl Jahn on 21.11.11.
  6
+//  Copyright (c) 2011 NIDAG. All rights reserved.
  7
+//
  8
+
  9
+#import "MacAdress.h"
  10
+
  11
+#include <sys/socket.h>
  12
+#include <sys/sysctl.h>
  13
+#include <net/if.h>
  14
+#include <net/if_dl.h>
  15
+
  16
+
  17
+
  18
+@implementation MacAdress
  19
+
  20
+
  21
+
  22
++ (NSString *)macAdress
  23
+{
  24
+  
  25
+  int                 mgmtInfoBase[6];
  26
+  char                *msgBuffer = NULL;
  27
+  NSString            *errorFlag = NULL;
  28
+  size_t              length;
  29
+  
  30
+  // Setup the management Information Base (mib)
  31
+  mgmtInfoBase[0] = CTL_NET;        // Request network subsystem
  32
+  mgmtInfoBase[1] = AF_ROUTE;       // Routing table info
  33
+  mgmtInfoBase[2] = 0;              
  34
+  mgmtInfoBase[3] = AF_LINK;        // Request link layer information
  35
+  mgmtInfoBase[4] = NET_RT_IFLIST;  // Request all configured interfaces
  36
+  
  37
+  // With all configured interfaces requested, get handle index
  38
+  if ((mgmtInfoBase[5] = if_nametoindex("en0")) == 0) 
  39
+    errorFlag = @"if_nametoindex failure";
  40
+  // Get the size of the data available (store in len)
  41
+  else if (sysctl(mgmtInfoBase, 6, NULL, &length, NULL, 0) < 0) 
  42
+    errorFlag = @"sysctl mgmtInfoBase failure";
  43
+  // Alloc memory based on above call
  44
+  else if ((msgBuffer = malloc(length)) == NULL)
  45
+    errorFlag = @"buffer allocation failure";
  46
+  // Get system information, store in buffer
  47
+  else if (sysctl(mgmtInfoBase, 6, msgBuffer, &length, NULL, 0) < 0)
  48
+  {
  49
+    free(msgBuffer);
  50
+    errorFlag = @"sysctl msgBuffer failure";
  51
+  }
  52
+  else
  53
+  {
  54
+    // Map msgbuffer to interface message structure
  55
+    struct if_msghdr *interfaceMsgStruct = (struct if_msghdr *) msgBuffer;
  56
+    
  57
+    // Map to link-level socket structure
  58
+    struct sockaddr_dl *socketStruct = (struct sockaddr_dl *) (interfaceMsgStruct + 1);
  59
+    
  60
+    // Copy link layer address data in socket structure to an array
  61
+    unsigned char macAddress[6];
  62
+    memcpy(&macAddress, socketStruct->sdl_data + socketStruct->sdl_nlen, 6);
  63
+    
  64
+    // Read from char array into a string object, into traditional Mac address format
  65
+    NSString *macAddressString = [NSString stringWithFormat:@"%02X:%02X:%02X:%02X:%02X:%02X",
  66
+                                  macAddress[0], macAddress[1], macAddress[2], macAddress[3], macAddress[4], macAddress[5]];
  67
+    NSLog(@"Mac Address: %@", macAddressString);
  68
+    
  69
+    // Release the buffer memory
  70
+    free(msgBuffer);
  71
+    
  72
+    return macAddressString;
  73
+  }
  74
+  
  75
+  // Error...
  76
+  NSLog(@"Error: %@", errorFlag);
  77
+  
  78
+  return errorFlag;
  79
+
  80
+}
  81
+
  82
+
  83
+
  84
+@end
20  libs/CrashManager/Support/NSString+SHA.h
... ...
@@ -0,0 +1,20 @@
  1
+//
  2
+//  NSString+SHA.h
  3
+//  CrashManager
  4
+//
  5
+//  Created by Carl Jahn on 03.04.12.
  6
+//  Copyright (c) 2012 NIDAG. All rights reserved.
  7
+//
  8
+
  9
+#import <Foundation/Foundation.h>
  10
+
  11
+@interface NSString (SHA)
  12
+
  13
+- (NSString *)sha1;
  14
+- (NSString *)sha224;
  15
+- (NSString *)sha256;
  16
+- (NSString *)sha384;
  17
+- (NSString *)sha512;
  18
+
  19
+
  20
+@end
126  libs/CrashManager/Support/NSString+SHA.m
... ...
@@ -0,0 +1,126 @@
  1
+//
  2
+//  NSString+SHA.m
  3
+//  CrashManager
  4
+//
  5
+//  Created by Carl Jahn on 03.04.12.
  6
+//  Copyright (c) 2012 NIDAG. All rights reserved.
  7
+//
  8
+
  9
+#import "NSString+SHA.h"
  10
+#import <CommonCrypto/CommonDigest.h>
  11
+
  12
+@implementation NSString (SHA)
  13
+
  14
+- (NSString *)sha1 {
  15
+  const char *cStr = [self UTF8String];
  16
+  unsigned char result[CC_SHA1_DIGEST_LENGTH];
  17
+  CC_SHA1(cStr, strlen(cStr), result);
  18
+  NSString *s = [NSString  stringWithFormat:
  19
+                 @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
  20
+                 result[0], result[1], result[2], result[3], result[4],
  21
+                 result[5], result[6], result[7],
  22
+                 result[8], result[9], result[10], result[11], result[12],
  23
+                 result[13], result[14], result[15],
  24
+                 result[16], result[17], result[18], result[19]
  25
+                 ];
  26
+  
  27
+  return [s lowercaseString];
  28
+}
  29
+
  30
+- (NSString *)sha224 {
  31
+  const char *cStr = [self UTF8String];
  32
+  unsigned char result[CC_SHA224_DIGEST_LENGTH];
  33
+  
  34
+  CC_SHA224(cStr, strlen(cStr), result);
  35
+  NSString *s = [NSString  stringWithFormat:
  36
+                 @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
  37
+                 result[0], result[1], result[2], result[3], result[4],
  38
+                 result[5], result[6], result[7],
  39
+                 result[8], result[9], result[10], result[11], result[12],
  40
+                 result[13], result[14], result[15],
  41
+                 result[16], result[17], result[18], result[19], result[20], 
  42
+                 result[21], result[22], result[23], result[24], result[25], 
  43
+                 result[26], result[27]
  44
+                 ];
  45
+  
  46
+  
  47
+  
  48
+  return [s lowercaseString];
  49
+}
  50
+
  51
+- (NSString *)sha256 {
  52
+  const char *cStr = [self UTF8String];
  53
+  unsigned char result[CC_SHA256_DIGEST_LENGTH];
  54
+  
  55
+  CC_SHA256(cStr, strlen(cStr), result);
  56
+  NSString *s = [NSString  stringWithFormat:
  57
+                 @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
  58
+                 result[0], result[1], result[2], result[3], result[4],
  59
+                 result[5], result[6], result[7],
  60
+                 result[8], result[9], result[10], result[11], result[12],
  61
+                 result[13], result[14], result[15],
  62
+                 result[16], result[17], result[18], result[19], result[20], 
  63
+                 result[21], result[22], result[23], result[24], result[25], 
  64
+                 result[26], result[27], result[28], result[29], result[30], 
  65
+                 result[31]
  66
+                 ];
  67
+  
  68
+  
  69
+  
  70
+  return [s lowercaseString];
  71
+}
  72
+- (NSString *)sha384 {
  73
+  const char *cStr = [self UTF8String];
  74
+  unsigned char result[CC_SHA384_DIGEST_LENGTH];
  75
+  
  76
+  CC_SHA384(cStr, strlen(cStr), result);
  77
+  NSString *s = [NSString  stringWithFormat:
  78
+                 @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
  79
+                 result[0], result[1], result[2], result[3], result[4],
  80
+                 result[5], result[6], result[7],
  81
+                 result[8], result[9], result[10], result[11], result[12],
  82
+                 result[13], result[14], result[15],
  83
+                 result[16], result[17], result[18], result[19], result[20], 
  84
+                 result[21], result[22], result[23], result[24], result[25], 
  85
+                 result[26], result[27], result[28], result[29], result[30], 
  86
+                 result[31], result[32], result[33], result[34], result[35], 
  87
+                 result[36], result[37], result[38], result[39], result[40], 
  88
+                 result[41], result[42], result[43], result[44], result[45], 
  89
+                 result[46], result[47]
  90
+                 ];
  91
+  
  92
+  
  93
+  
  94
+  return [s lowercaseString];
  95
+}
  96
+
  97
+- (NSString *)sha512 {
  98
+  const char *cStr = [self UTF8String];
  99
+  unsigned char result[CC_SHA512_DIGEST_LENGTH];
  100
+  
  101
+  CC_SHA512(cStr, strlen(cStr), result);
  102
+  NSString *s = [NSString  stringWithFormat:
  103
+                 @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
  104
+                 result[0], result[1], result[2], result[3], result[4],
  105
+                 result[5], result[6], result[7],
  106
+                 result[8], result[9], result[10], result[11], result[12],
  107
+                 result[13], result[14], result[15],
  108
+                 result[16], result[17], result[18], result[19], result[20], 
  109
+                 result[21], result[22], result[23], result[24], result[25], 
  110
+                 result[26], result[27], result[28], result[29], result[30], 
  111
+                 result[31], result[32], result[33], result[34], result[35], 
  112
+                 result[36], result[37], result[38], result[39], result[40], 
  113
+                 result[41], result[42], result[43], result[44], result[45], 
  114
+                 result[46], result[47], result[48], result[49], result[50], 
  115
+                 result[51], result[52], result[53], result[54], result[55], 
  116
+                 result[56], result[57], result[58], result[59], result[60], 
  117
+                 result[61], result[62], result[63]
  118
+                 ];
  119
+  
  120
+  
  121
+  return [s lowercaseString];
  122
+  
  123
+}
  124
+
  125
+
  126
+@end
4  libs/CrashManager/Support/SynthesizeSingleton.h
@@ -138,7 +138,7 @@ static volatile __CLASSNAME__* _##__CLASSNAME__##_sharedInstance = nil;	\
138 138
 			}	\
139 139
 		}	\
140 140
 	}	\
141  
-	return _##__CLASSNAME__##_sharedInstance;	\
  141
+	return (__CLASSNAME__*) _##__CLASSNAME__##_sharedInstance;	\
142 142
 }	\
143 143
 	\
144 144
 + (void)purgeSharedInstance	\
@@ -183,7 +183,7 @@ static volatile __CLASSNAME__* _##__CLASSNAME__##_sharedInstance = nil;	\
183 183
 	return [super retainCount];	\
184 184
 }	\
185 185
 	\
186  
-- (void)release	\
  186
+- (oneway void)release	\
187 187
 {	\
188 188
 	NSAssert1(1==0, @"SynthesizeSingleton: %@ ERROR: -(void)release method did not get swizzled.", self);	\
189 189
 }	\

0 notes on commit 557eff3

Please sign in to comment.
Something went wrong with that request. Please try again.