Skip to content
This repository has been archived by the owner on Sep 4, 2019. It is now read-only.

Message Plugin #357

Merged
merged 5 commits into from Jan 17, 2015
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions BB10-Cordova/MessageRetrieve/README.md
@@ -0,0 +1,24 @@
Message Plugin For Blackberry 10
===============================================

Plugin for retrieving a message body knowing account ID and message ID. These information comes to the application with the invocation data.

Example : getting a body of the email message, action invoked by SHARE from the hub.

```javascript
var json = base64.decode(invokedInfo.data);
if (community && community.messageplugin) {
json=eval("(" + json + ')');
json=community.messageplugin.getEmailMessage(json.attributes.accountid+" "+json.attributes.messageid);
console.log(json);
json=eval("(" + json + ')');
console.log(json.body);
}
```




#DISCLAIMER
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

16 changes: 16 additions & 0 deletions BB10-Cordova/MessageRetrieve/plugin/plugin.xml
@@ -0,0 +1,16 @@
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
id="community.messageplugin"
version="1.0.0">
<js-module src="www/client.js">
<clobbers target="community.messageplugin" />
</js-module>

<platform name="blackberry10">
<source-file src="src/blackberry10/index.js" />
<lib-file src="src/blackberry10/native/device/libMessageplugin.so" arch="device"/>
<lib-file src="src/blackberry10/native/simulator/libMessageplugin.so" arch="simulator"/>
<config-file target="www/config.xml" parent="/widget">
<feature name="community.messageplugin" value="community.messageplugin" />
</config-file>
</platform>
</plugin>
94 changes: 94 additions & 0 deletions BB10-Cordova/MessageRetrieve/plugin/src/blackberry10/index.js
@@ -0,0 +1,94 @@
/*
* Copyright (c) 2013 BlackBerry Limited
*
* Licensed 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.
*/

var message,
resultObjs = {},
threadCallback = null,
_utils = require("../../lib/utils");

module.exports = {

// Code can be declared and used outside the module.exports object,
// but any functions to be called by client.js need to be declared
// here in this object.

// These methods call into JNEXT.Message which handles the
// communication through the JNEXT plugin to message_js.cpp
ping: function (success, fail, args, env) {
var result = new PluginResult(args, env);
result.ok(message.getInstance().ping(), false);
},
getEmailMessage: function (success, fail, args, env) {
var result = new PluginResult(args, env);
args = JSON.parse(decodeURIComponent(args["input"]));
result.ok(message.getInstance().getEmailMessage(result.callbackId, args), false);
}
};

///////////////////////////////////////////////////////////////////
// JavaScript wrapper for JNEXT plugin for connection
///////////////////////////////////////////////////////////////////

JNEXT.Message = function () {
var self = this,
hasInstance = false;

self.getId = function () {
return self.m_id;
};

self.init = function () {
if (!JNEXT.require("libMessageplugin")) {
return false;
}

self.m_id = JNEXT.createObject("libMessageplugin.MessageJS");

if (self.m_id === "") {
return false;
}

JNEXT.registerEvents(self);
};

// ************************
// Enter your methods here
// ************************

// calls into InvokeMethod(string command) in message_js.cpp
self.ping = function () {
return JNEXT.invoke(self.m_id, "ping");
};
self.getEmailMessage = function (callbackId, input) {
return JNEXT.invoke(self.m_id, "getEmailMessage " + callbackId + " " + input);
};

// ************************
// End of methods to edit
// ************************
self.m_id = "";

self.getInstance = function () {
if (!hasInstance) {
hasInstance = true;
self.init();
}
return self;
};

};

message = new JNEXT.Message();