Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/mac_osx/src/external/cmcrashreporter/CMCrashReporterGlobal.m @ 8501

Last change on this file since 8501 was 8259, checked in by youngk, 14 years ago

Integrating automatic crash reporter. Does not work atm.

File size: 3.1 KB
Line 
1//
2//  CMCrashReporterGlobal.m
3//  CMCrashReporter-App
4//
5//  Created by Jelle De Laender on 20/01/08.
6//  Copyright 2008 CodingMammoth. All rights reserved.
7//  Copyright 2010 CodingMammoth. Revision. All rights reserved.
8//
9
10#import "CMCrashReporterGlobal.h"
11#import <AddressBook/AddressBook.h>
12
13
14NSString* mAppName = nil;
15NSString* mAppUiName = nil;
16NSString* mAppVersion = nil;
17NSString* mCrashReportEmail = nil;
18NSString* mCrashReportEmailSubject = nil;
19NSString* mCrashReportURL = nil;
20
21
22@implementation CMCrashReporterGlobal
23
24
25- (void)dealloc {
26    if (mAppName != nil)
27        [mAppName release];
28    if (mAppUiName != nil)
29        [mAppUiName release];
30    if (mAppVersion != nil)
31        [mAppVersion release];
32    if (mCrashReportEmail != nil)
33        [mCrashReportEmail release];
34    if (mCrashReportEmailSubject != nil)
35        [mCrashReportEmailSubject release];
36    if (mCrashReportURL != nil)
37        [mCrashReportURL release];
38
39    [super dealloc];
40}
41
42
43+ (NSString *)appName
44{
45    if (mAppName != NULL)
46        return mAppName;
47    else
48        return [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
49}
50
51+ (NSString *)appUiName
52{
53    if (mAppUiName != NULL)
54        return mAppUiName;
55    else
56        return [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
57}
58
59+ (NSString *)appVersion
60{
61    if (mAppVersion != NULL)
62        return mAppVersion;
63    else
64        return [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
65}
66
67+ (int)numberOfMaximumReports {
68        if (! [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CMMaxReports"]) return 0;
69       
70        return [[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CMMaxReports"] intValue];
71}
72
73+ (BOOL)isRunningLeopard
74{
75        SInt32 MacVersion;
76        Gestalt(gestaltSystemVersion, &MacVersion);
77        return MacVersion >= 4176;
78}
79
80+ (BOOL)checkOnCrashes
81{
82        // Integration for later
83        return YES;
84}
85
86+ (NSString *)crashReportURL
87{
88    NSString *value;
89    if (mCrashReportURL != NULL)
90        value = mCrashReportURL;
91    else
92        value = [[[NSBundle mainBundle] infoDictionary]
93                        objectForKey:@"CMSubmitURL"];
94    if (!value) NSLog(@"Warning: No CMSubmitURL - key available for CMCrashReporter. Please add this key at your info.plist file.");
95    return value;
96}
97
98+ (NSString *)crashReportEmail
99{
100    NSString *email;
101    if (mCrashReportURL != NULL)
102        email = mCrashReportEmail;
103    else
104    {
105        ABMultiValue *emails = [[[ABAddressBook sharedAddressBook] me] valueForProperty: kABEmailProperty];
106        email = (NSString *) [emails valueAtIndex: [emails indexForIdentifier: [emails primaryIdentifier]]];
107     }
108
109    return email;
110}
111
112+ (NSString *)osVersion
113{
114        return [[NSDictionary dictionaryWithContentsOfFile:@"/System/Library/CoreServices/SystemVersion.plist"]
115                        objectForKey:@"ProductVersion"];
116}
117
118+ (void)setAppName:(NSString *)name
119{
120    mAppName = name;
121}
122
123+ (void)setAppUiName:(NSString *)name
124{
125    mAppUiName = name;
126}
127
128+ (void)setAppVersion:(NSString *)version
129{
130    mAppVersion = version;
131}
132
133+ (void)setCrashReportEmail:(NSString *)emailTo
134{
135    mCrashReportEmail = emailTo;
136}
137
138+ (void)setCrashReportURL:(NSString *)reportServerUrl
139{
140    mCrashReportURL = reportServerUrl;
141}
142
143
144@end
145
Note: See TracBrowser for help on using the repository browser.