Imported Upstream version 1.0beta3
[platform/upstream/syncevolution.git] / src / synthesis / src / sysync / syserial.h
1 /*
2  *  File:         syserial.h
3  *
4  *  Author:                       Lukas Zeller (luz@synthesis.ch)
5  *
6  *  Serial number generator and checker
7  *
8  *  Copyright (c) 2003-2009 by Synthesis AG (www.synthesis.ch)
9  *
10  *  2003-02-11 : luz : created
11  *
12  */
13
14 #ifndef SYSERIAL_H
15 #define SYSERIAL_H
16
17 #include "generic_types.h"
18 #include <string>
19
20 using namespace std;
21
22 namespace sysync {
23
24
25 // variant codes
26 // =============
27
28 #define SYSER_VARIANT_UNKNOWN 0
29 #define SYSER_VARIANT_STD 1
30 #define SYSER_VARIANT_PRO 2
31 #define SYSER_VARIANT_CUSTOM 3
32 #define SYSER_VARIANT_DEMO 10
33
34
35 // branding codes
36 #define SYSER_EXTRA_ID_NONE 0
37 #define SYSER_EXTRA_ID_PROTO 1
38 #define SYSER_EXTRA_ID_DBG 2
39
40 #define SYSER_EXTRA_ID_GOOSYNC 10 // Toffa.com Goosync special version
41 #define SYSER_EXTRA_ID_FONELINK 11 // novamedia FoneLink special version
42 #define SYSER_EXTRA_ID_SOOCIAL 12 // soocial.com special version
43
44
45 // product codes
46 // =============
47
48 // PDA Clients
49 // - universal codes for all PDA clients = pocketPC codes
50 #define SYSER_PRODCODE_CLIENT_PDA_STD 2 // this is the former PocketPC STD code (most widespread)
51 #define SYSER_PRODCODE_CLIENT_PDA_PRO 5 // this is the former PocketPC PRO code (most widespread)
52
53 // Old platform specific PDA codes (still valid, but no longer required)
54 // - Palm & PPC STD
55 #define SYSER_PRODCODE_CLIENT_PALM_STD 1 // for PalmOS
56 #define SYSER_PRODCODE_CLIENT_PPC_STD  2 // for PocketPC
57 #define SYSER_PRODCODE_CLIENT_PALMPPC_STD  3 // combined for PPC and PalmOS
58 // - Palm & PPC PRO
59 #define SYSER_PRODCODE_CLIENT_PALM_PRO 4 // for PalmOS
60 #define SYSER_PRODCODE_CLIENT_PPC_PRO  5 // for PocketPC
61 #define SYSER_PRODCODE_CLIENT_PALMPPC_PRO  6 // combined for PPC and PalmOS
62 // - Symbian client
63 #define SYSER_PRODCODE_CLIENT_SYMBIAN_STD 18
64 #define SYSER_PRODCODE_CLIENT_SYMBIAN_PRO 19
65 // - Smartphone
66 #define SYSER_PRODCODE_CLIENT_MSSMP_STD 13 // for Microsoft SmartPhone (2003)
67 #define SYSER_PRODCODE_CLIENT_MSSMP_PRO 14 // for Microsoft SmartPhone (2003)
68
69
70 // - ODBC client STD
71 #define SYSER_PRODCODE_CLIENT_ODBC_STD_WIN32 7 // Win32 ODBC PRO
72 #define SYSER_PRODCODE_CLIENT_ODBC_STD_MACOSX 8 // for Mac OS X
73 #define SYSER_PRODCODE_CLIENT_ODBC_STD_LINUX 9 // for Linux
74 // - ODBC client PRO
75 #define SYSER_PRODCODE_CLIENT_ODBC_PRO_WIN32 10 // Win32 ODBC PRO
76 #define SYSER_PRODCODE_CLIENT_ODBC_PRO_MACOSX 11 // for Mac OS X
77 #define SYSER_PRODCODE_CLIENT_ODBC_PRO_LINUX 12 // for Linux
78
79
80 // - Demo client
81 #define SYSER_PRODCODE_CLIENT_DEMO 15 // Demo Client (Text only)
82
83 // - Outlook client
84 #define SYSER_PRODCODE_CLIENT_OUTLOOK_STD               16 // Outlook Client STD
85 #define SYSER_PRODCODE_CLIENT_OUTLOOK_PRO       17 // Outlook Client PRO (with email)
86
87 // - Client Libraries
88 #define SYSER_PRODCODE_CLIENT_LIB_WIN32         18 // Win32 ODBC PRO
89 #define SYSER_PRODCODE_CLIENT_LIB_MACOSX        19 // for Mac OS X
90 #define SYSER_PRODCODE_CLIENT_LIB_LINUX         20 // for Linux
91 #define SYSER_PRODCODE_CLIENT_LIB_SYMBIAN       21 // for Symbian
92 #define SYSER_PRODCODE_CLIENT_LIB_WM            22 // for Windows Mobile
93 #define SYSER_PRODCODE_CLIENT_LIB_PALM          23 // for PALMOS
94 #define SYSER_PRODCODE_CLIENT_LIB_IPHONEOS  28 // iPhone OS
95 #define SYSER_PRODCODE_CLIENT_LIB_ANDROID   40 // Android
96
97
98 #define SYSER_PRODCODE_CLIENT_LIB_ALL           24 // ALL Platforms
99 #define SYSER_PRODCODE_CLIENT_LIB_MOBILE        25 // ALL Mobile Platforms
100 #define SYSER_PRODCODE_CLIENT_LIB_DESK          26 // ALL Desktop Platforms
101
102 #define SYSER_PRODCODE_CLIENT_LIB_DEMO          27 // All DEMO Libraries
103
104
105 // - Client product flags (no flags -> only XPT version allowed)
106 #define SYSER_PRODFLAG_CLIENT_DMU 0x01 // DMU enabled
107 #define SYSER_PRODFLAG_CLIENT_APP 0x02 // App enabled (not only library)
108
109
110 // Servers
111
112 // - Server (=usually unified server+client) Libraries
113 #define SYSER_PRODCODE_SERVER_LIB_WIN32         39 // Win32 ODBC PRO
114 #define SYSER_PRODCODE_SERVER_LIB_MACOSX        29 // for Mac OS X
115 #define SYSER_PRODCODE_SERVER_LIB_LINUX         30 // for Linux
116 #define SYSER_PRODCODE_SERVER_LIB_SYMBIAN       31 // for Symbian
117 #define SYSER_PRODCODE_SERVER_LIB_WM            32 // for Windows Mobile
118 #define SYSER_PRODCODE_SERVER_LIB_PALM          33 // for PALMOS
119 #define SYSER_PRODCODE_SERVER_LIB_IPHONEOS  38 // iPhone OS
120 #define SYSER_PRODCODE_SERVER_LIB_ANDROID   41 // Android
121
122
123 #define SYSER_PRODCODE_SERVER_LIB_ALL           34 // ALL Platforms
124 #define SYSER_PRODCODE_SERVER_LIB_MOBILE        35 // ALL Mobile Platforms
125 #define SYSER_PRODCODE_SERVER_LIB_DESK          36 // ALL Desktop Platforms
126
127 #define SYSER_PRODCODE_SERVER_LIB_DEMO          37 // All DEMO Libraries
128
129 // - Demo
130 #define SYSER_PRODCODE_SERVER_DEMO 50 // Demo Server (Text only)
131 // - ODBC
132 #define SYSER_PRODCODE_SERVER_STD 51 // STD Server (with ODBC)
133 #define SYSER_PRODCODE_SERVER_PRO 52 // PRO Server (with ODBC)
134 // - XML2GO
135 #define SYSER_PRODCODE_SERVER_XML2GO 53 // xml2go Server (with ODBC and XML2GO)
136
137 // - Server product flags (no ISAPI or APACHE flags -> only XPT version allowed)
138 #define SYSER_PRODFLAG_SERVER_ISAPI 0x01 // ISAPI version
139 #define SYSER_PRODFLAG_SERVER_APACHE 0x02 // Apache version
140 #define SYSER_PRODFLAG_SERVER_SDKAPI 0x04 // external DB API plugins allowed
141
142
143 // special flag: if set, time code in license does not specify when temporary
144 // license expires, but for up to what release date (hard-coded into the binary)
145 // this code is valid. This allows to issue time unlimited licenses that will allow
146 // be used with new releases only up to a defined time period after issuing.
147 // If set, the duration bits (encoded absolute month) are no longer the
148 // expiry date, but the max release date supported.
149 // If this bit is set in SYSER_NEEDED_PRODUCT_FLAGS, this means that the
150 // license must either have the bit set, too, or the license must be a
151 // time limited license. Only licenses limited neither in time nor in release
152 // date will be rejected.
153 #define SYSER_PRODFLAG_MAXRELDATE 0x80
154
155
156 // license types
157 #define SYSER_LTYP_STANDARD 0   // standard license, nothing special
158 #define SYSER_LTYP_SYN_REG 1    // requires activation at synthesis
159 #define SYSER_LTYP_S2G_REG 2    // requires activation at space2go
160
161
162 // registration checking URLs
163 #define SYSER_SYN_REG_HOST "www.synthesis.ch"
164 #define SYSER_SYN_REG_DOC  "/reg/"
165 #define SYSER_S2G_REG_HOST "sync.space2go.com"
166 #define SYSER_S2G_REG_DOC  "/reg/"
167
168 // update checking URL
169 #define SYSER_SYN_UDC_HOST "www.synthesis.ch"
170 #define SYSER_SYN_UDC_DOC  "/udc/"
171
172
173
174 // Internals
175 // =========
176
177 // size of serial number
178 #define SYSER_SERIALNUM_SIZE 20 // 4*4 chars, plus 3 dashes, plus one terminator = 16+3+1 = 20
179 #define SYSER_SERIALNUM_MANGLED_SIZE 17 // dashes are optimized away, so 4*4+1 = 17
180 // max size of "name" string (only that much will be stored and tested)
181 #define SYSER_NAMESTRING_MAX 80 // should be enough for name and email
182
183
184 #ifdef LINUX
185 #define SYSER_CRC32_SEED ((uInt32)4119203362LL) // phone Tiefenau :-)
186 #else
187 #define SYSER_CRC32_SEED 4119203362 // phone Tiefenau :-)
188 #endif
189
190 // make sure we don't ever include the generator into a product
191 #ifndef SYSYNC_VERSION_MAJOR
192
193 // generate serial
194 void generateSySerial(
195   char *outbuf, // must be able to receive SYSER_SERIALNUM_SIZE chars (including terminator)
196   uInt8 productflags, uInt16 productcode, uInt8 licensetype, uInt16 quantity, uInt8 duration,
197   const char *name,
198   bool aIprevent
199 );
200
201 #endif
202
203 #if defined SYSER_REGISTRATION || !defined(SYSYNC_VERSION_MAJOR)
204
205 bool getSySerialInfo(
206   const char *input,
207   uInt8 &productflags, uInt16 &productcode, uInt8 &licensetype, uInt16 &quantity, uInt8 &duration,
208   uInt32 &crc, uInt32 &infocrc,
209   bool aMangled=false
210 );
211
212 #endif // SYSER_REGISTRATION
213
214
215 uInt32 addToCrc(uInt32 aCRC, uInt8 aByte);
216 uInt32 addNameToCRC(uInt32 aCRC, const char *aName, bool aMangled=false, uInt16 aMaxChars=32000);
217
218
219
220 } // namespace sysync
221
222 #endif // SYSERIAL_H
223
224 /* eof */