4 * Object which represents, and operates on,
5 * an eSellerate serial number.
7 * Original Author : Matt Judy <mjudy@ithinksw.com>
8 * Responsibility : Matt Judy <mjudy@ithinksw.com>
10 * Copyright (c) 2003 iThink Software.
15 #import <Cocoa/Cocoa.h>
19 ITeSerialNumberIsDead = -1 ,
20 ITeSerialNumberIsInvalid = 0 ,
21 ITeSerialNumberIsValid = 1
22 } MTeSerialNumberValidationResult;
25 ITeSerialNumberWillNotExpire = -1 ,
26 ITeSerialNumberHasExpired = 0 ,
27 ITeSerialNumberWillExpire = 1
28 } MTeSerialNumberExpirationResult;
31 @interface MTeSerialNumber : NSObject {
32 NSString *_serialNumber;
33 NSString *_nameBasedKey;
34 NSString *_extraDataKey;
35 NSString *_publisherKey;
37 NSArray *_deadSerials;
40 /*************************************************************************/
42 #pragma mark INITIALIZATION METHODS
43 /*************************************************************************/
46 @method initWithSerialNumber:name:extra:publisher:
47 @abstract Creates an ITeSerialNumber with the information provided.
48 @discussion This is the designated initializer for this class.
49 @param serial The eSellerate serial number
50 @param name The name-based key for the serial number
51 @param extra This is present for future use. eSellerate does not use this data yet. Pass nil.
52 @param publisher The publisher key, provided by the Serial Number management part of eSellerate.
53 @result The newly initialized object.
55 - (id)initWithSerialNumber:(NSString *)serial
57 extra:(NSString *)extra // Extra data not used. Pass nil.
58 publisher:(NSString *)publisher;
61 @method initWithDictionary:
62 @abstract Creates an ITeSerialNumber with the information provided in dictionary form
63 @discussion Utilizes initWithSerialNumber:name:extra:publisher:
64 @param dict Consists of 4 keys, and 4 NSStrings. The keys must be named
65 "Key", "Owner", "Extra", and "Publisher".
66 @result The newly initialized object.
68 - (id)initWithDictionary:(NSDictionary *)dict;
71 @method initWithContentsOfFile:extra:publisher:
72 @abstract Creates an ITeSerialNumber from the combination of a plist, and arguments.
73 @discussion Only the serial (Key) and name (Owner) should ever be stored in the plist,
74 for security. This method will ignore any other data present in the file.
75 @param path Path to the file on disk. This file must be a plist containing one dictionary.
76 @param extra eSellerate extra data. Currently unused by eSellerate. Pass nil.
77 @param publisher The publisher key, provided by the Serial Number management part of eSellerate.
78 @result The newly initialized object.
80 - (id)initWithContentsOfFile:(NSString *)path
81 extra:(NSString *)extra
82 publisher:(NSString *)publisher;
85 /*************************************************************************/
87 #pragma mark ACCESSOR METHODS
88 /*************************************************************************/
90 - (NSString *)serialNumber;
91 - (void)setSerialNumber:(NSString *)newSerial;
93 - (NSString *)nameBasedKey;
94 - (void)setNameBasedKey:(NSString *)newName;
96 - (NSString *)extraDataKey;
97 - (void)setExtraDataKey:(NSString *)newData;
99 - (NSString *)publisherKey;
100 - (void)setPublisherKey:(NSString *)newPublisher;
102 - (NSArray *)deadSerials;
103 - (void)setDeadSerials:(NSArray *)newList;
106 /*************************************************************************/
108 #pragma mark INSTANCE METHODS
109 /*************************************************************************/
113 @abstract Checks the current serial for validity.
114 @result ITeSerialNumberValidationResult, based on the current serial's validity.
116 - (MTeSerialNumberValidationResult)isValid;
120 @abstract Tests for validity, and returns whether or not the
121 serial is expired, or will expire.
122 @result YES if the serial will expire, NO if it will not.
124 - (MTeSerialNumberExpirationResult)isExpired;
126 - (NSDate *)storedDate;
128 - (NSTimeInterval)secondsRemaining;
130 - (NSDictionary *)infoDictionary;