You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ti...@apache.org on 2012/07/19 20:47:12 UTC
webworks commit: echo plugin
Updated Branches:
refs/heads/bbEchoPlugin 5129ae23e -> 8b80a9f50
echo plugin
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/commit/8b80a9f5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/tree/8b80a9f5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/diff/8b80a9f5
Branch: refs/heads/bbEchoPlugin
Commit: 8b80a9f50859948eef23d50b53750bf4d693a7e1
Parents: 5129ae2
Author: Tim Kim <ti...@nitobi.com>
Authored: Thu Jul 19 11:47:02 2012 -0700
Committer: Tim Kim <ti...@nitobi.com>
Committed: Thu Jul 19 11:47:02 2012 -0700
----------------------------------------------------------------------
.../ext/src/org/apache/cordova/echo/Echo.java | 59 +++++++++++++++
1 files changed, 59 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/8b80a9f5/framework/ext/src/org/apache/cordova/echo/Echo.java
----------------------------------------------------------------------
diff --git a/framework/ext/src/org/apache/cordova/echo/Echo.java b/framework/ext/src/org/apache/cordova/echo/Echo.java
new file mode 100644
index 0000000..691c55f
--- /dev/null
+++ b/framework/ext/src/org/apache/cordova/echo/Echo.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ * Copyright (c) 2011, Research In Motion Limited.
+ */
+package org.apache.cordova.echo;
+
+import org.apache.cordova.api.Plugin;
+import org.apache.cordova.api.PluginResult;
+import org.apache.cordova.json4j.JSONArray;
+import org.apache.cordova.json4j.JSONException;
+import org.apache.cordova.json4j.JSONObject;
+import org.apache.cordova.util.Logger;
+/**
+ * A simple plugin to demonstrate how to build a plugin for Blackberry
+ * Basically echos back the msg that a user calls to this plugin
+ */
+public final class Echo extends Plugin {
+
+ public static final String FIELD_VALUE = "value";
+ public static final String DO_ECHO = "doEcho";
+
+ public PluginResult execute(String action, JSONArray args, String callbackId) {
+ PluginResult result = new PluginResult(PluginResult.Status.INVALID_ACTION, "Echo: Invalid action:" + action);
+ if(action.equals(DO_ECHO)){
+ try {
+ JSONObject echoObj = new JSONObject();
+ String theMsg = args.getString(0);
+ if(theMsg.length()>0){
+ echoObj.put(FIELD_VALUE, theMsg);
+ result = new PluginResult(PluginResult.Status.OK, echoObj);
+ }else{
+ echoObj.put(FIELD_VALUE, "Nothing to echo.");
+ result = new PluginResult(PluginResult.Status.ERROR, echoObj);
+ }
+ } catch (JSONException e) {
+ result = new PluginResult(PluginResult.Status.JSON_EXCEPTION, e.getMessage());
+ }
+ }
+
+ return result;
+ }
+
+}