108 return; |
108 return; |
109 } |
109 } |
110 |
110 |
111 // Verify license info... |
111 // Verify license info... |
112 QString licenseKey = licenseInfo["LICENSEKEYEXT"]; |
112 QString licenseKey = licenseInfo["LICENSEKEYEXT"]; |
113 const char * clicenseKey = licenseKey.toLatin1(); |
113 QByteArray clicenseKey = licenseKey.toLatin1(); |
114 //We check the licence |
114 //We check the licence |
115 #ifndef _WIN32_WCE |
|
116 char *buffer = strdup(clicenseKey); |
|
117 #else |
|
118 char *buffer = (char*) malloc(strlen(clicenseKey) + 1); |
|
119 strcpy(buffer, clicenseKey); |
|
120 #endif |
|
121 static const char * const SEP = "-"; |
115 static const char * const SEP = "-"; |
122 char *licenseParts[NUMBER_OF_PARTS]; |
116 char *licenseParts[NUMBER_OF_PARTS]; |
123 int partNumber = 0; |
117 int partNumber = 0; |
124 for (char *part = strtok(buffer, SEP); part != 0; part = strtok(0, SEP)) |
118 for (char *part = strtok(clicenseKey.data(), SEP); part != 0; part = strtok(0, SEP)) |
125 licenseParts[partNumber++] = part; |
119 licenseParts[partNumber++] = part; |
126 if (partNumber < (NUMBER_OF_PARTS-1)) { |
120 if (partNumber < (NUMBER_OF_PARTS-1)) { |
127 dictionary["DONE"] = "error"; |
121 dictionary["DONE"] = "error"; |
128 cout << "License file does not contain proper license key." <<partNumber<< endl; |
122 cout << "License file does not contain proper license key." <<partNumber<< endl; |
129 free(buffer); |
|
130 return; |
123 return; |
131 } |
124 } |
132 |
125 |
133 char products = licenseParts[0][0]; |
126 char products = licenseParts[0][0]; |
134 char platforms = licenseParts[1][0]; |
127 char* platforms = licenseParts[1]; |
135 char* licenseSchema = licenseParts[2]; |
128 char* licenseSchema = licenseParts[2]; |
136 char licenseFeatures = licenseParts[3][0]; |
129 char licenseFeatures = licenseParts[3][0]; |
137 |
130 |
138 // Determine edition --------------------------------------------------------------------------- |
131 // Determine edition --------------------------------------------------------------------------- |
139 QString licenseType; |
132 QString licenseType; |
147 dictionary["QT_EDITION"] = "QT_EDITION_DESKTOP"; |
140 dictionary["QT_EDITION"] = "QT_EDITION_DESKTOP"; |
148 } else { |
141 } else { |
149 dictionary["EDITION"] = "GUIFramework"; |
142 dictionary["EDITION"] = "GUIFramework"; |
150 dictionary["QT_EDITION"] = "QT_EDITION_DESKTOPLIGHT"; |
143 dictionary["QT_EDITION"] = "QT_EDITION_DESKTOPLIGHT"; |
151 } |
144 } |
152 |
|
153 if (platforms == 'X') { |
|
154 dictionary["LICENSE_EXTENSION"] = "-ALLOS"; |
|
155 } else if (strchr("2346789ABCDEGHJKMPQSTUVWX", platforms)) { |
|
156 dictionary["LICENSE_EXTENSION"] = "-EMBEDDED"; |
|
157 } else if (strchr("4BFPQRTY", platforms)) { |
|
158 dictionary["LICENSE_EXTENSION"] = "-DESKTOP"; |
|
159 } |
|
160 } else if (strcmp(licenseSchema,"Z4M") == 0 || strcmp(licenseSchema,"R4M") == 0 || strcmp(licenseSchema,"Q4M") == 0) { |
145 } else if (strcmp(licenseSchema,"Z4M") == 0 || strcmp(licenseSchema,"R4M") == 0 || strcmp(licenseSchema,"Q4M") == 0) { |
161 if (products == 'B') { |
146 if (products == 'B') { |
162 dictionary["EDITION"] = "Evaluation"; |
147 dictionary["EDITION"] = "Evaluation"; |
163 dictionary["QT_EDITION"] = "QT_EDITION_EVALUATION"; |
148 dictionary["QT_EDITION"] = "QT_EDITION_EVALUATION"; |
164 dictionary["LICENSE_EXTENSION"] = "-EVALUATION"; |
149 } |
165 } |
150 } |
166 } |
151 |
|
152 if (platforms[2] == 'L') { |
|
153 static const char src[] = "8NPQRTZ"; |
|
154 static const char dst[] = "UCWX9M7"; |
|
155 const char *p = strchr(src, platforms[1]); |
|
156 platforms[1] = dst[p - src]; |
|
157 } |
|
158 |
|
159 #define PL(a,b) (int(a)+int(b)*256) |
|
160 int platformCode = PL(platforms[0],platforms[1]); |
|
161 switch (platformCode) { |
|
162 case PL('X','9'): |
|
163 case PL('X','C'): |
|
164 case PL('X','U'): |
|
165 case PL('X','W'): |
|
166 case PL('X','M'): // old license key |
|
167 dictionary["LICENSE_EXTENSION"] = "-ALLOS"; |
|
168 break; |
|
169 |
|
170 case PL('6', 'M'): |
|
171 case PL('8', 'M'): |
|
172 case PL('K', 'M'): // old license key |
|
173 case PL('N', '7'): |
|
174 case PL('N', '9'): |
|
175 case PL('N', 'X'): |
|
176 case PL('S', '9'): |
|
177 case PL('S', 'C'): |
|
178 case PL('S', 'U'): |
|
179 case PL('S', 'W'): |
|
180 dictionary["LICENSE_EXTENSION"] = "-EMBEDDED"; |
|
181 if (dictionary["PLATFORM NAME"].contains("Windows CE") |
|
182 && platformCode != PL('6', 'M') && platformCode != PL('S', '9') |
|
183 && platformCode != PL('S', 'C') && platformCode != PL('S', 'U') |
|
184 && platformCode != PL('S', 'W') && platformCode != PL('K', 'M')) { |
|
185 dictionary["DONE"] = "error"; |
|
186 } else if (dictionary["PLATFORM NAME"].contains("Symbian") |
|
187 && platformCode != PL('N', '9') && platformCode != PL('S', '9') |
|
188 && platformCode != PL('S', 'C') && platformCode != PL('S', 'U') |
|
189 && platformCode != PL('S', 'W')) { |
|
190 dictionary["DONE"] = "error"; |
|
191 } |
|
192 break; |
|
193 case PL('R', 'M'): |
|
194 case PL('F', 'M'): |
|
195 dictionary["LICENSE_EXTENSION"] = "-DESKTOP"; |
|
196 if (!dictionary["PLATFORM NAME"].endsWith("Windows")) { |
|
197 dictionary["DONE"] = "error"; |
|
198 } |
|
199 break; |
|
200 default: |
|
201 dictionary["DONE"] = "error"; |
|
202 break; |
|
203 } |
|
204 #undef PL |
|
205 |
|
206 if (dictionary.value("DONE") == "error") { |
|
207 cout << "You are not licensed for the " << dictionary["PLATFORM NAME"] << " platform." << endl << endl; |
|
208 cout << "Please contact qt-info@nokia.com to upgrade your license" << endl; |
|
209 cout << "to include the " << dictionary["PLATFORM NAME"] << " platform, or install the" << endl; |
|
210 cout << "Qt Open Source Edition if you intend to develop free software." << endl; |
|
211 return; |
|
212 } |
|
213 |
|
214 // Override for evaluation licenses |
|
215 if (dictionary["Edition"] == "Evaluation") |
|
216 dictionary["LICENSE_EXTENSION"] = "-EVALUATION"; |
167 |
217 |
168 if (QFile::exists(dictionary["QT_SOURCE_TREE"] + "/.LICENSE")) { |
218 if (QFile::exists(dictionary["QT_SOURCE_TREE"] + "/.LICENSE")) { |
169 // Generic, no-suffix license |
219 // Generic, no-suffix license |
170 dictionary["LICENSE_EXTENSION"] = QString(); |
220 dictionary["LICENSE_EXTENSION"] = QString(); |
171 } else if (dictionary["LICENSE_EXTENSION"].isEmpty()) { |
221 } else if (dictionary["LICENSE_EXTENSION"].isEmpty()) { |
178 cout << "License file does not contain proper license key." << endl; |
228 cout << "License file does not contain proper license key." << endl; |
179 dictionary["DONE"] = "error"; |
229 dictionary["DONE"] = "error"; |
180 return; |
230 return; |
181 } |
231 } |
182 |
232 |
183 if (dictionary["PLATFORM NAME"].contains("Windows CE")) { |
|
184 // verify that we are licensed to use Qt for Windows CE |
|
185 if (dictionary["LICENSE_EXTENSION"] != "-EMBEDDED" && dictionary["LICENSE_EXTENSION"] != "-ALLOS") { |
|
186 cout << "You are not licensed for the " << dictionary["PLATFORM NAME"] << " platform." << endl << endl; |
|
187 cout << "Please contact qt-info@nokia.com to upgrade your license" << endl; |
|
188 cout << "to include the " << dictionary["PLATFORM NAME"] << " platform, or install the" << endl; |
|
189 cout << "Qt Open Source Edition if you intend to develop free software." << endl; |
|
190 dictionary["DONE"] = "error"; |
|
191 return; |
|
192 } |
|
193 } |
|
194 |
|
195 // copy one of .LICENSE-*(-US) to LICENSE |
233 // copy one of .LICENSE-*(-US) to LICENSE |
196 QString toLicenseFile = dictionary["QT_SOURCE_TREE"] + "/LICENSE"; |
234 QString toLicenseFile = dictionary["QT_SOURCE_TREE"] + "/LICENSE"; |
197 QString fromLicenseFile = dictionary["QT_SOURCE_TREE"] + "/.LICENSE" + dictionary["LICENSE_EXTENSION"]; |
235 QString fromLicenseFile = dictionary["QT_SOURCE_TREE"] + "/.LICENSE" + dictionary["LICENSE_EXTENSION"]; |
198 if (licenseFeatures == 'G') //US |
236 if (licenseFeatures == 'B' || licenseFeatures == 'G' |
|
237 || licenseFeatures == 'L' || licenseFeatures == 'Y') |
199 fromLicenseFile += "-US"; |
238 fromLicenseFile += "-US"; |
200 |
|
201 if (licenseFeatures == '5') //Floating |
|
202 dictionary["METERED LICENSE"] = "true"; |
|
203 |
239 |
204 if (!CopyFile((wchar_t*)QDir::toNativeSeparators(fromLicenseFile).utf16(), |
240 if (!CopyFile((wchar_t*)QDir::toNativeSeparators(fromLicenseFile).utf16(), |
205 (wchar_t*)QDir::toNativeSeparators(toLicenseFile).utf16(), FALSE)) { |
241 (wchar_t*)QDir::toNativeSeparators(toLicenseFile).utf16(), FALSE)) { |
206 cout << "Failed to copy license file (" << fromLicenseFile << ")"; |
242 cout << "Failed to copy license file (" << fromLicenseFile << ")"; |
207 dictionary["DONE"] = "error"; |
243 dictionary["DONE"] = "error"; |
208 return; |
244 return; |
209 } |
245 } |
210 dictionary["LICENSE FILE"] = toLicenseFile; |
246 dictionary["LICENSE FILE"] = toLicenseFile; |
211 free(buffer); |
|
212 } |
247 } |
213 |
248 |