Permalink
Browse files

optionally toggle campfire sounds

  • Loading branch information...
1 parent 7993ac3 commit 57869ffb44a0c45ac1962ff00a9cc5b89b334600 @henrypoydar committed Oct 21, 2011
@@ -26,6 +26,7 @@
private Room room;
private String hudsonUrl;
private boolean smartNotify;
+ private boolean sound;
// getter for project configuration..
// Configured room name should be null unless different from descriptor/global room name
@@ -47,9 +48,9 @@ public CampfireNotifier() throws IOException {
initialize();
}
- public CampfireNotifier(String subdomain, String token, String room, String hudsonUrl, boolean ssl, boolean smartNotify) throws IOException {
+ public CampfireNotifier(String subdomain, String token, String room, String hudsonUrl, boolean ssl, boolean smartNotify, boolean sound) throws IOException {
super();
- initialize(subdomain, token, room, hudsonUrl, ssl, smartNotify);
+ initialize(subdomain, token, room, hudsonUrl, ssl, smartNotify, sound);
}
public BuildStepMonitor getRequiredMonitorService() {
@@ -110,18 +111,20 @@ private void publish(AbstractBuild<?, ?> build) throws IOException {
String resultString = result.toString();
if (!smartNotify && result == Result.SUCCESS) resultString = resultString.toLowerCase();
String message = build.getProject().getName() + " " + build.getDisplayName() + " \"" + changeString + "\": " + resultString;
- String message_sound = "";
- if (resultString == "FAILURE") {
- message_sound = "trombone";
- } else {
- message_sound = "rimshot";
- }
String fail_message = build.getProject().getName() + " " + build.getDisplayName() + " \"" + changeString + "\": " + resultString;
if (hudsonUrl != null && hudsonUrl.length() > 1 && (smartNotify || result != Result.SUCCESS)) {
message = message + " (" + hudsonUrl + build.getUrl() + ")";
}
room.speak(message);
- room.play(message_sound);
+ if (sound) {
+ String message_sound = "";
+ if (resultString == "FAILURE") {
+ message_sound = "trombone";
+ } else {
+ message_sound = "rimshot";
+ }
+ room.play(message_sound);
+ }
}
private void checkCampfireConnection() throws IOException {
@@ -131,10 +134,10 @@ private void checkCampfireConnection() throws IOException {
}
private void initialize() throws IOException {
- initialize(DESCRIPTOR.getSubdomain(), DESCRIPTOR.getToken(), room.getName(), DESCRIPTOR.getHudsonUrl(), DESCRIPTOR.getSsl(), DESCRIPTOR.getSmartNotify());
+ initialize(DESCRIPTOR.getSubdomain(), DESCRIPTOR.getToken(), room.getName(), DESCRIPTOR.getHudsonUrl(), DESCRIPTOR.getSsl(), DESCRIPTOR.getSmartNotify(), DESCRIPTOR.getSound());
}
- private void initialize(String subdomain, String token, String roomName, String hudsonUrl, boolean ssl, boolean smartNotify) throws IOException {
+ private void initialize(String subdomain, String token, String roomName, String hudsonUrl, boolean ssl, boolean smartNotify, boolean sound) throws IOException {
campfire = new Campfire(subdomain, token, ssl);
String exceptionMsg = "Failed to initialize campfire notifier";
try {
@@ -21,6 +21,7 @@
private String hudsonUrl;
private boolean ssl;
private boolean smartNotify;
+ private boolean sound;
public DescriptorImpl() {
super(CampfireNotifier.class);
@@ -55,6 +56,10 @@ public boolean getSmartNotify() {
return smartNotify;
}
+ public boolean getSound() {
+ return sound;
+ }
+
public boolean isApplicable(Class<? extends AbstractProject> aClass) {
return true;
}
@@ -69,7 +74,7 @@ public Publisher newInstance(StaplerRequest req, JSONObject formData) throws For
projectRoom = room;
}
try {
- return new CampfireNotifier(subdomain, token, projectRoom, hudsonUrl, ssl, smartNotify);
+ return new CampfireNotifier(subdomain, token, projectRoom, hudsonUrl, ssl, smartNotify, sound);
} catch (Exception e) {
throw new FormException("Failed to initialize campfire notifier - check your campfire notifier configuration settings", e, "");
}
@@ -87,7 +92,7 @@ public boolean configure(StaplerRequest req, JSONObject json) throws FormExcepti
ssl = req.getParameter("campfireSsl") != null;
smartNotify = req.getParameter("campfireSmartNotify") != null;
try {
- new CampfireNotifier(subdomain, token, room, hudsonUrl, ssl, smartNotify);
+ new CampfireNotifier(subdomain, token, room, hudsonUrl, ssl, smartNotify, sound);
} catch (Exception e) {
throw new FormException("Failed to initialize campfire notifier - check your global campfire notifier configuration settings", e, "");
}
@@ -30,5 +30,8 @@
<f:entry title="Enable Smart Notification" help="${rootURL}/plugin/campfire/help-globalConfig-smartNotify.html">
<f:checkbox name="campfireSmartNotify" checked="${descriptor.getSmartNotify()}" />
</f:entry>
+ <f:entry title="Enable Sounds" help="${rootURL}/plugin/campfire/help-globalConfig-sounds.html">
+ <f:checkbox name="campfireSounds" checked="${descriptor.getSound()}" />
+ </f:entry>
</f:section>
</j:jelly>

0 comments on commit 57869ff

Please sign in to comment.