comparison mcabber/src/jab_iq.c @ 1218:ab5de2ed2b7e

Simplify entity_version()
author Mikael Berthe <mikael@lilotux.net>
date Tue, 08 May 2007 11:41:17 +0200
parents 21226969d59a
children fb0460a3cf4b
comparison
equal deleted inserted replaced
1217:21226969d59a 1218:ab5de2ed2b7e
102 {NULL, NULL, NULL}, 102 {NULL, NULL, NULL},
103 }; 103 };
104 104
105 // entity_version() 105 // entity_version()
106 // Return a static version string for Entity Capabilities. 106 // Return a static version string for Entity Capabilities.
107 // It should be specific to the client version, so we'll append 107 // It should be specific to the client version, please change the id
108 // a random string if it's a dev version and there's no changeset, or 108 // if you alter mcabber's disco support (or add something to the version
109 // if it's been modified locally. 109 // number) so that it doesn't conflict with the official client.
110 const char *entity_version(void) 110 const char *entity_version(void)
111 { 111 {
112 static char *ver; 112 static char *ver;
113 char *tver;
114 113
115 if (ver) 114 if (ver)
116 return ver; 115 return ver;
117 116
118 #ifdef HGCSET 117 #ifdef HGCSET
119 tver = g_strdup_printf("%s-%s", PACKAGE_VERSION, HGCSET); 118 ver = g_strdup_printf("%s-%s", PACKAGE_VERSION, HGCSET);
120 if (strlen(HGCSET) == 12)
121 ver = tver;
122 #else 119 #else
123 tver = g_strdup(PACKAGE_VERSION); 120 ver = g_strdup(PACKAGE_VERSION);
124 if (!strcasestr(PACKAGE_VERSION, "-dev"))
125 ver = tver; // Official release
126 #endif 121 #endif
127 122
128 // If this isn't an official release, or if the changeset shows the source
129 // code has been modified locally, we alter the release id.
130 if (!ver) {
131 unsigned int n;
132 srand(time(NULL));
133 n = (unsigned int)(10.0 + 6.0 * rand() / (RAND_MAX + 1.0));
134 ver = g_strdup_printf("%s~%x", tver, n);
135 g_free(tver);
136 }
137 return ver; 123 return ver;
138 } 124 }
139 125
140 // iqs_new(type, namespace, prefix, timeout) 126 // iqs_new(type, namespace, prefix, timeout)
141 // Create a query (GET, SET) IQ structure. This function should not be used 127 // Create a query (GET, SET) IQ structure. This function should not be used
1314 1300
1315 // disco_info_set_default(ansquery, entitycaps) 1301 // disco_info_set_default(ansquery, entitycaps)
1316 // Add features attributes to ansquery. If entitycaps is TRUE, assume 1302 // Add features attributes to ansquery. If entitycaps is TRUE, assume
1317 // that we're answering an Entity Caps request (if not, the request was 1303 // that we're answering an Entity Caps request (if not, the request was
1318 // a basic discovery query). 1304 // a basic discovery query).
1305 // Please change the entity version string if you modify mcabber disco
1306 // source code, so that it doesn't conflict with the upstream client.
1319 static void disco_info_set_default(xmlnode ansquery, guint entitycaps) 1307 static void disco_info_set_default(xmlnode ansquery, guint entitycaps)
1320 { 1308 {
1321 xmlnode y; 1309 xmlnode y;
1322 char *eversion; 1310 char *eversion;
1323 1311