Updated to version 1.6.5
[MenuTunes.git] / MTeSerialNumber.h
1 /*
2  *      MenuTunes
3  *  MTeSerialNumber
4  *    Object which represents, and operates on,
5  *    an eSellerate serial number.
6  *
7  *  Original Author : Matt Judy <mjudy@ithinksw.com>
8  *   Responsibility : Matt Judy <mjudy@ithinksw.com>
9  *
10  *  Copyright (c) 2003 iThink Software.
11  *  All Rights Reserved
12  *
13  */
14
15 #import <Cocoa/Cocoa.h>
16
17
18 typedef enum {
19     ITeSerialNumberIsDead    = -1 ,
20     ITeSerialNumberIsInvalid =  0 ,
21     ITeSerialNumberIsValid   =  1
22 } MTeSerialNumberValidationResult;
23
24 typedef enum {
25     ITeSerialNumberWillNotExpire = -1 ,
26     ITeSerialNumberHasExpired    =  0 ,
27     ITeSerialNumberWillExpire    =  1
28 } MTeSerialNumberExpirationResult;
29
30
31 @interface MTeSerialNumber : NSObject {
32     NSString *_serialNumber;
33     NSString *_nameBasedKey;
34     NSString *_extraDataKey;
35     NSString *_publisherKey;
36
37     NSArray *_deadSerials;
38 }
39
40 /*************************************************************************/
41 #pragma mark -
42 #pragma mark INITIALIZATION METHODS
43 /*************************************************************************/
44
45 /*!
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.
54 */
55 - (id)initWithSerialNumber:(NSString *)serial
56                       name:(NSString *)name
57                      extra:(NSString *)extra  // Extra data not used.  Pass nil.
58                  publisher:(NSString *)publisher;
59
60 /*!
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.
67 */
68 - (id)initWithDictionary:(NSDictionary *)dict;
69
70 /*!
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.
79 */
80 - (id)initWithContentsOfFile:(NSString *)path
81                        extra:(NSString *)extra
82                    publisher:(NSString *)publisher;
83
84
85 /*************************************************************************/
86 #pragma mark -
87 #pragma mark ACCESSOR METHODS
88 /*************************************************************************/
89
90 - (NSString *)serialNumber;
91 - (void)setSerialNumber:(NSString *)newSerial;
92
93 - (NSString *)nameBasedKey;
94 - (void)setNameBasedKey:(NSString *)newName;
95
96 - (NSString *)extraDataKey;
97 - (void)setExtraDataKey:(NSString *)newData;
98
99 - (NSString *)publisherKey;
100 - (void)setPublisherKey:(NSString *)newPublisher;
101
102 - (NSArray *)deadSerials;
103 - (void)setDeadSerials:(NSArray *)newList;
104
105
106 /*************************************************************************/
107 #pragma mark -
108 #pragma mark INSTANCE METHODS
109 /*************************************************************************/
110
111 /*!
112     @method isValid
113     @abstract Checks the current serial for validity.
114     @result ITeSerialNumberValidationResult, based on the current serial's validity.
115 */
116 - (MTeSerialNumberValidationResult)isValid;
117
118 /*!
119     @method isExpired
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.
123 */
124 - (MTeSerialNumberExpirationResult)isExpired;
125
126 - (NSDate *)storedDate;
127
128 - (NSTimeInterval)secondsRemaining;
129
130 - (NSDictionary *)infoDictionary;
131
132 @end