|
5 | 5 | * is opened. It contains the initial connection properties, and the protocol |
6 | 6 | * number. |
7 | 7 | * |
8 | | - * @copyright 2014 - 2022 Copernica BV |
| 8 | + * @copyright 2014 - 2023 Copernica BV |
9 | 9 | */ |
10 | 10 |
|
| 11 | +/** |
| 12 | + * Dependencies |
| 13 | + */ |
| 14 | +#if !defined(_WIN32) && !defined(_WIN64) |
| 15 | +#include "programname.h" |
| 16 | +#include "platformname.h" |
| 17 | +#endif |
| 18 | + |
| 19 | +/** |
| 20 | + * Cause we want to print out version string that is passed to compiled with -D |
| 21 | + * flag. Why 2 macros? https://www.guyrutenberg.com/2008/12/20/expanding-macros-into-string-constants-in-c/ |
| 22 | + */ |
| 23 | +#define STR_EXPAND(s) #s |
| 24 | +#define STR(s) STR_EXPAND(s) |
| 25 | + |
| 26 | +/** |
| 27 | + * The version and distro names |
| 28 | + */ |
| 29 | +#define VERSION_NAME STR(VERSION) |
| 30 | + |
11 | 31 | /** |
12 | 32 | * Set up namespace |
13 | 33 | */ |
@@ -200,19 +220,28 @@ class ConnectionStartFrame : public ConnectionFrame |
200 | 220 | capabilities["consumer_cancel_notify"] = true; |
201 | 221 |
|
202 | 222 | // fill the peer properties |
203 | | - if (!properties.contains("product")) properties["product"] = "Copernica AMQP library"; |
204 | | - if (!properties.contains("version")) properties["version"] = "Unknown"; |
205 | | - if (!properties.contains("platform")) properties["platform"] = "Unknown"; |
206 | | - if (!properties.contains("copyright")) properties["copyright"] = "Copyright 2015 - 2018 Copernica BV"; |
207 | | - if (!properties.contains("information")) properties["information"] = "https://www.copernica.com"; |
| 223 | + if (!properties.contains("version")) properties["version"] = "AMQP-CPP " VERSION_NAME; |
| 224 | + if (!properties.contains("copyright")) properties["copyright"] = "Copernica AMQP-CPP library :: Copyright 2015-2023 Copernica BV"; |
| 225 | + if (!properties.contains("information")) properties["information"] = "https://github.com/CopernicaMarketingSoftware/AMQP-CPP"; |
208 | 226 | if (!properties.contains("capabilities")) properties["capabilities"] = capabilities; |
209 | | - |
| 227 | + |
| 228 | +#if defined(_WIN32) || defined(_WIN64) |
| 229 | + // i don't know that much about win32, so let's use hardcoded string |
| 230 | + if (!properties.contains("product")) properties["product"] = "application based on AMQP-CPP"; |
| 231 | + if (!properties.contains("platform")) properties["platform"] = "windows"; |
| 232 | +#else |
| 233 | + // on unix-like systems I know how to retrieve application and platform info |
| 234 | + if (!properties.contains("product")) properties["product"] = ProgramName(); |
| 235 | + if (!properties.contains("platform")) properties["platform"] = PlatformName(); |
| 236 | +#endif |
| 237 | + |
210 | 238 | // send back a connection start ok frame |
211 | 239 | connection->send(ConnectionStartOKFrame(properties, "PLAIN", connection->login().saslPlain(), "en_US")); |
212 | 240 |
|
213 | 241 | // done |
214 | 242 | return true; |
215 | 243 | } |
| 244 | + |
216 | 245 | }; |
217 | 246 |
|
218 | 247 | /** |
|
0 commit comments