1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
|
/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.version;
import net.java.sip.communicator.util.*;
import org.jitsi.service.resources.*;
import org.jitsi.service.version.*;
/**
* A static implementation of the Version interface.
*/
public class VersionImpl
implements Version
{
/**
* The version major of the current SIP Communicator version. In an
* example 2.3.1 version string 2 is the version major. The version major
* number changes when a relatively extensive set of new features and
* possibly rearchitecturing have been applied to the SIP Communicator.
*/
public static final int VERSION_MAJOR = 1;
/**
* The version major of the current SIP Communicator version. In an
* example 2.3.1 version string 2 is the version major. The version major
* number changes when a relatively extensive set of new features and
* possibly rearchitecturing have been applied to the SIP Communicator.
*/
public static final int VERSION_MINOR = 1;
/**
* Indicates whether this version represents a prerelease (i.e. a
* non-complete release like an alpha, beta or release candidate version).
*/
public static final boolean IS_PRE_RELEASE_VERSION = false;
/**
* Returns the version prerelease ID of the current SIP Communicator version
* and null if this version is not a prerelease. Version pre-release id-s
* and version revisions are exclusive, so in case this version is a pre-
* release the revision will bereturn null.
*/
public static final String PRE_RELEASE_ID = "beta1";
/**
* Indicates if this SIP Communicator version corresponds to a nightly build
* of a repository snapshot or to an official SIP Communicator release.
*/
public static final boolean IS_NIGHTLY_BUILD = true;
/**
* The default name of this application.
*/
public static final String DEFAULT_APPLICATION_NAME = "Jitsi";
/**
* The name of this application.
*/
private static String applicationName = null;
/**
* Returns the VersionImpl instance describing the current version of
* SIP Communicator.
*/
public static final VersionImpl CURRENT_VERSION = new VersionImpl();
/**
* Returns the version major of the current SIP Communicator version. In an
* example 2.3.1 version string 2 is the version major. The version major
* number changes when a relatively extensive set of new features and
* possibly rearchitecturing have been applied to the SIP Communicator.
*
* @return the version major String.
*/
public int getVersionMajor()
{
return VERSION_MAJOR;
}
/**
* Returns the version minor of the current SIP Communicator version. In an
* example 2.3.1 version string 3 is the version minor. The version minor
* number changes after adding enhancements and possibly new features to a
* given SIP Communicator version.
*
* @return the version minor integer.
*/
public int getVersionMinor()
{
return VERSION_MINOR;
}
/**
* Returns the version revision number of the current SIP Communicator
* version. In an example 2.3.1 version string 1 is the revision number.
* The version revision number number changes after applying bug fixes and
* possible some small enhancements to a given SIP Communicator version.
*
* @return the version revision number or -1 if this version of
* SIP Communicator corresponds to a pre-release.
*/
public int getVersionRevision()
{
if(isPreRelease())
return -1;
try
{
return Integer.valueOf(RevisionID.REVISION_ID);
} catch (NumberFormatException numberFormatException)
{
// if we cannot parse the revision number return -1, so we skip it
return -1;
}
}
/**
* Indicates if this SIP Communicator version corresponds to a nightly build
* of a repository snapshot or to an official SIP Communicator release.
*
* @return true if this is a build of a nightly repository snapshot and
* false if this is an official SIP Communicator release.
*/
public boolean isNightly()
{
return IS_NIGHTLY_BUILD;
}
/**
* If this is a nightly build, returns the build identifies (e.g.
* nightly-2007.12.07-06.45.17). If this is not a nightly build SIP
* Communicator version, the method returns null.
*
* @return a String containing a nightly build identifier or null if this is
* a release version and therefore not a nightly build
*/
public String getNightlyBuildID()
{
if(!isNightly())
return null;
return NightlyBuildID.BUILD_ID;
}
/**
* Indicates whether this version represents a prerelease (i.e. a
* non-complete release like an alpha, beta or release candidate version).
* @return true if this version represents a prerelease and false otherwise.
*/
public boolean isPreRelease()
{
return IS_PRE_RELEASE_VERSION;
}
/**
* Returns the version prerelease ID of the current SIP Communicator version
* and null if this version is not a prerelease. Version pre-release id-s
* and version revisions are exclusive, so in case this version is a pre-
* release the revision will bereturn null
*
* @return a String containing the version prerelease ID.
*/
public String getPreReleaseID()
{
if(!isPreRelease())
return null;
return PRE_RELEASE_ID;
}
/**
* Compares another <tt>Version</tt> object to this one and returns a
* negative, zero or a positive integer if this version instance represents
* respectively an earlier, same, or later version as the one indicated
* by the <tt>version</tt> parameter.
*
* @param version the <tt>Version</tt> instance that we'd like to compare
* to this one.
*
* @return a negative integer, zero, or a positive integer as this object
* represents a version that is earlier, same, or more recent than the one
* referenced by the <tt>version</tt> parameter.
*/
public int compareTo(Version version)
{
//our versioning system is built to produce lexicographically ordered
//names so we could simply return the comparison of the version strings.
return toString().compareTo( (version == null)
? "null"
: version.toString());
}
/**
* Compares the <tt>version</tt> parameter to this version and returns true
* if and only if both reference the same SIP Communicator version and
* false otherwise.
*
* @param version the version instance that we'd like to compare with this
* one.
* @return true if and only the version param references the same
* SIP Communicator version as this Version instance and false otherwise.
*/
public boolean equals(Object version)
{
//simply compare the version strings
return toString().equals( (version == null)
? "null"
: version.toString());
}
/**
* Returns a String representation of this Version instance in the generic
* form of major.minor.revision[.nightly.build.id]. If you'd just
* like to obtain the version of SIP Communicator so that you could display
* it (e.g. in a Help->About dialog) then all you need is calling this
* method.
*
* @return a major.minor.revision[.build] String containing the complete
* SIP Communicator version.
*/
public String toString()
{
StringBuffer versionStringBuff = new StringBuffer();
versionStringBuff.append(Integer.toString(getVersionMajor()));
versionStringBuff.append(".");
versionStringBuff.append(Integer.toString(getVersionMinor()));
if(isPreRelease())
{
versionStringBuff.append("-");
versionStringBuff.append(getPreReleaseID());
}
else
{
int rev = getVersionRevision();
if(rev >= 0)
{
versionStringBuff.append(".");
versionStringBuff.append(Integer.toString(rev));
}
}
if(isNightly())
{
versionStringBuff.append("-");
versionStringBuff.append(getNightlyBuildID());
}
return versionStringBuff.toString();
}
/**
* Returns the VersionImpl instance describing the current version of
* SIP Communicator.
*
* @return the VersionImpl instance describing the current version of
* SIP Communicator.
*/
public static final VersionImpl currentVersion()
{
return CURRENT_VERSION;
}
/**
* Returns the name of the application that we're currently running. Default
* MUST be SIP Communicator.
*
* @return the name of the application that we're currently running. Default
* MUST be SIP Communicator.
*/
public String getApplicationName()
{
if (applicationName == null)
{
try
{
/*
* XXX There is no need to have the ResourceManagementService
* instance as a static field of the VersionImpl class because
* it will be used once only anyway.
*/
ResourceManagementService resources
= ServiceUtils.getService(
VersionActivator.getBundleContext(),
ResourceManagementService.class);
if (resources != null)
{
applicationName
= resources.getSettingsString(
"service.gui.APPLICATION_NAME");
}
}
catch (Exception e)
{
// if resource bundle is not found or the key is missing
// return the default name
}
finally
{
if (applicationName == null)
applicationName = DEFAULT_APPLICATION_NAME;
}
}
return applicationName;
}
}
|