This repository has been archived by the owner on Feb 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
142 changed files
with
8,503 additions
and
5,029 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,5 @@ profile | |
*.swp | ||
*~.nib | ||
profile | ||
|
||
documentation/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Author: Peter Steinberger | ||
* | ||
* Copyright (c) 2012 HockeyApp, Bit Stadium GmbH. | ||
* Copyright (c) 2011 Andreas Linde, Peter Steinberger. | ||
* All rights reserved. | ||
* | ||
* Permission is hereby granted, free of charge, to any person | ||
* obtaining a copy of this software and associated documentation | ||
* files (the "Software"), to deal in the Software without | ||
* restriction, including without limitation the rights to use, | ||
* copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the | ||
* Software is furnished to do so, subject to the following | ||
* conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
* OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface BITAppVersionMetaInfo : NSObject { | ||
} | ||
@property (nonatomic, copy) NSString *name; | ||
@property (nonatomic, copy) NSString *version; | ||
@property (nonatomic, copy) NSString *shortVersion; | ||
@property (nonatomic, copy) NSString *notes; | ||
@property (nonatomic, copy) NSDate *date; | ||
@property (nonatomic, copy) NSNumber *size; | ||
@property (nonatomic, copy) NSNumber *mandatory; | ||
|
||
- (NSString *)nameAndVersionString; | ||
- (NSString *)versionString; | ||
- (NSString *)dateString; | ||
- (NSString *)sizeInMB; | ||
- (NSString *)notesOrEmptyString; | ||
- (void)setDateWithTimestamp:(NSTimeInterval)timestamp; | ||
- (BOOL)isValid; | ||
- (BOOL)isEqualToAppVersionMetaInfo:(BITAppVersionMetaInfo *)anAppVersionMetaInfo; | ||
|
||
+ (BITAppVersionMetaInfo *)appVersionMetaInfoFromDict:(NSDictionary *)dict; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
/* | ||
* Author: Peter Steinberger | ||
* | ||
* Copyright (c) 2012 HockeyApp, Bit Stadium GmbH. | ||
* Copyright (c) 2011 Andreas Linde, Peter Steinberger. | ||
* All rights reserved. | ||
* | ||
* Permission is hereby granted, free of charge, to any person | ||
* obtaining a copy of this software and associated documentation | ||
* files (the "Software"), to deal in the Software without | ||
* restriction, including without limitation the rights to use, | ||
* copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the | ||
* Software is furnished to do so, subject to the following | ||
* conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
* OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
#import "BITAppVersionMetaInfo.h" | ||
#import "HockeySDKPrivate.h" | ||
|
||
|
||
@implementation BITAppVersionMetaInfo | ||
|
||
@synthesize name = _name; | ||
@synthesize version = _version; | ||
@synthesize shortVersion = _shortVersion; | ||
@synthesize notes = _notes; | ||
@synthesize date = _date; | ||
@synthesize size = _size; | ||
@synthesize mandatory = _mandatory; | ||
|
||
|
||
#pragma mark - Static | ||
|
||
+ (BITAppVersionMetaInfo *)appVersionMetaInfoFromDict:(NSDictionary *)dict { | ||
BITAppVersionMetaInfo *appVersionMetaInfo = [[[[self class] alloc] init] autorelease]; | ||
|
||
if ([dict isKindOfClass:[NSDictionary class]]) { | ||
appVersionMetaInfo.name = [dict objectForKey:@"title"]; | ||
appVersionMetaInfo.version = [dict objectForKey:@"version"]; | ||
appVersionMetaInfo.shortVersion = [dict objectForKey:@"shortversion"]; | ||
[appVersionMetaInfo setDateWithTimestamp:[[dict objectForKey:@"timestamp"] doubleValue]]; | ||
appVersionMetaInfo.size = [dict objectForKey:@"appsize"]; | ||
appVersionMetaInfo.notes = [dict objectForKey:@"notes"]; | ||
appVersionMetaInfo.mandatory = [dict objectForKey:@"mandatory"]; | ||
} | ||
|
||
return appVersionMetaInfo; | ||
} | ||
|
||
|
||
#pragma mark - NSObject | ||
|
||
- (void)dealloc { | ||
[_name release]; | ||
[_version release]; | ||
[_shortVersion release]; | ||
[_notes release]; | ||
[_date release]; | ||
[_size release]; | ||
[_mandatory release]; | ||
|
||
[super dealloc]; | ||
} | ||
|
||
- (BOOL)isEqual:(id)other { | ||
if (other == self) | ||
return YES; | ||
if (!other || ![other isKindOfClass:[self class]]) | ||
return NO; | ||
return [self isEqualToAppVersionMetaInfo:other]; | ||
} | ||
|
||
- (BOOL)isEqualToAppVersionMetaInfo:(BITAppVersionMetaInfo *)anAppVersionMetaInfo { | ||
if (self == anAppVersionMetaInfo) | ||
return YES; | ||
if (self.name != anAppVersionMetaInfo.name && ![self.name isEqualToString:anAppVersionMetaInfo.name]) | ||
return NO; | ||
if (self.version != anAppVersionMetaInfo.version && ![self.version isEqualToString:anAppVersionMetaInfo.version]) | ||
return NO; | ||
if (self.shortVersion != anAppVersionMetaInfo.shortVersion && ![self.shortVersion isEqualToString:anAppVersionMetaInfo.shortVersion]) | ||
return NO; | ||
if (self.notes != anAppVersionMetaInfo.notes && ![self.notes isEqualToString:anAppVersionMetaInfo.notes]) | ||
return NO; | ||
if (self.date != anAppVersionMetaInfo.date && ![self.date isEqualToDate:anAppVersionMetaInfo.date]) | ||
return NO; | ||
if (self.size != anAppVersionMetaInfo.size && ![self.size isEqualToNumber:anAppVersionMetaInfo.size]) | ||
return NO; | ||
if (self.mandatory != anAppVersionMetaInfo.mandatory && ![self.mandatory isEqualToNumber:anAppVersionMetaInfo.mandatory]) | ||
return NO; | ||
return YES; | ||
} | ||
|
||
|
||
#pragma mark - NSCoder | ||
|
||
- (void)encodeWithCoder:(NSCoder *)encoder { | ||
[encoder encodeObject:self.name forKey:@"name"]; | ||
[encoder encodeObject:self.version forKey:@"version"]; | ||
[encoder encodeObject:self.shortVersion forKey:@"shortVersion"]; | ||
[encoder encodeObject:self.notes forKey:@"notes"]; | ||
[encoder encodeObject:self.date forKey:@"date"]; | ||
[encoder encodeObject:self.size forKey:@"size"]; | ||
[encoder encodeObject:self.mandatory forKey:@"mandatory"]; | ||
} | ||
|
||
- (id)initWithCoder:(NSCoder *)decoder { | ||
if ((self = [super init])) { | ||
self.name = [decoder decodeObjectForKey:@"name"]; | ||
self.version = [decoder decodeObjectForKey:@"version"]; | ||
self.shortVersion = [decoder decodeObjectForKey:@"shortVersion"]; | ||
self.notes = [decoder decodeObjectForKey:@"notes"]; | ||
self.date = [decoder decodeObjectForKey:@"date"]; | ||
self.size = [decoder decodeObjectForKey:@"size"]; | ||
self.mandatory = [decoder decodeObjectForKey:@"mandatory"]; | ||
} | ||
return self; | ||
} | ||
|
||
|
||
#pragma mark - Properties | ||
|
||
- (NSString *)nameAndVersionString { | ||
NSString *appNameAndVersion = [NSString stringWithFormat:@"%@ %@", self.name, [self versionString]]; | ||
return appNameAndVersion; | ||
} | ||
|
||
- (NSString *)versionString { | ||
NSString *shortString = ([self.shortVersion respondsToSelector:@selector(length)] && [self.shortVersion length]) ? [NSString stringWithFormat:@"%@", self.shortVersion] : @""; | ||
NSString *versionString = [shortString length] ? [NSString stringWithFormat:@" (%@)", self.version] : self.version; | ||
return [NSString stringWithFormat:@"%@ %@%@", BITHockeyLocalizedString(@"UpdateVersion"), shortString, versionString]; | ||
} | ||
|
||
- (NSString *)dateString { | ||
NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease]; | ||
[formatter setDateStyle:NSDateFormatterMediumStyle]; | ||
|
||
return [formatter stringFromDate:self.date]; | ||
} | ||
|
||
- (NSString *)sizeInMB { | ||
if ([_size isKindOfClass: [NSNumber class]] && [_size doubleValue] > 0) { | ||
double appSizeInMB = [_size doubleValue]/(1024*1024); | ||
NSString *appSizeString = [NSString stringWithFormat:@"%.1f MB", appSizeInMB]; | ||
return appSizeString; | ||
} | ||
|
||
return @"0 MB"; | ||
} | ||
|
||
- (void)setDateWithTimestamp:(NSTimeInterval)timestamp { | ||
if (timestamp) { | ||
NSDate *appDate = [NSDate dateWithTimeIntervalSince1970:timestamp]; | ||
self.date = appDate; | ||
} else { | ||
self.date = nil; | ||
} | ||
} | ||
|
||
- (NSString *)notesOrEmptyString { | ||
if (self.notes) { | ||
return self.notes; | ||
}else { | ||
return [NSString string]; | ||
} | ||
} | ||
|
||
// a valid app needs at least following properties: name, version, date | ||
- (BOOL)isValid { | ||
BOOL valid = [self.name length] && [self.version length] && self.date; | ||
return valid; | ||
} | ||
|
||
@end |
Oops, something went wrong.