Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

- Prowl: Proposed change to allow multiple API keys to be supported #8

Merged
merged 1 commit into from
Sep 25, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,28 @@ public static boolean doProwl(@ParamDoc(name="something", text="the something to
static int priority = 0;


/**
* Pushes a Prowl notification with the configured api
* key and takes the default priority into account
*
* @param subject the subject of the notification
* @param message the message of the notification
*
* @return <code>true</code>, if pushing the notification has been successful
* and <code>false</code> in all other cases.
*/
@ActionDoc(text="Pushes a Prowl notification and takes the default priority into account",
returns="<code>true</code>, if successful and <code>false</code> otherwise.")
static public boolean pushNotification(
@ParamDoc(name="subject", text = "subject the subject of the notification.") String subject,
@ParamDoc(name="message", text = "message the message of the notification.") String message) {
return pushNotification(Prowl.apiKey, subject, message, Prowl.priority);
}

/**
* Pushes a Prowl notification and takes the default priority into account
*
* @param apiKey apiKey to use for the notification
* @param subject the subject of the notification
* @param message the message of the notification
*
Expand All @@ -82,14 +101,16 @@ public static boolean doProwl(@ParamDoc(name="something", text="the something to
@ActionDoc(text="Pushes a Prowl notification and takes the default priority into account",
returns="<code>true</code>, if successful and <code>false</code> otherwise.")
static public boolean pushNotification(
@ParamDoc(name="subject") String subject,
@ParamDoc(name="message") String message) {
return pushNotification(subject, message, Prowl.priority);
@ParamDoc(name="apiKey", text = "apiKey to use for the notification.") String apiKey,
@ParamDoc(name="subject", text = "subject the subject of the notification.") String subject,
@ParamDoc(name="message", text = "message the message of the notification.") String message) {
return pushNotification(apiKey, subject, message, Prowl.priority);
}

/**
* Pushes a Prowl notification
*
* @param apiKey apiKey to use for the notification
* @param subject the subject of the notification
* @param message the message of the notification
* @param priority the priority of the notification (a value between
Expand All @@ -101,9 +122,10 @@ static public boolean pushNotification(
@ActionDoc(text="Pushes a Prowl notification",
returns="<code>true</code>, if successful and <code>false</code> otherwise.")
static public boolean pushNotification(
@ParamDoc(name="subject") String subject,
@ParamDoc(name="message") String message,
@ParamDoc(name="priority") int priority) {
@ParamDoc(name="apiKey", text = "apiKey to use for the notification.") String apiKey,
@ParamDoc(name="subject", text = "the subject of the notification.") String subject,
@ParamDoc(name="message", text = "the message of the notification.") String message,
@ParamDoc(name="priority", text = "the priority of the notification (a value between '-2' and '2'.") int priority) {
boolean success = false;

int normalizedPriority = priority;
Expand All @@ -122,7 +144,7 @@ static public boolean pushNotification(
}

ProwlEvent event = new DefaultProwlEvent(
Prowl.apiKey, "openhab", subject,
apiKey, "openhab", subject,
message, normalizedPriority);

try {
Expand All @@ -137,7 +159,7 @@ static public boolean pushNotification(
} else {
logger.error("Cannot push Prowl notification because of missing configuration settings. The current settings are: " +
"apiKey: '{}', priority: {}, url: '{}'",
new String[] { apiKey, String.valueOf(normalizedPriority), url} );
new Object[] { apiKey, String.valueOf(normalizedPriority), url} );
}

return success;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
import org.openhab.core.scriptengine.action.ActionService;
import org.osgi.service.cm.ConfigurationException;
import org.osgi.service.cm.ManagedService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
Expand Down