7ada448cc30d39c9ef1df8c09c85412e399df4ca
[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 // - Server product flags (no flags -> only XPT version allowed)
106 #define SYSER_PRODFLAG_CLIENT_DMU 0x01 // DMU enabled
107
108
109 // Servers
110
111 // - Server Libraries
112 #define SYSER_PRODCODE_SERVER_LIB_WIN32         39 // Win32 ODBC PRO
113 #define SYSER_PRODCODE_SERVER_LIB_MACOSX        29 // for Mac OS X
114 #define SYSER_PRODCODE_SERVER_LIB_LINUX         30 // for Linux
115 #define SYSER_PRODCODE_SERVER_LIB_SYMBIAN       31 // for Symbian
116 #define SYSER_PRODCODE_SERVER_LIB_WM            32 // for Windows Mobile
117 #define SYSER_PRODCODE_SERVER_LIB_PALM          33 // for PALMOS
118 #define SYSER_PRODCODE_SERVER_LIB_IPHONEOS  38 // iPhone OS
119 #define SYSER_PRODCODE_SERVER_LIB_ANDROID   41 // Android
120
121
122 #define SYSER_PRODCODE_SERVER_LIB_ALL           34 // ALL Platforms
123 #define SYSER_PRODCODE_SERVER_LIB_MOBILE        35 // ALL Mobile Platforms
124 #define SYSER_PRODCODE_SERVER_LIB_DESK          36 // ALL Desktop Platforms
125
126 #define SYSER_PRODCODE_SERVER_LIB_DEMO          37 // All DEMO Libraries
127
128 // - Demo
129 #define SYSER_PRODCODE_SERVER_DEMO 50 // Demo Server (Text only)
130 // - ODBC
131 #define SYSER_PRODCODE_SERVER_STD 51 // STD Server (with ODBC)
132 #define SYSER_PRODCODE_SERVER_PRO 52 // PRO Server (with ODBC)
133 // - XML2GO
134 #define SYSER_PRODCODE_SERVER_XML2GO 53 // xml2go Server (with ODBC and XML2GO)
135
136 // - Server product flags (no ISAPI or APACHE flags -> only XPT version allowed)
137 #define SYSER_PRODFLAG_SERVER_ISAPI 0x01 // ISAPI version
138 #define SYSER_PRODFLAG_SERVER_APACHE 0x02 // Apache version
139 #define SYSER_PRODFLAG_SERVER_SDKAPI 0x04 // external DB API plugins allowed
140
141
142 // special flag: if set, time code in license does not specify when temporary
143 // license expires, but for up to what release date (hard-coded into the binary)
144 // this code is valid. This allows to issue time unlimited licenses that will allow
145 // be used with new releases only up to a defined time period after issuing.
146 // If set, the duration bits (encoded absolute month) are no longer the
147 // expiry date, but the max release date supported.
148 // If this bit is set in SYSER_NEEDED_PRODUCT_FLAGS, this means that the
149 // license must either have the bit set, too, or the license must be a
150 // time limited license. Only licenses limited neither in time nor in release
151 // date will be rejected.
152 #define SYSER_PRODFLAG_MAXRELDATE 0x80
153
154
155 // license types
156 #define SYSER_LTYP_STANDARD 0   // standard license, nothing special
157 #define SYSER_LTYP_SYN_REG 1    // requires activation at synthesis
158 #define SYSER_LTYP_S2G_REG 2    // requires activation at space2go
159
160
161 // registration checking URLs
162 #define SYSER_SYN_REG_HOST "www.synthesis.ch"
163 #define SYSER_SYN_REG_DOC  "/reg/"
164 #define SYSER_S2G_REG_HOST "sync.space2go.com"
165 #define SYSER_S2G_REG_DOC  "/reg/"
166
167 // update checking URL
168 #define SYSER_SYN_UDC_HOST "www.synthesis.ch"
169 #define SYSER_SYN_UDC_DOC  "/udc/"
170
171
172
173 // Internals
174 // =========
175
176 // size of serial number
177 #define SYSER_SERIALNUM_SIZE 20 // 4*4 chars, plus 3 dashes, plus one terminator = 16+3+1 = 20
178 #define SYSER_SERIALNUM_MANGLED_SIZE 17 // dashes are optimized away, so 4*4+1 = 17
179 // max size of "name" string (only that much will be stored and tested)
180 #define SYSER_NAMESTRING_MAX 80 // should be enough for name and email
181
182
183 #ifdef LINUX
184 #define SYSER_CRC32_SEED ((uInt32)4119203362LL) // phone Tiefenau :-)
185 #else
186 #define SYSER_CRC32_SEED 4119203362 // phone Tiefenau :-)
187 #endif
188
189 // make sure we don't ever include the generator into a product
190 #ifndef SYSYNC_VERSION_MAJOR
191
192 // generate serial
193 void generateSySerial(
194   char *outbuf, // must be able to receive SYSER_SERIALNUM_SIZE chars (including terminator)
195   uInt8 productflags, uInt16 productcode, uInt8 licensetype, uInt16 quantity, uInt8 duration,
196   const char *name,
197   bool aIprevent
198 );
199
200 #endif
201
202 #if defined SYSER_REGISTRATION || !defined(SYSYNC_VERSION_MAJOR)
203
204 bool getSySerialInfo(
205   const char *input,
206   uInt8 &productflags, uInt16 &productcode, uInt8 &licensetype, uInt16 &quantity, uInt8 &duration,
207   uInt32 &crc, uInt32 &infocrc,
208   bool aMangled=false
209 );
210
211 #endif // SYSER_REGISTRATION
212
213
214 uInt32 addToCrc(uInt32 aCRC, uInt8 aByte);
215 uInt32 addNameToCRC(uInt32 aCRC, const char *aName, bool aMangled=false, uInt16 aMaxChars=32000);
216
217
218
219 } // namespace sysync
220
221 #endif // SYSERIAL_H
222
223 /* eof */